summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/lib
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/source/texk/web2c/lib
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/source/texk/web2c/lib')
-rw-r--r--Build/source/texk/web2c/lib/ChangeLog12
-rw-r--r--Build/source/texk/web2c/lib/texmfmp.c24
2 files changed, 30 insertions, 6 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. */