Deleted Added
full compact
cmd2.c (24932) cmd2.c (29574)
1/*
2 * Copyright (c) 1980, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 44 unchanged lines hidden (view full) ---

53int
54next(msgvec)
55 int *msgvec;
56{
57 register struct message *mp;
58 register int *ip, *ip2;
59 int list[2], mdot;
60
1/*
2 * Copyright (c) 1980, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 44 unchanged lines hidden (view full) ---

53int
54next(msgvec)
55 int *msgvec;
56{
57 register struct message *mp;
58 register int *ip, *ip2;
59 int list[2], mdot;
60
61 if (*msgvec != NULL) {
61 if (*msgvec != 0) {
62
63 /*
64 * If some messages were supplied, find the
65 * first applicable one following dot using
66 * wrap around.
67 */
68
69 mdot = dot - &message[0] + 1;
70
71 /*
72 * Find the first message in the supplied
73 * message list which follows dot.
74 */
75
62
63 /*
64 * If some messages were supplied, find the
65 * first applicable one following dot using
66 * wrap around.
67 */
68
69 mdot = dot - &message[0] + 1;
70
71 /*
72 * Find the first message in the supplied
73 * message list which follows dot.
74 */
75
76 for (ip = msgvec; *ip != NULL; ip++)
76 for (ip = msgvec; *ip != 0; ip++)
77 if (*ip > mdot)
78 break;
77 if (*ip > mdot)
78 break;
79 if (*ip == NULL)
79 if (*ip == 0)
80 ip = msgvec;
81 ip2 = ip;
82 do {
83 mp = &message[*ip2 - 1];
84 if ((mp->m_flag & MDELETED) == 0) {
85 dot = mp;
86 goto hitit;
87 }
80 ip = msgvec;
81 ip2 = ip;
82 do {
83 mp = &message[*ip2 - 1];
84 if ((mp->m_flag & MDELETED) == 0) {
85 dot = mp;
86 goto hitit;
87 }
88 if (*ip2 != NULL)
88 if (*ip2 != 0)
89 ip2++;
89 ip2++;
90 if (*ip2 == NULL)
90 if (*ip2 == 0)
91 ip2 = msgvec;
92 } while (ip2 != ip);
93 printf("No messages applicable\n");
94 return(1);
95 }
96
97 /*
98 * If this is the first command, select message 1.

--- 17 unchanged lines hidden (view full) ---

116 }
117 dot = mp;
118hitit:
119 /*
120 * Print dot.
121 */
122
123 list[0] = dot - &message[0] + 1;
91 ip2 = msgvec;
92 } while (ip2 != ip);
93 printf("No messages applicable\n");
94 return(1);
95 }
96
97 /*
98 * If this is the first command, select message 1.

--- 17 unchanged lines hidden (view full) ---

116 }
117 dot = mp;
118hitit:
119 /*
120 * Print dot.
121 */
122
123 list[0] = dot - &message[0] + 1;
124 list[1] = NULL;
124 list[1] = 0;
125 return(type(list));
126}
127
128/*
129 * Save a message in a file. Mark the message as saved
130 * so we can discard when the user quits.
131 */
132int

--- 32 unchanged lines hidden (view full) ---

165 int f, *msgvec;
166 FILE *obuf;
167
168 msgvec = (int *) salloc((msgCount + 2) * sizeof *msgvec);
169 if ((file = snarf(str, &f)) == NOSTR)
170 return(1);
171 if (!f) {
172 *msgvec = first(0, MMNORM);
125 return(type(list));
126}
127
128/*
129 * Save a message in a file. Mark the message as saved
130 * so we can discard when the user quits.
131 */
132int

--- 32 unchanged lines hidden (view full) ---

165 int f, *msgvec;
166 FILE *obuf;
167
168 msgvec = (int *) salloc((msgCount + 2) * sizeof *msgvec);
169 if ((file = snarf(str, &f)) == NOSTR)
170 return(1);
171 if (!f) {
172 *msgvec = first(0, MMNORM);
173 if (*msgvec == NULL) {
173 if (*msgvec == 0) {
174 printf("No messages to %s.\n", cmd);
175 return(1);
176 }
174 printf("No messages to %s.\n", cmd);
175 return(1);
176 }
177 msgvec[1] = NULL;
177 msgvec[1] = 0;
178 }
179 if (f && getmsglist(str, msgvec, 0) < 0)
180 return(1);
181 if ((file = expand(file)) == NOSTR)
182 return(1);
183 printf("\"%s\" ", file);
184 fflush(stdout);
185 if (access(file, 0) >= 0)

--- 100 unchanged lines hidden (view full) ---

286 int list[2];
287 int lastdot;
288
289 lastdot = dot - &message[0] + 1;
290 if (delm(msgvec) >= 0) {
291 list[0] = dot - &message[0] + 1;
292 if (list[0] > lastdot) {
293 touch(dot);
178 }
179 if (f && getmsglist(str, msgvec, 0) < 0)
180 return(1);
181 if ((file = expand(file)) == NOSTR)
182 return(1);
183 printf("\"%s\" ", file);
184 fflush(stdout);
185 if (access(file, 0) >= 0)

--- 100 unchanged lines hidden (view full) ---

286 int list[2];
287 int lastdot;
288
289 lastdot = dot - &message[0] + 1;
290 if (delm(msgvec) >= 0) {
291 list[0] = dot - &message[0] + 1;
292 if (list[0] > lastdot) {
293 touch(dot);
294 list[1] = NULL;
294 list[1] = 0;
295 return(type(list));
296 }
297 printf("At EOF\n");
298 } else
299 printf("No more messages\n");
300 return(0);
301}
302

--- 5 unchanged lines hidden (view full) ---

308int
309delm(msgvec)
310 int *msgvec;
311{
312 register struct message *mp;
313 register *ip;
314 int last;
315
295 return(type(list));
296 }
297 printf("At EOF\n");
298 } else
299 printf("No more messages\n");
300 return(0);
301}
302

--- 5 unchanged lines hidden (view full) ---

308int
309delm(msgvec)
310 int *msgvec;
311{
312 register struct message *mp;
313 register *ip;
314 int last;
315
316 last = NULL;
317 for (ip = msgvec; *ip != NULL; ip++) {
316 last = 0;
317 for (ip = msgvec; *ip != 0; ip++) {
318 mp = &message[*ip - 1];
319 touch(mp);
320 mp->m_flag |= MDELETED|MTOUCH;
321 mp->m_flag &= ~(MPRESERVE|MSAVED|MBOX);
322 last = *ip;
323 }
318 mp = &message[*ip - 1];
319 touch(mp);
320 mp->m_flag |= MDELETED|MTOUCH;
321 mp->m_flag &= ~(MPRESERVE|MSAVED|MBOX);
322 last = *ip;
323 }
324 if (last != NULL) {
324 if (last != 0) {
325 dot = &message[last-1];
326 last = first(0, MDELETED);
325 dot = &message[last-1];
326 last = first(0, MDELETED);
327 if (last != NULL) {
327 if (last != 0) {
328 dot = &message[last-1];
329 return(0);
330 }
331 else {
332 dot = &message[0];
333 return(-1);
334 }
335 }

--- 195 unchanged lines hidden ---
328 dot = &message[last-1];
329 return(0);
330 }
331 else {
332 dot = &message[0];
333 return(-1);
334 }
335 }

--- 195 unchanged lines hidden ---