| 1 |
% $Id: tex.ch 75108 2025-05-05 17:39:26Z karl $ |
| 2 |
% tex.ch for C compilation with web2c, derived from various other change files. |
| 3 |
% By Tim Morgan, UC Irvine ICS Department, and many others. |
| 4 |
% |
| 5 |
% Be very careful when making changes to this file, as it is used to |
| 6 |
% generate TeX, e-TeX, and pdfTeX, and most changes require similar |
| 7 |
% changes to be made to the Aleph sources. |
| 8 |
% |
| 9 |
% (05/28/86) ETM Started with TeX 2.0 |
| 10 |
% (06/03/87) ETM Brought up to TeX 2.2 |
| 11 |
% (09/26/87) ETM Brought up to TeX 2.3 |
| 12 |
% (10/01/87) ETM Brought up to TeX 2.5 |
| 13 |
% (12/21/87) ETM Brought up to TeX 2.7 |
| 14 |
% (01/14/88) ETM Brought up to TeX 2.9 |
| 15 |
% (02/20/88) PAM Revised format and module numbers |
| 16 |
% (03/01/88) ETM Eliminated some unused variables and unnecessary tests |
| 17 |
% (05/09/88) ETM Added yet another casting bug fix |
| 18 |
% (06/21/88) ETM Brought up to TeX version 2.93 |
| 19 |
% (12/11/88) ETM Brought up to TeX version 2.94 |
| 20 |
% (01/12/89) PAM Brought up to TeX version 2.95 |
| 21 |
% (02/14/89) ETM Brought up to TeX version 2.96 |
| 22 |
% (03/10/89) ETM Brought up to TeX version 2.98 |
| 23 |
% (07/06/89) ETM Brought up to TeX version 2.991 |
| 24 |
% (11/30/89) KB To version 2.992 (8-bit). |
| 25 |
% (01/10/90) SR To version 2.993. |
| 26 |
% (03/27/90) KY To version 3.0. |
| 27 |
% (more recent changes in ChangeLog) |
| 28 |
% |
| 29 |
% The TeX program is copyright (C) 1982 by D. E. Knuth. |
| 30 |
% TeX is a trademark of the American Mathematical Society. |
| 31 |
% |
| 32 |
% Includes MLTEX.CH (Version 2.2) in text format, as of Dec 17, 1995. |
| 33 |
% MLTeX is copyright (C) 1990-92 by Michael J. Ferguson; all rights reserved. |
| 34 |
% MLTeX Version 2.2 is copyright (C) 1995 by B. Raichle; all rights reserved. |
| 35 |
% |
| 36 |
% The MLTeX changes are copyrighted so that we have some chance to |
| 37 |
% forbid unauthorized copies; we explicitly authorize copying of |
| 38 |
% correct MLTeX implementations, and not of incorrect ones! |
| 39 |
% |
| 40 |
% (This means that you can use the MLTeX changes as free as you can |
| 41 |
% use TeX and its algorithm.) |
| 42 |
% |
| 43 |
% Copying of this file is authorized only if either |
| 44 |
% (1) you make absolutely no changes to your copy, including name, or |
| 45 |
% (2) if you do make changes, you name it to something other than |
| 46 |
% "mltex.ch", "char_sub.ch", or "charsub.ch". |
| 47 |
% |
| 48 |
% Except for MLTeX, the new code in this file is in the public domain. |
| 49 |
% |
| 50 |
% The part, module, and line numbers in this change file refer to |
| 51 |
% TEX.WEB 3.141592653 as of January, 2021 (published as Donald E. Knuth, |
| 52 |
% TeX: The Program, Volume B of Computers & Typesetting Jubilee Editions). |
| 53 |
|
| 54 |
@x [0.0] l.88 - WEAVE: print changes only. |
| 55 |
\def\?##1]{\hbox to 1in{\hfil##1.\ }} |
| 56 |
} |
| 57 |
@y |
| 58 |
\def\?##1]{\hbox{Changes to ##1.\ }} |
| 59 |
} |
| 60 |
\let\maybe=\iffalse |
| 61 |
@z |
| 62 |
|
| 63 |
@x [1.2] l.191 - MLTeX: add comment about banner line change |
| 64 |
November 1984]. |
| 65 |
@y |
| 66 |
November 1984]. |
| 67 |
|
| 68 |
ML\TeX{} will add new primitives changing the behaviour of \TeX. The |
| 69 |
|banner| string has to be changed. We do not change the |banner| |
| 70 |
string, but will output an additional line to make clear that this is |
| 71 |
a modified \TeX{} version. |
| 72 |
|
| 73 |
@z |
| 74 |
|
| 75 |
@x [1.2] l.193 |
| 76 |
@d banner=='This is TeX, Version 3.141592653' {printed when \TeX\ starts} |
| 77 |
@y |
| 78 |
@d TeX_banner_k=='This is TeXk, Version 3.141592653' {printed when \TeX\ starts} |
| 79 |
@d TeX_banner=='This is TeX, Version 3.141592653' {printed when \TeX\ starts} |
| 80 |
@# |
| 81 |
@d banner==TeX_banner |
| 82 |
@d banner_k==TeX_banner_k |
| 83 |
@z |
| 84 |
|
| 85 |
@x [1.4] l.244 - program header |
| 86 |
Actually the heading shown here is not quite normal: The |program| line |
| 87 |
does not mention any |output| file, because \ph\ would ask the \TeX\ user |
| 88 |
to specify a file name if |output| were specified here. |
| 89 |
@:PASCAL H}{\ph@> |
| 90 |
@^system dependencies@> |
| 91 |
@y |
| 92 |
@z |
| 93 |
|
| 94 |
@x [1.4] l.255 - labels in outer block not needed |
| 95 |
program TEX; {all file names are defined dynamically} |
| 96 |
label @<Labels in the outer block@>@/ |
| 97 |
@y |
| 98 |
program TEX; {all file names are defined dynamically} |
| 99 |
@z |
| 100 |
|
| 101 |
@x [1.6] l.279 - labels in outer block not needed |
| 102 |
@ Three labels must be declared in the main program, so we give them |
| 103 |
symbolic names. |
| 104 |
|
| 105 |
@d start_of_TEX=1 {go here when \TeX's variables are initialized} |
| 106 |
@d end_of_TEX=9998 {go here to close files and terminate gracefully} |
| 107 |
@d final_end=9999 {this label marks the ending of the program} |
| 108 |
|
| 109 |
@<Labels in the out...@>= |
| 110 |
start_of_TEX@t\hskip-2pt@>, end_of_TEX@t\hskip-2pt@>,@,final_end; |
| 111 |
{key control points} |
| 112 |
@y |
| 113 |
@ For Web2c, labels are not declared in the main program, but |
| 114 |
we still have to declare the symbolic names. |
| 115 |
|
| 116 |
@d start_of_TEX=1 {go here when \TeX's variables are initialized} |
| 117 |
@d final_end=9999 {this label marks the ending of the program} |
| 118 |
@z |
| 119 |
|
| 120 |
% Here we change these WEB symbols, which are used much as #ifdef's |
| 121 |
% are in C, into something which will get translated into actual #ifdef's. |
| 122 |
@x [1.7] l.304 - debug..gubed, stat..tats |
| 123 |
@d debug==@{ {change this to `$\\{debug}\equiv\null$' when debugging} |
| 124 |
@d gubed==@t@>@} {change this to `$\\{gubed}\equiv\null$' when debugging} |
| 125 |
@y |
| 126 |
@d debug==ifdef('TEXMF_DEBUG') |
| 127 |
@d gubed==endif('TEXMF_DEBUG') |
| 128 |
@z |
| 129 |
@x [1.7] l.309 - debug..gubed, stat..tats |
| 130 |
@d stat==@{ {change this to `$\\{stat}\equiv\null$' when gathering |
| 131 |
usage statistics} |
| 132 |
@d tats==@t@>@} {change this to `$\\{tats}\equiv\null$' when gathering |
| 133 |
usage statistics} |
| 134 |
@y |
| 135 |
@d stat==ifdef('STAT') |
| 136 |
@d tats==endif('STAT') |
| 137 |
@z |
| 138 |
|
| 139 |
@x [1.8] l.322 - Somewhat different for `init...tini'. |
| 140 |
the codewords `$|init|\ldots|tini|$'. |
| 141 |
|
| 142 |
@d init== {change this to `$\\{init}\equiv\.{@@\{}$' in the production version} |
| 143 |
@d tini== {change this to `$\\{tini}\equiv\.{@@\}}$' in the production version} |
| 144 |
@y |
| 145 |
the codewords `$|init|\ldots|tini|$' for declarations and by the codewords |
| 146 |
`$|Init|\ldots|Tini|$' for executable code. This distinction is helpful for |
| 147 |
implementations where a run-time switch differentiates between the two |
| 148 |
versions of the program. |
| 149 |
|
| 150 |
@d init==ifdef('INITEX') |
| 151 |
@d tini==endif('INITEX') |
| 152 |
@d Init==init if ini_version then begin |
| 153 |
@d Tini==end;@+tini |
| 154 |
@f Init==begin |
| 155 |
@f Tini==end |
| 156 |
@z |
| 157 |
|
| 158 |
@x [1.8] l.331 - init...tini is dynamic |
| 159 |
@!init @<Initialize table entries (done by \.{INITEX} only)@>@;@+tini |
| 160 |
@y |
| 161 |
@!Init @<Initialize table entries (done by \.{INITEX} only)@>@;@+Tini |
| 162 |
@z |
| 163 |
|
| 164 |
@x [1.11] l.389 - Compile-time constants: most removed for dynamic allocation. |
| 165 |
@<Constants...@>= |
| 166 |
@!mem_max=30000; {greatest index in \TeX's internal |mem| array; |
| 167 |
must be strictly less than |max_halfword|; |
| 168 |
must be equal to |mem_top| in \.{INITEX}, otherwise |>=mem_top|} |
| 169 |
@!mem_min=0; {smallest index in \TeX's internal |mem| array; |
| 170 |
must be |min_halfword| or more; |
| 171 |
must be equal to |mem_bot| in \.{INITEX}, otherwise |<=mem_bot|} |
| 172 |
@!buf_size=500; {maximum number of characters simultaneously present in |
| 173 |
current lines of open files and in control sequences between |
| 174 |
\.{\\csname} and \.{\\endcsname}; must not exceed |max_halfword|} |
| 175 |
@!error_line=72; {width of context lines on terminal error messages} |
| 176 |
@!half_error_line=42; {width of first lines of contexts in terminal |
| 177 |
error messages; should be between 30 and |error_line-15|} |
| 178 |
@!max_print_line=79; {width of longest text lines output; should be at least 60} |
| 179 |
@!stack_size=200; {maximum number of simultaneous input sources} |
| 180 |
@!max_in_open=6; {maximum number of input files and error insertions that |
| 181 |
can be going on simultaneously} |
| 182 |
@!font_max=75; {maximum internal font number; must not exceed |max_quarterword| |
| 183 |
and must be at most |font_base+256|} |
| 184 |
@!font_mem_size=20000; {number of words of |font_info| for all fonts} |
| 185 |
@!param_size=60; {maximum number of simultaneous macro parameters} |
| 186 |
@!nest_size=40; {maximum number of semantic levels simultaneously active} |
| 187 |
@!max_strings=3000; {maximum number of strings; must not exceed |max_halfword|} |
| 188 |
@!string_vacancies=8000; {the minimum number of characters that should be |
| 189 |
available for the user's control sequences and font names, |
| 190 |
after \TeX's own error messages are stored} |
| 191 |
@!pool_size=32000; {maximum number of characters in strings, including all |
| 192 |
error messages and help texts, and the names of all fonts and |
| 193 |
control sequences; must exceed |string_vacancies| by the total |
| 194 |
length of \TeX's own strings, which is currently about 23000} |
| 195 |
@!save_size=600; {space for saving values outside of current group; must be |
| 196 |
at most |max_halfword|} |
| 197 |
@!trie_size=8000; {space for hyphenation patterns; should be larger for |
| 198 |
\.{INITEX} than it is in production versions of \TeX} |
| 199 |
@!trie_op_size=500; {space for ``opcodes'' in the hyphenation patterns} |
| 200 |
@!dvi_buf_size=800; {size of the output buffer; must be a multiple of 8} |
| 201 |
@!file_name_size=40; {file names shouldn't be longer than this} |
| 202 |
@!pool_name='TeXformats:TEX.POOL '; |
| 203 |
{string of length |file_name_size|; tells where the string pool appears} |
| 204 |
@y |
| 205 |
@d file_name_size == maxint |
| 206 |
@d ssup_error_line = 255 |
| 207 |
@d ssup_max_strings == 2097151 |
| 208 |
{Larger values than 65536 cause the arrays to consume much more memory.} |
| 209 |
@d ssup_trie_opcode == 65535 |
| 210 |
@d ssup_trie_size == @"3FFFFF |
| 211 |
|
| 212 |
@d ssup_hyph_size == 65535 {Changing this requires changing (un)dumping!} |
| 213 |
@d iinf_hyphen_size == 610 {Must be not less than |hyph_prime|!} |
| 214 |
|
| 215 |
@d max_font_max=9000 {maximum number of internal fonts; this can be |
| 216 |
increased, but |hash_size+max_font_max| |
| 217 |
should not exceed 29000.} |
| 218 |
@d font_base=0 {smallest internal font number; must be |
| 219 |
|>= min_quarterword|; do not change this without |
| 220 |
modifying the dynamic definition of the font arrays.} |
| 221 |
|
| 222 |
|
| 223 |
@<Constants...@>= |
| 224 |
@!hash_offset=514; {smallest index in hash array, i.e., |hash_base| } |
| 225 |
{Use |hash_offset=0| for compilers which cannot decrement pointers.} |
| 226 |
@!trie_op_size=35111; {space for ``opcodes'' in the hyphenation patterns; |
| 227 |
best if relatively prime to 313, 361, and 1009.} |
| 228 |
@!neg_trie_op_size=-35111; {for lower |trie_op_hash| array bound; |
| 229 |
must be equal to |-trie_op_size|.} |
| 230 |
@!min_trie_op=0; {first possible trie op code for any language} |
| 231 |
@!max_trie_op=ssup_trie_opcode; {largest possible trie opcode for any language} |
| 232 |
@!pool_name=TEXMF_POOL_NAME; {this is configurable, for the sake of ML-\TeX} |
| 233 |
{string of length |file_name_size|; tells where the string pool appears} |
| 234 |
@!engine_name=TEXMF_ENGINE_NAME; {the name of this engine} |
| 235 |
@# |
| 236 |
@!inf_mem_bot = 0; |
| 237 |
@!sup_mem_bot = 1; |
| 238 |
|
| 239 |
@!inf_main_memory = 3000; |
| 240 |
@!sup_main_memory = 256000000; |
| 241 |
|
| 242 |
@!inf_trie_size = 8000; |
| 243 |
@!sup_trie_size = ssup_trie_size; |
| 244 |
|
| 245 |
@!inf_max_strings = 3000; |
| 246 |
@!sup_max_strings = ssup_max_strings; |
| 247 |
@!inf_strings_free = 100; |
| 248 |
@!sup_strings_free = sup_max_strings; |
| 249 |
|
| 250 |
@!inf_buf_size = 500; |
| 251 |
@!sup_buf_size = 30000000; |
| 252 |
|
| 253 |
@!inf_nest_size = 40; |
| 254 |
@!sup_nest_size = 4000; |
| 255 |
|
| 256 |
@!inf_max_in_open = 6; |
| 257 |
@!sup_max_in_open = 127; |
| 258 |
|
| 259 |
@!inf_param_size = 60; |
| 260 |
@!sup_param_size = 32767; |
| 261 |
|
| 262 |
@!inf_save_size = 600; |
| 263 |
@!sup_save_size = 30000000; |
| 264 |
|
| 265 |
@!inf_stack_size = 200; |
| 266 |
@!sup_stack_size = 30000; |
| 267 |
|
| 268 |
@!inf_dvi_buf_size = 800; |
| 269 |
@!sup_dvi_buf_size = 65536; |
| 270 |
|
| 271 |
@!inf_font_mem_size = 20000; |
| 272 |
@!sup_font_mem_size = 147483647; {|integer|-limited, so 2 could be prepended?} |
| 273 |
|
| 274 |
@!sup_font_max = max_font_max; |
| 275 |
@!inf_font_max = 50; {could be smaller, but why?} |
| 276 |
|
| 277 |
@!inf_pool_size = 32000; |
| 278 |
@!sup_pool_size = 40000000; |
| 279 |
@!inf_pool_free = 1000; |
| 280 |
@!sup_pool_free = sup_pool_size; |
| 281 |
@!inf_string_vacancies = 8000; |
| 282 |
@!sup_string_vacancies = sup_pool_size - 23000; |
| 283 |
|
| 284 |
@!sup_hash_extra = sup_max_strings; |
| 285 |
@!inf_hash_extra = 0; |
| 286 |
|
| 287 |
@!sup_hyph_size = ssup_hyph_size; |
| 288 |
@!inf_hyph_size = iinf_hyphen_size; {Must be not less than |hyph_prime|!} |
| 289 |
|
| 290 |
@!inf_expand_depth = 10; |
| 291 |
@!sup_expand_depth = 10000000; |
| 292 |
@z |
| 293 |
|
| 294 |
@x [1.12] l.441 - Constants that are WEB numeric macros. |
| 295 |
@d mem_bot=0 {smallest index in the |mem| array dumped by \.{INITEX}; |
| 296 |
must not be less than |mem_min|} |
| 297 |
@d mem_top==30000 {largest index in the |mem| array dumped by \.{INITEX}; |
| 298 |
must be substantially larger than |mem_bot| |
| 299 |
and not greater than |mem_max|} |
| 300 |
@d font_base=0 {smallest internal font number; must not be less |
| 301 |
than |min_quarterword|} |
| 302 |
@d hash_size=2100 {maximum number of control sequences; it should be at most |
| 303 |
about |(mem_max-mem_min)/10|} |
| 304 |
@d hash_prime=1777 {a prime number equal to about 85\pct! of |hash_size|} |
| 305 |
@d hyph_size=307 {another prime; the number of \.{\\hyphenation} exceptions} |
| 306 |
@y |
| 307 |
@d hash_size=15000 {maximum number of control sequences; it should be at most |
| 308 |
about |(mem_max-mem_min)/10|; see also |font_max|} |
| 309 |
@d hash_prime=8501 {a prime number equal to about 85\pct! of |hash_size|} |
| 310 |
@d hyph_prime=607 {another prime for hashing \.{\\hyphenation} exceptions; |
| 311 |
if you change this, you should also change |iinf_hyphen_size|.} |
| 312 |
@z |
| 313 |
|
| 314 |
@x [1.16] l.512 - Use C macros for `incr' and `decr'. |
| 315 |
@d incr(#) == #:=#+1 {increase a variable by unity} |
| 316 |
@d decr(#) == #:=#-1 {decrease a variable by unity} |
| 317 |
@y |
| 318 |
@z |
| 319 |
|
| 320 |
% The text_char type is used as an array index into xord. The |
| 321 |
% default type `char' produces signed integers, which are bad array |
| 322 |
% indices in C. |
| 323 |
@x [2.19] l.579 - data type text_char is 8-bit ASCII_code |
| 324 |
@d text_char == char {the data type of characters in text files} |
| 325 |
@y |
| 326 |
@d text_char == ASCII_code {the data type of characters in text files} |
| 327 |
@z |
| 328 |
|
| 329 |
@x [2.20] l.593 - printable characters |
| 330 |
@!xchr: array [ASCII_code] of text_char; |
| 331 |
{specifies conversion of output characters} |
| 332 |
@y |
| 333 |
xchr: array [ASCII_code] of text_char; |
| 334 |
{ specifies conversion of output characters } |
| 335 |
xprn: array [ASCII_code] of ASCII_code; |
| 336 |
{ non zero iff character is printable } |
| 337 |
@z |
| 338 |
|
| 339 |
@x [2.23] l.737 - Translate characters if desired, otherwise allow them all. |
| 340 |
for i:=0 to @'37 do xchr[i]:=' '; |
| 341 |
for i:=@'177 to @'377 do xchr[i]:=' '; |
| 342 |
@y |
| 343 |
{Initialize |xchr| to the identity mapping.} |
| 344 |
for i:=0 to @'37 do xchr[i]:=i; |
| 345 |
for i:=@'177 to @'377 do xchr[i]:=i; |
| 346 |
@z |
| 347 |
|
| 348 |
@x [2.24] l.749 - Don't reinitialize xord. |
| 349 |
for i:=0 to @'176 do xord[xchr[i]]:=i; |
| 350 |
@y |
| 351 |
for i:=0 to @'176 do xord[xchr[i]]:=i; |
| 352 |
{Set |xprn| for printable ASCII, unless |eight_bit_p| is set.} |
| 353 |
for i:=0 to 255 do xprn[i]:=(eight_bit_p or ((i>=" ")and(i<="~"))); |
| 354 |
|
| 355 |
{The idea for this dynamic translation comes from the patch by |
| 356 |
Libor Skarvada \.{<libor@@informatics.muni.cz>} |
| 357 |
and Petr Sojka \.{<sojka@@informatics.muni.cz>}. I didn't use any of the |
| 358 |
actual code, though, preferring a more general approach.} |
| 359 |
|
| 360 |
{This updates the |xchr|, |xord|, and |xprn| arrays from the provided |
| 361 |
|translate_filename|. See the function definition in \.{texmfmp.c} for |
| 362 |
more comments.} |
| 363 |
if translate_filename then read_tcx_file; |
| 364 |
@z |
| 365 |
|
| 366 |
% [3.26] name_of_file is no longer an array. And change the destination |
| 367 |
% type to text_char, which fixes: |
| 368 |
% |
| 369 |
% Date: 19 Sep 1994 10:38:24 +0200 |
| 370 |
% From: [email protected] (Lars Mathiesen) |
| 371 |
% When echoed to the screen and in the log, character codes |
| 372 |
% above '177 in file names are shown wrongly (typically as ^@). |
| 373 |
% |
| 374 |
@x [3.26] l.803 - name_of_file is no longer an array |
| 375 |
@!name_of_file:packed array[1..file_name_size] of char;@;@/ |
| 376 |
{on some systems this may be a \&{record} variable} |
| 377 |
@y |
| 378 |
@!name_of_file:^text_char; |
| 379 |
@z |
| 380 |
|
| 381 |
@x [3.27] l.808 - Do file opening in C. |
| 382 |
@ The \ph\ compiler with which the present version of \TeX\ was prepared has |
| 383 |
extended the rules of \PASCAL\ in a very convenient way. To open file~|f|, |
| 384 |
we can write |
| 385 |
$$\vbox{\halign{#\hfil\qquad&#\hfil\cr |
| 386 |
|reset(f,@t\\{name}@>,'/O')|&for input;\cr |
| 387 |
|rewrite(f,@t\\{name}@>,'/O')|&for output.\cr}}$$ |
| 388 |
The `\\{name}' parameter, which is of type `{\bf packed array |
| 389 |
$[\langle\\{any}\rangle]$ of \\{char}}', stands for the name of |
| 390 |
the external file that is being opened for input or output. |
| 391 |
Blank spaces that might appear in \\{name} are ignored. |
| 392 |
|
| 393 |
The `\.{/O}' parameter tells the operating system not to issue its own |
| 394 |
error messages if something goes wrong. If a file of the specified name |
| 395 |
cannot be found, or if such a file cannot be opened for some other reason |
| 396 |
(e.g., someone may already be trying to write the same file), we will have |
| 397 |
|@!erstat(f)<>0| after an unsuccessful |reset| or |rewrite|. This allows |
| 398 |
\TeX\ to undertake appropriate corrective action. |
| 399 |
@:PASCAL H}{\ph@> |
| 400 |
@^system dependencies@> |
| 401 |
|
| 402 |
\TeX's file-opening procedures return |false| if no file identified by |
| 403 |
|name_of_file| could be opened. |
| 404 |
|
| 405 |
@d reset_OK(#)==erstat(#)=0 |
| 406 |
@d rewrite_OK(#)==erstat(#)=0 |
| 407 |
|
| 408 |
@p function a_open_in(var f:alpha_file):boolean; |
| 409 |
{open a text file for input} |
| 410 |
begin reset(f,name_of_file,'/O'); a_open_in:=reset_OK(f); |
| 411 |
end; |
| 412 |
@# |
| 413 |
function a_open_out(var f:alpha_file):boolean; |
| 414 |
{open a text file for output} |
| 415 |
begin rewrite(f,name_of_file,'/O'); a_open_out:=rewrite_OK(f); |
| 416 |
end; |
| 417 |
@# |
| 418 |
function b_open_in(var f:byte_file):boolean; |
| 419 |
{open a binary file for input} |
| 420 |
begin reset(f,name_of_file,'/O'); b_open_in:=reset_OK(f); |
| 421 |
end; |
| 422 |
@# |
| 423 |
function b_open_out(var f:byte_file):boolean; |
| 424 |
{open a binary file for output} |
| 425 |
begin rewrite(f,name_of_file,'/O'); b_open_out:=rewrite_OK(f); |
| 426 |
end; |
| 427 |
@# |
| 428 |
function w_open_in(var f:word_file):boolean; |
| 429 |
{open a word file for input} |
| 430 |
begin reset(f,name_of_file,'/O'); w_open_in:=reset_OK(f); |
| 431 |
end; |
| 432 |
@# |
| 433 |
function w_open_out(var f:word_file):boolean; |
| 434 |
{open a word file for output} |
| 435 |
begin rewrite(f,name_of_file,'/O'); w_open_out:=rewrite_OK(f); |
| 436 |
end; |
| 437 |
@y |
| 438 |
@ All of the file opening functions are defined in C. |
| 439 |
@z |
| 440 |
|
| 441 |
@x [3.28] l.864 - Do file closing in C. |
| 442 |
@ Files can be closed with the \ph\ routine `|close(f)|', which |
| 443 |
@:PASCAL H}{\ph@> |
| 444 |
@^system dependencies@> |
| 445 |
should be used when all input or output with respect to |f| has been completed. |
| 446 |
This makes |f| available to be opened again, if desired; and if |f| was used for |
| 447 |
output, the |close| operation makes the corresponding external file appear |
| 448 |
on the user's area, ready to be read. |
| 449 |
|
| 450 |
These procedures should not generate error messages if a file is |
| 451 |
being closed before it has been successfully opened. |
| 452 |
|
| 453 |
@p procedure a_close(var f:alpha_file); {close a text file} |
| 454 |
begin close(f); |
| 455 |
end; |
| 456 |
@# |
| 457 |
procedure b_close(var f:byte_file); {close a binary file} |
| 458 |
begin close(f); |
| 459 |
end; |
| 460 |
@# |
| 461 |
procedure w_close(var f:word_file); {close a word file} |
| 462 |
begin close(f); |
| 463 |
end; |
| 464 |
@y |
| 465 |
@ And all the file closing routines as well. |
| 466 |
@z |
| 467 |
|
| 468 |
@x [3.30] l.903 - Array size of input buffer is determined at runtime. |
| 469 |
@!buffer:array[0..buf_size] of ASCII_code; {lines of characters being read} |
| 470 |
@y |
| 471 |
@!buffer:^ASCII_code; {lines of characters being read} |
| 472 |
@z |
| 473 |
|
| 474 |
@x [3.31] l.948 - Do `input_ln' in C. |
| 475 |
@p function input_ln(var f:alpha_file;@!bypass_eoln:boolean):boolean; |
| 476 |
{inputs the next line or returns |false|} |
| 477 |
var last_nonblank:0..buf_size; {|last| with trailing blanks removed} |
| 478 |
begin if bypass_eoln then if not eof(f) then get(f); |
| 479 |
{input the first character of the line into |f^|} |
| 480 |
last:=first; {cf.\ Matthew 19\thinspace:\thinspace30} |
| 481 |
if eof(f) then input_ln:=false |
| 482 |
else begin last_nonblank:=first; |
| 483 |
while not eoln(f) do |
| 484 |
begin if last>=max_buf_stack then |
| 485 |
begin max_buf_stack:=last+1; |
| 486 |
if max_buf_stack=buf_size then |
| 487 |
@<Report overflow of the input buffer, and abort@>; |
| 488 |
end; |
| 489 |
buffer[last]:=xord[f^]; get(f); incr(last); |
| 490 |
if buffer[last-1]<>" " then last_nonblank:=last; |
| 491 |
end; |
| 492 |
last:=last_nonblank; input_ln:=true; |
| 493 |
end; |
| 494 |
end; |
| 495 |
@y |
| 496 |
We define |input_ln| in C, for efficiency. Nevertheless we quote the module |
| 497 |
`Report overflow of the input buffer, and abort' here in order to make |
| 498 |
\.{WEAVE} happy, since part of that module is needed by e-TeX. |
| 499 |
|
| 500 |
@p @{ @<Report overflow of the input buffer, and abort@> @} |
| 501 |
@z |
| 502 |
|
| 503 |
% [3.32] `term_in' and `term_out' are standard input and output. |
| 504 |
% Declare the variables that used to be constants. |
| 505 |
@x [3.32] l.975 - `term_in' and `term_out' are standard input and output. |
| 506 |
@<Glob...@>= |
| 507 |
@!term_in:alpha_file; {the terminal as an input file} |
| 508 |
@!term_out:alpha_file; {the terminal as an output file} |
| 509 |
@y |
| 510 |
@d term_in==stdin {the terminal as an input file} |
| 511 |
@d term_out==stdout {the terminal as an output file} |
| 512 |
|
| 513 |
@<Glob...@>= |
| 514 |
@!init |
| 515 |
@!ini_version:boolean; {are we \.{INITEX}?} |
| 516 |
@!dump_option:boolean; {was the dump name option used?} |
| 517 |
@!dump_line:boolean; {was a \.{\%\AM format} line seen?} |
| 518 |
tini@/ |
| 519 |
@# |
| 520 |
@!dump_name:const_cstring; {format name for terminal display} |
| 521 |
@# |
| 522 |
@!bound_default:integer; {temporary for setup} |
| 523 |
@!bound_name:const_cstring; {temporary for setup} |
| 524 |
@# |
| 525 |
@!mem_bot:integer;{smallest index in the |mem| array dumped by \.{INITEX}; |
| 526 |
must not be less than |mem_min|} |
| 527 |
@!main_memory:integer; {total memory words allocated in initex} |
| 528 |
@!extra_mem_bot:integer; {|mem_min:=mem_bot-extra_mem_bot| except in \.{INITEX}} |
| 529 |
@!mem_min:integer; {smallest index in \TeX's internal |mem| array; |
| 530 |
must be |min_halfword| or more; |
| 531 |
must be equal to |mem_bot| in \.{INITEX}, otherwise |<=mem_bot|} |
| 532 |
@!mem_top:integer; {largest index in the |mem| array dumped by \.{INITEX}; |
| 533 |
must be substantially larger than |mem_bot|, |
| 534 |
equal to |mem_max| in \.{INITEX}, else not greater than |mem_max|} |
| 535 |
@!extra_mem_top:integer; {|mem_max:=mem_top+extra_mem_top| except in \.{INITEX}} |
| 536 |
@!mem_max:integer; {greatest index in \TeX's internal |mem| array; |
| 537 |
must be strictly less than |max_halfword|; |
| 538 |
must be equal to |mem_top| in \.{INITEX}, otherwise |>=mem_top|} |
| 539 |
@!error_line:integer; {width of context lines on terminal error messages} |
| 540 |
@!half_error_line:integer; {width of first lines of contexts in terminal |
| 541 |
error messages; should be between 30 and |error_line-15|} |
| 542 |
@!max_print_line:integer; |
| 543 |
{width of longest text lines output; should be at least 60} |
| 544 |
@!max_strings:integer; {maximum number of strings; must not exceed |max_halfword|} |
| 545 |
@!strings_free:integer; {strings available after format loaded} |
| 546 |
@!string_vacancies:integer; {the minimum number of characters that should be |
| 547 |
available for the user's control sequences and font names, |
| 548 |
after \TeX's own error messages are stored} |
| 549 |
@!pool_size:integer; {maximum number of characters in strings, including all |
| 550 |
error messages and help texts, and the names of all fonts and |
| 551 |
control sequences; must exceed |string_vacancies| by the total |
| 552 |
length of \TeX's own strings, which is currently about 23000} |
| 553 |
@!pool_free:integer;{pool space free after format loaded} |
| 554 |
@!font_mem_size:integer; {number of words of |font_info| for all fonts} |
| 555 |
@!font_max:integer; {maximum internal font number; ok to exceed |max_quarterword| |
| 556 |
and must be at most |font_base|+|max_font_max|} |
| 557 |
@!font_k:integer; {loop variable for initialization} |
| 558 |
@!hyph_size:integer; {maximum number of hyphen exceptions} |
| 559 |
@!trie_size:integer; {space for hyphenation patterns; should be larger for |
| 560 |
\.{INITEX} than it is in production versions of \TeX. 50000 is |
| 561 |
needed for English, German, and Portuguese.} |
| 562 |
@!buf_size:integer; {maximum number of characters simultaneously present in |
| 563 |
current lines of open files and in control sequences between |
| 564 |
\.{\\csname} and \.{\\endcsname}; must not exceed |max_halfword|} |
| 565 |
@!stack_size:integer; {maximum number of simultaneous input sources} |
| 566 |
@!max_in_open:integer; {maximum number of input files and error insertions that |
| 567 |
can be going on simultaneously} |
| 568 |
@!param_size:integer; {maximum number of simultaneous macro parameters} |
| 569 |
@!nest_size:integer; {maximum number of semantic levels simultaneously active} |
| 570 |
@!save_size:integer; {space for saving values outside of current group; must be |
| 571 |
at most |max_halfword|} |
| 572 |
@!dvi_buf_size:integer; {size of the output buffer; must be a multiple of 8} |
| 573 |
@!expand_depth:integer; {limits recursive calls to the |expand| procedure} |
| 574 |
@!parse_first_line_p:cinttype; {parse the first line for options} |
| 575 |
@!file_line_error_style_p:cinttype; {format messages as file:line:error} |
| 576 |
@!eight_bit_p:cinttype; {make all characters printable by default} |
| 577 |
@!halt_on_error_p:cinttype; {stop at first error} |
| 578 |
@!halting_on_error_p:boolean; {already trying to halt?} |
| 579 |
@!quoted_filename:boolean; {current filename is quoted} |
| 580 |
{Variables for source specials} |
| 581 |
@!src_specials_p : boolean;{Whether |src_specials| are enabled at all} |
| 582 |
@!insert_src_special_auto : boolean; |
| 583 |
@!insert_src_special_every_par : boolean; |
| 584 |
@!insert_src_special_every_parend : boolean; |
| 585 |
@!insert_src_special_every_cr : boolean; |
| 586 |
@!insert_src_special_every_math : boolean; |
| 587 |
@!insert_src_special_every_hbox : boolean; |
| 588 |
@!insert_src_special_every_vbox : boolean; |
| 589 |
@!insert_src_special_every_display : boolean; |
| 590 |
@z |
| 591 |
|
| 592 |
@x [3.33] l.979 - We don't need to open terminal files. |
| 593 |
@ Here is how to open the terminal files |
| 594 |
in \ph. The `\.{/I}' switch suppresses the first |get|. |
| 595 |
@:PASCAL H}{\ph@> |
| 596 |
@^system dependencies@> |
| 597 |
|
| 598 |
@d t_open_in==reset(term_in,'TTY:','/O/I') {open the terminal for text input} |
| 599 |
@d t_open_out==rewrite(term_out,'TTY:','/O') {open the terminal for text output} |
| 600 |
@y |
| 601 |
@ Here is how to open the terminal files. |t_open_out| does nothing. |
| 602 |
|t_open_in|, on the other hand, does the work of ``rescanning,'' or getting |
| 603 |
any command line arguments the user has provided. It's defined in C. |
| 604 |
|
| 605 |
@d t_open_out == {output already open for text output} |
| 606 |
@z |
| 607 |
|
| 608 |
@x [3.34] l.998 - Flushing output to terminal files. |
| 609 |
these operations can be specified in \ph: |
| 610 |
@:PASCAL H}{\ph@> |
| 611 |
@^system dependencies@> |
| 612 |
|
| 613 |
@d update_terminal == break(term_out) {empty the terminal output buffer} |
| 614 |
@d clear_terminal == break_in(term_in,true) {clear the terminal input buffer} |
| 615 |
@y |
| 616 |
these operations can be specified with {\mc UNIX}. |update_terminal| |
| 617 |
does an |fflush|. |clear_terminal| is redefined |
| 618 |
to do nothing, since the user should control the terminal. |
| 619 |
@^system dependencies@> |
| 620 |
|
| 621 |
@d update_terminal == fflush (term_out) |
| 622 |
@d clear_terminal == do_nothing |
| 623 |
@z |
| 624 |
|
| 625 |
@x [3.35] l.1034 - needed for e-TeX, but differently |
| 626 |
@<Report overflow of the input buffer, and abort@>= |
| 627 |
if format_ident=0 then |
| 628 |
begin write_ln(term_out,'Buffer size exceeded!'); goto final_end; |
| 629 |
@.Buffer size exceeded@> |
| 630 |
end |
| 631 |
else begin cur_input.loc_field:=first; cur_input.limit_field:=last-1; |
| 632 |
@y |
| 633 |
Routine is implemented in C; part of module is, however, needed for e-TeX. |
| 634 |
|
| 635 |
@<Report overflow of the input buffer, and abort@>= |
| 636 |
begin cur_input.loc_field:=first; cur_input.limit_field:=last-1; |
| 637 |
@z |
| 638 |
|
| 639 |
@x [3.37] l.1072 - |init_terminal|, reading the command line. |
| 640 |
@ The following program does the required initialization |
| 641 |
without retrieving a possible command line. |
| 642 |
It should be clear how to modify this routine to deal with command lines, |
| 643 |
if the system permits them. |
| 644 |
@^system dependencies@> |
| 645 |
|
| 646 |
@p function init_terminal:boolean; {gets the terminal input started} |
| 647 |
label exit; |
| 648 |
begin t_open_in; |
| 649 |
@y |
| 650 |
@ The following program does the required initialization. |
| 651 |
Iff anything has been specified on the command line, then |t_open_in| |
| 652 |
will return with |last > first|. |
| 653 |
@^system dependencies@> |
| 654 |
|
| 655 |
@p function init_terminal:boolean; {gets the terminal input started} |
| 656 |
label exit; |
| 657 |
begin t_open_in; |
| 658 |
if last > first then |
| 659 |
begin loc := first; |
| 660 |
while (loc < last) and (buffer[loc]=' ') do incr(loc); |
| 661 |
if loc < last then |
| 662 |
begin init_terminal := true; goto exit; |
| 663 |
end; |
| 664 |
end; |
| 665 |
@z |
| 666 |
|
| 667 |
@x [3.37] l.1085 - |init_terminal|, output missing newline. |
| 668 |
write(term_out,'! End of file on the terminal... why?'); |
| 669 |
@y |
| 670 |
write_ln(term_out,'! End of file on the terminal... why?'); |
| 671 |
@z |
| 672 |
|
| 673 |
@x [4.38] l.1144 - Array size for string pool is determined at runtime. |
| 674 |
@!pool_pointer = 0..pool_size; {for variables that point into |str_pool|} |
| 675 |
@!str_number = 0..max_strings; {for variables that point into |str_start|} |
| 676 |
@y |
| 677 |
@!pool_pointer = integer; {for variables that point into |str_pool|} |
| 678 |
@!str_number = 0..ssup_max_strings; {for variables that point into |str_start|} |
| 679 |
@z |
| 680 |
|
| 681 |
@x [4.39] l.1149 - Dynamically size pool arrays. |
| 682 |
@!str_pool:packed array[pool_pointer] of packed_ASCII_code; {the characters} |
| 683 |
@!str_start : array[str_number] of pool_pointer; {the starting pointers} |
| 684 |
@y |
| 685 |
@!str_pool: ^packed_ASCII_code; {the characters} |
| 686 |
@!str_start : ^pool_pointer; {the starting pointers} |
| 687 |
@z |
| 688 |
|
| 689 |
@x [4.47] l.1255 - string recycling |
| 690 |
@p @!init function get_strings_started:boolean; {initializes the string pool, |
| 691 |
@y |
| 692 |
@p @t\4@>@<Declare additional routines for string recycling@>@/ |
| 693 |
|
| 694 |
@!init function get_strings_started:boolean; {initializes the string pool, |
| 695 |
@z |
| 696 |
|
| 697 |
@x [4.49] l.1290 - Change documentation (probably needed in more places) |
| 698 |
would like string @'32 to be the single character @'32 instead of the |
| 699 |
@y |
| 700 |
would like string @'32 to be printed as the single character @'32 |
| 701 |
instead of the |
| 702 |
@z |
| 703 |
|
| 704 |
% [4.51] Open the pool file using a path, and can't do string |
| 705 |
% assignments directly. (`strcpy' and `strlen' work here because |
| 706 |
% `pool_name' is a constant string, and thus ends in a null and doesn't |
| 707 |
% start with a space.) |
| 708 |
@x [4.51] l.1332 - Open the pool file. |
| 709 |
name_of_file:=pool_name; {we needn't set |name_length|} |
| 710 |
if a_open_in(pool_file) then |
| 711 |
@y |
| 712 |
name_length := strlen (pool_name); |
| 713 |
name_of_file := xmalloc_array (ASCII_code, name_length + 1); |
| 714 |
strcpy (stringcast(name_of_file+1), pool_name); {copy the string} |
| 715 |
if a_open_in (pool_file, kpse_texpool_format) then |
| 716 |
@z |
| 717 |
|
| 718 |
@x [4.51] l.1340 - Make `TEX.POOL' lowercase, and change how it's read. |
| 719 |
else bad_pool('! I can''t read TEX.POOL.') |
| 720 |
@y |
| 721 |
else bad_pool('! I can''t read ', pool_name, '; bad path?') |
| 722 |
@z |
| 723 |
@x [4.52] l.1344 - Make `TEX.POOL' lowercase, and change how it's read. |
| 724 |
begin if eof(pool_file) then bad_pool('! TEX.POOL has no check sum.'); |
| 725 |
@.TEX.POOL has no check sum@> |
| 726 |
read(pool_file,m,n); {read two digits of string length} |
| 727 |
@y |
| 728 |
begin if eof(pool_file) then bad_pool('! ', pool_name, ' has no check sum.'); |
| 729 |
@.TEX.POOL has no check sum@> |
| 730 |
read(pool_file,m); read(pool_file,n); {read two digits of string length} |
| 731 |
@z |
| 732 |
@x [4.52] l.1350 - Make `TEX.POOL' lowercase, and change how it's read. |
| 733 |
bad_pool('! TEX.POOL line doesn''t begin with two digits.'); |
| 734 |
@y |
| 735 |
bad_pool('! ', pool_name, ' line doesn''t begin with two digits.'); |
| 736 |
@z |
| 737 |
@x [4.53] l.1372 - Make `TEX.POOL' lowercase, and change how it's read. |
| 738 |
bad_pool('! TEX.POOL check sum doesn''t have nine digits.'); |
| 739 |
@y |
| 740 |
bad_pool('! ', pool_name, ' check sum doesn''t have nine digits.'); |
| 741 |
@z |
| 742 |
@x [4.53] l.1378 - Make `TEX.POOL' lowercase, and change how it's read. |
| 743 |
done: if a<>@$ then bad_pool('! TEX.POOL doesn''t match; TANGLE me again.'); |
| 744 |
@y |
| 745 |
done: if a<>@$ then |
| 746 |
bad_pool('! ', pool_name, ' doesn''t match; tangle me again (or fix the path).'); |
| 747 |
@z |
| 748 |
|
| 749 |
@x [5.54] l.1440 - error_line |
| 750 |
@!trick_buf:array[0..error_line] of ASCII_code; {circular buffer for |
| 751 |
@y |
| 752 |
@!trick_buf:array[0..ssup_error_line] of ASCII_code; {circular buffer for |
| 753 |
@z |
| 754 |
|
| 755 |
@x [5.61] l.1574 - If the ``src-specials'' feature is active, change the banner. |
| 756 |
wterm(banner); |
| 757 |
@y |
| 758 |
if src_specials_p or file_line_error_style_p or parse_first_line_p then |
| 759 |
wterm(banner_k) |
| 760 |
else |
| 761 |
wterm(banner); |
| 762 |
@z |
| 763 |
|
| 764 |
@x [5.61] l.1575 - Print rest of banner. |
| 765 |
if format_ident=0 then wterm_ln(' (no format preloaded)') |
| 766 |
else begin slow_print(format_ident); print_ln; |
| 767 |
end; |
| 768 |
@y |
| 769 |
wterm(version_string); |
| 770 |
if format_ident=0 then wterm_ln(' (preloaded format=',dump_name,')') |
| 771 |
else begin slow_print(format_ident); print_ln; |
| 772 |
end; |
| 773 |
if shellenabledp then begin |
| 774 |
wterm(' '); |
| 775 |
if restrictedshell then begin |
| 776 |
wterm('restricted '); |
| 777 |
end; |
| 778 |
wterm_ln('\write18 enabled.'); |
| 779 |
end; |
| 780 |
if src_specials_p then begin |
| 781 |
wterm_ln(' Source specials enabled.') |
| 782 |
end; |
| 783 |
if translate_filename then begin |
| 784 |
wterm(' ('); |
| 785 |
fputs(translate_filename, stdout); |
| 786 |
wterm_ln(')'); |
| 787 |
end; |
| 788 |
@z |
| 789 |
|
| 790 |
% Original report: https://tug.org/pipermail/tex-k/2021-July/003630.html |
| 791 |
@x [5.71] l.1713 - term_input: set limit when fatal_error |
| 792 |
if not input_ln(term_in,true) then fatal_error("End of file on the terminal!"); |
| 793 |
@y |
| 794 |
if not input_ln(term_in,true) then begin |
| 795 |
limit:=0; fatal_error("End of file on the terminal!"); end; |
| 796 |
@z |
| 797 |
|
| 798 |
@x [6.73] l.1750 - Add unspecified_mode. |
| 799 |
@d error_stop_mode=3 {stops at every opportunity to interact} |
| 800 |
@y |
| 801 |
@d error_stop_mode=3 {stops at every opportunity to interact} |
| 802 |
@d unspecified_mode=4 {extra value for command-line switch} |
| 803 |
@z |
| 804 |
|
| 805 |
@x [6.73] l.1752 - file:line:error style error messages. |
| 806 |
print_nl("! "); print(#); |
| 807 |
@y |
| 808 |
if file_line_error_style_p then print_file_line |
| 809 |
else print_nl("! "); |
| 810 |
print(#); |
| 811 |
@z |
| 812 |
|
| 813 |
|
| 814 |
@x [6.73] l.1756 - Add interaction_option. |
| 815 |
@!interaction:batch_mode..error_stop_mode; {current level of interaction} |
| 816 |
@y |
| 817 |
@!interaction:batch_mode..error_stop_mode; {current level of interaction} |
| 818 |
@!interaction_option:batch_mode..unspecified_mode; {set from command line} |
| 819 |
@z |
| 820 |
|
| 821 |
@x [6.74] l.1758 - Allow override by command line switch. |
| 822 |
@ @<Set init...@>=interaction:=error_stop_mode; |
| 823 |
@y |
| 824 |
@ @<Set init...@>=if interaction_option=unspecified_mode then |
| 825 |
interaction:=error_stop_mode |
| 826 |
else |
| 827 |
interaction:=interaction_option; |
| 828 |
@z |
| 829 |
|
| 830 |
% [6.81] Eliminate nonlocal goto, since C doesn't have them. |
| 831 |
% Plus, it's nicer just to do an exit with the appropriate status code |
| 832 |
% under Unix. We call it `uexit' because there's a WEB symbol called |
| 833 |
% `exit' already. We use a C macro to change `uexit' back to `exit'. |
| 834 |
@x [6.81] l.1860 - Eliminate nonlocal goto, since C doesn't have them. |
| 835 |
@ The |jump_out| procedure just cuts across all active procedure levels and |
| 836 |
goes to |end_of_TEX|. This is the only nontrivial |@!goto| statement in the |
| 837 |
whole program. It is used when there is no recovery from a particular error. |
| 838 |
|
| 839 |
Some \PASCAL\ compilers do not implement non-local |goto| statements. |
| 840 |
@^system dependencies@> |
| 841 |
In such cases the body of |jump_out| should simply be |
| 842 |
`|close_files_and_terminate|;\thinspace' followed by a call on some system |
| 843 |
procedure that quietly terminates the program. |
| 844 |
|
| 845 |
@<Error hand...@>= |
| 846 |
procedure jump_out; |
| 847 |
begin goto end_of_TEX; |
| 848 |
end; |
| 849 |
@y |
| 850 |
@ The |jump_out| procedure just cuts across all active procedure levels. |
| 851 |
The body of |jump_out| simply calls |
| 852 |
`|close_files_and_terminate|;\thinspace' followed by a call on some system |
| 853 |
procedure that quietly terminates the program. |
| 854 |
@^system dependencies@> |
| 855 |
|
| 856 |
@f noreturn==procedure |
| 857 |
|
| 858 |
@d do_final_end==begin |
| 859 |
update_terminal; |
| 860 |
ready_already:=0; |
| 861 |
if (history <> spotless) and (history <> warning_issued) then |
| 862 |
uexit(1) |
| 863 |
else |
| 864 |
uexit(0); |
| 865 |
end |
| 866 |
|
| 867 |
@<Error hand...@>= |
| 868 |
noreturn procedure jump_out; |
| 869 |
begin |
| 870 |
close_files_and_terminate; |
| 871 |
do_final_end; |
| 872 |
end; |
| 873 |
@z |
| 874 |
|
| 875 |
@x [6.82] l.1884 - halt on error? |
| 876 |
print_char("."); show_context; |
| 877 |
@y |
| 878 |
print_char("."); show_context; |
| 879 |
if (halt_on_error_p) then begin |
| 880 |
{If |close_files_and_terminate| generates an error, we'll end up back |
| 881 |
here; just give up in that case. If files are truncated, too bad.} |
| 882 |
if (halting_on_error_p) then do_final_end; {quit immediately} |
| 883 |
halting_on_error_p:=true; |
| 884 |
|
| 885 |
{This module is executed at the end of the |error| procedure in |
| 886 |
\.{tex.web}, but we'll never get there when |halt_on_error_p|, so the |
| 887 |
error help shouldn't get duplicated. It's potentially useful to see, |
| 888 |
especially if \.{\\errhelp} is being used. See thread at: |
| 889 |
\.{https://tug.org/pipermail/tex-live/2024-July/050741.html}.} |
| 890 |
@<Put help message on the transcript file@>; |
| 891 |
|
| 892 |
{Proceed with normal exit.} |
| 893 |
history:=fatal_error_stop; |
| 894 |
jump_out; |
| 895 |
end; |
| 896 |
@z |
| 897 |
|
| 898 |
@x [6.84] l.1908 - Implement the switch-to-editor option. |
| 899 |
line ready to be edited. But such an extension requires some system |
| 900 |
wizardry, so the present implementation simply types out the name of the |
| 901 |
file that should be |
| 902 |
edited and the relevant line number. |
| 903 |
@^system dependencies@> |
| 904 |
|
| 905 |
There is a secret `\.D' option available when the debugging routines haven't |
| 906 |
been commented~out. |
| 907 |
@^debugging@> |
| 908 |
@y |
| 909 |
line ready to be edited. |
| 910 |
We do this by calling the external procedure |call_edit| with a pointer to |
| 911 |
the filename, its length, and the line number. |
| 912 |
However, here we just set up the variables that will be used as arguments, |
| 913 |
since we don't want to do the switch-to-editor until after TeX has closed |
| 914 |
its files. |
| 915 |
@^system dependencies@> |
| 916 |
|
| 917 |
There is a secret `\.D' option available when the debugging routines haven't |
| 918 |
been commented~out. |
| 919 |
@^debugging@> |
| 920 |
@d edit_file==input_stack[base_ptr] |
| 921 |
@z |
| 922 |
|
| 923 |
@x [6.84] l.1923 - Implement the switch-to-editor option. |
| 924 |
"E": if base_ptr>0 then if input_stack[base_ptr].name_field>=256 then |
| 925 |
begin print_nl("You want to edit file "); |
| 926 |
@.You want to edit file x@> |
| 927 |
slow_print(input_stack[base_ptr].name_field); |
| 928 |
print(" at line "); print_int(line); |
| 929 |
interaction:=scroll_mode; jump_out; |
| 930 |
@y |
| 931 |
"E": if base_ptr>0 then if input_stack[base_ptr].name_field>=256 then |
| 932 |
begin edit_name_start:=str_start[edit_file.name_field]; |
| 933 |
edit_name_length:=str_start[edit_file.name_field+1] - |
| 934 |
str_start[edit_file.name_field]; |
| 935 |
edit_line:=line; |
| 936 |
jump_out; |
| 937 |
@z |
| 938 |
|
| 939 |
@x [6.93] l.2062 - Declare fatal_error as noreturn. |
| 940 |
procedure fatal_error(@!s:str_number); {prints |s|, and that's it} |
| 941 |
@y |
| 942 |
noreturn procedure fatal_error(@!s:str_number); {prints |s|, and that's it} |
| 943 |
@z |
| 944 |
|
| 945 |
@x [6.94] l.2071 - Declare overflow as noreturn. |
| 946 |
procedure overflow(@!s:str_number;@!n:integer); {stop due to finiteness} |
| 947 |
@y |
| 948 |
noreturn procedure overflow(@!s:str_number;@!n:integer); {stop due to finiteness} |
| 949 |
@z |
| 950 |
|
| 951 |
@x [6.95] l.2090 - Declare confusion as noreturn. |
| 952 |
procedure confusion(@!s:str_number); |
| 953 |
@y |
| 954 |
noreturn procedure confusion(@!s:str_number); |
| 955 |
@z |
| 956 |
|
| 957 |
% [7.104] `remainder' is a library routine on some systems, so change |
| 958 |
% its name to avoid conflicts. |
| 959 |
@x [7.104] l.2248 - avoid conflict with libc remainder(), save_arith_error |
| 960 |
|remainder|, holds the remainder after a division. |
| 961 |
|
| 962 |
@<Glob...@>= |
| 963 |
@y |
| 964 |
|remainder|, holds the remainder after a division. For Web2C, we rename |
| 965 |
it to |tex_remainder| to avoid conflicts with a system library routine |
| 966 |
named |remainder|. |
| 967 |
|
| 968 |
Also, we define a new variable |save_arith_error| for when we want to |
| 969 |
save and restore |arith_error|, down below. |
| 970 |
|
| 971 |
@d remainder==tex_remainder |
| 972 |
|
| 973 |
@<Glob...@>= |
| 974 |
@!save_arith_error:boolean; |
| 975 |
@z |
| 976 |
|
| 977 |
@x [7.109] l.2373 - Define glue_ratio in C. |
| 978 |
@!glue_ratio=real; {one-word representation of a glue expansion factor} |
| 979 |
@y |
| 980 |
@z |
| 981 |
|
| 982 |
% [8.110] Make it easy to change constants. Do not increase |
| 983 |
% max_quarterword without changing the memoryword structure in `texmfmem.h'. |
| 984 |
@x [8.110] l.2428 - increase |max_halfword| |
| 985 |
@d min_halfword==0 {smallest allowable value in a |halfword|} |
| 986 |
@d max_halfword==65535 {largest allowable value in a |halfword|} |
| 987 |
@y |
| 988 |
@d min_halfword==-@"FFFFFFF {smallest allowable value in a |halfword|} |
| 989 |
@d max_halfword==@"FFFFFFF {largest allowable value in a |halfword|} |
| 990 |
@z |
| 991 |
|
| 992 |
@x [8.111] l.2441 - min_halfword and max_halfword |
| 993 |
if (mem_min<min_halfword)or(mem_max>=max_halfword)or@| |
| 994 |
(mem_bot-mem_min>max_halfword+1) then bad:=14; |
| 995 |
@y |
| 996 |
if (mem_bot-sup_main_memory<min_halfword)or@| |
| 997 |
(mem_top+sup_main_memory>=max_halfword) then bad:=14; |
| 998 |
@z |
| 999 |
|
| 1000 |
@x [8.111] l.2443 - max_font_max |
| 1001 |
if (font_base<min_quarterword)or(font_max>max_quarterword) then bad:=15; |
| 1002 |
if font_max>font_base+256 then bad:=16; |
| 1003 |
@y |
| 1004 |
if (max_font_max<min_halfword)or(max_font_max>max_halfword) then bad:=15; |
| 1005 |
if font_max>font_base+max_font_max then bad:=16; |
| 1006 |
@z |
| 1007 |
|
| 1008 |
@x [8.112] l.2456 - Efficiency. |
| 1009 |
macros are simplified in the obvious way when |min_quarterword=0|. |
| 1010 |
@^inner loop@>@^system dependencies@> |
| 1011 |
|
| 1012 |
@d qi(#)==#+min_quarterword |
| 1013 |
{to put an |eight_bits| item into a quarterword} |
| 1014 |
@d qo(#)==#-min_quarterword |
| 1015 |
{to take an |eight_bits| item out of a quarterword} |
| 1016 |
@d hi(#)==#+min_halfword |
| 1017 |
{to put a sixteen-bit item into a halfword} |
| 1018 |
@d ho(#)==#-min_halfword |
| 1019 |
{to take a sixteen-bit item from a halfword} |
| 1020 |
@y |
| 1021 |
macros are simplified in the obvious way when |min_quarterword=0|. |
| 1022 |
So they have been simplified here in the obvious way. |
| 1023 |
@^inner loop@>@^system dependencies@> |
| 1024 |
|
| 1025 |
The \.{WEB} source for \TeX\ defines |hi(#)==#+min_halfword| which can be |
| 1026 |
simplified when |min_halfword=0|. The Web2C implementation of \TeX\ can use |
| 1027 |
|hi(#)==#| together with |min_halfword<0| as long as |max_halfword| is |
| 1028 |
sufficiently large. |
| 1029 |
|
| 1030 |
@d qi(#)==# {to put an |eight_bits| item into a quarterword} |
| 1031 |
@d qo(#)==# {to take an |eight_bits| item from a quarterword} |
| 1032 |
@d hi(#)==# {to put a sixteen-bit item into a halfword} |
| 1033 |
@d ho(#)==# {to take a sixteen-bit item from a halfword} |
| 1034 |
@z |
| 1035 |
|
| 1036 |
% [8.113] We've put the memory structure into the include file |
| 1037 |
% `texmf.h', since it's too hard to translate automatically. |
| 1038 |
@x [8.113] l.2474 - data structures for main memory |
| 1039 |
@!quarterword = min_quarterword..max_quarterword; {1/4 of a word} |
| 1040 |
@!halfword=min_halfword..max_halfword; {1/2 of a word} |
| 1041 |
@!two_choices = 1..2; {used when there are two variants in a record} |
| 1042 |
@!four_choices = 1..4; {used when there are four variants in a record} |
| 1043 |
@!two_halves = packed record@;@/ |
| 1044 |
@!rh:halfword; |
| 1045 |
case two_choices of |
| 1046 |
1: (@!lh:halfword); |
| 1047 |
2: (@!b0:quarterword; @!b1:quarterword); |
| 1048 |
end; |
| 1049 |
@!four_quarters = packed record@;@/ |
| 1050 |
@!b0:quarterword; |
| 1051 |
@!b1:quarterword; |
| 1052 |
@!b2:quarterword; |
| 1053 |
@!b3:quarterword; |
| 1054 |
end; |
| 1055 |
@!memory_word = record@;@/ |
| 1056 |
case four_choices of |
| 1057 |
1: (@!int:integer); |
| 1058 |
2: (@!gr:glue_ratio); |
| 1059 |
3: (@!hh:two_halves); |
| 1060 |
4: (@!qqqq:four_quarters); |
| 1061 |
end; |
| 1062 |
@y |
| 1063 |
@!quarterword = min_quarterword..max_quarterword; |
| 1064 |
@!halfword = min_halfword..max_halfword; |
| 1065 |
@!two_choices = 1..2; {used when there are two variants in a record} |
| 1066 |
@!four_choices = 1..4; {used when there are four variants in a record} |
| 1067 |
@=#include "texmfmem.h";@> |
| 1068 |
@z |
| 1069 |
|
| 1070 |
% [9.116] Change `mem' to `zmem', so we can define mem to be a register |
| 1071 |
% pointer to the memory array for speed. |
| 1072 |
@x [9.116] l.2566 - definition of main memory array |
| 1073 |
@!mem : array[mem_min..mem_max] of memory_word; {the big dynamic storage area} |
| 1074 |
@y |
| 1075 |
@!yzmem : ^memory_word; {the big dynamic storage area} |
| 1076 |
@!zmem : ^memory_word; {the big dynamic storage area} |
| 1077 |
@z |
| 1078 |
|
| 1079 |
@x [10.144] l.3027 - font numbers can be >255 now. |
| 1080 |
@p function new_ligature(@!f,@!c:quarterword; @!q:pointer):pointer; |
| 1081 |
@y |
| 1082 |
@p function new_ligature(@!f:internal_font_number; @!c:quarterword; |
| 1083 |
@!q:pointer):pointer; |
| 1084 |
@z |
| 1085 |
|
| 1086 |
% [11.165] Fix the word `free' so that it doesn't conflict with the |
| 1087 |
% standard C library routine of the same name. |
| 1088 |
@x [11.165] l.3385 - avoid conflict with lib function free() |
| 1089 |
are debugging.) |
| 1090 |
@y |
| 1091 |
are debugging.) |
| 1092 |
|
| 1093 |
@d free==free_arr |
| 1094 |
@z |
| 1095 |
|
| 1096 |
@x [11.165] l.3388 - dummy |free| and |was_free| arrays |
| 1097 |
@!debug @!free: packed array [mem_min..mem_max] of boolean; {free cells} |
| 1098 |
@t\hskip10pt@>@!was_free: packed array [mem_min..mem_max] of boolean; |
| 1099 |
@y |
| 1100 |
{The debug memory arrays have not been mallocated yet.} |
| 1101 |
@!debug @!free: packed array [0..9] of boolean; {free cells} |
| 1102 |
@t\hskip10pt@>@!was_free: packed array [0..9] of boolean; |
| 1103 |
@z |
| 1104 |
|
| 1105 |
@x [12.174] l.3547 - Eliminate unsigned comparisons to zero. |
| 1106 |
begin if (font(p)<font_base)or(font(p)>font_max) then |
| 1107 |
@y |
| 1108 |
begin if (font(p)>font_max) then |
| 1109 |
@z |
| 1110 |
|
| 1111 |
@x [12.176] l.3584 - Eliminate unsigned comparisons to zero. |
| 1112 |
@p procedure print_font_and_char(@!p:integer); {prints |char_node| data} |
| 1113 |
begin if p>mem_end then print_esc("CLOBBERED.") |
| 1114 |
else begin if (font(p)<font_base)or(font(p)>font_max) then print_char("*") |
| 1115 |
@y |
| 1116 |
@p procedure print_font_and_char(@!p:integer); {prints |char_node| data} |
| 1117 |
begin if p>mem_end then print_esc("CLOBBERED.") |
| 1118 |
else begin if (font(p)>font_max) then print_char("*") |
| 1119 |
@z |
| 1120 |
|
| 1121 |
@x [12.186] l.3768 - Don't worry about strange floating point values. |
| 1122 |
if abs(mem[p+glue_offset].int)<@'4000000 then print("?.?") |
| 1123 |
else if abs(g)>float_constant(20000) then |
| 1124 |
@y |
| 1125 |
{ The Unix |pc| folks removed this restriction with a remark that |
| 1126 |
invalid bit patterns were vanishingly improbable, so we follow |
| 1127 |
their example without really understanding it. |
| 1128 |
|if abs(mem[p+glue_offset].int)<@'4000000 then print('?.?')| |
| 1129 |
|else| } |
| 1130 |
if fabs(g)>float_constant(20000) then |
| 1131 |
@z |
| 1132 |
|
| 1133 |
|
| 1134 |
@x [15.209] l.4186 - MLTeX: \charsubdef primitive |
| 1135 |
@d shorthand_def=95 {code definition ( \.{\\chardef}, \.{\\countdef}, etc.~)} |
| 1136 |
@y |
| 1137 |
@d shorthand_def=95 {code definition ( \.{\\chardef}, \.{\\countdef}, etc.~)} |
| 1138 |
{or \.{\\charsubdef}} |
| 1139 |
@z |
| 1140 |
|
| 1141 |
% i18n fix: messages printed by print_mode in [16.211] and [46.1049] |
| 1142 |
% can not be translated. For example, messages printed by |print_mode| |
| 1143 |
% from [16.211] use different word order and [46.1049] use different |
| 1144 |
% word order and words are declined. |
| 1145 |
@x [16.211] l.4259 |
| 1146 |
begin if m>0 then |
| 1147 |
case m div (max_command+1) of |
| 1148 |
0:print("vertical"); |
| 1149 |
1:print("horizontal"); |
| 1150 |
2:print("display math"); |
| 1151 |
end |
| 1152 |
else if m=0 then print("no") |
| 1153 |
else case (-m) div (max_command+1) of |
| 1154 |
0:print("internal vertical"); |
| 1155 |
1:print("restricted horizontal"); |
| 1156 |
2:print("math"); |
| 1157 |
end; |
| 1158 |
print(" mode"); |
| 1159 |
end; |
| 1160 |
@y |
| 1161 |
begin if m>0 then |
| 1162 |
case m div (max_command+1) of |
| 1163 |
0:print("vertical mode"); |
| 1164 |
1:print("horizontal mode"); |
| 1165 |
2:print("display math mode"); |
| 1166 |
end |
| 1167 |
else if m=0 then print("no mode") |
| 1168 |
else case (-m) div (max_command+1) of |
| 1169 |
0:print("internal vertical mode"); |
| 1170 |
1:print("restricted horizontal mode"); |
| 1171 |
2:print("math mode"); |
| 1172 |
end; |
| 1173 |
end; |
| 1174 |
|
| 1175 |
procedure print_in_mode(@!m:integer); {prints the mode represented by |m|} |
| 1176 |
begin if m>0 then |
| 1177 |
case m div (max_command+1) of |
| 1178 |
0:print("' in vertical mode"); |
| 1179 |
1:print("' in horizontal mode"); |
| 1180 |
2:print("' in display math mode"); |
| 1181 |
end |
| 1182 |
else if m=0 then print("' in no mode") |
| 1183 |
else case (-m) div (max_command+1) of |
| 1184 |
0:print("' in internal vertical mode"); |
| 1185 |
1:print("' in restricted horizontal mode"); |
| 1186 |
2:print("' in math mode"); |
| 1187 |
end; |
| 1188 |
end; |
| 1189 |
@z |
| 1190 |
|
| 1191 |
@x [16.213] l.4342 - texarray |
| 1192 |
@!nest:array[0..nest_size] of list_state_record; |
| 1193 |
@y |
| 1194 |
@!nest:^list_state_record; |
| 1195 |
@z |
| 1196 |
|
| 1197 |
@x [16.215] l.4365 - remove mem[] reference from initialize. |
| 1198 |
prev_graf:=0; shown_mode:=0; |
| 1199 |
@<Start a new current page@>; |
| 1200 |
@y |
| 1201 |
prev_graf:=0; shown_mode:=0; |
| 1202 |
@/{The following piece of code is a copy of module 991:} |
| 1203 |
page_contents:=empty; page_tail:=page_head; {|link(page_head):=null;|}@/ |
| 1204 |
last_glue:=max_halfword; last_penalty:=0; last_kern:=0; |
| 1205 |
page_depth:=0; page_max_depth:=0; |
| 1206 |
@z |
| 1207 |
|
| 1208 |
@x [16.219] l.4430 - i18n fix |
| 1209 |
print_int(nest[p].pg_field); print(" line"); |
| 1210 |
if nest[p].pg_field<>1 then print_char("s"); |
| 1211 |
@y |
| 1212 |
print_int(nest[p].pg_field); |
| 1213 |
if nest[p].pg_field<>1 then print(" lines") |
| 1214 |
else print(" line"); |
| 1215 |
@z |
| 1216 |
|
| 1217 |
@x [17.220] l.4469 - MLTeX: char_sub_code_base |
| 1218 |
paragraph shape. |
| 1219 |
@y |
| 1220 |
paragraph shape. |
| 1221 |
Additionally region~4 contains the table with ML\TeX's character |
| 1222 |
substitution definitions. |
| 1223 |
@z |
| 1224 |
|
| 1225 |
@x [17.222] l.4543 - frozen_special, for source specials. |
| 1226 |
@d frozen_null_font=frozen_control_sequence+10 |
| 1227 |
@y |
| 1228 |
@d frozen_special=frozen_control_sequence+10 |
| 1229 |
{permanent `\.{\\special}'} |
| 1230 |
@d frozen_null_font=frozen_control_sequence+11 |
| 1231 |
@z |
| 1232 |
|
| 1233 |
@x [17.222] l.4547 - max_font_max |
| 1234 |
@d undefined_control_sequence=frozen_null_font+257 {dummy location} |
| 1235 |
@y |
| 1236 |
@d undefined_control_sequence=frozen_null_font+max_font_max+1 {dummy location} |
| 1237 |
@z |
| 1238 |
|
| 1239 |
@x [17.222] l.4554 - hash_extra |
| 1240 |
for k:=active_base to undefined_control_sequence-1 do |
| 1241 |
eqtb[k]:=eqtb[undefined_control_sequence]; |
| 1242 |
@y |
| 1243 |
for k:=active_base to eqtb_top do |
| 1244 |
eqtb[k]:=eqtb[undefined_control_sequence]; |
| 1245 |
@z |
| 1246 |
|
| 1247 |
@x [17.230] l.4752 - MLTeX: char_sub_code_base |
| 1248 |
@d int_base=math_code_base+256 {beginning of region 5} |
| 1249 |
@y |
| 1250 |
@d char_sub_code_base=math_code_base+256 {table of character substitutions} |
| 1251 |
@d int_base=char_sub_code_base+256 {beginning of region 5} |
| 1252 |
@z |
| 1253 |
|
| 1254 |
@x [17.230] l.4773 - MLTeX: char_sub_code_base |
| 1255 |
{Note: |math_code(c)| is the true math code plus |min_halfword|} |
| 1256 |
@y |
| 1257 |
{Note: |math_code(c)| is the true math code plus |min_halfword|} |
| 1258 |
@d char_sub_code(#)==equiv(char_sub_code_base+#) |
| 1259 |
{Note: |char_sub_code(c)| is the true substitution info plus |min_halfword|} |
| 1260 |
@z |
| 1261 |
|
| 1262 |
% MLTeX: \charsubdefmax and \tracingcharsubdef |
| 1263 |
@x [17.236] l.4975 |
| 1264 |
@d int_pars=55 {total number of integer parameters} |
| 1265 |
@y |
| 1266 |
@d tex_int_pars=55 {total number of \TeX's integer parameters} |
| 1267 |
@# |
| 1268 |
@d web2c_int_base=tex_int_pars {base for web2c's integer parameters} |
| 1269 |
@d char_sub_def_min_code=web2c_int_base {smallest value in the charsubdef list} |
| 1270 |
@d char_sub_def_max_code=web2c_int_base+1 {largest value in the charsubdef list} |
| 1271 |
@d tracing_char_sub_def_code=web2c_int_base+2 {traces changes to a charsubdef def} |
| 1272 |
@d web2c_int_pars=web2c_int_base+3 {total number of web2c's integer parameters} |
| 1273 |
@# |
| 1274 |
@d int_pars=web2c_int_pars {total number of integer parameters} |
| 1275 |
@z |
| 1276 |
|
| 1277 |
% MLTeX: \charsubdefmax and \tracingcharsubdef |
| 1278 |
@x [17.236] l.5037 |
| 1279 |
@d error_context_lines==int_par(error_context_lines_code) |
| 1280 |
@y |
| 1281 |
@d error_context_lines==int_par(error_context_lines_code) |
| 1282 |
@# |
| 1283 |
@d char_sub_def_min==int_par(char_sub_def_min_code) |
| 1284 |
@d char_sub_def_max==int_par(char_sub_def_max_code) |
| 1285 |
@d tracing_char_sub_def==int_par(tracing_char_sub_def_code) |
| 1286 |
@z |
| 1287 |
|
| 1288 |
% MLTeX: \charsubdefmax and \tracingcharsubdef |
| 1289 |
@x [17.237] l.5101 |
| 1290 |
error_context_lines_code:print_esc("errorcontextlines"); |
| 1291 |
@y |
| 1292 |
error_context_lines_code:print_esc("errorcontextlines"); |
| 1293 |
char_sub_def_min_code:print_esc("charsubdefmin"); |
| 1294 |
char_sub_def_max_code:print_esc("charsubdefmax"); |
| 1295 |
tracing_char_sub_def_code:print_esc("tracingcharsubdef"); |
| 1296 |
@z |
| 1297 |
|
| 1298 |
% MLTeX: \charsubdefmax and \tracingcharsubdef |
| 1299 |
@x [17.238] l.5221 |
| 1300 |
@!@:error_context_lines_}{\.{\\errorcontextlines} primitive@> |
| 1301 |
@y |
| 1302 |
@!@:error_context_lines_}{\.{\\errorcontextlines} primitive@> |
| 1303 |
if mltex_p then |
| 1304 |
begin mltex_enabled_p:=true; {enable character substitution} |
| 1305 |
if false then {remove the if-clause to enable \.{\\charsubdefmin}} |
| 1306 |
primitive("charsubdefmin",assign_int,int_base+char_sub_def_min_code);@/ |
| 1307 |
@!@:char_sub_def_min_}{\.{\\charsubdefmin} primitive@> |
| 1308 |
primitive("charsubdefmax",assign_int,int_base+char_sub_def_max_code);@/ |
| 1309 |
@!@:char_sub_def_max_}{\.{\\charsubdefmax} primitive@> |
| 1310 |
primitive("tracingcharsubdef",assign_int,int_base+tracing_char_sub_def_code);@/ |
| 1311 |
@!@:tracing_char_sub_def_}{\.{\\tracingcharsubdef} primitive@> |
| 1312 |
end; |
| 1313 |
@z |
| 1314 |
|
| 1315 |
@x [17.240] l.5234 - MLTeX: \charsubdefmax and \tracingcharsubdef |
| 1316 |
for k:=int_base to del_code_base-1 do eqtb[k].int:=0; |
| 1317 |
@y |
| 1318 |
for k:=int_base to del_code_base-1 do eqtb[k].int:=0; |
| 1319 |
char_sub_def_min:=256; char_sub_def_max:=-1; |
| 1320 |
{allow \.{\\charsubdef} for char 0}@/ |
| 1321 |
{|tracing_char_sub_def:=0| is already done}@/ |
| 1322 |
@z |
| 1323 |
|
| 1324 |
@x [17.241] l.5240 - Do `fix_date_and_time' in C. |
| 1325 |
@ The following procedure, which is called just before \TeX\ initializes its |
| 1326 |
input and output, establishes the initial values of the date and time. |
| 1327 |
@^system dependencies@> |
| 1328 |
Since standard \PASCAL\ cannot provide such information, something special |
| 1329 |
is needed. The program here simply assumes that suitable values appear in |
| 1330 |
the global variables \\{sys\_time}, \\{sys\_day}, \\{sys\_month}, and |
| 1331 |
\\{sys\_year} (which are initialized to noon on 4 July 1776, |
| 1332 |
in case the implementor is careless). |
| 1333 |
|
| 1334 |
@p procedure fix_date_and_time; |
| 1335 |
begin sys_time:=12*60; |
| 1336 |
sys_day:=4; sys_month:=7; sys_year:=1776; {self-evident truths} |
| 1337 |
@y |
| 1338 |
@ The following procedure, which is called just before \TeX\ initializes |
| 1339 |
its input and output, establishes the initial values of the date and |
| 1340 |
time. It calls a |date_and_time| C macro (a.k.a.\ |dateandtime|), which |
| 1341 |
calls the C function |get_date_and_time|, passing it the addresses of |
| 1342 |
|sys_time|, etc., so they can be set by the routine. |get_date_and_time| |
| 1343 |
also sets up interrupt catching if that is conditionally compiled in the |
| 1344 |
C code. |
| 1345 |
|
| 1346 |
We have to initialize the |sys_| variables because that is what gets |
| 1347 |
output on the first line of the log file. (New in 2021.) |
| 1348 |
@^system dependencies@> |
| 1349 |
|
| 1350 |
@p procedure fix_date_and_time; |
| 1351 |
begin date_and_time(sys_time,sys_day,sys_month,sys_year); |
| 1352 |
@z |
| 1353 |
|
| 1354 |
@x [17.252] l.5447 - hash_extra |
| 1355 |
else if n<glue_base then @<Show equivalent |n|, in region 1 or 2@> |
| 1356 |
@y |
| 1357 |
else if (n<glue_base) or ((n>eqtb_size)and(n<=eqtb_top)) then |
| 1358 |
@<Show equivalent |n|, in region 1 or 2@> |
| 1359 |
@z |
| 1360 |
|
| 1361 |
@x [17.253] l.5462 - Change eqtb to zeqtb. |
| 1362 |
@!eqtb:array[active_base..eqtb_size] of memory_word; |
| 1363 |
@y |
| 1364 |
@!zeqtb:^memory_word; |
| 1365 |
@z |
| 1366 |
|
| 1367 |
@x [18.256] l.5510 - hash_extra |
| 1368 |
@!hash: array[hash_base..undefined_control_sequence-1] of two_halves; |
| 1369 |
{the hash table} |
| 1370 |
@!hash_used:pointer; {allocation pointer for |hash|} |
| 1371 |
@y |
| 1372 |
@!hash: ^two_halves; {the hash table} |
| 1373 |
@!yhash: ^two_halves; {auxiliary pointer for freeing hash} |
| 1374 |
@!hash_used:pointer; {allocation pointer for |hash|} |
| 1375 |
@!hash_extra:pointer; {|hash_extra=hash| above |eqtb_size|} |
| 1376 |
@!hash_top:pointer; {maximum of the hash array} |
| 1377 |
@!eqtb_top:pointer; {maximum of the |eqtb|} |
| 1378 |
@!hash_high:pointer; {pointer to next high hash location} |
| 1379 |
@z |
| 1380 |
|
| 1381 |
@x [18.257] l.5518 - hash_extra |
| 1382 |
next(hash_base):=0; text(hash_base):=0; |
| 1383 |
for k:=hash_base+1 to undefined_control_sequence-1 do hash[k]:=hash[hash_base]; |
| 1384 |
@y |
| 1385 |
@z |
| 1386 |
|
| 1387 |
@x [18.258] l.5522 - hash_extra |
| 1388 |
hash_used:=frozen_control_sequence; {nothing is used} |
| 1389 |
@y |
| 1390 |
hash_used:=frozen_control_sequence; {nothing is used} |
| 1391 |
hash_high:=0; |
| 1392 |
@z |
| 1393 |
|
| 1394 |
@x [18.260] l.5558 - hash_extra |
| 1395 |
@ @<Insert a new control...@>= |
| 1396 |
begin if text(p)>0 then |
| 1397 |
begin repeat if hash_is_full then overflow("hash size",hash_size); |
| 1398 |
@:TeX capacity exceeded hash size}{\quad hash size@> |
| 1399 |
decr(hash_used); |
| 1400 |
until text(hash_used)=0; {search for an empty location in |hash|} |
| 1401 |
next(p):=hash_used; p:=hash_used; |
| 1402 |
end; |
| 1403 |
@y |
| 1404 |
@ @<Insert a new control...@>= |
| 1405 |
begin if text(p)>0 then |
| 1406 |
begin if hash_high<hash_extra then |
| 1407 |
begin incr(hash_high); |
| 1408 |
next(p):=hash_high+eqtb_size; p:=hash_high+eqtb_size; |
| 1409 |
end |
| 1410 |
else begin |
| 1411 |
repeat if hash_is_full then overflow("hash size",hash_size+hash_extra); |
| 1412 |
@:TeX capacity exceeded hash size}{\quad hash size@> |
| 1413 |
decr(hash_used); |
| 1414 |
until text(hash_used)=0; {search for an empty location in |hash|} |
| 1415 |
next(p):=hash_used; p:=hash_used; |
| 1416 |
end; |
| 1417 |
end; |
| 1418 |
@z |
| 1419 |
|
| 1420 |
@x [18.262] l.5610 - hash_extra |
| 1421 |
else if p>=undefined_control_sequence then print_esc("IMPOSSIBLE.") |
| 1422 |
@y |
| 1423 |
else if ((p>=undefined_control_sequence)and(p<=eqtb_size))or(p>eqtb_top) then |
| 1424 |
print_esc("IMPOSSIBLE.") |
| 1425 |
@z |
| 1426 |
|
| 1427 |
@x [18.262] l.5611 - Remove more unsigned comparisons to zero. |
| 1428 |
else if (text(p)<0)or(text(p)>=str_ptr) then print_esc("NONEXISTENT.") |
| 1429 |
@y |
| 1430 |
else if (text(p)>=str_ptr) then print_esc("NONEXISTENT.") |
| 1431 |
@z |
| 1432 |
|
| 1433 |
@x [19.271] l.5899 - texarray |
| 1434 |
@!save_stack : array[0..save_size] of memory_word; |
| 1435 |
@y |
| 1436 |
@!save_stack : ^memory_word; |
| 1437 |
@z |
| 1438 |
|
| 1439 |
@x [19.283] l.6077 - hash_extra |
| 1440 |
if p<int_base then |
| 1441 |
@y |
| 1442 |
if (p<int_base)or(p>eqtb_size) then |
| 1443 |
@z |
| 1444 |
|
| 1445 |
@x [20.290] l.6185 - hash_extra |
| 1446 |
if cs_token_flag+undefined_control_sequence>max_halfword then bad:=21; |
| 1447 |
@y |
| 1448 |
if cs_token_flag+eqtb_size+hash_extra>max_halfword then bad:=21; |
| 1449 |
if (hash_offset<0)or(hash_offset>hash_base) then bad:=42; |
| 1450 |
@z |
| 1451 |
|
| 1452 |
@x [22.301] l.6459 - texarray |
| 1453 |
@!input_stack : array[0..stack_size] of in_state_record; |
| 1454 |
@y |
| 1455 |
@!input_stack : ^in_state_record; |
| 1456 |
@z |
| 1457 |
|
| 1458 |
@x [22.304] l.6563 - texarray; additions for file:line:error style. |
| 1459 |
@!input_file : array[1..max_in_open] of alpha_file; |
| 1460 |
@!line : integer; {current line number in the current source file} |
| 1461 |
@!line_stack : array[1..max_in_open] of integer; |
| 1462 |
@y |
| 1463 |
@!input_file : ^alpha_file; |
| 1464 |
@!line : integer; {current line number in the current source file} |
| 1465 |
@!line_stack : ^integer; |
| 1466 |
@!source_filename_stack : ^str_number; |
| 1467 |
@!full_source_filename_stack : ^str_number; |
| 1468 |
@z |
| 1469 |
|
| 1470 |
@x [22.306] l.6615 - i18n fix |
| 1471 |
begin print_nl("Runaway "); |
| 1472 |
@.Runaway...@> |
| 1473 |
case scanner_status of |
| 1474 |
defining: begin print("definition"); p:=def_ref; |
| 1475 |
end; |
| 1476 |
matching: begin print("argument"); p:=temp_head; |
| 1477 |
end; |
| 1478 |
aligning: begin print("preamble"); p:=hold_head; |
| 1479 |
end; |
| 1480 |
absorbing: begin print("text"); p:=def_ref; |
| 1481 |
end; |
| 1482 |
end; {there are no other cases} |
| 1483 |
@y |
| 1484 |
begin |
| 1485 |
@.Runaway...@> |
| 1486 |
case scanner_status of |
| 1487 |
defining: begin print_nl("Runaway definition"); p:=def_ref; |
| 1488 |
end; |
| 1489 |
matching: begin print_nl("Runaway argument"); p:=temp_head; |
| 1490 |
end; |
| 1491 |
aligning: begin print_nl("Runaway preamble"); p:=hold_head; |
| 1492 |
end; |
| 1493 |
absorbing: begin print_nl("Runaway text"); p:=def_ref; |
| 1494 |
end; |
| 1495 |
end; {there are no other cases} |
| 1496 |
@z |
| 1497 |
|
| 1498 |
@x [22.308] l.6728 - texarray |
| 1499 |
@!param_stack:array [0..param_size] of pointer; |
| 1500 |
{token list pointers for parameters} |
| 1501 |
@y |
| 1502 |
@!param_stack: ^pointer; |
| 1503 |
{token list pointers for parameters} |
| 1504 |
@z |
| 1505 |
|
| 1506 |
@x [23.328] l.7064 - keep top of source_filename_stack initialized |
| 1507 |
incr(in_open); push_input; index:=in_open; |
| 1508 |
@y |
| 1509 |
incr(in_open); push_input; index:=in_open; |
| 1510 |
source_filename_stack[index]:=0;full_source_filename_stack[index]:=0; |
| 1511 |
@z |
| 1512 |
|
| 1513 |
@x [23.331] l.7092 - init source file name stacks |
| 1514 |
begin input_ptr:=0; max_in_stack:=0; |
| 1515 |
@y |
| 1516 |
begin input_ptr:=0; max_in_stack:=0; |
| 1517 |
source_filename_stack[0]:=0;full_source_filename_stack[0]:=0; |
| 1518 |
@z |
| 1519 |
|
| 1520 |
% This one is a consequence of the limit:=0 fix. |
| 1521 |
@x [23.331] l.7095 - initialize buffer[0] |
| 1522 |
first:=buf_size; repeat buffer[first]:=0; decr(first); until first=0; |
| 1523 |
@y |
| 1524 |
first:=buf_size; repeat buffer[first]:=0; decr(first); until first=0; |
| 1525 |
buffer[0]:=0; |
| 1526 |
@z |
| 1527 |
|
| 1528 |
% Original report: https://tug.org/pipermail/tex-k/2024-March/004021.html |
| 1529 |
% TeX bug entry: https://tug.org/texmfbug/newbug.html#B142outer |
| 1530 |
% -- but this has the problem that token deletion will now continue |
| 1531 |
% through an eof, which seems undesirable, and not a permissible |
| 1532 |
% change for "TeX". See tests/outerdel.tex. |
| 1533 |
%@x [24.336] l.7152 - allow interactive deletion of \outer token |
| 1534 |
%begin if scanner_status<>normal then |
| 1535 |
%@y |
| 1536 |
%begin if OK_to_interrupt and(scanner_status<>normal) then |
| 1537 |
%@z |
| 1538 |
|
| 1539 |
@x [24.338] l.7191 - i18n fix |
| 1540 |
print(" while scanning "); |
| 1541 |
@y |
| 1542 |
@z |
| 1543 |
|
| 1544 |
@x [24.339] l.7213 - i18n fix |
| 1545 |
defining:begin print("definition"); info(p):=right_brace_token+"}"; |
| 1546 |
end; |
| 1547 |
matching:begin print("use"); info(p):=par_token; long_state:=outer_call; |
| 1548 |
end; |
| 1549 |
aligning:begin print("preamble"); info(p):=right_brace_token+"}"; q:=p; |
| 1550 |
p:=get_avail; link(p):=q; info(p):=cs_token_flag+frozen_cr; |
| 1551 |
align_state:=-1000000; |
| 1552 |
end; |
| 1553 |
absorbing:begin print("text"); info(p):=right_brace_token+"}"; |
| 1554 |
@y |
| 1555 |
defining:begin print(" while scanning definition"); info(p):=right_brace_token+"}"; |
| 1556 |
end; |
| 1557 |
matching:begin print(" while scanning use"); info(p):=par_token; long_state:=outer_call; |
| 1558 |
end; |
| 1559 |
aligning:begin print(" while scanning preamble"); info(p):=right_brace_token+"}"; q:=p; |
| 1560 |
p:=get_avail; link(p):=q; info(p):=cs_token_flag+frozen_cr; |
| 1561 |
align_state:=-1000000; |
| 1562 |
end; |
| 1563 |
absorbing:begin print(" while scanning text"); info(p):=right_brace_token+"}"; |
| 1564 |
@z |
| 1565 |
|
| 1566 |
@x [25.366] l.7672 - expansion depth overflow |
| 1567 |
begin cv_backup:=cur_val; cvl_backup:=cur_val_level; radix_backup:=radix; |
| 1568 |
@y |
| 1569 |
begin |
| 1570 |
incr(expand_depth_count); |
| 1571 |
if expand_depth_count>=expand_depth then overflow("expansion depth",expand_depth); |
| 1572 |
cv_backup:=cur_val; cvl_backup:=cur_val_level; radix_backup:=radix; |
| 1573 |
@z |
| 1574 |
|
| 1575 |
@x [25.366] l.7678 - expansion depth overflow |
| 1576 |
cur_order:=co_backup; link(backup_head):=backup_backup; |
| 1577 |
@y |
| 1578 |
cur_order:=co_backup; link(backup_head):=backup_backup; |
| 1579 |
decr(expand_depth_count); |
| 1580 |
@z |
| 1581 |
|
| 1582 |
% Original report: https://tex.stackexchange.com/questions/609423 |
| 1583 |
% TeX bug entry: https://tug.org/texmfbug/newbug.html#B155endwrite |
| 1584 |
@x [25.369] l.7717 - disallow \noexpand\endwrite |
| 1585 |
if t>=cs_token_flag then |
| 1586 |
@y |
| 1587 |
if (t>=cs_token_flag)and(t<>end_write_token) then |
| 1588 |
@z |
| 1589 |
|
| 1590 |
% Original report: https://tug.org/pipermail/tex-k/2025-January/004150.html |
| 1591 |
% TeX bug entry: https://tug.org/texmfbug/newbug.html#B182muerror |
| 1592 |
% Test file: tests/invalidmu.tex |
| 1593 |
@x [26.449] l.8878 - recover better from \mkern <non-mu-dimen-or-skip> |
| 1594 |
@<Coerce glue to a dimension@>; |
| 1595 |
if cur_val_level=mu_val then goto attach_sign; |
| 1596 |
if cur_val_level<>int_val then mu_error; |
| 1597 |
@y |
| 1598 |
if cur_val_level<>int_val then |
| 1599 |
begin |
| 1600 |
@<Coerce glue to a dimension@>; |
| 1601 |
if cur_val_level<>mu_val then mu_error; |
| 1602 |
goto attach_sign; |
| 1603 |
end; |
| 1604 |
@z |
| 1605 |
|
| 1606 |
% See above change "term_input: set limit when fatal_error" for references. |
| 1607 |
@x [27.484] l.9495 - set limit when fatal_error |
| 1608 |
else fatal_error("*** (cannot \read from terminal in nonstop modes)") |
| 1609 |
@y |
| 1610 |
else begin |
| 1611 |
limit:=0; |
| 1612 |
fatal_error("*** (cannot \read from terminal in nonstop modes)"); |
| 1613 |
end |
| 1614 |
@z |
| 1615 |
|
| 1616 |
@x [28.501] l.9765 - \eof18 |
| 1617 |
if_eof_code: begin scan_four_bit_int; b:=(read_open[cur_val]=closed); |
| 1618 |
end; |
| 1619 |
@y |
| 1620 |
if_eof_code: begin scan_four_bit_int_or_18; |
| 1621 |
if cur_val=18 then b:=not shellenabledp |
| 1622 |
else b:=(read_open[cur_val]=closed); |
| 1623 |
end; |
| 1624 |
@z |
| 1625 |
|
| 1626 |
@x [29.513] l.9983 - Area and extension rules for filenames. |
| 1627 |
@ The file names we shall deal with for illustrative purposes have the |
| 1628 |
following structure: If the name contains `\.>' or `\.:', the file area |
| 1629 |
consists of all characters up to and including the final such character; |
| 1630 |
otherwise the file area is null. If the remaining file name contains |
| 1631 |
`\..', the file extension consists of all such characters from the first |
| 1632 |
remaining `\..' to the end, otherwise the file extension is null. |
| 1633 |
@y |
| 1634 |
@ The file names we shall deal with have the |
| 1635 |
following structure: If the name contains `\./' or `\.:' |
| 1636 |
(for Amiga only), the file area |
| 1637 |
consists of all characters up to and including the final such character; |
| 1638 |
otherwise the file area is null. If the remaining file name contains |
| 1639 |
`\..', the file extension consists of all such characters from the last |
| 1640 |
`\..' to the end, otherwise the file extension is null. |
| 1641 |
@z |
| 1642 |
|
| 1643 |
@x [29.513] l.9995 - Area and extension rules for filenames. |
| 1644 |
@!area_delimiter:pool_pointer; {the most recent `\.>' or `\.:', if any} |
| 1645 |
@!ext_delimiter:pool_pointer; {the relevant `\..', if any} |
| 1646 |
@y |
| 1647 |
@!area_delimiter:pool_pointer; {the most recent `\./', if any} |
| 1648 |
@!ext_delimiter:pool_pointer; {the most recent `\..', if any} |
| 1649 |
@z |
| 1650 |
|
| 1651 |
@x [29.514] l.10005 - TeX area directories. |
| 1652 |
@d TEX_area=="TeXinputs:" |
| 1653 |
@.TeXinputs@> |
| 1654 |
@d TEX_font_area=="TeXfonts:" |
| 1655 |
@.TeXfonts@> |
| 1656 |
@y |
| 1657 |
In C, the default paths are specified separately. |
| 1658 |
@z |
| 1659 |
|
| 1660 |
@x [29.515] l.10014 - filenames: quoted |
| 1661 |
begin area_delimiter:=0; ext_delimiter:=0; |
| 1662 |
@y |
| 1663 |
begin area_delimiter:=0; ext_delimiter:=0; quoted_filename:=false; |
| 1664 |
@z |
| 1665 |
|
| 1666 |
@x [29.516] l.10024 - filenames: more_name |
| 1667 |
begin if c=" " then more_name:=false |
| 1668 |
@y |
| 1669 |
begin if (c=" ") and stop_at_space and (not quoted_filename) then |
| 1670 |
more_name:=false |
| 1671 |
else if c="""" then begin |
| 1672 |
quoted_filename:=not quoted_filename; |
| 1673 |
more_name:=true; |
| 1674 |
end |
| 1675 |
@z |
| 1676 |
|
| 1677 |
@x [29.516] l.10026 - filenames: more_name |
| 1678 |
if (c=">")or(c=":") then |
| 1679 |
@y |
| 1680 |
if IS_DIR_SEP(c) then |
| 1681 |
@z |
| 1682 |
|
| 1683 |
@x [29.516] l.10029 - filenames: more_name |
| 1684 |
else if (c=".")and(ext_delimiter=0) then ext_delimiter:=cur_length; |
| 1685 |
@y |
| 1686 |
else if c="." then ext_delimiter:=cur_length; |
| 1687 |
@z |
| 1688 |
|
| 1689 |
@x [29.517] l.10034 - end_name: string recycling |
| 1690 |
@ The third. |
| 1691 |
@^system dependencies@> |
| 1692 |
|
| 1693 |
@p procedure end_name; |
| 1694 |
@y |
| 1695 |
@ The third. |
| 1696 |
@^system dependencies@> |
| 1697 |
If a string is already in the string pool, the function |
| 1698 |
|slow_make_string| does not create a new string but returns this string |
| 1699 |
number, thus saving string space. Because of this new property of the |
| 1700 |
returned string number it is not possible to apply |flush_string| to |
| 1701 |
these strings. |
| 1702 |
|
| 1703 |
@p procedure end_name; |
| 1704 |
var temp_str: str_number; {result of file name cache lookups} |
| 1705 |
@!j,@!s,@!t: pool_pointer; {running indices} |
| 1706 |
@!must_quote:boolean; {whether we need to quote a string} |
| 1707 |
@z |
| 1708 |
|
| 1709 |
@x [29.517] l.10040 - end_name: spaces in filenames |
| 1710 |
@:TeX capacity exceeded number of strings}{\quad number of strings@> |
| 1711 |
@y |
| 1712 |
@:TeX capacity exceeded number of strings}{\quad number of strings@> |
| 1713 |
str_room(6); {Room for quotes, if needed.} |
| 1714 |
{add quotes if needed} |
| 1715 |
if area_delimiter<>0 then begin |
| 1716 |
{maybe quote |cur_area|} |
| 1717 |
must_quote:=false; |
| 1718 |
s:=str_start[str_ptr]; |
| 1719 |
t:=str_start[str_ptr]+area_delimiter; |
| 1720 |
j:=s; |
| 1721 |
while (not must_quote) and (j<t) do begin |
| 1722 |
must_quote:=str_pool[j]=" "; incr(j); |
| 1723 |
end; |
| 1724 |
if must_quote then begin |
| 1725 |
for j:=pool_ptr-1 downto t do str_pool[j+2]:=str_pool[j]; |
| 1726 |
str_pool[t+1]:=""""; |
| 1727 |
for j:=t-1 downto s do str_pool[j+1]:=str_pool[j]; |
| 1728 |
str_pool[s]:=""""; |
| 1729 |
if ext_delimiter<>0 then ext_delimiter:=ext_delimiter+2; |
| 1730 |
area_delimiter:=area_delimiter+2; |
| 1731 |
pool_ptr:=pool_ptr+2; |
| 1732 |
end; |
| 1733 |
end; |
| 1734 |
{maybe quote |cur_name|} |
| 1735 |
s:=str_start[str_ptr]+area_delimiter; |
| 1736 |
if ext_delimiter=0 then t:=pool_ptr else t:=str_start[str_ptr]+ext_delimiter-1; |
| 1737 |
must_quote:=false; |
| 1738 |
j:=s; |
| 1739 |
while (not must_quote) and (j<t) do begin |
| 1740 |
must_quote:=str_pool[j]=" "; incr(j); |
| 1741 |
end; |
| 1742 |
if must_quote then begin |
| 1743 |
for j:=pool_ptr-1 downto t do str_pool[j+2]:=str_pool[j]; |
| 1744 |
str_pool[t+1]:=""""; |
| 1745 |
for j:=t-1 downto s do str_pool[j+1]:=str_pool[j]; |
| 1746 |
str_pool[s]:=""""; |
| 1747 |
if ext_delimiter<>0 then ext_delimiter:=ext_delimiter+2; |
| 1748 |
pool_ptr:=pool_ptr+2; |
| 1749 |
end; |
| 1750 |
if ext_delimiter<>0 then begin |
| 1751 |
{maybe quote |cur_ext|} |
| 1752 |
s:=str_start[str_ptr]+ext_delimiter-1; |
| 1753 |
t:=pool_ptr; |
| 1754 |
must_quote:=false; |
| 1755 |
j:=s; |
| 1756 |
while (not must_quote) and (j<t) do begin |
| 1757 |
must_quote:=str_pool[j]=" "; incr(j); |
| 1758 |
end; |
| 1759 |
if must_quote then begin |
| 1760 |
str_pool[t+1]:=""""; |
| 1761 |
for j:=t-1 downto s do str_pool[j+1]:=str_pool[j]; |
| 1762 |
str_pool[s]:=""""; |
| 1763 |
pool_ptr:=pool_ptr+2; |
| 1764 |
end; |
| 1765 |
end; |
| 1766 |
@z |
| 1767 |
|
| 1768 |
@x [29.517] l.10044 - end_name: string recycling |
| 1769 |
end; |
| 1770 |
if ext_delimiter=0 then |
| 1771 |
begin cur_ext:=""; cur_name:=make_string; |
| 1772 |
@y |
| 1773 |
temp_str:=search_string(cur_area); |
| 1774 |
if temp_str>0 then |
| 1775 |
begin cur_area:=temp_str; |
| 1776 |
decr(str_ptr); {no |flush_string|, |pool_ptr| will be wrong!} |
| 1777 |
for j:=str_start[str_ptr+1] to pool_ptr-1 do |
| 1778 |
begin str_pool[j-area_delimiter]:=str_pool[j]; |
| 1779 |
end; |
| 1780 |
pool_ptr:=pool_ptr-area_delimiter; {update |pool_ptr|} |
| 1781 |
end; |
| 1782 |
end; |
| 1783 |
if ext_delimiter=0 then |
| 1784 |
begin cur_ext:=""; cur_name:=slow_make_string; |
| 1785 |
@z |
| 1786 |
|
| 1787 |
@x [29.517] l.10050 - end_name: string recycling |
| 1788 |
incr(str_ptr); cur_ext:=make_string; |
| 1789 |
@y |
| 1790 |
incr(str_ptr); cur_ext:=make_string; |
| 1791 |
decr(str_ptr); {undo extension string to look at name part} |
| 1792 |
temp_str:=search_string(cur_name); |
| 1793 |
if temp_str>0 then |
| 1794 |
begin cur_name:=temp_str; |
| 1795 |
decr(str_ptr); {no |flush_string|, |pool_ptr| will be wrong!} |
| 1796 |
for j:=str_start[str_ptr+1] to pool_ptr-1 do |
| 1797 |
begin str_pool[j-ext_delimiter+area_delimiter+1]:=str_pool[j]; |
| 1798 |
end; |
| 1799 |
pool_ptr:=pool_ptr-ext_delimiter+area_delimiter+1; {update |pool_ptr|} |
| 1800 |
end; |
| 1801 |
cur_ext:=slow_make_string; {remake extension string} |
| 1802 |
@z |
| 1803 |
|
| 1804 |
@x [29.518] l.10056 - print_file_name: quote if spaces in names. |
| 1805 |
some operating systems put the file area last instead of first.) |
| 1806 |
@^system dependencies@> |
| 1807 |
@y |
| 1808 |
some operating systems put the file area last instead of first.) |
| 1809 |
@^system dependencies@> |
| 1810 |
|
| 1811 |
@d check_quoted(#) == {check if string |#| needs quoting} |
| 1812 |
if #<>0 then begin |
| 1813 |
j:=str_start[#]; |
| 1814 |
while (not must_quote) and (j<str_start[#+1]) do begin |
| 1815 |
must_quote:=str_pool[j]=" "; incr(j); |
| 1816 |
end; |
| 1817 |
end |
| 1818 |
@# |
| 1819 |
@d print_quoted(#) == {print string |#|, omitting quotes} |
| 1820 |
if #<>0 then |
| 1821 |
for j:=str_start[#] to str_start[#+1]-1 do |
| 1822 |
if so(str_pool[j])<>"""" then |
| 1823 |
print(so(str_pool[j])) |
| 1824 |
@z |
| 1825 |
|
| 1826 |
@x [29.518] l.10061 - print_file_name: quote if spaces in names. |
| 1827 |
begin slow_print(a); slow_print(n); slow_print(e); |
| 1828 |
@y |
| 1829 |
var must_quote: boolean; {whether to quote the filename} |
| 1830 |
@!j:pool_pointer; {index into |str_pool|} |
| 1831 |
begin |
| 1832 |
must_quote:=false; |
| 1833 |
check_quoted(a); check_quoted(n); check_quoted(e); |
| 1834 |
{FIXME: Alternative is to assume that any filename that has to be quoted has |
| 1835 |
at least one quoted component...if we pick this, a number of insertions |
| 1836 |
of |print_file_name| should go away. |
| 1837 |
|must_quote|:=((|a|<>0)and(|str_pool|[|str_start|[|a|]]=""""))or |
| 1838 |
((|n|<>0)and(|str_pool|[|str_start|[|n|]]=""""))or |
| 1839 |
((|e|<>0)and(|str_pool|[|str_start|[|e|]]=""""));} |
| 1840 |
if must_quote then print_char(""""); |
| 1841 |
print_quoted(a); print_quoted(n); print_quoted(e); |
| 1842 |
if must_quote then print_char(""""); |
| 1843 |
@z |
| 1844 |
|
| 1845 |
@x [29.519] l.10070 - have append_to_name skip quotes. |
| 1846 |
@d append_to_name(#)==begin c:=#; incr(k); |
| 1847 |
if k<=file_name_size then name_of_file[k]:=xchr[c]; |
| 1848 |
end |
| 1849 |
@y |
| 1850 |
@d append_to_name(#)==begin c:=#; if not (c="""") then begin incr(k); |
| 1851 |
if k<=file_name_size then name_of_file[k]:=xchr[c]; |
| 1852 |
end end |
| 1853 |
@z |
| 1854 |
|
| 1855 |
% [29.519] In pack_file_name, leave room for the extra null we append at |
| 1856 |
% the end of a filename. |
| 1857 |
@x [29.519] l.10078 - pack_file_name, leave room for the extra null |
| 1858 |
begin k:=0; |
| 1859 |
@y |
| 1860 |
begin k:=0; |
| 1861 |
if name_of_file then libc_free (name_of_file); |
| 1862 |
name_of_file:= xmalloc_array (ASCII_code, length(a)+length(n)+length(e)+1); |
| 1863 |
@z |
| 1864 |
|
| 1865 |
@x [29.519] l.10083 - pack_file_name, append the extra null |
| 1866 |
for k:=name_length+1 to file_name_size do name_of_file[k]:=' '; |
| 1867 |
@y |
| 1868 |
name_of_file[name_length+1]:=0; |
| 1869 |
@z |
| 1870 |
|
| 1871 |
@x [29.520] l.10092 - filenames: default format. |
| 1872 |
@d format_default_length=20 {length of the |TEX_format_default| string} |
| 1873 |
@d format_area_length=11 {length of its area part} |
| 1874 |
@d format_ext_length=4 {length of its `\.{.fmt}' part} |
| 1875 |
@y |
| 1876 |
Under {\mc UNIX} we don't give the area part, instead depending |
| 1877 |
on the path searching that will happen during file opening. Also, the |
| 1878 |
length will be set in the main program. |
| 1879 |
|
| 1880 |
@d format_area_length=0 {length of its area part} |
| 1881 |
@d format_ext_length=4 {length of its `\.{.fmt}' part} |
| 1882 |
@z |
| 1883 |
|
| 1884 |
@x [29.520] l.10098 - filenames: default format, where `plain.fmt' is. |
| 1885 |
@!TEX_format_default:packed array[1..format_default_length] of char; |
| 1886 |
|
| 1887 |
@ @<Set init...@>= |
| 1888 |
TEX_format_default:='TeXformats:plain.fmt'; |
| 1889 |
@y |
| 1890 |
@!format_default_length: integer; |
| 1891 |
@!TEX_format_default: cstring; |
| 1892 |
|
| 1893 |
@ We set the name of the default format file and the length of that name |
| 1894 |
in C, instead of Pascal, since we want them to depend on the name of the |
| 1895 |
program. |
| 1896 |
@z |
| 1897 |
|
| 1898 |
@x [29.523] l.10127 - Change to pack_buffered_name as with pack_file_name. |
| 1899 |
for j:=1 to n do append_to_name(xord[TEX_format_default[j]]); |
| 1900 |
for j:=a to b do append_to_name(buffer[j]); |
| 1901 |
for j:=format_default_length-format_ext_length+1 to format_default_length do |
| 1902 |
append_to_name(xord[TEX_format_default[j]]); |
| 1903 |
if k<=file_name_size then name_length:=k@+else name_length:=file_name_size; |
| 1904 |
for k:=name_length+1 to file_name_size do name_of_file[k]:=' '; |
| 1905 |
@y |
| 1906 |
if name_of_file then libc_free (name_of_file); |
| 1907 |
name_of_file := xmalloc_array (ASCII_code, n+(b-a+1)+format_ext_length+1); |
| 1908 |
for j:=1 to n do append_to_name(xord[ucharcast(TEX_format_default[j])]); |
| 1909 |
for j:=a to b do append_to_name(buffer[j]); |
| 1910 |
for j:=format_default_length-format_ext_length+1 to format_default_length do |
| 1911 |
append_to_name(xord[ucharcast(TEX_format_default[j])]); |
| 1912 |
if k<=file_name_size then name_length:=k@+else name_length:=file_name_size; |
| 1913 |
name_of_file[name_length+1]:=0; |
| 1914 |
@z |
| 1915 |
|
| 1916 |
@x [29.524] l.10150 - Format file opening: only try once, with path searching. |
| 1917 |
pack_buffered_name(0,loc,j-1); {try first without the system file area} |
| 1918 |
if w_open_in(fmt_file) then goto found; |
| 1919 |
pack_buffered_name(format_area_length,loc,j-1); |
| 1920 |
{now try the system format file area} |
| 1921 |
if w_open_in(fmt_file) then goto found; |
| 1922 |
@y |
| 1923 |
pack_buffered_name(0,loc,j-1); {Kpathsea does everything} |
| 1924 |
if w_open_in(fmt_file) then goto found; |
| 1925 |
@z |
| 1926 |
|
| 1927 |
@x [29.524] l.10156 - replace `PLAIN' in error messages with `default'. |
| 1928 |
wterm_ln('Sorry, I can''t find that format;',' will try PLAIN.'); |
| 1929 |
@y |
| 1930 |
wterm ('Sorry, I can''t find the format `'); |
| 1931 |
fputs (stringcast(name_of_file + 1), stdout); |
| 1932 |
wterm ('''; will try `'); |
| 1933 |
fputs (TEX_format_default + 1, stdout); |
| 1934 |
wterm_ln ('''.'); |
| 1935 |
@z |
| 1936 |
|
| 1937 |
@x [29.524] l.10164 - replace `PLAIN' in error messages with `default'. |
| 1938 |
wterm_ln('I can''t find the PLAIN format file!'); |
| 1939 |
@.I can't find PLAIN...@> |
| 1940 |
@y |
| 1941 |
wterm ('I can''t find the format file `'); |
| 1942 |
fputs (TEX_format_default + 1, stdout); |
| 1943 |
wterm_ln ('''!'); |
| 1944 |
@.I can't find the format...@> |
| 1945 |
@z |
| 1946 |
|
| 1947 |
@x [29.525] l.10184 - make_name_string |
| 1948 |
begin if (pool_ptr+name_length>pool_size)or(str_ptr=max_strings)or |
| 1949 |
@y |
| 1950 |
save_area_delimiter, save_ext_delimiter: pool_pointer; |
| 1951 |
save_name_in_progress, save_stop_at_space: boolean; |
| 1952 |
begin if (pool_ptr+name_length>pool_size)or(str_ptr=max_strings)or |
| 1953 |
@z |
| 1954 |
|
| 1955 |
@x [29.525] l.10188 - make_name_string |
| 1956 |
make_name_string:=make_string; |
| 1957 |
@y |
| 1958 |
make_name_string:=make_string; |
| 1959 |
{At this point we also set |cur_name|, |cur_ext|, and |cur_area| to |
| 1960 |
match the contents of |name_of_file|.} |
| 1961 |
save_area_delimiter:=area_delimiter; save_ext_delimiter:=ext_delimiter; |
| 1962 |
save_name_in_progress:=name_in_progress; save_stop_at_space:=stop_at_space; |
| 1963 |
name_in_progress:=true; |
| 1964 |
begin_name; |
| 1965 |
stop_at_space:=false; |
| 1966 |
k:=1; |
| 1967 |
while (k<=name_length)and(more_name(name_of_file[k])) do |
| 1968 |
incr(k); |
| 1969 |
stop_at_space:=save_stop_at_space; |
| 1970 |
end_name; |
| 1971 |
name_in_progress:=save_name_in_progress; |
| 1972 |
area_delimiter:=save_area_delimiter; ext_delimiter:=save_ext_delimiter; |
| 1973 |
@z |
| 1974 |
|
| 1975 |
@x [29.526] l.10206 - look for a left_brace when scanning a file name |
| 1976 |
@p procedure scan_file_name; |
| 1977 |
label done; |
| 1978 |
@y |
| 1979 |
@p procedure scan_file_name; |
| 1980 |
label done; |
| 1981 |
var |
| 1982 |
@!save_warning_index: pointer; |
| 1983 |
begin |
| 1984 |
save_warning_index := warning_index; |
| 1985 |
warning_index := cur_cs; {store |cur_cs| here to remember until later} |
| 1986 |
@<Get the next non-blank non-relax non-call...@>; {here the program expands |
| 1987 |
tokens and removes spaces and \.{\\relax}es from the input. The \.{\\relax} |
| 1988 |
removal follows LuaTeX''s implementation, and other cases of |
| 1989 |
balanced text scanning.} |
| 1990 |
back_input; {return the last token to be read by either code path} |
| 1991 |
if cur_cmd=left_brace then |
| 1992 |
scan_file_name_braced |
| 1993 |
else |
| 1994 |
@z |
| 1995 |
|
| 1996 |
@x [29.526] l.10213 - stop scanning file name if we're at end-of-line. |
| 1997 |
if not more_name(cur_chr) then goto done; |
| 1998 |
@y |
| 1999 |
{If |cur_chr| is a space and we're not scanning a token list, check |
| 2000 |
whether we're at the end of the buffer. Otherwise we end up adding |
| 2001 |
spurious spaces to file names in some cases.} |
| 2002 |
if (cur_chr=" ") and (state<>token_list) and (loc>limit) then goto done; |
| 2003 |
if not more_name(cur_chr) then goto done; |
| 2004 |
@z |
| 2005 |
|
| 2006 |
@x [29.526] l.10216 - scan a bgroup/egroup-delimited file name |
| 2007 |
done: end_name; name_in_progress:=false; |
| 2008 |
end; |
| 2009 |
@y |
| 2010 |
end; |
| 2011 |
done: end_name; name_in_progress:=false; |
| 2012 |
warning_index := save_warning_index; {restore |warning_index|} |
| 2013 |
end; |
| 2014 |
@z |
| 2015 |
|
| 2016 |
@x [29.530] l.10264 - prompt_file_name: prevent empty filenames. |
| 2017 |
var k:0..buf_size; {index into |buffer|} |
| 2018 |
@y |
| 2019 |
var k:0..buf_size; {index into |buffer|} |
| 2020 |
@!saved_cur_name:str_number; {to catch empty terminal input} |
| 2021 |
@!saved_cur_ext:str_number; {to catch empty terminal input} |
| 2022 |
@!saved_cur_area:str_number; {to catch empty terminal input} |
| 2023 |
@z |
| 2024 |
|
| 2025 |
@x [29.530] l.10271 - prompt_file_name: No default extension is TeX input file. |
| 2026 |
if e=".tex" then show_context; |
| 2027 |
@y |
| 2028 |
if (e=".tex") or (e="") then show_context; |
| 2029 |
print_ln; print_c_string(prompt_file_name_help_msg); |
| 2030 |
if (e<>"") then |
| 2031 |
begin |
| 2032 |
print("; default file extension is `"); print(e); print("'"); |
| 2033 |
end; |
| 2034 |
print(")"); print_ln; |
| 2035 |
@z |
| 2036 |
|
| 2037 |
@x [29.530] l.10277 - prompt_file_name: prevent empty filenames. |
| 2038 |
clear_terminal; prompt_input(": "); @<Scan file name in the buffer@>; |
| 2039 |
if cur_ext="" then cur_ext:=e; |
| 2040 |
@y |
| 2041 |
saved_cur_name:=cur_name; |
| 2042 |
saved_cur_ext:=cur_ext; |
| 2043 |
saved_cur_area:=cur_area; |
| 2044 |
clear_terminal; prompt_input(": "); @<Scan file name in the buffer@>; |
| 2045 |
if (length(cur_name)=0) and (cur_ext="") and (cur_area="") then |
| 2046 |
begin |
| 2047 |
cur_name:=saved_cur_name; |
| 2048 |
cur_ext:=saved_cur_ext; |
| 2049 |
cur_area:=saved_cur_area; |
| 2050 |
end |
| 2051 |
else |
| 2052 |
if cur_ext="" then cur_ext:=e; |
| 2053 |
@z |
| 2054 |
|
| 2055 |
@x [29.532] l.10295 - avoid conflict, `logname' in <unistd.h> on some systems. |
| 2056 |
@d ensure_dvi_open==if output_file_name=0 then |
| 2057 |
@y |
| 2058 |
@d log_name == texmf_log_name |
| 2059 |
@d ensure_dvi_open==if output_file_name=0 then |
| 2060 |
@z |
| 2061 |
|
| 2062 |
@x [29.534] l.10317 - Adjust for C string conventions. |
| 2063 |
@!months:packed array [1..36] of char; {abbreviations of month names} |
| 2064 |
@y |
| 2065 |
@!months:const_cstring; |
| 2066 |
@z |
| 2067 |
|
| 2068 |
@x [29.534] l.10319 - Filename change for the recorder. |
| 2069 |
if job_name=0 then job_name:="texput"; |
| 2070 |
@.texput@> |
| 2071 |
@y |
| 2072 |
if job_name=0 then job_name:=get_job_name("texput"); |
| 2073 |
@.texput@> |
| 2074 |
pack_job_name(".fls"); |
| 2075 |
recorder_change_filename(stringcast(name_of_file+1)); |
| 2076 |
@z |
| 2077 |
|
| 2078 |
@x [29.534] l.10325 - MLTeX: add MLTeX banner after loading fmt file |
| 2079 |
@<Print the banner line, including the date and time@>; |
| 2080 |
@y |
| 2081 |
@<Print the banner line, including the date and time@>; |
| 2082 |
if mltex_enabled_p then |
| 2083 |
begin wlog_cr; wlog('MLTeX v2.2 enabled'); |
| 2084 |
end; |
| 2085 |
@z |
| 2086 |
|
| 2087 |
@x [29.536] l.10356 |
| 2088 |
begin wlog(banner); |
| 2089 |
@y |
| 2090 |
begin |
| 2091 |
if src_specials_p or file_line_error_style_p or parse_first_line_p |
| 2092 |
then |
| 2093 |
wlog(banner_k) |
| 2094 |
else |
| 2095 |
wlog(banner); |
| 2096 |
@z |
| 2097 |
|
| 2098 |
@x [29.536] l.10357 - Print rest of banner. |
| 2099 |
slow_print(format_ident); print(" "); |
| 2100 |
@y |
| 2101 |
wlog(version_string); |
| 2102 |
slow_print(format_ident); print(" "); |
| 2103 |
@z |
| 2104 |
|
| 2105 |
@x [29.536] l.10359 - Adjust for C string conventions. |
| 2106 |
months:='JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC'; |
| 2107 |
@y |
| 2108 |
months := ' JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC'; |
| 2109 |
@z |
| 2110 |
|
| 2111 |
% Print whether we're using src-specials and other such features. |
| 2112 |
% Print TCX name if one's given. |
| 2113 |
@x [29.536] l.10363 |
| 2114 |
end |
| 2115 |
@y |
| 2116 |
if shellenabledp then begin |
| 2117 |
wlog_cr; |
| 2118 |
wlog(' '); |
| 2119 |
if restrictedshell then begin |
| 2120 |
wlog('restricted '); |
| 2121 |
end; |
| 2122 |
wlog('\write18 enabled.') |
| 2123 |
end; |
| 2124 |
if src_specials_p then begin |
| 2125 |
wlog_cr; |
| 2126 |
wlog(' Source specials enabled.') |
| 2127 |
end; |
| 2128 |
if file_line_error_style_p then begin |
| 2129 |
wlog_cr; |
| 2130 |
wlog(' file:line:error style messages enabled.') |
| 2131 |
end; |
| 2132 |
if parse_first_line_p then begin |
| 2133 |
wlog_cr; |
| 2134 |
wlog(' %&-line parsing enabled.'); |
| 2135 |
end; |
| 2136 |
if translate_filename then begin |
| 2137 |
wlog_cr; |
| 2138 |
wlog(' ('); |
| 2139 |
fputs(translate_filename, log_file); |
| 2140 |
wlog(')'); |
| 2141 |
end; |
| 2142 |
end |
| 2143 |
@z |
| 2144 |
|
| 2145 |
% [29.537] Use a path when calling a_open_in to do a \input; also, try |
| 2146 |
% to open the file with and without the `.tex' extension, regardless of |
| 2147 |
% whether the file already has an extension. This allows filenames like |
| 2148 |
% `foo' and `foo.bar.tex', as well as `foo.tex' and `foo.bar'. |
| 2149 |
@x [29.537] l.10373 - start_input |
| 2150 |
begin scan_file_name; {set |cur_name| to desired file name} |
| 2151 |
if cur_ext="" then cur_ext:=".tex"; |
| 2152 |
pack_cur_name; |
| 2153 |
loop@+ begin begin_file_reading; {set up |cur_file| and new level of input} |
| 2154 |
if a_open_in(cur_file) then goto done; |
| 2155 |
if cur_area="" then |
| 2156 |
begin pack_file_name(cur_name,TEX_area,cur_ext); |
| 2157 |
if a_open_in(cur_file) then goto done; |
| 2158 |
end; |
| 2159 |
@y |
| 2160 |
var temp_str: str_number; |
| 2161 |
begin scan_file_name; {set |cur_name| to desired file name} |
| 2162 |
pack_cur_name; |
| 2163 |
loop@+begin |
| 2164 |
begin_file_reading; {set up |cur_file| and new level of input} |
| 2165 |
tex_input_type := 1; {Tell |open_input| we are \.{\\input}.} |
| 2166 |
{Kpathsea tries all the various ways to get the file.} |
| 2167 |
if kpse_in_name_ok(stringcast(name_of_file+1)) |
| 2168 |
and a_open_in(cur_file, kpse_tex_format) then |
| 2169 |
goto done; |
| 2170 |
@z |
| 2171 |
|
| 2172 |
@x [29.537] l.10383 - start_input: don't force ".tex" extension. |
| 2173 |
prompt_file_name("input file name",".tex"); |
| 2174 |
@y |
| 2175 |
prompt_file_name("input file name",""); |
| 2176 |
@z |
| 2177 |
|
| 2178 |
@x [29.537] l.10385 - start_input: string recycling |
| 2179 |
done: name:=a_make_name_string(cur_file); |
| 2180 |
@y |
| 2181 |
done: name:=a_make_name_string(cur_file); |
| 2182 |
source_filename_stack[in_open]:=name; |
| 2183 |
full_source_filename_stack[in_open]:=make_full_name_string; |
| 2184 |
if name=str_ptr-1 then {we can try to conserve string pool space now} |
| 2185 |
begin temp_str:=search_string(name); |
| 2186 |
if temp_str>0 then |
| 2187 |
begin name:=temp_str; flush_string; |
| 2188 |
end; |
| 2189 |
end; |
| 2190 |
@z |
| 2191 |
|
| 2192 |
@x [29.537] l.10387 - start_input: was job_name given on the command line? |
| 2193 |
begin job_name:=cur_name; open_log_file; |
| 2194 |
@y |
| 2195 |
begin job_name:=get_job_name(cur_name); open_log_file; |
| 2196 |
@z |
| 2197 |
|
| 2198 |
@x [29.537] l.10390 |
| 2199 |
if term_offset+length(name)>max_print_line-2 then print_ln |
| 2200 |
else if (term_offset>0)or(file_offset>0) then print_char(" "); |
| 2201 |
print_char("("); incr(open_parens); slow_print(name); update_terminal; |
| 2202 |
@y |
| 2203 |
if term_offset+length(full_source_filename_stack[in_open])>max_print_line-2 |
| 2204 |
then print_ln |
| 2205 |
else if (term_offset>0)or(file_offset>0) then print_char(" "); |
| 2206 |
print_char("("); incr(open_parens); |
| 2207 |
slow_print(full_source_filename_stack[in_open]); update_terminal; |
| 2208 |
@z |
| 2209 |
|
| 2210 |
@x [29.537] l.10394 - start_input: don't return filename to string pool. |
| 2211 |
if name=str_ptr-1 then {conserve string pool space (but see note above)} |
| 2212 |
begin flush_string; name:=cur_name; |
| 2213 |
end; |
| 2214 |
@y |
| 2215 |
@z |
| 2216 |
|
| 2217 |
@x [30.548] l.10708 - texarray |
| 2218 |
@!internal_font_number=font_base..font_max; {|font| in a |char_node|} |
| 2219 |
@!font_index=0..font_mem_size; {index into |font_info|} |
| 2220 |
@y |
| 2221 |
@!internal_font_number=integer; {|font| in a |char_node|} |
| 2222 |
@!font_index=integer; {index into |font_info|} |
| 2223 |
@!nine_bits=min_quarterword..non_char; |
| 2224 |
@z |
| 2225 |
|
| 2226 |
@x [30.549] l.10717 - texarray |
| 2227 |
@!font_info:array[font_index] of memory_word; |
| 2228 |
{the big collection of font data} |
| 2229 |
@!fmem_ptr:font_index; {first unused word of |font_info|} |
| 2230 |
@!font_ptr:internal_font_number; {largest internal font number in use} |
| 2231 |
@!font_check:array[internal_font_number] of four_quarters; {check sum} |
| 2232 |
@!font_size:array[internal_font_number] of scaled; {``at'' size} |
| 2233 |
@!font_dsize:array[internal_font_number] of scaled; {``design'' size} |
| 2234 |
@!font_params:array[internal_font_number] of font_index; {how many font |
| 2235 |
parameters are present} |
| 2236 |
@!font_name:array[internal_font_number] of str_number; {name of the font} |
| 2237 |
@!font_area:array[internal_font_number] of str_number; {area of the font} |
| 2238 |
@!font_bc:array[internal_font_number] of eight_bits; |
| 2239 |
{beginning (smallest) character code} |
| 2240 |
@!font_ec:array[internal_font_number] of eight_bits; |
| 2241 |
{ending (largest) character code} |
| 2242 |
@!font_glue:array[internal_font_number] of pointer; |
| 2243 |
{glue specification for interword space, |null| if not allocated} |
| 2244 |
@!font_used:array[internal_font_number] of boolean; |
| 2245 |
{has a character from this font actually appeared in the output?} |
| 2246 |
@!hyphen_char:array[internal_font_number] of integer; |
| 2247 |
{current \.{\\hyphenchar} values} |
| 2248 |
@!skew_char:array[internal_font_number] of integer; |
| 2249 |
{current \.{\\skewchar} values} |
| 2250 |
@!bchar_label:array[internal_font_number] of font_index; |
| 2251 |
{start of |lig_kern| program for left boundary character, |
| 2252 |
|non_address| if there is none} |
| 2253 |
@!font_bchar:array[internal_font_number] of min_quarterword..non_char; |
| 2254 |
{boundary character, |non_char| if there is none} |
| 2255 |
@!font_false_bchar:array[internal_font_number] of min_quarterword..non_char; |
| 2256 |
{|font_bchar| if it doesn't exist in the font, otherwise |non_char|} |
| 2257 |
@y |
| 2258 |
@!font_info: ^fmemory_word; |
| 2259 |
{the big collection of font data} |
| 2260 |
@!fmem_ptr:font_index; {first unused word of |font_info|} |
| 2261 |
@!font_ptr:internal_font_number; {largest internal font number in use} |
| 2262 |
@!font_check: ^four_quarters; {check sum} |
| 2263 |
@!font_size: ^scaled; {``at'' size} |
| 2264 |
@!font_dsize: ^scaled; {``design'' size} |
| 2265 |
@!font_params: ^font_index; {how many font |
| 2266 |
parameters are present} |
| 2267 |
@!font_name: ^str_number; {name of the font} |
| 2268 |
@!font_area: ^str_number; {area of the font} |
| 2269 |
@!font_bc: ^eight_bits; |
| 2270 |
{beginning (smallest) character code} |
| 2271 |
@!font_ec: ^eight_bits; |
| 2272 |
{ending (largest) character code} |
| 2273 |
@!font_glue: ^pointer; |
| 2274 |
{glue specification for interword space, |null| if not allocated} |
| 2275 |
@!font_used: ^boolean; |
| 2276 |
{has a character from this font actually appeared in the output?} |
| 2277 |
@!hyphen_char: ^integer; |
| 2278 |
{current \.{\\hyphenchar} values} |
| 2279 |
@!skew_char: ^integer; |
| 2280 |
{current \.{\\skewchar} values} |
| 2281 |
@!bchar_label: ^font_index; |
| 2282 |
{start of |lig_kern| program for left boundary character, |
| 2283 |
|non_address| if there is none} |
| 2284 |
@!font_bchar: ^nine_bits; |
| 2285 |
{boundary character, |non_char| if there is none} |
| 2286 |
@!font_false_bchar: ^nine_bits; |
| 2287 |
{|font_bchar| if it doesn't exist in the font, otherwise |non_char|} |
| 2288 |
@z |
| 2289 |
|
| 2290 |
@x [30.550] l.10758 - texarray |
| 2291 |
@!char_base:array[internal_font_number] of integer; |
| 2292 |
{base addresses for |char_info|} |
| 2293 |
@!width_base:array[internal_font_number] of integer; |
| 2294 |
{base addresses for widths} |
| 2295 |
@!height_base:array[internal_font_number] of integer; |
| 2296 |
{base addresses for heights} |
| 2297 |
@!depth_base:array[internal_font_number] of integer; |
| 2298 |
{base addresses for depths} |
| 2299 |
@!italic_base:array[internal_font_number] of integer; |
| 2300 |
{base addresses for italic corrections} |
| 2301 |
@!lig_kern_base:array[internal_font_number] of integer; |
| 2302 |
{base addresses for ligature/kerning programs} |
| 2303 |
@!kern_base:array[internal_font_number] of integer; |
| 2304 |
{base addresses for kerns} |
| 2305 |
@!exten_base:array[internal_font_number] of integer; |
| 2306 |
{base addresses for extensible recipes} |
| 2307 |
@!param_base:array[internal_font_number] of integer; |
| 2308 |
{base addresses for font parameters} |
| 2309 |
@y |
| 2310 |
@!char_base: ^integer; |
| 2311 |
{base addresses for |char_info|} |
| 2312 |
@!width_base: ^integer; |
| 2313 |
{base addresses for widths} |
| 2314 |
@!height_base: ^integer; |
| 2315 |
{base addresses for heights} |
| 2316 |
@!depth_base: ^integer; |
| 2317 |
{base addresses for depths} |
| 2318 |
@!italic_base: ^integer; |
| 2319 |
{base addresses for italic corrections} |
| 2320 |
@!lig_kern_base: ^integer; |
| 2321 |
{base addresses for ligature/kerning programs} |
| 2322 |
@!kern_base: ^integer; |
| 2323 |
{base addresses for kerns} |
| 2324 |
@!exten_base: ^integer; |
| 2325 |
{base addresses for extensible recipes} |
| 2326 |
@!param_base: ^integer; |
| 2327 |
{base addresses for font parameters} |
| 2328 |
@z |
| 2329 |
|
| 2330 |
@x [30.551] l.10778 - texarray |
| 2331 |
for k:=font_base to font_max do font_used[k]:=false; |
| 2332 |
@y |
| 2333 |
@z |
| 2334 |
|
| 2335 |
@x [30.552] l.10784 - texarray |
| 2336 |
font_ptr:=null_font; fmem_ptr:=7; |
| 2337 |
font_name[null_font]:="nullfont"; font_area[null_font]:=""; |
| 2338 |
hyphen_char[null_font]:="-"; skew_char[null_font]:=-1; |
| 2339 |
bchar_label[null_font]:=non_address; |
| 2340 |
font_bchar[null_font]:=non_char; font_false_bchar[null_font]:=non_char; |
| 2341 |
font_bc[null_font]:=1; font_ec[null_font]:=0; |
| 2342 |
font_size[null_font]:=0; font_dsize[null_font]:=0; |
| 2343 |
char_base[null_font]:=0; width_base[null_font]:=0; |
| 2344 |
height_base[null_font]:=0; depth_base[null_font]:=0; |
| 2345 |
italic_base[null_font]:=0; lig_kern_base[null_font]:=0; |
| 2346 |
kern_base[null_font]:=0; exten_base[null_font]:=0; |
| 2347 |
font_glue[null_font]:=null; font_params[null_font]:=7; |
| 2348 |
param_base[null_font]:=-1; |
| 2349 |
for k:=0 to 6 do font_info[k].sc:=0; |
| 2350 |
@y |
| 2351 |
@z |
| 2352 |
|
| 2353 |
@x [30.554] l.10830 - MLTeX: |effective_char| in |char_info| |
| 2354 |
as fast as possible under the circumstances. |
| 2355 |
@^inner loop@> |
| 2356 |
|
| 2357 |
@d char_info_end(#)==#].qqqq |
| 2358 |
@d char_info(#)==font_info[char_base[#]+char_info_end |
| 2359 |
@y |
| 2360 |
as fast as possible under the circumstances. |
| 2361 |
@^inner loop@> |
| 2362 |
|
| 2363 |
ML\TeX{} will assume that a character |c| exists iff either exists in |
| 2364 |
the current font or a character substitution definition for this |
| 2365 |
character was defined using \.{\\charsubdef}. To avoid the |
| 2366 |
distinction between these two cases, ML\TeX{} introduces the notion |
| 2367 |
``effective character'' of an input character |c|. If |c| exists in |
| 2368 |
the current font, the effective character of |c| is the character |c| |
| 2369 |
itself. If it doesn't exist but a character substitution is defined, |
| 2370 |
the effective character of |c| is the base character defined in the |
| 2371 |
character substitution. If there is an effective character for a |
| 2372 |
non-existing character |c|, the ``virtual character'' |c| will get |
| 2373 |
appended to the horizontal lists. |
| 2374 |
|
| 2375 |
The effective character is used within |char_info| to access |
| 2376 |
appropriate character descriptions in the font. For example, when |
| 2377 |
calculating the width of a box, ML\TeX{} will use the metrics of the |
| 2378 |
effective characters. For the case of a substitution, ML\TeX{} uses |
| 2379 |
the metrics of the base character, ignoring the metrics of the accent |
| 2380 |
character. |
| 2381 |
|
| 2382 |
If character substitutions are changed, it will be possible that a |
| 2383 |
character |c| neither exists in a font nor there is a valid character |
| 2384 |
substitution for |c|. To handle these cases |effective_char| should |
| 2385 |
be called with its first argument set to |true| to ensure that it |
| 2386 |
will still return an existing character in the font. If neither |c| |
| 2387 |
nor the substituted base character in the current character |
| 2388 |
substitution exists, |effective_char| will output a warning and |
| 2389 |
return the character |font_bc[f]| (which is incorrect, but can not be |
| 2390 |
changed within the current framework). |
| 2391 |
|
| 2392 |
Sometimes character substitutions are unwanted, therefore the |
| 2393 |
original definition of |char_info| can be used using the macro |
| 2394 |
|orig_char_info|. Operations in which character substitutions should |
| 2395 |
be avoided are, for example, loading a new font and checking the font |
| 2396 |
metric information in this font, and character accesses in math mode. |
| 2397 |
|
| 2398 |
@d char_list_exists(#)==(char_sub_code(#)>hi(0)) |
| 2399 |
@d char_list_accent(#)==(ho(char_sub_code(#)) div 256) |
| 2400 |
@d char_list_char(#)==(ho(char_sub_code(#)) mod 256) |
| 2401 |
@# |
| 2402 |
@d char_info_end(#)== #@=)@>].qqqq |
| 2403 |
@d char_info(#)== |
| 2404 |
font_info[char_base[#]+effective_char@=(@>true,#,char_info_end |
| 2405 |
@# |
| 2406 |
@d orig_char_info_end(#)==#].qqqq |
| 2407 |
@d orig_char_info(#)==font_info[char_base[#]+orig_char_info_end |
| 2408 |
@# |
| 2409 |
@z |
| 2410 |
|
| 2411 |
@x [30.560] l.10911 - MLTeX: |effective_char| in |char_info| |
| 2412 |
@p function read_font_info(@!u:pointer;@!nom,@!aire:str_number; |
| 2413 |
@y |
| 2414 |
@p @t\4@>@<Declare additional functions for ML\TeX@>@/ |
| 2415 |
|
| 2416 |
function read_font_info(@!u:pointer;@!nom,@!aire:str_number; |
| 2417 |
@z |
| 2418 |
|
| 2419 |
@x [30.560] l.10915 - Check lengths |
| 2420 |
@!file_opened:boolean; {was |tfm_file| successfully opened?} |
| 2421 |
@y |
| 2422 |
@!name_too_long:boolean; {|nom| or |aire| exceeds 255 bytes?} |
| 2423 |
@!file_opened:boolean; {was |tfm_file| successfully opened?} |
| 2424 |
@z |
| 2425 |
|
| 2426 |
@x [30.561] l.10956 - Check lengths |
| 2427 |
else print(" not loadable: Metric (TFM) file not found"); |
| 2428 |
@y |
| 2429 |
else if name_too_long then print(" not loadable: Metric (TFM) file name too long") |
| 2430 |
else print(" not loadable: Metric (TFM) file not found"); |
| 2431 |
@z |
| 2432 |
|
| 2433 |
@x [30.563] l.10978 - Check lengths, don't use TEX_font_area. |
| 2434 |
if aire="" then pack_file_name(nom,TEX_font_area,".tfm") |
| 2435 |
else pack_file_name(nom,aire,".tfm"); |
| 2436 |
@y |
| 2437 |
name_too_long:=(length(nom)>255)or(length(aire)>255); |
| 2438 |
if name_too_long then abort; |
| 2439 |
{|kpse_find_file| will append the |".tfm"|, and avoid searching the disk |
| 2440 |
before the font alias files as well.} |
| 2441 |
pack_file_name(nom,aire,""); |
| 2442 |
@z |
| 2443 |
|
| 2444 |
% [30.564] Reading the tfm file. As a special case, whenever we open a |
| 2445 |
% tfm file, we read its first byte into `tfm_temp' right away. TeX |
| 2446 |
% looks at `fbyte' before calling `fget', so it ends up seeing every |
| 2447 |
% byte. This is Pascal-like I/O. |
| 2448 |
@x [30.564] l.10991 - reading the tfm file, define fget & fbyte |
| 2449 |
@d fget==get(tfm_file) |
| 2450 |
@d fbyte==tfm_file^ |
| 2451 |
@y |
| 2452 |
@d fget==tfm_temp:=getc(tfm_file) |
| 2453 |
@d fbyte==tfm_temp |
| 2454 |
@z |
| 2455 |
|
| 2456 |
% Too much font scaling can cause overflows and silently changing the |
| 2457 |
% user's value. See tests/fonttoobig.tex for examples. Reports from |
| 2458 |
% Igor Liferenko (https://tug.org/pipermail/tex-k/2021-June/003604.html) |
| 2459 |
% and Tyge Tiessen (https://tug.org/pipermail/tex-k/2022-January/003752.html). |
| 2460 |
% Original patch from Tyge. |
| 2461 |
@x [30.568] l.11072 - Avoid scaling fonts to 2048pt or more. |
| 2462 |
else z:=xn_over_d(z,-s,1000); |
| 2463 |
@y |
| 2464 |
else begin |
| 2465 |
save_arith_error:=arith_error; |
| 2466 |
sw:=z; z:=xn_over_d(z,-s,1000); |
| 2467 |
if arith_error or z>=@'1000000000 then begin |
| 2468 |
start_font_error_message; print(" scaled to 2048pt or higher"); |
| 2469 |
help1("I will ignore the scaling factor."); error; z:=sw; |
| 2470 |
end; |
| 2471 |
arith_error:=save_arith_error; |
| 2472 |
end; |
| 2473 |
@z |
| 2474 |
|
| 2475 |
@x [30.570] l.11100 - MLTeX: fix for bug while loading font |
| 2476 |
begin qw:=char_info(f)(d); |
| 2477 |
@y |
| 2478 |
begin qw:=orig_char_info(f)(d); |
| 2479 |
@z |
| 2480 |
|
| 2481 |
@x [30.573] l.11152 - MLTeX: fix for bug while loading font |
| 2482 |
qw:=char_info(f)(#); {N.B.: not |qi(#)|} |
| 2483 |
@y |
| 2484 |
qw:=orig_char_info(f)(#); {N.B.: not |qi(#)|} |
| 2485 |
@z |
| 2486 |
|
| 2487 |
% [30.575] We only want `eof' on the TFM file to be true if we |
| 2488 |
% previously had EOF, not if we're at EOF now. This is like `feof', and |
| 2489 |
% unlike our implementation of `eof' elsewhere. |
| 2490 |
@x [30.575] l.11197 - Reading the tfm file, replace eof() by feof(). |
| 2491 |
if eof(tfm_file) then abort; |
| 2492 |
@y |
| 2493 |
if feof(tfm_file) then abort; |
| 2494 |
@z |
| 2495 |
|
| 2496 |
@x [30.576] l.11216 - MLTeX: fix for bug while loading font |
| 2497 |
begin qw:=char_info(f)(bchar); {N.B.: not |qi(bchar)|} |
| 2498 |
@y |
| 2499 |
begin qw:=orig_char_info(f)(bchar); {N.B.: not |qi(bchar)|} |
| 2500 |
@z |
| 2501 |
|
| 2502 |
@x [30.582] l.11312 - MLTeX: call |effective_char| in |new_character| |
| 2503 |
@p function new_character(@!f:internal_font_number;@!c:eight_bits):pointer; |
| 2504 |
label exit; |
| 2505 |
var p:pointer; {newly allocated node} |
| 2506 |
begin if font_bc[f]<=c then if font_ec[f]>=c then |
| 2507 |
if char_exists(char_info(f)(qi(c))) then |
| 2508 |
@y |
| 2509 |
|
| 2510 |
This allows a character node to be used if there is an equivalent |
| 2511 |
in the |char_sub_code| list. |
| 2512 |
|
| 2513 |
@p function new_character(@!f:internal_font_number;@!c:eight_bits):pointer; |
| 2514 |
label exit; |
| 2515 |
var p:pointer; {newly allocated node} |
| 2516 |
@!ec:quarterword; {effective character of |c|} |
| 2517 |
begin ec:=effective_char(false,f,qi(c)); |
| 2518 |
if font_bc[f]<=qo(ec) then if font_ec[f]>=qo(ec) then |
| 2519 |
if char_exists(orig_char_info(f)(ec)) then {N.B.: not |char_info|} |
| 2520 |
@z |
| 2521 |
|
| 2522 |
@x [32.592] l.11856 - font numbers can be >255 now. |
| 2523 |
@!c,@!f:quarterword; {character and font in current |char_node|} |
| 2524 |
@y |
| 2525 |
{character and font in current |char_node|} |
| 2526 |
@!c:quarterword; |
| 2527 |
@!f:internal_font_number; |
| 2528 |
@z |
| 2529 |
|
| 2530 |
@x [32.595] l.11896 - texarray |
| 2531 |
@!dvi_buf:array[dvi_index] of eight_bits; {buffer for \.{DVI} output} |
| 2532 |
@!half_buf:dvi_index; {half of |dvi_buf_size|} |
| 2533 |
@!dvi_limit:dvi_index; {end of the current half buffer} |
| 2534 |
@!dvi_ptr:dvi_index; {the next available buffer address} |
| 2535 |
@y |
| 2536 |
@!dvi_buf:^eight_bits; {buffer for \.{DVI} output} |
| 2537 |
@!half_buf:integer; {half of |dvi_buf_size|} |
| 2538 |
@!dvi_limit:integer; {end of the current half buffer} |
| 2539 |
@!dvi_ptr:integer; {the next available buffer address} |
| 2540 |
@z |
| 2541 |
|
| 2542 |
@x [32.597] l.11922 - write_dvi done in C. |
| 2543 |
@p procedure write_dvi(@!a,@!b:dvi_index); |
| 2544 |
var k:dvi_index; |
| 2545 |
begin for k:=a to b do write(dvi_file,dvi_buf[k]); |
| 2546 |
end; |
| 2547 |
@y |
| 2548 |
In C, we use a macro to call |fwrite| or |write| directly, writing all |
| 2549 |
the bytes in one shot. Much better even than writing four |
| 2550 |
bytes at a time. |
| 2551 |
@z |
| 2552 |
|
| 2553 |
@x [32.598] l.11928 - check dvi file size |
| 2554 |
each time, we use the macro |dvi_out|. |
| 2555 |
@y |
| 2556 |
each time, we use the macro |dvi_out|. |
| 2557 |
|
| 2558 |
The length of |dvi_file| should not exceed |@"7FFFFFFF|; we set |cur_s:=-2| |
| 2559 |
to prevent further \.{DVI} output causing infinite recursion. |
| 2560 |
@z |
| 2561 |
|
| 2562 |
@x [32.598] l.11935 - dvi_swap: check dvi file size |
| 2563 |
begin if dvi_limit=dvi_buf_size then |
| 2564 |
@y |
| 2565 |
begin if dvi_ptr>(@"7FFFFFFF-dvi_offset) then |
| 2566 |
begin cur_s:=-2; |
| 2567 |
fatal_error("dvi length exceeds ""7FFFFFFF"); |
| 2568 |
@.dvi length exceeds...@> |
| 2569 |
end; |
| 2570 |
if dvi_limit=dvi_buf_size then |
| 2571 |
@z |
| 2572 |
|
| 2573 |
@x [32.599] l.11949 - empty the last bytes: check dvi file size |
| 2574 |
if dvi_ptr>0 then write_dvi(0,dvi_ptr-1) |
| 2575 |
@y |
| 2576 |
if dvi_ptr>(@"7FFFFFFF-dvi_offset) then |
| 2577 |
begin cur_s:=-2; |
| 2578 |
fatal_error("dvi length exceeds ""7FFFFFFF"); |
| 2579 |
@.dvi length exceeds...@> |
| 2580 |
end; |
| 2581 |
if dvi_ptr>0 then write_dvi(0,dvi_ptr-1) |
| 2582 |
@z |
| 2583 |
|
| 2584 |
@x [32.602] l.11980 - Allow for outputting more than 256 fonts. |
| 2585 |
begin dvi_out(fnt_def1); |
| 2586 |
dvi_out(f-font_base-1);@/ |
| 2587 |
@y |
| 2588 |
begin if f<=256+font_base then |
| 2589 |
begin dvi_out(fnt_def1); |
| 2590 |
dvi_out(f-font_base-1); |
| 2591 |
end |
| 2592 |
else begin dvi_out(fnt_def1+1); |
| 2593 |
dvi_out((f-font_base-1) div @'400); |
| 2594 |
dvi_out((f-font_base-1) mod @'400); |
| 2595 |
end; |
| 2596 |
@z |
| 2597 |
|
| 2598 |
@x [32.617] l.12297 - Use output_comment if the user set it. Assume it's short enough. |
| 2599 |
old_setting:=selector; selector:=new_string; |
| 2600 |
@y |
| 2601 |
if output_comment then |
| 2602 |
begin l:=strlen(output_comment); dvi_out(l); |
| 2603 |
for s:=0 to l-1 do dvi_out(output_comment[s]); |
| 2604 |
end |
| 2605 |
else begin {the default code is unchanged} |
| 2606 |
old_setting:=selector; selector:=new_string; |
| 2607 |
@z |
| 2608 |
|
| 2609 |
@x [32.617] l.12305 - Use output_comment if the user set it. |
| 2610 |
end |
| 2611 |
@y |
| 2612 |
end; |
| 2613 |
end |
| 2614 |
@z |
| 2615 |
|
| 2616 |
@x [32.619] l.12330 - MLTeX: substitute character in |hlist_out| |
| 2617 |
procedure hlist_out; {output an |hlist_node| box} |
| 2618 |
label reswitch, move_past, fin_rule, next_p; |
| 2619 |
@y |
| 2620 |
procedure hlist_out; {output an |hlist_node| box} |
| 2621 |
label reswitch, move_past, fin_rule, next_p, continue, found; |
| 2622 |
@z |
| 2623 |
|
| 2624 |
@x [32.620] l.12365 - MLTeX: replace virtual character in |hlist_out| |
| 2625 |
reaching a non-|char_node|. The program uses the fact that |set_char_0=0|. |
| 2626 |
@^inner loop@> |
| 2627 |
@y |
| 2628 |
reaching a non-|char_node|. The program uses the fact that |set_char_0=0|. |
| 2629 |
|
| 2630 |
In ML\TeX{} this part looks for the existence of a substitution |
| 2631 |
definition for a character |c|, if |c| does not exist in the font, |
| 2632 |
and create appropriate \.{DVI} commands. Former versions of ML\TeX{} |
| 2633 |
have spliced appropriate character, kern, and box nodes into the |
| 2634 |
horizontal list. |
| 2635 |
% |
| 2636 |
% 91/05/08 \charsubdefmax bug detected by Bernd Raichle |
| 2637 |
Because the user can change character substitutions or |
| 2638 |
\.{\\charsubdefmax} on the fly, we have to test a again |
| 2639 |
for valid substitutions. |
| 2640 |
% |
| 2641 |
% 93/10/29 \leaders bug detected by Eberhard Mattes |
| 2642 |
(Additional it is necessary to be careful---if leaders are used |
| 2643 |
the current hlist is normally traversed more than once!) |
| 2644 |
@^inner loop@> |
| 2645 |
@z |
| 2646 |
|
| 2647 |
@x [32.620] l.12373 - MLTeX: substitute character during |shipout| |
| 2648 |
if c>=qi(128) then dvi_out(set1); |
| 2649 |
dvi_out(qo(c));@/ |
| 2650 |
cur_h:=cur_h+char_width(f)(char_info(f)(c)); |
| 2651 |
@y |
| 2652 |
if font_ec[f]>=qo(c) then if font_bc[f]<=qo(c) then |
| 2653 |
if char_exists(orig_char_info(f)(c)) then {N.B.: not |char_info|} |
| 2654 |
begin if c>=qi(128) then dvi_out(set1); |
| 2655 |
dvi_out(qo(c));@/ |
| 2656 |
cur_h:=cur_h+char_width(f)(orig_char_info(f)(c)); |
| 2657 |
goto continue; |
| 2658 |
end; |
| 2659 |
if mltex_enabled_p then |
| 2660 |
@<Output a substitution, |goto continue| if not possible@>; |
| 2661 |
continue: |
| 2662 |
@z |
| 2663 |
|
| 2664 |
@x [32.621] l.12388 - more >256 font output stuff. |
| 2665 |
else begin dvi_out(fnt1); dvi_out(f-font_base-1); |
| 2666 |
end; |
| 2667 |
@y |
| 2668 |
else if f<=256+font_base then |
| 2669 |
begin dvi_out(fnt1); dvi_out(f-font_base-1); |
| 2670 |
end |
| 2671 |
else begin dvi_out(fnt1+1); |
| 2672 |
dvi_out((f-font_base-1) div @'400); |
| 2673 |
dvi_out((f-font_base-1) mod @'400); |
| 2674 |
end; |
| 2675 |
@z |
| 2676 |
|
| 2677 |
% We output each portion of the page as we get to it, if we are using |
| 2678 |
% IPC, so that the previewer (TeXView) can display it immediately. [SPM] |
| 2679 |
@x [32.640] l.12740 - IPC |
| 2680 |
done: |
| 2681 |
@y |
| 2682 |
ifdef ('IPC') |
| 2683 |
if ipc_on>0 then |
| 2684 |
begin if dvi_limit=half_buf then |
| 2685 |
begin write_dvi(half_buf, dvi_buf_size-1); |
| 2686 |
flush_dvi; |
| 2687 |
dvi_gone:=dvi_gone+half_buf; |
| 2688 |
end; |
| 2689 |
if dvi_ptr>(@"7FFFFFFF-dvi_offset) then |
| 2690 |
begin cur_s:=-2; |
| 2691 |
fatal_error("dvi length exceeds ""7FFFFFFF"); |
| 2692 |
@.dvi length exceeds...@> |
| 2693 |
end; |
| 2694 |
if dvi_ptr>0 then |
| 2695 |
begin write_dvi(0, dvi_ptr-1); |
| 2696 |
flush_dvi; |
| 2697 |
dvi_offset:=dvi_offset+dvi_ptr; dvi_gone:=dvi_gone+dvi_ptr; |
| 2698 |
end; |
| 2699 |
dvi_ptr:=0; dvi_limit:=dvi_buf_size; |
| 2700 |
ipc_page(dvi_gone); |
| 2701 |
end; |
| 2702 |
endif ('IPC'); |
| 2703 |
done: |
| 2704 |
@z |
| 2705 |
|
| 2706 |
@x [32.642] l.12783 - check dvi file size |
| 2707 |
else begin dvi_out(post); {beginning of the postamble} |
| 2708 |
@y |
| 2709 |
else if cur_s<>-2 then |
| 2710 |
begin dvi_out(post); {beginning of the postamble} |
| 2711 |
@z |
| 2712 |
|
| 2713 |
@x [32.642] l.12792 - Use dvi_offset instead of dvi_buf_size with IPC stuff. |
| 2714 |
k:=4+((dvi_buf_size-dvi_ptr) mod 4); {the number of 223's} |
| 2715 |
@y |
| 2716 |
ifdef ('IPC') |
| 2717 |
k:=7-((3+dvi_offset+dvi_ptr) mod 4); {the number of 223's} |
| 2718 |
endif ('IPC') |
| 2719 |
ifndef ('IPC') |
| 2720 |
k:=4+((dvi_buf_size-dvi_ptr) mod 4); {the number of 223's} |
| 2721 |
endifn ('IPC') |
| 2722 |
@z |
| 2723 |
|
| 2724 |
@x [32.642] l.12797 - use print_file_name |
| 2725 |
print_nl("Output written on "); slow_print(output_file_name); |
| 2726 |
@y |
| 2727 |
print_nl("Output written on "); print_file_name(0, output_file_name, 0); |
| 2728 |
@z |
| 2729 |
|
| 2730 |
@x [32.642] l.12799 - i18n fix |
| 2731 |
print(" ("); print_int(total_pages); print(" page"); |
| 2732 |
if total_pages<>1 then print_char("s"); |
| 2733 |
@y |
| 2734 |
print(" ("); print_int(total_pages); |
| 2735 |
if total_pages<>1 then print(" pages") |
| 2736 |
else print(" page"); |
| 2737 |
@z |
| 2738 |
|
| 2739 |
% The MLTeX changes never dealt with the problems of character |
| 2740 |
% substitutions in math mode. With the new additions in v2.2, |
| 2741 |
% non-existing characters between |font_bc[f]| and |font_ec[f]| |
| 2742 |
% can be substituted => we have to avoid this in math mode |
| 2743 |
% (for compatibility reasons and to avoid other problems). |
| 2744 |
% |
| 2745 |
@x [35.708] l.13954 - MLTeX: avoid substitution in |var_delimiter| |
| 2746 |
if (qo(y)>=font_bc[g])and(qo(y)<=font_ec[g]) then |
| 2747 |
begin continue: q:=char_info(g)(y); |
| 2748 |
@y |
| 2749 |
if (qo(y)>=font_bc[g])and(qo(y)<=font_ec[g]) then |
| 2750 |
begin continue: q:=orig_char_info(g)(y); |
| 2751 |
@z |
| 2752 |
|
| 2753 |
@x [36.722] l.14224 - MLTeX: avoid substitution in |fetch| |
| 2754 |
cur_i:=char_info(cur_f)(cur_c) |
| 2755 |
@y |
| 2756 |
cur_i:=orig_char_info(cur_f)(cur_c) |
| 2757 |
@z |
| 2758 |
|
| 2759 |
@x [36.740] l.14537 - MLTeX: avoid substitution in |make_math_accent| |
| 2760 |
i:=char_info(f)(y); |
| 2761 |
@y |
| 2762 |
i:=orig_char_info(f)(y); |
| 2763 |
@z |
| 2764 |
|
| 2765 |
@x [36.749] l.14689 - MLTeX: avoid substitution in |make_op| |
| 2766 |
begin c:=rem_byte(cur_i); i:=char_info(cur_f)(c); |
| 2767 |
@y |
| 2768 |
begin c:=rem_byte(cur_i); i:=orig_char_info(cur_f)(c); |
| 2769 |
@z |
| 2770 |
|
| 2771 |
% disabled in original tex-src-special.ch |
| 2772 |
@x [37.774] l.15291 - source specials |
| 2773 |
if every_cr<>null then begin_token_list(every_cr,every_cr_text); |
| 2774 |
@y |
| 2775 |
if (insert_src_special_every_cr and head<>tail) then insert_src_special; |
| 2776 |
if every_cr<>null then begin_token_list(every_cr,every_cr_text); |
| 2777 |
@z |
| 2778 |
|
| 2779 |
% disabled in original tex-source-special.ch |
| 2780 |
@x [37.799] l.15682 - source specials |
| 2781 |
if every_cr<>null then begin_token_list(every_cr,every_cr_text); |
| 2782 |
@y |
| 2783 |
if (insert_src_special_every_cr) then insert_src_special; |
| 2784 |
if every_cr<>null then begin_token_list(every_cr,every_cr_text); |
| 2785 |
@z |
| 2786 |
|
| 2787 |
@x [42.920] l.18111 - bigtrie: allow larger hyphenation tries. |
| 2788 |
Comparatively few different number sequences $n_0\ldots n_k$ actually occur, |
| 2789 |
since most of the |n|'s are generally zero. Therefore the number sequences |
| 2790 |
are encoded in such a way that |trie_op|$(z_k)$ is only one byte long. |
| 2791 |
If |trie_op(@t$z_k$@>)<>min_quarterword|, when $p_1\ldots p_k$ has matched |
| 2792 |
the letters in |hc[(l-k+1)..l@,]| of language |t|, |
| 2793 |
we perform all of the required operations |
| 2794 |
for this pattern by carrying out the following little program: Set |
| 2795 |
|v:=trie_op(@t$z_k$@>)|. Then set |v:=v+op_start[t]|, |
| 2796 |
|hyf[l-hyf_distance[v]]:=@tmax@>(hyf[l-hyf_distance[v]], hyf_num[v])|, |
| 2797 |
and |v:=hyf_next[v]|; repeat, if necessary, until |v=min_quarterword|. |
| 2798 |
@y |
| 2799 |
The theory that comparatively few different number sequences $n_0\ldots n_k$ |
| 2800 |
actually occur, since most of the |n|'s are generally zero, seems to fail |
| 2801 |
at least for the large German hyphenation patterns. |
| 2802 |
Therefore the number sequences cannot any longer be encoded in such a way |
| 2803 |
that |trie_op|$(z_k)$ is only one byte long. |
| 2804 |
We have introduced a new constant |max_trie_op| for the maximum allowable |
| 2805 |
hyphenation operation code value; |max_trie_op| might be different for |
| 2806 |
\TeX\ and \.{INITEX} and must not exceed |max_halfword|. |
| 2807 |
An opcode will occupy a halfword if |max_trie_op| exceeds |max_quarterword| |
| 2808 |
or a quarterword otherwise. |
| 2809 |
@^system dependencies@> |
| 2810 |
If |trie_op(@t$z_k$@>)<>min_trie_op|, when $p_1\ldots p_k$ has matched |
| 2811 |
the letters in |hc[(l-k+1)..l@,]| of language |t|, |
| 2812 |
we perform all of the required operations |
| 2813 |
for this pattern by carrying out the following little program: Set |
| 2814 |
|v:=trie_op(@t$z_k$@>)|. Then set |v:=v+op_start[t]|, |
| 2815 |
|hyf[l-hyf_distance[v]]:=@tmax@>(hyf[l-hyf_distance[v]], hyf_num[v])|, |
| 2816 |
and |v:=hyf_next[v]|; repeat, if necessary, until |v=min_trie_op|. |
| 2817 |
@z |
| 2818 |
|
| 2819 |
@x [42.920] l.18123 - bigtrie: allow larger hyphenation tries. |
| 2820 |
@!trie_pointer=0..trie_size; {an index into |trie|} |
| 2821 |
@y |
| 2822 |
@!trie_pointer=0..ssup_trie_size; {an index into |trie|} |
| 2823 |
@!trie_opcode=0..ssup_trie_opcode; {a trie opcode} |
| 2824 |
@z |
| 2825 |
|
| 2826 |
@x [42.921] l.18125 - bigtrie: allow larger hyphenation tries. |
| 2827 |
@ @d trie_link(#)==trie[#].rh {``downward'' link in a trie} |
| 2828 |
@d trie_char(#)==trie[#].b1 {character matched at this trie location} |
| 2829 |
@d trie_op(#)==trie[#].b0 {program for hyphenation at this trie location} |
| 2830 |
@y |
| 2831 |
@ For more than 255 trie op codes, the three fields |trie_link|, |trie_char|, |
| 2832 |
and |trie_op| will no longer fit into one memory word; thus using web2c |
| 2833 |
we define |trie| as three array instead of an array of records. |
| 2834 |
The variant will be implemented by reusing the opcode field later on with |
| 2835 |
another macro. |
| 2836 |
|
| 2837 |
@d trie_link(#)==trie_trl[#] {``downward'' link in a trie} |
| 2838 |
@d trie_char(#)==trie_trc[#] {character matched at this trie location} |
| 2839 |
@d trie_op(#)==trie_tro[#] {program for hyphenation at this trie location} |
| 2840 |
@z |
| 2841 |
|
| 2842 |
@x [42.921] l.18130 - bigtrie: allow larger hyphenation tries. |
| 2843 |
@!trie:array[trie_pointer] of two_halves; {|trie_link|, |trie_char|, |trie_op|} |
| 2844 |
@y |
| 2845 |
{We will dynamically allocate these arrays.} |
| 2846 |
@!trie_trl:^trie_pointer; {|trie_link|} |
| 2847 |
@!trie_tro:^trie_pointer; {|trie_op|} |
| 2848 |
@!trie_trc:^quarterword; {|trie_char|} |
| 2849 |
@z |
| 2850 |
|
| 2851 |
@x [42.921] l.18133 - bigtrie: allow larger hyphenation tries. |
| 2852 |
@!hyf_next:array[1..trie_op_size] of quarterword; {continuation code} |
| 2853 |
@y |
| 2854 |
@!hyf_next:array[1..trie_op_size] of trie_opcode; {continuation code} |
| 2855 |
@z |
| 2856 |
|
| 2857 |
@x [42.923] l.18154 - bigtrie: allow larger hyphenation tries. |
| 2858 |
begin if trie_op(z)<>min_quarterword then |
| 2859 |
@y |
| 2860 |
begin if trie_op(z)<>min_trie_op then |
| 2861 |
@z |
| 2862 |
|
| 2863 |
@x [42.924] l.18167 - bigtrie: allow larger hyphenation tries. |
| 2864 |
until v=min_quarterword; |
| 2865 |
@y |
| 2866 |
until v=min_trie_op; |
| 2867 |
@z |
| 2868 |
|
| 2869 |
%%%%%%%% dynamic hyph_size |
| 2870 |
@x [42.925] l.18181 |
| 2871 |
different from $\alpha$, we can conclude that $\alpha$ is not in the table. |
| 2872 |
@y |
| 2873 |
different from $\alpha$, we can conclude that $\alpha$ is not in the table. |
| 2874 |
This is a clever scheme which saves the need for a hash link array. |
| 2875 |
However, it is difficult to increase the size of the hyphen exception |
| 2876 |
arrays. To make this easier, the ordered hash has been replaced by |
| 2877 |
a simple hash, using an additional array |hyph_link|. The value |
| 2878 |
|0| in |hyph_link[k]| means that there are no more entries corresponding |
| 2879 |
to the specific hash chain. When |hyph_link[k]>0|, the next entry in |
| 2880 |
the hash chain is |hyph_link[k]-1|. This value is used because the |
| 2881 |
arrays start at |0|. |
| 2882 |
@z |
| 2883 |
|
| 2884 |
%%%%%%%% dynamic hyph_size |
| 2885 |
@x [42.925] l.18189 |
| 2886 |
@!hyph_pointer=0..hyph_size; {an index into the ordered hash table} |
| 2887 |
@y |
| 2888 |
@!hyph_pointer=0..ssup_hyph_size; {index into hyphen exceptions hash table; |
| 2889 |
enlarging this requires changing (un)dump code} |
| 2890 |
@z |
| 2891 |
|
| 2892 |
%%%%%%%% dynamic hyph_size |
| 2893 |
@x [42.926] l.18192 |
| 2894 |
@!hyph_word:array[hyph_pointer] of str_number; {exception words} |
| 2895 |
@!hyph_list:array[hyph_pointer] of pointer; {lists of hyphen positions} |
| 2896 |
@!hyph_count:hyph_pointer; {the number of words in the exception dictionary} |
| 2897 |
@y |
| 2898 |
@!hyph_word: ^str_number; {exception words} |
| 2899 |
@!hyph_list: ^pointer; {lists of hyphen positions} |
| 2900 |
@!hyph_link: ^hyph_pointer; {link array for hyphen exceptions hash table} |
| 2901 |
@!hyph_count:integer; {the number of words in the exception dictionary} |
| 2902 |
@!hyph_next:integer; {next free slot in hyphen exceptions hash table} |
| 2903 |
@z |
| 2904 |
|
| 2905 |
%%%%%%%% dynamic hyph_size |
| 2906 |
@x [42.928] l.18200 |
| 2907 |
for z:=0 to hyph_size do |
| 2908 |
begin hyph_word[z]:=0; hyph_list[z]:=null; |
| 2909 |
end; |
| 2910 |
hyph_count:=0; |
| 2911 |
@y |
| 2912 |
for z:=0 to hyph_size do |
| 2913 |
begin hyph_word[z]:=0; hyph_list[z]:=null; hyph_link[z]:=0; |
| 2914 |
end; |
| 2915 |
hyph_count:=0; |
| 2916 |
hyph_next:=hyph_prime+1; if hyph_next>hyph_size then hyph_next:=hyph_prime; |
| 2917 |
@z |
| 2918 |
|
| 2919 |
%%%%%%%% dynamic hyph_size |
| 2920 |
@x [42.930] l.18218 |
| 2921 |
h:=hc[1]; incr(hn); hc[hn]:=cur_lang; |
| 2922 |
for j:=2 to hn do h:=(h+h+hc[j]) mod hyph_size; |
| 2923 |
loop@+ begin @<If the string |hyph_word[h]| is less than \(hc)|hc[1..hn]|, |
| 2924 |
|goto not_found|; but if the two strings are equal, |
| 2925 |
set |hyf| to the hyphen positions and |goto found|@>; |
| 2926 |
if h>0 then decr(h)@+else h:=hyph_size; |
| 2927 |
end; |
| 2928 |
not_found: decr(hn) |
| 2929 |
@y |
| 2930 |
h:=hc[1]; incr(hn); hc[hn]:=cur_lang; |
| 2931 |
for j:=2 to hn do h:=(h+h+hc[j]) mod hyph_prime; |
| 2932 |
loop@+ begin @<If the string |hyph_word[h]| is less than \(hc)|hc[1..hn]|, |
| 2933 |
|goto not_found|; but if the two strings are equal, |
| 2934 |
set |hyf| to the hyphen positions and |goto found|@>; |
| 2935 |
h:=hyph_link[h]; if h=0 then goto not_found; |
| 2936 |
decr(h); |
| 2937 |
end; |
| 2938 |
not_found: decr(hn) |
| 2939 |
@z |
| 2940 |
|
| 2941 |
@x [42.931] l.18227 - dynamic hyph_size |
| 2942 |
@ @<If the string |hyph_word[h]| is less than \(hc)...@>= |
| 2943 |
k:=hyph_word[h]; if k=0 then goto not_found; |
| 2944 |
if length(k)<hn then goto not_found; |
| 2945 |
@y |
| 2946 |
@ @<If the string |hyph_word[h]| is less than \(hc)...@>= |
| 2947 |
{This is now a simple hash list, not an ordered one, so |
| 2948 |
the module title is no longer descriptive.} |
| 2949 |
k:=hyph_word[h]; if k=0 then goto not_found; |
| 2950 |
@z |
| 2951 |
|
| 2952 |
@x [42.931] l.18232 - dynamic hyph_size |
| 2953 |
repeat if so(str_pool[u])<hc[j] then goto not_found; |
| 2954 |
if so(str_pool[u])>hc[j] then goto done; |
| 2955 |
@y |
| 2956 |
repeat |
| 2957 |
if so(str_pool[u])<>hc[j] then goto done; |
| 2958 |
@z |
| 2959 |
|
| 2960 |
%%%%%%%% dynamic hyph_size |
| 2961 |
@x [42.934] l.18273 |
| 2962 |
@!s,@!t:str_number; {strings being compared or stored} |
| 2963 |
@y |
| 2964 |
@!s:str_number; {strings being compared or stored} |
| 2965 |
@z |
| 2966 |
|
| 2967 |
%%%%%%%% dynamic hyph_size |
| 2968 |
@x [42.939] l.18329 |
| 2969 |
begin h:=(h+h+hc[j]) mod hyph_size; |
| 2970 |
@y |
| 2971 |
begin h:=(h+h+hc[j]) mod hyph_prime; |
| 2972 |
@z |
| 2973 |
|
| 2974 |
%%%%%%%% dynamic hyph_size |
| 2975 |
@x [42.940] l.18336 |
| 2976 |
@ @<Insert the \(p)pair |(s,p)|...@>= |
| 2977 |
if hyph_count=hyph_size then overflow("exception dictionary",hyph_size); |
| 2978 |
@:TeX capacity exceeded exception dictionary}{\quad exception dictionary@> |
| 2979 |
incr(hyph_count); |
| 2980 |
while hyph_word[h]<>0 do |
| 2981 |
begin @<If the string |hyph_word[h]| is less than \(or)or equal to |
| 2982 |
|s|, interchange |(hyph_word[h],hyph_list[h])| with |(s,p)|@>; |
| 2983 |
if h>0 then decr(h)@+else h:=hyph_size; |
| 2984 |
end; |
| 2985 |
hyph_word[h]:=s; hyph_list[h]:=p |
| 2986 |
@y |
| 2987 |
@ @<Insert the \(p)pair |(s,p)|...@>= |
| 2988 |
if hyph_next <= hyph_prime then |
| 2989 |
while (hyph_next>0) and (hyph_word[hyph_next-1]>0) do decr(hyph_next); |
| 2990 |
if (hyph_count=hyph_size)or(hyph_next=0) then |
| 2991 |
overflow("exception dictionary",hyph_size); |
| 2992 |
@:TeX capacity exceeded exception dictionary}{\quad exception dictionary@> |
| 2993 |
incr(hyph_count); |
| 2994 |
while hyph_word[h]<>0 do |
| 2995 |
begin @<If the string |hyph_word[h]| is less than \(or)or equal to |
| 2996 |
|s|, interchange |(hyph_word[h],hyph_list[h])| with |(s,p)|@>; |
| 2997 |
if hyph_link[h]=0 then |
| 2998 |
begin |
| 2999 |
hyph_link[h]:=hyph_next; |
| 3000 |
if hyph_next >= hyph_size then hyph_next:=hyph_prime; |
| 3001 |
if hyph_next > hyph_prime then incr(hyph_next); |
| 3002 |
end; |
| 3003 |
h:=hyph_link[h]-1; |
| 3004 |
end; |
| 3005 |
|
| 3006 |
found: hyph_word[h]:=s; hyph_list[h]:=p |
| 3007 |
@z |
| 3008 |
|
| 3009 |
@x [42.941] l.18347 - dynamic hyph_size |
| 3010 |
@ @<If the string |hyph_word[h]| is less than \(or)...@>= |
| 3011 |
k:=hyph_word[h]; |
| 3012 |
if length(k)<length(s) then goto found; |
| 3013 |
if length(k)>length(s) then goto not_found; |
| 3014 |
@y |
| 3015 |
@ @<If the string |hyph_word[h]| is less than \(or)...@>= |
| 3016 |
{This is now a simple hash list, not an ordered one, so |
| 3017 |
the module title is no longer descriptive.} |
| 3018 |
k:=hyph_word[h]; |
| 3019 |
if length(k)<>length(s) then goto not_found; |
| 3020 |
@z |
| 3021 |
|
| 3022 |
@x [42.941] l.18352 - dynamic hyph_size |
| 3023 |
repeat if str_pool[u]<str_pool[v] then goto found; |
| 3024 |
if str_pool[u]>str_pool[v] then goto not_found; |
| 3025 |
@y |
| 3026 |
repeat if str_pool[u]<>str_pool[v] then goto not_found; |
| 3027 |
@z |
| 3028 |
|
| 3029 |
@x [42.941] l.18356 - dynamic hyph_size |
| 3030 |
found:q:=hyph_list[h]; hyph_list[h]:=p; p:=q;@/ |
| 3031 |
t:=hyph_word[h]; hyph_word[h]:=s; s:=t; |
| 3032 |
not_found: |
| 3033 |
@y |
| 3034 |
{repeat hyphenation exception; flushing old data} |
| 3035 |
flush_string; s:=hyph_word[h]; {avoid |slow_make_string|!} |
| 3036 |
decr(hyph_count); |
| 3037 |
{ We could also |flush_list(hyph_list[h]);|, but it interferes |
| 3038 |
with \.{trip.log}. } |
| 3039 |
goto found; |
| 3040 |
not_found: |
| 3041 |
@z |
| 3042 |
|
| 3043 |
@x [43.943] l.18387 - bigtrie: Larger tries, also in documentation parts. |
| 3044 |
|hyf_next[@t$v^\prime$@>]=min_quarterword|. |
| 3045 |
@y |
| 3046 |
|hyf_next[@t$v^\prime$@>]=min_trie_op|. |
| 3047 |
@z |
| 3048 |
|
| 3049 |
@x [43.943] l.18391 - bigtrie: Larger tries, also in documentation parts. |
| 3050 |
$$\hbox{|@t$v^\prime$@>:=new_trie_op(0,1,min_quarterword)|,\qquad |
| 3051 |
@y |
| 3052 |
$$\hbox{|@t$v^\prime$@>:=new_trie_op(0,1,min_trie_op)|,\qquad |
| 3053 |
@z |
| 3054 |
|
| 3055 |
@x [43.943] l.18401 - web2c can't parse negative lower bounds in arrays. Sorry. |
| 3056 |
@!init @!trie_op_hash:array[-trie_op_size..trie_op_size] of 0..trie_op_size; |
| 3057 |
@y |
| 3058 |
@!init @!trie_op_hash:array[neg_trie_op_size..trie_op_size] of 0..trie_op_size; |
| 3059 |
@z |
| 3060 |
|
| 3061 |
@x [43.943] l.18403 - bigtrie: Larger hyphenation tries. |
| 3062 |
@!trie_used:array[ASCII_code] of quarterword; |
| 3063 |
@y |
| 3064 |
@!trie_used:array[ASCII_code] of trie_opcode; |
| 3065 |
@z |
| 3066 |
|
| 3067 |
@x [43.943] l.18407 - bigtrie: Larger hyphenation tries. |
| 3068 |
@!trie_op_val:array[1..trie_op_size] of quarterword; |
| 3069 |
@y |
| 3070 |
@!trie_op_val:array[1..trie_op_size] of trie_opcode; |
| 3071 |
@z |
| 3072 |
|
| 3073 |
@x [43.943] l.18410 - Dynamic trie arrays |
| 3074 |
tini |
| 3075 |
@y |
| 3076 |
tini@; |
| 3077 |
@!max_op_used:trie_opcode; {largest opcode used for any language} |
| 3078 |
@!small_op:boolean; {flag used while dumping or undumping} |
| 3079 |
@z |
| 3080 |
|
| 3081 |
@x [43.944] l.18413 - bigtrie: Larger tries, also in documentation parts. |
| 3082 |
|new_trie_op| could return |min_quarterword| (thereby simply ignoring |
| 3083 |
@y |
| 3084 |
|new_trie_op| could return |min_trie_op| (thereby simply ignoring |
| 3085 |
@z |
| 3086 |
|
| 3087 |
@x [43.944] l.18420 - bigtrie: Larger hyphenation tries. |
| 3088 |
function new_trie_op(@!d,@!n:small_number;@!v:quarterword):quarterword; |
| 3089 |
label exit; |
| 3090 |
var h:-trie_op_size..trie_op_size; {trial hash location} |
| 3091 |
@!u:quarterword; {trial op code} |
| 3092 |
@y |
| 3093 |
function new_trie_op(@!d,@!n:small_number;@!v:trie_opcode):trie_opcode; |
| 3094 |
label exit; |
| 3095 |
var h:neg_trie_op_size..trie_op_size; {trial hash location} |
| 3096 |
@!u:trie_opcode; {trial op code} |
| 3097 |
@z |
| 3098 |
|
| 3099 |
@x [43.944] l.18425 - Another casting problem, and use |neg_trie_op_size|. |
| 3100 |
begin h:=abs(n+313*d+361*v+1009*cur_lang) mod (trie_op_size+trie_op_size) |
| 3101 |
- trie_op_size; |
| 3102 |
@y |
| 3103 |
begin h:=abs(n+313*d+361*v+1009*cur_lang) mod (trie_op_size-neg_trie_op_size) |
| 3104 |
+ neg_trie_op_size; |
| 3105 |
@z |
| 3106 |
|
| 3107 |
@x [43.944] l.18432 - bigtrie: And larger tries again. |
| 3108 |
if u=max_quarterword then |
| 3109 |
overflow("pattern memory ops per language", |
| 3110 |
max_quarterword-min_quarterword); |
| 3111 |
incr(trie_op_ptr); incr(u); trie_used[cur_lang]:=u; |
| 3112 |
@y |
| 3113 |
if u=max_trie_op then |
| 3114 |
overflow("pattern memory ops per language", |
| 3115 |
max_trie_op-min_trie_op); |
| 3116 |
incr(trie_op_ptr); incr(u); trie_used[cur_lang]:=u; |
| 3117 |
if u>max_op_used then max_op_used:=u; |
| 3118 |
@z |
| 3119 |
|
| 3120 |
@x [43.945] l.18454 - bigtrie: And larger tries again. |
| 3121 |
op_start[0]:=-min_quarterword; |
| 3122 |
@y |
| 3123 |
op_start[0]:=-min_trie_op; |
| 3124 |
@z |
| 3125 |
|
| 3126 |
@x [43.946] l.18471 - bigtrie: And larger tries again. |
| 3127 |
for k:=0 to 255 do trie_used[k]:=min_quarterword; |
| 3128 |
@y |
| 3129 |
for k:=0 to 255 do trie_used[k]:=min_trie_op; |
| 3130 |
@z |
| 3131 |
|
| 3132 |
@x [43.946] l.18472 - Dynamic trie arrays. |
| 3133 |
trie_op_ptr:=0; |
| 3134 |
@y |
| 3135 |
max_op_used:=min_trie_op; |
| 3136 |
trie_op_ptr:=0; |
| 3137 |
@z |
| 3138 |
|
| 3139 |
@x [43.947] l.18493 - Dynamically allocate arrays, and a casting problem. |
| 3140 |
@!init @!trie_c:packed array[trie_pointer] of packed_ASCII_code; |
| 3141 |
{characters to match} |
| 3142 |
@t\hskip10pt@>@!trie_o:packed array[trie_pointer] of quarterword; |
| 3143 |
{operations to perform} |
| 3144 |
@t\hskip10pt@>@!trie_l:packed array[trie_pointer] of trie_pointer; |
| 3145 |
{left subtrie links} |
| 3146 |
@t\hskip10pt@>@!trie_r:packed array[trie_pointer] of trie_pointer; |
| 3147 |
{right subtrie links} |
| 3148 |
@t\hskip10pt@>@!trie_ptr:trie_pointer; {the number of nodes in the trie} |
| 3149 |
@t\hskip10pt@>@!trie_hash:packed array[trie_pointer] of trie_pointer; |
| 3150 |
{used to identify equivalent subtries} |
| 3151 |
tini |
| 3152 |
@y |
| 3153 |
@!init @!trie_c:^packed_ASCII_code; |
| 3154 |
{characters to match} |
| 3155 |
@t\hskip10pt@>@!trie_o:^trie_opcode; |
| 3156 |
{operations to perform} |
| 3157 |
@t\hskip10pt@>@!trie_l:^trie_pointer; |
| 3158 |
{left subtrie links} |
| 3159 |
@t\hskip10pt@>@!trie_r:^trie_pointer; |
| 3160 |
{right subtrie links} |
| 3161 |
@t\hskip10pt@>@!trie_ptr:trie_pointer; {the number of nodes in the trie} |
| 3162 |
@t\hskip10pt@>@!trie_hash:^trie_pointer; |
| 3163 |
{used to identify equivalent subtries} |
| 3164 |
tini |
| 3165 |
@z |
| 3166 |
|
| 3167 |
@x [43.950] l.18576 - Dynamically allocate & larger tries. |
| 3168 |
@d trie_back(#)==trie[#].lh {backward links in |trie| holes} |
| 3169 |
@y |
| 3170 |
@d trie_back(#)==trie_tro[#] {use the opcode field now for backward links} |
| 3171 |
@z |
| 3172 |
|
| 3173 |
@x [43.950] l.18579 - Dynamically allocate & larger tries. |
| 3174 |
@!init @!trie_taken:packed array[1..trie_size] of boolean; |
| 3175 |
{does a family start here?} |
| 3176 |
@t\hskip10pt@>@!trie_min:array[ASCII_code] of trie_pointer; |
| 3177 |
{the first possible slot for each character} |
| 3178 |
@t\hskip10pt@>@!trie_max:trie_pointer; {largest location used in |trie|} |
| 3179 |
@t\hskip10pt@>@!trie_not_ready:boolean; {is the trie still in linked form?} |
| 3180 |
tini |
| 3181 |
@y |
| 3182 |
@!init @!trie_taken: ^boolean; |
| 3183 |
{does a family start here?} |
| 3184 |
@t\hskip10pt@>@!trie_min:array[ASCII_code] of trie_pointer; |
| 3185 |
{the first possible slot for each character} |
| 3186 |
@t\hskip10pt@>@!trie_max:trie_pointer; {largest location used in |trie|} |
| 3187 |
@t\hskip10pt@>@!trie_not_ready:boolean; {is the trie still in linked form?} |
| 3188 |
tini |
| 3189 |
@z |
| 3190 |
|
| 3191 |
@x [43.951] l.18594 - Dynamically allocate. |
| 3192 |
trie_not_ready:=true; trie_root:=0; trie_c[0]:=si(0); trie_ptr:=0; |
| 3193 |
@y |
| 3194 |
trie_not_ready:=true; |
| 3195 |
@z |
| 3196 |
|
| 3197 |
@x [43.958] l.18689 - bigtrie: Larger tries. |
| 3198 |
@<Move the data into |trie|@>= |
| 3199 |
h.rh:=0; h.b0:=min_quarterword; h.b1:=min_quarterword; {|trie_link:=0|, |
| 3200 |
|trie_op:=min_quarterword|, |trie_char:=qi(0)|} |
| 3201 |
@y |
| 3202 |
@d clear_trie == {clear |trie[r]|} |
| 3203 |
begin trie_link(r):=0; |
| 3204 |
trie_op(r):=min_trie_op; |
| 3205 |
trie_char(r):=min_quarterword; {|trie_char:=qi(0)|} |
| 3206 |
end |
| 3207 |
|
| 3208 |
@<Move the data into |trie|@>= |
| 3209 |
@z |
| 3210 |
|
| 3211 |
@x [43.958] l.18693 - bigtrie: Larger tries. |
| 3212 |
begin for r:=0 to 256 do trie[r]:=h; |
| 3213 |
@y |
| 3214 |
begin for r:=0 to 256 do clear_trie; |
| 3215 |
@z |
| 3216 |
|
| 3217 |
@x [43.958] l.18698 - bigtrie: Larger tries. |
| 3218 |
repeat s:=trie_link(r); trie[r]:=h; r:=s; |
| 3219 |
@y |
| 3220 |
repeat s:=trie_link(r); clear_trie; r:=s; |
| 3221 |
@z |
| 3222 |
|
| 3223 |
@x [43.960] l.18732 - bigtrie: Larger tries. |
| 3224 |
@!v:quarterword; {trie op code} |
| 3225 |
@y |
| 3226 |
@!v:trie_opcode; {trie op code} |
| 3227 |
@z |
| 3228 |
|
| 3229 |
@x [43.963] l.18804 - bigtrie: Larger tries. |
| 3230 |
if trie_o[q]<>min_quarterword then |
| 3231 |
@y |
| 3232 |
if trie_o[q]<>min_trie_op then |
| 3233 |
@z |
| 3234 |
|
| 3235 |
@x [43.964] l.18817 - bigtrie: Larger tries. |
| 3236 |
trie_c[p]:=si(c); trie_o[p]:=min_quarterword; |
| 3237 |
@y |
| 3238 |
trie_c[p]:=si(c); trie_o[p]:=min_trie_op; |
| 3239 |
@z |
| 3240 |
|
| 3241 |
@x [43.965] l.18823 - bigtrie: Larger tries. |
| 3242 |
l:=k; v:=min_quarterword; |
| 3243 |
@y |
| 3244 |
l:=k; v:=min_trie_op; |
| 3245 |
@z |
| 3246 |
|
| 3247 |
@x [43.966] l.18841 - bigtrie: Larger tries. |
| 3248 |
@!h:two_halves; {template used to zero out |trie|'s holes} |
| 3249 |
@y |
| 3250 |
@z |
| 3251 |
|
| 3252 |
%% |
| 3253 |
%% We can rewrite the original code after "main_loop_move+2" upto the |
| 3254 |
%% "tail_append(lig_stack)" in module 1036 as |
| 3255 |
%% |
| 3256 |
% |
| 3257 |
% main_loop_move+2: |
| 3258 |
% if font_bc[main_f]<=cur_chr then |
| 3259 |
% if cur_chr<=font_ec[main_f] then |
| 3260 |
% begin main_i:=char_info(main_f)(cur_l); |
| 3261 |
% if char_exists(main_i) goto main_loop_move+3; |
| 3262 |
% end; |
| 3263 |
% char_warning(main_f,cur_chr); free_avail(lig_stack); goto big_switch; |
| 3264 |
% main_loop_move+3: |
| 3265 |
% tail_append(lig_stack) {|main_loop_lookahead| is next} |
| 3266 |
% |
| 3267 |
%% |
| 3268 |
%% We can use the rewritten code above to include additional MLTeX |
| 3269 |
%% specific parts in the future. Additionally it can be used when |
| 3270 |
%% optimizing |main_control| to minimize the call of the function |
| 3271 |
%% |effective_char|. |
| 3272 |
%% |
| 3273 |
% |
| 3274 |
%@x [46.1030] l.19977 - MLTeX: substitution in |main_control| |
| 3275 |
% main_loop_move,main_loop_move+1,main_loop_move+2,main_loop_move_lig, |
| 3276 |
%@y |
| 3277 |
% main_loop_move,main_loop_move+1,main_loop_move+2,main_loop_move+3, |
| 3278 |
% main_loop_move_lig, |
| 3279 |
%@z |
| 3280 |
|
| 3281 |
@x [46.1034] l.20132 - source specials |
| 3282 |
@<Append character |cur_chr|...@>= |
| 3283 |
@y |
| 3284 |
@<Append character |cur_chr|...@>= |
| 3285 |
if ((head=tail) and (mode>0)) then begin |
| 3286 |
if (insert_src_special_auto) then append_src_special; |
| 3287 |
end; |
| 3288 |
@z |
| 3289 |
|
| 3290 |
@x [46.1036] l.20198 - MLTeX: substitution in |main_control| |
| 3291 |
main_loop_move+2:if(cur_chr<font_bc[main_f])or(cur_chr>font_ec[main_f]) then |
| 3292 |
@y |
| 3293 |
main_loop_move+2: |
| 3294 |
if(qo(effective_char(false,main_f,qi(cur_chr)))>font_ec[main_f])or |
| 3295 |
(qo(effective_char(false,main_f,qi(cur_chr)))<font_bc[main_f]) then |
| 3296 |
@z |
| 3297 |
|
| 3298 |
@x [46.1036] l.20201 - MLTeX: substitution in |main_control| |
| 3299 |
main_i:=char_info(main_f)(cur_l); |
| 3300 |
@y |
| 3301 |
main_i:=effective_char_info(main_f,cur_l); |
| 3302 |
@z |
| 3303 |
|
| 3304 |
@x [46.1049] l.20440 - i18n fix, see change to [16.211] |
| 3305 |
print("' in "); print_mode(mode); |
| 3306 |
@y |
| 3307 |
print_in_mode(mode); |
| 3308 |
@z |
| 3309 |
|
| 3310 |
% disabled in original tex-src-special.ch |
| 3311 |
@x [47.1083] l.20966 - source specials |
| 3312 |
if every_vbox<>null then begin_token_list(every_vbox,every_vbox_text); |
| 3313 |
@y |
| 3314 |
if (insert_src_special_every_vbox) then insert_src_special; |
| 3315 |
if every_vbox<>null then begin_token_list(every_vbox,every_vbox_text); |
| 3316 |
@z |
| 3317 |
|
| 3318 |
% disabled in original tex-src-special.ch |
| 3319 |
@x [47.1083] l.20969 - source specials |
| 3320 |
if every_hbox<>null then begin_token_list(every_hbox,every_hbox_text); |
| 3321 |
@y |
| 3322 |
if (insert_src_special_every_hbox) then insert_src_special; |
| 3323 |
if every_hbox<>null then begin_token_list(every_hbox,every_hbox_text); |
| 3324 |
@z |
| 3325 |
|
| 3326 |
@x [47.1091] l.21124 - source specials |
| 3327 |
if indented then |
| 3328 |
begin tail:=new_null_box; link(head):=tail; width(tail):=par_indent;@+ |
| 3329 |
end; |
| 3330 |
@y |
| 3331 |
if indented then |
| 3332 |
begin tail:=new_null_box; link(head):=tail; width(tail):=par_indent; |
| 3333 |
if (insert_src_special_every_par) then insert_src_special;@+ |
| 3334 |
end; |
| 3335 |
@z |
| 3336 |
|
| 3337 |
% disabled in original tex-src-special.ch, conflicts with etex. |
| 3338 |
@x [47.1096] l.21121 - source specials |
| 3339 |
else line_break(widow_penalty); |
| 3340 |
@y |
| 3341 |
else begin |
| 3342 |
if (insert_src_special_every_parend) then insert_src_special; |
| 3343 |
line_break(widow_penalty); |
| 3344 |
end; |
| 3345 |
@z |
| 3346 |
|
| 3347 |
@x [48.1139] l.21722 - source specials |
| 3348 |
if every_math<>null then begin_token_list(every_math,every_math_text); |
| 3349 |
@y |
| 3350 |
if (insert_src_special_every_math) then insert_src_special; |
| 3351 |
if every_math<>null then begin_token_list(every_math,every_math_text); |
| 3352 |
@z |
| 3353 |
|
| 3354 |
% disabled in original tex-src-special.ch |
| 3355 |
@x [48.1145] l.21705 - source specials |
| 3356 |
if every_display<>null then begin_token_list(every_display,every_display_text); |
| 3357 |
@y |
| 3358 |
if (insert_src_special_every_display) then append_src_special; |
| 3359 |
if every_display<>null then begin_token_list(every_display,every_display_text); |
| 3360 |
@z |
| 3361 |
|
| 3362 |
@x [48.1167] l.22114 - source specials |
| 3363 |
if every_vbox<>null then begin_token_list(every_vbox,every_vbox_text); |
| 3364 |
@y |
| 3365 |
if (insert_src_special_every_vbox) then insert_src_special; |
| 3366 |
if every_vbox<>null then begin_token_list(every_vbox,every_vbox_text); |
| 3367 |
@z |
| 3368 |
|
| 3369 |
@x [49.1215] l.22793 - hash_extra |
| 3370 |
if (cur_cs=0)or(cur_cs>frozen_control_sequence) then |
| 3371 |
@y |
| 3372 |
if (cur_cs=0)or(cur_cs>eqtb_top)or |
| 3373 |
((cur_cs>frozen_control_sequence)and(cur_cs<=eqtb_size)) then |
| 3374 |
@z |
| 3375 |
|
| 3376 |
@x [49.1222] l.22869 - MLTeX: \charsubdef primitive |
| 3377 |
@d toks_def_code=6 {|shorthand_def| for \.{\\toksdef}} |
| 3378 |
@y |
| 3379 |
@d toks_def_code=6 {|shorthand_def| for \.{\\toksdef}} |
| 3380 |
@d char_sub_def_code=7 {|shorthand_def| for \.{\\charsubdef}} |
| 3381 |
@z |
| 3382 |
|
| 3383 |
@x [49.1222] l.22885 - MLTeX: \charsubdef primitive |
| 3384 |
@!@:toks_def_}{\.{\\toksdef} primitive@> |
| 3385 |
@y |
| 3386 |
@!@:toks_def_}{\.{\\toksdef} primitive@> |
| 3387 |
if mltex_p then |
| 3388 |
begin |
| 3389 |
primitive("charsubdef",shorthand_def,char_sub_def_code);@/ |
| 3390 |
@!@:char_sub_def_}{\.{\\charsubdef} primitive@> |
| 3391 |
end; |
| 3392 |
@z |
| 3393 |
|
| 3394 |
@x [49.1223] l.22895 - MLTeX: \charsubdef primitive |
| 3395 |
othercases print_esc("toksdef") |
| 3396 |
@y |
| 3397 |
char_sub_def_code: print_esc("charsubdef"); |
| 3398 |
othercases print_esc("toksdef") |
| 3399 |
@z |
| 3400 |
|
| 3401 |
@x [49.1224] l.22908 - MLTeX: \charsubdef primitive |
| 3402 |
shorthand_def: begin n:=cur_chr; get_r_token; p:=cur_cs; define(p,relax,256); |
| 3403 |
@y |
| 3404 |
shorthand_def: if cur_chr=char_sub_def_code then |
| 3405 |
begin scan_char_num; p:=char_sub_code_base+cur_val; scan_optional_equals; |
| 3406 |
scan_char_num; n:=cur_val; {accent character in substitution} |
| 3407 |
scan_char_num; |
| 3408 |
if (tracing_char_sub_def>0) then |
| 3409 |
begin begin_diagnostic; print_nl("New character substitution: "); |
| 3410 |
print_ASCII(p-char_sub_code_base); print(" = "); |
| 3411 |
print_ASCII(n); print_char(" "); |
| 3412 |
print_ASCII(cur_val); end_diagnostic(false); |
| 3413 |
end; |
| 3414 |
n:=n*256+cur_val; |
| 3415 |
define(p,data,hi(n)); |
| 3416 |
if (p-char_sub_code_base)<char_sub_def_min then |
| 3417 |
word_define(int_base+char_sub_def_min_code,p-char_sub_code_base); |
| 3418 |
if (p-char_sub_code_base)>char_sub_def_max then |
| 3419 |
word_define(int_base+char_sub_def_max_code,p-char_sub_code_base); |
| 3420 |
end |
| 3421 |
else begin n:=cur_chr; get_r_token; p:=cur_cs; define(p,relax,256); |
| 3422 |
@z |
| 3423 |
|
| 3424 |
@x [49.1252] l.23309 - INI = VIR, so have to do runtime test. |
| 3425 |
begin @!init new_patterns; goto done;@;@+tini@/ |
| 3426 |
@y |
| 3427 |
begin @!Init new_patterns; goto done;@;@+Tini@/ |
| 3428 |
@z |
| 3429 |
|
| 3430 |
% undo Knuth's change because |
| 3431 |
% a) the string is already replaced in |scan_file_name| and therefore |
| 3432 |
% b) the wrong string will get flushed!!! |
| 3433 |
% |
| 3434 |
@x [49.1257] l.23354 - unused variable |
| 3435 |
@!flushable_string:str_number; {string not yet referenced} |
| 3436 |
@y |
| 3437 |
@z |
| 3438 |
@x [49.1260] l.23409 - new_font: string recycling -- already done |
| 3439 |
flushable_string:=str_ptr-1; |
| 3440 |
@y |
| 3441 |
@z |
| 3442 |
|
| 3443 |
% If you don't want to remove code with the following two changes, |
| 3444 |
% please replace the former change by |
| 3445 |
% |
| 3446 |
% @x |
| 3447 |
% flushable_string:=str_ptr-1; |
| 3448 |
% @y |
| 3449 |
% if cur_name=str_ptr-1 then |
| 3450 |
% flushable_string:=str_ptr-1 |
| 3451 |
% else |
| 3452 |
% flushable_string:=str_ptr; {number of a non-existing} |
| 3453 |
% @z |
| 3454 |
% |
| 3455 |
% otherwise the wrong string will get removed by |flush_string|!! |
| 3456 |
% |
| 3457 |
@x [49.1260] l.23412 - new_font: string recycling -- already done |
| 3458 |
begin if cur_name=flushable_string then |
| 3459 |
begin flush_string; cur_name:=font_name[f]; |
| 3460 |
end; |
| 3461 |
if s>0 then |
| 3462 |
@y |
| 3463 |
begin if s>0 then |
| 3464 |
@z |
| 3465 |
|
| 3466 |
@x [49.1260] l.23418 - Avoid scaling fonts to 2048pt or more (see above). |
| 3467 |
else if font_size[f]=xn_over_d(font_dsize[f],-s,1000) then |
| 3468 |
goto common_ending; |
| 3469 |
@y |
| 3470 |
else begin arith_error:=false; |
| 3471 |
if font_size[f]=xn_over_d(font_dsize[f],-s,1000) |
| 3472 |
then if not arith_error |
| 3473 |
then goto common_ending; |
| 3474 |
end; |
| 3475 |
@z |
| 3476 |
|
| 3477 |
@x [49.1265] l.23454 - if batchmode, mktex... scripts should be silent. |
| 3478 |
interaction:=cur_chr; |
| 3479 |
@y |
| 3480 |
interaction:=cur_chr; |
| 3481 |
if interaction = batch_mode |
| 3482 |
then kpse_make_tex_discard_errors := 1 |
| 3483 |
else kpse_make_tex_discard_errors := 0; |
| 3484 |
@z |
| 3485 |
|
| 3486 |
@x [49.1275] l.23519 - Same stuff as for \input, this time for \openin. |
| 3487 |
if cur_ext="" then cur_ext:=".tex"; |
| 3488 |
pack_cur_name; |
| 3489 |
if a_open_in(read_file[n]) then read_open[n]:=just_open; |
| 3490 |
@y |
| 3491 |
pack_cur_name; |
| 3492 |
tex_input_type:=0; {Tell |open_input| we are \.{\\openin}.} |
| 3493 |
if kpse_in_name_ok(stringcast(name_of_file+1)) |
| 3494 |
and a_open_in(read_file[n], kpse_tex_format) then |
| 3495 |
read_open[n]:=just_open; |
| 3496 |
@z |
| 3497 |
|
| 3498 |
@x [50.1301] l.23760 - INI = VIR, so runtime test. |
| 3499 |
format_ident:=" (INITEX)"; |
| 3500 |
@y |
| 3501 |
if ini_version then format_ident:=" (INITEX)"; |
| 3502 |
@z |
| 3503 |
|
| 3504 |
% Eliminate now-unused variable `w' in `store_fmt_file'. |
| 3505 |
% Add format_engine. |
| 3506 |
@x [50.1302] l.23768 - store_fmt_file |
| 3507 |
@!w: four_quarters; {four ASCII codes} |
| 3508 |
@y |
| 3509 |
@!format_engine: ^text_char; |
| 3510 |
@z |
| 3511 |
|
| 3512 |
% MLTeX: dump |mltex_p| to fmt file |
| 3513 |
@x [50.1302] l.23772 |
| 3514 |
@<Dump constants for consistency check@>; |
| 3515 |
@y |
| 3516 |
@<Dump constants for consistency check@>; |
| 3517 |
@<Dump ML\TeX-specific data@>; |
| 3518 |
@z |
| 3519 |
|
| 3520 |
% Eliminate now-unused variable `w' in `load_fmt_file'. |
| 3521 |
% Add format_engine. |
| 3522 |
% Add dummies for undumping |xord|, |xchr|, and |xprn| into the void. |
| 3523 |
@x [50.1303] l.23800 - load_fmt_file |
| 3524 |
@!w: four_quarters; {four ASCII codes} |
| 3525 |
@y |
| 3526 |
@!format_engine: ^text_char; |
| 3527 |
@!dummy_xord: ASCII_code; |
| 3528 |
@!dummy_xchr: text_char; |
| 3529 |
@!dummy_xprn: ASCII_code; |
| 3530 |
@z |
| 3531 |
|
| 3532 |
% MLTeX: undump |mltex_enabled_p| from fmt file |
| 3533 |
@x [50.1303] l.23801 |
| 3534 |
begin @<Undump constants for consistency check@>; |
| 3535 |
@y |
| 3536 |
begin @<Undump constants for consistency check@>; |
| 3537 |
@<Undump ML\TeX-specific data@>; |
| 3538 |
@z |
| 3539 |
|
| 3540 |
@x [50.1305] l.23829 - Do dumping and undumping of fmt files in C. |
| 3541 |
@d dump_wd(#)==begin fmt_file^:=#; put(fmt_file);@+end |
| 3542 |
@d dump_int(#)==begin fmt_file^.int:=#; put(fmt_file);@+end |
| 3543 |
@d dump_hh(#)==begin fmt_file^.hh:=#; put(fmt_file);@+end |
| 3544 |
@d dump_qqqq(#)==begin fmt_file^.qqqq:=#; put(fmt_file);@+end |
| 3545 |
@y |
| 3546 |
@z |
| 3547 |
@x [50.1306] l.23843 |
| 3548 |
@d undump_wd(#)==begin get(fmt_file); #:=fmt_file^;@+end |
| 3549 |
@d undump_int(#)==begin get(fmt_file); #:=fmt_file^.int;@+end |
| 3550 |
@d undump_hh(#)==begin get(fmt_file); #:=fmt_file^.hh;@+end |
| 3551 |
@d undump_qqqq(#)==begin get(fmt_file); #:=fmt_file^.qqqq;@+end |
| 3552 |
@y |
| 3553 |
@z |
| 3554 |
@x [50.1306] l.23850 - debug format file |
| 3555 |
@d undump_size_end_end(#)==too_small(#)@+else undump_end_end |
| 3556 |
@y |
| 3557 |
@d format_debug_end(#)== |
| 3558 |
write_ln (stderr, ' = ', #); |
| 3559 |
end; |
| 3560 |
@d format_debug(#)== |
| 3561 |
if debug_format_file then begin |
| 3562 |
write (stderr, 'fmtdebug:', #); |
| 3563 |
format_debug_end |
| 3564 |
@d undump_size_end_end(#)== |
| 3565 |
too_small(#)@+else format_debug (#)(x); undump_end_end |
| 3566 |
@z |
| 3567 |
|
| 3568 |
@x [50.1307] l.23859 - texarray |
| 3569 |
dump_int(@$);@/ |
| 3570 |
@y |
| 3571 |
dump_int(@"57325458); {Web2C \TeX's magic constant: "W2TX"} |
| 3572 |
{Align engine to 4 bytes with one or more trailing NUL} |
| 3573 |
x:=strlen(engine_name); |
| 3574 |
format_engine:=xmalloc_array(text_char,x+4); |
| 3575 |
strcpy(stringcast(format_engine), engine_name); |
| 3576 |
for k:=x to x+3 do format_engine[k]:=0; |
| 3577 |
x:=x+4-(x mod 4); |
| 3578 |
dump_int(x);dump_things(format_engine[0], x); |
| 3579 |
libc_free(format_engine);@/ |
| 3580 |
dump_int(@$);@/ |
| 3581 |
@<Dump |xord|, |xchr|, and |xprn|@>; |
| 3582 |
dump_int(max_halfword);@/ |
| 3583 |
dump_int(hash_high); |
| 3584 |
@z |
| 3585 |
|
| 3586 |
%%%%%%%% dynamic hyph_size |
| 3587 |
@x [50.1307] l.23864 |
| 3588 |
dump_int(hyph_size) |
| 3589 |
@y |
| 3590 |
dump_int(hyph_prime) |
| 3591 |
@z |
| 3592 |
|
| 3593 |
@x [50.1308] l.23873 - texarray |
| 3594 |
x:=fmt_file^.int; |
| 3595 |
if x<>@$ then goto bad_fmt; {check that strings are the same} |
| 3596 |
@y |
| 3597 |
@+Init |
| 3598 |
libc_free(font_info); libc_free(str_pool); libc_free(str_start); |
| 3599 |
libc_free(yhash); libc_free(zeqtb); libc_free(yzmem); |
| 3600 |
@+Tini |
| 3601 |
undump_int(x); |
| 3602 |
format_debug('format magic number')(x); |
| 3603 |
if x<>@"57325458 then goto bad_fmt; {not a format file} |
| 3604 |
undump_int(x); |
| 3605 |
format_debug('engine name size')(x); |
| 3606 |
if (x<0) or (x>256) then goto bad_fmt; {corrupted format file} |
| 3607 |
format_engine:=xmalloc_array(text_char, x); |
| 3608 |
undump_things(format_engine[0], x); |
| 3609 |
format_engine[x-1]:=0; {force string termination, just in case} |
| 3610 |
if strcmp(engine_name, stringcast(format_engine)) then |
| 3611 |
begin wake_up_terminal; |
| 3612 |
wterm_ln('---! ', stringcast(name_of_file+1), ' was written by ', format_engine); |
| 3613 |
libc_free(format_engine); |
| 3614 |
goto bad_fmt; |
| 3615 |
end; |
| 3616 |
libc_free(format_engine); |
| 3617 |
undump_int(x); |
| 3618 |
format_debug('string pool checksum')(x); |
| 3619 |
if x<>@$ then begin {check that strings are the same} |
| 3620 |
wake_up_terminal; |
| 3621 |
wterm_ln('---! ', stringcast(name_of_file+1), |
| 3622 |
' made by different executable version, strings are different'); |
| 3623 |
goto bad_fmt; |
| 3624 |
end; |
| 3625 |
@<Undump |xord|, |xchr|, and |xprn|@>; |
| 3626 |
undump_int(x); |
| 3627 |
if x<>max_halfword then goto bad_fmt; {check |max_halfword|} |
| 3628 |
undump_int(hash_high); |
| 3629 |
if (hash_high<0)or(hash_high>sup_hash_extra) then goto bad_fmt; |
| 3630 |
if hash_extra<hash_high then hash_extra:=hash_high; |
| 3631 |
eqtb_top:=eqtb_size+hash_extra; |
| 3632 |
if hash_extra=0 then hash_top:=undefined_control_sequence else |
| 3633 |
hash_top:=eqtb_top; |
| 3634 |
yhash:=xmalloc_array(two_halves,1+hash_top-hash_offset); |
| 3635 |
hash:=yhash - hash_offset; |
| 3636 |
next(hash_base):=0; text(hash_base):=0; |
| 3637 |
for x:=hash_base+1 to hash_top do hash[x]:=hash[hash_base]; |
| 3638 |
zeqtb:=xmalloc_array (memory_word,eqtb_top+1); |
| 3639 |
eqtb:=zeqtb; |
| 3640 |
|
| 3641 |
eq_type(undefined_control_sequence):=undefined_cs; |
| 3642 |
equiv(undefined_control_sequence):=null; |
| 3643 |
eq_level(undefined_control_sequence):=level_zero; |
| 3644 |
for x:=eqtb_size+1 to eqtb_top do |
| 3645 |
eqtb[x]:=eqtb[undefined_control_sequence]; |
| 3646 |
@z |
| 3647 |
|
| 3648 |
@x [50.1308] l.23875 - texarray |
| 3649 |
undump_int(x); |
| 3650 |
if x<>mem_bot then goto bad_fmt; |
| 3651 |
undump_int(x); |
| 3652 |
if x<>mem_top then goto bad_fmt; |
| 3653 |
@y |
| 3654 |
undump_int(x); format_debug ('mem_bot')(x); |
| 3655 |
if x<>mem_bot then goto bad_fmt; |
| 3656 |
undump_int(mem_top); format_debug ('mem_top')(mem_top); |
| 3657 |
if mem_bot+1100>mem_top then goto bad_fmt; |
| 3658 |
|
| 3659 |
|
| 3660 |
head:=contrib_head; tail:=contrib_head; |
| 3661 |
page_tail:=page_head; {page initialization} |
| 3662 |
|
| 3663 |
mem_min := mem_bot - extra_mem_bot; |
| 3664 |
mem_max := mem_top + extra_mem_top; |
| 3665 |
|
| 3666 |
yzmem:=xmalloc_array (memory_word, mem_max - mem_min + 1); |
| 3667 |
zmem := yzmem - mem_min; {this pointer arithmetic fails with some compilers} |
| 3668 |
mem := zmem; |
| 3669 |
@z |
| 3670 |
|
| 3671 |
%%%%%%%% dynamic hyph_size |
| 3672 |
@x [50.1308] l.23884 |
| 3673 |
if x<>hyph_size then goto bad_fmt |
| 3674 |
@y |
| 3675 |
if x<>hyph_prime then goto bad_fmt |
| 3676 |
@z |
| 3677 |
|
| 3678 |
% [1309] Make dumping/undumping more efficient by doing whole arrays at |
| 3679 |
% a time, via fread/fwrite in texmfmp.c. |
| 3680 |
@x [50.1309] l.23894 - Make dumping/undumping more efficient. |
| 3681 |
for k:=0 to str_ptr do dump_int(str_start[k]); |
| 3682 |
k:=0; |
| 3683 |
while k+4<pool_ptr do |
| 3684 |
begin dump_four_ASCII; k:=k+4; |
| 3685 |
end; |
| 3686 |
k:=pool_ptr-4; dump_four_ASCII; |
| 3687 |
@y |
| 3688 |
dump_things(str_start[0], str_ptr+1); |
| 3689 |
dump_things(str_pool[0], pool_ptr); |
| 3690 |
@z |
| 3691 |
|
| 3692 |
@x [50.1310] l.23909 - Make dumping/undumping more efficient. |
| 3693 |
undump_size(0)(pool_size)('string pool size')(pool_ptr); |
| 3694 |
undump_size(0)(max_strings)('max strings')(str_ptr); |
| 3695 |
for k:=0 to str_ptr do undump(0)(pool_ptr)(str_start[k]); |
| 3696 |
k:=0; |
| 3697 |
while k+4<pool_ptr do |
| 3698 |
begin undump_four_ASCII; k:=k+4; |
| 3699 |
end; |
| 3700 |
k:=pool_ptr-4; undump_four_ASCII; |
| 3701 |
@y |
| 3702 |
undump_size(0)(sup_pool_size-pool_free)('string pool size')(pool_ptr); |
| 3703 |
if pool_size<pool_ptr+pool_free then |
| 3704 |
pool_size:=pool_ptr+pool_free; |
| 3705 |
undump_size(0)(sup_max_strings-strings_free)('sup strings')(str_ptr);@/ |
| 3706 |
if max_strings<str_ptr+strings_free then |
| 3707 |
max_strings:=str_ptr+strings_free; |
| 3708 |
str_start:=xmalloc_array(pool_pointer, max_strings); |
| 3709 |
undump_checked_things(0, pool_ptr, str_start[0], str_ptr+1);@/ |
| 3710 |
str_pool:=xmalloc_array(packed_ASCII_code, pool_size); |
| 3711 |
undump_things(str_pool[0], pool_ptr); |
| 3712 |
@z |
| 3713 |
|
| 3714 |
@x [50.1311] l.23930 - Make dumping/undumping more efficient. |
| 3715 |
repeat for k:=p to q+1 do dump_wd(mem[k]); |
| 3716 |
@y |
| 3717 |
repeat dump_things(mem[p], q+2-p); |
| 3718 |
@z |
| 3719 |
|
| 3720 |
@x [50.1311] l.23935 - Make dumping/undumping more efficient. |
| 3721 |
for k:=p to lo_mem_max do dump_wd(mem[k]); |
| 3722 |
@y |
| 3723 |
dump_things(mem[p], lo_mem_max+1-p); |
| 3724 |
@z |
| 3725 |
|
| 3726 |
@x [50.1311] l.23938 - Make dumping/undumping more efficient. |
| 3727 |
for k:=hi_mem_min to mem_end do dump_wd(mem[k]); |
| 3728 |
@y |
| 3729 |
dump_things(mem[hi_mem_min], mem_end+1-hi_mem_min); |
| 3730 |
@z |
| 3731 |
|
| 3732 |
@x [50.1312] l.23953 - Make dumping/undumping more efficient. |
| 3733 |
repeat for k:=p to q+1 do undump_wd(mem[k]); |
| 3734 |
@y |
| 3735 |
repeat undump_things(mem[p], q+2-p); |
| 3736 |
@z |
| 3737 |
|
| 3738 |
@x [50.1312] l.23954 - Check that p did not become corrupt. |
| 3739 |
p:=q+node_size(q); |
| 3740 |
if (p>lo_mem_max)or((q>=rlink(q))and(rlink(q)<>rover)) then goto bad_fmt; |
| 3741 |
@y |
| 3742 |
{If the format file is messed up, that addition to |p| might cause it to |
| 3743 |
become garbage. Report from Gregory James DUCK to Karl, 14 Sep 2023. |
| 3744 |
Also changed in \MF. Fix from DRF, who explains: we test before doing the |
| 3745 |
addition to avoid assuming silent wrap-around overflow, and also to to |
| 3746 |
catch cases where |node_size| was, say, bogusly the equivalent of $-1$ |
| 3747 |
and thus |p+node_size| would still look valid.} |
| 3748 |
if (node_size(q)>lo_mem_max-q) or (rlink(q)>lo_mem_max) |
| 3749 |
or ((q>=rlink(q))and(rlink(q)<>rover)) |
| 3750 |
then goto bad_fmt; |
| 3751 |
p:=q+node_size(q); |
| 3752 |
@z |
| 3753 |
|
| 3754 |
@x [50.1312] l.23958 - Make dumping/undumping more efficient. |
| 3755 |
for k:=p to lo_mem_max do undump_wd(mem[k]); |
| 3756 |
@y |
| 3757 |
undump_things(mem[p], lo_mem_max+1-p); |
| 3758 |
@z |
| 3759 |
|
| 3760 |
@x [50.1312] l.23968 - Make dumping/undumping more efficient. |
| 3761 |
for k:=hi_mem_min to mem_end do undump_wd(mem[k]); |
| 3762 |
@y |
| 3763 |
undump_things (mem[hi_mem_min], mem_end+1-hi_mem_min); |
| 3764 |
@z |
| 3765 |
|
| 3766 |
@x [50.1314] l.23979 - hash_extra, source specials |
| 3767 |
undump(hash_base)(frozen_control_sequence)(par_loc); |
| 3768 |
par_token:=cs_token_flag+par_loc;@/ |
| 3769 |
undump(hash_base)(frozen_control_sequence)(write_loc);@/ |
| 3770 |
@y |
| 3771 |
undump(hash_base)(hash_top)(par_loc); |
| 3772 |
par_token:=cs_token_flag+par_loc;@/ |
| 3773 |
undump(hash_base)(hash_top)(write_loc);@/ |
| 3774 |
@z |
| 3775 |
|
| 3776 |
@x [50.1315] l.24005 - Make dumping/undumping more efficient - eqtb |
| 3777 |
while k<l do |
| 3778 |
begin dump_wd(eqtb[k]); incr(k); |
| 3779 |
end; |
| 3780 |
@y |
| 3781 |
dump_things(eqtb[k], l-k); |
| 3782 |
@z |
| 3783 |
|
| 3784 |
@x [50.1316] l.24024 - Make dumping/undumping more efficient - eqtb |
| 3785 |
while k<l do |
| 3786 |
begin dump_wd(eqtb[k]); incr(k); |
| 3787 |
end; |
| 3788 |
@y |
| 3789 |
dump_things(eqtb[k], l-k); |
| 3790 |
@z |
| 3791 |
|
| 3792 |
@x [50.1316] l.24027 - hash_extra |
| 3793 |
k:=j+1; dump_int(k-l); |
| 3794 |
until k>eqtb_size |
| 3795 |
@y |
| 3796 |
k:=j+1; dump_int(k-l); |
| 3797 |
until k>eqtb_size; |
| 3798 |
if hash_high>0 then dump_things(eqtb[eqtb_size+1],hash_high); |
| 3799 |
{dump |hash_extra| part} |
| 3800 |
@z |
| 3801 |
|
| 3802 |
@x [50.1317] l.24034 - Make dumping/undumping more efficient - eqtb |
| 3803 |
for j:=k to k+x-1 do undump_wd(eqtb[j]); |
| 3804 |
@y |
| 3805 |
undump_things(eqtb[k], x); |
| 3806 |
@z |
| 3807 |
|
| 3808 |
@x [50.1317] l.24040 - hash_extra |
| 3809 |
until k>eqtb_size |
| 3810 |
@y |
| 3811 |
until k>eqtb_size; |
| 3812 |
if hash_high>0 then undump_things(eqtb[eqtb_size+1],hash_high); |
| 3813 |
{undump |hash_extra| part} |
| 3814 |
@z |
| 3815 |
|
| 3816 |
@x [50.1318] l.24048 - hash_extra |
| 3817 |
dump_int(hash_used); cs_count:=frozen_control_sequence-1-hash_used; |
| 3818 |
@y |
| 3819 |
dump_int(hash_used); cs_count:=frozen_control_sequence-1-hash_used+hash_high; |
| 3820 |
@z |
| 3821 |
|
| 3822 |
@x [50.1318] l.24052 - Make dumping/undumping more efficient, hash_extra |
| 3823 |
for p:=hash_used+1 to undefined_control_sequence-1 do dump_hh(hash[p]); |
| 3824 |
@y |
| 3825 |
dump_things(hash[hash_used+1], undefined_control_sequence-1-hash_used); |
| 3826 |
if hash_high>0 then dump_things(hash[eqtb_size+1], hash_high); |
| 3827 |
@z |
| 3828 |
|
| 3829 |
@x [50.1319] l.24060 - Make dumping/undumping more efficient, hash_extra |
| 3830 |
for p:=hash_used+1 to undefined_control_sequence-1 do undump_hh(hash[p]); |
| 3831 |
@y |
| 3832 |
undump_things (hash[hash_used+1], undefined_control_sequence-1-hash_used); |
| 3833 |
if debug_format_file then begin |
| 3834 |
print_csnames (hash_base, undefined_control_sequence - 1); |
| 3835 |
end; |
| 3836 |
if hash_high > 0 then begin |
| 3837 |
undump_things (hash[eqtb_size+1], hash_high); |
| 3838 |
if debug_format_file then begin |
| 3839 |
print_csnames (eqtb_size + 1, hash_high - (eqtb_size + 1)); |
| 3840 |
end; |
| 3841 |
end; |
| 3842 |
@z |
| 3843 |
|
| 3844 |
@x [50.1320] l.24065 - Make dumping/undumping more efficient - tfm |
| 3845 |
for k:=0 to fmem_ptr-1 do dump_wd(font_info[k]); |
| 3846 |
dump_int(font_ptr); |
| 3847 |
for k:=null_font to font_ptr do |
| 3848 |
@<Dump the array info for internal font number |k|@>; |
| 3849 |
@y |
| 3850 |
dump_things(font_info[0], fmem_ptr); |
| 3851 |
dump_int(font_ptr); |
| 3852 |
@<Dump the array info for internal font number |k|@>; |
| 3853 |
@z |
| 3854 |
|
| 3855 |
@x [50.1320] l.24070 - i18n fix |
| 3856 |
print_int(font_ptr-font_base); print(" preloaded font"); |
| 3857 |
if font_ptr<>font_base+1 then print_char("s") |
| 3858 |
@y |
| 3859 |
print_int(font_ptr-font_base); |
| 3860 |
if font_ptr<>font_base+1 then print(" preloaded fonts") |
| 3861 |
else print(" preloaded font") |
| 3862 |
@z |
| 3863 |
|
| 3864 |
@x [50.1321] l.24074 - texarray |
| 3865 |
undump_size(7)(font_mem_size)('font mem size')(fmem_ptr); |
| 3866 |
for k:=0 to fmem_ptr-1 do undump_wd(font_info[k]); |
| 3867 |
undump_size(font_base)(font_max)('font max')(font_ptr); |
| 3868 |
for k:=null_font to font_ptr do |
| 3869 |
@<Undump the array info for internal font number |k|@> |
| 3870 |
@y |
| 3871 |
undump_size(7)(sup_font_mem_size)('font mem size')(fmem_ptr); |
| 3872 |
if fmem_ptr>font_mem_size then font_mem_size:=fmem_ptr; |
| 3873 |
font_info:=xmalloc_array(fmemory_word, font_mem_size); |
| 3874 |
undump_things(font_info[0], fmem_ptr);@/ |
| 3875 |
undump_size(font_base)(font_base+max_font_max)('font max')(font_ptr); |
| 3876 |
{This undumps all of the font info, despite the name.} |
| 3877 |
@<Undump the array info for internal font number |k|@>; |
| 3878 |
@z |
| 3879 |
|
| 3880 |
% [50.1322] Dumping font_info. |
| 3881 |
% Knuth's code writes all the information relevant to a single font |
| 3882 |
% in the same section of the fmt file. But it's a lot faster to |
| 3883 |
% write the arrays of information out, one whole array at a time. |
| 3884 |
% So that's the way we handle dumping and undumping font info. |
| 3885 |
@x [50.1322] l.24080 - Make dumping/undumping more efficient - tfm |
| 3886 |
@ @<Dump the array info for internal font number |k|@>= |
| 3887 |
begin dump_qqqq(font_check[k]); |
| 3888 |
dump_int(font_size[k]); |
| 3889 |
dump_int(font_dsize[k]); |
| 3890 |
dump_int(font_params[k]);@/ |
| 3891 |
dump_int(hyphen_char[k]); |
| 3892 |
dump_int(skew_char[k]);@/ |
| 3893 |
dump_int(font_name[k]); |
| 3894 |
dump_int(font_area[k]);@/ |
| 3895 |
dump_int(font_bc[k]); |
| 3896 |
dump_int(font_ec[k]);@/ |
| 3897 |
dump_int(char_base[k]); |
| 3898 |
dump_int(width_base[k]); |
| 3899 |
dump_int(height_base[k]);@/ |
| 3900 |
dump_int(depth_base[k]); |
| 3901 |
dump_int(italic_base[k]); |
| 3902 |
dump_int(lig_kern_base[k]);@/ |
| 3903 |
dump_int(kern_base[k]); |
| 3904 |
dump_int(exten_base[k]); |
| 3905 |
dump_int(param_base[k]);@/ |
| 3906 |
dump_int(font_glue[k]);@/ |
| 3907 |
dump_int(bchar_label[k]); |
| 3908 |
dump_int(font_bchar[k]); |
| 3909 |
dump_int(font_false_bchar[k]);@/ |
| 3910 |
print_nl("\font"); print_esc(font_id_text(k)); print_char("="); |
| 3911 |
print_file_name(font_name[k],font_area[k],""); |
| 3912 |
if font_size[k]<>font_dsize[k] then |
| 3913 |
begin print(" at "); print_scaled(font_size[k]); print("pt"); |
| 3914 |
end; |
| 3915 |
end |
| 3916 |
@y |
| 3917 |
@ @<Dump the array info for internal font number |k|@>= |
| 3918 |
begin |
| 3919 |
dump_things(font_check[null_font], font_ptr+1-null_font); |
| 3920 |
dump_things(font_size[null_font], font_ptr+1-null_font); |
| 3921 |
dump_things(font_dsize[null_font], font_ptr+1-null_font); |
| 3922 |
dump_things(font_params[null_font], font_ptr+1-null_font); |
| 3923 |
dump_things(hyphen_char[null_font], font_ptr+1-null_font); |
| 3924 |
dump_things(skew_char[null_font], font_ptr+1-null_font); |
| 3925 |
dump_things(font_name[null_font], font_ptr+1-null_font); |
| 3926 |
dump_things(font_area[null_font], font_ptr+1-null_font); |
| 3927 |
dump_things(font_bc[null_font], font_ptr+1-null_font); |
| 3928 |
dump_things(font_ec[null_font], font_ptr+1-null_font); |
| 3929 |
dump_things(char_base[null_font], font_ptr+1-null_font); |
| 3930 |
dump_things(width_base[null_font], font_ptr+1-null_font); |
| 3931 |
dump_things(height_base[null_font], font_ptr+1-null_font); |
| 3932 |
dump_things(depth_base[null_font], font_ptr+1-null_font); |
| 3933 |
dump_things(italic_base[null_font], font_ptr+1-null_font); |
| 3934 |
dump_things(lig_kern_base[null_font], font_ptr+1-null_font); |
| 3935 |
dump_things(kern_base[null_font], font_ptr+1-null_font); |
| 3936 |
dump_things(exten_base[null_font], font_ptr+1-null_font); |
| 3937 |
dump_things(param_base[null_font], font_ptr+1-null_font); |
| 3938 |
dump_things(font_glue[null_font], font_ptr+1-null_font); |
| 3939 |
dump_things(bchar_label[null_font], font_ptr+1-null_font); |
| 3940 |
dump_things(font_bchar[null_font], font_ptr+1-null_font); |
| 3941 |
dump_things(font_false_bchar[null_font], font_ptr+1-null_font); |
| 3942 |
for k:=null_font to font_ptr do |
| 3943 |
begin print_nl("\font"); print_esc(font_id_text(k)); print_char("="); |
| 3944 |
print_file_name(font_name[k],font_area[k],""); |
| 3945 |
if font_size[k]<>font_dsize[k] then |
| 3946 |
begin print(" at "); print_scaled(font_size[k]); print("pt"); |
| 3947 |
end; |
| 3948 |
end; |
| 3949 |
end |
| 3950 |
@z |
| 3951 |
|
| 3952 |
@x [50.1323] l.24111 - Make dumping/undumping more efficient - tfm |
| 3953 |
@ @<Undump the array info for internal font number |k|@>= |
| 3954 |
begin undump_qqqq(font_check[k]);@/ |
| 3955 |
undump_int(font_size[k]); |
| 3956 |
undump_int(font_dsize[k]); |
| 3957 |
undump(min_halfword)(max_halfword)(font_params[k]);@/ |
| 3958 |
undump_int(hyphen_char[k]); |
| 3959 |
undump_int(skew_char[k]);@/ |
| 3960 |
undump(0)(str_ptr)(font_name[k]); |
| 3961 |
undump(0)(str_ptr)(font_area[k]);@/ |
| 3962 |
undump(0)(255)(font_bc[k]); |
| 3963 |
undump(0)(255)(font_ec[k]);@/ |
| 3964 |
undump_int(char_base[k]); |
| 3965 |
undump_int(width_base[k]); |
| 3966 |
undump_int(height_base[k]);@/ |
| 3967 |
undump_int(depth_base[k]); |
| 3968 |
undump_int(italic_base[k]); |
| 3969 |
undump_int(lig_kern_base[k]);@/ |
| 3970 |
undump_int(kern_base[k]); |
| 3971 |
undump_int(exten_base[k]); |
| 3972 |
undump_int(param_base[k]);@/ |
| 3973 |
undump(min_halfword)(lo_mem_max)(font_glue[k]);@/ |
| 3974 |
undump(0)(fmem_ptr-1)(bchar_label[k]); |
| 3975 |
undump(min_quarterword)(non_char)(font_bchar[k]); |
| 3976 |
undump(min_quarterword)(non_char)(font_false_bchar[k]); |
| 3977 |
end |
| 3978 |
@y |
| 3979 |
@ This module should now be named `Undump all the font arrays'. |
| 3980 |
|
| 3981 |
@<Undump the array info for internal font number |k|@>= |
| 3982 |
begin {Allocate the font arrays} |
| 3983 |
font_check:=xmalloc_array(four_quarters, font_max); |
| 3984 |
font_size:=xmalloc_array(scaled, font_max); |
| 3985 |
font_dsize:=xmalloc_array(scaled, font_max); |
| 3986 |
font_params:=xmalloc_array(font_index, font_max); |
| 3987 |
font_name:=xmalloc_array(str_number, font_max); |
| 3988 |
font_area:=xmalloc_array(str_number, font_max); |
| 3989 |
font_bc:=xmalloc_array(eight_bits, font_max); |
| 3990 |
font_ec:=xmalloc_array(eight_bits, font_max); |
| 3991 |
font_glue:=xmalloc_array(halfword, font_max); |
| 3992 |
hyphen_char:=xmalloc_array(integer, font_max); |
| 3993 |
skew_char:=xmalloc_array(integer, font_max); |
| 3994 |
bchar_label:=xmalloc_array(font_index, font_max); |
| 3995 |
font_bchar:=xmalloc_array(nine_bits, font_max); |
| 3996 |
font_false_bchar:=xmalloc_array(nine_bits, font_max); |
| 3997 |
char_base:=xmalloc_array(integer, font_max); |
| 3998 |
width_base:=xmalloc_array(integer, font_max); |
| 3999 |
height_base:=xmalloc_array(integer, font_max); |
| 4000 |
depth_base:=xmalloc_array(integer, font_max); |
| 4001 |
italic_base:=xmalloc_array(integer, font_max); |
| 4002 |
lig_kern_base:=xmalloc_array(integer, font_max); |
| 4003 |
kern_base:=xmalloc_array(integer, font_max); |
| 4004 |
exten_base:=xmalloc_array(integer, font_max); |
| 4005 |
param_base:=xmalloc_array(integer, font_max); |
| 4006 |
|
| 4007 |
undump_things(font_check[null_font], font_ptr+1-null_font); |
| 4008 |
undump_things(font_size[null_font], font_ptr+1-null_font); |
| 4009 |
undump_things(font_dsize[null_font], font_ptr+1-null_font); |
| 4010 |
undump_checked_things(min_halfword, max_halfword, |
| 4011 |
font_params[null_font], font_ptr+1-null_font); |
| 4012 |
undump_things(hyphen_char[null_font], font_ptr+1-null_font); |
| 4013 |
undump_things(skew_char[null_font], font_ptr+1-null_font); |
| 4014 |
undump_upper_check_things(str_ptr, font_name[null_font], font_ptr+1-null_font); |
| 4015 |
undump_upper_check_things(str_ptr, font_area[null_font], font_ptr+1-null_font); |
| 4016 |
{There's no point in checking these values against the range $[0,255]$, |
| 4017 |
since the data type is |unsigned char|, and all values of that type are |
| 4018 |
in that range by definition.} |
| 4019 |
undump_things(font_bc[null_font], font_ptr+1-null_font); |
| 4020 |
undump_things(font_ec[null_font], font_ptr+1-null_font); |
| 4021 |
undump_things(char_base[null_font], font_ptr+1-null_font); |
| 4022 |
undump_things(width_base[null_font], font_ptr+1-null_font); |
| 4023 |
undump_things(height_base[null_font], font_ptr+1-null_font); |
| 4024 |
undump_things(depth_base[null_font], font_ptr+1-null_font); |
| 4025 |
undump_things(italic_base[null_font], font_ptr+1-null_font); |
| 4026 |
undump_things(lig_kern_base[null_font], font_ptr+1-null_font); |
| 4027 |
undump_things(kern_base[null_font], font_ptr+1-null_font); |
| 4028 |
undump_things(exten_base[null_font], font_ptr+1-null_font); |
| 4029 |
undump_things(param_base[null_font], font_ptr+1-null_font); |
| 4030 |
undump_checked_things(min_halfword, lo_mem_max, |
| 4031 |
font_glue[null_font], font_ptr+1-null_font); |
| 4032 |
undump_checked_things(0, fmem_ptr-1, |
| 4033 |
bchar_label[null_font], font_ptr+1-null_font); |
| 4034 |
undump_checked_things(min_quarterword, non_char, |
| 4035 |
font_bchar[null_font], font_ptr+1-null_font); |
| 4036 |
undump_checked_things(min_quarterword, non_char, |
| 4037 |
font_false_bchar[null_font], font_ptr+1-null_font); |
| 4038 |
end |
| 4039 |
@z |
| 4040 |
|
| 4041 |
%%%%%%%% dynamic hyph_size |
| 4042 |
@x [50.1324] l.24138 |
| 4043 |
dump_int(hyph_count); |
| 4044 |
for k:=0 to hyph_size do if hyph_word[k]<>0 then |
| 4045 |
begin dump_int(k); dump_int(hyph_word[k]); dump_int(hyph_list[k]); |
| 4046 |
end; |
| 4047 |
@y |
| 4048 |
dump_int(hyph_count); |
| 4049 |
if hyph_next <= hyph_prime then hyph_next:=hyph_size; |
| 4050 |
dump_int(hyph_next);{minimum value of |hyphen_size| needed} |
| 4051 |
for k:=0 to hyph_size do if hyph_word[k]<>0 then |
| 4052 |
begin dump_int(k+65536*hyph_link[k]); |
| 4053 |
{assumes number of hyphen exceptions does not exceed 65535} |
| 4054 |
dump_int(hyph_word[k]); dump_int(hyph_list[k]); |
| 4055 |
end; |
| 4056 |
@z |
| 4057 |
|
| 4058 |
@x [50.1324] l.24142 - i18n fix |
| 4059 |
print_ln; print_int(hyph_count); print(" hyphenation exception"); |
| 4060 |
if hyph_count<>1 then print_char("s"); |
| 4061 |
@y |
| 4062 |
print_ln; print_int(hyph_count); |
| 4063 |
if hyph_count<>1 then print(" hyphenation exceptions") |
| 4064 |
else print(" hyphenation exception"); |
| 4065 |
@z |
| 4066 |
|
| 4067 |
@x [50.1324] l.24146 - Make dumping/undumping more efficient - trie |
| 4068 |
for k:=0 to trie_max do dump_hh(trie[k]); |
| 4069 |
@y |
| 4070 |
dump_things(trie_trl[0], trie_max+1); |
| 4071 |
dump_things(trie_tro[0], trie_max+1); |
| 4072 |
dump_things(trie_trc[0], trie_max+1); |
| 4073 |
@z |
| 4074 |
|
| 4075 |
@x [50.1324] l.24148 - Make dumping/undumping more efficient - trie |
| 4076 |
for k:=1 to trie_op_ptr do |
| 4077 |
begin dump_int(hyf_distance[k]); |
| 4078 |
dump_int(hyf_num[k]); |
| 4079 |
dump_int(hyf_next[k]); |
| 4080 |
end; |
| 4081 |
@y |
| 4082 |
dump_things(hyf_distance[1], trie_op_ptr); |
| 4083 |
dump_things(hyf_num[1], trie_op_ptr); |
| 4084 |
dump_things(hyf_next[1], trie_op_ptr); |
| 4085 |
@z |
| 4086 |
|
| 4087 |
@x [50.1324] l.24155 - i18n fix |
| 4088 |
print(" has "); print_int(trie_op_ptr); print(" op"); |
| 4089 |
if trie_op_ptr<>1 then print_char("s"); |
| 4090 |
@y |
| 4091 |
print(" has "); print_int(trie_op_ptr); |
| 4092 |
if trie_op_ptr<>1 then print(" ops") |
| 4093 |
else print(" op"); |
| 4094 |
@z |
| 4095 |
|
| 4096 |
%%%%%%%% dynamic hyph_size |
| 4097 |
@x [50.1325] l.24167 |
| 4098 |
undump(0)(hyph_size)(hyph_count); |
| 4099 |
for k:=1 to hyph_count do |
| 4100 |
begin undump(0)(hyph_size)(j); |
| 4101 |
undump(0)(str_ptr)(hyph_word[j]); |
| 4102 |
undump(min_halfword)(max_halfword)(hyph_list[j]); |
| 4103 |
end; |
| 4104 |
@y |
| 4105 |
undump_size(0)(hyph_size)('hyph_size')(hyph_count); |
| 4106 |
undump_size(hyph_prime)(hyph_size)('hyph_size')(hyph_next); |
| 4107 |
j:=0; |
| 4108 |
for k:=1 to hyph_count do |
| 4109 |
begin undump_int(j); if j<0 then goto bad_fmt; |
| 4110 |
if j>65535 then |
| 4111 |
begin hyph_next:= j div 65536; j:=j - hyph_next * 65536; end |
| 4112 |
else hyph_next:=0; |
| 4113 |
if (j>=hyph_size)or(hyph_next>hyph_size) then goto bad_fmt; |
| 4114 |
hyph_link[j]:=hyph_next; |
| 4115 |
undump(0)(str_ptr)(hyph_word[j]); |
| 4116 |
undump(min_halfword)(max_halfword)(hyph_list[j]); |
| 4117 |
end; |
| 4118 |
{|j| is now the largest occupied location in |hyph_word|} |
| 4119 |
incr(j); |
| 4120 |
if j<hyph_prime then j:=hyph_prime; |
| 4121 |
hyph_next:=j; |
| 4122 |
if hyph_next >= hyph_size then hyph_next:=hyph_prime else |
| 4123 |
if hyph_next >= hyph_prime then incr(hyph_next); |
| 4124 |
@z |
| 4125 |
|
| 4126 |
@x [50.1325] l.24174 - Make dumping/undumping more efficient - trie |
| 4127 |
for k:=0 to j do undump_hh(trie[k]); |
| 4128 |
@y |
| 4129 |
{These first three haven't been allocated yet unless we're \.{INITEX}; |
| 4130 |
we do that precisely so we don't allocate more space than necessary.} |
| 4131 |
if not trie_trl then trie_trl:=xmalloc_array(trie_pointer,j+1); |
| 4132 |
undump_things(trie_trl[0], j+1); |
| 4133 |
if not trie_tro then trie_tro:=xmalloc_array(trie_pointer,j+1); |
| 4134 |
undump_things(trie_tro[0], j+1); |
| 4135 |
if not trie_trc then trie_trc:=xmalloc_array(quarterword, j+1); |
| 4136 |
undump_things(trie_trc[0], j+1); |
| 4137 |
@z |
| 4138 |
|
| 4139 |
@x [50.1325] l.24176 - Make dumping/undumping more efficient - trie |
| 4140 |
for k:=1 to j do |
| 4141 |
begin undump(0)(63)(hyf_distance[k]); {a |small_number|} |
| 4142 |
undump(0)(63)(hyf_num[k]); |
| 4143 |
undump(min_quarterword)(max_quarterword)(hyf_next[k]); |
| 4144 |
end; |
| 4145 |
@y |
| 4146 |
{I'm not sure we have such a strict limitation (64) on these values, so |
| 4147 |
let's leave them unchecked.} |
| 4148 |
undump_things(hyf_distance[1], j); |
| 4149 |
undump_things(hyf_num[1], j); |
| 4150 |
undump_upper_check_things(max_trie_op, hyf_next[1], j); |
| 4151 |
@z |
| 4152 |
|
| 4153 |
@x [50.1327] l.24197 - Allow command line to override dumped value. |
| 4154 |
undump(batch_mode)(error_stop_mode)(interaction); |
| 4155 |
@y |
| 4156 |
undump(batch_mode)(error_stop_mode)(interaction); |
| 4157 |
if interaction_option<>unspecified_mode then interaction:=interaction_option; |
| 4158 |
@z |
| 4159 |
|
| 4160 |
@x [50.1327] l.24200 - Test for end-of-file already done by undump. |
| 4161 |
if (x<>69069)or eof(fmt_file) then goto bad_fmt |
| 4162 |
@y |
| 4163 |
if x<>69069 then goto bad_fmt |
| 4164 |
@z |
| 4165 |
|
| 4166 |
@x [51.1332] l.24283 - make the main program a procedure, for eqtb hack. |
| 4167 |
@p begin @!{|start_here|} |
| 4168 |
@y |
| 4169 |
@d const_chk(#)==begin if # < inf@&# then # := inf@&# else |
| 4170 |
if # > sup@&# then # := sup@&# end |
| 4171 |
|
| 4172 |
{|setup_bound_var| stuff duplicated in \.{mf.ch}.} |
| 4173 |
@d setup_bound_var(#)==bound_default:=#; setup_bound_var_end |
| 4174 |
@d setup_bound_var_end(#)==bound_name:=#; setup_bound_var_end_end |
| 4175 |
@d setup_bound_var_end_end(#)== |
| 4176 |
setup_bound_variable(addressof(#), bound_name, bound_default) |
| 4177 |
|
| 4178 |
@p procedure main_body; |
| 4179 |
begin @!{|start_here|} |
| 4180 |
|
| 4181 |
{Bounds that may be set from the configuration file. We want the user to |
| 4182 |
be able to specify the names with underscores, but \.{TANGLE} removes |
| 4183 |
underscores, so we're stuck giving the names twice, once as a string, |
| 4184 |
once as the identifier. How ugly.} |
| 4185 |
setup_bound_var (0)('mem_bot')(mem_bot); |
| 4186 |
setup_bound_var (250000)('main_memory')(main_memory); |
| 4187 |
{|memory_word|s for |mem| in \.{INITEX}} |
| 4188 |
setup_bound_var (0)('extra_mem_top')(extra_mem_top); |
| 4189 |
{increase high mem in \.{VIRTEX}} |
| 4190 |
setup_bound_var (0)('extra_mem_bot')(extra_mem_bot); |
| 4191 |
{increase low mem in \.{VIRTEX}} |
| 4192 |
setup_bound_var (200000)('pool_size')(pool_size); |
| 4193 |
setup_bound_var (75000)('string_vacancies')(string_vacancies); |
| 4194 |
setup_bound_var (5000)('pool_free')(pool_free); {min pool avail after fmt} |
| 4195 |
setup_bound_var (15000)('max_strings')(max_strings); |
| 4196 |
setup_bound_var (100)('strings_free')(strings_free); |
| 4197 |
setup_bound_var (100000)('font_mem_size')(font_mem_size); |
| 4198 |
setup_bound_var (500)('font_max')(font_max); |
| 4199 |
setup_bound_var (20000)('trie_size')(trie_size); |
| 4200 |
{if |ssup_trie_size| increases, recompile} |
| 4201 |
setup_bound_var (659)('hyph_size')(hyph_size); |
| 4202 |
setup_bound_var (3000)('buf_size')(buf_size); |
| 4203 |
setup_bound_var (50)('nest_size')(nest_size); |
| 4204 |
setup_bound_var (15)('max_in_open')(max_in_open); |
| 4205 |
setup_bound_var (60)('param_size')(param_size); |
| 4206 |
setup_bound_var (4000)('save_size')(save_size); |
| 4207 |
setup_bound_var (300)('stack_size')(stack_size); |
| 4208 |
setup_bound_var (16384)('dvi_buf_size')(dvi_buf_size); |
| 4209 |
setup_bound_var (79)('error_line')(error_line); |
| 4210 |
setup_bound_var (50)('half_error_line')(half_error_line); |
| 4211 |
setup_bound_var (79)('max_print_line')(max_print_line); |
| 4212 |
setup_bound_var (0)('hash_extra')(hash_extra); |
| 4213 |
setup_bound_var (10000)('expand_depth')(expand_depth); |
| 4214 |
|
| 4215 |
const_chk (mem_bot); |
| 4216 |
const_chk (main_memory); |
| 4217 |
@+Init |
| 4218 |
extra_mem_top := 0; |
| 4219 |
extra_mem_bot := 0; |
| 4220 |
@+Tini |
| 4221 |
if extra_mem_bot>sup_main_memory then extra_mem_bot:=sup_main_memory; |
| 4222 |
if extra_mem_top>sup_main_memory then extra_mem_top:=sup_main_memory; |
| 4223 |
{|mem_top| is an index, |main_memory| a size} |
| 4224 |
mem_top := mem_bot + main_memory -1; |
| 4225 |
mem_min := mem_bot; |
| 4226 |
mem_max := mem_top; |
| 4227 |
|
| 4228 |
{Check other constants against their sup and inf.} |
| 4229 |
const_chk (trie_size); |
| 4230 |
const_chk (hyph_size); |
| 4231 |
const_chk (buf_size); |
| 4232 |
const_chk (nest_size); |
| 4233 |
const_chk (max_in_open); |
| 4234 |
const_chk (param_size); |
| 4235 |
const_chk (save_size); |
| 4236 |
const_chk (stack_size); |
| 4237 |
const_chk (dvi_buf_size); |
| 4238 |
const_chk (pool_size); |
| 4239 |
const_chk (string_vacancies); |
| 4240 |
const_chk (pool_free); |
| 4241 |
const_chk (max_strings); |
| 4242 |
const_chk (strings_free); |
| 4243 |
const_chk (font_mem_size); |
| 4244 |
const_chk (font_max); |
| 4245 |
const_chk (hash_extra); |
| 4246 |
if error_line > ssup_error_line then error_line := ssup_error_line; |
| 4247 |
|
| 4248 |
{array memory allocation} |
| 4249 |
buffer:=xmalloc_array (ASCII_code, buf_size); |
| 4250 |
nest:=xmalloc_array (list_state_record, nest_size); |
| 4251 |
save_stack:=xmalloc_array (memory_word, save_size); |
| 4252 |
input_stack:=xmalloc_array (in_state_record, stack_size); |
| 4253 |
input_file:=xmalloc_array (alpha_file, max_in_open); |
| 4254 |
line_stack:=xmalloc_array (integer, max_in_open); |
| 4255 |
source_filename_stack:=xmalloc_array (str_number, max_in_open); |
| 4256 |
full_source_filename_stack:=xmalloc_array (str_number, max_in_open); |
| 4257 |
param_stack:=xmalloc_array (halfword, param_size); |
| 4258 |
dvi_buf:=xmalloc_array (eight_bits, dvi_buf_size); |
| 4259 |
hyph_word :=xmalloc_array (str_number, hyph_size); |
| 4260 |
hyph_list :=xmalloc_array (halfword, hyph_size); |
| 4261 |
hyph_link :=xmalloc_array (hyph_pointer, hyph_size); |
| 4262 |
@+Init |
| 4263 |
yzmem:=xmalloc_array (memory_word, mem_top - mem_bot + 1); |
| 4264 |
zmem := yzmem - mem_bot; {Some compilers require |mem_bot=0|} |
| 4265 |
eqtb_top := eqtb_size+hash_extra; |
| 4266 |
if hash_extra=0 then hash_top:=undefined_control_sequence else |
| 4267 |
hash_top:=eqtb_top; |
| 4268 |
yhash:=xmalloc_array (two_halves,1+hash_top-hash_offset); |
| 4269 |
hash:=yhash - hash_offset; {Some compilers require |hash_offset=0|} |
| 4270 |
next(hash_base):=0; text(hash_base):=0; |
| 4271 |
for hash_used:=hash_base+1 to hash_top do hash[hash_used]:=hash[hash_base]; |
| 4272 |
zeqtb:=xmalloc_array (memory_word, eqtb_top); |
| 4273 |
eqtb:=zeqtb; |
| 4274 |
|
| 4275 |
str_start:=xmalloc_array (pool_pointer, max_strings); |
| 4276 |
str_pool:=xmalloc_array (packed_ASCII_code, pool_size); |
| 4277 |
font_info:=xmalloc_array (fmemory_word, font_mem_size); |
| 4278 |
@+Tini |
| 4279 |
@z |
| 4280 |
|
| 4281 |
@x [51.1332] l.24295 - INI = VIR, so pool init needs runtime test |
| 4282 |
@!init if not get_strings_started then goto final_end; |
| 4283 |
init_prim; {call |primitive| for each primitive} |
| 4284 |
init_str_ptr:=str_ptr; init_pool_ptr:=pool_ptr; fix_date_and_time; |
| 4285 |
tini@/ |
| 4286 |
@y |
| 4287 |
@!Init if not get_strings_started then goto final_end; |
| 4288 |
init_prim; {call |primitive| for each primitive} |
| 4289 |
init_str_ptr:=str_ptr; init_pool_ptr:=pool_ptr; fix_date_and_time; |
| 4290 |
Tini@/ |
| 4291 |
@z |
| 4292 |
|
| 4293 |
@x [51.1332] l.24305 - main |
| 4294 |
end_of_TEX: close_files_and_terminate; |
| 4295 |
final_end: ready_already:=0; |
| 4296 |
end. |
| 4297 |
@y |
| 4298 |
close_files_and_terminate; |
| 4299 |
final_end: do_final_end; |
| 4300 |
end {|main_body|}; |
| 4301 |
@z |
| 4302 |
|
| 4303 |
@x [51.1333] l.24334 - Print new line before termination; switch to editor if necessary. |
| 4304 |
slow_print(log_name); print_char("."); |
| 4305 |
end; |
| 4306 |
end; |
| 4307 |
@y |
| 4308 |
print_file_name(0, log_name, 0); print_char("."); |
| 4309 |
end; |
| 4310 |
end; |
| 4311 |
print_ln; |
| 4312 |
if (edit_name_start<>0) and (interaction>batch_mode) then |
| 4313 |
call_edit(str_pool,edit_name_start,edit_name_length,edit_line); |
| 4314 |
@z |
| 4315 |
|
| 4316 |
@x [51.1334] l.24355 - hash_extra |
| 4317 |
wlog_ln(' ',cs_count:1,' multiletter control sequences out of ', |
| 4318 |
hash_size:1);@/ |
| 4319 |
@y |
| 4320 |
wlog_ln(' ',cs_count:1,' multiletter control sequences out of ', |
| 4321 |
hash_size:1, '+', hash_extra:1);@/ |
| 4322 |
@z |
| 4323 |
|
| 4324 |
@x [51.1335] l.24415 - Only do dump if ini. |
| 4325 |
begin @!init for c:=top_mark_code to split_bot_mark_code do |
| 4326 |
@y |
| 4327 |
begin @!Init for c:=top_mark_code to split_bot_mark_code do |
| 4328 |
@z |
| 4329 |
|
| 4330 |
@x [51.1335] l.24418 - Only do dump if ini. |
| 4331 |
store_fmt_file; return;@+tini@/ |
| 4332 |
@y |
| 4333 |
store_fmt_file; return;@+Tini@/ |
| 4334 |
@z |
| 4335 |
|
| 4336 |
@x [51.1337] l.24441 - Handle %&format in all cases. |
| 4337 |
if (format_ident=0)or(buffer[loc]="&") then |
| 4338 |
@y |
| 4339 |
if (format_ident=0)or(buffer[loc]="&")or dump_line then |
| 4340 |
@z |
| 4341 |
|
| 4342 |
@x [51.1337] l.24447 - Dynamic arrays size. |
| 4343 |
w_close(fmt_file); |
| 4344 |
@y |
| 4345 |
w_close(fmt_file); |
| 4346 |
eqtb:=zeqtb; |
| 4347 |
@z |
| 4348 |
|
| 4349 |
%% [51.1337] l.24371 - MLTeX: add. MLTeX banner after loading fmt file |
| 4350 |
%% (MLTeX change: only "if mltex_enabled_p then ....;") |
| 4351 |
@x [51.1337] l.24452 - Allocate hyphenation tries, do char translation, MLTeX |
| 4352 |
fix_date_and_time;@/ |
| 4353 |
@y |
| 4354 |
if mltex_enabled_p then |
| 4355 |
begin wterm_ln('MLTeX v2.2 enabled'); |
| 4356 |
end; |
| 4357 |
fix_date_and_time;@/ |
| 4358 |
|
| 4359 |
@!init |
| 4360 |
if trie_not_ready then begin {initex without format loaded} |
| 4361 |
trie_trl:=xmalloc_array (trie_pointer, trie_size); |
| 4362 |
trie_tro:=xmalloc_array (trie_pointer, trie_size); |
| 4363 |
trie_trc:=xmalloc_array (quarterword, trie_size); |
| 4364 |
|
| 4365 |
trie_c:=xmalloc_array (packed_ASCII_code, trie_size); |
| 4366 |
trie_o:=xmalloc_array (trie_opcode, trie_size); |
| 4367 |
trie_l:=xmalloc_array (trie_pointer, trie_size); |
| 4368 |
trie_r:=xmalloc_array (trie_pointer, trie_size); |
| 4369 |
trie_hash:=xmalloc_array (trie_pointer, trie_size); |
| 4370 |
trie_taken:=xmalloc_array (boolean, trie_size); |
| 4371 |
|
| 4372 |
trie_root:=0; trie_c[0]:=si(0); trie_ptr:=0; |
| 4373 |
|
| 4374 |
{Allocate and initialize font arrays} |
| 4375 |
font_check:=xmalloc_array(four_quarters, font_max); |
| 4376 |
font_size:=xmalloc_array(scaled, font_max); |
| 4377 |
font_dsize:=xmalloc_array(scaled, font_max); |
| 4378 |
font_params:=xmalloc_array(font_index, font_max); |
| 4379 |
font_name:=xmalloc_array(str_number, font_max); |
| 4380 |
font_area:=xmalloc_array(str_number, font_max); |
| 4381 |
font_bc:=xmalloc_array(eight_bits, font_max); |
| 4382 |
font_ec:=xmalloc_array(eight_bits, font_max); |
| 4383 |
font_glue:=xmalloc_array(halfword, font_max); |
| 4384 |
hyphen_char:=xmalloc_array(integer, font_max); |
| 4385 |
skew_char:=xmalloc_array(integer, font_max); |
| 4386 |
bchar_label:=xmalloc_array(font_index, font_max); |
| 4387 |
font_bchar:=xmalloc_array(nine_bits, font_max); |
| 4388 |
font_false_bchar:=xmalloc_array(nine_bits, font_max); |
| 4389 |
char_base:=xmalloc_array(integer, font_max); |
| 4390 |
width_base:=xmalloc_array(integer, font_max); |
| 4391 |
height_base:=xmalloc_array(integer, font_max); |
| 4392 |
depth_base:=xmalloc_array(integer, font_max); |
| 4393 |
italic_base:=xmalloc_array(integer, font_max); |
| 4394 |
lig_kern_base:=xmalloc_array(integer, font_max); |
| 4395 |
kern_base:=xmalloc_array(integer, font_max); |
| 4396 |
exten_base:=xmalloc_array(integer, font_max); |
| 4397 |
param_base:=xmalloc_array(integer, font_max); |
| 4398 |
|
| 4399 |
font_ptr:=null_font; fmem_ptr:=7; |
| 4400 |
font_name[null_font]:="nullfont"; font_area[null_font]:=""; |
| 4401 |
hyphen_char[null_font]:="-"; skew_char[null_font]:=-1; |
| 4402 |
bchar_label[null_font]:=non_address; |
| 4403 |
font_bchar[null_font]:=non_char; font_false_bchar[null_font]:=non_char; |
| 4404 |
font_bc[null_font]:=1; font_ec[null_font]:=0; |
| 4405 |
font_size[null_font]:=0; font_dsize[null_font]:=0; |
| 4406 |
char_base[null_font]:=0; width_base[null_font]:=0; |
| 4407 |
height_base[null_font]:=0; depth_base[null_font]:=0; |
| 4408 |
italic_base[null_font]:=0; lig_kern_base[null_font]:=0; |
| 4409 |
kern_base[null_font]:=0; exten_base[null_font]:=0; |
| 4410 |
font_glue[null_font]:=null; font_params[null_font]:=7; |
| 4411 |
param_base[null_font]:=-1; |
| 4412 |
for font_k:=0 to 6 do font_info[font_k].sc:=0; |
| 4413 |
end; |
| 4414 |
tini@/ |
| 4415 |
|
| 4416 |
font_used:=xmalloc_array (boolean, font_max); |
| 4417 |
for font_k:=font_base to font_max do font_used[font_k]:=false; |
| 4418 |
@z |
| 4419 |
|
| 4420 |
% [52.1338] Core-dump in debugging mode on 0 input. Under Unix, it's |
| 4421 |
% not possible to portably switch into the debugger while a program is |
| 4422 |
% running. The best approximation is to do a core dump, then run the |
| 4423 |
% debugger on it later. |
| 4424 |
@x [52.1338] l.24493 - Core-dump in debugging mode on 0 input. |
| 4425 |
begin goto breakpoint;@/ {go to every declared label at least once} |
| 4426 |
breakpoint: m:=0; @{'BREAKPOINT'@}@/ |
| 4427 |
end |
| 4428 |
@y |
| 4429 |
dump_core {do something to cause a core dump} |
| 4430 |
@z |
| 4431 |
|
| 4432 |
@x [52.1339] l.24511 - debug - print tfm info |
| 4433 |
5: print_word(font_info[n]); |
| 4434 |
@y |
| 4435 |
5: begin print_scaled(font_info[n].sc); print_char(" ");@/ |
| 4436 |
print_int(font_info[n].qqqq.b0); print_char(":");@/ |
| 4437 |
print_int(font_info[n].qqqq.b1); print_char(":");@/ |
| 4438 |
print_int(font_info[n].qqqq.b2); print_char(":");@/ |
| 4439 |
print_int(font_info[n].qqqq.b3); |
| 4440 |
end; |
| 4441 |
@z |
| 4442 |
|
| 4443 |
@x [53.1344] l.24624 - source specials |
| 4444 |
primitive("special",extension,special_node);@/ |
| 4445 |
@y |
| 4446 |
primitive("special",extension,special_node);@/ |
| 4447 |
text(frozen_special):="special"; eqtb[frozen_special]:=eqtb[cur_val];@/ |
| 4448 |
@z |
| 4449 |
|
| 4450 |
@x [53.1348] l.24657 - (do_extension) Remove unused variables |
| 4451 |
var i,@!j,@!k:integer; {all-purpose integers} |
| 4452 |
@!p,@!q,@!r:pointer; {all-purpose pointers} |
| 4453 |
@y |
| 4454 |
var k:integer; {all-purpose integers} |
| 4455 |
@!p:pointer; {all-purpose pointers} |
| 4456 |
@z |
| 4457 |
|
| 4458 |
% [53.1350] (new_write_whatsit) Allow 18 as a \write stream. We never |
| 4459 |
% refer to an actual file, though, so we don't need to change the |
| 4460 |
% write_file or write_open arrays. We provide for disabling this at |
| 4461 |
% runtime, for paranoids. |
| 4462 |
@x [53.1350] l.24691 - system: Allow 18 as a \write stream. |
| 4463 |
else if cur_val>15 then cur_val:=16; |
| 4464 |
@y |
| 4465 |
else if (cur_val>15) and (cur_val <> 18) then cur_val:=16; |
| 4466 |
@z |
| 4467 |
|
| 4468 |
@x [53.1370] l.24852 - \write18{foo} |
| 4469 |
begin @<Expand macros in the token list |
| 4470 |
@y |
| 4471 |
@!d:integer; {number of characters in incomplete current string} |
| 4472 |
@!clobbered:boolean; {system string is ok?} |
| 4473 |
@!runsystem_ret:integer; {return value from |runsystem|} |
| 4474 |
begin @<Expand macros in the token list |
| 4475 |
@z |
| 4476 |
|
| 4477 |
@x [53.1370] l.24855 - system: (write_out) \write18{foo} => system(foo). |
| 4478 |
if write_open[j] then selector:=j |
| 4479 |
@y |
| 4480 |
if j=18 then selector := new_string |
| 4481 |
else if write_open[j] then selector:=j |
| 4482 |
@z |
| 4483 |
|
| 4484 |
% Then call system(3) on that string. |
| 4485 |
@x [53.1370] l.24861 - system: (write_out) \write18{foo} => system(foo). |
| 4486 |
flush_list(def_ref); selector:=old_setting; |
| 4487 |
@y |
| 4488 |
flush_list(def_ref); |
| 4489 |
if j=18 then |
| 4490 |
begin if (tracing_online<=0) then |
| 4491 |
selector:=log_only {Show what we're doing in the log file.} |
| 4492 |
else selector:=term_and_log; {Show what we're doing.} |
| 4493 |
{If the log file isn't open yet, we can only send output to the terminal. |
| 4494 |
Calling |open_log_file| from here seems to result in bad data in the log.} |
| 4495 |
if not log_opened then selector:=term_only; |
| 4496 |
print_nl("runsystem("); |
| 4497 |
for d:=0 to cur_length-1 do |
| 4498 |
begin {|print| gives up if passed |str_ptr|, so do it by hand.} |
| 4499 |
print(so(str_pool[str_start[str_ptr]+d])); {N.B.: not |print_char|} |
| 4500 |
end; |
| 4501 |
print(")..."); |
| 4502 |
if shellenabledp then begin |
| 4503 |
str_room(1); append_char(0); {Append a null byte to the expansion.} |
| 4504 |
clobbered:=false; |
| 4505 |
for d:=0 to cur_length-1 do {Convert to external character set.} |
| 4506 |
begin |
| 4507 |
str_pool[str_start[str_ptr]+d]:=xchr[str_pool[str_start[str_ptr]+d]]; |
| 4508 |
if (str_pool[str_start[str_ptr]+d]=null_code) |
| 4509 |
and (d<cur_length-1) then clobbered:=true; |
| 4510 |
{minimal checking: NUL not allowed in argument string of |system|()} |
| 4511 |
end; |
| 4512 |
if clobbered then print("clobbered") |
| 4513 |
else begin {We have the command. See if we're allowed to execute it, |
| 4514 |
and report in the log. We don't check the actual exit status of |
| 4515 |
the command, or do anything with the output.} |
| 4516 |
runsystem_ret := runsystem(conststringcast(addressof( |
| 4517 |
str_pool[str_start[str_ptr]]))); |
| 4518 |
if runsystem_ret = -1 then print("quotation error in system command") |
| 4519 |
else if runsystem_ret = 0 then print("disabled (restricted)") |
| 4520 |
else if runsystem_ret = 1 then print("executed") |
| 4521 |
else if runsystem_ret = 2 then print("executed safely (allowed)") |
| 4522 |
end; |
| 4523 |
end else begin |
| 4524 |
print("disabled"); {|shellenabledp| false} |
| 4525 |
end; |
| 4526 |
print_char("."); print_nl(""); print_ln; |
| 4527 |
pool_ptr:=str_start[str_ptr]; {erase the string} |
| 4528 |
end; |
| 4529 |
selector:=old_setting; |
| 4530 |
@z |
| 4531 |
|
| 4532 |
@x [53.1373] l.24902 - Need new local. |
| 4533 |
procedure out_what(@!p:pointer); |
| 4534 |
var j:small_number; {write stream number} |
| 4535 |
@y |
| 4536 |
procedure out_what(@!p:pointer); |
| 4537 |
var j:small_number; {write stream number} |
| 4538 |
@!old_setting:0..max_selector; |
| 4539 |
@z |
| 4540 |
|
| 4541 |
@x [53.1374] l.24923 |
| 4542 |
else begin if write_open[j] then a_close(write_file[j]); |
| 4543 |
if subtype(p)=close_node then write_open[j]:=false |
| 4544 |
@y |
| 4545 |
else begin if write_open[j] then begin a_close(write_file[j]); |
| 4546 |
write_open[j]:=false; end; |
| 4547 |
if subtype(p)=close_node then do_nothing {already closed} |
| 4548 |
@z |
| 4549 |
|
| 4550 |
@x [53.1374] l.24930 - Disallow certain \openout filenames, and log results. |
| 4551 |
while not a_open_out(write_file[j]) do |
| 4552 |
prompt_file_name("output file name",".tex"); |
| 4553 |
write_open[j]:=true; |
| 4554 |
@y |
| 4555 |
while not kpse_out_name_ok(stringcast(name_of_file+1)) |
| 4556 |
or not a_open_out(write_file[j]) do |
| 4557 |
prompt_file_name("output file name",".tex"); |
| 4558 |
write_open[j]:=true; |
| 4559 |
{If on first line of input, log file is not ready yet, so don't log.} |
| 4560 |
if log_opened and texmf_yesno('log_openout') then begin |
| 4561 |
old_setting:=selector; |
| 4562 |
if (tracing_online<=0) then |
| 4563 |
selector:=log_only {Show what we're doing in the log file.} |
| 4564 |
else selector:=term_and_log; {Show what we're doing.} |
| 4565 |
print_nl("\openout"); |
| 4566 |
print_int(j); |
| 4567 |
print(" = `"); |
| 4568 |
print_file_name(cur_name,cur_area,cur_ext); |
| 4569 |
print("'."); print_nl(""); print_ln; |
| 4570 |
selector:=old_setting; |
| 4571 |
end; |
| 4572 |
@z |
| 4573 |
|
| 4574 |
@x [54.1379] l.24985 - Add editor-switch variables to globals. |
| 4575 |
@* \[54] System-dependent changes. |
| 4576 |
This section should be replaced, if necessary, by any special |
| 4577 |
modifications of the program |
| 4578 |
that are necessary to make \TeX\ work at a particular installation. |
| 4579 |
It is usually best to design your change file so that all changes to |
| 4580 |
previous sections preserve the section numbering; then everybody's version |
| 4581 |
will be consistent with the published program. More extensive changes, |
| 4582 |
which introduce new sections, can be inserted here; then only the index |
| 4583 |
itself will get a new section number. |
| 4584 |
@^system dependencies@> |
| 4585 |
|
| 4586 |
@y |
| 4587 |
@* \[54/web2c] System-dependent changes for Web2c. |
| 4588 |
Here are extra variables for Web2c. (This numbering of the |
| 4589 |
system-dependent section allows easy integration of Web2c and e-\TeX, etc.) |
| 4590 |
@^system dependencies@> |
| 4591 |
|
| 4592 |
@<Glob...@>= |
| 4593 |
@!edit_name_start: pool_pointer; {where the filename to switch to starts} |
| 4594 |
@!edit_name_length,@!edit_line: integer; {what line to start editing at} |
| 4595 |
@!ipc_on: cinttype; {level of IPC action, 0 for none [default]} |
| 4596 |
@!stop_at_space: boolean; {whether |more_name| returns false for space} |
| 4597 |
|
| 4598 |
@ The |edit_name_start| will be set to point into |str_pool| somewhere after |
| 4599 |
its beginning if \TeX\ is supposed to switch to an editor on exit. |
| 4600 |
|
| 4601 |
Initialize the |stop_at_space| variable for filename parsing. |
| 4602 |
|
| 4603 |
Initialize the |halting_on_error_p| variable to avoid infloop with |
| 4604 |
\.{--halt-on-error}. |
| 4605 |
|
| 4606 |
@<Set init...@>= |
| 4607 |
edit_name_start:=0; |
| 4608 |
stop_at_space:=true; |
| 4609 |
halting_on_error_p:=false; |
| 4610 |
|
| 4611 |
@ These are used when we regenerate the representation of the first 256 |
| 4612 |
strings. |
| 4613 |
|
| 4614 |
@<Global...@> = |
| 4615 |
@!save_str_ptr: str_number; |
| 4616 |
@!save_pool_ptr: pool_pointer; |
| 4617 |
@!shellenabledp: cinttype; |
| 4618 |
@!restrictedshell: cinttype; |
| 4619 |
@!output_comment: ^char; |
| 4620 |
@!k,l: 0..255; {used by `Make the first 256 strings', etc.} |
| 4621 |
|
| 4622 |
@ When debugging a macro package, it can be useful to see the exact |
| 4623 |
control sequence names in the format file. For example, if ten new |
| 4624 |
csnames appear, it's nice to know what they are, to help pinpoint where |
| 4625 |
they came from. (This isn't a truly ``basic'' printing procedure, but |
| 4626 |
that's a convenient module in which to put it.) |
| 4627 |
|
| 4628 |
@<Basic printing procedures@> = |
| 4629 |
procedure print_csnames (hstart:integer; hfinish:integer); |
| 4630 |
var c,h:integer; |
| 4631 |
begin |
| 4632 |
write_ln(stderr, 'fmtdebug:csnames from ', hstart, ' to ', hfinish, ':'); |
| 4633 |
for h := hstart to hfinish do begin |
| 4634 |
if text(h) > 0 then begin {if have anything at this position} |
| 4635 |
for c := str_start[text(h)] to str_start[text(h) + 1] - 1 |
| 4636 |
do begin |
| 4637 |
put_byte(str_pool[c], stderr); {print the characters} |
| 4638 |
end; |
| 4639 |
write_ln(stderr, '|'); |
| 4640 |
end; |
| 4641 |
end; |
| 4642 |
end; |
| 4643 |
|
| 4644 |
@ Are we printing extra info as we read the format file? |
| 4645 |
|
| 4646 |
@<Glob...@> = |
| 4647 |
@!debug_format_file: boolean; |
| 4648 |
|
| 4649 |
|
| 4650 |
@ A helper for printing file:line:error style messages. Look for a |
| 4651 |
filename in |full_source_filename_stack|, and if we fail to find |
| 4652 |
one fall back on the non-file:line:error style. |
| 4653 |
|
| 4654 |
@<Basic print...@>= |
| 4655 |
procedure print_file_line; |
| 4656 |
var level: 0..max_in_open; |
| 4657 |
begin |
| 4658 |
level:=in_open; |
| 4659 |
while (level>0) and (full_source_filename_stack[level]=0) do |
| 4660 |
decr(level); |
| 4661 |
if level=0 then |
| 4662 |
print_nl("! ") |
| 4663 |
else begin |
| 4664 |
print_nl (""); print (full_source_filename_stack[level]); print (":"); |
| 4665 |
if level=in_open then print_int (line) |
| 4666 |
else print_int (line_stack[level+1]); |
| 4667 |
print (": "); |
| 4668 |
end; |
| 4669 |
end; |
| 4670 |
|
| 4671 |
@ To be able to determine whether \.{\\write18} is enabled from within |
| 4672 |
\TeX\ we also implement \.{\\eof18}. We sort of cheat by having an |
| 4673 |
additional route |scan_four_bit_int_or_18| which is the same as |
| 4674 |
|scan_four_bit_int| except it also accepts the value 18. |
| 4675 |
|
| 4676 |
@<Declare procedures that scan restricted classes of integers@>= |
| 4677 |
procedure scan_four_bit_int_or_18; |
| 4678 |
begin scan_int; |
| 4679 |
if (cur_val<0)or((cur_val>15)and(cur_val<>18)) then |
| 4680 |
begin print_err("Bad number"); |
| 4681 |
@.Bad number@> |
| 4682 |
help2("Since I expected to read a number between 0 and 15,")@/ |
| 4683 |
("I changed this one to zero."); int_error(cur_val); cur_val:=0; |
| 4684 |
end; |
| 4685 |
end; |
| 4686 |
|
| 4687 |
@ Dumping the |xord|, |xchr|, and |xprn| arrays. We dump these always |
| 4688 |
in the format, so a TCX file loaded during format creation can set a |
| 4689 |
default for users of the format. |
| 4690 |
|
| 4691 |
@<Dump |xord|, |xchr|, and |xprn|@>= |
| 4692 |
dump_things(xord[0], 256); |
| 4693 |
dump_things(xchr[0], 256); |
| 4694 |
dump_things(xprn[0], 256); |
| 4695 |
|
| 4696 |
@ Undumping the |xord|, |xchr|, and |xprn| arrays. This code is more |
| 4697 |
complicated, because we want to ensure that a TCX file specified on |
| 4698 |
the command line will override whatever is in the format. Since the |
| 4699 |
tcx file has already been loaded, that implies throwing away the data |
| 4700 |
in the format. Also, if no |translate_filename| is given, but |
| 4701 |
|eight_bit_p| is set we have to make all characters printable. |
| 4702 |
|
| 4703 |
@<Undump |xord|, |xchr|, and |xprn|@>= |
| 4704 |
if translate_filename then begin |
| 4705 |
for k:=0 to 255 do undump_things(dummy_xord, 1); |
| 4706 |
for k:=0 to 255 do undump_things(dummy_xchr, 1); |
| 4707 |
for k:=0 to 255 do undump_things(dummy_xprn, 1); |
| 4708 |
end |
| 4709 |
else begin |
| 4710 |
undump_things(xord[0], 256); |
| 4711 |
undump_things(xchr[0], 256); |
| 4712 |
undump_things(xprn[0], 256); |
| 4713 |
if eight_bit_p then |
| 4714 |
for k:=0 to 255 do |
| 4715 |
xprn[k]:=1; |
| 4716 |
end; |
| 4717 |
|
| 4718 |
|
| 4719 |
@* \[54/web2c-string] The string recycling routines. |
| 4720 |
\TeX{} uses 2 upto 4 {\it new\/} strings when scanning a filename in an |
| 4721 |
\.{\\input}, \.{\\openin}, or \.{\\openout} operation. These strings are |
| 4722 |
normally lost because the reference to them are not saved after finishing |
| 4723 |
the operation. |search_string| searches through the string pool for the |
| 4724 |
given string and returns either 0 or the found string number. |
| 4725 |
|
| 4726 |
@<Declare additional routines for string recycling@>= |
| 4727 |
function search_string(@!search:str_number):str_number; |
| 4728 |
label found; |
| 4729 |
var result: str_number; |
| 4730 |
@!s: str_number; {running index} |
| 4731 |
@!len: integer; {length of searched string} |
| 4732 |
begin result:=0; len:=length(search); |
| 4733 |
if len=0 then {trivial case} |
| 4734 |
begin result:=""; goto found; |
| 4735 |
end |
| 4736 |
else begin s:=search-1; {start search with newest string below |s|; |search>1|!} |
| 4737 |
while s>255 do {first 256 strings depend on implementation!!} |
| 4738 |
begin if length(s)=len then |
| 4739 |
if str_eq_str(s,search) then |
| 4740 |
begin result:=s; goto found; |
| 4741 |
end; |
| 4742 |
decr(s); |
| 4743 |
end; |
| 4744 |
end; |
| 4745 |
found:search_string:=result; |
| 4746 |
end; |
| 4747 |
|
| 4748 |
@ The following routine is a variant of |make_string|. It searches |
| 4749 |
the whole string pool for a string equal to the string currently built |
| 4750 |
and returns a found string. Otherwise a new string is created and |
| 4751 |
returned. Be cautious, you can not apply |flush_string| to a replaced |
| 4752 |
string! |
| 4753 |
|
| 4754 |
@<Declare additional routines for string recycling@>= |
| 4755 |
function slow_make_string : str_number; |
| 4756 |
label exit; |
| 4757 |
var s: str_number; {result of |search_string|} |
| 4758 |
@!t: str_number; {new string} |
| 4759 |
begin t:=make_string; s:=search_string(t); |
| 4760 |
if s>0 then |
| 4761 |
begin flush_string; slow_make_string:=s; return; |
| 4762 |
end; |
| 4763 |
slow_make_string:=t; |
| 4764 |
exit:end; |
| 4765 |
|
| 4766 |
|
| 4767 |
@* \[54/web2c] More changes for Web2c. |
| 4768 |
% Related to [25.366] expansion depth check |
| 4769 |
Sometimes, recursive calls to the |expand| routine may |
| 4770 |
cause exhaustion of the run-time calling stack, resulting in |
| 4771 |
forced execution stops by the operating system. To diminish the chance |
| 4772 |
of this happening, a counter is used to keep track of the recursion |
| 4773 |
depth, in conjunction with a constant called |expand_depth|. |
| 4774 |
|
| 4775 |
This does not catch all possible infinite recursion loops, just the ones |
| 4776 |
that exhaust the application calling stack. The actual maximum value of |
| 4777 |
|expand_depth| is outside of our control, but the initial setting of |
| 4778 |
|10000| should be enough to prevent problems. |
| 4779 |
@^system dependencies@> |
| 4780 |
|
| 4781 |
@<Global...@>= |
| 4782 |
expand_depth_count:integer; |
| 4783 |
|
| 4784 |
@ @<Set init...@>= |
| 4785 |
expand_depth_count:=0; |
| 4786 |
|
| 4787 |
@ % Related to [29.526] expansion depth check |
| 4788 |
When |scan_file_name| starts it looks for a |left_brace| |
| 4789 |
(skipping \.{\\relax}es, as other \.{\\toks}-like primitives). |
| 4790 |
If a |left_brace| is found, then the procedure scans a file |
| 4791 |
name contained in a balanced token list, expanding tokens as |
| 4792 |
it goes. When the scanner finds the balanced token list, it |
| 4793 |
is converted into a string and fed character-by-character to |
| 4794 |
|more_name| to do its job the same as in the ``normal'' file |
| 4795 |
name scanning. |
| 4796 |
|
| 4797 |
@p procedure scan_file_name_braced; |
| 4798 |
var |
| 4799 |
@!save_scanner_status: small_number; {|scanner_status| upon entry} |
| 4800 |
@!save_def_ref: pointer; {|def_ref| upon entry, important if inside `\.{\\message}} |
| 4801 |
@!save_cur_cs: pointer; |
| 4802 |
@!s: str_number; {temp string} |
| 4803 |
@!p: pointer; {temp pointer} |
| 4804 |
@!i: integer; {loop tally} |
| 4805 |
@!save_stop_at_space: boolean; {this should be in tex.ch} |
| 4806 |
@!dummy: boolean; |
| 4807 |
{Initializing} |
| 4808 |
begin save_scanner_status := scanner_status; {|scan_toks| sets |scanner_status| to |absorbing|} |
| 4809 |
save_def_ref := def_ref; {|scan_toks| uses |def_ref| to point to the token list just read} |
| 4810 |
save_cur_cs := cur_cs; {we set |cur_cs| back a few tokens to use in runaway errors} |
| 4811 |
{Scanning a token list} |
| 4812 |
cur_cs := warning_index; {for possible runaway error} |
| 4813 |
{mimick |call_func| from pdfTeX} |
| 4814 |
if scan_toks(false, true) <> 0 then do_nothing; {actually do the scanning} |
| 4815 |
{|s := tokens_to_string(def_ref);|} |
| 4816 |
old_setting := selector; selector:=new_string; |
| 4817 |
show_token_list(link(def_ref),null,pool_size-pool_ptr); |
| 4818 |
selector := old_setting; |
| 4819 |
s := make_string; |
| 4820 |
{turns the token list read in a string to input} |
| 4821 |
{Restoring some variables} |
| 4822 |
delete_token_ref(def_ref); {remove the token list from memory} |
| 4823 |
def_ref := save_def_ref; {and restore |def_ref|} |
| 4824 |
cur_cs := save_cur_cs; {restore |cur_cs|} |
| 4825 |
scanner_status := save_scanner_status; {restore |scanner_status|} |
| 4826 |
{Passing the read string to the input machinery} |
| 4827 |
save_stop_at_space := stop_at_space; {save |stop_at_space|} |
| 4828 |
stop_at_space := false; {set |stop_at_space| to false to allow spaces in file names} |
| 4829 |
begin_name; |
| 4830 |
for i:=str_start[s] to str_start[s+1]-1 do |
| 4831 |
dummy := more_name(str_pool[i]); {add each read character to the current file name} |
| 4832 |
stop_at_space := save_stop_at_space; {restore |stop_at_space|} |
| 4833 |
end; |
| 4834 |
|
| 4835 |
|
| 4836 |
@* \[54/ML\TeX] System-dependent changes for ML\TeX. |
| 4837 |
@^system dependencies@> |
| 4838 |
The boolean variable |mltex_p| is set by web2c according to the given |
| 4839 |
command line option (or an entry in the configuration file) before any |
| 4840 |
\TeX{} function is called. |
| 4841 |
|
| 4842 |
@<Global...@> = |
| 4843 |
@!mltex_p: boolean; |
| 4844 |
|
| 4845 |
@ The boolean variable |mltex_enabled_p| is used to enable ML\TeX's |
| 4846 |
character substitution. It is initialized to |false|. When loading |
| 4847 |
a \.{FMT} it is set to the value of the boolean |mltex_p| saved in |
| 4848 |
the \.{FMT} file. Additionally it is set to the value of |mltex_p| |
| 4849 |
in Ini\TeX. |
| 4850 |
|
| 4851 |
@<Glob...@>= |
| 4852 |
@!mltex_enabled_p:boolean; {enable character substitution} |
| 4853 |
|
| 4854 |
|
| 4855 |
@ @<Set init...@>= |
| 4856 |
mltex_enabled_p:=false; |
| 4857 |
|
| 4858 |
|
| 4859 |
@ The function |effective_char| computes the effective character with |
| 4860 |
respect to font information. The effective character is either the |
| 4861 |
base character part of a character substitution definition, if the |
| 4862 |
character does not exist in the font or the character itself. |
| 4863 |
|
| 4864 |
Inside |effective_char| we can not use |char_info| because the macro |
| 4865 |
|char_info| uses |effective_char| calling this function a second time |
| 4866 |
with the same arguments. |
| 4867 |
|
| 4868 |
If neither the character |c| exists in font |f| nor a character |
| 4869 |
substitution for |c| was defined, you can not use the function value |
| 4870 |
as a character offset in |char_info| because it will access an |
| 4871 |
undefined or invalid |font_info| entry! Therefore inside |char_info| |
| 4872 |
and in other places, |effective_char|'s boolean parameter |err_p| is |
| 4873 |
set to |true| to issue a warning and return the incorrect |
| 4874 |
replacement, but always existing character |font_bc[f]|. |
| 4875 |
@^inner loop@> |
| 4876 |
|
| 4877 |
@<Declare additional functions for ML\TeX@>= |
| 4878 |
function effective_char(@!err_p:boolean; |
| 4879 |
@!f:internal_font_number;@!c:quarterword):integer; |
| 4880 |
label found; |
| 4881 |
var base_c: integer; {or |eightbits|: replacement base character} |
| 4882 |
@!result: integer; {or |quarterword|} |
| 4883 |
begin result:=c; {return |c| unless it does not exist in the font} |
| 4884 |
if not mltex_enabled_p then goto found; |
| 4885 |
if font_ec[f]>=qo(c) then if font_bc[f]<=qo(c) then |
| 4886 |
if char_exists(orig_char_info(f)(c)) then {N.B.: not |char_info|(f)(c)} |
| 4887 |
goto found; |
| 4888 |
if qo(c)>=char_sub_def_min then if qo(c)<=char_sub_def_max then |
| 4889 |
if char_list_exists(qo(c)) then |
| 4890 |
begin base_c:=char_list_char(qo(c)); |
| 4891 |
result:=qi(base_c); {return |base_c|} |
| 4892 |
if not err_p then goto found; |
| 4893 |
if font_ec[f]>=base_c then if font_bc[f]<=base_c then |
| 4894 |
if char_exists(orig_char_info(f)(qi(base_c))) then goto found; |
| 4895 |
end; |
| 4896 |
if err_p then {print error and return existing character?} |
| 4897 |
begin begin_diagnostic; |
| 4898 |
print_nl("Missing character: There is no "); print("substitution for "); |
| 4899 |
@.Missing character@> |
| 4900 |
print_ASCII(qo(c)); print(" in font "); |
| 4901 |
slow_print(font_name[f]); print_char("!"); end_diagnostic(false); |
| 4902 |
result:=qi(font_bc[f]); {N.B.: not non-existing character |c|!} |
| 4903 |
end; |
| 4904 |
found: effective_char:=result; |
| 4905 |
end; |
| 4906 |
|
| 4907 |
|
| 4908 |
@ The function |effective_char_info| is equivalent to |char_info|, |
| 4909 |
except it will return |null_character| if neither the character |c| |
| 4910 |
exists in font |f| nor is there a substitution definition for |c|. |
| 4911 |
(For these cases |char_info| using |effective_char| will access an |
| 4912 |
undefined or invalid |font_info| entry. See the documentation of |
| 4913 |
|effective_char| for more information.) |
| 4914 |
@^inner loop@> |
| 4915 |
|
| 4916 |
@<Declare additional functions for ML\TeX@>= |
| 4917 |
function effective_char_info(@!f:internal_font_number; |
| 4918 |
@!c:quarterword):four_quarters; |
| 4919 |
label exit; |
| 4920 |
var ci:four_quarters; {character information bytes for |c|} |
| 4921 |
@!base_c:integer; {or |eightbits|: replacement base character} |
| 4922 |
begin if not mltex_enabled_p then |
| 4923 |
begin effective_char_info:=orig_char_info(f)(c); return; |
| 4924 |
end; |
| 4925 |
if font_ec[f]>=qo(c) then if font_bc[f]<=qo(c) then |
| 4926 |
begin ci:=orig_char_info(f)(c); {N.B.: not |char_info|(f)(c)} |
| 4927 |
if char_exists(ci) then |
| 4928 |
begin effective_char_info:=ci; return; |
| 4929 |
end; |
| 4930 |
end; |
| 4931 |
if qo(c)>=char_sub_def_min then if qo(c)<=char_sub_def_max then |
| 4932 |
if char_list_exists(qo(c)) then |
| 4933 |
begin {|effective_char_info:=char_info(f)(qi(char_list_char(qo(c))));|} |
| 4934 |
base_c:=char_list_char(qo(c)); |
| 4935 |
if font_ec[f]>=base_c then if font_bc[f]<=base_c then |
| 4936 |
begin ci:=orig_char_info(f)(qi(base_c)); {N.B.: not |char_info|(f)(c)} |
| 4937 |
if char_exists(ci) then |
| 4938 |
begin effective_char_info:=ci; return; |
| 4939 |
end; |
| 4940 |
end; |
| 4941 |
end; |
| 4942 |
effective_char_info:=null_character; |
| 4943 |
exit:end; |
| 4944 |
|
| 4945 |
|
| 4946 |
@ This code is called for a virtual character |c| in |hlist_out| |
| 4947 |
during |ship_out|. It tries to built a character substitution |
| 4948 |
construct for |c| generating appropriate \.{DVI} code using the |
| 4949 |
character substitution definition for this character. If a valid |
| 4950 |
character substitution exists \.{DVI} code is created as if |
| 4951 |
|make_accent| was used. In all other cases the status of the |
| 4952 |
substitution for this character has been changed between the creation |
| 4953 |
of the character node in the hlist and the output of the page---the |
| 4954 |
created \.{DVI} code will be correct but the visual result will be |
| 4955 |
undefined. |
| 4956 |
|
| 4957 |
Former ML\TeX\ versions have replaced the character node by a |
| 4958 |
sequence of character, box, and accent kern nodes splicing them into |
| 4959 |
the original horizontal list. This version does not do this to avoid |
| 4960 |
a)~a memory overflow at this processing stage, b)~additional code to |
| 4961 |
add a pointer to the previous node needed for the replacement, and |
| 4962 |
c)~to avoid wrong code resulting in anomalies because of the use |
| 4963 |
within a \.{\\leaders} box. |
| 4964 |
|
| 4965 |
@<Output a substitution, |goto continue| if not possible@>= |
| 4966 |
begin |
| 4967 |
@<Get substitution information, check it, goto |found| |
| 4968 |
if all is ok, otherwise goto |continue|@>; |
| 4969 |
found: @<Print character substitution tracing log@>; |
| 4970 |
@<Rebuild character using substitution information@>; |
| 4971 |
end |
| 4972 |
|
| 4973 |
|
| 4974 |
@ The global variables for the code to substitute a virtual character |
| 4975 |
can be declared as local. Nonetheless we declare them as global to |
| 4976 |
avoid stack overflows because |hlist_out| can be called recursively. |
| 4977 |
|
| 4978 |
@<Glob...@>= |
| 4979 |
@!accent_c,@!base_c,@!replace_c:integer; |
| 4980 |
@!ia_c,@!ib_c:four_quarters; {accent and base character information} |
| 4981 |
@!base_slant,@!accent_slant:real; {amount of slant} |
| 4982 |
@!base_x_height:scaled; {accent is designed for characters of this height} |
| 4983 |
@!base_width,@!base_height:scaled; {height and width for base character} |
| 4984 |
@!accent_width,@!accent_height:scaled; {height and width for accent} |
| 4985 |
@!delta:scaled; {amount of right shift} |
| 4986 |
|
| 4987 |
|
| 4988 |
@ Get the character substitution information in |char_sub_code| for |
| 4989 |
the character |c|. The current code checks that the substitution |
| 4990 |
exists and is valid and all substitution characters exist in the |
| 4991 |
font, so we can {\it not\/} substitute a character used in a |
| 4992 |
substitution. This simplifies the code because we have not to check |
| 4993 |
for cycles in all character substitution definitions. |
| 4994 |
|
| 4995 |
@<Get substitution information, check it...@>= |
| 4996 |
if qo(c)>=char_sub_def_min then if qo(c)<=char_sub_def_max then |
| 4997 |
if char_list_exists(qo(c)) then |
| 4998 |
begin base_c:=char_list_char(qo(c)); |
| 4999 |
accent_c:=char_list_accent(qo(c)); |
| 5000 |
if (font_ec[f]>=base_c) then if (font_bc[f]<=base_c) then |
| 5001 |
if (font_ec[f]>=accent_c) then if (font_bc[f]<=accent_c) then |
| 5002 |
begin ia_c:=char_info(f)(qi(accent_c)); |
| 5003 |
ib_c:=char_info(f)(qi(base_c)); |
| 5004 |
if char_exists(ib_c) then |
| 5005 |
if char_exists(ia_c) then goto found; |
| 5006 |
end; |
| 5007 |
begin_diagnostic; |
| 5008 |
print_nl("Missing character: Incomplete substitution "); |
| 5009 |
@.Missing character@> |
| 5010 |
print_ASCII(qo(c)); print(" = "); print_ASCII(accent_c); |
| 5011 |
print(" "); print_ASCII(base_c); print(" in font "); |
| 5012 |
slow_print(font_name[f]); print_char("!"); end_diagnostic(false); |
| 5013 |
goto continue; |
| 5014 |
end; |
| 5015 |
begin_diagnostic; |
| 5016 |
print_nl("Missing character: There is no "); print("substitution for "); |
| 5017 |
@.Missing character@> |
| 5018 |
print_ASCII(qo(c)); print(" in font "); |
| 5019 |
slow_print(font_name[f]); print_char("!"); end_diagnostic(false); |
| 5020 |
goto continue |
| 5021 |
|
| 5022 |
|
| 5023 |
@ For |tracinglostchars>99| the substitution is shown in the log file. |
| 5024 |
|
| 5025 |
@<Print character substitution tracing log@>= |
| 5026 |
if tracing_lost_chars>99 then |
| 5027 |
begin begin_diagnostic; |
| 5028 |
print_nl("Using character substitution: "); |
| 5029 |
print_ASCII(qo(c)); print(" = "); |
| 5030 |
print_ASCII(accent_c); print(" "); print_ASCII(base_c); |
| 5031 |
print(" in font "); slow_print(font_name[f]); print_char("."); |
| 5032 |
end_diagnostic(false); |
| 5033 |
end |
| 5034 |
|
| 5035 |
|
| 5036 |
@ This outputs the accent and the base character given in the |
| 5037 |
substitution. It uses code virtually identical to the |make_accent| |
| 5038 |
procedure, but without the node creation steps. |
| 5039 |
|
| 5040 |
Additionally if the accent character has to be shifted vertically it |
| 5041 |
does {\it not\/} create the same code. The original routine in |
| 5042 |
|make_accent| and former versions of ML\TeX{} creates a box node |
| 5043 |
resulting in |push| and |pop| operations, whereas this code simply |
| 5044 |
produces vertical positioning operations. This can influence the |
| 5045 |
pixel rounding algorithm in some \.{DVI} drivers---and therefore will |
| 5046 |
probably be changed in one of the next ML\TeX{} versions. |
| 5047 |
|
| 5048 |
@<Rebuild character using substitution information@>= |
| 5049 |
base_x_height:=x_height(f); |
| 5050 |
base_slant:=slant(f)/float_constant(65536); |
| 5051 |
@^real division@> |
| 5052 |
accent_slant:=base_slant; {slant of accent character font} |
| 5053 |
base_width:=char_width(f)(ib_c); |
| 5054 |
base_height:=char_height(f)(height_depth(ib_c)); |
| 5055 |
accent_width:=char_width(f)(ia_c); |
| 5056 |
accent_height:=char_height(f)(height_depth(ia_c)); |
| 5057 |
@/{compute necessary horizontal shift (don't forget slant)}@/ |
| 5058 |
delta:=round((base_width-accent_width)/float_constant(2)+ |
| 5059 |
base_height*base_slant-base_x_height*accent_slant); |
| 5060 |
@^real multiplication@> |
| 5061 |
@^real addition@> |
| 5062 |
dvi_h:=cur_h; {update |dvi_h|, similar to the last statement in module 620} |
| 5063 |
@/{1. For centering/horizontal shifting insert a kern node.}@/ |
| 5064 |
cur_h:=cur_h+delta; synch_h; |
| 5065 |
@/{2. Then insert the accent character possibly shifted up or down.}@/ |
| 5066 |
if ((base_height<>base_x_height) and (accent_height>0)) then |
| 5067 |
begin {the accent must be shifted up or down} |
| 5068 |
cur_v:=base_line+(base_x_height-base_height); synch_v; |
| 5069 |
if accent_c>=128 then dvi_out(set1); |
| 5070 |
dvi_out(accent_c);@/ |
| 5071 |
cur_v:=base_line; |
| 5072 |
end |
| 5073 |
else begin synch_v; |
| 5074 |
if accent_c>=128 then dvi_out(set1); |
| 5075 |
dvi_out(accent_c);@/ |
| 5076 |
end; |
| 5077 |
cur_h:=cur_h+accent_width; dvi_h:=cur_h; |
| 5078 |
@/{3. For centering/horizontal shifting insert another kern node.}@/ |
| 5079 |
cur_h:=cur_h+(-accent_width-delta); |
| 5080 |
@/{4. Output the base character.}@/ |
| 5081 |
synch_h; synch_v; |
| 5082 |
if base_c>=128 then dvi_out(set1); |
| 5083 |
dvi_out(base_c);@/ |
| 5084 |
cur_h:=cur_h+base_width; |
| 5085 |
dvi_h:=cur_h {update of |dvi_h| is unnecessary, will be set in module 620} |
| 5086 |
|
| 5087 |
@ Dumping ML\TeX-related material. This is just the flag in the |
| 5088 |
format that tells us whether ML\TeX{} is enabled. |
| 5089 |
|
| 5090 |
@<Dump ML\TeX-specific data@>= |
| 5091 |
dump_int(@"4D4C5458); {ML\TeX's magic constant: "MLTX"} |
| 5092 |
if mltex_p then dump_int(1) |
| 5093 |
else dump_int(0); |
| 5094 |
|
| 5095 |
@ Undump ML\TeX-related material, which is just a flag in the format |
| 5096 |
that tells us whether ML\TeX{} is enabled. |
| 5097 |
|
| 5098 |
@<Undump ML\TeX-specific data@>= |
| 5099 |
undump_int(x); {check magic constant of ML\TeX} |
| 5100 |
if x<>@"4D4C5458 then goto bad_fmt; |
| 5101 |
undump_int(x); {undump |mltex_p| flag into |mltex_enabled_p|} |
| 5102 |
if x=1 then mltex_enabled_p:=true |
| 5103 |
else if x<>0 then goto bad_fmt; |
| 5104 |
@z |
| 5105 |
|
| 5106 |
@x [55.1380] l.24996 - extra routines |
| 5107 |
@* \[55] Index. |
| 5108 |
@y |
| 5109 |
|
| 5110 |
@* \[54] System-dependent changes. |
| 5111 |
|
| 5112 |
@<Declare action procedures for use by |main_control|@>= |
| 5113 |
|
| 5114 |
procedure insert_src_special; |
| 5115 |
var toklist, p, q : pointer; |
| 5116 |
begin |
| 5117 |
if (source_filename_stack[in_open] > 0 and is_new_source (source_filename_stack[in_open] |
| 5118 |
, line)) then begin |
| 5119 |
toklist := get_avail; |
| 5120 |
p := toklist; |
| 5121 |
info(p) := cs_token_flag+frozen_special; |
| 5122 |
link(p) := get_avail; p := link(p); |
| 5123 |
info(p) := left_brace_token+"{"; |
| 5124 |
q := str_toks (make_src_special (source_filename_stack[in_open], line)); |
| 5125 |
link(p) := link(temp_head); |
| 5126 |
p := q; |
| 5127 |
link(p) := get_avail; p := link(p); |
| 5128 |
info(p) := right_brace_token+"}"; |
| 5129 |
ins_list (toklist); |
| 5130 |
remember_source_info (source_filename_stack[in_open], line); |
| 5131 |
end; |
| 5132 |
end; |
| 5133 |
|
| 5134 |
procedure append_src_special; |
| 5135 |
var q : pointer; |
| 5136 |
begin |
| 5137 |
if (source_filename_stack[in_open] > 0 and is_new_source (source_filename_stack[in_open] |
| 5138 |
, line)) then begin |
| 5139 |
new_whatsit (special_node, write_node_size); |
| 5140 |
write_stream(tail) := 0; |
| 5141 |
def_ref := get_avail; |
| 5142 |
token_ref_count(def_ref) := null; |
| 5143 |
q := str_toks (make_src_special (source_filename_stack[in_open], line)); |
| 5144 |
link(def_ref) := link(temp_head); |
| 5145 |
write_tokens(tail) := def_ref; |
| 5146 |
remember_source_info (source_filename_stack[in_open], line); |
| 5147 |
end; |
| 5148 |
end; |
| 5149 |
|
| 5150 |
@ This function used to be in pdftex, but is useful in tex too. |
| 5151 |
|
| 5152 |
@p function get_nullstr: str_number; |
| 5153 |
begin |
| 5154 |
get_nullstr := ""; |
| 5155 |
end; |
| 5156 |
|
| 5157 |
|
| 5158 |
@* \[55] Index. |
| 5159 |
@z |