]> diplodocus.org Git - nmh/blobdiff - uip/rcvdist.c
Added many flags to CFLAGS with gcc, if supported.
[nmh] / uip / rcvdist.c
index 531518d8dd54efe8466a410534b28806f93938f5..c6698865d7ad916a9809866aa19d65384b7385be 100644 (file)
@@ -85,7 +85,7 @@ DEFINE_SWITCH_ENUM(POST);
 #undef X
 
 #define X(sw, minchars, id) { sw, minchars, id },
-DEFINE_SWITCH_ARRAY(POST, post_switches);
+DEFINE_SWITCH_ARRAY(POST, post_switches_with_args);
 #undef X
 
 static char backup[BUFSIZ] = "";
@@ -130,17 +130,19 @@ main (int argc, char **argv)
                case AMBIGSW: 
                    ambigsw (cp, switches);
                    done (1);
-               case UNKWNSW: 
+               case UNKWNSW: {
+                   const int argno = smatch(cp, post_switches_with_args);
                    vec[vecp++] = --cp;
-                   if (smatch(cp + 1, post_switches) != UNKWNSW) {
+                   if (argno != AMBIGSW && argno != UNKWNSW) {
                        /* It's a post switch that does take an argument. */
                        if (!(cp = *argp) || *cp == '-') {
                            die("missing argument to %s", argp[-1]);
                        }
-                        vec[vecp++] = *argp++;
+                       vec[vecp++] = cp;
+                       ++argp;
                    }
                    continue;
-
+               }
                case HELPSW: 
                    snprintf (buf, sizeof(buf),
                        "%s [switches] [switches for postproc] address ...",
@@ -169,7 +171,7 @@ main (int argc, char **argv)
     if ((tfile = m_mktemp2(NULL, invo_name, NULL, &fp)) == NULL) {
        die("unable to create temporary file in %s", get_temp_dir());
     }
-    strncpy (tmpfil, tfile, sizeof(tmpfil));
+    strncpy (tmpfil, tfile, sizeof(tmpfil) - 1);
 
     cpydata (fileno (stdin), fileno (fp), "message", tmpfil);
     fseek (fp, 0L, SEEK_SET);
@@ -177,7 +179,7 @@ main (int argc, char **argv)
     if ((tfile = m_mktemp2(NULL, invo_name, NULL, NULL)) == NULL) {
        die("unable to create temporary file in %s", get_temp_dir());
     }
-    strncpy (drft, tfile, sizeof(tmpfil));
+    strncpy (drft, tfile, sizeof(drft) - 1);
 
     rcvdistout (fp, form, addrs);
     fclose (fp);
@@ -271,7 +273,7 @@ rcvdistout (FILE *inb, char *form, char *addrs)
        switch (state = m_getfld2(&gstate, name, tmpbuf, &msg_count)) {
            case FLD: 
            case FLDPLUS: 
-               i = fmt_addcomptext(name, tmpbuf);
+               i = fmt_addcomptext(name, tmpbuf);
                if (i != -1) {
                    char_read += msg_count;
                    while (state == FLDPLUS) {