summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/tex/texfileio.w
diff options
context:
space:
mode:
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);