X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fwhatnowproc.c;h=44146d7e27026d7880aeeb0e6d2e93fbb5500ce9;hp=6bf4b369d47d4907aef58360fa9c248c392fb9d1;hb=a485ed478abbd599d8c9aab48934e7a26733ecb1;hpb=f480c03187724e54e5391ee61b810827da319a6c diff --git a/uip/whatnowproc.c b/uip/whatnowproc.c index 6bf4b36..44146d7 100644 --- a/uip/whatnowproc.c +++ b/uip/whatnowproc.c @@ -1,4 +1,3 @@ - /* * whatnowproc.c -- exec the "whatnowproc" * @@ -25,97 +24,97 @@ int WhatNow (int, char **); int what_now (char *ed, int nedit, int use, char *file, char *altmsg, int dist, - struct msgs *mp, char *text, int inplace, char *cwd) + struct msgs *mp, char *text, int inplace, char *cwd) { - int found, k, msgnum, vecp; - int len, buflen; - register char *bp; - char buffer[BUFSIZ], *vec[MAXARGS]; - - vecp = 0; - vec[vecp++] = r1bindex (whatnowproc, '/'); - vec[vecp] = NULL; - - m_putenv ("mhdraft", file); - if (mp) - m_putenv ("mhfolder", mp->foldpath); - else - unputenv ("mhfolder"); - if (altmsg) { - if (mp == NULL || *altmsg == '/' || cwd == NULL) - m_putenv ("mhaltmsg", altmsg); - else { - snprintf (buffer, sizeof(buffer), "%s/%s", mp->foldpath, altmsg); - m_putenv ("mhaltmsg", buffer); - } - } else { - unputenv ("mhaltmsg"); - } - if ((bp = getenv ("mhaltmsg")))/* XXX */ - m_putenv ("editalt", bp); - snprintf (buffer, sizeof(buffer), "%d", dist); - m_putenv ("mhdist", buffer); - if (nedit) { - unputenv ("mheditor"); - } else { - m_putenv ("mheditor", ed ? ed : (ed = context_find ("editor")) - ? ed : defaulteditor); - } - snprintf (buffer, sizeof(buffer), "%d", use); - m_putenv ("mhuse", buffer); - - unputenv ("mhmessages"); - unputenv ("mhannotate"); - unputenv ("mhinplace"); - - if (text && mp && !is_readonly(mp)) { - found = 0; - bp = buffer; - buflen = sizeof(buffer); - for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg; msgnum++) { - if (is_selected(mp, msgnum)) { - snprintf (bp, buflen, "%s%s", found ? " " : "", m_name (msgnum)); - len = strlen (bp); - bp += len; - buflen -= len; - for (k = msgnum + 1; k <= mp->hghmsg && is_selected(mp, k); k++) - continue; - if (--k > msgnum) { - snprintf (bp, buflen, "-%s", m_name (k)); - len = strlen (bp); - bp += len; - buflen -= len; + int found, k, msgnum, vecp; + int len, buflen; + register char *bp; + char buffer[BUFSIZ], *vec[MAXARGS]; + + vecp = 0; + vec[vecp++] = r1bindex (whatnowproc, '/'); + vec[vecp] = NULL; + + m_putenv ("mhdraft", file); + if (mp) + m_putenv ("mhfolder", mp->foldpath); + else + unputenv ("mhfolder"); + if (altmsg) { + if (mp == NULL || *altmsg == '/' || cwd == NULL) + m_putenv ("mhaltmsg", altmsg); + else { + snprintf (buffer, sizeof(buffer), "%s/%s", mp->foldpath, altmsg); + m_putenv ("mhaltmsg", buffer); } - msgnum = k + 1; - found++; - } + } else { + unputenv ("mhaltmsg"); } - if (found) { - m_putenv ("mhmessages", buffer); - m_putenv ("mhannotate", text); - snprintf (buffer, sizeof(buffer), "%d", inplace); - m_putenv ("mhinplace", buffer); + if ((bp = getenv ("mhaltmsg")))/* XXX */ + m_putenv ("editalt", bp); + snprintf (buffer, sizeof(buffer), "%d", dist); + m_putenv ("mhdist", buffer); + if (nedit) { + unputenv ("mheditor"); + } else { + m_putenv ("mheditor", ed ? ed : (ed = context_find ("editor")) + ? ed : defaulteditor); + } + snprintf (buffer, sizeof(buffer), "%d", use); + m_putenv ("mhuse", buffer); + + unputenv ("mhmessages"); + unputenv ("mhannotate"); + unputenv ("mhinplace"); + + if (text && mp && !is_readonly(mp)) { + found = 0; + bp = buffer; + buflen = sizeof(buffer); + for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg; msgnum++) { + if (is_selected(mp, msgnum)) { + snprintf (bp, buflen, "%s%s", found ? " " : "", m_name (msgnum)); + len = strlen (bp); + bp += len; + buflen -= len; + for (k = msgnum + 1; k <= mp->hghmsg && is_selected(mp, k); k++) + continue; + if (--k > msgnum) { + snprintf (bp, buflen, "-%s", m_name (k)); + len = strlen (bp); + bp += len; + buflen -= len; + } + msgnum = k + 1; + found++; + } + } + if (found) { + m_putenv ("mhmessages", buffer); + m_putenv ("mhannotate", text); + snprintf (buffer, sizeof(buffer), "%d", inplace); + m_putenv ("mhinplace", buffer); + } } - } - context_save (); /* save the context file */ - fflush (stdout); + context_save (); /* save the context file */ + fflush (stdout); - if (cwd) - chdir (cwd); + if (cwd) + chdir (cwd); - /* - * If the "whatnowproc" is the nmh command "whatnow", - * we run it internally, rather than exec'ing it. - */ - if (strcmp (vec[0], "whatnow") == 0) { - WhatNow (vecp, vec); - done (0); - } + /* + * If the "whatnowproc" is the nmh command "whatnow", + * we run it internally, rather than exec'ing it. + */ + if (strcmp (vec[0], "whatnow") == 0) { + WhatNow (vecp, vec); + done (0); + } - execvp (whatnowproc, vec); - fprintf (stderr, "unable to exec "); - perror (whatnowproc); + execvp (whatnowproc, vec); + fprintf (stderr, "unable to exec "); + perror (whatnowproc); - return 0; + return 0; }