diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2012-07-09 13:19:46 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2012-07-09 13:19:46 +0000 |
commit | 2db3e832883b212925d0599d113a1a1000d0bb7e (patch) | |
tree | 4a6d053c29dc7092151b37f3a577f210dae6abfe /Build/source/texk/web2c/luatexdir/luatex.c | |
parent | b98940bc6a3d63959c1e0c07acf5c09626bf9efa (diff) |
luaTeX: Use binary file io mode (from W32TeX)
Sync shell_cmd_is_allowed() and runpopen() with ../lib/texmfmp.c
git-svn-id: svn://tug.org/texlive/trunk@26978 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/luatex.c')
-rw-r--r-- | Build/source/texk/web2c/luatexdir/luatex.c | 77 |
1 files changed, 38 insertions, 39 deletions
diff --git a/Build/source/texk/web2c/luatexdir/luatex.c b/Build/source/texk/web2c/luatexdir/luatex.c index 35da4e0e55c..814ee4d7f49 100644 --- a/Build/source/texk/web2c/luatexdir/luatex.c +++ b/Build/source/texk/web2c/luatexdir/luatex.c @@ -208,24 +208,24 @@ static int Isspace(char c) should get executed. And we set CMDNAME to its first word; this is what is checked against the shell_escape_commands list. */ -int shell_cmd_is_allowed(const char **cmd, char **safecmd, char **cmdname) +int shell_cmd_is_allowed(const char *cmd, char **safecmd, char **cmdname) { char **p; char *buf; - char *s, *d; - const char *ss; + char *c, *d; + const char *s; int pre; unsigned spaces; int allow = 0; /* pre == 1 means that the previous character is a white space pre == 0 means that the previous character is not a white space */ - buf = (char *) xmalloc((unsigned) strlen(*cmd) + 1); - strcpy(buf, *cmd); - s = buf; - while (Isspace(*s)) - s++; - d = s; + buf = xmalloc(strlen(cmd) + 1); + strcpy(buf, cmd); + c = buf; + while (Isspace(*c)) + c++; + d = c; while (!Isspace(*d) && *d) d++; *d = '\0'; @@ -234,7 +234,7 @@ int shell_cmd_is_allowed(const char **cmd, char **safecmd, char **cmdname) *cmdname == "kpsewhich" for \write18{kpsewhich --progname=dvipdfm --format="other text files" config} */ - *cmdname = xstrdup(s); + *cmdname = xstrdup(c); free(buf); /* Is *cmdname listed in a texmf.cnf vriable as @@ -253,37 +253,36 @@ int shell_cmd_is_allowed(const char **cmd, char **safecmd, char **cmdname) } if (allow == 2) { spaces = 0; - for (ss = *cmd; *ss; ss++) { - if (Isspace(*ss)) + for (s = cmd; *s; s++) { + if (Isspace(*s)) spaces++; } /* allocate enough memory (too much?) */ # ifdef WIN32 - *safecmd = - (char *) xmalloc(2 * (unsigned) strlen(*cmd) + 3 + 2 * spaces); + *safecmd = xmalloc(2 * strlen(cmd) + 3 + 2 * spaces); # else - *safecmd = (char *) xmalloc((unsigned) strlen(*cmd) + 3 + 2 * spaces); + *safecmd = xmalloc(strlen(cmd) + 3 + 2 * spaces); # endif /* make a safe command line *safecmd */ - ss = *cmd; - while (Isspace(*ss)) - ss++; + s = cmd; + while (Isspace(*s)) + s++; d = *safecmd; - while (!Isspace(*ss) && *ss) - *d++ = *ss++; + while (!Isspace(*s) && *s) + *d++ = *s++; pre = 1; - while (*ss) { + while (*s) { /* Quotation given by a user. " should always be used; we transform it below. On Unix, if ' is used, simply immediately return a quotation error. */ - if (*ss == '\'') { + if (*s == '\'') { return -1; } - if (*ss == '"') { + if (*s == '"') { /* All arguments are quoted as 'foo' (Unix) or "foo" (Windows) before calling system(). Therefore closing QUOTE is necessary if the previous character is not a white space. @@ -298,51 +297,51 @@ int shell_cmd_is_allowed(const char **cmd, char **safecmd, char **cmdname) pre = 0; /* output the quotation mark for the quoted argument */ *d++ = QUOTE; - ss++; + s++; - while (*ss != '"') { + while (*s != '"') { /* Illegal use of ', or closing quotation mark is missing */ - if (*ss == '\'' || *ss == '\0') + if (*s == '\'' || *s == '\0') return -1; # ifdef WIN32 - if (char_needs_quote(*ss)) + if (char_needs_quote(*s)) *d++ = '^'; # endif - *d++ = *ss++; + *d++ = *s++; } /* Closing quotation mark will be output afterwards, so we do nothing here */ - ss++; + s++; /* The character after the closing quotation mark should be a white space or NULL */ - if (!Isspace(*ss) && *ss) + if (!Isspace(*s) && *s) return -1; /* Beginning of a usual argument */ - } else if (pre == 1 && !Isspace(*ss)) { + } else if (pre == 1 && !Isspace(*s)) { pre = 0; *d++ = QUOTE; # ifdef WIN32 - if (char_needs_quote(*ss)) + if (char_needs_quote(*s)) *d++ = '^'; # endif - *d++ = *ss++; + *d++ = *s++; /* Ending of a usual argument */ - } else if (pre == 0 && Isspace(*ss)) { + } else if (pre == 0 && Isspace(*s)) { pre = 1; /* Closing quotation mark */ *d++ = QUOTE; - *d++ = *ss++; + *d++ = *s++; } else { - /* Copy a character from *cmd to *safecmd. */ + /* Copy a character from cmd to *safecmd. */ # ifdef WIN32 - if (char_needs_quote(*ss)) + if (char_needs_quote(*s)) *d++ = '^'; # endif - *d++ = *ss++; + *d++ = *s++; } } /* End of the command line */ @@ -408,7 +407,7 @@ int runsystem(char *cmd) allow = 1; } else { const char *thecmd = cmd; - allow = shell_cmd_is_allowed(&thecmd, &safecmd, &cmdname); + allow = shell_cmd_is_allowed(thecmd, &safecmd, &cmdname); } if (allow == 1) |