X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/d9c11dfca8a175c98add7e00ce7a39a5fefb7e8c..c3238c0e:/uip/mhlsbr.c?ds=inline diff --git a/uip/mhlsbr.c b/uip/mhlsbr.c index ac5dc89a..e2d97607 100644 --- a/uip/mhlsbr.c +++ b/uip/mhlsbr.c @@ -1,6 +1,4 @@ - -/* - * mhlsbr.c -- main routines for nmh message lister +/* mhlsbr.c -- main routines for nmh message lister * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for @@ -22,7 +20,7 @@ * set, then addresses get split wrong (not at the spaces between commas). * To fix this correctly, putstr() should know about "atomic" strings that * must NOT be broken across lines. That's too difficult for right now - * (it turns out that there are a number of degernate cases), so in + * (it turns out that there are a number of degenerate cases), so in * oneline(), instead of * * (*onelp == '\n' && !onelp[1]) @@ -306,13 +304,6 @@ static char delim4[] = "\n------------------------------\n\n"; 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 */ @@ -367,17 +358,21 @@ mhl (int argc, char **argv) switch (smatch (++cp, mhlswitches)) { case AMBIGSW: ambigsw (cp, mhlswitches); - done (1); + mhldone (1); + /* FALLTHRU */ case UNKWNSW: - adios (NULL, "-%s unknown\n", cp); + mhladios (NULL, "-%s unknown\n", cp); + /* FALLTHRU */ case HELPSW: snprintf (buf, sizeof(buf), "%s [switches] [files ...]", invo_name); print_help (buf, mhlswitches, 1); - done (0); + mhldone (0); + /* FALLTHRU */ case VERSIONSW: print_version(invo_name); - done (0); + mhldone (0); + /* FALLTHRU */ case BELLSW: bellflg = 1; @@ -395,23 +390,23 @@ mhl (int argc, char **argv) case FOLDSW: if (!(folder = *argp++) || *folder == '-') - adios (NULL, "missing argument to %s", argp[-2]); + mhladios (NULL, "missing argument to %s", argp[-2]); continue; case FORMSW: if (!(form = *argp++) || *form == '-') - adios (NULL, "missing argument to %s", argp[-2]); + mhladios (NULL, "missing argument to %s", argp[-2]); continue; case SLEEPSW: if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); + mhladios (NULL, "missing argument to %s", argp[-2]); else sleepsw = atoi (cp);/* ZERO ok! */ continue; case PROGSW: if (!(moreproc = *argp++) || *moreproc == '-') - adios (NULL, "missing argument to %s", argp[-2]); + mhladios (NULL, "missing argument to %s", argp[-2]); continue; case NPROGSW: nomore++; @@ -419,7 +414,7 @@ mhl (int argc, char **argv) case FMTPROCSW: if (!(formatproc = *argp++) || *formatproc == '-') - adios (NULL, "missing argument to %s", argp[-2]); + mhladios (NULL, "missing argument to %s", argp[-2]); continue; case NFMTPROCSW: formatproc = NULL; @@ -427,46 +422,47 @@ mhl (int argc, char **argv) case LENSW: if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); + mhladios (NULL, "missing argument to %s", argp[-2]); else if ((length = atoi (cp)) < 1) - adios (NULL, "bad argument %s %s", argp[-2], cp); + mhladios (NULL, "bad argument %s %s", argp[-2], cp); continue; case WIDTHSW: if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); + mhladios (NULL, "missing argument to %s", argp[-2]); else if ((width = atoi (cp)) < 1) - adios (NULL, "bad argument %s %s", argp[-2], cp); + mhladios (NULL, "bad argument %s %s", argp[-2], cp); continue; case DGSTSW: if (!(digest = *argp++) || *digest == '-') - adios (NULL, "missing argument to %s", argp[-2]); + mhladios (NULL, "missing argument to %s", argp[-2]); continue; case ISSUESW: if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); + mhladios (NULL, "missing argument to %s", argp[-2]); else if ((issue = atoi (cp)) < 1) - adios (NULL, "bad argument %s %s", argp[-2], cp); + mhladios (NULL, "bad argument %s %s", argp[-2], cp); continue; case VOLUMSW: if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); + mhladios (NULL, "missing argument to %s", argp[-2]); else if ((volume = atoi (cp)) < 1) - adios (NULL, "bad argument %s %s", argp[-2], cp); + mhladios (NULL, "bad argument %s %s", argp[-2], cp); continue; case FORW2SW: - forwall++; /* fall */ + forwall++; + /* FALLTHRU */ case FORW1SW: forwflg++; clearflg = -1;/* XXX */ continue; case BITSTUFFSW: - dashstuff = 1; /* trinary logic */ + dashstuff = 1; /* ternary logic */ continue; case NBITSTUFFSW: - dashstuff = -1; /* trinary logic */ + dashstuff = -1; /* ternary logic */ continue; case NBODYSW: @@ -525,12 +521,12 @@ mhl (int argc, char **argv) } else printf ("\n------- End of Forwarded Message%s\n", - vecp > 1 ? "s" : ""); + PLURALS(vecp)); } fflush(stdout); if(ferror(stdout)){ - adios("output", "error writing"); + mhladios("output", "error writing"); } if (clearflg > 0 && ontty == NOTTY) @@ -566,7 +562,7 @@ mhl_format (char *file, int length, int width) } if ((fp = fopen (etcpath (file), "r")) == NULL) - adios (file, "unable to open format file"); + mhladios (file, "unable to open format file"); if (fstat (fileno (fp), &st) != NOTOK) { mtime = st.st_mtime; @@ -592,7 +588,7 @@ mhl_format (char *file, int length, int width) if (*bp == ';') continue; - TrimSuffixC(bp, '\n'); + trim_suffix_c(bp, '\n'); if (*bp == ':') { (void) add_queue (&fmthd, &fmttl, NULL, bp + 1, CLEARTEXT); @@ -629,7 +625,7 @@ mhl_format (char *file, int length, int width) parptr = bp; while (*parptr) { if (evalvar (&global)) - adios (NULL, "format file syntax error: %s", bp); + mhladios (NULL, "format file syntax error: %s", bp); if (*parptr) parptr++; } @@ -640,7 +636,7 @@ mhl_format (char *file, int length, int width) while (*parptr == ':' || *parptr == ',') { parptr++; if (evalvar (c1)) - adios (NULL, "format file syntax error: %s", bp); + mhladios (NULL, "format file syntax error: %s", bp); } if (!c1->c_nfs && global.c_nfs) { if (c1->c_flags & DATEFMT) { @@ -660,7 +656,7 @@ mhl_format (char *file, int length, int width) continue; default: - adios (NULL, "format file syntax error: %s", bp); + mhladios (NULL, "format file syntax error: %s", bp); } } fclose (fp); @@ -773,7 +769,7 @@ evalvar (struct mcomp *c1) return 1; if (! c1->c_name || strcasecmp (c1->c_name, "body")) { - advise (NULL, "format filters are currently only supported on " + inform("format filters are currently only supported on " "the \"body\" component"); return 1; } @@ -804,7 +800,7 @@ ptoi (char *name, int *i) char *cp; if (*parptr++ != '=' || !*(cp = parse ())) { - advise (NULL, "missing argument to variable %s", name); + inform("missing argument to variable %s", name); return 1; } @@ -819,7 +815,7 @@ ptos (char *name, char **s) char c, *cp; if (*parptr++ != '=') { - advise (NULL, "missing argument to variable %s", name); + inform("missing argument to variable %s", name); return 1; } @@ -852,15 +848,14 @@ parse (void) for (cp = result; *parptr && (cp - result < NAMESZ); parptr++) { c = *parptr; - if (isalnum (c) - || c == '.' - || c == '-' - || c == '_' - || c =='[' - || c == ']') - *cp++ = c; - else + if (!isalnum (c) + && c != '.' + && c != '-' + && c != '_' + && c !='[' + && c != ']') break; + *cp++ = c; } *cp = '\0'; @@ -907,7 +902,7 @@ process (char *folder, char *fname, int ofilen, int ofilec) cp = folder ? concat (folder, ":", fname2, NULL) : mh_xstrdup(fname2); if (ontty != PITTY) SIGNAL (SIGINT, intrser); - mhlfile (fp, cp, ofilen, ofilec); /* FALL THROUGH! */ + mhlfile (fp, cp, ofilen, ofilec); free (cp); for (ap = arglist_head; ap; ap = ap->a_next) { @@ -916,7 +911,8 @@ process (char *folder, char *fname, int ofilen, int ofilec) } if (arglist_head) - fmt_free(NULL, 1); + fmt_free(NULL, 1); + /* FALLTHRU */ default: if (ontty != PITTY) @@ -939,7 +935,7 @@ mhlfile (FILE *fp, char *mname, int ofilen, int ofilec) { int state, bucket; struct mcomp *c1, *c2, *c3; - char **ip, name[NAMESZ], buf[BUFSIZ]; + char **ip, name[NAMESZ], buf[NMH_BUFSIZ]; m_getfld_state_t gstate = 0; compile_filterargs(); @@ -950,7 +946,7 @@ mhlfile (FILE *fp, char *mname, int ofilen, int ofilec) else { printf ("\n-------"); if (ofilen == 1) - printf (" Forwarded Message%s", ofilec > 1 ? "s" : ""); + printf (" Forwarded Message%s", PLURALS(ofilec)); else printf (" Message %d", ofilen); printf ("\n\n"); @@ -1023,13 +1019,13 @@ mhlfile (FILE *fp, char *mname, int ofilen, int ofilec) continue; for (c2 = fmthd; c2; c2 = c2->c_next) - if (!strcasecmp (c2->c_name ? c2->c_name : "", name)) + if (!strcasecmp (FENDNULL(c2->c_name), name)) break; c1 = NULL; if (!((c3 = c2 ? c2 : &global)->c_flags & SPLIT)) for (c1 = msghd; c1; c1 = c1->c_next) - if (!strcasecmp (c1->c_name ? c1->c_name : "", - c3->c_name ? c3->c_name : "")) { + if (!strcasecmp (FENDNULL(c1->c_name), + FENDNULL(c3->c_name))) { c1->c_text = mcomp_add (c1->c_flags, buf, c1->c_text); break; @@ -1089,8 +1085,8 @@ mhlfile (FILE *fp, char *mname, int ofilen, int ofilec) continue; } for (c2 = msghd; c2; c2 = c2->c_next) - if (!strcasecmp (c2->c_name ? c2->c_name : "", - c1->c_name ? c1->c_name : "")) { + if (!strcasecmp (FENDNULL(c2->c_name), + FENDNULL(c1->c_name))) { putcomp (c1, c2, ONECOMP); if (!(c1->c_flags & SPLIT)) break; @@ -1101,13 +1097,13 @@ mhlfile (FILE *fp, char *mname, int ofilen, int ofilec) case LENERR: case FMTERR: - advise (NULL, "format error in message %s", mname); + inform("format error in message %s", mname); exitstat++; m_getfld_state_destroy (&gstate); return; default: - adios (NULL, "getfld() returned %d", state); + mhladios (NULL, "getfld() returned %d", state); } } } @@ -1310,7 +1306,7 @@ putcomp (struct mcomp *c1, struct mcomp *c2, int flag) if ((ovtxt = c1->c_ovtxt ? c1->c_ovtxt : global.c_ovtxt) == NULL) ovtxt = ""; if (wid < ovoff + strlen (ovtxt) + 5) - adios (NULL, "component: %s width(%d) too small for overflow(%d)", + mhladios (NULL, "component: %s width(%d) too small for overflow(%d)", c1->c_name, wid, ovoff + strlen (ovtxt) + 5); onelp = NULL; @@ -1337,7 +1333,7 @@ putcomp (struct mcomp *c1, struct mcomp *c2, int flag) if (!(c1->c_flags & HDROUTPUT) && !(c1->c_flags & NOCOMPONENT)) { if (c1->c_flags & UPPERCASE) /* uppercase component also */ - ToUpper(text); + to_upper(text); putstr(text, c1->c_flags); if (flag != BODYCOMP) { putstr (": ", c1->c_flags); @@ -1357,7 +1353,7 @@ putcomp (struct mcomp *c1, struct mcomp *c2, int flag) && !(c2->c_flags & HDROUTPUT) && !(c2->c_flags & NOCOMPONENT)) { if (c1->c_flags & UPPERCASE) - ToUpper(c2->c_name); + to_upper(c2->c_name); putstr (c2->c_name, c1->c_flags); putstr (": ", c1->c_flags); if (!(c1->c_flags & SPLIT)) @@ -1369,7 +1365,7 @@ putcomp (struct mcomp *c1, struct mcomp *c2, int flag) putstr (" ", c1->c_flags); } if (c1->c_flags & UPPERCASE) - ToUpper(c2->c_text); + to_upper(c2->c_text); count = 0; if (cchdr) { @@ -1434,11 +1430,10 @@ oneline (char *stuff, unsigned long flags) *onelp++ = 0; break; } - else - if (!spc) { - *cp++ = ' '; - spc++; - } + if (!spc) { + *cp++ = ' '; + spc++; + } } else { *cp++ = *onelp; @@ -1486,7 +1481,7 @@ putstr (char *string, unsigned long flags) lm = 0; #ifdef MULTIBYTE_SUPPORT - (void) mbtowc (NULL, NULL, 0); /* reset shift state */ + if (mbtowc (NULL, NULL, 0)) {} /* reset shift state */ char_len = 0; #else NMH_UNUSED (char_len); @@ -1595,7 +1590,7 @@ putch (char ch, unsigned long flags) putch ('\n', flags); if (ovoff > 0) lm = ovoff; - putstr (ovtxt ? ovtxt : "", flags); + putstr (FENDNULL(ovtxt), flags); putch (ch, flags); return; } @@ -1624,7 +1619,7 @@ pipeser (int i) { NMH_UNUSED (i); - done (NOTOK); + mhldone (NOTOK); } @@ -1635,13 +1630,10 @@ quitser (int i) putchar ('\n'); fflush (stdout); - done (NOTOK); + mhldone (NOTOK); } -#undef adios -#undef done - static void mhladios (char *what, char *fmt, ...) {