texlive[45225] Build/source/texk/web2c/luatexdir: luatex.c: apply
commits+kakuto at tug.org
commits+kakuto at tug.org
Wed Sep 6 00:00:27 CEST 2017
Revision: 45225
http://tug.org/svn/texlive?view=revision&revision=45225
Author: kakuto
Date: 2017-09-06 00:00:26 +0200 (Wed, 06 Sep 2017)
Log Message:
-----------
luatex.c: apply similar changes as texmfmp.c
Modified Paths:
--------------
trunk/Build/source/texk/web2c/luatexdir/ChangeLog
trunk/Build/source/texk/web2c/luatexdir/luatex.c
Modified: trunk/Build/source/texk/web2c/luatexdir/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/luatexdir/ChangeLog 2017-09-05 21:57:29 UTC (rev 45224)
+++ trunk/Build/source/texk/web2c/luatexdir/ChangeLog 2017-09-05 22:00:26 UTC (rev 45225)
@@ -1,3 +1,15 @@
+2017-09-05 Karl Berry <karl at tug.org>
+ and Akira Kakuto <kakuto at 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 at gmail.com>
* luaffi/: First attempt to implement the ffi module in lua
Modified: trunk/Build/source/texk/web2c/luatexdir/luatex.c
===================================================================
--- trunk/Build/source/texk/web2c/luatexdir/luatex.c 2017-09-05 21:57:29 UTC (rev 45224)
+++ trunk/Build/source/texk/web2c/luatexdir/luatex.c 2017-09-05 22:00:26 UTC (rev 45225)
@@ -615,10 +615,15 @@
/* 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 @@
;
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 @@
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. */
More information about the tex-live-commits
mailing list