From a40e399a346d4aef26ad6ea583558cdf00751c1f Mon Sep 17 00:00:00 2001 From: Philipp Takacs Date: Fri, 16 Jan 2015 20:48:09 +0100 Subject: [PATCH] Bugfix in pick.c Undo last last commit in uip/pick.c. pick shoud only print "0" if it exit with a non-zero exit. --- uip/pick.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/uip/pick.c b/uip/pick.c index 7c42b42..e94c259 100644 --- a/uip/pick.c +++ b/uip/pick.c @@ -76,7 +76,7 @@ static int pmatches(FILE *, int, long, long); static int listsw = -1; -static void putzero_done(); +static void putzero_done(int) NORETURN; int main(int argc, char **argv) @@ -91,7 +91,7 @@ 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]); @@ -112,7 +112,7 @@ main(int argc, char **argv) case AMBIGSW: ambigsw(cp, switches); listsw = 0; /* HACK */ - exit(1); + done(1); case UNKWNSW: adios(NULL, "-%s unknown", cp); @@ -120,11 +120,11 @@ main(int argc, char **argv) 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: @@ -163,8 +163,7 @@ main(int argc, char **argv) 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; @@ -224,7 +223,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])) - exit(1); + done(1); seq_setprev(mp); /* set the previous-sequence */ /* @@ -239,8 +238,7 @@ main(int argc, char **argv) folder); if (!pcompile(vec, NULL)) - /* sysexits.h EX_USAGE */ - exit(1); + done(1); lo = mp->lowsel; hi = mp->hghsel; @@ -291,8 +289,7 @@ main(int argc, char **argv) */ 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. @@ -305,16 +302,17 @@ main(int argc, char **argv) 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); } -- 1.7.10.4