Debian Codegraph @

texk/web2c/xetexdir/xetex.ch

raw
1 /****************************************************************************\
2 $Id: xetex.ch 77404 2026-01-18 23:42:09Z karl $
3 Part of the XeTeX typesetting system
4 Copyright (c) 1994-2008 by SIL International
5 Copyright (c) 2009-2026 by Jonathan Kew
6 Copyright (c) 2012 by Khaled Hosny
7
8 SIL Author(s): Jonathan Kew
9
10 Permission is hereby granted, free of charge, to any person obtaining
11 a copy of this software and associated documentation files (the
12 "Software"), to deal in the Software without restriction, including
13 without limitation the rights to use, copy, modify, merge, publish,
14 distribute, sublicense, and/or sell copies of the Software, and to
15 permit persons to whom the Software is furnished to do so, subject to
16 the following conditions:
17
18 The above copyright notice and this permission notice shall be
19 included in all copies or substantial portions of the Software.
20
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE
25 FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
26 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
29 Except as contained in this notice, the name of the copyright holders
30 shall not be used in advertising or otherwise to promote the sale,
31 use or other dealings in this Software without prior written
32 authorization from the copyright holders.
33 \****************************************************************************/
34
35 @x
36 \let\maybe=\iffalse
37 @y
38 \let\maybe=\iftrue
39 @z
40
41 @x [1] m.2 l.188 - banner
42 @d banner==TeX_banner
43 @d banner_k==TeX_banner_k
44 @y
45 @d banner==XeTeX_banner
46 @d banner_k==XeTeX_banner
47 @z
48
49 @x [2.20] l.579 - printable characters
50 xchr: array [ASCII_code] of text_char;
51 { specifies conversion of output characters }
52 xprn: array [ASCII_code] of ASCII_code;
53 { non zero iff character is printable }
54 @y
55 @!xchr: ^text_char;
56 {dummy variable so tangle doesn't complain; not actually used}
57 @z
58
59 @x [2.23] l.723 - Translate characters if desired, otherwise allow them all.
60 {Initialize |xchr| to the identity mapping.}
61 for i:=0 to @'37 do xchr[i]:=i;
62 for i:=@'177 to @'377 do xchr[i]:=i;
63 @y
64 @z
65
66 @x [2.24] l.733 - Don't reinitialize xord.
67 for i:=0 to @'176 do xord[xchr[i]]:=i;
68 {Set |xprn| for printable ASCII, unless |eight_bit_p| is set.}
69 for i:=0 to 255 do xprn[i]:=(eight_bit_p or ((i>=" ")and(i<="~")));
70
71 {The idea for this dynamic translation comes from the patch by
72 Libor Skarvada \.{<libor@@informatics.muni.cz>}
73 and Petr Sojka \.{<sojka@@informatics.muni.cz>}. I didn't use any of the
74 actual code, though, preferring a more general approach.}
75
76 {This updates the |xchr|, |xord|, and |xprn| arrays from the provided
77 |translate_filename|. See the function definition in \.{texmfmp.c} for
78 more comments.}
79 if translate_filename then read_tcx_file;
80 @y
81 @z
82
83 @x [3.26] l.789 - name_of_file is no longer an array
84 @!name_of_file:^text_char;
85 @y
86 @!name_of_file:^UTF8_code; {we build filenames in utf8 to pass to the OS}
87 @z
88
89 @x
90 @!name_of_file16:array[1..file_name_size] of UTF16_code;@;@/
91 @y
92 @!name_of_file16:^UTF16_code;
93 @z
94
95 @x [3.30] l.888 - Array size of input buffer is determined at runtime.
96 @!buffer:^ASCII_code; {lines of characters being read}
97 @y
98 @!buffer:^UnicodeScalar; {lines of characters being read}
99 @z
100
101 @x [3.32] l.961 - `term_in' and `term_out' are standard input and output.
102 @d term_in==stdin {the terminal as an input file}
103 @y
104 @z
105
106 @x [3.32] l.961
107 @!bound_default:integer; {temporary for setup}
108 @y
109 @!term_in:unicode_file;
110 @#
111 @!bound_default:integer; {temporary for setup}
112 @z
113
114 @x [5.??] type of trick_buf[]
115 @!trick_buf:array[0..ssup_error_line] of ASCII_code; {circular buffer for
116 pseudoprinting}
117 @y
118 @!trick_buf:array[0..ssup_error_line] of UnicodeScalar; {circular buffer for
119 pseudoprinting}
120 @z
121
122 @x [5.61] l.1556 - Print rest of banner, eliminate misleading `(no format preloaded)'.
123 if translate_filename then begin
124 wterm(' (');
125 fputs(translate_filename, stdout);
126 wterm_ln(')');
127 @y
128 if translate_filename then begin
129 wterm(' (WARNING: translate-file "');
130 fputs(translate_filename, stdout);
131 wterm_ln('" ignored)');
132 @z
133
134 @x l.2020 - add a new |history| value for failure of the output driver
135 has been detected. It has four possible values: |spotless|, |warning_issued|,
136 |error_message_issued|, and |fatal_error_stop|.
137 @y
138 has been detected. It has five possible values: |spotless|, |warning_issued|,
139 |error_message_issued|, |fatal_error_stop|, and |output_failure|.
140 @z
141
142 @x l.2031
143 @d fatal_error_stop=3 {|history| value when termination was premature}
144 @y
145 @d fatal_error_stop=3 {|history| value when termination was premature}
146 @d output_failure=4 {|history| value when output driver returned an error}
147 @z
148
149 @x l.2036
150 @!history:spotless..fatal_error_stop; {has the source input been clean so far?}
151 @y
152 @!history:spotless..output_failure; {has the source input been clean so far?}
153 @z
154
155 @x [6.84] l.1904 - Implement the switch-to-editor option.
156 begin edit_name_start:=str_start[edit_file.name_field];
157 edit_name_length:=str_start[edit_file.name_field+1] -
158 str_start[edit_file.name_field];
159 @y
160 begin edit_name_start:=str_start_macro(edit_file.name_field);
161 edit_name_length:=str_start_macro(edit_file.name_field+1) -
162 str_start_macro(edit_file.name_field);
163 @z
164
165 @x [8.110] l.2423
166 @d max_halfword==@"FFFFFFF {largest allowable value in a |halfword|}
167 @y
168 @d max_halfword==@"3FFFFFFF {largest allowable value in a |halfword|}
169 @z
170
171 @x [15.209] l.4165
172 @d shorthand_def=95 {code definition ( \.{\\chardef}, \.{\\countdef}, etc.~)}
173 @y
174 @d shorthand_def=97 {code definition ( \.{\\chardef}, \.{\\countdef}, etc.~)}
175 @z
176
177 @x [16.215] - e-TeX last_node_type
178 last_glue:=max_halfword; last_penalty:=0; last_kern:=0;
179 @y
180 last_glue:=max_halfword; last_penalty:=0; last_kern:=0;
181 last_node_type:=-1;
182 @z
183
184 @x [17.222] l.4523 - frozen_special, for source specials.
185 @d frozen_null_font=frozen_control_sequence+11
186 @y
187 @d frozen_null_font=frozen_control_sequence+12+prim_size
188 @z
189
190 @x [17.230] l.4731
191 @d char_sub_code_base=math_code_base+256 {table of character substitutions}
192 @d int_base=char_sub_code_base+256 {beginning of region 5}
193 @y
194 @d char_sub_code_base=math_code_base+number_usvs {table of character substitutions}
195 @d int_base=char_sub_code_base+number_usvs {beginning of region 5}
196 @z
197
198 @x [17.236] l.4960 - first web2c, then e-TeX additional integer parameters
199 @d int_pars=web2c_int_pars {total number of integer parameters}
200 @#
201 @d etex_int_base=tex_int_pars {base for \eTeX's integer parameters}
202 @y
203 @d etex_int_base=web2c_int_pars {base for \eTeX's integer parameters}
204 @z
205
206 @x [22.304] l.6536 - texarray; additions for file:line:error style.
207 @!input_file : ^alpha_file;
208 @y
209 @!input_file : ^unicode_file;
210 @z
211
212 @x [29.516] l.9992 - filenames: more_name
213 begin if (c=" ") and stop_at_space and (not quoted_filename) then
214 more_name:=false
215 else if c="""" then begin
216 quoted_filename:=not quoted_filename;
217 @y
218 begin if stop_at_space and (c=" ") and (file_name_quote_char=0) then
219 more_name:=false
220 else if stop_at_space and (file_name_quote_char<>0) and (c=file_name_quote_char) then begin
221 file_name_quote_char:=0;
222 more_name:=true;
223 end
224 else if stop_at_space and (file_name_quote_char=0) and ((c="""") or (c="'")) then begin
225 file_name_quote_char:=c;
226 quoted_filename:=true;
227 @z
228
229 @x [29.517] l.10002 - end_name: string recycling
230 @!j,@!s,@!t: pool_pointer; {running indices}
231 @!must_quote:boolean; {whether we need to quote a string}
232 @y
233 @!j: pool_pointer; {running index}
234 @z
235 @x [29.517] l.10002 - end_name: string recycling
236 str_room(6); {Room for quotes, if needed.}
237 {add quotes if needed}
238 if area_delimiter<>0 then begin
239 {maybe quote |cur_area|}
240 must_quote:=false;
241 s:=str_start[str_ptr];
242 t:=str_start[str_ptr]+area_delimiter;
243 j:=s;
244 while (not must_quote) and (j<t) do begin
245 must_quote:=str_pool[j]=" "; incr(j);
246 end;
247 if must_quote then begin
248 for j:=pool_ptr-1 downto t do str_pool[j+2]:=str_pool[j];
249 str_pool[t+1]:="""";
250 for j:=t-1 downto s do str_pool[j+1]:=str_pool[j];
251 str_pool[s]:="""";
252 if ext_delimiter<>0 then ext_delimiter:=ext_delimiter+2;
253 area_delimiter:=area_delimiter+2;
254 pool_ptr:=pool_ptr+2;
255 end;
256 end;
257 {maybe quote |cur_name|}
258 s:=str_start[str_ptr]+area_delimiter;
259 if ext_delimiter=0 then t:=pool_ptr else t:=str_start[str_ptr]+ext_delimiter-1;
260 must_quote:=false;
261 j:=s;
262 while (not must_quote) and (j<t) do begin
263 must_quote:=str_pool[j]=" "; incr(j);
264 end;
265 if must_quote then begin
266 for j:=pool_ptr-1 downto t do str_pool[j+2]:=str_pool[j];
267 str_pool[t+1]:="""";
268 for j:=t-1 downto s do str_pool[j+1]:=str_pool[j];
269 str_pool[s]:="""";
270 if ext_delimiter<>0 then ext_delimiter:=ext_delimiter+2;
271 pool_ptr:=pool_ptr+2;
272 end;
273 if ext_delimiter<>0 then begin
274 {maybe quote |cur_ext|}
275 s:=str_start[str_ptr]+ext_delimiter-1;
276 t:=pool_ptr;
277 must_quote:=false;
278 j:=s;
279 while (not must_quote) and (j<t) do begin
280 must_quote:=str_pool[j]=" "; incr(j);
281 end;
282 if must_quote then begin
283 str_pool[t+1]:="""";
284 for j:=t-1 downto s do str_pool[j+1]:=str_pool[j];
285 str_pool[s]:="""";
286 pool_ptr:=pool_ptr+2;
287 end;
288 end;
289 @y
290 @z
291
292 @x [29.517] l.10011 - end_name: string recycling
293 for j:=str_start[str_ptr+1] to pool_ptr-1 do
294 @y
295 for j:=str_start_macro(str_ptr+1) to pool_ptr-1 do
296 @z
297
298 @x [29.517] l.10016 - end_name: string recycling
299 for j:=str_start[str_ptr+1] to pool_ptr-1 do
300 @y
301 for j:=str_start_macro(str_ptr+1) to pool_ptr-1 do
302 @z
303
304 @x [29.518] l.10042 - print_file_name: quote if spaces in names.
305 @d check_quoted(#) == {check if string |#| needs quoting}
306 if #<>0 then begin
307 j:=str_start[#];
308 while (not must_quote) and (j<str_start[#+1]) do begin
309 must_quote:=str_pool[j]=" "; incr(j);
310 @y
311 @d check_quoted(#) == {check if string |#| needs quoting}
312 if #<>0 then begin
313 j:=str_start_macro(#);
314 while ((not must_quote) or (quote_char=0)) and (j<str_start_macro(#+1)) do begin
315 if str_pool[j]=" " then must_quote:=true
316 else if (str_pool[j]="""") or (str_pool[j]="'") then begin
317 must_quote:=true;
318 quote_char:="""" + "'" - str_pool[j];
319 end;
320 incr(j);
321 @z
322
323 @x [29.518] l.10042 - print_file_name: quote if spaces in names.
324 @d print_quoted(#) == {print string |#|, omitting quotes}
325 if #<>0 then
326 for j:=str_start[#] to str_start[#+1]-1 do
327 if so(str_pool[j])<>"""" then
328 print(so(str_pool[j]))
329 @y
330 @d print_quoted(#) == {print string |#|, omitting quotes}
331 if #<>0 then
332 for j:=str_start_macro(#) to str_start_macro(#+1)-1 do begin
333 if str_pool[j]=quote_char then begin
334 print(quote_char);
335 quote_char:="""" + "'" - quote_char;
336 print(quote_char);
337 end;
338 if (so(str_pool[j])>=@"D800) and (so(str_pool[j])<=@"DBFF)
339 and (j+1<str_start_macro(#+1))
340 and (so(str_pool[j+1])>=@"DC00) and (so(str_pool[j+1])<=@"DFFF) then
341 begin print_char(@"10000 + (so(str_pool[j])-@"D800) * @"400
342 + so(str_pool[j+1])-@"DC00);
343 incr(j);
344 end
345 else
346 print(str_pool[j]);
347 end
348 @z
349
350 @x [29.518] l.10042 - print_file_name: quote if spaces in names.
351 @!j:pool_pointer; {index into |str_pool|}
352 begin
353 must_quote:=false;
354 check_quoted(a); check_quoted(n); check_quoted(e);
355 {FIXME: Alternative is to assume that any filename that has to be quoted has
356 at least one quoted component...if we pick this, a number of insertions
357 of |print_file_name| should go away.
358 |must_quote|:=((|a|<>0)and(|str_pool|[|str_start|[|a|]]=""""))or
359 ((|n|<>0)and(|str_pool|[|str_start|[|n|]]=""""))or
360 ((|e|<>0)and(|str_pool|[|str_start|[|e|]]=""""));}
361 if must_quote then print_char("""");
362 print_quoted(a); print_quoted(n); print_quoted(e);
363 if must_quote then print_char("""");
364 @y
365 @!quote_char: integer; {current quote char (single or double)}
366 @!j:pool_pointer; {index into |str_pool|}
367 begin
368 must_quote:=false;
369 quote_char:=0;
370 check_quoted(a); check_quoted(n); check_quoted(e);
371 if must_quote then begin
372 if quote_char=0 then quote_char:="""";
373 print_char(quote_char);
374 end;
375 print_quoted(a); print_quoted(n); print_quoted(e);
376 if quote_char<>0 then print_char(quote_char);
377 @z
378
379 @x [29.519] l.10051 - have append_to_name skip quotes.
380 @d append_to_name(#)==begin c:=#; if not (c="""") then begin incr(k);
381 if k<=file_name_size then name_of_file[k]:=xchr[c];
382 end end
383 @y
384 @d append_to_name(#)==begin c:=#; incr(k);
385 if k<=file_name_size then begin
386 if (c < 128) then name_of_file[k]:=c
387 else if (c < @"800) then begin
388 name_of_file[k]:=@"C0 + c div @"40; incr(k);
389 name_of_file[k]:=@"80 + c mod @"40;
390 end else if (c < @"D800) then begin
391 name_of_file[k]:=@"E0 + c div @"1000; incr(k);
392 name_of_file[k]:=@"80 + (c mod @"1000) div @"40; incr(k);
393 name_of_file[k]:=@"80 + c mod @"40;
394 end else if (c < @"DC00) and (k+3<file_name_size) then begin
395 name_of_file[k]:=@"F0 + (c - @"D7C0) div @"1000; incr(k);
396 name_of_file[k]:=@"80 + ((c - @"D7C0) mod @"1000) div @"4; incr(k);
397 name_of_file[k]:=@"80 + (c - @"D7C0) mod @"4 * @"10; incr(k);
398 name_of_file[k]:=@"80;
399 end else if (c < @"E000) and (k>4) then begin
400 decr(k);
401 name_of_file[k-1]:=name_of_file[k-1] + (c - @"DC00) div @"40;
402 name_of_file[k] :=name_of_file[k] + (c - @"DC00) mod @"40;
403 end else if (c < @"10000) then begin
404 name_of_file[k]:=@"E0 + c div @"1000; incr(k);
405 name_of_file[k]:=@"80 + (c mod @"1000) div @"40; incr(k);
406 name_of_file[k]:=@"80 + c mod @"40;
407 end else begin { replacement character U+FFFD }
408 name_of_file[k]:=@"EF; incr(k);
409 name_of_file[k]:=@"BF; incr(k);
410 name_of_file[k]:=@"BD;
411 end
412 end
413 end
414 @z
415
416 @x [29.519] l.10047 - pack_file_name, leave room for the extra null
417 name_of_file:= xmalloc_array (ASCII_code, length(a)+length(n)+length(e)+1);
418 @y
419 name_of_file:= xmalloc_array (UTF8_code, (length(a)+length(n)+length(e))*3+1);
420 @z
421
422 @x [29.523] l.10095 - Change to pack_buffered_name as with pack_file_name.
423 name_of_file := xmalloc_array (ASCII_code, n+(b-a+1)+format_ext_length+1);
424 for j:=1 to n do append_to_name(xord[ucharcast(TEX_format_default[j])]);
425 @y
426 name_of_file := xmalloc_array (UTF8_code, n+(b-a+1)+format_ext_length+1);
427 for j:=1 to n do append_to_name(TEX_format_default[j]);
428 @z
429
430 @x [29.523] l.10095 - Change to pack_buffered_name as with pack_file_name.
431 append_to_name(xord[ucharcast(TEX_format_default[j])]);
432 @y
433 append_to_name(TEX_format_default[j]);
434 @z
435
436 @x [29.525] l.10174 - make_name_string
437 k:=1;
438 while (k<=name_length)and(more_name(name_of_file[k])) do
439 @y
440 k:=0;
441 while (k<name_length16)and(more_name(name_of_file16[k])) do
442 @z
443
444 @x [29.526] l.10194 - stop scanning file name if we're at end-of-line.
445 {If |cur_chr| is a space and we're not scanning a token list, check
446 whether we're at the end of the buffer. Otherwise we end up adding
447 spurious spaces to file names in some cases.}
448 if (cur_chr=" ") and (state<>token_list) and (loc>limit) then goto done;
449 @y
450 @z
451
452 @x [29.536] l.10331
453 wlog(' (');
454 fputs(translate_filename, log_file);
455 wlog(')');
456 @y
457 wlog(' (WARNING: translate-file "');
458 fputs(translate_filename, log_file);
459 wlog('" ignored)');
460 @z
461
462 @x [29.537] l.10338 - start_input
463 var temp_str: str_number;
464 v: pointer;
465 begin scan_file_name; {set |cur_name| to desired file name}
466 @y
467 var temp_str: str_number;
468 v: pointer;
469 @!k:0..file_name_size; {index into |name_of_file16|}
470 begin scan_file_name; {set |cur_name| to desired file name}
471 @z
472
473 @x [29.537] l.10338 - start_input
474 and a_open_in(cur_file, kpse_tex_format) then
475 goto done;
476 @y
477 and u_open_in(cur_file, kpse_tex_format, XeTeX_default_input_mode, XeTeX_default_input_encoding) then
478 {At this point |name_of_file| contains the actual name found, as a UTF8 string.
479 We convert to UTF16, then extract the |cur_area|, |cur_name|, and |cur_ext| from it.}
480 begin
481 make_utf16_name;
482 name_in_progress:=true;
483 begin_name;
484 stop_at_space:=false;
485 k:=0;
486 while (k<name_length16)and(more_name(name_of_file16[k])) do
487 incr(k);
488 stop_at_space:=true;
489 end_name;
490 name_in_progress:=false;
491 goto done;
492 end;
493 @z
494
495 @x [30.549] l.10682 - texarray
496 @!font_bc: ^eight_bits;
497 {beginning (smallest) character code}
498 @!font_ec: ^eight_bits;
499 {ending (largest) character code}
500 @y
501 @!font_bc: ^UTF16_code;
502 {beginning (smallest) character code}
503 @!font_ec: ^UTF16_code;
504 {ending (largest) character code}
505 @z
506
507 @x [30.549] l.10682 - texarray
508 @!font_false_bchar: ^nine_bits;
509 {|font_bchar| if it doesn't exist in the font, otherwise |non_char|}
510 @y
511 @!font_false_bchar: ^nine_bits;
512 {|font_bchar| if it doesn't exist in the font, otherwise |non_char|}
513 @#
514 @!font_layout_engine: ^void_pointer; {either an CFDictionaryRef or a XeTeXLayoutEngine}
515 @!font_mapping: ^void_pointer; { |TECkit_Converter| or 0 }
516 @!font_flags: ^char; { flags:
517 0x01: |font_colored|
518 0x02: |font_vertical| }
519 @!font_letter_space: ^scaled; { letterspacing to be applied to the font }
520 @!loaded_font_mapping: void_pointer; { used by |load_native_font| to return mapping, if any }
521 @!loaded_font_flags: char; { used by |load_native_font| to return flags }
522 @!loaded_font_letter_space: scaled;
523 @!loaded_font_design_size: scaled;
524 @!mapped_text: ^UTF16_code; { scratch buffer used while applying font mappings }
525 @!xdv_buffer: ^char; { scratch buffer used in generating XDV output }
526 @z
527
528 @x [30.561] l.10939 - Check lengths
529 else print(" not loadable: Metric (TFM) file not found");
530 @y
531 else print(" not loadable: Metric (TFM) file or installed font not found");
532 @z
533
534 @x
535 @ We need a few subroutines for |new_character|.
536
537 @p @t\4@>@<Declare subroutines for |new_character|@>@;
538 @y
539 @ The subroutines for |new_character| have been moved.
540 @z
541
542 @x [30.582] l.11276 - MLTeX: call |effective_char| in |new_character|
543 @p function new_character(@!f:internal_font_number;@!c:eight_bits):pointer;
544 @y
545 @p function new_character(@!f:internal_font_number;@!c:ASCII_code):pointer;
546 @z
547
548 @x [30.582] l.11276 - MLTeX: call |effective_char| in |new_character|
549 begin ec:=effective_char(false,f,qi(c));
550 @y
551 begin
552 if is_native_font(f) then
553 begin new_character:=new_native_character(f,c); return;
554 end;
555 ec:=effective_char(false,f,qi(c));
556 @z
557
558 @x [32.619] l.12294 - MLTeX: substitute character in |hlist_out|
559 label reswitch, move_past, fin_rule, next_p, continue, found;
560 @y
561 label reswitch, move_past, fin_rule, next_p, continue, found, check_next, end_node_run;
562 @z
563
564 @x
565 if list_ptr(p)=null then cur_v:=cur_v+height(p)+depth(p)
566 @y
567 if list_ptr(p)=null then begin
568 if upwards then cur_v:=cur_v-depth(p)-height(p) else cur_v:=cur_v+height(p)+depth(p);
569 end
570 @z
571
572 @x [32.645] l.12780 - use print_file_name
573 print_nl("Output written on "); print_file_name(0, output_file_name, 0);
574 @.Output written on x@>
575 print(" ("); print_int(total_pages);
576 if total_pages<>1 then print(" pages")
577 else print(" page");
578 print(", "); print_int(dvi_offset+dvi_ptr); print(" bytes).");
579 b_close(dvi_file);
580 @y
581 k:=dvi_close(dvi_file);
582 if k=0 then begin
583 print_nl("Output written on "); print(output_file_name);
584 @.Output written on x@>
585 print(" ("); print_int(total_pages);
586 if total_pages<>1 then print(" pages")
587 else print(" page");
588 if no_pdf_output then begin
589 print(", "); print_int(dvi_offset+dvi_ptr); print(" bytes).");
590 end else print(").");
591 end else begin
592 print_nl("Error "); print_int(k); print(" (");
593 if no_pdf_output then print_c_string(strerror(k))
594 else print("driver return code");
595 print(") generating output;");
596 print_nl("file "); print(output_file_name); print(" may not be valid.");
597 history:=output_failure;
598 end;
599 @z
600
601 @x [43.943] l.18348 - bigtrie: Larger hyphenation tries.
602 @!trie_used:array[ASCII_code] of trie_opcode;
603 @y
604 @!trie_used:array[0..biggest_lang] of trie_opcode;
605 @z
606
607 @x [43.946] l.18416 - bigtrie: And larger tries again.
608 for k:=0 to 255 do trie_used[k]:=min_trie_op;
609 @y
610 for k:=0 to biggest_lang do trie_used[k]:=min_trie_op;
611 @z
612
613 @xx [43.958] l.18638 - bigtrie: Larger tries.
614 begin for r:=0 to 256 do clear_trie;
615 trie_max:=256;
616 @y
617 begin for r:=0 to max_hyph_char do clear_trie;
618 trie_max:=max_hyph_char;
619 @z
620
621 @x [49.1222] l.22833 - MLTeX: \charsubdef primitive
622 else begin n:=cur_chr; get_r_token; p:=cur_cs; define(p,relax,256);
623 @y
624 else begin n:=cur_chr; get_r_token; p:=cur_cs; define(p,relax,too_big_usv);
625 @z
626
627 @x [49.1275] l.23441 - Same stuff as for \input, this time for \openin.
628 var c:0..1; {1 for \.{\\openin}, 0 for \.{\\closein}}
629 @!n:0..15; {stream number}
630 @y
631 var c:0..1; {1 for \.{\\openin}, 0 for \.{\\closein}}
632 @!n:0..15; {stream number}
633 @!k:0..file_name_size; {index into |name_of_file16|}
634 @z
635
636 @x [49.1275] l.23441 - Same stuff as for \input, this time for \openin.
637 and a_open_in(read_file[n], kpse_tex_format) then
638 read_open[n]:=just_open;
639 @y
640 and u_open_in(read_file[n], kpse_tex_format, XeTeX_default_input_mode, XeTeX_default_input_encoding) then
641 begin
642 make_utf16_name;
643 name_in_progress:=true;
644 begin_name;
645 stop_at_space:=false;
646 k:=0;
647 while (k<name_length16)and(more_name(name_of_file16[k])) do
648 incr(k);
649 stop_at_space:=true;
650 end_name;
651 name_in_progress:=false;
652 read_open[n]:=just_open;
653 end;
654 @z
655
656 @x [50.1302] l.23690 - store_fmt_file
657 @!format_engine: ^text_char;
658 @y
659 @!format_engine: ^char;
660 @z
661
662 @x [50.1303] l.23722 - load_fmt_file
663 @!format_engine: ^text_char;
664 @!dummy_xord: ASCII_code;
665 @!dummy_xchr: text_char;
666 @!dummy_xprn: ASCII_code;
667 @y
668 @!format_engine: ^char;
669 @z
670
671 @x [50,1307] l.23779 - texarray
672 format_engine:=xmalloc_array(text_char,x+4);
673 @y
674 format_engine:=xmalloc_array(char,x+4);
675 @z
676
677 @x [50,1307] l.23779 - texarray
678 @<Dump |xord|, |xchr|, and |xprn|@>;
679 @y
680 @z
681
682 @x [50.1308] l.23793 - texarray
683 format_engine:=xmalloc_array(text_char, x);
684 @y
685 format_engine:=xmalloc_array(char, x);
686 @z
687
688 @x [50.1308] l.23793 - texarray
689 @<Undump |xord|, |xchr|, and |xprn|@>;
690 @y
691 @z
692
693 @x [50.1309] l.23814 - Make dumping/undumping more efficient.
694 dump_things(str_start[0], str_ptr+1);
695 @y
696 dump_things(str_start_macro(too_big_char), str_ptr+1-too_big_char);
697 @z
698
699 @x [50.1310] l.23829 - Make dumping/undumping more efficient.
700 undump_checked_things(0, pool_ptr, str_start[0], str_ptr+1);@/
701 @y
702 undump_checked_things(0, pool_ptr, str_start_macro(too_big_char), str_ptr+1-too_big_char);@/
703 @z
704
705 @x [50.1322] l.24000 - Make dumping/undumping more efficient - tfm
706 print_file_name(font_name[k],font_area[k],"");
707 @y
708 if is_native_font(k) or (font_mapping[k]<>0) then
709 begin print_file_name(font_name[k],"","");
710 print_err("Can't \dump a format with native fonts or font-mappings");
711 help3("You really, really don't want to do this.")@/
712 ("It won't work, and only confuses me.")@/
713 ("(Load them at runtime, not as part of the format file.)");
714 error;
715 end
716 else print_file_name(font_name[k],font_area[k],"");
717 @z
718
719 @x [50.1322] l.24031 - Make dumping/undumping more efficient - tfm
720 begin {Allocate the font arrays}
721 @y
722 begin {Allocate the font arrays}
723 font_mapping:=xmalloc_array(void_pointer, font_max);
724 font_layout_engine:=xmalloc_array(void_pointer, font_max);
725 font_flags:=xmalloc_array(char, font_max);
726 font_letter_space:=xmalloc_array(scaled, font_max);
727 @z
728
729 @x [50.1322] l.24031 - Make dumping/undumping more efficient - tfm
730 font_bc:=xmalloc_array(eight_bits, font_max);
731 font_ec:=xmalloc_array(eight_bits, font_max);
732 @y
733 font_bc:=xmalloc_array(UTF16_code, font_max);
734 font_ec:=xmalloc_array(UTF16_code, font_max);
735 @z
736
737 @x [50.1322] l.24031 - Make dumping/undumping more efficient - tfm
738 undump_things(font_check[null_font], font_ptr+1-null_font);
739 @y
740 for k:=null_font to font_ptr do font_mapping[k]:=0;
741 undump_things(font_check[null_font], font_ptr+1-null_font);
742 @z
743
744 @x [51.1332] l.24203 - make the main program a procedure, for eqtb hack.
745 setup_bound_var (15000)('max_strings')(max_strings);
746 @y
747 setup_bound_var (15000)('max_strings')(max_strings);
748 max_strings:=max_strings+too_big_char; {the |max_strings| value doesn't include the 64K synthetic strings}
749 @z
750
751 @x [51.1332] l.24203 - make the main program a procedure, for eqtb hack.
752 buffer:=xmalloc_array (ASCII_code, buf_size);
753 @y
754 buffer:=xmalloc_array (UnicodeScalar, buf_size);
755 @z
756
757 @x [51.1332] l.24203 - make the main program a procedure, for eqtb hack.
758 input_file:=xmalloc_array (alpha_file, max_in_open);
759 @y
760 input_file:=xmalloc_array (unicode_file, max_in_open);
761 @z
762
763 @x [51.1332] l.24203 (ca.) texarray
764 line_stack:=xmalloc_array (integer, max_in_open);
765 @y
766 line_stack:=xmalloc_array (integer, max_in_open);
767 eof_seen:=xmalloc_array (boolean, max_in_open);
768 grp_stack:=xmalloc_array (save_pointer, max_in_open);
769 if_stack:=xmalloc_array (pointer, max_in_open);
770 @z
771
772 @x [51.1333] l.24254 - Print new line before termination; switch to editor if necessary.
773 print_file_name(0, log_name, 0); print_char(".");
774 @y
775 print(log_name); print_char(".");
776 @z
777
778 @x [51.1337] l.24371 (ca.) texarray
779 trie_root:=0; trie_c[0]:=si(0); trie_ptr:=0;
780 @y
781 trie_root:=0; trie_c[0]:=si(0); trie_ptr:=0;
782 hyph_root:=0; hyph_start:=0;
783 @z
784
785 @x [51.1337] l.24371 - Allocate hyphenation tries, do char translation, MLTeX
786 {Allocate and initialize font arrays}
787 @y
788 {Allocate and initialize font arrays}
789 font_mapping:=xmalloc_array(void_pointer, font_max);
790 font_layout_engine:=xmalloc_array(void_pointer, font_max);
791 font_flags:=xmalloc_array(char, font_max);
792 font_letter_space:=xmalloc_array(scaled, font_max);
793 @z
794
795 @x [51.1337] l.24371 - Allocate hyphenation tries, do char translation, MLTeX
796 font_bc:=xmalloc_array(eight_bits, font_max);
797 font_ec:=xmalloc_array(eight_bits, font_max);
798 @y
799 font_bc:=xmalloc_array(UTF16_code, font_max);
800 font_ec:=xmalloc_array(UTF16_code, font_max);
801 @z
802
803 @x [51.1337] l.24371 - Allocate hyphenation tries, do char translation, MLTeX
804 param_base[null_font]:=-1;
805 @y
806 font_mapping[null_font]:=0;
807 param_base[null_font]:=-1;
808 @z
809
810 @x [53.1348] (do_extension) Remove unused variables
811 var k:integer; {all-purpose integers}
812 @y
813 var i,@!j,@!k:integer; {all-purpose integers}
814 @z
815
816 @x [53.1370] l.24779 - system: (write_out) \write18{foo} => system(foo).
817 print(so(str_pool[str_start[str_ptr]+d])); {N.B.: not |print_char|}
818 @y
819 print(so(str_pool[str_start_macro(str_ptr)+d])); {N.B.: not |print_char|}
820 @z
821
822 @x [53.1370] l.24779 - system: (write_out) \write18{foo} => system(foo).
823 str_pool[str_start[str_ptr]+d]:=xchr[str_pool[str_start[str_ptr]+d]];
824 if (str_pool[str_start[str_ptr]+d]=null_code)
825 @y
826 if (str_pool[str_start_macro(str_ptr)+d]=null_code)
827 @z
828
829 @x [53.1370] l.24779 - convert from UTF-16 to UTF-8 for system(3).
830 runsystem_ret := runsystem(conststringcast(addressof(
831 str_pool[str_start[str_ptr]])));
832 @y
833 if name_of_file then libc_free(name_of_file);
834 name_of_file := xmalloc(cur_length * 3 + 2);
835 k := 0;
836 for d:=0 to cur_length-1 do
837 append_to_name(str_pool[str_start_macro(str_ptr)+d]);
838 name_of_file[k+1] := 0;
839 runsystem_ret := runsystem(conststringcast(name_of_file+1));
840 @z
841
842 @x [53.1370] l.24779 - system: (write_out) \write18{foo} => system(foo).
843 pool_ptr:=str_start[str_ptr]; {erase the string}
844 @y
845 pool_ptr:=str_start_macro(str_ptr); {erase the string}
846 @z
847
848 @x [53a.1379] l.??? -etex command line switch
849 @!init if (buffer[loc]="*")and(format_ident=" (INITEX)") then
850 @y
851 @!init if (etex_p or(buffer[loc]="*"))and(format_ident=" (INITEX)") then
852 @z
853
854 @x [53a.1379] l.??? -etex command line switch
855 incr(loc); eTeX_mode:=1; {enter extended mode}
856 @y
857 if buffer[loc]="*" then incr(loc);
858 eTeX_mode:=1; {enter extended mode}
859 @z
860
861 @x [53a.1383] l.??? -etex command line switch
862 @!eTeX_mode: 0..1; {identifies compatibility and extended mode}
863 @y
864 @!eTeX_mode: 0..1; {identifies compatibility and extended mode}
865 @!etex_p: boolean; {was the -etex option specified}
866 @z
867
868 @x [53a.1391] l.??? texarray
869 @!eof_seen : array[1..max_in_open] of boolean; {has eof been seen?}
870 @y
871 @!eof_seen : ^boolean; {has eof been seen?}
872 @z
873
874 @x [53a.1506] l.??? texarray
875 @!grp_stack : array[0..max_in_open] of save_pointer; {initial |cur_boundary|}
876 @!if_stack : array[0..max_in_open] of pointer; {initial |cond_ptr|}
877 @y
878 @!grp_stack : ^save_pointer; {initial |cur_boundary|}
879 @!if_stack : ^pointer; {initial |cond_ptr|}
880 @z
881
882 @x [54.1376] l.24903 - print_csnames
883 for c := str_start[text(h)] to str_start[text(h) + 1] - 1
884 @y
885 for c := str_start_macro(text(h)) to str_start_macro(text(h) + 1) - 1
886 @z
887
888 @x [54.1376] l.24903 - Dumping/Undumping
889 @ Dumping the |xord|, |xchr|, and |xprn| arrays. We dump these always
890 in the format, so a TCX file loaded during format creation can set a
891 default for users of the format.
892
893 @<Dump |xord|, |xchr|, and |xprn|@>=
894 dump_things(xord[0], 256);
895 dump_things(xchr[0], 256);
896 dump_things(xprn[0], 256);
897
898 @ Undumping the |xord|, |xchr|, and |xprn| arrays. This code is more
899 complicated, because we want to ensure that a TCX file specified on
900 the command line will override whatever is in the format. Since the
901 tcx file has already been loaded, that implies throwing away the data
902 in the format. Also, if no |translate_filename| is given, but
903 |eight_bit_p| is set we have to make all characters printable.
904
905 @<Undump |xord|, |xchr|, and |xprn|@>=
906 if translate_filename then begin
907 for k:=0 to 255 do undump_things(dummy_xord, 1);
908 for k:=0 to 255 do undump_things(dummy_xchr, 1);
909 for k:=0 to 255 do undump_things(dummy_xprn, 1);
910 end
911 else begin
912 undump_things(xord[0], 256);
913 undump_things(xchr[0], 256);
914 undump_things(xprn[0], 256);
915 if eight_bit_p then
916 for k:=0 to 255 do
917 xprn[k]:=1;
918 end;
919
920
921 @y
922 @z
923
924 @x
925 while s>255 do {first 256 strings depend on implementation!!}
926 @y
927 while s>65535 do {first 64K strings don't really exist in the pool!}
928 @z
929
930 @x [54/web2c.1407] - scan a bgroup/egroup-delimited file name
931 stop_at_space := false; {set |stop_at_space| to false to allow spaces in file names}
932 begin_name;
933 for i:=str_start[s] to str_start[s+1]-1 do
934 dummy := more_name(str_pool[i]); {add each read character to the current file name}
935 @y
936 stop_at_space := false; {set |stop_at_space| to false to allow spaces in file names}
937 begin_name;
938 for i:=str_start_macro(s) to str_start_macro(s+1)-1 do
939 dummy := more_name(str_pool[i]); {add each read character to the current file name}
940 @z
941
942 @x
943 @!mltex_enabled_p:boolean; {enable character substitution}
944 @y
945 @!mltex_enabled_p:boolean; {enable character substitution}
946 @!native_font_type_flag:integer; {used by XeTeX font loading code to record which font technology was used}
947 @!xtx_ligature_present:boolean; {to suppress tfm font mapping of char codes from ligature nodes (already mapped)}
948 @z
949
950 @x [54/web2c.???] l.??? needed earlier
951 replacement, but always existing character |font_bc[f]|.
952 @^inner loop@>
953
954 @<Declare additional functions for ML\TeX@>=
955 function effective_char(@!err_p:boolean;
956 @y
957 replacement, but always existing character |font_bc[f]|.
958 @^inner loop@>
959
960 @<Declare \eTeX\ procedures for sc...@>=
961 function effective_char(@!err_p:boolean;
962 @z
963
964 @x
965 begin result:=c; {return |c| unless it does not exist in the font}
966 @y
967 begin if (not xtx_ligature_present) and (font_mapping[f]<>nil) then
968 c:=apply_tfm_font_mapping(font_mapping[f],c);
969 xtx_ligature_present:=false;
970 result:=c; {return |c| unless it does not exist in the font}
971 @z
972
973 @x
974 begin if not mltex_enabled_p then
975 @y
976 begin if (not xtx_ligature_present) and (font_mapping[f]<>nil) then
977 c:=apply_tfm_font_mapping(font_mapping[f],c);
978 xtx_ligature_present:=false;
979 if not mltex_enabled_p then
980 @z
981
982 @x
983 effective_char_info:=null_character;
984 exit:end;
985 @y
986 effective_char_info:=null_character;
987 exit:end;
988 @#
989 @<Declare subroutines for |new_character|@>@;
990 @z