X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/3bd5ce286fa6983f3f3f9fda4ff7f2f96c2a22a2..9322ba2854211794c27fae9468768b80b767c211:/uip/slocal.c diff --git a/uip/slocal.c b/uip/slocal.c index 71c67b1e..f41b6ad3 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -423,7 +423,7 @@ usr_delivery (int fd, char *delivery, int su) int i, accept, status=1, won, vecp, next; char *field, *pattern, *action, *result, *string; char buffer[BUFSIZ], tmpbuf[BUFSIZ]; - char *cp, *vec[NVEC]; + char *vec[NVEC]; struct stat st; struct pair *p; FILE *fp; @@ -452,9 +452,7 @@ usr_delivery (int fd, char *delivery, int su) if (*buffer == '#' || *buffer == '\n') continue; - /* zap trailing newline */ - if ((cp = strchr(buffer, '\n'))) - *cp = 0; + trim_suffix_c(buffer, '\n'); /* split buffer into fields */ vecp = split (buffer, vec); @@ -486,7 +484,8 @@ usr_delivery (int fd, char *delivery, int su) * do this - else fall through */ if (!next) - continue; /* else fall */ + continue; + /* FALLTHRU */ case '?': /* @@ -494,7 +493,8 @@ usr_delivery (int fd, char *delivery, int su) * consider delivered if action is successful. */ if (won) - continue; /* else fall */ + continue; + /* FALLTHRU */ case 'A': case 'a': @@ -540,7 +540,8 @@ usr_delivery (int fd, char *delivery, int su) if (won) continue; break; - } /* else fall */ + } + /* FALLTHRU */ default: /* parse message and build lookup table */ @@ -567,7 +568,8 @@ usr_delivery (int fd, char *delivery, int su) case 'q': /* deliver to quoted pipe */ if (strcasecmp (action, "qpipe")) - continue; /* else fall */ + continue; + /* FALLTHRU */ case '^': expand (tmpbuf, string, fd); if (split (tmpbuf, vec) < 1) @@ -578,7 +580,8 @@ usr_delivery (int fd, char *delivery, int su) case 'p': /* deliver to pipe */ if (strcasecmp (action, "pipe")) - continue; /* else fall */ + continue; + /* FALLTHRU */ case '|': vec[2] = "sh"; vec[3] = "-c"; @@ -596,7 +599,8 @@ usr_delivery (int fd, char *delivery, int su) } /* deliver to nmh folder */ else if (strcasecmp (action, "folder")) - continue; /* else fall */ + continue; + /* FALLTHRU */ case '+': status = usr_folder (fd, string); break; @@ -609,7 +613,8 @@ usr_delivery (int fd, char *delivery, int su) } /* mbox format */ else if (strcasecmp (action, "mbox")) - continue; /* else fall */ + continue; + /* FALLTHRU */ case '>': /* mbox format */ @@ -737,7 +742,7 @@ parse (int fd) switch (state = m_getfld (&gstate, name, field, &fieldsz, in)) { case FLD: case FLDPLUS: - lp = add (field, NULL); + lp = mh_xstrdup(field); while (state == FLDPLUS) { fieldsz = sizeof field; state = m_getfld (&gstate, name, field, &fieldsz, in); @@ -763,7 +768,7 @@ parse (int fd) } } if (p->p_name == NULL && i < NVEC) { - p->p_name = getcpy (name); + p->p_name = mh_xstrdup(name); p->p_value = lp; p->p_flags = P_NIL; p++, i++; @@ -874,7 +879,7 @@ glob (int fd) if ((p = lookup (vars, "size"))) { snprintf (buffer, sizeof(buffer), "%d", fstat (fd, &st) != -1 ? (int) st.st_size : 0); - p->p_value = getcpy (buffer); + p->p_value = mh_xstrdup(buffer); } if ((p = lookup (vars, "info"))) p->p_value = getcpy (info); @@ -1127,16 +1132,15 @@ usr_pipe (int fd_arg, char *cmd, char *pgm, char **vec, int suppress) pidstatus (status, stdout, ", failed"); } return (status == 0 ? 0 : -1); - } else { - /* - * Ruthlessly kill the child and anything - * else in its process group. - */ - killpg(child_id, SIGKILL); - if (verbose) - verbose_printf (", timed-out; terminated\n"); - return -1; } + /* + * Ruthlessly kill the child and anything + * else in its process group. + */ + killpg(child_id, SIGKILL); + if (verbose) + verbose_printf (", timed-out; terminated\n"); + return -1; } } @@ -1167,7 +1171,7 @@ get_sender (char *envelope, char **sender) return; } - i = strlen ("From "); + i = LEN("From "); strncpy (buffer, envelope + i, sizeof(buffer)); if ((cp = strchr(buffer, '\n'))) { *cp = 0; @@ -1184,7 +1188,7 @@ get_sender (char *envelope, char **sender) *cp = 0; else break; - *sender = getcpy (buffer); + *sender = mh_xstrdup(buffer); } @@ -1253,13 +1257,12 @@ you_lose: * and massage the headers. Save * a copy of the "From " line for later. */ - i = strlen ("From "); while (fgets (buffer, sizeof(buffer), qfp)) { if (first) { first = 0; - if (!strncmp (buffer, "From ", i)) { + if (has_prefix(buffer, "From ")) { /* get copy of envelope information ("From " line) */ - envelope = getcpy (buffer); + envelope = mh_xstrdup(buffer); /* Put the delivery date in message */ fputs (ddate, ffp); @@ -1328,7 +1331,7 @@ trim (char *cp) *sp = ' '; /* now return a copy */ - return getcpy(bp); + return mh_xstrdup(bp); } /* @@ -1341,7 +1344,7 @@ verbose_printf (char *fmt, ...) va_list ap; va_start(ap, fmt); - vfprintf (stdout, fmt, ap); + vprintf(fmt, ap); va_end(ap); fflush (stdout); /* now flush output */ @@ -1361,22 +1364,22 @@ adorn (char *what, char *fmt, ...) char *s; eindex = errno; /* save the errno */ - fprintf (stdout, ", "); + printf(", "); va_start(ap, fmt); - vfprintf (stdout, fmt, ap); + vprintf(fmt, ap); va_end(ap); if (what) { if (*what) - fprintf (stdout, " %s: ", what); + printf(" %s: ", what); if ((s = strerror (eindex))) - fprintf (stdout, "%s", s); + fputs(s, stdout); else - fprintf (stdout, "Error %d", eindex); + printf("Error %d", eindex); } - fputc ('\n', stdout); + putchar('\n'); fflush (stdout); } @@ -1436,7 +1439,7 @@ suppress_duplicates (int fd, char *file) continue; } - cp = add (buf, NULL); + cp = mh_xstrdup(buf); while (state == FLDPLUS) { bufsz = sizeof buf; state = m_getfld (&gstate, name, buf, &bufsz, in);