texlive[65602] Build/source/texk/web2c/pdftexdir: sync from pdftex

commits+karl at tug.org commits+karl at tug.org
Sat Jan 21 03:06:31 CET 2023


Revision: 65602
          http://tug.org/svn/texlive?view=revision&revision=65602
Author:   karl
Date:     2023-01-21 03:06:30 +0100 (Sat, 21 Jan 2023)
Log Message:
-----------
sync from pdftex r890: shipout keyword for delayed expansion of \special and \literal, from phelype

Revision Links:
--------------
    http://tug.org/svn/texlive?view=revision&revision=890

Modified Paths:
--------------
    trunk/Build/source/texk/web2c/pdftexdir/ChangeLog
    trunk/Build/source/texk/web2c/pdftexdir/NEWS
    trunk/Build/source/texk/web2c/pdftexdir/pdftex.web

Modified: trunk/Build/source/texk/web2c/pdftexdir/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/ChangeLog	2023-01-21 00:49:29 UTC (rev 65601)
+++ trunk/Build/source/texk/web2c/pdftexdir/ChangeLog	2023-01-21 02:06:30 UTC (rev 65602)
@@ -1,3 +1,17 @@
+2023-01-20  Phelype Oleinik  <phe.h.o1 at gmail.com>
+
+	* pdftex.web: implement shipout keyword for delayed expansion
+	with \pdfliteral and \special, like non-\immediate \write.
+	(pdf_out_literal): check for pdf_lateliteral_node.
+	(pdf_special): check for latespecial_node.
+	(latespecial_node): new @d (4)
+	(pdf_lateliteral_node): new @d (pdftex_first_extension_code + 1).
+	(Implement \.{\\special}),
+	(Implement \.{\\pdfliteral}): look for `shipout' keyword.
+	(scan_pdf_ext_late_toks): new procedure.
+	(Display the whatsit) <latespecial_node, <pdf_lateliteral_node>:
+	new cases.
+
 2022-12-28  Thanh Han The  <hanthethanh at gmail.com>
 
 	* pdftex.web (Display the whatsit...) <pdf_dest_node>: indicate

Modified: trunk/Build/source/texk/web2c/pdftexdir/NEWS
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/NEWS	2023-01-21 00:49:29 UTC (rev 65601)
+++ trunk/Build/source/texk/web2c/pdftexdir/NEWS	2023-01-21 02:06:30 UTC (rev 65602)
@@ -1,5 +1,7 @@
 pdfTeX 3.141592653-2.6-1.40.25
 - changes:
+  - new keyword `shipout' for \special and \pdfliteral, delaying
+    expansion until the node is shipped out, like non-\immediate \write.
   - new primitive \pdfinfoomitdict to omit /Info dictionary completely.
   - new primitive \pdfomitprocset to control omitting /ProcSet array;
     /ProcSet is included if this parameter is negative, or if this

