static int listsw = -1;
-static void putzero_done();
+static void putzero_done(int) NORETURN;
int
main(int argc, char **argv)
struct msgs *mp;
register FILE *fp;
- atexit(putzero_done);
+ done=putzero_done;
setlocale(LC_ALL, "");
invo_name = mhbasename(argv[0]);
case AMBIGSW:
ambigsw(cp, switches);
listsw = 0; /* HACK */
- exit(1);
+ done(1);
case UNKWNSW:
adios(NULL, "-%s unknown", cp);
snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
print_help(buf, switches, 1);
listsw = 0; /* HACK */
- exit(0);
+ done(1);
case VERSIONSW:
print_version(invo_name);
listsw = 0; /* HACK */
- exit(0);
+ done(1);
case CCSW:
case DATESW:
adios(NULL, "too many sequences (more than %d) specified", NUMATTRS);
if (!seq_nameok(cp))
- /* sysexits.h EX_USAGE */
- exit(1);
+ done(1);
seqs[seqp++] = cp;
continue;
/* parse all the message ranges/sequences and set SELECTED */
for (msgnum = 0; msgnum < msgs.size; msgnum++)
if (!m_convert(mp, msgs.msgs[msgnum]))
- exit(1);
+ done(1);
seq_setprev(mp); /* set the previous-sequence */
/*
folder);
if (!pcompile(vec, NULL))
- /* sysexits.h EX_USAGE */
- exit(1);
+ done(1);
lo = mp->lowsel;
hi = mp->hghsel;
*/
for (seqp = 0; seqs[seqp]; seqp++)
if (!seq_addsel(mp, seqs[seqp], publicsw, zerosw))
- /* sysexits.h EX_IOERR */
- exit(1);
+ done(1);
/*
** Print total matched if not printing each matched message number.
seq_save(mp); /* synchronize message sequences */
context_save(); /* save the context file */
folder_free(mp); /* free folder/message structure */
- return 0;
+ done(0);
+ return 1;
}
static void
-putzero_done()
+putzero_done(int status)
{
- if (listsw && !isatty(fileno(stdout))) {
+ if (listsw && status && !isatty(fileno(stdout)))
printf("0\n");
- }
+ exit(status);
}