From ec18722d02bd307bd09f30715dc8ba4e1b8a6716 Mon Sep 17 00:00:00 2001 From: Ralph Corderoy Date: Sun, 13 Aug 2017 15:20:14 +0100 Subject: [PATCH 01/16] m_getfld() et al: Replace with m_getfld2(), etc., in many places. The difference is the FILE pointer isn't passed in on each call. Instead, it's stored in the m_getfld_state_t once, on m_getfld_state_init(). No functional change intended. --- h/oauth.h | 2 +- sbr/m_getfld.c | 11 +++++++---- sbr/oauth.c | 9 +++++---- sbr/readconfig.c | 7 ++++--- sbr/seq_read.c | 9 +++++---- uip/distsbr.c | 16 +++++++++------- uip/fmttest.c | 11 ++++++----- uip/forwsbr.c | 11 ++++++----- uip/mhbuildsbr.c | 15 ++++++++------- uip/mhcachesbr.c | 7 ++++--- uip/mhfixmsg.c | 7 ++++--- uip/mhlsbr.c | 25 +++++++++++++------------ uip/mhparse.c | 9 +++++---- uip/new.c | 9 +++++---- uip/picksbr.c | 7 ++++--- uip/post.c | 9 +++++---- uip/prompter.c | 9 +++++---- uip/rcvdist.c | 11 ++++++----- uip/replsbr.c | 11 ++++++----- uip/sendsbr.c | 22 ++++++++++++---------- uip/show.c | 12 ++++++------ uip/slocal.c | 18 ++++++++++-------- uip/sortm.c | 11 ++++++----- uip/whatnowsbr.c | 5 +++-- 24 files changed, 145 insertions(+), 118 deletions(-) diff --git a/h/oauth.h b/h/oauth.h index 42c9ce7c..66da2f31 100644 --- a/h/oauth.h +++ b/h/oauth.h @@ -234,7 +234,7 @@ mh_oauth_cred_save(FILE *fp, mh_oauth_cred *cred, const char *user); /* * Load OAuth tokens from file. * - * Calls m_getfld(), which writes to stderr with advise(). + * Calls m_getfld2(), which writes to stderr with advise(). * * On error, return NULL. */ diff --git a/sbr/m_getfld.c b/sbr/m_getfld.c index f674792e..eb377411 100644 --- a/sbr/m_getfld.c +++ b/sbr/m_getfld.c @@ -60,10 +60,13 @@ Usage ===== - m_getfld_state_t gstate = 0; - ... - int state = m_getfld (&gstate, ...); - ... + m_getfld_state_t gstate; + + gstate = m_getfld_state_init(mailfp); + Perhaps m_getfld_track_filepos2(&gstate); + ... + state = m_getfld2(&gstate, ...); + ...Repeat until finished with mailfp. m_getfld_state_destroy (&gstate); The state is retained internally by gstate. To reset its state to FLD: diff --git a/sbr/oauth.c b/sbr/oauth.c index 89288c1e..8e3d6b05 100755 --- a/sbr/oauth.c +++ b/sbr/oauth.c @@ -616,7 +616,7 @@ load_creds(struct user_creds **result, FILE *fp, mh_oauth_ctx *ctx) boolean success = FALSE; char name[NAMESZ], value_buf[BUFSIZ]; int state; - m_getfld_state_t getfld_ctx = 0; + m_getfld_state_t getfld_ctx; struct user_creds *user_creds; NEW(user_creds); @@ -624,9 +624,10 @@ load_creds(struct user_creds **result, FILE *fp, mh_oauth_ctx *ctx) user_creds->len = 0; user_creds->creds = mh_xmalloc(user_creds->alloc * sizeof *user_creds->creds); + getfld_ctx = m_getfld_state_init(fp); for (;;) { int size = sizeof value_buf; - switch (state = m_getfld(&getfld_ctx, name, value_buf, &size, fp)) { + switch (state = m_getfld2(&getfld_ctx, name, value_buf, &size)) { case FLD: case FLDPLUS: { char **save, *expire; @@ -658,7 +659,7 @@ load_creds(struct user_creds **result, FILE *fp, mh_oauth_ctx *ctx) char *tmp = getcpy(value_buf); while (state == FLDPLUS) { size = sizeof value_buf; - state = m_getfld(&getfld_ctx, name, value_buf, &size, fp); + state = m_getfld2(&getfld_ctx, name, value_buf, &size); tmp = add(value_buf, tmp); } *save = trimcpy(tmp); @@ -684,7 +685,7 @@ load_creds(struct user_creds **result, FILE *fp, mh_oauth_ctx *ctx) break; default: - /* Not adding details for LENERR/FMTERR because m_getfld already + /* Not adding details for LENERR/FMTERR because m_getfld2 already * wrote advise message to stderr. */ set_err(ctx, MH_OAUTH_CRED_FILE); break; diff --git a/sbr/readconfig.c b/sbr/readconfig.c index 53f5c353..d737a2a0 100644 --- a/sbr/readconfig.c +++ b/sbr/readconfig.c @@ -47,16 +47,17 @@ readconfig (struct node **npp, FILE *ib, const char *file, int ctx) char name[NAMESZ], field[NMH_BUFSIZ]; struct node *np; struct procstr *ps; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; if (npp == NULL && (npp = opp) == NULL) { inform("bug: readconfig called but pump not primed, continuing..."); return; } + gstate = m_getfld_state_init(ib); for (;;) { int fieldsz = sizeof field; - switch (state = m_getfld (&gstate, name, field, &fieldsz, ib)) { + switch (state = m_getfld2(&gstate, name, field, &fieldsz)) { case FLD: case FLDPLUS: NEW(np); @@ -67,7 +68,7 @@ readconfig (struct node **npp, FILE *ib, const char *file, int ctx) cp = mh_xstrdup(field); while (state == FLDPLUS) { fieldsz = sizeof field; - state = m_getfld (&gstate, name, field, &fieldsz, ib); + state = m_getfld2(&gstate, name, field, &fieldsz); cp = add (field, cp); } np->n_field = trimcpy (cp); diff --git a/sbr/seq_read.c b/sbr/seq_read.c index c9cc9240..39192605 100644 --- a/sbr/seq_read.c +++ b/sbr/seq_read.c @@ -63,7 +63,7 @@ seq_public (struct msgs *mp, int lockflag, int *failed_to_lock) char *cp, seqfile[PATH_MAX]; char name[NAMESZ], field[NMH_BUFSIZ]; FILE *fp; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; /* * If mh_seq == NULL or if *mh_seq == '\0' (the user has defined @@ -80,17 +80,18 @@ seq_public (struct msgs *mp, int lockflag, int *failed_to_lock) == NULL) return NOTOK; - /* Use m_getfld to scan sequence file */ + /* Use m_getfld2 to scan sequence file */ + gstate = m_getfld_state_init(fp); for (;;) { int fieldsz = sizeof field; - switch (state = m_getfld (&gstate, name, field, &fieldsz, fp)) { + switch (state = m_getfld2(&gstate, name, field, &fieldsz)) { case FLD: case FLDPLUS: if (state == FLDPLUS) { cp = mh_xstrdup(field); while (state == FLDPLUS) { fieldsz = sizeof field; - state = m_getfld (&gstate, name, field, &fieldsz, fp); + state = m_getfld2(&gstate, name, field, &fieldsz); cp = add (field, cp); } seq_init (mp, mh_xstrdup(name), trimcpy (cp)); diff --git a/uip/distsbr.c b/uip/distsbr.c index c9f6656b..f29426e2 100644 --- a/uip/distsbr.c +++ b/uip/distsbr.c @@ -30,7 +30,7 @@ distout (char *drft, char *msgnam, char *backup) char *dp, *resent; char name[NAMESZ], buffer[NMH_BUFSIZ]; FILE *ifp, *ofp; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; if (rename (drft, strcpy (backup, m_backup (drft))) == NOTOK) adios (backup, "unable to rename %s to",drft); @@ -45,9 +45,10 @@ distout (char *drft, char *msgnam, char *backup) lseek(hdrfd, 0, SEEK_SET); /* msgnam not accurate */ cpydata (hdrfd, fileno (ofp), msgnam, drft); + gstate = m_getfld_state_init(ifp); for (resent = NULL;;) { int buffersz = sizeof buffer; - switch (state = m_getfld (&gstate, name, buffer, &buffersz, ifp)) { + switch (state = m_getfld2(&gstate, name, buffer, &buffersz)) { case FLD: case FLDPLUS: if (uprf (name, "distribute-")) @@ -64,7 +65,7 @@ distout (char *drft, char *msgnam, char *backup) fprintf (ofp, "%s: %s", name, buffer); while (state == FLDPLUS) { buffersz = sizeof buffer; - state = m_getfld (&gstate, name, buffer, &buffersz, ifp); + state = m_getfld2(&gstate, name, buffer, &buffersz); resent = add (buffer, resent); fputs (buffer, ofp); } @@ -128,7 +129,7 @@ ready_msg (char *msgnam) char name[NAMESZ], buffer[NMH_BUFSIZ], tmpfil[BUFSIZ]; FILE *ifp, *ofp; char *cp = NULL; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; if (hdrfd != NOTOK) { close (hdrfd); @@ -152,9 +153,10 @@ ready_msg (char *msgnam) adios (NULL, "no file descriptors -- you lose big"); (void) m_unlink (tmpfil); + gstate = m_getfld_state_init(ifp); for (;;) { int buffersz = sizeof buffer; - switch (state = m_getfld (&gstate, name, buffer, &buffersz, ifp)) { + switch (state = m_getfld2(&gstate, name, buffer, &buffersz)) { case FLD: case FLDPLUS: if (uprf (name, "resent")) @@ -162,7 +164,7 @@ ready_msg (char *msgnam) fprintf (ofp, "%s: %s", name, buffer); while (state == FLDPLUS) { buffersz = sizeof buffer; - state = m_getfld (&gstate, name, buffer, &buffersz, ifp); + state = m_getfld2(&gstate, name, buffer, &buffersz); fputs (buffer, ofp); } break; @@ -184,7 +186,7 @@ ready_msg (char *msgnam) fprintf (ofp, "\n%s", buffer); while (state == BODY) { buffersz = sizeof buffer; - state = m_getfld (&gstate, name, buffer, &buffersz, ifp); + state = m_getfld2(&gstate, name, buffer, &buffersz); fputs (buffer, ofp); } case FILEEOF: diff --git a/uip/fmttest.c b/uip/fmttest.c index 3dfdf9b6..d848bea0 100644 --- a/uip/fmttest.c +++ b/uip/fmttest.c @@ -584,7 +584,7 @@ process_single_file(FILE *in, struct msgs_array *comps, int *dat, int msgsize, { int i, state; char name[NAMESZ], rbuf[NMH_BUFSIZ]; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; struct comp *c; int bufsz; @@ -616,9 +616,10 @@ process_single_file(FILE *in, struct msgs_array *comps, int *dat, int msgsize, * Read in the message and process the components */ + gstate = m_getfld_state_init(in); for (;;) { bufsz = sizeof(rbuf); - state = m_getfld(&gstate, name, rbuf, &bufsz, in); + state = m_getfld2(&gstate, name, rbuf, &bufsz); switch (state) { case FLD: case FLDPLUS: @@ -626,14 +627,14 @@ process_single_file(FILE *in, struct msgs_array *comps, int *dat, int msgsize, if (i != -1) { while (state == FLDPLUS) { bufsz = sizeof(rbuf); - state = m_getfld(&gstate, name, rbuf, &bufsz, in); + state = m_getfld2(&gstate, name, rbuf, &bufsz); fmt_appendcomp(i, name, rbuf); } } while (state == FLDPLUS) { bufsz = sizeof(rbuf); - state = m_getfld(&gstate, name, rbuf, &bufsz, in); + state = m_getfld2(&gstate, name, rbuf, &bufsz); } break; @@ -641,7 +642,7 @@ process_single_file(FILE *in, struct msgs_array *comps, int *dat, int msgsize, if (fmt_findcomp("body")) { if ((i = strlen(rbuf)) < outwidth) { bufsz = min (outwidth, (int) sizeof rbuf - i); - m_getfld(&gstate, name, rbuf + i, &bufsz, in); + m_getfld2(&gstate, name, rbuf + i, &bufsz); } fmt_addcomptext("body", rbuf); diff --git a/uip/forwsbr.c b/uip/forwsbr.c index 4f76c386..bce58aee 100644 --- a/uip/forwsbr.c +++ b/uip/forwsbr.c @@ -54,7 +54,7 @@ build_form (char *form, char *digest, int *dat, char *from, char *to, struct comp *cptr; struct format *fmt; char *cp = NULL; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; /* * Open the message we'll be scanning for components @@ -87,9 +87,10 @@ build_form (char *form, char *digest, int *dat, char *from, char *to, * these routines? */ + gstate = m_getfld_state_init(tmp); for (;;) { int msg_count = sizeof msgbuf; - state = m_getfld (&gstate, name, msgbuf, &msg_count, tmp); + state = m_getfld2(&gstate, name, msgbuf, &msg_count); switch (state) { case FLD: case FLDPLUS: @@ -103,13 +104,13 @@ build_form (char *form, char *digest, int *dat, char *from, char *to, if (i != -1) { while (state == FLDPLUS) { msg_count = sizeof msgbuf; - state = m_getfld (&gstate, name, msgbuf, &msg_count, tmp); + state = m_getfld2(&gstate, name, msgbuf, &msg_count); fmt_appendcomp(i, name, msgbuf); } } while (state == FLDPLUS) { msg_count = sizeof msgbuf; - state = m_getfld (&gstate, name, msgbuf, &msg_count, tmp); + state = m_getfld2(&gstate, name, msgbuf, &msg_count); } break; @@ -120,7 +121,7 @@ build_form (char *form, char *digest, int *dat, char *from, char *to, goto finished; default: - adios(NULL, "m_getfld() returned %d", state); + adios(NULL, "m_getfld2() returned %d", state); } } diff --git a/uip/mhbuildsbr.c b/uip/mhbuildsbr.c index e34dd978..7fc0111f 100644 --- a/uip/mhbuildsbr.c +++ b/uip/mhbuildsbr.c @@ -134,7 +134,7 @@ build_mime (char *infile, int autobuild, int dist, int directives, CT ct; FILE *in; HF hp; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; struct attach_list *attach_head = NULL, *attach_tail = NULL, *at_entry; convert_list *convert_head = NULL, *convert_tail = NULL, *convert; @@ -163,10 +163,11 @@ build_mime (char *infile, int autobuild, int dist, int directives, * draft into the linked list of header fields for * the new MIME message. */ - m_getfld_track_filepos (&gstate, in); + gstate = m_getfld_state_init(in); + m_getfld_track_filepos2(&gstate); for (compnum = 1;;) { int bufsz = sizeof buf; - switch (state = m_getfld (&gstate, name, buf, &bufsz, in)) { + switch (state = m_getfld2(&gstate, name, buf, &bufsz)) { case FLD: case FLDPLUS: compnum++; @@ -186,7 +187,7 @@ build_mime (char *infile, int autobuild, int dist, int directives, if (!strcasecmp (name, TYPE_FIELD)) { while (state == FLDPLUS) { bufsz = sizeof buf; - state = m_getfld (&gstate, name, buf, &bufsz, in); + state = m_getfld2(&gstate, name, buf, &bufsz); } goto finish_field; } @@ -198,7 +199,7 @@ build_mime (char *infile, int autobuild, int dist, int directives, /* if necessary, get rest of field */ while (state == FLDPLUS) { bufsz = sizeof buf; - state = m_getfld (&gstate, name, buf, &bufsz, in); + state = m_getfld2(&gstate, name, buf, &bufsz); vp = add (buf, vp); /* add to previous value */ } @@ -249,7 +250,7 @@ build_mime (char *infile, int autobuild, int dist, int directives, char *type = np + strlen (MHBUILD_FILE_PSEUDOHEADER); char *filename = vp; - /* vp should begin with a space because m_getfld() + /* vp should begin with a space because m_getfld2() includes the space after the colon in buf. */ while (isspace((unsigned char) *filename)) { ++filename; } /* Trim trailing newline and any other whitespace. */ @@ -289,7 +290,7 @@ build_mime (char *infile, int autobuild, int dist, int directives, char *type = np + strlen (MHBUILD_ARGS_PSEUDOHEADER); char *argstring = vp; - /* vp should begin with a space because m_getfld() + /* vp should begin with a space because m_getfld2() includes the space after the colon in buf. */ while (isspace((unsigned char) *argstring)) { ++argstring; } /* Trim trailing newline and any other whitespace. */ diff --git a/uip/mhcachesbr.c b/uip/mhcachesbr.c index f343bf39..0c61fc0f 100644 --- a/uip/mhcachesbr.c +++ b/uip/mhcachesbr.c @@ -369,18 +369,19 @@ find_cache_aux2 (char *mapfile, char *id, char *mapname, int namelen) int state; char buf[NMH_BUFSIZ], name[NAMESZ]; FILE *fp; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; int failed_to_lock = 0; if (!(fp = lkfopendata (mapfile, "r", &failed_to_lock))) return NOTOK; + gstate = m_getfld_state_init(fp); for (;;) { int result; char *cp, *dp; int bufsz = sizeof buf; - switch (state = m_getfld (&gstate, name, buf, &bufsz, fp)) { + switch (state = m_getfld2(&gstate, name, buf, &bufsz)) { case FLD: case FLDPLUS: strncpy (mapname, name, namelen); @@ -390,7 +391,7 @@ find_cache_aux2 (char *mapfile, char *id, char *mapname, int namelen) cp = mh_xstrdup(buf); while (state == FLDPLUS) { bufsz = sizeof buf; - state = m_getfld (&gstate, name, buf, &bufsz, fp); + state = m_getfld2(&gstate, name, buf, &bufsz); cp = add (buf, cp); } } diff --git a/uip/mhfixmsg.c b/uip/mhfixmsg.c index aed480ea..2737dac8 100644 --- a/uip/mhfixmsg.c +++ b/uip/mhfixmsg.c @@ -818,7 +818,7 @@ replace_boundary (CT ct, char *file, char *boundary) { int compnum, state; char buf[NMH_BUFSIZ], name[NAMESZ]; char *np, *vp; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; int status = OK; if (ct->c_file == NULL) { @@ -837,10 +837,11 @@ replace_boundary (CT ct, char *file, char *boundary) { return NOTOK; } + gstate = m_getfld_state_init(fpin); for (compnum = 1;;) { int bufsz = (int) sizeof buf; - switch (state = m_getfld (&gstate, name, buf, &bufsz, fpin)) { + switch (state = m_getfld2(&gstate, name, buf, &bufsz)) { case FLD: case FLDPLUS: compnum++; @@ -852,7 +853,7 @@ replace_boundary (CT ct, char *file, char *boundary) { /* if necessary, get rest of field */ while (state == FLDPLUS) { bufsz = sizeof buf; - state = m_getfld (&gstate, name, buf, &bufsz, fpin); + state = m_getfld2(&gstate, name, buf, &bufsz); vp = add (buf, vp); /* add to previous value */ } diff --git a/uip/mhlsbr.c b/uip/mhlsbr.c index a4402c56..e16f31d9 100644 --- a/uip/mhlsbr.c +++ b/uip/mhlsbr.c @@ -329,7 +329,7 @@ static void pipeser (int); static void quitser (int); static void mhladios (char *, char *, ...); static void mhldone (int); -static void filterbody (struct mcomp *, char *, int, int, FILE *, +static void filterbody (struct mcomp *, char *, int, int, m_getfld_state_t); static void compile_formatfield(struct mcomp *); static void compile_filterargs (void); @@ -937,7 +937,7 @@ mhlfile (FILE *fp, char *mname, int ofilen, int ofilec) int state, bucket; struct mcomp *c1, *c2, *c3; char **ip, name[NAMESZ], buf[NMH_BUFSIZ]; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; compile_filterargs(); @@ -1001,9 +1001,10 @@ mhlfile (FILE *fp, char *mname, int ofilen, int ofilec) } } + gstate = m_getfld_state_init(fp); for (;;) { int bufsz = sizeof buf; - switch (state = m_getfld (&gstate, name, buf, &bufsz, fp)) { + switch (state = m_getfld2(&gstate, name, buf, &bufsz)) { case FLD: case FLDPLUS: bucket = fmt_addcomptext(name, buf); @@ -1011,7 +1012,7 @@ mhlfile (FILE *fp, char *mname, int ofilen, int ofilec) if (!strcasecmp (name, *ip)) { while (state == FLDPLUS) { bufsz = sizeof buf; - state = m_getfld (&gstate, name, buf, &bufsz, fp); + state = m_getfld2(&gstate, name, buf, &bufsz); fmt_appendcomp(bucket, name, buf); } break; @@ -1035,7 +1036,7 @@ mhlfile (FILE *fp, char *mname, int ofilen, int ofilec) c1 = add_queue (&msghd, &msgtl, name, buf, 0); while (state == FLDPLUS) { bufsz = sizeof buf; - state = m_getfld (&gstate, name, buf, &bufsz, fp); + state = m_getfld2(&gstate, name, buf, &bufsz); c1->c_text = add (buf, c1->c_text); fmt_appendcomp(bucket, name, buf); } @@ -1070,15 +1071,15 @@ mhlfile (FILE *fp, char *mname, int ofilen, int ofilec) !strcasecmp (c1->c_name, "body"))) { if (c1->c_flags & FMTFILTER && state == BODY && formatproc != NULL) { - filterbody(c1, buf, sizeof(buf), state, fp, gstate); + filterbody(c1, buf, sizeof(buf), state, gstate); } else { holder.c_text = mh_xmalloc (sizeof(buf)); strncpy (holder.c_text, buf, sizeof(buf)); while (state == BODY) { putcomp (c1, &holder, BODYCOMP); bufsz = sizeof buf; - state = m_getfld (&gstate, name, holder.c_text, - &bufsz, fp); + state = m_getfld2(&gstate, name, holder.c_text, + &bufsz); } free (holder.c_text); holder.c_text = NULL; @@ -1726,8 +1727,8 @@ compile_filterargs (void) */ static void -filterbody (struct mcomp *c1, char *buf, int bufsz, int state, FILE *fp, - m_getfld_state_t gstate) +filterbody (struct mcomp *c1, char *buf, int bufsz, int state, + m_getfld_state_t gstate) { struct mcomp holder; char name[NAMESZ]; @@ -1777,7 +1778,7 @@ filterbody (struct mcomp *c1, char *buf, int bufsz, int state, FILE *fp, close(fdoutput[1]); /* - * Call m_getfld() until we're no longer in the BODY state + * Call m_getfld2() until we're no longer in the BODY state */ while (state == BODY) { @@ -1785,7 +1786,7 @@ filterbody (struct mcomp *c1, char *buf, int bufsz, int state, FILE *fp, if (write(fdinput[1], buf, strlen(buf)) < 0) { advise ("pipe output", "write"); } - state = m_getfld (&gstate, name, buf, &bufsz2, fp); + state = m_getfld2(&gstate, name, buf, &bufsz2); } /* diff --git a/uip/mhparse.c b/uip/mhparse.c index 76dd7f71..74e03a7e 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -295,7 +295,7 @@ get_content (FILE *in, char *file, int toplevel) char *np, *vp; CT ct; HF hp; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; /* allocate the content structure */ NEW0(ct); @@ -307,10 +307,11 @@ get_content (FILE *in, char *file, int toplevel) * Parse the header fields for this * content into a linked list. */ - m_getfld_track_filepos (&gstate, in); + gstate = m_getfld_state_init(in); + m_getfld_track_filepos2(&gstate); for (compnum = 1;;) { int bufsz = sizeof buf; - switch (state = m_getfld (&gstate, name, buf, &bufsz, in)) { + switch (state = m_getfld2(&gstate, name, buf, &bufsz)) { case FLD: case FLDPLUS: compnum++; @@ -322,7 +323,7 @@ get_content (FILE *in, char *file, int toplevel) /* if necessary, get rest of field */ while (state == FLDPLUS) { bufsz = sizeof buf; - state = m_getfld (&gstate, name, buf, &bufsz, in); + state = m_getfld2(&gstate, name, buf, &bufsz); vp = add (buf, vp); /* add to previous value */ } diff --git a/uip/new.c b/uip/new.c index c82979ec..f9549331 100644 --- a/uip/new.c +++ b/uip/new.c @@ -102,7 +102,7 @@ get_msgnums(char *folder, char *sequences[]) char *cp; char *msgnums = NULL, *this_msgnums, *old_msgnums; int failed_to_lock = 0; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; /* copied from seq_read.c:seq_public */ /* @@ -129,17 +129,18 @@ get_msgnums(char *folder, char *sequences[]) } } - /* Use m_getfld to scan sequence file */ + /* Use m_getfld2 to scan sequence file */ + gstate = m_getfld_state_init(fp); for (;;) { int fieldsz = sizeof field; - switch (state = m_getfld (&gstate, name, field, &fieldsz, fp)) { + switch (state = m_getfld2(&gstate, name, field, &fieldsz)) { case FLD: case FLDPLUS: if (state == FLDPLUS) { cp = getcpy (field); while (state == FLDPLUS) { fieldsz = sizeof field; - state = m_getfld (&gstate, name, field, &fieldsz, fp); + state = m_getfld2(&gstate, name, field, &fieldsz); cp = add (field, cp); } diff --git a/uip/picksbr.c b/uip/picksbr.c index ca330b96..3f8a17c2 100644 --- a/uip/picksbr.c +++ b/uip/picksbr.c @@ -925,20 +925,21 @@ TWSaction(struct nexus *n, FILE *fp, int msgnum, long start, long stop) char *bp; char buf[NMH_BUFSIZ], name[NAMESZ]; struct tws *tw; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; NMH_UNUSED (stop); fseek (fp, start, SEEK_SET); + gstate = m_getfld_state_init(fp); for (bp = NULL;;) { int bufsz = sizeof buf; - switch (state = m_getfld (&gstate, name, buf, &bufsz, fp)) { + switch (state = m_getfld2(&gstate, name, buf, &bufsz)) { case FLD: case FLDPLUS: mh_xfree(bp); bp = mh_xstrdup(buf); while (state == FLDPLUS) { bufsz = sizeof buf; - state = m_getfld (&gstate, name, buf, &bufsz, fp); + state = m_getfld2(&gstate, name, buf, &bufsz); bp = add (buf, bp); } if (!strcasecmp (name, n->n_datef)) diff --git a/uip/post.c b/uip/post.c index 9282a71c..5f70e62f 100644 --- a/uip/post.c +++ b/uip/post.c @@ -323,7 +323,7 @@ main (int argc, char **argv) char *cp, *msg = NULL, **argp, **arguments, *envelope; char buf[NMH_BUFSIZ], name[NAMESZ], *auth_svc = NULL; FILE *in, *out; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; if (nmh_init(argv[0], 0 /* use context_foil() */)) { return 1; } @@ -619,16 +619,17 @@ main (int argc, char **argv) hdrtab = msgstate == NORMAL ? NHeaders : RHeaders; + gstate = m_getfld_state_init(in); for (compnum = 1;;) { int bufsz = sizeof buf; - switch (state = m_getfld (&gstate, name, buf, &bufsz, in)) { + switch (state = m_getfld2(&gstate, name, buf, &bufsz)) { case FLD: case FLDPLUS: compnum++; cp = mh_xstrdup(buf); while (state == FLDPLUS) { bufsz = sizeof buf; - state = m_getfld (&gstate, name, buf, &bufsz, in); + state = m_getfld2(&gstate, name, buf, &bufsz); cp = add (buf, cp); } putfmt (name, cp, &eai, out); @@ -642,7 +643,7 @@ main (int argc, char **argv) fprintf (out, "\n%s", buf); while (state == BODY) { bufsz = sizeof buf; - state = m_getfld (&gstate, name, buf, &bufsz, in); + state = m_getfld2(&gstate, name, buf, &bufsz); fputs (buf, out); } break; diff --git a/uip/prompter.c b/uip/prompter.c index 303d2ad4..5c4926a0 100644 --- a/uip/prompter.c +++ b/uip/prompter.c @@ -64,7 +64,7 @@ main (int argc, char **argv) char **arguments, **argp; FILE *in, *out; char *tmpfil; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; if (nmh_init(argv[0], 2)) { return 1; } @@ -182,9 +182,10 @@ main (int argc, char **argv) /* * Loop through the lines of the draft skeleton. */ + gstate = m_getfld_state_init(in); for (;;) { int fieldsz = sizeof field; - switch (state = m_getfld (&gstate, name, field, &fieldsz, in)) { + switch (state = m_getfld2(&gstate, name, field, &fieldsz)) { case FLD: case FLDPLUS: /* @@ -201,7 +202,7 @@ main (int argc, char **argv) fprintf (out, "%s:%s", name, field); while (state == FLDPLUS) { fieldsz = sizeof field; - state = m_getfld (&gstate, name, field, &fieldsz, in); + state = m_getfld2(&gstate, name, field, &fieldsz); fputs(field, stdout); fputs(field, out); } @@ -260,7 +261,7 @@ abort: fputs(field, stdout); } while (state == BODY && (fieldsz = sizeof field, - state = m_getfld (&gstate, name, field, &fieldsz, in))); + state = m_getfld2(&gstate, name, field, &fieldsz))); if (prepend || !body) break; else diff --git a/uip/rcvdist.c b/uip/rcvdist.c index 1ad585d2..a123f8e9 100644 --- a/uip/rcvdist.c +++ b/uip/rcvdist.c @@ -177,7 +177,7 @@ rcvdistout (FILE *inb, char *form, char *addrs) charstring_t scanl; struct comp *cptr; FILE *out; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; if (!(out = fopen (drft, "w"))) adios (drft, "unable to create"); @@ -197,9 +197,10 @@ rcvdistout (FILE *inb, char *form, char *addrs) if (cptr) cptr->c_text = addrs; + gstate = m_getfld_state_init(inb); for (;;) { int msg_count = sizeof tmpbuf; - switch (state = m_getfld (&gstate, name, tmpbuf, &msg_count, inb)) { + switch (state = m_getfld2(&gstate, name, tmpbuf, &msg_count)) { case FLD: case FLDPLUS: i = fmt_addcomptext(name, tmpbuf); @@ -207,7 +208,7 @@ rcvdistout (FILE *inb, char *form, char *addrs) char_read += msg_count; while (state == FLDPLUS) { msg_count = sizeof tmpbuf; - state = m_getfld (&gstate, name, tmpbuf, &msg_count, inb); + state = m_getfld2(&gstate, name, tmpbuf, &msg_count); fmt_appendcomp(i, name, tmpbuf); char_read += msg_count; } @@ -215,7 +216,7 @@ rcvdistout (FILE *inb, char *form, char *addrs) while (state == FLDPLUS) { msg_count = sizeof tmpbuf; - state = m_getfld (&gstate, name, tmpbuf, &msg_count, inb); + state = m_getfld2(&gstate, name, tmpbuf, &msg_count); } break; @@ -226,7 +227,7 @@ rcvdistout (FILE *inb, char *form, char *addrs) goto finished; default: - adios (NULL, "m_getfld() returned %d", state); + adios (NULL, "m_getfld2() returned %d", state); } } finished: ; diff --git a/uip/replsbr.c b/uip/replsbr.c index e63ce755..d3ba2709 100644 --- a/uip/replsbr.c +++ b/uip/replsbr.c @@ -63,7 +63,7 @@ replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen, char name[NAMESZ], *cp; charstring_t scanl; static int dat[5]; /* aux. data for format routine */ - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; struct fmt_callbacks cb; FILE *out; @@ -110,9 +110,10 @@ replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen, /* * pick any interesting stuff out of msg "inb" */ + gstate = m_getfld_state_init(inb); for (;;) { int msg_count = sizeof tmpbuf; - state = m_getfld (&gstate, name, tmpbuf, &msg_count, inb); + state = m_getfld2(&gstate, name, tmpbuf, &msg_count); switch (state) { case FLD: case FLDPLUS: @@ -128,7 +129,7 @@ replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen, char_read += msg_count; while (state == FLDPLUS) { msg_count= sizeof tmpbuf; - state = m_getfld (&gstate, name, tmpbuf, &msg_count, inb); + state = m_getfld2(&gstate, name, tmpbuf, &msg_count); fmt_appendcomp(i, name, tmpbuf); char_read += msg_count; } @@ -136,7 +137,7 @@ replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen, while (state == FLDPLUS) { msg_count= sizeof tmpbuf; - state = m_getfld (&gstate, name, tmpbuf, &msg_count, inb); + state = m_getfld2(&gstate, name, tmpbuf, &msg_count); } break; @@ -147,7 +148,7 @@ replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen, goto finished; default: - adios (NULL, "m_getfld() returned %d", state); + adios (NULL, "m_getfld2() returned %d", state); } } diff --git a/uip/sendsbr.c b/uip/sendsbr.c index 7d54f43b..796b58ea 100644 --- a/uip/sendsbr.c +++ b/uip/sendsbr.c @@ -198,7 +198,7 @@ splitmsg (char **vec, int vecp, char *program, char *drft, char subject[BUFSIZ]; char name[NAMESZ], partnum[BUFSIZ]; FILE *in; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; if ((in = fopen (drft, "r")) == NULL) adios (drft, "unable to open for reading"); @@ -210,10 +210,11 @@ splitmsg (char **vec, int vecp, char *program, char *drft, * Scan through the message and examine the various header fields, * as well as locate the beginning of the message body. */ - m_getfld_track_filepos (&gstate, in); + gstate = m_getfld_state_init(in); + m_getfld_track_filepos2(&gstate); for (compnum = 1;;) { int bufsz = sizeof buffer; - switch (state = m_getfld (&gstate, name, buffer, &bufsz, in)) { + switch (state = m_getfld2(&gstate, name, buffer, &bufsz)) { case FLD: case FLDPLUS: compnum++; @@ -224,7 +225,7 @@ splitmsg (char **vec, int vecp, char *program, char *drft, if (!strcasecmp (name, "Message-ID")) { while (state == FLDPLUS) { bufsz = sizeof buffer; - state = m_getfld (&gstate, name, buffer, &bufsz, in); + state = m_getfld2(&gstate, name, buffer, &bufsz); } } else if (uprf (name, XXX_FIELD_PRF) || !strcasecmp (name, VRSN_FIELD) @@ -250,7 +251,7 @@ splitmsg (char **vec, int vecp, char *program, char *drft, dp = add (concat (name, ":", buffer, NULL), dp); while (state == FLDPLUS) { bufsz = sizeof buffer; - state = m_getfld (&gstate, name, buffer, &bufsz, in); + state = m_getfld2(&gstate, name, buffer, &bufsz); dp = add (buffer, dp); } } else { @@ -261,7 +262,7 @@ splitmsg (char **vec, int vecp, char *program, char *drft, cp = add (concat (name, ":", buffer, NULL), cp); while (state == FLDPLUS) { bufsz = sizeof buffer; - state = m_getfld (&gstate, name, buffer, &bufsz, in); + state = m_getfld2(&gstate, name, buffer, &bufsz); cp = add (buffer, cp); } } @@ -912,7 +913,7 @@ get_message_header_info(FILE *in, char *format) { struct format *fmt; struct stat st; int parsing_header; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; charstring_t buffer = charstring_create(0); char *retval; @@ -928,10 +929,11 @@ get_message_header_info(FILE *in, char *format) { */ rewind (in); parsing_header = 1; + gstate = m_getfld_state_init(in); do { char name[NAMESZ], rbuf[NMH_BUFSIZ]; int bufsz = sizeof rbuf; - int state = m_getfld(&gstate, name, rbuf, &bufsz, in); + int state = m_getfld2(&gstate, name, rbuf, &bufsz); switch (state) { case FLD: @@ -941,14 +943,14 @@ get_message_header_info(FILE *in, char *format) { if (bucket != -1) { while (state == FLDPLUS) { bufsz = sizeof rbuf; - state = m_getfld(&gstate, name, rbuf, &bufsz, in); + state = m_getfld2(&gstate, name, rbuf, &bufsz); fmt_appendcomp(bucket, name, rbuf); } } while (state == FLDPLUS) { bufsz = sizeof rbuf; - state = m_getfld(&gstate, name, rbuf, &bufsz, in); + state = m_getfld2(&gstate, name, rbuf, &bufsz); } break; } diff --git a/uip/show.c b/uip/show.c index ac012927..dfe5052c 100644 --- a/uip/show.c +++ b/uip/show.c @@ -370,14 +370,14 @@ is_nontext (char *msgnam) char *bp, *dp, *cp; char buf[NMH_BUFSIZ], name[NAMESZ]; FILE *fp; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; if ((fp = fopen (msgnam, "r")) == NULL) return 0; - + gstate = m_getfld_state_init(fp); for (;;) { int bufsz = sizeof buf; - switch (state = m_getfld (&gstate, name, buf, &bufsz, fp)) { + switch (state = m_getfld2(&gstate, name, buf, &bufsz)) { case FLD: case FLDPLUS: /* @@ -390,7 +390,7 @@ is_nontext (char *msgnam) cp = mh_xstrdup(buf); while (state == FLDPLUS) { bufsz = sizeof buf; - state = m_getfld (&gstate, name, buf, &bufsz, fp); + state = m_getfld2(&gstate, name, buf, &bufsz); cp = add (buf, cp); } bp = cp; @@ -495,7 +495,7 @@ out: cp = mh_xstrdup(buf); while (state == FLDPLUS) { bufsz = sizeof buf; - state = m_getfld (&gstate, name, buf, &bufsz, fp); + state = m_getfld2(&gstate, name, buf, &bufsz); cp = add (buf, cp); } for (bp = cp; isspace ((unsigned char) *bp); bp++) @@ -522,7 +522,7 @@ out: */ while (state == FLDPLUS) { bufsz = sizeof buf; - state = m_getfld (&gstate, name, buf, &bufsz, fp); + state = m_getfld2(&gstate, name, buf, &bufsz); } break; diff --git a/uip/slocal.c b/uip/slocal.c index 97897ad1..bf58fd0b 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -713,7 +713,7 @@ parse (int fd) char name[NAMESZ], field[NMH_BUFSIZ]; struct pair *p, *q; FILE *in; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; if (parsed++) return 0; @@ -737,15 +737,16 @@ parse (int fd) * Scan the headers of the message and build * a lookup table. */ + gstate = m_getfld_state_init(in); for (i = 0;;) { int fieldsz = sizeof field; - switch (state = m_getfld (&gstate, name, field, &fieldsz, in)) { + switch (state = m_getfld2(&gstate, name, field, &fieldsz)) { case FLD: case FLDPLUS: lp = mh_xstrdup(field); while (state == FLDPLUS) { fieldsz = sizeof field; - state = m_getfld (&gstate, name, field, &fieldsz, in); + state = m_getfld2(&gstate, name, field, &fieldsz); lp = add (field, lp); } for (p = hdrs; p->p_name; p++) { @@ -786,7 +787,7 @@ parse (int fd) break; default: - inform("internal error in m_getfld"); + inform("internal error in m_getfld2"); fclose (in); return -1; } @@ -1405,7 +1406,7 @@ suppress_duplicates (int fd, char *file) datum key, value; DBM *db; FILE *in; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; if ((fd1 = dup (fd)) == -1) return -1; @@ -1415,10 +1416,11 @@ suppress_duplicates (int fd, char *file) } rewind (in); + gstate = m_getfld_state_init(in); for (;;) { int failed_to_lock = 0; int bufsz = sizeof buf; - state = m_getfld (&gstate, name, buf, &bufsz, in); + state = m_getfld2(&gstate, name, buf, &bufsz); switch (state) { case FLD: case FLDPLUS: @@ -1426,7 +1428,7 @@ suppress_duplicates (int fd, char *file) if (strcasecmp (name, "Message-ID")) { while (state == FLDPLUS) { bufsz = sizeof buf; - state = m_getfld (&gstate, name, buf, &bufsz, in); + state = m_getfld2(&gstate, name, buf, &bufsz); } continue; } @@ -1434,7 +1436,7 @@ suppress_duplicates (int fd, char *file) cp = mh_xstrdup(buf); while (state == FLDPLUS) { bufsz = sizeof buf; - state = m_getfld (&gstate, name, buf, &bufsz, in); + state = m_getfld2(&gstate, name, buf, &bufsz); cp = add (buf, cp); } key.dptr = trimcpy (cp); diff --git a/uip/sortm.c b/uip/sortm.c index dc62f563..3ebb5325 100644 --- a/uip/sortm.c +++ b/uip/sortm.c @@ -340,15 +340,16 @@ get_fields (char *datesw, int msg, struct smsg *smsg) struct tws *tw; char *datecomp = NULL, *subjcomp = NULL; FILE *in; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; if ((in = fopen (msgnam = m_name (msg), "r")) == NULL) { admonish (msgnam, "unable to read message"); return (0); } + gstate = m_getfld_state_init(in); for (compnum = 1;;) { int bufsz = sizeof buf; - switch (state = m_getfld (&gstate, nam, buf, &bufsz, in)) { + switch (state = m_getfld2(&gstate, nam, buf, &bufsz)) { case FLD: case FLDPLUS: compnum++; @@ -356,7 +357,7 @@ get_fields (char *datesw, int msg, struct smsg *smsg) datecomp = add (buf, datecomp); while (state == FLDPLUS) { bufsz = sizeof buf; - state = m_getfld (&gstate, nam, buf, &bufsz, in); + state = m_getfld2(&gstate, nam, buf, &bufsz); datecomp = add (buf, datecomp); } if (!subjsort || subjcomp) @@ -365,7 +366,7 @@ get_fields (char *datesw, int msg, struct smsg *smsg) subjcomp = add (buf, subjcomp); while (state == FLDPLUS) { bufsz = sizeof buf; - state = m_getfld (&gstate, nam, buf, &bufsz, in); + state = m_getfld2(&gstate, nam, buf, &bufsz); subjcomp = add (buf, subjcomp); } if (datecomp) @@ -374,7 +375,7 @@ get_fields (char *datesw, int msg, struct smsg *smsg) /* just flush this guy */ while (state == FLDPLUS) { bufsz = sizeof buf; - state = m_getfld (&gstate, nam, buf, &bufsz, in); + state = m_getfld2(&gstate, nam, buf, &bufsz); } } continue; diff --git a/uip/whatnowsbr.c b/uip/whatnowsbr.c index 802535b3..4fd8cbdb 100644 --- a/uip/whatnowsbr.c +++ b/uip/whatnowsbr.c @@ -1312,7 +1312,7 @@ static int checkmimeheader (char *drft) { FILE *f; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; char buf[NMH_BUFSIZ], name[NAMESZ]; int state, retval = 0; @@ -1321,9 +1321,10 @@ checkmimeheader (char *drft) return (0); } + gstate = m_getfld_state_init(f); for (;;) { int bufsz = sizeof(buf); - switch (state = m_getfld(&gstate, name, buf, &bufsz, f)) { + switch (state = m_getfld2(&gstate, name, buf, &bufsz)) { case FLD: case FLDPLUS: if (strcasecmp(name, VRSN_FIELD) == 0) { -- 2.48.1 From 7d81fd0ae7fc14189d7758c78a5168921c7ef11b Mon Sep 17 00:00:00 2001 From: Ralph Corderoy Date: Sun, 13 Aug 2017 16:33:06 +0100 Subject: [PATCH 02/16] scan(): Don't ioctl(2) for TTY's width every call. Saves a system call per message scanned. Does mean it won't adjust should the terminal width change mid scan, but that seems fine; after all, the retrieved width could be out of date by the time a message's output is written anyway. --- uip/scansbr.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/uip/scansbr.c b/uip/scansbr.c index df9ef645..24609d26 100644 --- a/uip/scansbr.c +++ b/uip/scansbr.c @@ -48,6 +48,8 @@ int scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg, int unseen, char *folder, long size, int noisy, charstring_t *scanl) { + static bool deja_vu; + static int tty_width; int i, compnum, encrypted, state; char *cp, *tmpbuf, *startbody, **nxtbuf; char *saved_c_text = NULL; @@ -64,9 +66,12 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg, scanl used to be a global. */ if (! *scanl) { if (width == -1) { - /* Default: width of the terminal, but at least WIDTH/2. */ - if ((width = sc_width ()) < WIDTH/2) - width = WIDTH/2; + if (!deja_vu) { + deja_vu = true; + tty_width = sc_width(); + } + + width = max(tty_width, WIDTH / 2); } else if (width == 0) { /* Unlimited width. */ width = INT_MAX; -- 2.48.1 From 54b3847305718394e886272edd49f8dcd2bcfc29 Mon Sep 17 00:00:00 2001 From: Ralph Corderoy Date: Sun, 13 Aug 2017 16:58:14 +0100 Subject: [PATCH 03/16] inc.c: Narrow scope of inc_type. Chain mutually-exclusive ifs. Joining the separate if-statements with `else' tells the reader it's not expected that more than one branch can be taken. Useful when each is many lines long. No functional change intended. --- uip/inc.c | 54 ++++++++++++++++++++---------------------------------- 1 file changed, 20 insertions(+), 34 deletions(-) diff --git a/uip/inc.c b/uip/inc.c index 0890f831..0df0a4de 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -93,7 +93,6 @@ DEFINE_SWITCH_ARRAY(INC, switches); #define INC_FILE 0 #define INC_POP 1 -static int inc_type; static struct Maildir_entry { char *filename; time_t mtime; @@ -174,6 +173,7 @@ maildir_srt(const void *va, const void *vb) int main (int argc, char **argv) { + static int inc_type; bool chgflag; int trnflag = 1; bool noisy; @@ -391,21 +391,11 @@ main (int argc, char **argv) /* guarantee dropping group privileges; we might not have done so earlier */ DROPGROUPPRIVS(); - /* - * Where are we getting the new mail? - */ - if (from) - inc_type = INC_FILE; - else if (host) - inc_type = INC_POP; - else - inc_type = INC_FILE; + /* Source of mail; -from overrides any -host. */ + inc_type = host && !from ? INC_POP : INC_FILE; - /* - * Are we getting the mail from - * a POP server? - */ if (inc_type == INC_POP) { + /* Mail from a POP server. */ int tlsflag = 0; if (auth_svc == NULL) { @@ -439,14 +429,9 @@ main (int argc, char **argv) pop_quit(); adios (NULL, "no mail to incorporate"); } - } - - /* - * We will get the mail from a file - * (typically the standard maildrop) - */ - if (inc_type == INC_FILE) { + } else if (inc_type == INC_FILE) { + /* Mail from a spool file, or Maildir. */ if (from) newmail = from; else if ((newmail = getenv ("MAILDROP")) && *newmail) @@ -537,6 +522,8 @@ main (int argc, char **argv) adios (NULL, "unable to read folder %s", folder); if (inc_type == INC_FILE && Maildir == NULL) { + /* Mail from a spool file. */ + if (access (newmail, W_OK) != NOTOK) { locked++; if (trnflag) { @@ -595,6 +582,7 @@ main (int argc, char **argv) * Get the mail from a POP server */ if (inc_type == INC_POP) { + /* Mail from a POP server. */ int i; hghnum = msgnum = mp->hghmsg; @@ -659,12 +647,10 @@ main (int argc, char **argv) if (pop_quit () == NOTOK) adios (NULL, "%s", response); - } - /* - * Get the mail from file (usually mail spool) - */ - if (inc_type == INC_FILE && Maildir == NULL) { + } else if (inc_type == INC_FILE && Maildir == NULL) { + /* Mail from a spool file. */ + scan_detect_mbox_style (in); /* the MAGIC invocation... */ hghnum = msgnum = mp->hghmsg; for (;;) { @@ -716,7 +702,9 @@ main (int argc, char **argv) */ break; } - } else if (inc_type == INC_FILE) { /* Maildir inbox to process */ + + } else { + /* Mail from Maildir. */ char *sp; FILE *sf; int i; @@ -827,10 +815,9 @@ main (int argc, char **argv) if (noisy) fflush (stdout); - /* - * truncate file we are incorporating from - */ if (inc_type == INC_FILE && Maildir == NULL) { + /* Mail from a spool file; truncate it. */ + if (trnflag) { if (stat (newmail, &st) != NOTOK && s1.st_mtime != st.st_mtime) inform("new messages have arrived!\007"); @@ -894,12 +881,11 @@ main (int argc, char **argv) seq_save(mp2); /* Save the sequence file */ folder_free(mp2); } -skip: - /* - * unlock the mail spool - */ +skip: if (inc_type == INC_FILE && Maildir == NULL) { + /* Mail from a spool file; unlock it. */ + if (locked) { GETGROUPPRIVS(); /* Be sure we can unlock mail file */ (void) lkfclosespool (in, newmail); in = NULL; -- 2.48.1 From d3d8f636ed951b4c02bdeeb146b528fe00dfbb48 Mon Sep 17 00:00:00 2001 From: Ralph Corderoy Date: Sun, 13 Aug 2017 17:13:34 +0100 Subject: [PATCH 04/16] pop_retr(): Add a `void *closure' to be passed to action callback. Only caller passes in NULL for the moment, and doesn't use it in the callback, but it will allow fewer scopes by name of the variables the action callback uses. --- h/popsbr.h | 2 +- uip/inc.c | 7 ++++--- uip/popsbr.c | 10 +++++----- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/h/popsbr.h b/h/popsbr.h index 7193f1f5..fab83e14 100644 --- a/h/popsbr.h +++ b/h/popsbr.h @@ -8,7 +8,7 @@ int pop_init (char *, char *, char *, char *, int, int, char *, int, const char *); int pop_fd (char *, int, char *, int); int pop_stat (int *, int *); -int pop_retr (int, int (*)(char *)); +int pop_retr (int, int (*)(void *, char *), void *); int pop_dele (int); int pop_quit (void); int pop_done (void); diff --git a/uip/inc.c b/uip/inc.c index 0df0a4de..26cdbe53 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -157,7 +157,7 @@ static FILE *in; * prototypes */ static void inc_done(int) NORETURN; -static int pop_action(char *); +static int pop_action(void *closure, char *); int maildir_srt(const void *va, const void *vb) @@ -596,7 +596,7 @@ main (int argc, char **argv) chmod (cp, m_gmprot ()); start = stop = 0L; - if (pop_retr (i, pop_action) == NOTOK) + if (pop_retr(i, pop_action, NULL) == NOTOK) adios (NULL, "%s", response); if (fflush (pf)) @@ -915,8 +915,9 @@ inc_done (int status) } static int -pop_action (char *s) +pop_action(void *closure, char *s) { + NMH_UNUSED(closure); fprintf (pf, "%s\n", s); stop += strlen (s) + 1; return 0; /* Is return value used? This was missing before 1999-07-15. */ diff --git a/uip/popsbr.c b/uip/popsbr.c index 8d54e021..fba13992 100644 --- a/uip/popsbr.c +++ b/uip/popsbr.c @@ -27,7 +27,7 @@ static netsec_context *nsc = NULL; static int command(const char *, ...); static int multiline(void); -static int traverse (int (*)(char *), const char *, ...); +static int traverse (int (*)(void *, char *), void *closure, const char *, ...); static int vcommand(const char *, va_list); static int pop_getline (char *, int, netsec_context *); static int pop_sasl_callback(enum sasl_message_type, unsigned const char *, @@ -481,14 +481,14 @@ pop_stat (int *nmsgs, int *nbytes) int -pop_retr (int msgno, int (*action)(char *)) +pop_retr (int msgno, int (*action)(void *, char *), void *closure) { - return traverse (action, "RETR %d", msgno); + return traverse (action, closure, "RETR %d", msgno); } static int -traverse (int (*action)(char *), const char *fmt, ...) +traverse (int (*action)(void *, char *), void *closure, const char *fmt, ...) { int result, snoopstate; va_list ap; @@ -517,7 +517,7 @@ traverse (int (*action)(char *), const char *fmt, ...) return OK; case OK: - (*action) (response); + (*action)(closure, response); break; } } -- 2.48.1 From bb0b14bdb72ac3b3fbee4ba4ff4da0b7848089bf Mon Sep 17 00:00:00 2001 From: Ralph Corderoy Date: Sun, 13 Aug 2017 17:54:59 +0100 Subject: [PATCH 05/16] popsbr.c: Alter traverse() to check action callback's result. The action callback returned zero, with a 1999 comment asking if it was checked. traverse() didn't check it. Change it so it does, wanting `OK' if all's well, else returning the non-OK value to traverse's caller; though that only checks for NOTOK. No functional change intended. --- uip/inc.c | 2 +- uip/popsbr.c | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/uip/inc.c b/uip/inc.c index 26cdbe53..9a72aa45 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -920,5 +920,5 @@ pop_action(void *closure, char *s) NMH_UNUSED(closure); fprintf (pf, "%s\n", s); stop += strlen (s) + 1; - return 0; /* Is return value used? This was missing before 1999-07-15. */ + return OK; } diff --git a/uip/popsbr.c b/uip/popsbr.c index fba13992..ca6599e0 100644 --- a/uip/popsbr.c +++ b/uip/popsbr.c @@ -505,21 +505,21 @@ traverse (int (*action)(void *, char *), void *closure, const char *fmt, ...) if ((snoopstate = netsec_get_snoop(nsc))) netsec_set_snoop(nsc, 0); - for (;;) - switch (multiline ()) { - case NOTOK: - netsec_set_snoop(nsc, snoopstate); - return NOTOK; - - case DONE: - strncpy (response, buffer, sizeof(response)); - netsec_set_snoop(nsc, snoopstate); - return OK; + for (;;) { + result = multiline(); + if (result == OK) { + result = (*action)(closure, response); + if (result == OK) + continue; + } else if (result == DONE) { + strncpy(response, buffer, sizeof(response)); + result = OK; + } + break; + } - case OK: - (*action)(closure, response); - break; - } + netsec_set_snoop(nsc, snoopstate); + return result; } -- 2.48.1 From 6aec307fcced3dbd5dc47c52c79bd5c833021f51 Mon Sep 17 00:00:00 2001 From: Ralph Corderoy Date: Sun, 13 Aug 2017 18:07:33 +0100 Subject: [PATCH 06/16] inc.c: Alter pop_action() to check I/O, perhaps returning NOTOK. --- uip/inc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/uip/inc.c b/uip/inc.c index 9a72aa45..20d4088b 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -918,7 +918,11 @@ static int pop_action(void *closure, char *s) { NMH_UNUSED(closure); - fprintf (pf, "%s\n", s); - stop += strlen (s) + 1; + + if (fputs(s, pf) == EOF || putc('\n', pf) == EOF) + return NOTOK; + + stop += strlen(s) + 1; /* Count linefeed too. */ + return OK; } -- 2.48.1 From 58c5e5b287f2ef7b6a855b30eb0c2be1edd5ab42 Mon Sep 17 00:00:00 2001 From: Ralph Corderoy Date: Mon, 14 Aug 2017 00:52:57 +0100 Subject: [PATCH 07/16] inc.c: Use closure for pop_retr()'s action callback. Allows file-static variables to become local to a function. In fact, two of them no longer need to exist: one of them becomes the closure's struct's member, and the other is always 0 and probably just present due to copy and paste. --- uip/inc.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/uip/inc.c b/uip/inc.c index 20d4088b..68fb06b6 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -100,12 +100,12 @@ static struct Maildir_entry { static int num_maildir_entries = 0; static int snoop = 0; -extern char response[]; - -static long start; -static long stop; +typedef struct { + FILE *mailout; + long written; +} pop_closure; -static FILE *pf = NULL; +extern char response[]; /* This is an attempt to simplify things by putting all the * privilege ops into macros. @@ -179,6 +179,7 @@ main (int argc, char **argv) bool noisy; int width = -1; int hghnum = 0, msgnum = 0; + FILE *pf = NULL; bool sasl, tls, noverify; int incerr = 0; /* <0 if inc hits an error which means it should not truncate mailspool */ char *cp, *maildir = NULL, *folder = NULL; @@ -584,6 +585,7 @@ main (int argc, char **argv) if (inc_type == INC_POP) { /* Mail from a POP server. */ int i; + pop_closure pc; hghnum = msgnum = mp->hghmsg; for (i = 1; i <= nmsgs; i++) { @@ -594,9 +596,10 @@ main (int argc, char **argv) if ((pf = fopen (cp, "w+")) == NULL) adios (cp, "unable to write"); chmod (cp, m_gmprot ()); - start = stop = 0L; - if (pop_retr(i, pop_action, NULL) == NOTOK) + pc.written = 0; + pc.mailout = pf; + if (pop_retr(i, pop_action, &pc) == NOTOK) adios (NULL, "%s", response); if (fflush (pf)) @@ -604,7 +607,7 @@ main (int argc, char **argv) fseek (pf, 0L, SEEK_SET); switch (incerr = scan (pf, msgnum, 0, nfs, width, msgnum == mp->hghmsg + 1 && chgflag, - 1, NULL, stop - start, noisy, &scanl)) { + 1, NULL, pc.written, noisy, &scanl)) { case SCNEOF: printf ("%*d empty\n", DMAXFOLDER, msgnum); break; @@ -745,7 +748,7 @@ main (int argc, char **argv) fseek (pf, 0L, SEEK_SET); switch (incerr = scan (pf, msgnum, 0, nfs, width, msgnum == mp->hghmsg + 1 && chgflag, - 1, NULL, stop - start, noisy, &scanl)) { + 1, NULL, 0, noisy, &scanl)) { case SCNEOF: printf ("%*d empty\n", DMAXFOLDER, msgnum); break; @@ -917,12 +920,14 @@ inc_done (int status) static int pop_action(void *closure, char *s) { - NMH_UNUSED(closure); + pop_closure *pc; + int n; - if (fputs(s, pf) == EOF || putc('\n', pf) == EOF) + pc = closure; + n = fprintf(pc->mailout, "%s\n", s); + if (n < 0) return NOTOK; - - stop += strlen(s) + 1; /* Count linefeed too. */ + pc->written += n; /* Count linefeed too. */ return OK; } -- 2.48.1 From 69b1af64ab786895358ed58b6bf900d4371af138 Mon Sep 17 00:00:00 2001 From: Ralph Corderoy Date: Wed, 16 Aug 2017 00:49:02 +0100 Subject: [PATCH 08/16] getcwidth.c: Use WCHAR_MAX, not __WCHAR_MAX__. Former is clearly part of POSIX. --- test/getcwidth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/getcwidth.c b/test/getcwidth.c index a6c7391c..b692a9f6 100644 --- a/test/getcwidth.c +++ b/test/getcwidth.c @@ -164,9 +164,9 @@ typedef struct { static unicode_range range[] = { /* https://en.wikipedia.org/wiki/Unicode#Code_point_planes_and_blocks */ { L'\x0000', L'\xff' }, -#if __WCHAR_MAX__ >= 0xffff +#if WCHAR_MAX >= 0xffff { L'\x0100', L'\xffff' }, -#if __WCHAR_MAX__ >= 0xfffff +#if WCHAR_MAX >= 0xfffff { L'\x10000', L'\x14fff' }, { L'\x16000', L'\x18fff' }, { L'\x1b000', L'\x1bfff' }, -- 2.48.1 From 0d0d0e65a4c093f3f8827d4cd3375dcde4d4aab0 Mon Sep 17 00:00:00 2001 From: Ralph Corderoy Date: Wed, 16 Aug 2017 13:44:32 +0100 Subject: [PATCH 09/16] INSTALL: Update c89(1) mention to c99(1), that exists today. --- INSTALL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL b/INSTALL index 246cf0e9..3639fe2c 100644 --- a/INSTALL +++ b/INSTALL @@ -135,7 +135,7 @@ linking that the "configure" script does not know about, by giving "configure" initial values for these on its command line or in its environment. For example, - ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix + ./configure CC=c99 CFLAGS=-O2 LIBS=-lposix If you wish to add options that are only used at compile time instead of link time, you can use the CPPFLAGS variable: -- 2.48.1 From 877306f0cf8700241efc2e245f66df5ba95113f9 Mon Sep 17 00:00:00 2001 From: Ken Hornstein Date: Wed, 16 Aug 2017 23:55:23 -0400 Subject: [PATCH 10/16] Make sure the %(kilo) and %(kibi) instructions are in fmttest(1). Man, we should really merge fmttest and fmtdump at some point. --- uip/fmttest.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/uip/fmttest.c b/uip/fmttest.c index d848bea0..301321b7 100644 --- a/uip/fmttest.c +++ b/uip/fmttest.c @@ -1040,6 +1040,8 @@ f_typestr(int t) case FT_LV_DIVIDE_L: return("LV_DIVIDE_L"); case FT_LV_MODULO_L: return("LV_MODULO_L"); case FT_LV_CHAR_LEFT: return("LV_CHAR_LEFT"); + case FT_LS_KILO: return("LS_KILO"); + case FT_LS_KIBI: return("LS_KIBI"); case FT_LS_MONTH: return("LS_MONTH"); case FT_LS_LMONTH: return("LS_LMONTH"); case FT_LS_ZONE: return("LS_ZONE"); -- 2.48.1 From b7a676587f92187d2270be73a1ede5be0af9f104 Mon Sep 17 00:00:00 2001 From: Ken Hornstein Date: Thu, 17 Aug 2017 01:12:22 -0400 Subject: [PATCH 11/16] Improve installation documentation Fix up the various installation information so it matches reality. --- INSTALL | 37 +++++++++++++++++++------------------ configure.ac | 4 ++-- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/INSTALL b/INSTALL index 3639fe2c..5f1b88aa 100644 --- a/INSTALL +++ b/INSTALL @@ -202,7 +202,7 @@ Options for configure nmh command `prompter'. If you specify `prompter', then you don't need to give the full pathname. ---with-locking=LOCKTYPE (DEFAULT is dot) +--with-locking=LOCKTYPE (DEFAULT is based on operating system) Specify the locking mechanism when attempting to "inc" or "msgchk" a local mail spool. Valid options are "dot", "fcntl", "flock", and "lockf". Of the four, dot-locking @@ -223,12 +223,12 @@ Options for configure locked. --with-mts=MTS (DEFAULT is smtp) - Specify the default mail transport system you want to use. The two - acceptable options are "smtp" (which is the default), and - "sendmail". This value will be put into the mts.conf file. You - may find it convenient to specify a value at configure-time, - however, so that each time nmh is reinstalled, the right value will - be there. + Specify the default mail transport system you want to use. The three + acceptable options are "smtp" (which is the default), + "sendmail/smtp", and "sendmail/pipe". This value will be put into + the mts.conf file. You may find it convenient to specify a value + at configure-time, however, so that each time nmh is reinstalled, + the right value will be there. If you use "smtp", this will enable a direct SMTP (simple mail transport protocol) interface in nmh. When sending mail, instead @@ -237,12 +237,14 @@ Options for configure in the `mts.conf' file (default is localhost), and speak SMTP directly. - If you use "sendmail", then `post' will send messages by forking a + If you use "sendmail/smtp", then `post' will send messages by forking a local copy of sendmail. Currently it will still speak SMTP with this local copy of sendmail. - If you wish to use a transport agent other than sendmail, you will - need to use a `sendmail wrapper'. + If you use "sendmail/pipe", then `post' will open a pipe to the + sendmail program and invoke it with the '-t' and '-i' options + and write the message to sendmail's standard input. Note that + some nmh functionality is not available in this mode. --with-ndbm=LIB (DEFAULT is to autodetect) --with-ndbmheader=HEADER (DEFAULT is to autodetect) @@ -255,11 +257,6 @@ Options for configure If either of these options is given then the other must also be specified. ---with-pager=PAGER (DEFAULT is more) - Specify the default pager (file lister) to use. If this option - is not given, then the configuration process will search for the - command `more' and use it as the default. - --with-smtpserver='SMTPSERVER' (DEFAULT is localhost) If this option is not specified, the mts.conf file will contain the line "servers: localhost", which may be manually edited later. @@ -269,15 +266,19 @@ Options for configure See the mh-tailor(5) man page for full documentation of "servers:". ---with-cyrus-sasl (DEFAULT is without) +--with-cyrus-sasl (DEFAULT is to autodetect)) Enable SASL support for SMTP and POP via the Cyrus SASL library. This is used for the POP AUTH and SMTP AUTH protocols. This supports a wide variety of security mechanisms, including Kerberos/GSSAPI. Session encryption via SASL is supported for both POP and SMTP (depending on server-side support and the security mechanism in use). ---with-tls (DEFAULT is without) - Enable TLS session encryption support for SMTP via the STARTTLS command. +--with-tls (DEFAULT is to autodetect) + Enable TLS session encryption support for SMTP via the STARTTLS command + and TLS at connection start for both SMTP and POP. + +--with-oauth (DEFAULT is to enable if curl is installed) + Enable OAuth2 authentication for SMTP and POP. --with-readline (DEFAULT is to autodetect) Enable support for readline functionality (command history/editing) at diff --git a/configure.ac b/configure.ac index 1d42bf53..f41c7140 100644 --- a/configure.ac +++ b/configure.ac @@ -35,9 +35,9 @@ AS_IF([test x"$with_cyrus_sasl" != x -a x"$with_cyrus_sasl" != xyes -a \ dnl Do you want client-side support for encryption with TLS? AC_ARG_WITH([tls], AS_HELP_STRING([--with-tls], [Enable TLS support])) -dnl Do you want client-side support for using OAuth2 for SMTP authentication? +dnl Do you want client-side support for using OAuth2 for SMTP & POP auth? AC_ARG_WITH([oauth], AS_HELP_STRING([--with-oauth], - [Enable OAuth2 support in SMTP auth])) + [Enable OAuth2 support in SMTP and POP auth])) dnl Set the backup prefix AC_ARG_WITH([hash-backup], -- 2.48.1 From 58fa16ef1e6d6c3a698d220409416bccec187287 Mon Sep 17 00:00:00 2001 From: Ken Hornstein Date: Thu, 17 Aug 2017 01:24:08 -0400 Subject: [PATCH 12/16] Fix bug in cpnumber(). The cpnumber() function (which handles the NUMF instruction, among others) would hang if a 0 width was given to it. Make sure that (and negative widths) are handled correctly. Note that normally NUMF did not handle left padding which is indicated by a negative width; that may change in the future. --- sbr/fmt_scan.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sbr/fmt_scan.c b/sbr/fmt_scan.c index 8e59669d..50d7c4ca 100644 --- a/sbr/fmt_scan.c +++ b/sbr/fmt_scan.c @@ -67,7 +67,12 @@ match (char *str, char *sub) * copy a number to the destination subject to a maximum width */ void -cpnumber(charstring_t dest, int num, unsigned int wid, char fill, size_t max) { +cpnumber(charstring_t dest, int num, int wid, char fill, size_t max) { + /* Maybe we should handle left padding at some point? */ + if (wid == 0) + return; + if (wid < 0) + wid = -wid; if (wid < (num >= 0 ? max : max-1)) { /* Build up the string representation of num in reverse. */ charstring_t rev = charstring_create (0); -- 2.48.1 From ac0bb0e1e19bedfd9d7105db0aad1cdfc5ef994f Mon Sep 17 00:00:00 2001 From: Ralph Corderoy Date: Thu, 17 Aug 2017 11:35:51 +0100 Subject: [PATCH 13/16] cpnumber(): Cast desired width to size_t to silence gcc's warning. Add a comment on `wid = -wid' that it's OK because wid's value was originally a short so won't remain the same value. --- sbr/fmt_scan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sbr/fmt_scan.c b/sbr/fmt_scan.c index 50d7c4ca..075b7dd6 100644 --- a/sbr/fmt_scan.c +++ b/sbr/fmt_scan.c @@ -72,8 +72,8 @@ cpnumber(charstring_t dest, int num, int wid, char fill, size_t max) { if (wid == 0) return; if (wid < 0) - wid = -wid; - if (wid < (num >= 0 ? max : max-1)) { + wid = -wid; /* OK because wid originally a short. */ + if ((size_t)wid < (num >= 0 ? max : max-1)) { /* Build up the string representation of num in reverse. */ charstring_t rev = charstring_create (0); int i = num >= 0 ? num : -num; -- 2.48.1 From 1009a32da2ba2b0caae7b71708625e00d8cf58c6 Mon Sep 17 00:00:00 2001 From: Ralph Corderoy Date: Thu, 17 Aug 2017 11:59:38 +0100 Subject: [PATCH 14/16] Makefile.am: Remove multiple `mkdir -p' for etc; use ./configure. A `mkdir -p' was used in each rule that created a file in etc to ensure the directory already existed. Ken pointed out existing ./configure code to do that for the man directory, just once. Use that for etc too. Remove the `test -d' because `mkdir -p' does that itself. --- Makefile.am | 2 -- configure.ac | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 4f6627e4..5b975fd1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -871,7 +871,6 @@ config/version.c: Makefile $(srcdir)/config/version.sh env srcdir="$(srcdir)" sh $(srcdir)/config/version.sh $(VERSION) > ./config/version.c etc/bash_completion_nmh: $(srcdir)/etc/bash_completion_nmh-gen - $(MKDIR_P) $(@D) # FIXME: A better way? $(srcdir)/etc/bash_completion_nmh-gen > $@ etc/mts.conf: $(srcdir)/etc/mts.conf.in Makefile @@ -884,7 +883,6 @@ etc/mts.conf: $(srcdir)/etc/mts.conf.in Makefile < $(srcdir)/etc/mts.conf.in > $@ etc/mhn.defaults: $(srcdir)/etc/mhn.defaults.sh $(MHNSEARCHPROG) - $(MKDIR_P) $(@D) # FIXME: A better way? @rm -f $@ $(srcdir)/etc/mhn.defaults.sh $(MHNSEARCHPATH) $(MHNSEARCHPROG) > $@ diff --git a/configure.ac b/configure.ac index f41c7140..f0a8183d 100644 --- a/configure.ac +++ b/configure.ac @@ -604,7 +604,7 @@ dnl exist. dnl AC_CONFIG_COMMANDS([build-directories], -[test -d man || AS_MKDIR_P([man])]) +[AS_MKDIR_P([etc]); AS_MKDIR_P([man])]) AC_CONFIG_COMMANDS_POST([ -- 2.48.1 From 2fdd29fd2bacb043c5424605496a625c352072a2 Mon Sep 17 00:00:00 2001 From: Ralph Corderoy Date: Thu, 17 Aug 2017 12:09:43 +0100 Subject: [PATCH 15/16] Makefile.am: Remove `test -d' guarding `mkdir -p'. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 5b975fd1..caffaabf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1144,7 +1144,7 @@ ChangeLog: ## Our RPM build target ## rpm: dist - @test -d $(rpmdir)/SOURCES || $(MKDIR_P) $(rpmdir)/SOURCES + @$(MKDIR_P) $(rpmdir)/SOURCES @mv -f $(DIST_ARCHIVES) $(rpmdir)/SOURCES @cp -p VERSION $(rpmdir)/SOURCES @rpmbuild --define '_topdir $(rpmdir)' \ -- 2.48.1 From efb2c94fbc4861fc81307cd5d0ce22eb16e6de26 Mon Sep 17 00:00:00 2001 From: Ralph Corderoy Date: Thu, 17 Aug 2017 12:20:16 +0100 Subject: [PATCH 16/16] fmtdump.c, fmttest.c: Remove tests for FT_LIT_FORCE. It isn't defined, and git-grep(1) suggests it was a local Lawrence Berkeley Laboratory modification that output a literal without consuming any of the width budget. --- uip/fmtdump.c | 6 ------ uip/fmttest.c | 6 ------ 2 files changed, 12 deletions(-) diff --git a/uip/fmtdump.c b/uip/fmtdump.c index 57968f0e..eeeb1461 100644 --- a/uip/fmtdump.c +++ b/uip/fmtdump.c @@ -238,9 +238,6 @@ dumpone(struct format *fmt) break; case FT_LIT: -#ifdef FT_LIT_FORCE - case FT_LIT_FORCE: -#endif putchar(' '); litputs(fmt->f_text); break; @@ -346,9 +343,6 @@ f_typestr(int t) case FT_COMPF: return("COMPF"); case FT_LIT: return("LIT"); case FT_LITF: return("LITF"); -#ifdef FT_LIT_FORCE - case FT_LIT_FORCE: return("LIT_FORCE"); -#endif case FT_CHAR: return("CHAR"); case FT_NUM: return("NUM"); case FT_NUMF: return("NUMF"); diff --git a/uip/fmttest.c b/uip/fmttest.c index 301321b7..becf25d1 100644 --- a/uip/fmttest.c +++ b/uip/fmttest.c @@ -865,9 +865,6 @@ dumpone(struct format *fmt) break; case FT_LIT: -#ifdef FT_LIT_FORCE - case FT_LIT_FORCE: -#endif putchar(' '); litputs(fmt->f_text); break; @@ -1011,9 +1008,6 @@ f_typestr(int t) case FT_COMPF: return("COMPF"); case FT_LIT: return("LIT"); case FT_LITF: return("LITF"); -#ifdef FT_LIT_FORCE - case FT_LIT_FORCE: return("LIT_FORCE"); -#endif case FT_CHAR: return("CHAR"); case FT_NUM: return("NUM"); case FT_NUMF: return("NUMF"); -- 2.48.1