send: Convert system() to execprog() ... partly
authormarkus schnalke <meillo@marmaro.de>
Wed, 14 Jan 2015 20:56:54 +0000 (21:56 +0100)
committermarkus schnalke <meillo@marmaro.de>
Wed, 14 Jan 2015 20:56:54 +0000 (21:56 +0100)
uip/send.c

index c2c9f17..3c2db0e 100644 (file)
@@ -674,6 +674,9 @@ anno(struct stat *st)
        struct stat st2;
        char *msgs, *folder;
        char buf[BUFSIZ];
+       char *vec[MAXARGS];
+       int vecp;
+       char *cp, *dp;
 
        if (altmsg && (stat(altmsg, &st2) == NOTOK ||
                        st->st_mtime != st2.st_mtime ||
@@ -701,9 +704,27 @@ anno(struct stat *st)
                advise(NULL, "annotate as `%s': %s %s", annotext,
                                folder, msgs);
        }
-       snprintf(buf, sizeof buf, "anno -comp '%s' '+%s' %s",
-                       annotext, folder, msgs);
-       if (system(buf) != 0) {
+       vec[vecp++] = "anno";
+       vec[vecp++] = "-comp";
+       vec[vecp++] = annotext;
+       snprintf(buf, sizeof buf, "+%s", folder);
+       vec[vecp++] = buf;
+
+       while (isspace(*msgs)) {
+               msgs++;
+       }
+       for (cp=dp=msgs; *cp; cp++) {
+               if (isspace(*cp)) {
+                       while (isspace(*cp)) {
+                               *cp++ = '\0';
+                       }
+                       vec[vecp++] = dp;
+                       dp = cp;
+               }
+       }
+       vec[vecp++] = dp;
+       vec[vecp] = NULL;
+       if (execprog(*vec, vec) != 0) {
                advise(NULL, "unable to annotate");
        }
 }