From 04e93dabf152cc30d0aeb043d65f911ef765a176 Mon Sep 17 00:00:00 2001 From: markus schnalke Date: Wed, 14 Jan 2015 21:56:54 +0100 Subject: [PATCH] send: Convert system() to execprog() ... partly --- uip/send.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) 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"); } } -- 1.7.10.4