From dacb12b3c7f0dcaa0ce37c68d4777abb018cac7d Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 27 Jun 2012 13:13:24 +0000 Subject: append "b" to popen modes only on Windows; avoid synctex seg fault with -ini git-svn-id: svn://tug.org/texlive/trunk@26900 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/lib/ChangeLog | 13 +++++++++++++ Build/source/texk/web2c/lib/texmfmp.c | 26 +++++++++++++++++++------- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/Build/source/texk/web2c/lib/ChangeLog b/Build/source/texk/web2c/lib/ChangeLog index 83dfe7b1d3a..1bec2130f51 100644 --- a/Build/source/texk/web2c/lib/ChangeLog +++ b/Build/source/texk/web2c/lib/ChangeLog @@ -1,3 +1,16 @@ +2012-06-27 Norbert Preining + + * texmfmp.c (runpopen): append "b" on Windows. + (open_in_or_pipe): do not use the "b" here. + (This makes pdftex's \input"|..." feature work again, + unintentionally broken.) + tex-live mail, 26 Jun 2012 14:02:26. + +2012-06-27 Karl Berry + + * texmfmp.c (generic_synctex_get_current_name): return the + empty string if passed null (can happen with -ini). + 2012-05-04 Peter Breitenlohner * printversion.c (printversionandexit): Update 'Copyright 2012'. diff --git a/Build/source/texk/web2c/lib/texmfmp.c b/Build/source/texk/web2c/lib/texmfmp.c index eedba336354..70cb3960792 100644 --- a/Build/source/texk/web2c/lib/texmfmp.c +++ b/Build/source/texk/web2c/lib/texmfmp.c @@ -127,6 +127,10 @@ char *generic_synctex_get_current_name (void) { char *pwdbuf, *ret; + if (!fullnameoffile) { + ret = xstrdup(""); + return ret; + } if (kpse_absolute_p(fullnameoffile, false)) { return xstrdup(fullnameoffile); } @@ -523,7 +527,9 @@ runsystem (const char *cmd) /* Like runsystem(), the runpopen() function is called only when shellenabledp == 1. Unlike runsystem(), here we write errors to stderr, since we have nowhere better to use; and of course we return - a file handle (or NULL) instead of a status indicator. */ + a file handle (or NULL) instead of a status indicator. + + Also, we append "b" to MODE on Windows. */ static FILE * runpopen (char *cmd, const char *mode) @@ -532,9 +538,14 @@ runpopen (char *cmd, const char *mode) char *safecmd = NULL; char *cmdname = NULL; int allow; - #ifdef WIN32 char *pp; +#endif + string realmode = xmalloc(strlen(mode)+2); + + strcpy(realmode, mode); +#ifdef WIN32 + strcat(realmode, "b"); for (pp = cmd; *pp; pp++) { if (*pp == '\'') *pp = '"'; @@ -548,9 +559,9 @@ runpopen (char *cmd, const char *mode) allow = shell_cmd_is_allowed (cmd, &safecmd, &cmdname); if (allow == 1) - f = popen (cmd, mode); + f = popen (cmd, realmode); else if (allow == 2) - f = popen (safecmd, mode); + f = popen (safecmd, realmode); else if (allow == -1) fprintf (stderr, "\nrunpopen quotation error in command line: %s\n", cmd); @@ -561,6 +572,7 @@ runpopen (char *cmd, const char *mode) free (safecmd); if (cmdname) free (cmdname); + free (realmode); return f; } #endif /* ENABLE_PIPES */ @@ -1853,7 +1865,7 @@ open_in_or_pipe (FILE **f_ptr, int filefmt, const_string fopen_mode) fname = xmalloc(strlen((const_string)(nameoffile+1))+1); strcpy(fname,(const_string)(nameoffile+1)); recorder_record_input (fname + 1); - *f_ptr = runpopen(fname+1,"rb"); + *f_ptr = runpopen(fname+1,"r"); free(fname); for (i=0; i