texlive[45936] Build/source/texk/web2c/pdftexdir: import

commits+karl at tug.org commits+karl at tug.org
Wed Nov 29 00:57:17 CET 2017

Revision: 45936
Author:   karl
Date:     2017-11-29 00:57:17 +0100 (Wed, 29 Nov 2017)
Log Message:
import \pdfprimitive fixes (pdftex r784)

Revision Links:

Modified Paths:

Modified: trunk/Build/source/texk/web2c/pdftexdir/ChangeLog
--- trunk/Build/source/texk/web2c/pdftexdir/ChangeLog	2017-11-28 22:15:24 UTC (rev 45935)
+++ trunk/Build/source/texk/web2c/pdftexdir/ChangeLog	2017-11-28 23:57:17 UTC (rev 45936)
@@ -1,3 +1,24 @@
+2017-11-28  Hironori KITAGAWA <h_kitagawa2001 at yahoo.co.jp>
+	Stop \pdfprimitive\vrule\q from swallowing q, by moving prim_eqtb
+	into the end of region 2 of eqtb instead of being a separate table.
+	* pdftex.ch (frozen_null_font): add prim_size.
+	* pdftex.web (prim_size): move to other region 2 definitions.
+	(prim_eqtb_base): new constant.
+	(prim_eq_level, prim_eq_type, prim_equiv): use prim_eqtb_base.
+	(prim_eqtb): remove array.
+	(Set init...): remove initializations.
+	(Basic printing...),
+	(Basic printing procedures): handle primitives after prim_eqtb_base.
+	(Implement \.{\\pdfprimitive}): do not give error if argument is
+	 not a primitive, just do nothing.
+	(Reset |cur_tok| for unexpandable primitives, goto restart):
+	 handle primitive lookups via prim_eqtb_base instead of cur_cmd*@'400.
+	(Cases of |main_control| that are not part of the inner loop):
+	<not undefined_primitive>: also set cur_tok.
+	(Dump the hash table): do not dump prim_eqtb.
+	(Undump the hash table): do not undump prim_eqtb.
 2017-11-14  Anders Kaseorg  <andersk at mit.edu>
 	* utils.c (printID): Do not hash the current directory name into

Modified: trunk/Build/source/texk/web2c/pdftexdir/NEWS
--- trunk/Build/source/texk/web2c/pdftexdir/NEWS	2017-11-28 22:15:24 UTC (rev 45935)
+++ trunk/Build/source/texk/web2c/pdftexdir/NEWS	2017-11-28 23:57:17 UTC (rev 45936)
@@ -1,12 +1,16 @@
 - changes:
-  - do not hash current directory into PDF ID, for more reproducible builds.
+  - do not hash current directory into PDF ID, for more reproducible builds
+    (pdftex r782).
 - bugfixes:
-  - \ifpdfprimitive now correctly returns true for "\ " (r45394).
+  - \pdfprimitive does nothing, rather than give an error, when given a
+    non-primitive (pdftex r784).
+  - \pdfprimitive does not swallow a following control sequence (pdftex r784).
+  - \ifpdfprimitive now correctly returns true for "\ " (TL r45394).
 - source: support xpdf-4 by default, or xpdf-3.04, or poppler-0.57.0
-  and older, via #defines. provide new files, pdftoepdf-newpoppler.cc
-  and pdftosrc-newpoppler.cc, to support poppler-0.59.0 and newer.
+  and older, via #defines. Provide new files, pdftoepdf-newpoppler.cc
+  and pdftosrc-newpoppler.cc, to support poppler-0.59.0 and newer:
   they should be renamed as pdftoepdf.cc and pdftosrc.cc, respectively,
   before compilation.
@@ -21,7 +25,7 @@
 - bugfixes:
   - \pdflastmatch more reliable when there was no match.
 pdfTeX 3.14159265-2.6-1.40.17 (TeX Live 2016)  (May 20, 2016)
 - changes:
   - if the environment variable SOURCE_DATE_EPOCH is set, use its value for

