summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-09-05 17:56:45 +0000
committerKarl Berry <karl@freefriends.org>2017-09-05 17:56:45 +0000
commit0ba29ce4e645334229114e3a1d97a89b5ee0eb9a (patch)
treea44af28023dd0e6b236b8c95bcd9a3b2640569b6 /Build
parentff1fa94aaa339cb7c5702289206d7f0d44471a7e (diff)
strip only trailing spaces on input, not tabs et al.
git-svn-id: svn://tug.org/texlive/trunk@45221 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/web2c/lib/ChangeLog12
-rw-r--r--Build/source/texk/web2c/lib/texmfmp.c24
-rw-r--r--Build/source/texk/web2c/xetexdir/ChangeLog9
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeX_ext.c5
4 files changed, 42 insertions, 8 deletions
diff --git a/Build/source/texk/web2c/lib/ChangeLog b/Build/source/texk/web2c/lib/ChangeLog
index c2d8a540345..96160bd4078 100644
--- a/Build/source/texk/web2c/lib/ChangeLog
+++ b/Build/source/texk/web2c/lib/ChangeLog
@@ -1,3 +1,15 @@
+2017-09-05 Karl Berry <karl@tug.org>
+ and Akira Kakuto <kakuto@fuk.kindai.ac.jp>
+
+ * texmfmp.c (IS_SPC_OR_EOL): new macro.
+ (topenin): use it, instead of ISBLANK.
+ (parse_first_line): doc fix.
+ (input_line): remove only trailing space characters
+ instead of using ISBLANK.
+ See also analogous change in xetexdir/XeTeX_ext.c.
+ Original bug report from Evan Aad,
+ http://tug.org/pipermail/tex-k/2017-August/002801.html
+
2017-03-12 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
* texmfmp.c: Adopt Jonathan's solution for the Change on 2017-02-01.
diff --git a/Build/source/texk/web2c/lib/texmfmp.c b/Build/source/texk/web2c/lib/texmfmp.c
index c8b1dcc1b25..55dea7291bb 100644
--- a/Build/source/texk/web2c/lib/texmfmp.c
+++ b/Build/source/texk/web2c/lib/texmfmp.c
@@ -1079,10 +1079,15 @@ topenin (void)
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++;
@@ -1945,6 +1950,8 @@ parse_first_line (const_string filename)
int npart;
char **parse;
+ /* Here we use ISBLANK instead of IS_SPC_OR_EOL because we are
+ parsing the whitespace-delimited %& line, not TeX input. */
for (s = first_line+2; ISBLANK(*s); ++s)
;
npart = 0;
@@ -2404,8 +2411,13 @@ 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. */
diff --git a/Build/source/texk/web2c/xetexdir/ChangeLog b/Build/source/texk/web2c/xetexdir/ChangeLog
index b6bcfb6859f..d937561b22b 100644
--- a/Build/source/texk/web2c/xetexdir/ChangeLog
+++ b/Build/source/texk/web2c/xetexdir/ChangeLog
@@ -1,3 +1,12 @@
+2017-09-05 Karl Berry <karl@tug.org>
+ and Akira Kakuto <kakuto@fuk.kindai.ac.jp>
+
+ * xetexdir/XeTeX_ext.c (IS_SPC_OR_EOL): new macro.
+ (input_line): use it, instead of 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
+
2017-08-06 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
* pdfimage.cpp: Support /Rotate in PDF image inclusion with
diff --git a/Build/source/texk/web2c/xetexdir/XeTeX_ext.c b/Build/source/texk/web2c/xetexdir/XeTeX_ext.c
index a5ba2e40a46..533423bf052 100644
--- a/Build/source/texk/web2c/xetexdir/XeTeX_ext.c
+++ b/Build/source/texk/web2c/xetexdir/XeTeX_ext.c
@@ -466,8 +466,9 @@ static uint32_t *utf32Buf = NULL;
if (last >= maxbufstack)
maxbufstack = last;
- /* Trim trailing whitespace. */
- while (last > first && ISBLANK(buffer[last - 1]))
+ /* Trim trailing space or EOL characters. */
+#define IS_SPC_OR_EOL(c) ((c) == ' ' || (c) == '\r' || (c) == '\n')
+ while (last > first && IS_SPC_OR_EOL(buffer[last - 1]))
--last;
return true;