texlive[45221] Build/source/texk/web2c: strip only trailing spaces on

commits+karl at tug.org commits+karl at tug.org
Tue Sep 5 19:56:45 CEST 2017


Revision: 45221
          http://tug.org/svn/texlive?view=revision&revision=45221
Author:   karl
Date:     2017-09-05 19:56:45 +0200 (Tue, 05 Sep 2017)
Log Message:
-----------
strip only trailing spaces on input, not tabs et al.

Modified Paths:
--------------
    trunk/Build/source/texk/web2c/lib/ChangeLog
    trunk/Build/source/texk/web2c/lib/texmfmp.c
    trunk/Build/source/texk/web2c/xetexdir/ChangeLog
    trunk/Build/source/texk/web2c/xetexdir/XeTeX_ext.c

Modified: trunk/Build/source/texk/web2c/lib/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/lib/ChangeLog	2017-09-05 00:18:29 UTC (rev 45220)
+++ trunk/Build/source/texk/web2c/lib/ChangeLog	2017-09-05 17:56:45 UTC (rev 45221)
@@ -1,3 +1,15 @@
+2017-09-05  Karl Berry  <karl at tug.org>
+        and Akira Kakuto  <kakuto at 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 at fuk.kindai.ac.jp>
 
 	* texmfmp.c: Adopt Jonathan's solution for the Change on 2017-02-01.

Modified: trunk/Build/source/texk/web2c/lib/texmfmp.c
===================================================================
--- trunk/Build/source/texk/web2c/lib/texmfmp.c	2017-09-05 00:18:29 UTC (rev 45220)
+++ trunk/Build/source/texk/web2c/lib/texmfmp.c	2017-09-05 17:56:45 UTC (rev 45221)
@@ -1079,10 +1079,15 @@
   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 @@
       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 @@
       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.  */

Modified: trunk/Build/source/texk/web2c/xetexdir/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/xetexdir/ChangeLog	2017-09-05 00:18:29 UTC (rev 45220)
+++ trunk/Build/source/texk/web2c/xetexdir/ChangeLog	2017-09-05 17:56:45 UTC (rev 45221)
@@ -1,3 +1,12 @@
+2017-09-05  Karl Berry  <karl at tug.org>
+        and Akira Kakuto  <kakuto at 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 at fuk.kindai.ac.jp>
 
 	* pdfimage.cpp: Support /Rotate in PDF image inclusion with

Modified: trunk/Build/source/texk/web2c/xetexdir/XeTeX_ext.c
===================================================================
--- trunk/Build/source/texk/web2c/xetexdir/XeTeX_ext.c	2017-09-05 00:18:29 UTC (rev 45220)
+++ trunk/Build/source/texk/web2c/xetexdir/XeTeX_ext.c	2017-09-05 17:56:45 UTC (rev 45221)
@@ -466,8 +466,9 @@
     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;



More information about the tex-live-commits mailing list