diff options
Diffstat (limited to 'Build')
-rw-r--r-- | Build/source/texk/web2c/luatexdir/ChangeLog | 4 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/luatex.c | 29 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/tex/texfileio.h | 4 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/tex/texfileio.w | 13 |
4 files changed, 49 insertions, 1 deletions
diff --git a/Build/source/texk/web2c/luatexdir/ChangeLog b/Build/source/texk/web2c/luatexdir/ChangeLog index ffc4182063e..c7716cfac96 100644 --- a/Build/source/texk/web2c/luatexdir/ChangeLog +++ b/Build/source/texk/web2c/luatexdir/ChangeLog @@ -4,6 +4,10 @@ * luatex.c (swap_items): Moved from here ... * tex/texfileio.w (swap_items): ... to here and declared static. + * luatex.c (input_line) [WIN32]: Sync with ../lib/texmfmp.c. + Detect and skip Byte order marks. + * tex/texfileio.[ch] [WIN32]: Use Poptr to record pipe input. + 2012-08-03 Peter Breitenlohner <peb@mppmu.mpg.de> * luatex.[ch] [W32TeX]: Use DLLPROC for luatex.dll. diff --git a/Build/source/texk/web2c/luatexdir/luatex.c b/Build/source/texk/web2c/luatexdir/luatex.c index 0d540533ee4..190f080f59d 100644 --- a/Build/source/texk/web2c/luatexdir/luatex.c +++ b/Build/source/texk/web2c/luatexdir/luatex.c @@ -842,6 +842,35 @@ boolean input_line(FILE * f) { int i = EOF; +#ifdef WIN32 + if (f != Poptr && fileno (f) != fileno (stdin)) { + long position = ftell (f); + + if (position == 0L) { /* Detect and skip Byte order marks. */ + int k1 = getc (f); + + if (k1 != 0xff && k1 != 0xfe && k1 != 0xef) + rewind (f); + else { + int k2 = getc (f); + + if (k2 != 0xff && k2 != 0xfe && k2 != 0xbb) + rewind (f); + else if ((k1 == 0xff && k2 == 0xfe) || /* UTF-16(LE) */ + (k1 == 0xfe && k2 == 0xff)) /* UTF-16(BE) */ + ; + else { + int k3 = getc (f); + + if (k1 == 0xef && k2 == 0xbb && k3 == 0xbf) /* UTF-8 */ + ; + else + rewind (f); + } + } + } + } +#endif /* Recognize either LF or CR as a line terminator. */ last = first; while (last < buf_size && (i = getc(f)) != EOF && i != '\n' && i != '\r') diff --git a/Build/source/texk/web2c/luatexdir/tex/texfileio.h b/Build/source/texk/web2c/luatexdir/tex/texfileio.h index ceb7a1383fd..7b2b17b2d53 100644 --- a/Build/source/texk/web2c/luatexdir/tex/texfileio.h +++ b/Build/source/texk/web2c/luatexdir/tex/texfileio.h @@ -135,6 +135,10 @@ extern int readbinfile(FILE * f, unsigned char **b, int *s); extern boolean openinnameok(const_string); extern boolean openoutnameok(const_string); +# ifdef WIN32 +extern FILE *Poptr; +# endif + extern boolean open_in_or_pipe(FILE **, char *, int, const_string fopen_mode, boolean must_exist); extern boolean open_out_or_pipe(FILE **, char *, const_string fopen_mode); diff --git a/Build/source/texk/web2c/luatexdir/tex/texfileio.w b/Build/source/texk/web2c/luatexdir/tex/texfileio.w index 7123bdfb557..201c78dea41 100644 --- a/Build/source/texk/web2c/luatexdir/tex/texfileio.w +++ b/Build/source/texk/web2c/luatexdir/tex/texfileio.w @@ -1270,6 +1270,10 @@ static FILE *pipes[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; +#ifdef WIN32 +FILE *Poptr; +#endif + boolean open_in_or_pipe(FILE ** f_ptr, char *fn, int filefmt, const_string fopen_mode, boolean must_exist) { @@ -1299,6 +1303,9 @@ boolean open_in_or_pipe(FILE ** f_ptr, char *fn, int filefmt, } if (*f_ptr) setvbuf(*f_ptr, (char *) NULL, _IOLBF, 0); +#ifdef WIN32 + Poptr = *f_ptr; +#endif return *f_ptr != NULL; } @@ -1360,8 +1367,12 @@ void close_file_or_pipe(FILE * f) for (i = 0; i <= 15; i++) { /* if this file was a pipe, |pclose()| it and return */ if (pipes[i] == f) { - if (f) + if (f) { pclose(f); +#ifdef WIN32 + Poptr = NULL; +#endif + } pipes[i] = NULL; return; } |