diff options
Diffstat (limited to 'Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/dpxfile.c')
-rw-r--r-- | Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/dpxfile.c | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/dpxfile.c b/Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/dpxfile.c index 16c81eaf503..dbbf077989c 100644 --- a/Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/dpxfile.c +++ b/Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/dpxfile.c @@ -155,9 +155,13 @@ static int exec_spawn (char *cmd) char **cmdv, **qv; char *p, *pp; char buf[1024]; - int i, ret; + int i, ret = -1; - if (!cmd || !*cmd) + if (!cmd) + return -1; + while (*cmd == ' ' || *cmd == '\t') + cmd++; + if (*cmd == '\0') return -1; i = 0; p = cmd; @@ -166,19 +170,16 @@ static int exec_spawn (char *cmd) i++; p++; } - cmdv = (char **) xmalloc (sizeof (char *) * (i+2)); + cmdv = xcalloc (i + 2, sizeof (char *)); p = cmd; qv = cmdv; - while (*p == ' ' || *p == '\t') - p++; while (*p) { pp = buf; if (*p == '"') { p++; while (*p != '"') { if (*p == '\0') { - free (cmdv); - return -1; + goto done; } *pp++ = *p++; } @@ -187,8 +188,7 @@ static int exec_spawn (char *cmd) p++; while (*p != '\'') { if (*p == '\0') { - free (cmdv); - return -1; + goto done; } *pp++ = *p++; } @@ -199,8 +199,7 @@ static int exec_spawn (char *cmd) p++; while (*p != '\'') { if (*p == '\0') { - free (cmdv); - return -1; + goto done; } *pp++ = *p++; } @@ -211,7 +210,7 @@ static int exec_spawn (char *cmd) } } *pp = '\0'; - if ((pp = strchr (buf, ' ')) || (pp = strchr (buf, '\t'))) { + if (strchr (buf, ' ') || strchr (buf, '\t')) { #ifdef WIN32 *qv = concat3 ("\"", buf, "\""); #else @@ -227,7 +226,6 @@ static int exec_spawn (char *cmd) p++; qv++; } - *qv = NULL; #ifdef WIN32 ret = spawnvp (_P_WAIT, *cmdv, (const char* const*) cmdv); #else @@ -236,7 +234,7 @@ static int exec_spawn (char *cmd) ret = -1; else if (i == 0) { if (execvp (*cmdv, cmdv)) - ret = -1; + _exit (-1); } else { if (wait (&ret) == i) { ret = (WIFEXITED (ret) ? WEXITSTATUS (ret) : -1); @@ -245,14 +243,13 @@ static int exec_spawn (char *cmd) } } #endif +done: qv = cmdv; - if (qv) { - while (*qv) { - free (*qv); - qv++; - } - free (cmdv); + while (*qv) { + free (*qv); + qv++; } + free (cmdv); return ret; } |