X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/c703902741e0f7ce55f87e48ef0d00901195f1bc..d067b8780f39cb8d52e3e07a3b05ffcb1ed684ea:/uip/mshcmds.c diff --git a/uip/mshcmds.c b/uip/mshcmds.c index 8212375a..41017430 100644 --- a/uip/mshcmds.c +++ b/uip/mshcmds.c @@ -51,6 +51,8 @@ static int process (int, char *, int, char **); static void copy_message (int, FILE *); static void copy_digest (int, FILE *); +extern m_getfld_state_t gstate; /* use the gstate in scansbr.c */ + void forkcmd (char **args, char *pgm) { @@ -950,7 +952,7 @@ forw (char *proc, char *filter, int vecp, char **vec) args[i++] = getcpy (m_name (msgnum)); args[i] = NULL; mhlsbr (i, args, mhl_action); - m_eomsbr ((int (*) ()) 0); + scan_eom_action ((int (*) ()) 0); fclose (stdout); _exit (0); @@ -2211,7 +2213,7 @@ finish: ; if (mp->numsel == 1 && headersw) show (mp->lowsel); mhlsbr (vecp, vec, mhl_action); - m_eomsbr ((int (*)()) 0); + scan_eom_action ((int (*)()) 0); while (msgp < vecp) free (vec[msgp++]); } else { @@ -2283,7 +2285,7 @@ mhl_action (char *name) mhlfp = msh_ready (msgnum, 1); if (!fmsh) - m_eomsbr (eom_action); + scan_eom_action (eom_action); return mhlfp; } @@ -2330,8 +2332,7 @@ static int is_nontext (int msgnum) { int result, state; - unsigned char *bp, *dp; - char *cp; + char *bp, *dp, *cp; char buf[BUFSIZ], name[NAMESZ]; FILE *fp; @@ -2341,11 +2342,11 @@ is_nontext (int msgnum) fp = msh_ready (msgnum, 1); - for (state = FLD;;) - switch (state = m_getfld (state, name, buf, sizeof buf, fp)) { + for (;;) { + int bufsz = sizeof buf; + switch (state = m_getfld (&gstate, name, buf, &bufsz, fp)) { case FLD: case FLDPLUS: - case FLDEOF: /* * Check Content-Type field */ @@ -2355,14 +2356,15 @@ is_nontext (int msgnum) cp = add (buf, NULL); while (state == FLDPLUS) { - state = m_getfld (state, name, buf, sizeof buf, fp); + bufsz = sizeof buf; + state = m_getfld (&gstate, name, buf, &bufsz, fp); cp = add (buf, cp); } bp = cp; passno = 1; again: - for (; isspace (*bp); bp++) + for (; isspace ((unsigned char) *bp); bp++) continue; if (*bp == '(') { int i; @@ -2407,24 +2409,24 @@ invalid: if ((result = (mh_strcasecmp (bp, "plain") != 0))) goto out; *dp = c; - for (dp++; isspace (*dp); dp++) + for (dp++; isspace ((unsigned char) *dp); dp++) continue; if (*dp) { if ((result = !uprf (dp, "charset"))) goto out; dp += sizeof "charset" - 1; - while (isspace (*dp)) + while (isspace ((unsigned char) *dp)) dp++; if (*dp++ != '=') goto invalid; - while (isspace (*dp)) + while (isspace ((unsigned char) *dp)) dp++; if (*dp == '"') { if ((bp = strchr(++dp, '"'))) *bp = '\0'; } else { for (bp = dp; *bp; bp++) - if (isspace (*bp)) { + if (isspace ((unsigned char) *bp)) { *bp = '\0'; break; } @@ -2458,10 +2460,11 @@ out: if (!mh_strcasecmp (name, ENCODING_FIELD)) { cp = add (buf, NULL); while (state == FLDPLUS) { - state = m_getfld (state, name, buf, sizeof buf, fp); + bufsz = sizeof buf; + state = m_getfld (&gstate, name, buf, &bufsz, fp); cp = add (buf, cp); } - for (bp = cp; isspace (*bp); bp++) + for (bp = cp; isspace ((unsigned char) *bp); bp++) continue; for (dp = bp; istoken (*dp); dp++) continue; @@ -2482,8 +2485,10 @@ out: * Just skip the rest of this header * field and go to next one. */ - while (state == FLDPLUS) - state = m_getfld (state, name, buf, sizeof(buf), fp); + while (state == FLDPLUS) { + bufsz = sizeof buf; + state = m_getfld (&gstate, name, buf, &bufsz, fp); + } break; /* @@ -2493,6 +2498,7 @@ out: default: return 0; } + } } @@ -2645,15 +2651,17 @@ get_fields (char *datesw, char *subjsw, int msgnum, struct Msg *msgp) register FILE *zp; zp = msh_ready (msgnum, 0); - for (state = FLD;;) { - switch (state = m_getfld (state, name, buf, sizeof buf, zp)) { + + for (;;) { + int bufsz = sizeof buf; + switch (state = m_getfld (&gstate, name, buf, &bufsz, zp)) { case FLD: - case FLDEOF: case FLDPLUS: if (!mh_strcasecmp (name, datesw)) { bp = getcpy (buf); while (state == FLDPLUS) { - state = m_getfld (state, name, buf, sizeof buf, zp); + bufsz = sizeof buf; + state = m_getfld (&gstate, name, buf, &bufsz, zp); bp = add (buf, bp); } if ((tw = dparsetime (bp)) == NULL) @@ -2670,7 +2678,8 @@ get_fields (char *datesw, char *subjsw, int msgnum, struct Msg *msgp) else if (subjsw && !mh_strcasecmp(name, subjsw)) { bp = getcpy (buf); while (state == FLDPLUS) { - state = m_getfld (state, name, buf, sizeof buf, zp); + bufsz = sizeof buf; + state = m_getfld (&gstate, name, buf, &bufsz, zp); bp = add (buf, bp); } msgp->m_scanl = sosmash(subjsw, bp); @@ -2679,13 +2688,14 @@ get_fields (char *datesw, char *subjsw, int msgnum, struct Msg *msgp) else subjsw = (char *)0;/* subject done, need date */ } else { - while (state == FLDPLUS) /* flush this one */ - state = m_getfld (state, name, buf, sizeof buf, zp); + while (state == FLDPLUS) { /* flush this one */ + bufsz = sizeof buf; + state = m_getfld (&gstate, name, buf, &bufsz, zp); + } } continue; case BODY: - case BODYEOF: case FILEEOF: break;