| 1 |
% latespecial.ch: Adding the "shipout" keyword to \special |
| 2 |
% |
| 3 |
% This file is part of the Omega project, which |
| 4 |
% is based on the web2c distribution of TeX. |
| 5 |
% |
| 6 |
% Copyright (c) 2023 Phelype Oleinik |
| 7 |
% |
| 8 |
% This library is free software; you can redistribute it and/or |
| 9 |
% modify it under the terms of the GNU Library General Public |
| 10 |
% License as published by the Free Software Foundation; either |
| 11 |
% version 2 of the License, or (at your option) any later version. |
| 12 |
% |
| 13 |
% This library is distributed in the hope that it will be useful, |
| 14 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 |
% Library General Public License for more details. |
| 17 |
% |
| 18 |
% You should have received a copy of the GNU Library General Public |
| 19 |
% License along with this library; if not, write to the Free Software |
| 20 |
% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 21 |
|
| 22 |
@x |
| 23 |
@d language_node=4 {|subtype| in whatsits that change the current language} |
| 24 |
@y |
| 25 |
@d latespecial_node=4 {|subtype| in whatsits for \.{\\special shipout}} |
| 26 |
@d language_node=5 {|subtype| in whatsits that change the current language} |
| 27 |
@z |
| 28 |
|
| 29 |
@x |
| 30 |
@d immediate_code=4 {command modifier for \.{\\immediate}} |
| 31 |
@d set_language_code=5 {command modifier for \.{\\setlanguage}} |
| 32 |
@y |
| 33 |
@d immediate_code=5 {command modifier for \.{\\immediate}} |
| 34 |
@d set_language_code=6 {command modifier for \.{\\setlanguage}} |
| 35 |
@z |
| 36 |
|
| 37 |
@x |
| 38 |
begin new_whatsit(special_node,write_node_size); write_stream(tail):=null; |
| 39 |
p:=scan_toks(false,true); write_tokens(tail):=def_ref; |
| 40 |
end |
| 41 |
@y |
| 42 |
begin if scan_keyword("shipout") then |
| 43 |
begin new_whatsit(latespecial_node,write_node_size); write_stream(tail):=null; |
| 44 |
p:=scan_toks(false,false); write_tokens(tail):=def_ref; |
| 45 |
end else |
| 46 |
begin new_whatsit(special_node,write_node_size); write_stream(tail):=null; |
| 47 |
p:=scan_toks(false,true); write_tokens(tail):=def_ref; |
| 48 |
end; end |
| 49 |
@z |
| 50 |
|
| 51 |
@x |
| 52 |
language_node:begin print_esc("setlanguage"); |
| 53 |
@y |
| 54 |
latespecial_node:begin print_esc("special"); print(" shipout"); |
| 55 |
print_mark(write_tokens(p)); |
| 56 |
end; |
| 57 |
language_node:begin print_esc("setlanguage"); |
| 58 |
@z |
| 59 |
|
| 60 |
@x |
| 61 |
write_node,special_node: begin r:=get_node(write_node_size); |
| 62 |
@y |
| 63 |
write_node,special_node,latespecial_node: begin r:=get_node(write_node_size); |
| 64 |
@z |
| 65 |
|
| 66 |
@x |
| 67 |
write_node,special_node: begin delete_token_ref(write_tokens(p)); |
| 68 |
@y |
| 69 |
write_node,special_node,latespecial_node: begin delete_token_ref(write_tokens(p)); |
| 70 |
@z |
| 71 |
|
| 72 |
@x |
| 73 |
begin synch_h; synch_v;@/ |
| 74 |
old_setting:=selector; selector:=new_string; |
| 75 |
show_token_list(link(write_tokens(p)),null,pool_size-pool_ptr); |
| 76 |
@y |
| 77 |
@!h:halfword; |
| 78 |
@!q,@!r:pointer; {temporary variables for list manipulation} |
| 79 |
@!old_mode:integer; {saved |mode|} |
| 80 |
begin synch_h; synch_v;@/ |
| 81 |
old_setting:=selector; |
| 82 |
if subtype(p)=latespecial_node then |
| 83 |
begin @<Expand macros in the token list |
| 84 |
and make |link(def_ref)| point to the result@>; |
| 85 |
h:=def_ref; |
| 86 |
end |
| 87 |
else h:=write_tokens(p); |
| 88 |
selector:=new_string; |
| 89 |
show_token_list(link(h),null,pool_size-pool_ptr); |
| 90 |
@z |
| 91 |
|
| 92 |
@x |
| 93 |
pool_ptr:=str_start(str_ptr); {erase the string} |
| 94 |
@y |
| 95 |
pool_ptr:=str_start(str_ptr); {erase the string} |
| 96 |
if subtype(p)=latespecial_node then |
| 97 |
flush_list(def_ref); |
| 98 |
@z |
| 99 |
|
| 100 |
@x |
| 101 |
special_node:special_out(p); |
| 102 |
@y |
| 103 |
special_node,latespecial_node:special_out(p); |
| 104 |
@z |