]> diplodocus.org Git - nmh/blobdiff - uip/slocal.c
Just show relevant portion of invalid encoded string.
[nmh] / uip / slocal.c
index 3ba3fd427675ba800a081a4cc3588832cf357017..41eda311dbe89eac4d5d418ac262420bf76fbccc 100644 (file)
@@ -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;
+        TrimSuffixC(buffer, '\n');
 
        /* split buffer into fields */
        vecp = split (buffer, vec);
@@ -1127,16 +1125,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 +1164,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;
@@ -1253,11 +1250,10 @@ 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 (HasPrefix(buffer, "From ")) {
                /* get copy of envelope information ("From " line) */
                envelope = mh_xstrdup(buffer);
 
@@ -1341,7 +1337,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 +1357,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);
 }