X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/de4636bb664106d9932ae7acb517e471b848f1f3..030c6e4df060fcbc33db4495148267e90c960d9d:/uip/slocal.c diff --git a/uip/slocal.c b/uip/slocal.c index 1c30dfc5..f570aaaf 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -645,7 +645,7 @@ static int split (char *cp, char **vec) { int i; - unsigned char *s; + char *s; s = cp; @@ -654,7 +654,7 @@ split (char *cp, char **vec) vec[i] = NULL; /* zap any whitespace and comma's */ - while (isspace (*s) || *s == ',') + while (isspace ((unsigned char) *s) || *s == ',') *s++ = 0; /* end of buffer, time to leave */ @@ -684,7 +684,7 @@ split (char *cp, char **vec) vec[i++] = s++; /* move forward to next field delimiter */ - while (*s && !isspace (*s) && *s != ',') + while (*s && !isspace ((unsigned char) *s) && *s != ',') s++; } vec[i] = NULL; @@ -707,6 +707,7 @@ parse (int fd) char name[NAMESZ], field[BUFSIZ]; struct pair *p, *q; FILE *in; + m_getfld_state_t gstate = 0; if (parsed++) return 0; @@ -730,14 +731,15 @@ parse (int fd) * Scan the headers of the message and build * a lookup table. */ - for (i = 0, state = FLD;;) { - switch (state = m_getfld (state, name, field, sizeof(field), in)) { + for (i = 0;;) { + int fieldsz = sizeof field; + switch (state = m_getfld (&gstate, name, field, &fieldsz, in)) { case FLD: - case FLDEOF: case FLDPLUS: lp = add (field, NULL); while (state == FLDPLUS) { - state = m_getfld (state, name, field, sizeof(field), in); + fieldsz = sizeof field; + state = m_getfld (&gstate, name, field, &fieldsz, in); lp = add (field, lp); } for (p = hdrs; p->p_name; p++) { @@ -766,12 +768,9 @@ parse (int fd) p++, i++; p->p_name = NULL; } - if (state != FLDEOF) - continue; - break; + continue; case BODY: - case BODYEOF: case FILEEOF: break; @@ -787,6 +786,7 @@ parse (int fd) } break; } + m_getfld_state_destroy (&gstate); fclose (in); if ((p = lookup (vars, "reply-to"))) { @@ -1153,8 +1153,8 @@ static void get_sender (char *envelope, char **sender) { int i; - unsigned char *cp; - unsigned char buffer[BUFSIZ]; + char *cp; + char buffer[BUFSIZ]; if (envelope == NULL) { *sender = getcpy (""); @@ -1174,7 +1174,7 @@ get_sender (char *envelope, char **sender) *cp = 0; for (cp = buffer + strlen (buffer) - 1; cp >= buffer; cp--) - if (isspace (*cp)) + if (isspace ((unsigned char) *cp)) *cp = 0; else break; @@ -1296,7 +1296,7 @@ static char * trim (char *cp) { char buffer[BUFSIZ*4]; - unsigned char *bp, *sp; + char *bp, *sp; if (cp == NULL) return NULL; @@ -1306,12 +1306,12 @@ trim (char *cp) bp = buffer; /* skip over leading whitespace */ - while (isspace(*bp)) + while (isspace((unsigned char) *bp)) bp++; /* start at the end and zap trailing whitespace */ for (sp = bp + strlen(bp) - 1; sp >= bp; sp--) { - if (isspace(*sp)) + if (isspace((unsigned char) *sp)) *sp = 0; else break; @@ -1319,7 +1319,7 @@ trim (char *cp) /* replace remaining whitespace with spaces */ for (sp = bp; *sp; sp++) - if (isspace(*sp)) + if (isspace((unsigned char) *sp)) *sp = ' '; /* now return a copy */ @@ -1405,6 +1405,7 @@ suppress_duplicates (int fd, char *file) datum key, value; DBM *db; FILE *in; + m_getfld_state_t gstate = 0; if ((fd1 = dup (fd)) == -1) return -1; @@ -1414,22 +1415,25 @@ suppress_duplicates (int fd, char *file) } rewind (in); - for (state = FLD;;) { - state = m_getfld (state, name, buf, sizeof(buf), in); + for (;;) { + int bufsz = sizeof buf; + state = m_getfld (&gstate, name, buf, &bufsz, in); switch (state) { case FLD: case FLDPLUS: - case FLDEOF: /* Search for the message ID */ if (mh_strcasecmp (name, "Message-ID")) { - while (state == FLDPLUS) - state = m_getfld (state, name, buf, sizeof(buf), in); + while (state == FLDPLUS) { + bufsz = sizeof buf; + state = m_getfld (&gstate, name, buf, &bufsz, in); + } continue; } cp = add (buf, NULL); while (state == FLDPLUS) { - state = m_getfld (state, name, buf, sizeof(buf), in); + bufsz = sizeof buf; + state = m_getfld (&gstate, name, buf, &bufsz, in); cp = add (buf, cp); } key.dptr = trimcpy (cp); @@ -1477,7 +1481,6 @@ suppress_duplicates (int fd, char *file) break; case BODY: - case BODYEOF: case FILEEOF: break; @@ -1489,6 +1492,7 @@ suppress_duplicates (int fd, char *file) break; } + m_getfld_state_destroy (&gstate); fclose (in); return 0;