diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2017-09-05 22:00:26 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2017-09-05 22:00:26 +0000 |
commit | f3ea6d55e74f5c73f1d804edfcf3590d83a98ee3 (patch) | |
tree | 77af9616e3d7e13d1c554b3e71d864421e242be8 | |
parent | 39b632f4114d433ae2c9b49a177ce30c519b46f3 (diff) |
luatex.c: apply similar changes as texmfmp.c
git-svn-id: svn://tug.org/texlive/trunk@45225 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Build/source/texk/web2c/luatexdir/ChangeLog | 12 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/luatex.c | 29 |
2 files changed, 32 insertions, 9 deletions
diff --git a/Build/source/texk/web2c/luatexdir/ChangeLog b/Build/source/texk/web2c/luatexdir/ChangeLog index f9aa304d879..5f68df41c51 100644 --- a/Build/source/texk/web2c/luatexdir/ChangeLog +++ b/Build/source/texk/web2c/luatexdir/ChangeLog @@ -1,3 +1,15 @@ +2017-09-05 Karl Berry <karl@tug.org> + and Akira Kakuto <kakuto@fuk.kindai.ac.jp> + + * luatex.c (IS_SPC_OR_EOL): new macro. + (topenin): use it, instead of ISBLANK. + (input_line): remove only trailing space characters + instead of using ISBLANK. + See also analogous change in lib/texmfmp.c. + Original bug report from Evan Aad, + http://tug.org/pipermail/tex-k/2017-August/002801.html. + Fix a bug to skip BOM (w32 only). + 2017-02-07 Luigi Scarso <luigi.scarso@gmail.com> * luaffi/: First attempt to implement the ffi module in lua diff --git a/Build/source/texk/web2c/luatexdir/luatex.c b/Build/source/texk/web2c/luatexdir/luatex.c index 2c893cd2bbe..c6ddb639192 100644 --- a/Build/source/texk/web2c/luatexdir/luatex.c +++ b/Build/source/texk/web2c/luatexdir/luatex.c @@ -615,10 +615,15 @@ void topenin(void) /* Find the end of the buffer. */ for (last = first; buffer[last]; ++last); - /* Make `last' be one past the last non-blank character in `buffer'. */ - /* ??? The test for '\r' should not be necessary. */ - for (--last; last >= first - && ISBLANK(buffer[last]) && buffer[last] != '\r'; --last); + /* Make `last' be one past the last non-space character in `buffer', + ignoring line terminators (but not, e.g., tabs). This is because + we are supposed to treat this like a line of TeX input. Although + there are pathological cases (SPC CR SPC CR) where this differs + from input_line below, and from previous behavior of removing all + whitespace, the simplicity of removing all trailing line terminators + seems more in keeping with actual command line processing. */ +#define IS_SPC_OR_EOL(c) ((c) == ' ' || (c) == '\r' || (c) == '\n') + for (--last; last >= first && IS_SPC_OR_EOL (buffer[last]); --last) last++; /* One more time, this time converting to TeX's internal character @@ -1060,9 +1065,10 @@ boolean input_line(FILE * f) ; else { int k3 = getc (f); - - if (k1 == 0xef && k2 == 0xbb && k3 == 0xbf) /* UTF-8 */ - ; + int k4 = getc (f); + if (k1 == 0xef && k2 == 0xbb && k3 == 0xbf && + k4 >= 0 && k4 <= 0x7e) /* UTF-8 */ + ungetc (k4, f); else rewind (f); } @@ -1097,8 +1103,13 @@ boolean input_line(FILE * f) ungetc(i, f); } - /* Trim trailing whitespace. */ - while (last > first && ISBLANK(buffer[last - 1])) + /* Trim trailing space character (but not, e.g., tabs). We can't have + line terminators because we stopped reading at the first \r or \n. + TeX's rule is to strip only trailing spaces (and eols). David + Fuchs mentions that this stripping was done to ensure portability + of TeX documents given the padding with spaces on fixed-record + "lines" on some systems of the time, e.g., IBM VM/CMS and OS/360. */ + while (last > first && buffer[last - 1] == ' ') --last; /* Don't bother using xord if we don't need to. */ |