diff options
Diffstat (limited to 'Build/source/texk/web2c/lib/texmfmp.c')
-rw-r--r-- | Build/source/texk/web2c/lib/texmfmp.c | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/Build/source/texk/web2c/lib/texmfmp.c b/Build/source/texk/web2c/lib/texmfmp.c index e4779a6f08c..47d52321930 100644 --- a/Build/source/texk/web2c/lib/texmfmp.c +++ b/Build/source/texk/web2c/lib/texmfmp.c @@ -209,40 +209,31 @@ mk_shellcmdlist (char *v) { char **p; char *q, *r; - int n; + size_t n; q = v; - n = 0; + n = 1; /* analyze the variable shell_escape_commands = foo,bar,... spaces before and after (,) are not allowed. */ while ((r = strchr (q, ',')) != 0) { n++; - r++; - q = r; + q = r + 1; } if (*q) n++; - cmdlist = xmalloc ((n + 1) * sizeof (char *)); + cmdlist = xmalloc (n * sizeof (char *)); p = cmdlist; q = v; while ((r = strchr (q, ',')) != 0) { *r = '\0'; - *p = xmalloc (strlen (q) + 1); - strcpy (*p, q); - *r = ','; - r++; - q = r; - p++; + *p++ = xstrdup (q); + q = r + 1; } - if (*q) { - *p = xmalloc (strlen (q) + 1); - strcpy (*p, q); - p++; - *p = NULL; - } else - *p = NULL; + if (*q) + *p++ = xstrdup (q); + *p = NULL; } static void |