From: markus schnalke Date: Wed, 14 Jan 2015 20:56:54 +0000 (+0100) Subject: send: Convert system() to execprog() ... partly X-Git-Tag: mmh-0.2-RC1~73 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=04e93dabf152cc30d0aeb043d65f911ef765a176;p=mmh send: Convert system() to execprog() ... partly --- diff --git a/uip/send.c b/uip/send.c index c2c9f17..3c2db0e 100644 --- a/uip/send.c +++ b/uip/send.c @@ -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"); } }