diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2013-01-18 12:02:40 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2013-01-18 12:02:40 +0000 |
commit | 83881755c0c8346dd450a2a3ffc2f446961d4497 (patch) | |
tree | 650271233979d332892f0e9879f4b2c6e4f9f286 /Build/source/texk/web2c/lib/texmfmp.c | |
parent | 1edf6b64eb5ea6b65099076e92bccb6a90d2d88b (diff) |
texk/web2c: Simplify mk_shellcmdlist()
git-svn-id: svn://tug.org/texlive/trunk@28861 c570f23f-e606-0410-a88d-b1316a301751
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 |