Modified: trunk/Build/source/texk/web2c/pdftexdir/pdftex.ch
--- trunk/Build/source/texk/web2c/pdftexdir/pdftex.ch	2017-11-28 22:15:24 UTC (rev 45935)
+++ trunk/Build/source/texk/web2c/pdftexdir/pdftex.ch	2017-11-28 23:57:17 UTC (rev 45936)
@@ -41,7 +41,7 @@
 @d frozen_null_font=frozen_control_sequence+11
   {permanent `\.{\\nullfont}'}
- at d frozen_null_font=frozen_control_sequence+12
+ at d frozen_null_font=frozen_control_sequence+12+prim_size
   {permanent `\.{\\nullfont}'}

Modified: trunk/Build/source/texk/web2c/pdftexdir/pdftex.web
--- trunk/Build/source/texk/web2c/pdftexdir/pdftex.web	2017-11-28 22:15:24 UTC (rev 45935)
+++ trunk/Build/source/texk/web2c/pdftexdir/pdftex.web	2017-11-28 23:57:17 UTC (rev 45936)
@@ -184,7 +184,7 @@
 % and should use:
 %    \toks0=\expandafter{\title}
 %    \edef\title{...\the\toks0...}
-\let\maybe=\iffalse % print only changed modules
+\let\maybe=\iftrue % print only changed modules
 \def\topofcontents{\hsize 5.5in
   \vglue 0pt plus 1fil minus 1.5in
   \def\?##1]{\hbox to 1in{\hfil##1.\ }}
@@ -5176,10 +5176,12 @@
 @d end_write=frozen_control_sequence+8 {permanent `\.{\\endwrite}'}
 @d frozen_dont_expand=frozen_control_sequence+9
   {permanent `\.{\\notexpanded:}'}
+ at d prim_size=2100 {maximum number of primitives }
 @d frozen_null_font=frozen_control_sequence+10
   {permanent `\.{\\nullfont}'}
 @d frozen_primitive=frozen_control_sequence+11
   {permanent `\.{\\pdfprimitive}'}
+ at d prim_eqtb_base=frozen_primitive+1
 @d font_id_base=frozen_null_font-font_base
   {begins table of 257 permanent font identifiers}
 @d undefined_control_sequence=frozen_null_font+257 {dummy location}
@@ -6455,7 +6457,6 @@
 @ Primitive support needs a few extra variables and definitions
- at d prim_size=2100 {maximum number of primitives }
 @d prim_prime=1777 {about 85\pct! of |primitive_size|}
 @d prim_base=1
 @d prim_next(#) == prim[#].lh {link for coalesced lists}
@@ -6464,9 +6465,9 @@
 @d prim_eq_level_field(#)==#.hh.b1
 @d prim_eq_type_field(#)==#.hh.b0
 @d prim_equiv_field(#)==#.hh.rh
- at d prim_eq_level(#)==prim_eq_level_field(prim_eqtb[#]) {level of definition}
- at d prim_eq_type(#)==prim_eq_type_field(prim_eqtb[#]) {command code for equivalent}
- at d prim_equiv(#)==prim_equiv_field(prim_eqtb[#]) {equivalent value}
+ at d prim_eq_level(#)==prim_eq_level_field(eqtb[prim_eqtb_base+#]) {level of definition}
+ at d prim_eq_type(#)==prim_eq_type_field(eqtb[prim_eqtb_base+#]) {command code for equivalent}
+ at d prim_equiv(#)==prim_equiv_field(eqtb[prim_eqtb_base+#]) {equivalent value}
 @d undefined_primitive=0
 @d biggest_char=255 { 65535 in XeTeX }
@@ -6473,16 +6474,11 @@
 @!prim: array [0..prim_size] of two_halves;  {the primitives table}
 @!prim_used:pointer; {allocation pointer for |prim|}
-@!prim_eqtb:array[0..prim_size] of memory_word;
 @ @<Set init...@>=
 no_new_control_sequence:=true; {new identifiers are usually forbidden}
 prim_next(0):=0; prim_text(0):=0;
 for k:=1 to prim_size do prim[k]:=prim[0];
-prim_eq_level(0) := level_zero;
-prim_eq_type(0) := undefined_cs;
-prim_equiv(0) := null;
-for k:=1 to prim_size do prim_eqtb[k]:=prim_eqtb[0];
 next(hash_base):=0; text(hash_base):=0;
 for k:=hash_base+1 to undefined_control_sequence-1 do hash[k]:=hash[hash_base];
@@ -6642,7 +6638,9 @@
 else if p>=undefined_control_sequence then print_esc("IMPOSSIBLE.")
 else if (text(p)<0)or(text(p)>=str_ptr) then print_esc("NONEXISTENT.")
-else  begin print_esc(text(p));
+else  begin
+  if (p>=prim_eqtb_base)and(p<frozen_null_font) then
+    print_esc(prim_text(p-prim_eqtb_base)-1) else print_esc(text(p));
   print_char(" ");
@@ -6657,6 +6655,8 @@
   else  if p<null_cs then print_esc(p-single_base)
     else  begin print_esc("csname"); print_esc("endcsname");
+else if (p>=prim_eqtb_base)and(p<frozen_null_font) then
+    print_esc(prim_text(p-prim_eqtb_base)-1)
 else print_esc(text(p));
@@ -6666,6 +6666,57 @@
 does this, in a way that no \TeX\ user can. The global value |cur_val|
 contains the new |eqtb| pointer after |primitive| has acted.
+Until pdf\TeX\ 1.40.19 (released in 2018), a bug in primitive handling
+caused, e.g., \.{\\pdfprimitive\\ \\q} to swallow the \.{\\q} instead of
+giving an undefined control sequence error. The original report was
+posted by Hironori Kitagawa
+(\.{tug.org/pipermail/tex-k/2017-October/002816.html}). Largely
+quoting from that message:
+The cause was |cur_tok| not being set in the ``Cases of |main_control|\dots''
+module, because |back_input| unscans the token, but only looks at
+|cur_tok|, which represents the internalized \.{\\pdfprimitive} at that
+time.  So \.{\\pdfprimitive\\vrule\\q} becomes ``(internalized
+\.{\\pdfprimitive})''\.{\\q}, hence no error (and \.{\\vrule} disappears).
+Hironori's explanation of the previous behavior and fix continues (off-list):
+\yskip\textindent{*} |back_input| (and similar routine $\langle\,$Insert token
+|p| into \TeX's input$\,\rangle$) only stores |cur_tok| to a token list.
+\textindent{*} When \TeX\ gets input from a token list (at module
+$\langle\,$Input from token list, |goto restart| \dots$\,\rangle$),
+\TeX\ looks at the saved |cur_tok| value $t$, and recover the command
+code (|cur_cmd|) and its fmodifier (|cur_chr|) from it:
+{\advance\leftskip by 1.5em
+\textindent{--} If |t>=cs_token_flag|, $t$ points to an |eqtb| location
+|t - cs_token_flag|.
+\textindent{--} If |t<cs_token_flag|, |cur_cmd| and |cur_chr| are set
+with |cur_cmd:=t div @'400; cur_chr:=t mod @'400|.
+\textindent{--} This $t$ is used to display the token (|show_token_list|).
+\textindent{*} pdf\TeX\ defines |cs_token_flag| as \.{"FFF}.  So simply
+using |cur_tok:=(cur_cmd*@'400)+cur_chr| by \.{\\pdfprimitive} does not
+work correctly with primitives whose command codes |cur_cmd| $\ge16$.
+Increasing |cs_token_flag| to \.{"FFFF} or somewhat higher
+might suffice for fixing this situation in pdf\TeX.
+However, this approach does not seem good, because
+\textindent{1)} an (indirect) mapping from |cur_tok| to control sequence
+name is needed anyway, for displaying the token, and
+\textindent{2)} this does not work in Japanese e-(u)p\TeX.
+Thus, we now put |prim_eqtb| entries into the end of region 2 of
+|eqtb| (which contains some frozen primitives, such as ``frozen \.{\\fi}''
+and ``frozen \.{\\cr}''), thus treating |prim_eqtb| entries as a permanent
+location for primitives.
 @p @!init procedure primitive(@!s:str_number;@!c:quarterword;@!o:halfword);
 var k:pool_pointer; {index into |str_pool|}
 @!j:0..buf_size; {index into |buffer|}
@@ -8939,12 +8990,6 @@
     p:=get_avail; info(p):=cs_token_flag+frozen_primitive;
     link(p):=loc; loc:=p; start:=p;
-  end
-else begin
-  print_err("Missing primitive name");
-  help2("The control sequence marked <to be read again> does not")@/
-    ("represent any known primitive.");
-  back_error;
@@ -8958,11 +9003,15 @@
 @<Reset |cur_tok| for unexpandable primitives, goto restart @>=
-cur_cs := prim_lookup(text(cur_cs));
+if cur_cs < hash_base then
+  cur_cs := prim_lookup(cur_cs-single_base)
+  cur_cs  := prim_lookup(text(cur_cs));
 if cur_cs<>undefined_primitive then begin
   cur_cmd := prim_eq_type(cur_cs);
   cur_chr := prim_equiv(cur_cs);
-  cur_tok := (cur_cmd*@'400)+cur_chr;
+  cur_cs  := prim_eqtb_base+cur_cs;
+  cur_tok := cs_token_flag+cur_cs;
 else begin
   cur_cmd := relax;
@@ -28807,6 +28856,7 @@
     if cur_cs<>undefined_primitive then begin
       cur_cmd := prim_eq_type(cur_cs);
       cur_chr := prim_equiv(cur_cs);
+      cur_tok := cs_token_flag+prim_eqtb_base+cur_cs;
       goto reswitch;
@@ -32706,7 +32756,6 @@
 @<Dump the hash table@>=
 for p:=0 to prim_size do dump_hh(prim[p]);
-for p:=0 to prim_size do dump_wd(prim_eqtb[p]);
 dump_int(hash_used); cs_count:=frozen_control_sequence-1-hash_used;
 for p:=hash_base to hash_used do if text(p)<>0 then
   begin dump_int(p); dump_hh(hash[p]); incr(cs_count);
@@ -32717,7 +32766,6 @@
 @ @<Undump the hash table@>=
 for p:=0 to prim_size do undump_hh(prim[p]);
-for p:=0 to prim_size do undump_wd(prim_eqtb[p]);
 undump(hash_base)(frozen_control_sequence)(hash_used); p:=hash_base-1;
 repeat undump(p+1)(hash_used)(p); undump_hh(hash[p]);
 until p=hash_used;

More information about the tex-live-commits mailing list