X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;ds=sidebyside;f=uip%2Fpick.c;h=07dca9a98b342930cd5f67e16ab308f78518616b;hb=2abb9a7cfb0930e27062088734d306e7d78e4cc2;hp=58c5969ce1900b25c06ca7c56e6d739333e9cf0b;hpb=2f43405ca3cccdfc56faca7a8b6b0d6913cf45aa;p=mmh diff --git a/uip/pick.c b/uip/pick.c index 58c5969..07dca9a 100644 --- a/uip/pick.c +++ b/uip/pick.c @@ -9,6 +9,8 @@ #include #include #include +#include +#include #ifdef HAVE_SYS_TIME_H # include @@ -76,7 +78,7 @@ static int pmatches(FILE *, int, long, long); static int listsw = -1; -static void putzero_done(int) NORETURN; +void putzero_done(); int main(int argc, char **argv) @@ -91,7 +93,9 @@ main(int argc, char **argv) struct msgs *mp; register FILE *fp; - done=putzero_done; + if (atexit(putzero_done) != 0) { + adios(NULL, "atexit failed"); + } setlocale(LC_ALL, ""); invo_name = mhbasename(argv[0]); @@ -112,7 +116,7 @@ main(int argc, char **argv) case AMBIGSW: ambigsw(cp, switches); listsw = 0; /* HACK */ - done(1); + exit(1); case UNKWNSW: adios(NULL, "-%s unknown", cp); @@ -120,11 +124,11 @@ main(int argc, char **argv) snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name); print_help(buf, switches, 1); listsw = 0; /* HACK */ - done(1); + exit(0); case VERSIONSW: print_version(invo_name); listsw = 0; /* HACK */ - done(1); + exit(0); case CCSW: case DATESW: @@ -163,7 +167,7 @@ main(int argc, char **argv) adios(NULL, "too many sequences (more than %d) specified", NUMATTRS); if (!seq_nameok(cp)) - done(1); + exit(1); seqs[seqp++] = cp; continue; @@ -223,7 +227,7 @@ main(int argc, char **argv) /* parse all the message ranges/sequences and set SELECTED */ for (msgnum = 0; msgnum < msgs.size; msgnum++) if (!m_convert(mp, msgs.msgs[msgnum])) - done(1); + exit(1); seq_setprev(mp); /* set the previous-sequence */ /* @@ -238,7 +242,7 @@ main(int argc, char **argv) folder); if (!pcompile(vec, NULL)) - done(1); + exit(1); lo = mp->lowsel; hi = mp->hghsel; @@ -289,7 +293,7 @@ main(int argc, char **argv) */ for (seqp = 0; seqs[seqp]; seqp++) if (!seq_addsel(mp, seqs[seqp], publicsw, zerosw)) - done(1); + exit(1); /* ** Print total matched if not printing each matched message number. @@ -302,17 +306,16 @@ main(int argc, char **argv) seq_save(mp); /* synchronize message sequences */ context_save(); /* save the context file */ folder_free(mp); /* free folder/message structure */ - done(0); - return 1; + listsw = 0; /* HACK */ + return 0; } -static void -putzero_done(int status) +void +putzero_done() { - if (listsw && status && !isatty(fileno(stdout))) + if (listsw && !isatty(fileno(stdout))) printf("0\n"); - exit(status); }