Modified: trunk/Build/source/texk/web2c/pdftexdir/pdftex.web
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/pdftex.web	2023-01-21 00:49:29 UTC (rev 65601)
+++ trunk/Build/source/texk/web2c/pdftexdir/pdftex.web	2023-01-21 02:06:30 UTC (rev 65602)
@@ -1,4 +1,4 @@
-% Copyright 1996-2022 Han Th\^e\llap{\raise 0.5ex\hbox{\'{}}} Th\`anh,
+% Copyright 1996-2023 Han Th\^e\llap{\raise 0.5ex\hbox{\'{}}} Th\`anh,
 % <thanh@@pdftex.org>
 
 % This file is part of pdfTeX.
@@ -18501,8 +18501,16 @@
 procedure pdf_out_literal(p:pointer);
 var old_setting:0..max_selector; {holds print |selector|}
     s: str_number;
+    @!q,@!r:pointer; {temporary variables for list manipulation}
+    @!old_mode:integer; {saved |mode|}
 begin
-    old_setting:=selector; selector:=new_string;
+    old_setting:=selector;
+    if subtype(p)=pdf_lateliteral_node then
+      begin @<Expand macros in the token list
+        and make |link(def_ref)| point to the result@>;
+      pdf_literal_data(p):=def_ref;
+      end;
+    selector:=new_string;
     show_token_list(link(pdf_literal_data(p)),null,pool_size-pool_ptr);
     selector:=old_setting;
     s := make_string;
@@ -18618,8 +18626,17 @@
 procedure pdf_special(p: pointer);
 var old_setting:0..max_selector; {holds print |selector|}
     s: str_number;
+    @!q,@!r:pointer; {temporary variables for list manipulation}
+    @!old_mode:integer; {saved |mode|}
 begin
-    old_setting:=selector; selector:=new_string;
+    old_setting:=selector;
+    selector:=selector;
+    if subtype(p)=latespecial_node then
+      begin @<Expand macros in the token list
+        and make |link(def_ref)| point to the result@>;
+      write_tokens(p):=def_ref;
+      end;
+    selector:=new_string;
     show_token_list(link(write_tokens(p)),null,pool_size-pool_ptr);
     selector:=old_setting;
     s := make_string;
@@ -33624,7 +33641,8 @@
 @d write_node=1 {|subtype| in whatsits that represent things to \.{\\write}}
 @d close_node=2 {|subtype| in whatsits that represent streams to \.{\\closeout}}
 @d special_node=3 {|subtype| in whatsits that represent \.{\\special} things}
- at d language_node=4 {|subtype| in whatsits that change the current language}
+ at d latespecial_node==4 {|subtype| in whatsits that represent \.{\\special} things expanded during output}
+ at d language_node=5 {|subtype| in whatsits that change the current language}
 @d what_lang(#)==link(#+1) {language number, in the range |0..255|}
 @d what_lhm(#)==type(#+1) {minimum left fragment, in the range |1..63|}
 @d what_rhm(#)==subtype(#+1) {minimum right fragment, in the range |1..63|}
@@ -33651,52 +33669,53 @@
 |extension| with a modifier, whenever possible, so that |main_control|
 stays the same.
 
- at d immediate_code=4 {command modifier for \.{\\immediate}}
- at d set_language_code=5 {command modifier for \.{\\setlanguage}}
- at d pdftex_first_extension_code = 6
+ at d immediate_code=5 {command modifier for \.{\\immediate}}
+ at d set_language_code=6 {command modifier for \.{\\setlanguage}}
+ at d pdftex_first_extension_code = 7
 @d pdf_literal_node            == pdftex_first_extension_code + 0
- at d pdf_obj_code                == pdftex_first_extension_code + 1
- at d pdf_refobj_node             == pdftex_first_extension_code + 2
- at d pdf_xform_code              == pdftex_first_extension_code + 3
- at d pdf_refxform_node           == pdftex_first_extension_code + 4
- at d pdf_ximage_code             == pdftex_first_extension_code + 5
- at d pdf_refximage_node          == pdftex_first_extension_code + 6
- at d pdf_annot_node              == pdftex_first_extension_code + 7
- at d pdf_start_link_node         == pdftex_first_extension_code + 8
- at d pdf_end_link_node           == pdftex_first_extension_code + 9
- at d pdf_outline_code            == pdftex_first_extension_code + 10
- at d pdf_dest_node               == pdftex_first_extension_code + 11
- at d pdf_thread_node             == pdftex_first_extension_code + 12
- at d pdf_start_thread_node       == pdftex_first_extension_code + 13
- at d pdf_end_thread_node         == pdftex_first_extension_code + 14
- at d pdf_save_pos_node           == pdftex_first_extension_code + 15
- at d pdf_info_code               == pdftex_first_extension_code + 16
- at d pdf_catalog_code            == pdftex_first_extension_code + 17
- at d pdf_names_code              == pdftex_first_extension_code + 18
- at d pdf_font_attr_code          == pdftex_first_extension_code + 19
- at d pdf_include_chars_code      == pdftex_first_extension_code + 20
- at d pdf_map_file_code           == pdftex_first_extension_code + 21
- at d pdf_map_line_code           == pdftex_first_extension_code + 22
- at d pdf_trailer_code            == pdftex_first_extension_code + 23
- at d pdf_trailer_id_code         == pdftex_first_extension_code + 24
- at d reset_timer_code            == pdftex_first_extension_code + 25
- at d pdf_font_expand_code        == pdftex_first_extension_code + 26
- at d set_random_seed_code        == pdftex_first_extension_code + 27
- at d pdf_snap_ref_point_node     == pdftex_first_extension_code + 28
- at d pdf_snapy_node              == pdftex_first_extension_code + 29
- at d pdf_snapy_comp_node         == pdftex_first_extension_code + 30
- at d pdf_glyph_to_unicode_code   == pdftex_first_extension_code + 31
- at d pdf_colorstack_node         == pdftex_first_extension_code + 32
- at d pdf_setmatrix_node          == pdftex_first_extension_code + 33
- at d pdf_save_node               == pdftex_first_extension_code + 34
- at d pdf_restore_node            == pdftex_first_extension_code + 35
- at d pdf_nobuiltin_tounicode_code== pdftex_first_extension_code + 36
- at d pdf_interword_space_on_node == pdftex_first_extension_code + 37
- at d pdf_interword_space_off_node== pdftex_first_extension_code + 38
- at d pdf_fake_space_node         == pdftex_first_extension_code + 39
- at d pdf_running_link_off_node   == pdftex_first_extension_code + 40
- at d pdf_running_link_on_node    == pdftex_first_extension_code + 41
- at d pdftex_last_extension_code  == pdftex_first_extension_code + 41
+ at d pdf_lateliteral_node        == pdftex_first_extension_code + 1
+ at d pdf_obj_code                == pdftex_first_extension_code + 2
+ at d pdf_refobj_node             == pdftex_first_extension_code + 3
+ at d pdf_xform_code              == pdftex_first_extension_code + 4
+ at d pdf_refxform_node           == pdftex_first_extension_code + 5
+ at d pdf_ximage_code             == pdftex_first_extension_code + 6
+ at d pdf_refximage_node          == pdftex_first_extension_code + 7
+ at d pdf_annot_node              == pdftex_first_extension_code + 8
+ at d pdf_start_link_node         == pdftex_first_extension_code + 9
+ at d pdf_end_link_node           == pdftex_first_extension_code + 10
+ at d pdf_outline_code            == pdftex_first_extension_code + 11
+ at d pdf_dest_node               == pdftex_first_extension_code + 12
+ at d pdf_thread_node             == pdftex_first_extension_code + 13
+ at d pdf_start_thread_node       == pdftex_first_extension_code + 14
+ at d pdf_end_thread_node         == pdftex_first_extension_code + 15
+ at d pdf_save_pos_node           == pdftex_first_extension_code + 16
+ at d pdf_info_code               == pdftex_first_extension_code + 17
+ at d pdf_catalog_code            == pdftex_first_extension_code + 18
+ at d pdf_names_code              == pdftex_first_extension_code + 19
+ at d pdf_font_attr_code          == pdftex_first_extension_code + 20
+ at d pdf_include_chars_code      == pdftex_first_extension_code + 21
+ at d pdf_map_file_code           == pdftex_first_extension_code + 22
+ at d pdf_map_line_code           == pdftex_first_extension_code + 23
+ at d pdf_trailer_code            == pdftex_first_extension_code + 24
+ at d pdf_trailer_id_code         == pdftex_first_extension_code + 25
+ at d reset_timer_code            == pdftex_first_extension_code + 26
+ at d pdf_font_expand_code        == pdftex_first_extension_code + 27
+ at d set_random_seed_code        == pdftex_first_extension_code + 28
+ at d pdf_snap_ref_point_node     == pdftex_first_extension_code + 29
+ at d pdf_snapy_node              == pdftex_first_extension_code + 30
+ at d pdf_snapy_comp_node         == pdftex_first_extension_code + 31
+ at d pdf_glyph_to_unicode_code   == pdftex_first_extension_code + 32
+ at d pdf_colorstack_node         == pdftex_first_extension_code + 33
+ at d pdf_setmatrix_node          == pdftex_first_extension_code + 34
+ at d pdf_save_node               == pdftex_first_extension_code + 35
+ at d pdf_restore_node            == pdftex_first_extension_code + 36
+ at d pdf_nobuiltin_tounicode_code== pdftex_first_extension_code + 37
+ at d pdf_interword_space_on_node == pdftex_first_extension_code + 38
+ at d pdf_interword_space_off_node== pdftex_first_extension_code + 39
+ at d pdf_fake_space_node         == pdftex_first_extension_code + 40
+ at d pdf_running_link_off_node   == pdftex_first_extension_code + 41
+ at d pdf_running_link_on_node    == pdftex_first_extension_code + 42
+ at d pdftex_last_extension_code  == pdftex_first_extension_code + 42
 
 @<Put each...@>=
 primitive("openout",extension,open_node);@/
@@ -33965,12 +33984,17 @@
 end
 
 @ When `\.{\\special\{...\}}' appears, we expand the macros in the token
-list as in \.{\\xdef} and \.{\\mark}.
+list as in \.{\\xdef} and \.{\\mark}.  When marked with \.{shipout}, we keep
+tokens unexpanded for now.
 
 @<Implement \.{\\special}@>=
+begin if scan_keyword("shipout") then
+begin new_whatsit(latespecial_node,write_node_size); write_stream(tail):=null;
+p:=scan_toks(false,false); write_tokens(tail):=def_ref;
+end else
 begin new_whatsit(special_node,write_node_size); write_stream(tail):=null;
 p:=scan_toks(false,true); write_tokens(tail):=def_ref;
-end
+end; end
 
 @ @<Implement \.{\\pdffontexpand}@>=
     read_expand_font
@@ -34022,6 +34046,11 @@
     call_func(scan_toks(false, true)); {like \.{\\special}}
 end;
 
+procedure scan_pdf_ext_late_toks;
+begin
+    call_func(scan_toks(false, false)); {like \.{\\special}, but doesn't expand}
+end;
+
 procedure compare_strings; {to implement \.{\\pdfstrcmp}}
 label done;
 var s1, s2: str_number;
@@ -34065,7 +34094,9 @@
 @ @<Implement \.{\\pdfliteral}@>=
 begin
     check_pdfoutput("\pdfliteral", true);
-    new_whatsit(pdf_literal_node, write_node_size);
+    if scan_keyword("shipout") then k:=pdf_lateliteral_node
+    else k:=pdf_literal_node;
+    new_whatsit(k, write_node_size);
     if scan_keyword("direct") then
         pdf_literal_mode(tail) := direct_always
     else if scan_keyword("page") then
@@ -34072,7 +34103,8 @@
         pdf_literal_mode(tail) := direct_page
     else
         pdf_literal_mode(tail) := set_origin;
-    scan_pdf_ext_toks;
+    if k=pdf_literal_node then
+      scan_pdf_ext_toks else scan_pdf_ext_late_toks;
     pdf_literal_data(tail) := def_ref;
 end
 
@@ -35406,13 +35438,17 @@
 special_node:begin print_esc("special");
   print_mark(write_tokens(p));
   end;
+latespecial_node:begin print_esc("special"); print(" shipout");
+  print_mark(write_tokens(p));
+  end;
 language_node:begin print_esc("setlanguage");
   print_int(what_lang(p)); print(" (hyphenmin ");
   print_int(what_lhm(p)); print_char(",");
   print_int(what_rhm(p)); print_char(")");
   end;
-pdf_literal_node: begin
+pdf_literal_node,pdf_lateliteral_node: begin
     print_esc("pdfliteral");
+    if subtype(p)=pdf_lateliteral_node then print(" shipout");
     case pdf_literal_mode(p) of
     set_origin:
         do_nothing;
@@ -35620,13 +35656,13 @@
 case subtype(p) of
 open_node: begin r:=get_node(open_node_size); words:=open_node_size;
   end;
-write_node,special_node: begin r:=get_node(write_node_size);
+write_node,special_node,latespecial_node: begin r:=get_node(write_node_size);
   add_token_ref(write_tokens(p)); words:=write_node_size;
   end;
 close_node,language_node: begin r:=get_node(small_node_size);
   words:=small_node_size;
   end;
-pdf_literal_node: begin
+pdf_literal_node,pdf_lateliteral_node: begin
     r := get_node(write_node_size);
     add_token_ref(pdf_literal_data(p));
     words := write_node_size;
@@ -35731,11 +35767,11 @@
 @ @<Wipe out the whatsit...@>=
 begin case subtype(p) of
 open_node: free_node(p,open_node_size);
-write_node,special_node: begin delete_token_ref(write_tokens(p));
+write_node,special_node,latespecial_node: begin delete_token_ref(write_tokens(p));
   free_node(p,write_node_size); goto done;
   end;
 close_node,language_node: free_node(p,small_node_size);
-pdf_literal_node: begin
+pdf_literal_node,pdf_lateliteral_node: begin
     delete_token_ref(pdf_literal_data(p));
     free_node(p, write_node_size);
 end;
@@ -35884,8 +35920,17 @@
 procedure special_out(@!p:pointer);
 var old_setting:0..max_selector; {holds print |selector|}
 @!k:pool_pointer; {index into |str_pool|}
+@!q,@!r:pointer; {temporary variables for list manipulation}
+@!old_mode:integer; {saved |mode|}
 begin synch_h; synch_v;@/
 old_setting:=selector; selector:=new_string;
+selector:=old_setting;
+if subtype(p)=latespecial_node then
+  begin @<Expand macros in the token list
+    and make |link(def_ref)| point to the result@>;
+  write_tokens(p):=def_ref;
+  end;
+selector:=new_string;
 show_token_list(link(write_tokens(p)),null,pool_size-pool_ptr);
 selector:=old_setting;
 str_room(1);
@@ -35972,7 +36017,7 @@
 begin case subtype(p) of
 open_node,write_node,close_node:@<Do some work that has been queued up
   for \.{\\write}@>;
-special_node:special_out(p);
+special_node,latespecial_node:special_out(p);
 language_node:do_nothing;
 pdf_save_pos_node:
   @<Save current position in DVI mode@>;
@@ -36817,7 +36862,7 @@
 
 @ @<Output the whatsit node |p| in |pdf_vlist_out|@>=
 case subtype(p) of
-pdf_literal_node:
+pdf_literal_node,pdf_lateliteral_node:
     pdf_out_literal(p);
 pdf_colorstack_node:
     pdf_out_colorstack(p);
@@ -36848,7 +36893,7 @@
     end_thread;
 pdf_save_pos_node:
     @<Save current position to |pdf_last_x_pos|, |pdf_last_y_pos|@>;
-special_node:
+special_node,latespecial_node:
     pdf_special(p);
 pdf_snap_ref_point_node:
     @<Save current position to |pdf_snapx_refpos|, |pdf_snapy_refpos|@>;
@@ -36903,7 +36948,7 @@
 
 @ @<Output the whatsit node |p| in |pdf_hlist_out|@>=
 case subtype(p) of
-pdf_literal_node:
+pdf_literal_node,pdf_lateliteral_node:
     pdf_out_literal(p);
 pdf_colorstack_node:
     pdf_out_colorstack(p);
@@ -36935,7 +36980,7 @@
     pdf_error("ext4", "\pdfendthread ended up in hlist");
 pdf_save_pos_node:
     @<Save current position to |pdf_last_x_pos|, |pdf_last_y_pos|@>;
-special_node:
+special_node,latespecial_node:
     pdf_special(p);
 pdf_snap_ref_point_node:
     @<Save current position to |pdf_snapx_refpos|, |pdf_snapy_refpos|@>;



More information about the tex-live-commits mailing list.