X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/8bb0f8000b86df9270f2410de3fb6f41fa63e88b..8a97d4892770a49955add690ac2a53bdc6bf2fcf:/uip/replsbr.c diff --git a/uip/replsbr.c b/uip/replsbr.c index d81eb745..b696ae71 100644 --- a/uip/replsbr.c +++ b/uip/replsbr.c @@ -412,7 +412,8 @@ replfilter (FILE *in, FILE *out, char *filter, int fmtproc) int pid; char *mhl; char *errstr; - char *arglist[7]; + char **arglist; + int argnum; if (filter == NULL) return; @@ -420,8 +421,6 @@ replfilter (FILE *in, FILE *out, char *filter, int fmtproc) if (access (filter, R_OK) == NOTOK) adios (filter, "unable to read"); - mhl = r1bindex (mhlproc, '/'); - rewind (in); lseek (fileno(in), (off_t) 0, SEEK_SET); @@ -434,26 +433,29 @@ replfilter (FILE *in, FILE *out, char *filter, int fmtproc) dup2 (fileno (out), fileno (stdout)); closefds (3); - arglist[0] = mhl; - arglist[1] = "-form"; - arglist[2] = filter; - arglist[3] = "-noclear"; + /* + * We're not allocating the memory for the extra arguments, + * because we never call arglist_free(). But if we ever change + * that be sure to use getcpy() for the extra arguments. + */ + arglist = argsplit(mhlproc, &mhl, &argnum); + arglist[argnum++] = "-form"; + arglist[argnum++] = filter; + arglist[argnum++] = "-noclear"; switch (fmtproc) { case 1: - arglist[4] = "-fmtproc"; - arglist[5] = formatproc; - arglist[6] = NULL; + arglist[argnum++] = "-fmtproc"; + arglist[argnum++] = formatproc; break; case 0: - arglist[4] = "-nofmtproc"; - arglist[5] = NULL; + arglist[argnum++] = "-nofmtproc"; break; - default: - arglist[4] = NULL; } - execvp (mhlproc, arglist); + arglist[argnum++] = NULL; + + execvp (mhl, arglist); errstr = strerror(errno); write(2, "unable to exec ", 15); write(2, mhlproc, strlen(mhlproc));