summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/tex/texfileio.w
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2012-07-09 13:19:46 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2012-07-09 13:19:46 +0000
commit2db3e832883b212925d0599d113a1a1000d0bb7e (patch)
tree4a6d053c29dc7092151b37f3a577f210dae6abfe /Build/source/texk/web2c/luatexdir/tex/texfileio.w
parentb98940bc6a3d63959c1e0c07acf5c09626bf9efa (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/tex/texfileio.w')
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/texfileio.w22
1 files changed, 20 insertions, 2 deletions
diff --git a/Build/source/texk/web2c/luatexdir/tex/texfileio.w b/Build/source/texk/web2c/luatexdir/tex/texfileio.w
index 523b9e4f2ec..3d9afbe37e6 100644
--- a/Build/source/texk/web2c/luatexdir/tex/texfileio.w
+++ b/Build/source/texk/web2c/luatexdir/tex/texfileio.w
@@ -1125,20 +1125,38 @@ int readbinfile(FILE * f, unsigned char **tfm_buffer, int *tfm_size)
stderr, since we have nowhere better to use; and of course we return
a file handle (or NULL) instead of a status indicator.
+ Also, we append "b" to IO_MODE on Windows.
+
@c
-static FILE *runpopen(char *cmd, const char *mode)
+static FILE *runpopen(char *cmd, const char *io_mode)
{
FILE *f = NULL;
char *safecmd = NULL;
char *cmdname = NULL;
int allow;
+#ifndef WIN32
+ /* Use mode "r" or "w" for Posix. */
+ char mode[] = "X";
+#else
+ /* Use mode "rb" or "wb" for Windows. */
+ char mode[] = "Xb";
+ char *pp;
+
+ for (pp = cmd; *pp; pp++) {
+ if (*pp == '\'') *pp = '"';
+ }
+#endif
+
+ /* Replace 'X' by 'r' or 'w'. */
+ mode[0] = *io_mode;
+
/* If restrictedshell == 0, any command is allowed. */
if (restrictedshell == 0) {
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)
f = popen(cmd, mode);