Debian Codegraph @

texk/web2c/euptexdir/eptex.ech

raw
1 % eptexdir/eptex.ech: changefile used to build e-pTeX, see eptexdir/eptex-base.ch for details.
2 % Public domain. Originally written by Peter Breitenlohner <[email protected]>.
3
4 %% new primitives by e-pTeX
5 %%
6 %% \epTeXversion
7 %% \epTeXinputencoding <euc|sjis|jis|utf8>
8 %%
9 %% \currentspacingmode: 1 iff auto_spacing
10 %% \currentxspacingmode: 1 iff auto_xspacing
11 %% \lastnodechar: the (internal) character code of the last node
12 %% -1: non-character or null
13 %% \lastnodesubtype: the (internal) subtype of the last node
14 %% note: returns a value from the type if the node is s math noad.
15 %% -1: null
16 %% fallback to 0 if not explicitly set
17 %% \readpapersizespecial
18 %% 1: papersize special automatically sets \pdfpage{width,height} (quick hack).
19 %% 0: off
20 %% The default value is 1.
21 %%
22
23 @x e-pTeX: logo
24 \def\eTeX{$\varepsilon$-\TeX}
25 @y
26 \def\eTeX{$\varepsilon$-\TeX}
27 \def\epTeX{$\varepsilon$-\pTeX}
28 \def\eupTeX{$\varepsilon$-\upTeX}
29 @z
30
31 @x [1.2] l.190 - epTeX:
32 @d eTeX_version_string=='-2.6' {current \eTeX\ version}
33 @y
34 @d eTeX_version_string=='-2.6' {current \eTeX\ version}
35 @#
36 @d epTeX_version_string=='-251130'
37 @d epTeX_version_number==251130
38 @z
39
40 @x e-upTeX: banner
41 {printed when \upTeX\ starts}
42 @y
43 {printed when \upTeX\ starts}
44 @#
45 @d eupTeX_version==pTeX_version_string,upTeX_version_string,epTeX_version_string,eTeX_version_string
46 @d eupTeX_banner=='This is e-upTeX, Version 3.141592653',eupTeX_version
47 @d eupTeX_banner_k==eupTeX_banner
48 {printed when \eupTeX\ starts}
49 @z
50
51 @x [1.2]
52 @d banner==upTeX_banner
53 @d banner_k==upTeX_banner_k
54 @y
55 @d banner==eupTeX_banner
56 @d banner_k==eupTeX_banner_k
57 @z
58
59 @x [10.135] l.2895 - e-pTeX: box_lr and box_dir
60 In \eTeX\ the |subtype| field records the box direction mode |box_lr|.
61 @y
62 In \eTeX\ the |subtype| field records the box direction mode |box_lr|.
63 In \epTeX\ the |subtype| field is |qi(16*box_lr+box_dir)|.
64 @z
65
66 @x
67 @d box_dir(#) == (qo(subtype(#))-dir_max) {direction of a box}
68 @d set_box_dir(#) == subtype(#):=set_box_dir_end
69 @y
70 @d box_dir(#) == ((qo(subtype(#)))mod 16 - dir_max) {direction of a box}
71 @d set_box_dir(#) == subtype(#):=box_lr(#)*16+set_box_dir_end
72 @z
73
74 @x [17]
75 @d saving_hyph_codes_code=etex_int_base+8 {save hyphenation codes for languages}
76 @d eTeX_state_code=etex_int_base+9 {\eTeX\ state variables}
77 @y
78 @d saving_hyph_codes_code=etex_int_base+8 {save hyphenation codes for languages}
79 @d read_papersize_special_code=etex_int_base+9
80 @d eTeX_state_code=etex_int_base+10 {\eTeX\ state variables}
81 @z
82
83 @x [17]
84 @d saving_hyph_codes==int_par(saving_hyph_codes_code)
85 @y
86 @d saving_hyph_codes==int_par(saving_hyph_codes_code)
87 @d read_papersize_special==int_par(read_papersize_special_code)
88 @z
89
90 @x
91 @d protected_token=@'7001 {$2^8\cdot|end_match|+1$}
92 @y
93 @d protected_token=@"E0001 {$2^16\cdot|end_match|+1$}
94 @z
95
96 @x [26.???] prepare for |scan_font_ident| to recognize \lastnodefont
97 @p procedure@?scan_int; forward; {scans an integer value}
98 @y
99 @p procedure@?scan_int; forward; {scans an integer value}
100 procedure@?scan_something_internal_ident; forward;
101 @z
102
103 @x [26.413] l.8343 - e-pTeX: scan_something_internal
104 var m:halfword; {|chr_code| part of the operand token}
105 @y
106 label exit;
107 var m:halfword; {|chr_code| part of the operand token}
108 @z
109
110 @x [26.???] add |scan_something_internal_ident| (used in |scan_font_ident|)
111 @<Fix the reference count, if any, and negate |cur_val| if |negative|@>;
112 end;
113 @y
114 @<Fix the reference count, if any, and negate |cur_val| if |negative|@>;
115 exit:end;
116
117 @ @p procedure scan_something_internal_ident;
118 begin scan_something_internal(ident_val,false); end;
119 @z
120
121 @x
122 @d input_line_no_code=glue_val+2 {code for \.{\\inputlineno}}
123 @d badness_code=glue_val+2 {code for \.{\\badness}}
124 @y
125 @d last_node_subtype_code=glue_val+2 {code for \.{\\lastnodesubtype}}
126 @d last_node_char_code=glue_val+3 {code for \.{\\lastnodechar}}
127 @d last_node_font_code=glue_val+4 {code for \.{\\lastnodefont}}
128 @d input_line_no_code=glue_val+5 {code for \.{\\inputlineno}}
129 @d badness_code=glue_val+6 {code for \.{\\badness}}
130 @z
131
132 @x
133 @d uptex_version_code=ptex_version_code+1 {code for \.{\\uptexversion}}
134 @d ptex_minor_version_code=uptex_version_code+1 {code for \.{\\ptexminorversion}}
135 @y
136 @d uptex_version_code=ptex_version_code+1 {code for \.{\\uptexversion}}
137 @d eptex_version_code=uptex_version_code+1 {code for \.{\\epTeXversion}}
138 @d ptex_minor_version_code=eptex_version_code+1 {code for \.{\\ptexminorversion}}
139 @z
140
141 @x e-pTeX: \current(x)spacingmode
142 @d eTeX_dim=eTeX_int+8 {first of \eTeX\ codes for dimensions}
143 @y
144 @d eTeX_dim=eTeX_int+11 {first of \eTeX\ codes for dimensions}
145 @z
146
147 @x
148 primitive("ptexminorversion",last_item,ptex_minor_version_code);
149 @!@:ptexminorversion_}{\.{\\ptexminorversion} primitive@>
150 @y
151 primitive("epTeXversion",last_item,eptex_version_code);
152 @!@:epTeXversion_}{\.{\\epTeXversion} primitive@>
153 primitive("ptexminorversion",last_item,ptex_minor_version_code);
154 @!@:ptexminorversion_}{\.{\\ptexminorversion} primitive@>
155 @z
156
157 @x
158 uptex_version_code: print_esc("uptexversion");
159 ptex_minor_version_code: print_esc("ptexminorversion");
160 @y
161 uptex_version_code: print_esc("uptexversion");
162 eptex_version_code: print_esc("epTeXversion");
163 ptex_minor_version_code: print_esc("ptexminorversion");
164 @z
165
166 @x [26.420] l.8474 - pTeX: Fetch a box dimension: dir_node
167 begin scan_eight_bit_int; q:=box(cur_val);
168 @y
169 begin scan_register_num; fetch_box(q);
170 @z
171
172 @x [26.424] l.8508 - e-pTeX: TeXXeT and disp_node
173 node of the current list.
174 @y
175 node of the current list.
176 The macro |find_effective_tail_epTeX| sets |tx| to the last non-\.{\\endM}
177 non-|disp_node| of the current list.
178 @z
179
180 @x [26.424] l.8510 - e-pTeX: last node
181 @d find_effective_tail==find_effective_tail_pTeX
182 @y
183 @d find_effective_tail_epTeX==
184 tx:=tail;
185 if not is_char_node(tx) then if type(tx)=disp_node then tx:=prev_node;
186 if not is_char_node(tx) then
187 if (type(tx)=disp_node) {|disp_node| from a discretionary}
188 or((type(tx)=math_node)and(subtype(tx)=end_M_code)) then
189 begin r:=head; q:=link(head);
190 while q<>tx do
191 begin if is_char_node(q) then r:=q
192 else if (type(q)<>disp_node)and
193 ((type(q)<>math_node)or(subtype(q)<>end_M_code)) then r:=q;
194 q:=link(q);
195 end;
196 tx:=r;
197 end
198 @#
199 @d find_effective_tail==find_effective_tail_epTeX
200 @#
201 @d find_last_char==
202 if font_dir[font(tx)]<>dir_default then cur_val:=KANJI(info(link(tx))) mod max_cjk_val
203 else cur_val:=qo(character(tx))
204
205 @d ignore_font_kerning==
206 begin if ((type(tx)=glue_node) and (subtype(tx)=jfm_skip+1))
207 or ((type(tx)=penalty_node) and (subtype(tx)=kinsoku_pena)) then
208 tx:=last_jchr
209 else if (type(tx)=kern_node) and (subtype(tx)=normal) then
210 begin r:=head; q:=link(head);
211 while q<>tx do
212 begin r:=q;
213 if is_char_node(q) then if font_dir[font(q)]<>dir_default then q:=link(q);
214 q:=link(q);
215 end;
216 if ((type(r)=penalty_node) and (subtype(r)=kinsoku_pena)) then tx:=last_jchr else tx:=r;
217 end;
218 end
219 @z
220
221 @x
222 ptex_minor_version_code: cur_val:=pTeX_minor_version;
223 @y
224 eptex_version_code: cur_val:=epTeX_version_number;
225 ptex_minor_version_code: cur_val:=pTeX_minor_version;
226 @z
227
228 @x [26.424] e-pTeX: node char
229 if cur_chr=last_node_type_code then
230 begin cur_val_level:=int_val;
231 if (tx=head)or(mode=0) then cur_val:=-1;
232 end
233 else cur_val_level:=cur_chr;
234 @y
235 if (cur_chr=last_node_type_code)or(cur_chr=last_node_subtype_code) then
236 begin cur_val_level:=int_val;
237 if (tx=head)or(mode=0) then cur_val:=-1;
238 end
239 else if cur_chr=last_node_char_code then
240 begin cur_val_level:=int_val; cur_val:=-1;
241 end
242 else if cur_chr=last_node_font_code then
243 begin if level<>tok_val then
244 begin print_err("Missing number, treated as zero");
245 @.Missing number...@>
246 help3("A number should have been here; I inserted `0'.")@/
247 ("(If you can't figure out why I needed to see a number,")@/
248 ("look up `weird error' in the index to The TeXbook.)");
249 @:TeXbook}{\sl The \TeX book@>
250 back_error; scanned_result(0)(dimen_val);
251 end
252 else scanned_result(null_font+font_id_base)(ident_val);
253 end
254 else cur_val_level:=cur_chr;
255 if (cur_chr=last_node_char_code)or(cur_chr=last_node_font_code) then
256 if is_char_node(tx)and(tx<>head) then begin
257 { |tx| might be ``second node'' of a KANJI character; so we need to look the node before |tx| }
258 r:=head; q:=head;
259 while q<>tx do begin r:=q; q:=link(q); end; { |r| is the node just before |tx| }
260 if (r<>head)and is_char_node(r) then if font_dir[font(r)]<>dir_default then tx:=r;
261 if cur_chr=last_node_char_code then find_last_char
262 else cur_val:=font(tx)+font_id_base;
263 end;
264 @z
265
266 @x [26.424] e-pTeX: node types
267 last_node_type_code: if type(tx)<=unset_node then cur_val:=type(tx)+1
268 else cur_val:=unset_node+2;
269 @y
270 last_node_type_code: if type(tx)<=unset_node then
271 begin if type(tx)=dir_node then tx:=list_ptr(tx);
272 cur_val:=type(tx);
273 if cur_val<dir_node then cur_val:=cur_val+1
274 else if cur_val>disp_node then cur_val:=cur_val-1;
275 end
276 else cur_val:=unset_node; {\epTeX's |unset_node| is \eTeX's |unset_node+2|}
277 last_node_subtype_code: if type(tx)<=unset_node then cur_val:=subtype(tx)
278 { non-math nodes }
279 else begin
280 cur_val:=type(tx);
281 if cur_val<unset_node+4 then cur_val:=cur_val-unset_node-1
282 { |style_noad|, |choice_noad|, |ord_noad| }
283 else if cur_val=unset_node+4 then cur_val:=cur_val-unset_node-1+subtype(tx)
284 else cur_val:=cur_val-unset_node+1;
285 end;
286 last_node_char_code: begin
287 ignore_font_kerning;
288 if is_char_node(tx) then
289 find_last_char
290 else if type(tx)=ligature_node then
291 {decompose a ligature to original characters}
292 begin r:=lig_ptr(tx);
293 while link(r)<>null do r:=link(r);
294 cur_val:=qo(character(r));
295 end
296 {else: already -1}
297 end;
298 last_node_font_code: begin
299 ignore_font_kerning;
300 if is_char_node(tx) then
301 cur_val:=font(tx)+font_id_base
302 else if type(tx)=ligature_node then
303 cur_val:=font(lig_char(tx))+font_id_base
304 {else: already nullfont}
305 end;
306 @z
307
308 @x
309 last_node_type_code: cur_val:=last_node_type;
310 @y
311 last_node_type_code: cur_val:=last_node_type;
312 last_node_subtype_code: cur_val:=last_node_subtype;
313 @z
314
315 @x e-pTeX: if primitives - leave room for three e-TeX codes
316 @d if_tdir_code=if_case_code+1 { `\.{\\iftdir}' }
317 @y
318 @d if_tdir_code=if_case_code+4 { `\.{\\iftdir}' }
319 @z
320
321 @x procedure conditional
322 @!m,@!n:integer; {to be tested against the second operand}
323 @!p,@!q:pointer; {for traversing token lists in \.{\\ifx} tests}
324 @y
325 @!m,@!n,@!s,@!v,@!nn,@!jj:integer; {to be tested against the second operand}
326 @!p,@!q:pointer; {for traversing token lists in \.{\\ifx} tests}
327 @z
328
329 @x [30.???] |scan_font_ident|: recognize \lastnodefont
330 else begin print_err("Missing font identifier");
331 @y
332 else if (cur_cmd=last_item)and(cur_chr=last_node_font_code) then
333 begin scan_something_internal_ident; f:=cur_val-font_id_base;
334 end
335 else begin print_err("Missing font identifier");
336 @z
337
338 @x
339 @d box_lr(#) == (qo(subtype(#))) {direction mode of a box}
340 @d set_box_lr(#) == subtype(#):=set_box_lr_end
341 @d set_box_lr_end(#) == qi(#)
342 @y
343 @d box_lr(#) == ((qo(subtype(#)))div 16) {direction mode of a box}
344 @d set_box_lr(#) == subtype(#):=box_dir(#)+dir_max+set_box_lr_end
345 @d set_box_lr_end(#) == qi(16*(#))
346 @z
347
348 @x [35]
349 @<Initialize table entries...@>=
350 text_baseline_shift_factor:=1000;
351 @y
352 @<Initialize table entries...@>=
353 text_baseline_shift_factor:=1000;
354 read_papersize_special:=1;
355 @z
356
357 @x
358 @!last_node_type:integer; {used to implement \.{\\lastnodetype}}
359 @y
360 @!last_node_type:integer; {used to implement \.{\\lastnodetype}}
361 @!last_node_subtype:integer; {used to implement \.{\\lastnodesubtype}}
362 @z
363
364 @x
365 last_node_type:=-1;
366 @y
367 last_node_type:=-1; last_node_subtype:=-1;
368 @z
369
370 @x [45.996] l.19420
371 last_node_type:=type(p)+1;
372 @y
373 if type(p)<dir_node then last_node_type:=type(p)+1
374 else if type(p)=dir_node then last_node_type:=type(list_ptr(p))+1
375 else if type(p)<disp_node then last_node_type:=type(p)
376 else last_node_type:=type(p)-1; {no |disp_node| in a vertical list}
377 last_node_subtype:=subtype(p);
378 @z
379
380 @x [47.1079] l.20920
381 @!fd:boolean; {a final |disp_node| pair?}
382 @y
383 @!s:pointer; {running behind |r|}
384 @!t:pointer;
385 @!fm:integer; {1: if |r|, 2: if |p| is a \.{\\beginM} node}
386 @!gm:integer; {1: if |link(q)|, 2: if |q| is an \.{\\endM} node}
387 @!fd,@!gd:integer; {same for |disp_node|}
388 @z
389
390 @x [47.1080] l.20940
391 @d check_effective_tail==check_effective_tail_pTeX
392 @d fetch_effective_tail==fetch_effective_tail_pTeX
393 @y
394 @d fetch_effective_tail_epTeX(#)== {extract |tx|,
395 drop \.{\\beginM} \.{\\endM} pair and\slash or merge |disp_node| pair}
396 q:=head; p:=null; r:=null; fm:=0; fd:=0; disp:=0; pdisp:=0;
397 repeat s:=r; r:=p; p:=q; fm:=fm div 2; fd:=fd div 2;
398 if not is_char_node(q) then
399 if type(q)=disc_node then
400 begin for m:=1 to replace_count(q) do
401 begin p:=link(p); if p=tx then #; end
402 { |tx| might be a part of discretionary; in this case, nothing will be removed}
403 end
404 else if (type(q)=math_node)and(subtype(q)=begin_M_code) then fm:=2
405 else if type(q)=disp_node then
406 begin pdisp:=disp; disp:=disp_dimen(q); fd:=2;@+end;
407 q:=link(p);
408 until q=tx; {found |s|$\to$|r|$\to$|p|$\to$|q=tx|}
409 q:=link(tx); link(p):=q; link(tx):=null;
410 if q=null then begin tail:=p; gm:=0; gd:=0;@+end
411 else begin if type(q)=math_node then
412 begin gm:=2;
413 if link(q)=null then gd:=0
414 else if type(link(q))=disp_node then gd:=1
415 else confusion("tail3");
416 @:this can't happen tail3}{\quad tail3@>
417 end
418 else if type(q)=disp_node then
419 begin prev_node:=p; gd:=2;
420 if link(q)=null then gm:=0
421 else if type(link(q))=math_node then gm:=1
422 else confusion("tail4");
423 @:this can't happen tail4}{\quad tail4@>
424 end
425 else confusion("tail5");
426 @:this can't happen tail5}{\quad tail5@>
427 end;
428 if gm=0 then if fm=2 then confusion("tail1")
429 @:this can't happen tail1}{\quad tail1@>
430 else if fm=1 then confusion("tail2");
431 @:this can't happen tail2}{\quad tail2@>
432 if (fm+fd)=1 then begin fm:=0; fd:=0;@+end;
433 if gm=0 then fm:=0;
434 if gd=0 then fd:=0;
435 @#
436 if fd>0 then {merge a |disp_node| pair}
437 begin if gm=0 then {|p|$\to$|q=disp_node|$to$|null|}
438 begin t:=q; q:=null; link(p):=q; tail:=p;@+end
439 else if gm=1 then {|p|$\to$|q=disp_node|$to$|end_M|$to$|null|}
440 begin t:=q; q:=link(q); link(p):=q; gm:=2;@+end
441 else {|p|$\to$|q=end_M|$\to$|disp_node|$to$|null|}
442 begin t:=link(q); link(q):=null; tail:=q;@+end;
443 @#
444 if fd=1 then {|s|$\to$|r=disp_node|}
445 begin prev_node:=s; disp_dimen(r):=disp_dimen(t);@+end
446 else {|r|$\to$|p=disp_node|}
447 begin prev_node:=r; disp_dimen(p):=disp_dimen(t);@+end;
448 prev_disp:=pdisp; free_node(t,small_node_size); gd:=0;
449 end;
450 @#
451 if fm>0 then {drop \.{\\beginM} \.{\\endM} pair}
452 begin if gd=0 then {|p|$\to$|q=end_M|$to$|null|}
453 begin t:=q; q:=null; link(p):=q; tail:=p;@+end
454 else if gd=1 then {|p|$\to$|q=end_M|$to$|disp_node|$to$|null|}
455 begin t:=q; q:=link(q); link(p):=q; prev_node:=p; link(t):=null
456 end
457 else {|p|$\to$|q=disp_node|$\to$|end_M|$to$|null|}
458 begin t:=link(q); link(q):=null; tail:=q;@+end;
459 @#
460 if fm=1 then {|s|$\to$|r=begin_M|$\to$|p=disp_node|}
461 begin link(s):=p; link(r):=t; t:=r; prev_node:=s;@+end
462 else {|r|$\to$|p=begin_M|$\to$|q|}
463 begin link(r):=q; link(p):=t; t:=p;
464 if q=null then tail:=r@+else prev_node:=r;
465 end;
466 flush_node_list(t);
467 end
468 @#
469 @d check_effective_tail(#)==find_effective_tail_epTeX
470 @d fetch_effective_tail==fetch_effective_tail_epTeX
471 @z
472
473 @x [47.1105] l.21246
474 @!fd:boolean; {a final |disp_node| pair?}
475 @y
476 @!s:pointer; {running behind |r|}
477 @!t:pointer;
478 @!fm:integer; {1: if |r|, 2: if |p| is a \.{\\beginM} node}
479 @!gm:integer; {1: if |link(q)|, 2: if |q| is an \.{\\endM} node}
480 @!fd,@!gd:integer; {same for |disp_node|}
481 @z
482
483 @x
484 @d set_language_code=5 {command modifier for \.{\\setlanguage}}
485 @y
486 @d set_language_code=5 {command modifier for \.{\\setlanguage}}
487 @d epTeX_input_encoding_code=6 {command modifier for \.{\\epTeXinputencoding}}
488 @z
489
490 @x
491 primitive("setlanguage",extension,set_language_code);@/
492 @!@:set_language_}{\.{\\setlanguage} primitive@>
493 @y
494 primitive("setlanguage",extension,set_language_code);@/
495 @!@:set_language_}{\.{\\setlanguage} primitive@>
496 primitive("epTeXinputencoding",extension,epTeX_input_encoding_code);@/
497 @!@:epTeX_input_encoding_}{\.{\\epTeXinputencoding} primitive@>
498 @z
499
500 @x
501 set_language_code:print_esc("setlanguage");
502 @y
503 set_language_code:print_esc("setlanguage");
504 epTeX_input_encoding_code:print_esc("epTeXinputencoding");
505 @z
506
507 @x
508 set_language_code:@<Implement \.{\\setlanguage}@>;
509 @y
510 set_language_code:@<Implement \.{\\setlanguage}@>;
511 epTeX_input_encoding_code:@<Implement \.{\\epTeXinputencoding}@>;
512 @z
513
514 @x
515 @ @<Finish the extensions@>=
516 @y
517 @ @<Declare procedures needed in |do_ext...@>=
518 procedure eptex_set_input_encoding;
519 var j,k:integer;
520 begin
521 scan_file_name;
522 pack_cur_name;
523 if state=token_list then
524 begin k:=input_ptr-1; j:=-1;
525 while k>=0 do
526 begin if input_stack[k].state_field=token_list then decr(k)
527 else if input_stack[k].name_field>19 then
528 begin j:=input_stack[k].index_field; k:=-1; end
529 else begin j:=-(input_stack[k].name_field+1); k:=-1; end
530 end
531 end
532 else if name>19 then j:=index else j:=-(name+1);
533 if (j>=0) or (j=-1) or (j=-18) then begin
534 k:=true;
535 if j>=0 then k:=setinfileenc(input_file[j],stringcast(name_of_file+1))
536 else k:=setstdinenc(stringcast(name_of_file+1));
537 if k = false then
538 begin begin_diagnostic;
539 print_nl("Unknown encoding `");
540 slow_print(cur_area); slow_print(cur_name); slow_print(cur_ext);
541 print("'"); end_diagnostic(false);
542 end
543 end
544 else
545 begin begin_diagnostic; j:=-j-1;
546 print_ln;
547 print_nl("Warning: \epTeXinputencoding is ignored, since I am current reading");
548 print_nl("from ");
549 if j>=18 then print("a pseudo file created by \scantokens.")
550 else begin print("input stream "); print_int(j); print("."); end;
551 end_diagnostic(false);
552 end
553 end;
554
555 @ @<Implement \.{\\epTeXinputencoding}@>=
556 eptex_set_input_encoding
557
558 @ @<Finish the extensions@>=
559 @z
560
561 @x
562 primitive("lastnodetype",last_item,last_node_type_code);
563 @!@:last_node_type_}{\.{\\lastnodetype} primitive@>
564 @y
565 primitive("lastnodetype",last_item,last_node_type_code);
566 @!@:last_node_type_}{\.{\\lastnodetype} primitive@>
567 primitive("lastnodesubtype",last_item,last_node_subtype_code);
568 @!@:last_node_subtype_}{\.{\\lastnodesubtype} primitive@>
569 primitive("lastnodechar",last_item,last_node_char_code);
570 @!@:last_node_char_}{\.{\\lastnodechar} primitive@>
571 primitive("lastnodefont",last_item,last_node_font_code);
572 @!@:last_node_font_}{\.{\\lastnodefont} primitive@>
573 @z
574
575 @x
576 last_node_type_code: print_esc("lastnodetype");
577 @y
578 last_node_type_code: print_esc("lastnodetype");
579 last_node_subtype_code: print_esc("lastnodesubtype");
580 last_node_char_code: print_esc("lastnodechar");
581 last_node_font_code: print_esc("lastnodefont");
582 @z
583
584 @x
585 primitive("savinghyphcodes",assign_int,int_base+saving_hyph_codes_code);@/
586 @!@:saving_hyph_codes_}{\.{\\savinghyphcodes} primitive@>
587 @y
588 primitive("savinghyphcodes",assign_int,int_base+saving_hyph_codes_code);@/
589 @!@:saving_hyph_codes_}{\.{\\savinghyphcodes} primitive@>
590 primitive("readpapersizespecial",assign_int,int_base+read_papersize_special_code);@/
591 @!@:read_papersize_special_}{\.{\\readpapersizespecial} primitive@>
592 @z
593
594 @x
595 saving_hyph_codes_code:print_esc("savinghyphcodes");
596 @y
597 saving_hyph_codes_code:print_esc("savinghyphcodes");
598 read_papersize_special_code:print_esc("readpapersizespecial");
599 @z
600
601 @x e-pTeX: font_char_{wd,ht,dp,ic}_code l.27306
602 font_char_ic_code: begin scan_font_ident; q:=cur_val; scan_char_num;
603 if (font_bc[q]<=cur_val)and(font_ec[q]>=cur_val) then
604 begin i:=char_info(q)(qi(cur_val));
605 case m of
606 font_char_wd_code: cur_val:=char_width(q)(i);
607 font_char_ht_code: cur_val:=char_height(q)(height_depth(i));
608 font_char_dp_code: cur_val:=char_depth(q)(height_depth(i));
609 font_char_ic_code: cur_val:=char_italic(q)(i);
610 end; {there are no other cases}
611 end
612 else cur_val:=0;
613 end;
614 @y
615 font_char_ic_code: begin scan_font_ident; q:=cur_val;
616 if font_dir[q]<>dir_default then {Japanese font}
617 begin scan_int;
618 if cur_val>=0 then
619 begin if is_char_kanji(cur_val) then {Japanese Character}
620 cur_val:=get_jfm_pos(KANJI(cur_val),q)
621 else cur_val:=-1
622 end
623 else begin
624 cur_val:=-(cur_val+1);
625 if (font_bc[q]>cur_val)or(font_ec[q]<cur_val) then cur_val:=-1
626 end;
627 if cur_val<>-1 then
628 begin
629 i:=orig_char_info(q)(qi(cur_val));
630 case m of
631 font_char_wd_code: cur_val:=char_width(q)(i);
632 font_char_ht_code: cur_val:=char_height(q)(height_depth(i));
633 font_char_dp_code: cur_val:=char_depth(q)(height_depth(i));
634 font_char_ic_code: cur_val:=char_italic(q)(i);
635 end; {there are no other cases}
636 end
637 else cur_val:=0;
638 end
639 else begin scan_latin_num;
640 if (font_bc[q]<=cur_val)and(font_ec[q]>=cur_val) then
641 begin i:=orig_char_info(q)(qi(cur_val));
642 case m of
643 font_char_wd_code: cur_val:=char_width(q)(i);
644 font_char_ht_code: cur_val:=char_height(q)(height_depth(i));
645 font_char_dp_code: cur_val:=char_depth(q)(height_depth(i));
646 font_char_ic_code: cur_val:=char_italic(q)(i);
647 end; {there are no other cases}
648 end
649 else cur_val:=0;
650 end
651 end;
652 @z
653
654 @x e-pTeX: displacement value when typesetting right-to-left l.27798
655 @!LR_ptr:pointer; {stack of LR codes for |hpack|, |ship_out|, and |init_math|}
656 @y
657 @!revdisp:scaled; {temporary value of displacement}
658 @!LR_ptr:pointer; {stack of LR codes for |hpack|, |ship_out|, and |init_math|}
659 @z
660
661 @x e-pTeX: reverse nodes of an hlist l.28010
662 var l:pointer; {the new list}
663 @y
664 var l,la:pointer; {the new list}
665 disp,disp2: scaled; { displacement } disped: boolean;
666 @z
667 @x e-pTeX: reverse nodes of an hlist l.28010
668 begin g_order:=glue_order(this_box); g_sign:=glue_sign(this_box);
669 @y
670 begin g_order:=glue_order(this_box); g_sign:=glue_sign(this_box);
671 disp:=revdisp; disped:=false;
672 @z
673 @x e-pTeX: reverse nodes of an hlist l.28010
674 done:reverse:=l;
675 @y
676 done: {if the beginning node of the new list isn't |disp_node|,
677 we insert |disp_node| to fix.}
678 if (l<>null)and(type(l)<>disp_node) then begin
679 p:=get_node(small_node_size); type(p):=disp_node;
680 disp_dimen(p):=disp; link(p):=l; reverse:=p;
681 end
682 else reverse:=l;
683 @z
684 @x e-pTeX: reverse nodes of an hlist l.28010
685 q:=link(p); link(p):=l; l:=p; p:=q;
686 @y
687 if font_dir[f]<>dir_default then begin
688 q:=link(p); la:=l; l:=p; p:=link(q); link(q):=la;
689 end
690 else begin q:=link(p); link(p):=l; l:=p; p:=q; end;
691 @z
692 @x e-pTeX: reverse nodes of an hlist l.28010
693 othercases goto next_p
694 @y
695 disp_node: begin
696 disp2:=disp_dimen(p); disp_dimen(p):=disp; disp:=disp2;
697 if not disped then disped:=true; end;
698 othercases goto next_p
699 @z
700
701 @x e-pTeX: just_copy
702 hlist_node,vlist_node: begin r:=get_node(box_node_size);
703 @y
704 dir_node,
705 hlist_node,vlist_node: begin r:=get_node(box_node_size);
706 @z
707 @x e-pTeX: just_copy
708 mem[r+6]:=mem[p+6]; mem[r+5]:=mem[p+5]; {copy the last two words}
709 @y
710 mem[r+7]:=mem[p+7];
711 mem[r+6]:=mem[p+6]; mem[r+5]:=mem[p+5]; {copy the last three words}
712 add_glue_ref(space_ptr(r)); add_glue_ref(xspace_ptr(r));
713 @z
714
715 @x e-pTeX: pseudo file
716 buffer[last]:=w.b0; buffer[last+1]:=w.b1;
717 buffer[last+2]:=w.b2; buffer[last+3]:=w.b3;
718 @y
719 buffer[last]:=w.b0 mod @"100; buffer[last+1]:=w.b1 mod @"100;
720 buffer[last+2]:=w.b2 mod @"100; buffer[last+3]:=w.b3 mod @"100;@/
721 buffer2[last]:=0; buffer2[last+1]:=0;
722 buffer2[last+2]:=0; buffer2[last+3]:=0;
723 @z
724
725 @x e-pTeX: \readline
726 @ @<Handle \.{\\readline} and |goto done|@>=
727 if j=1 then
728 begin while loc<=limit do {current line not yet finished}
729 begin cur_chr:=buffer[loc]; incr(loc);
730 if cur_chr=" " then cur_tok:=space_token
731 @+else cur_tok:=cur_chr+other_token;
732 @y
733 @ @<Handle \.{\\readline} and |goto done|@>=
734 if j=1 then
735 begin while loc<=limit do {current line not yet finished}
736 begin cur_chr:=fromBUFF(ustringcast(buffer), limit+1, loc);
737 cur_tok:=kcat_code(kcatcodekey(cur_chr));
738 if (multistrlen(ustringcast(buffer), limit+1,loc)>1)and
739 check_kcat_code(cur_tok,cur_chr) then
740 begin if (cur_tok=not_cjk) then cur_tok:=other_kchar;
741 if (cur_tok=latin_ucs) then cur_tok:=letter;
742 cur_tok:=cur_chr+cur_tok*max_cjk_val;
743 loc:=loc+multistrlen(ustringcast(buffer), limit+1,loc);
744 end
745 else begin cur_chr:=buffer[loc]; incr(loc);
746 if cur_chr=" " then cur_tok:=space_token
747 else cur_tok:=cur_chr+other_token;
748 end;
749 @z
750
751 @x e-pTeX: ifcsname l.28620
752 buffer[m]:=info(p) mod @'400; incr(m); p:=link(p);
753 @y
754 if check_kanji(info(p)) then {|wchar_token|}
755 begin
756 if (isinternalUPTEX) then begin
757 s:=toUCS(ktokentochr(info(p)));
758 nn:=UVSgetcodepointlength(s);
759 jj:=1;
760 while jj<=nn do begin
761 v:=UVSgetcodepointinsequence(s,jj);
762 if (v>0) then begin
763 v:=UCStoUTF8(v);
764 if BYTE1(v)<>0 then
765 begin buffer[m]:=BYTE1(v); buffer2[m]:=1; incr(m); end;
766 if BYTE2(v)<>0 then
767 begin buffer[m]:=BYTE2(v); buffer2[m]:=1; incr(m); end;
768 if BYTE3(v)<>0 then
769 begin buffer[m]:=BYTE3(v); buffer2[m]:=1; incr(m); end;
770 buffer[m]:=BYTE4(v); buffer2[m]:=1; incr(m);
771 end;
772 incr(jj);
773 end
774 end
775 else begin
776 v:=toBUFF(info(p) mod max_cjk_val);
777 if BYTE1(v)<>0 then
778 begin buffer[m]:=BYTE1(v); buffer2[m]:=1; incr(m); end;
779 if BYTE2(v)<>0 then
780 begin buffer[m]:=BYTE2(v); buffer2[m]:=1; incr(m); end;
781 if BYTE3(v)<>0 then
782 begin buffer[m]:=BYTE3(v); buffer2[m]:=1; incr(m); end;
783 buffer[m]:=BYTE4(v); buffer2[m]:=1; incr(m);
784 end;
785 p:=link(p);
786 end
787 else
788 begin buffer[m]:=info(p) mod max_char_val; buffer2[m]:=0; incr(m); p:=link(p);
789 end;
790 @z
791
792 @x e-pTeX: if_font_char_code l.28633
793 if_font_char_code:begin scan_font_ident; n:=cur_val; scan_char_num;
794 if (font_bc[n]<=cur_val)and(font_ec[n]>=cur_val) then
795 b:=char_exists(char_info(n)(qi(cur_val)))
796 else b:=false;
797 end;
798 @y
799 if_font_char_code:begin scan_font_ident; n:=cur_val;
800 if font_dir[n]<>dir_default then {Japanese font}
801 begin scan_int;
802 if cur_val>=0 then b:=is_char_kanji(cur_val)
803 { In u\pTeX, $\hbox{|is_char_kanji|} = \lambda x\mathpunct{.} x\ge 0$ }
804 else begin
805 cur_val:=-(cur_val+1);
806 b:=(font_bc[n]<=cur_val)and(font_ec[n]>=cur_val)
807 end
808 end
809 else begin scan_latin_num;
810 cur_val:=ptencucsto8bitcode(font_enc[n],cur_val);
811 if (font_bc[n]<=cur_val)and(font_ec[n]>=cur_val) then @/
812 b:=char_exists(orig_char_info(n)(qi(cur_val)))
813 else b:=false;
814 end;
815 end;
816 @z
817
818 @x e-pTeX: pTeX has \showmode, follow showstream.ch r61589
819 @<Show the current japanese processing mode@>=
820 begin print_nl("> ");
821 @y
822 @<Show the current japanese processing mode@>=
823 begin
824 @<Adjust |selector| based on |show_stream|@>
825 print_nl("> ");
826 @z
827
828 @x
829 procedure print_direction(@!d:integer); {print the direction represented by d}
830 @y
831 procedure print_direction_alt(@!d:integer);
832 var x: boolean;
833 begin x:=false;
834 case abs(d) of
835 dir_yoko: begin print(", yoko"); x:=true; end;
836 dir_tate: begin print(", tate"); x:=true; end;
837 dir_dtou: begin print(", dtou"); x:=true; end;
838 end;
839 if x then begin if d<0 then print("(math)");
840 print(" direction"); end;
841 end;
842 @#
843 procedure print_direction(@!d:integer); {print the direction represented by d}
844 @z
845
846 @x e-pTeX: fetch \(no)auto(x)spacing status
847 @* \[54] System-dependent changes.
848 @y
849 @ The \.{\\currentspacingmode} and \.{\\currentxspacingmode} commands
850 return the current \pTeX's status of \.{\\(no)autospacing} and
851 \.{\\(no)autoxspacing} respectively.
852
853 @d current_spacing_mode_code=eTeX_int+8 {code for \.{\\currentspacingmode}}
854 @d current_xspacing_mode_code=eTeX_int+9 {code for \.{\\currentxspacingmode}}
855
856 @<Generate all \eTeX...@>=
857 primitive("currentspacingmode",last_item,current_spacing_mode_code);
858 @!@:current_spacing_mode_}{\.{\\currentspacingmode} primitive@>
859 primitive("currentxspacingmode",last_item,current_xspacing_mode_code);
860 @!@:current_xspacing_mode_}{\.{\\currentxspacingmode} primitive@>
861
862 @ @<Cases of |last_item| for |print_cmd_chr|@>=
863 current_spacing_mode_code: print_esc("currentspacingmode");
864 current_xspacing_mode_code: print_esc("currentxspacingmode");
865
866 @ @<Cases for fetching an integer value@>=
867 current_spacing_mode_code: cur_val:=auto_spacing;
868 current_xspacing_mode_code: cur_val:=auto_xspacing;
869
870 @ The \.{\\currentcjktoken} command returns the current \upTeX's
871 status of \.{\\(disable|enable|force)cjktoken}.
872
873 @d current_cjk_token_code=eTeX_int+10 {code for \.{\\currentcjktoken}}
874
875 @<Generate all \eTeX...@>=
876 primitive("currentcjktoken",last_item,current_cjk_token_code);
877 @!@:current_cjk_token_}{\.{\\currentcjktoken} primitive@>
878
879 @ @<Cases of |last_item| for |print_cmd_chr|@>=
880 current_cjk_token_code: print_esc("currentcjktoken");
881
882 @ @<Cases for fetching an integer value@>=
883 current_cjk_token_code: cur_val:=enable_cjk_token;
884
885 @* \[54] System-dependent changes.
886 @z