From: markus schnalke Date: Sat, 14 Feb 2015 16:44:14 +0000 (+0100) Subject: Merge branch 'master' of ssh://marmaro.de:443/var/git/mmh X-Git-Tag: mmh-0.2-RC1~56 X-Git-Url: http://git.marmaro.de/?p=mmh;a=commitdiff_plain;h=5a12e4b0477d3ad699f5713682d26079f2792d17;hp=-c Merge branch 'master' of ssh://marmaro.de:443/var/git/mmh Conflicts: uip/mhl.c uip/mhlist.c uip/mhmail.c uip/pick.c uip/send.c --- 5a12e4b0477d3ad699f5713682d26079f2792d17 diff --combined uip/mhl.c index 8c2e4af,45113f3..5403673 --- a/uip/mhl.c +++ b/uip/mhl.c @@@ -175,17 -175,11 +175,11 @@@ static int num_ignores = 0 static char *ignores[MAXARGS]; static jmp_buf env; - static jmp_buf mhlenv; - - static FILE *(*mhl_action) () = (FILE *(*) ()) 0; - /* ** Redefine a couple of functions. ** These are undefined later in the code. */ - #define adios mhladios - #define done mhldone /* ** prototypes @@@ -208,8 -202,6 +202,6 @@@ static char *oneline(char *, long) static void putstr(char *); static void putch(char); static void intrser(int); - static void mhladios(char *, char *, ...); - static void mhldone(int); int sc_width(void); /* from termsbr.c */ @@@ -239,17 -231,17 +231,17 @@@ main(int argc, char **argv switch (smatch(++cp, switches)) { case AMBIGSW: ambigsw(cp, switches); - done(1); + exit(1); case UNKWNSW: adios(NULL, "-%s unknown\n", cp); case HELPSW: snprintf(buf, sizeof(buf), "%s [switches] [files ...]", invo_name); print_help(buf, switches, 1); - done(1); + exit(0); case VERSIONSW: print_version(invo_name); - done(1); + exit(0); case FORMSW: if (!(form = *argp++) || *form == '-') @@@ -573,10 -565,10 +565,9 @@@ process(char *fname, int ofilen, int of FILE *fp = NULL; struct mcomp *c1; - switch (setjmp(env)) { - case OK: + if (setjmp(env) == 0) { if (fname) { - fp = mhl_action ? (*mhl_action) (fname) : - fopen(fname, "r"); + fp = fopen(fname, "r"); if (fp == NULL) { advise(fname, "unable to open"); exitstat++; @@@ -588,18 -580,20 +579,18 @@@ } SIGNAL(SIGINT, intrser); mhlfile(fp, fname, ofilen, ofilec); - /* FALL THROUGH! */ - default: - SIGNAL(SIGINT, SIG_IGN); - if (fp != stdin) - fclose(fp); - if (holder.c_text) { - free(holder.c_text); - holder.c_text = NULL; - } - free_queue(&msghd, &msgtl); - for (c1 = fmthd; c1; c1 = c1->c_next) - c1->c_flags &= ~HDROUTPUT; - break; } + + SIGNAL(SIGINT, SIG_IGN); - if (mhl_action == NULL && fp != stdin) ++ if (fp != stdin) + fclose(fp); + if (holder.c_text) { + free(holder.c_text); + holder.c_text = NULL; + } + free_queue(&msghd, &msgtl); + for (c1 = fmthd; c1; c1 = c1->c_next) + c1->c_flags &= ~HDROUTPUT; } @@@ -1117,29 -1111,3 +1108,3 @@@ intrser(int i putchar('\n'); longjmp(env, DONE); } - - - #undef adios - #undef done - - static void - mhladios(char *what, char *fmt, ...) - { - va_list ap; - - va_start(ap, fmt); - advertise(what, NULL, fmt, ap); - va_end(ap); - mhldone(1); - } - - - static void - mhldone(int status) - { - exitstat = status; - if (mhl_action) - longjmp(mhlenv, DONE); - else - done(exitstat); - } diff --combined uip/mhmail.c index e79d874,46b16fd..9936261 --- a/uip/mhmail.c +++ b/uip/mhmail.c @@@ -40,6 -40,7 +40,6 @@@ static void intrser(int) int main(int argc, char **argv) { - pid_t child_id; int status, iscc = 0, nvec; char *cp, *tolist = NULL, *cclist = NULL, *subject = NULL; char *from = NULL, *body = NULL, **argp, **arguments; @@@ -65,7 -66,8 +65,8 @@@ switch (smatch(++cp, switches)) { case AMBIGSW: ambigsw(cp, switches); - done(1); + /* sysexits.h EX_USAGE */ + exit(1); case UNKWNSW: adios(NULL, "-%s unknown", cp); @@@ -74,10 -76,10 +75,10 @@@ "%s addrs... [switches]", invo_name); print_help(buf, switches, 0); - done(1); + exit(0); case VERSIONSW: print_version(invo_name); - done(1); + exit(0); case FROMSW: if (!(from = *argp++) || *from == '-') @@@ -159,25 -161,42 +160,26 @@@ vec[nvec++] = tmpfil; vec[nvec] = NULL; - if ((child_id = fork()) == NOTOK) { - /* report failure and then send it */ - adios(NULL, "unable to fork"); - - } else if (child_id == 0) { - /* child process */ - execvp(*vec, vec); - fprintf(stderr, "unable to exec "); - perror(*vec); - _exit(-1); - - } else { - /* parent process */ - if ((status = pidXwait(child_id, *vec))) { - /* spost failed, save draft as dead.letter */ - int in, out; - - in = open(tmpfil, O_RDONLY); - out = creat("dead.letter", 0600); - if (in == -1 || out == -1) { - fprintf(stderr, "Letter left at %s.\n", - tmpfil); - /* sysexits.h exit-status from spost */ - exit(status ? 1 : 0); - } - cpydata(in, out, tmpfil, "dead.letter"); - close(in); - close(out); - fprintf(stderr, "Letter saved in dead.letter\n"); + if ((status = execprog(*vec, vec))) { + /* spost failed, save draft as dead.letter */ + int in, out; + + in = open(tmpfil, O_RDONLY); + out = creat("dead.letter", 0600); + if (in == -1 || out == -1) { + fprintf(stderr, "Letter left at %s.\n", + tmpfil); - done(status ? 1 : 0); ++ /* sysexits.h exit-status from spost */ ++ exit(status ? 1 : 0); } - unlink(tmpfil); - /* sysexits.h exit status from spost */ - exit(status ? 1 : 0); + cpydata(in, out, tmpfil, "dead.letter"); + close(in); + close(out); + fprintf(stderr, "Letter saved in dead.letter\n"); } - - return 0; /* dead code to satisfy the compiler */ + unlink(tmpfil); - done(status ? 1 : 0); - return 0; /* dead code to satisfy the compiler */ ++ /* sysexits.h exit status from spost */ ++ exit(status ? 1 : 0); } @@@ -185,6 -204,6 +187,6 @@@ static voi intrser(int i) { unlink(tmpfil); - done(i != 0 ? 1 : 0); + exit(i != 0 ? 1 : 0); } diff --combined uip/mhparse.c index e187f59,205c41a..f4c26cc --- a/uip/mhparse.c +++ b/uip/mhparse.c @@@ -10,6 -10,7 +10,6 @@@ #include #include #include -#include #include #include #include @@@ -136,7 -137,7 +136,7 @@@ pidcheck(int status fflush(stdout); fflush(stderr); - done(1); + exit(1); return 1; } diff --combined uip/mhstore.c index f28d867,5b56b09..6a268f2 --- a/uip/mhstore.c +++ b/uip/mhstore.c @@@ -10,6 -10,7 +10,6 @@@ #include #include #include -#include #include #include #include @@@ -63,7 -64,7 +63,7 @@@ void flush_errors(void) /* mhfree.c */ void free_content(CT); extern CT *cts; /* The list of top-level contents to display */ - void freects_done(int) NORETURN; + void freects_done(); /* ** static prototypes @@@ -129,7 -130,7 +129,7 @@@ main(int argc, char **argv CT ct, *ctp; FILE *fp; - done=freects_done; + atexit(freects_done); setlocale(LC_ALL, ""); invo_name = mhbasename(argv[0]); @@@ -148,17 -149,17 +148,17 @@@ switch (smatch(++cp, switches)) { case AMBIGSW: ambigsw(cp, switches); - done(1); + exit(1); case UNKWNSW: adios(NULL, "-%s unknown", cp); case HELPSW: snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name); print_help(buf, switches, 1); - done(1); + exit(0); case VERSIONSW: print_version(invo_name); - done(1); + exit(0); case AUTOSW: autosw++; @@@ -285,7 -286,7 +285,7 @@@ /* 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 */ if (!(cts = (CT *) calloc((size_t) (mp->numsel + 1), @@@ -305,7 -306,7 +305,7 @@@ } if (!*cts) - done(1); + exit(1); userrs = 1; SIGNAL(SIGQUIT, quitser); @@@ -346,8 -347,7 +346,7 @@@ context_save(); /* save the context file */ } - done(0); - return 1; + return 0; } @@@ -361,7 -361,7 +360,7 @@@ pipeser(int i fflush(stderr); } - done(1); + exit(1); /* NOTREACHED */ } diff --combined uip/pick.c index 58c5969,ae1fa03..6c59add --- a/uip/pick.c +++ b/uip/pick.c @@@ -76,7 -76,7 +76,7 @@@ static int pmatches(FILE *, int, long, static int listsw = -1; - static void putzero_done(int) NORETURN; + static void putzero_done(); int main(int argc, char **argv) @@@ -91,7 -91,7 +91,7 @@@ struct msgs *mp; register FILE *fp; - done=putzero_done; + atexit(putzero_done); setlocale(LC_ALL, ""); invo_name = mhbasename(argv[0]); @@@ -112,7 -112,7 +112,7 @@@ case AMBIGSW: ambigsw(cp, switches); listsw = 0; /* HACK */ - done(1); + exit(1); case UNKWNSW: adios(NULL, "-%s unknown", cp); @@@ -120,11 -120,11 +120,11 @@@ 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 -163,7 +163,7 @@@ adios(NULL, "too many sequences (more than %d) specified", NUMATTRS); if (!seq_nameok(cp)) - done(1); - exit(1); ++ exit(1); seqs[seqp++] = cp; continue; @@@ -223,7 -223,7 +223,7 @@@ /* 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 -238,7 +238,7 @@@ folder); if (!pcompile(vec, NULL)) - done(1); + exit(1); lo = mp->lowsel; hi = mp->hghsel; @@@ -289,7 -289,7 +289,7 @@@ */ 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 -302,16 +302,16 @@@ 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) + putzero_done() { - if (listsw && status && !isatty(fileno(stdout))) + if (listsw && !isatty(fileno(stdout))) printf("0\n"); - exit(status); } diff --combined uip/prompter.c index ef33db9,03038a6..4d0ce86 --- a/uip/prompter.c +++ b/uip/prompter.c @@@ -71,7 -71,7 +71,7 @@@ main(int argc, char **argv switch (smatch(++cp, switches)) { case AMBIGSW: ambigsw(cp, switches); - done(1); + exit(1); case UNKWNSW: adios(NULL, "-%s unknown", cp); @@@ -80,10 -80,10 +80,10 @@@ "%s [switches] file", invo_name); print_help(buffer, switches, 1); - done(1); + exit(0); case VERSIONSW: print_version(invo_name); - done(1); + exit(0); case PREPSW: prepend++; @@@ -160,7 -160,8 +160,8 @@@ if (i == -1) { abort: unlink(tmpfil); - done(1); + /* sysexits.h EX_DATAERR */ + exit(1); } if (i || (field[0]!='\n' && field[0]!='\0')) { fprintf(out, "%s:", name); @@@ -254,8 -255,7 +255,7 @@@ has_no_body unlink(tmpfil); context_save(); /* save the context file */ - done(0); - return 1; + return 0; } @@@ -269,7 -269,7 +269,7 @@@ getln(char *buffer, int n *cp = '\0'; switch (setjmp(sigenv)) { - case OK: + case 0: wtuser = 1; break; diff --combined uip/send.c index 13ae761,492f027..234dfb2 --- a/uip/send.c +++ b/uip/send.c @@@ -11,7 -11,6 +11,6 @@@ #include #include #include - #include #include #include #include @@@ -28,8 -27,6 +27,6 @@@ char *altmsg = NULL char *annotext = NULL; char *distfile = NULL; - static jmp_buf env; - /* name of temp file for body content */ static char body_file_name[MAXPATHLEN + 1]; /* name of mhbuild composition temporary file */ @@@ -44,7 -41,6 +41,6 @@@ static FILE *composition_file; /* comp ** static prototypes */ static int sendsbr(char **, int, char *, struct stat *); - static void armed_done(int) NORETURN; static void anno(struct stat *); static int sendaux(char **, int, char *, struct stat *); static int attach(char *); @@@ -99,7 -95,7 +95,7 @@@ main(int argc, char **argv switch (smatch(++cp, switches)) { case AMBIGSW: ambigsw(cp, switches); - done(1); + exit(1); case UNKWNSW: adios(NULL, "-%s unknown\n", cp); @@@ -108,10 -104,10 +104,10 @@@ "%s [file] [switches]", invo_name); print_help(buf, switches, 1); - done(1); + exit(0); case VERSIONSW: print_version(invo_name); - done(1); + exit(0); case DEBUGSW: debugsw++; @@@ -150,7 -146,7 +146,7 @@@ /* parse all the msgranges/sequences and set SELECTED */ for (msgnum = 0; msgnum < nmsgs; msgnum++) { if (!m_convert(mp, msgs[msgnum])) { - done(1); + exit(1); } } seq_setprev(mp); @@@ -217,7 -213,7 +213,7 @@@ for (n = 0; n < nfiles; n++) { switch (sendsbr(vec, vecp, files[n], &st)) { case DONE: - done(++status); + exit(++status); case NOTOK: status++; /* fall */ case OK: @@@ -226,8 -222,7 +222,7 @@@ } context_save(); - done(status); - return 1; + return status; } @@@ -288,27 -283,26 +283,22 @@@ sendsbr(char **vec, int vecp, char *drf break; } - done=armed_done; - if (setjmp(env) == 0) { - status = sendaux(vec, vecp, drft, st) ? NOTOK : OK; - if (status == OK) { - /* move original draft to +trash folder */ - /* temporary close stdin, for refile not to ask */ - dupfd = dup(0); - close(0); - if (execprogl("refile", "refile", "-file", - original_draft, "+trash", - (char *)NULL) != 0) { - advise(NULL, "unable to trash the draft"); - } - dup2(dupfd, 0); - close(dupfd); - switch (status = sendaux(vec, vecp, drft, st)) { - case OK: ++ if ((status = sendaux(vec, vecp, drft, st)) == OK) { + /* move original draft to +trash folder */ + /* temporary close stdin, for refile not to ask */ + dupfd = dup(0); + close(0); + if (execprogl("refile", "refile", "-file", + original_draft, "+trash", + (char *)NULL) != 0) { + advise(NULL, "unable to trash the draft"); } + dup2(dupfd, 0); + close(dupfd); - break; - - default: + } else { status = DONE; - break; } - done=exit; if (distfile) { unlink(distfile); } @@@ -624,15 -618,15 +614,15 @@@ sendaux(char **vec, int vecp, char *drf vec[vecp++] = drft; if (distfile && distout(drft, distfile, backup) == NOTOK) { - done(1); + return DONE; } vec[vecp] = NULL; switch (child_id = fork()) { case -1: /* oops -- fork error */ - adios("fork", "unable to"); - break; /* NOT REACHED */ + advise("fork", "unable to"); + return DONE; case 0: /* child process -- send it */ @@@ -663,7 -657,7 +653,7 @@@ } - return status; + return status ? NOTOK : status; } @@@ -745,12 -739,3 +735,3 @@@ strexit(int status return "message not delivered to anyone"; } } - - - static void - armed_done(int status) - { - longjmp(env, status ? status : NOTOK); - - exit(status); - }