move extra headers
[nestedvm.git] / upstream / build / tex / tex.ch
1 % Change file for GNU Pascal and Linux
2 % (by Don Knuth, 2000; see ../tex-sparc for the prehistory)
3 % (I'm no longer keeping the "efficiency" changes; just enuf for TRIP test)
4 %
5 % Use this file as is to make an INITEX.  To get triptex, use the
6 % shell script ``ini_to_trip'' and re-TANGLE.
7
8 % History:
9 % 2000.04.30 first sketch --- untested --- see FIXTHIS for parts not done yet
10
11 % NOTE: the module numbers in this change file refer to Volume B.
12
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14 % [0] WEAVE: only print changes
15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16 @x
17 \def\botofcontents{\vskip 0pt plus 1fil minus 1.5in}
18 @y
19 \def\botofcontents{\vskip 0pt plus 1fil minus 1.5in}
20 \let\maybe=\iffalse
21 \def\title{\TeX82 changes for GNU Pascal}
22 \def\glob{13}\def\gglob{20, 26} % these are defined in module 1
23 @z
24
25 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26 % [1.2] banner line
27 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
28 @x
29 @d banner=='This is TeX, Version 3.14159' {printed when \TeX\ starts}
30 @y
31 @d banner=='This is '#27'[33;1mNesTeX'#27'[0m, Version 3.14159 for '#27'[31;1mJava'#27'[0m'
32 @z
33
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 % [1.7] debug..gubed, stat..tats
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 @x
38 @d debug==@{ {change this to `$\\{debug}\equiv\null$' when debugging}
39 @d gubed==@t@>@} {change this to `$\\{gubed}\equiv\null$' when debugging}
40 @y
41 @d debug==@{ {the trip test will use debugging}
42 @d gubed==@t@>@}
43 @z
44 @x
45 @d stat==@{ {change this to `$\\{stat}\equiv\null$' when gathering
46   usage statistics}
47 @d tats==@t@>@} {change this to `$\\{tats}\equiv\null$' when gathering
48   usage statistics}
49 @y
50 @d stat==
51 @d tats==
52 @z
53
54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
55 % [1.8] init..tini
56 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 @x
58 @d init== {change this to `$\\{init}\equiv\.{@@\{}$' in the production version}
59 @d tini== {change this to `$\\{tini}\equiv\.{@@\}}$' in the production version}
60 @y
61 @d init==
62 @d tini==
63 @z
64
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 % [1.10] othercases, feature of ISO Extended Pascal
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
68 @x
69 @d othercases == others: {default for cases not listed explicitly}
70 @y
71 @d othercases == otherwise {default for cases not listed explicitly}
72 @z
73
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 % [1.11] compile-time constants
76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77 @x
78 @!mem_max=30000; {greatest index in \TeX's internal |mem| array;
79   must be strictly less than |max_halfword|;
80   must be equal to |mem_top| in \.{INITEX}, otherwise |>=mem_top|}
81 @!mem_min=0; {smallest index in \TeX's internal |mem| array;
82   must be |min_halfword| or more;
83   must be equal to |mem_bot| in \.{INITEX}, otherwise |<=mem_bot|}
84 @!buf_size=500; {maximum number of characters simultaneously present in
85   current lines of open files and in control sequences between
86   \.{\\csname} and \.{\\endcsname}; must not exceed |max_halfword|}
87 @!error_line=72; {width of context lines on terminal error messages}
88 @!half_error_line=42; {width of first lines of contexts in terminal
89   error messages; should be between 30 and |error_line-15|}
90 @!max_print_line=79; {width of longest text lines output; should be at least 60}
91 @!stack_size=200; {maximum number of simultaneous input sources}
92 @!max_in_open=6; {maximum number of input files and error insertions that
93   can be going on simultaneously}
94 @!font_max=75; {maximum internal font number; must not exceed |max_quarterword|
95   and must be at most |font_base+256|}
96 @!font_mem_size=20000; {number of words of |font_info| for all fonts}
97 @!param_size=60; {maximum number of simultaneous macro parameters}
98 @!nest_size=40; {maximum number of semantic levels simultaneously active}
99 @!max_strings=3000; {maximum number of strings; must not exceed |max_halfword|}
100 @!string_vacancies=8000; {the minimum number of characters that should be
101   available for the user's control sequences and font names,
102   after \TeX's own error messages are stored}
103 @!pool_size=32000; {maximum number of characters in strings, including all
104   error messages and help texts, and the names of all fonts and
105   control sequences; must exceed |string_vacancies| by the total
106   length of \TeX's own strings, which is currently about 23000}
107 @!save_size=600; {space for saving values outside of current group; must be
108   at most |max_halfword|}
109 @!trie_size=8000; {space for hyphenation patterns; should be larger for
110   \.{INITEX} than it is in production versions of \TeX}
111 @!trie_op_size=500; {space for ``opcodes'' in the hyphenation patterns}
112 @!dvi_buf_size=800; {size of the output buffer; must be a multiple of 8}
113 @!file_name_size=40; {file names shouldn't be longer than this}
114 @!pool_name='TeXformats:TEX.POOL                     ';
115   {string of length |file_name_size|; tells where the string pool appears}
116 @y
117 @!mem_max=300000; {greatest index in \TeX's internal |mem| array;
118   must be strictly less than |max_halfword|;
119   must be equal to |mem_top| in \.{INITEX}, otherwise |>=mem_top|}
120 @!mem_min=0; {smallest index in \TeX's internal |mem| array;
121   must be |min_halfword| or more;
122   must be equal to |mem_bot| in \.{INITEX}, otherwise |<=mem_bot|}
123 @!buf_size=5000; {maximum number of characters simultaneously present in
124   current lines of open files and in control sequences between
125   \.{\\csname} and \.{\\endcsname}; must not exceed |max_halfword|}
126 @!error_line=79; {width of context lines on terminal error messages}
127 @!half_error_line=50; {width of first lines of contexts in terminal
128   error messages; should be between 30 and |error_line-15|}
129 @!max_print_line=79; {width of longest text lines output; should be at least 60}
130 @!stack_size=200; {maximum number of simultaneous input sources}
131 @!max_in_open=15; {maximum number of input files and error insertions that
132   can be going on simultaneously}
133 @!font_max=127; {maximum internal font number; must not exceed |max_quarterword|
134   and must be at most |font_base+256|}
135 @!font_mem_size=40000; {number of words of |font_info| for all fonts}
136 @!param_size=60; {maximum number of simultaneous macro parameters}
137 @!nest_size=40; {maximum number of semantic levels simultaneously active}
138 @!max_strings=30000; {maximum number of strings; must not exceed |max_halfword|}
139 @!string_vacancies=8000; {the minimum number of characters that should be
140   available for the user's control sequences and font names,
141   after \TeX's own error messages are stored}
142 @!pool_size=100000; {maximum number of characters in strings, including all
143   error messages and help texts, and the names of all fonts and
144   control sequences; must exceed |string_vacancies| by the total
145   length of \TeX's own strings, which is currently about 23000}
146 @!save_size=6000; {space for saving values outside of current group; must be
147   at most |max_halfword|}
148 @!trie_size=30000; {space for hyphenation patterns; should be larger for
149   \.{INITEX} than it is in production versions of \TeX}
150 @!trie_op_size=500; {space for ``opcodes'' in the hyphenation patterns}
151 @!dvi_buf_size=800; {size of the output buffer; must be a multiple of 8}
152 @!file_name_size=1024; {file names shouldn't be longer than this}
153 @!pool_name='tex.pool';
154   {string of length |file_name_size|; the string pool name}
155 @.TeXformats@>
156 @z
157
158 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
159 % [1.12] sensitive compile-time constants
160 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
161 @x
162 @d mem_bot=0 {smallest index in the |mem| array dumped by \.{INITEX};
163   must not be less than |mem_min|}
164 @d mem_top==30000 {largest index in the |mem| array dumped by \.{INITEX};
165   must be substantially larger than |mem_bot|
166   and not greater than |mem_max|}
167 @d font_base=0 {smallest internal font number; must not be less
168   than |min_quarterword|}
169 @d hash_size=2100 {maximum number of control sequences; it should be at most
170   about |(mem_max-mem_min)/10|}
171 @d hash_prime=1777 {a prime number equal to about 85\pct! of |hash_size|}
172 @d hyph_size=307 {another prime; the number of \.{\\hyphenation} exceptions}
173 @y
174 @d mem_bot=0 {smallest index in the |mem| array dumped by \.{INITEX};
175   must not be less than |mem_min|}
176 @d mem_top==300000 {largest index in the |mem| array dumped by \.{INITEX};
177   must be substantially larger than |mem_bot|
178   and not greater than |mem_max|}
179 @d font_base=0 {smallest internal font number; must not be less
180   than |min_quarterword|}
181 @d hash_size=10000 {maximum number of control sequences; it should be at most
182   about |(mem_max-mem_min)/10|}
183 @d hash_prime=3443 {a prime number equal to about 85\pct! of |hash_size|}
184 @d hyph_size=307 {another prime; the number of \.{\\hyphenation} exceptions}
185 @z
186
187 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
188 % [2.23] allow any character that we can input to get in
189 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
190 @x
191 for i:=0 to @'37 do xchr[i]:=' ';
192 for i:=@'177 to @'377 do xchr[i]:=' ';
193 @y
194 for i:=0 to @'37 do xchr[i]:=chr(i);
195 for i:=@'177 to @'377 do xchr[i]:=chr(i);
196 @z
197
198 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
199 % [3.25] file types
200 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
201 @x
202 @!eight_bits=0..255; {unsigned one-byte quantity}
203 @!alpha_file=packed file of text_char; {files that contain textual data}
204 @y
205 @!eight_bits=ByteCard; {unsigned one-byte quantity}
206 @!alpha_file=t@&e@&x@&t; {files that contain textual data}
207 @z
208
209 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
210 % [3.27] file opening
211 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
212 @x
213 @ The \ph\ compiler with which the present version of \TeX\ was prepared has
214 extended the rules of \PASCAL\ in a very convenient way. To open file~|f|,
215 we can write
216 $$\vbox{\halign{#\hfil\qquad&#\hfil\cr
217 |reset(f,@t\\{name}@>,'/O')|&for input;\cr
218 |rewrite(f,@t\\{name}@>,'/O')|&for output.\cr}}$$
219 The `\\{name}' parameter, which is of type `{\bf packed array
220 $[\langle\\{any}\rangle]$ of \\{char}}', stands for the name of
221 the external file that is being opened for input or output.
222 Blank spaces that might appear in \\{name} are ignored.
223
224 The `\.{/O}' parameter tells the operating system not to issue its own
225 error messages if something goes wrong. If a file of the specified name
226 cannot be found, or if such a file cannot be opened for some other reason
227 (e.g., someone may already be trying to write the same file), we will have
228 |@!erstat(f)<>0| after an unsuccessful |reset| or |rewrite|.  This allows
229 \TeX\ to undertake appropriate corrective action.
230 @:PASCAL H}{\ph@>
231 @^system dependencies@>
232
233 \TeX's file-opening procedures return |false| if no file identified by
234 |name_of_file| could be opened.
235
236 @d reset_OK(#)==erstat(#)=0
237 @d rewrite_OK(#)==erstat(#)=0
238
239 @p function a_open_in(var f:alpha_file):boolean;
240   {open a text file for input}
241 begin reset(f,name_of_file,'/O'); a_open_in:=reset_OK(f);
242 end;
243 @#
244 function a_open_out(var f:alpha_file):boolean;
245   {open a text file for output}
246 begin rewrite(f,name_of_file,'/O'); a_open_out:=rewrite_OK(f);
247 end;
248 @#
249 function b_open_in(var f:byte_file):boolean;
250   {open a binary file for input}
251 begin reset(f,name_of_file,'/O'); b_open_in:=reset_OK(f);
252 end;
253 @#
254 function b_open_out(var f:byte_file):boolean;
255   {open a binary file for output}
256 begin rewrite(f,name_of_file,'/O'); b_open_out:=rewrite_OK(f);
257 end;
258 @#
259 function w_open_in(var f:word_file):boolean;
260   {open a word file for input}
261 begin reset(f,name_of_file,'/O'); w_open_in:=reset_OK(f);
262 end;
263 @#
264 function w_open_out(var f:word_file):boolean;
265   {open a word file for output}
266 begin rewrite(f,name_of_file,'/O'); w_open_out:=rewrite_OK(f);
267 end;
268 @y
269 @ An external C procedure, |test_access| is used to check whether or not the
270 open will work.  It is declared in the ``ext.h'' include file, and it returns
271 |true| or |false|. The |Trim(name_of_file)| global holds the file name whose access
272 is to be tested.
273 The first parameter for |test_access| is the access mode,
274 one of |read_access_mode| or |write_access_mode|.
275
276 We also implement path searching in |test_access|:  its second parameter is
277 one of the ``file path'' constants defined below.  If |Trim(name_of_file)|
278 doesn't start with |'/'| then |test_access| tries prepending pathnames
279 from the appropriate path list until success or the end of path list
280 is reached.
281 On return, |Trim(name_of_file)| contains the original name with the path
282 that succeeded (if any) prepended.  It is the name used in the various
283 open procedures.
284
285 Note that |a_open_in| has been redefined to take an additional argument,
286 which should be one of the ``file path'' specifiers.
287 Since |b_open_in| is only used for \.{TFM} files, and
288 |w_open_in| is only used for format files, we don't need a path specifying
289 argument for them.
290 Path searching is not done for output files.
291
292 @d read_access_mode=4  {``read'' mode for |test_access|}
293 @d write_access_mode=2 {``write'' mode for |test_access|}
294
295 @d no_file_path=0    {no path searching should be done}
296 @d input_file_path=1 {path specifier for \.{\\input} files}
297 @d read_file_path=2  {path specifier for \.{\\read} files}
298 @d font_file_path=3  {path specifier for \.{TFM} files}
299 @d format_file_path=4 {path specifier for format files}
300 @d pool_file_path=5  {path specifier for the pool file}
301
302 @p function a_open_in(var f:alpha_file):boolean;
303   {open a text file for input}
304 var str:String;
305 begin
306 reset(f,name_of_file);
307 a_open_in:=IOResult=0;
308 end;
309
310
311
312 @#
313 function a_open_out(var f:alpha_file):boolean;
314   {open a text file for output}
315 var @!ok:boolean;
316 begin
317      rewrite(f,Trim(name_of_file));
318 a_open_out:=true;
319 end;
320 @#
321 function b_open_in(var f:byte_file):boolean;
322   {open a binary file for input}
323 var @!ok:boolean;
324 begin
325      reset(f,Trim(name_of_file));
326 b_open_in:=true;
327 end;
328 @#
329 function b_open_out(var f:byte_file):boolean;
330   {open a binary file for output}
331 var @!ok:boolean;
332 begin
333      rewrite(f,Trim(name_of_file));
334 b_open_out:=true;
335 end;
336 @#
337 function w_open_in(var f:word_file):boolean;
338   {open a word file for input}
339 var @!ok:boolean;
340 begin
341      reset(f,Trim(name_of_file));
342 w_open_in:=true;
343 end;
344 @#
345 function w_open_out(var f:word_file):boolean;
346   {open a word file for output}
347 var @!ok:boolean;
348 begin
349      rewrite(f,Trim(name_of_file));
350 w_open_out:=true;
351 end;
352 @z
353
354
355 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
356 % [3.32] term_in/out are input,output
357 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
358 @x
359 @!term_in:alpha_file; {the terminal as an input file}
360 @!term_out:alpha_file; {the terminal as an output file}
361
362 @y
363 @!{the terminal as an input file}
364
365 @z
366
367 @x
368 @d t_open_in==reset(term_in,'TTY:','/O/I') {open the terminal for text input}
369 @d t_open_out==rewrite(term_out,'TTY:','/O') {open the terminal for text output}
370 @y
371 @d term_in==Input
372 @d term_out==Output
373 @d t_open_in==do_nothing
374 @d t_open_out==do_nothing
375 @z
376
377
378 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
379 % [3.34] flushing output
380 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
381 @x
382 these operations can be specified in \ph:
383 @^system dependencies@>
384
385 @d update_terminal == break(term_out) {empty the terminal output buffer}
386 @d clear_terminal == break_in(term_in,true) {clear the terminal input buffer}
387 @d wake_up_terminal == do_nothing {cancel the user's cancellation of output}
388 @y
389 these operations can be specified with Berkeley {\mc UNIX}:
390 @^system dependencies@>
391
392 @d update_terminal == {nothing necessary on UNIX}
393 @d clear_terminal == {nothing necessary on UNIX}
394 @d wake_up_terminal == {nothing necessary on UNIX}
395 @z
396
397 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
398 % [4.38] string data
399 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
400 @x
401 @!packed_ASCII_code = 0..255; {elements of |str_pool| array}
402 @y
403 @!packed_ASCII_code = ByteCard; {elements of |str_pool| array}
404 @z
405
406 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
407 % [4.51,52,53] make TEX.POOL lowercase in messages
408 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
409 @x
410 else  bad_pool('! I can''t read TEX.POOL.')
411 @y
412 else  bad_pool('! I can''t read tex.pool.')
413 @z
414 @x
415 begin if eof(pool_file) then bad_pool('! TEX.POOL has no check sum.');
416 @y
417 begin if eof(pool_file) then bad_pool('! tex.pool has no check sum.');
418 @z
419 @x
420     bad_pool('! TEX.POOL line doesn''t begin with two digits.');
421 @y
422     bad_pool('! tex.pool line doesn''t begin with two digits.');
423 @z
424 @x
425   bad_pool('! TEX.POOL check sum doesn''t have nine digits.');
426 @y
427   bad_pool('! tex.pool check sum doesn''t have nine digits.');
428 @z
429 @x
430 done: if a<>@$ then bad_pool('! TEX.POOL doesn''t match; TANGLE me again.');
431 @y
432 done: if a<>@$ then bad_pool('! tex.pool doesn''t match; tangle me again.');
433 @z
434
435
436 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
437 % [8.110] ranges for quarter,half words FIXTHIS
438 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
439 @x
440 @d min_quarterword=0 {smallest allowable value in a |quarterword|}
441 @d max_quarterword=255 {largest allowable value in a |quarterword|}
442 @d min_halfword==0 {smallest allowable value in a |halfword|}
443 @d max_halfword==65535 {largest allowable value in a |halfword|}
444 @y
445 @d min_quarterword=-128 {smallest allowable value in a |quarterword|}
446 @d max_quarterword=127 {largest allowable value in a |quarterword|}
447 @d min_halfword==-2147483648 {smallest allowable value in a |halfword|}
448 @d max_halfword==2147483647 {largest allowable value in a |halfword|}
449 @z
450
451 @x
452 @<Types...@>=
453 @!quarterword = min_quarterword..max_quarterword; {1/4 of a word}
454 @!halfword=min_halfword..max_halfword; {1/2 of a word}
455 @!two_choices = 1..2; {used when there are two variants in a record}
456 @!four_choices = 1..4; {used when there are four variants in a record}
457 @y
458 @<Types...@>=
459 @!quarterword = min_quarterword..max_quarterword; {1/4 of a word}
460 @!halfword=min_halfword..max_halfword; {1/2 of a word}
461 @!two_choices = 1..2; {used when there are two variants in a record}
462 @!four_choices = 1..4; {used when there are four variants in a record}
463 @z
464
465 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
466 % [11.165] fix the word "free" so that it doesn't conflict with a runtime proc
467 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
468 @x
469 been included. (You may want to decrease the size of |mem| while you
470 @^debugging@>
471 are debugging.)
472 @y
473 been included. (You may want to decrease the size of |mem| while you
474 @^debugging@>
475 are debugging.)
476
477 @d free==free_arr
478 @z
479
480 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
481 % [12.186] glue_ratio fix  FIXTHIS
482 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
483 @x
484 floating point underflow on the author's computer.
485 @^system dependencies@>
486 @^dirty \PASCAL@>
487
488 @<Display the value of |glue_set(p)|@>=
489 g:=float(glue_set(p));
490 if (g<>float_constant(0))and(glue_sign(p)<>normal) then
491   begin print(", glue set ");
492   if glue_sign(p)=shrinking then print("- ");
493   if abs(mem[p+glue_offset].int)<@'4000000 then print("?.?")
494   else if abs(g)>float_constant(20000) then
495     begin if g>float_constant(0) then print_char(">")
496     else print("< -");
497     print_glue(20000*unity,glue_order(p),0);
498     end
499   else print_glue(round(unity*g),glue_order(p),0);
500 @^real multiplication@>
501   end
502 @y
503 floating point underflow on the author's computer.
504 For the {\mc VAX}, the only possible random value that could hurt is
505 a reserved value with 1 in the sign bit and 0 for the (excess) exponent.
506 Because the sign-plus-exponent is in the middle of the word, the chances
507 of this happening are miniscule, and ignored here.
508 @^system dependencies@>
509 @^dirty \PASCAL@>
510
511 @<Display the value of |glue_set(p)|@>=
512 g:=float(glue_set(p));
513 if (g<>float_constant(0))and(glue_sign(p)<>normal) then
514   begin print(", glue set ");
515   if glue_sign(p)=shrinking then print("- ");
516   if abs(float(glue_set(p)))>20000.0 then
517      begin if float(glue_set(p))>0 then print_char(">")
518      else print("< -");
519      print_glue(20000*unity,glue_order(p),0);
520      end
521   else print_glue(round(float(glue_set(p))*unity),glue_order(p),0);
522 @^real multiplication@>
523   end
524 @z
525
526 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
527 % [29.513] area and extension rules
528 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
529 @x
530 @ The file names we shall deal with for illustrative purposes have the
531 following structure:  If the name contains `\.>' or `\.:', the file area
532 consists of all characters up to and including the final such character;
533 otherwise the file area is null.  If the remaining file name contains
534 `\..', the file extension consists of all such characters from the first
535 remaining `\..' to the end, otherwise the file extension is null.
536 @^system dependencies@>
537
538 We can scan such file names easily by using two global variables that keep track
539 of the occurrences of area and extension delimiters:
540
541 @<Glob...@>=
542 @!area_delimiter:pool_pointer; {the most recent `\.>' or `\.:', if any}
543 @!ext_delimiter:pool_pointer; {the relevant `\..', if any}
544 @y
545 @ The file names we shall deal with for SunOS have the
546 following structure:  If the name contains `\./', the file area
547 consists of all characters up to and including the final such character;
548 otherwise the file area is null.  If the remaining file name contains
549 `\..', the file extension consists of all such characters from the first
550 remaining `\..' to the end, otherwise the file extension is null.
551 @^system dependencies@>
552
553 We can scan such file names easily by using two global variables that keep
554 track of the occurrences of area and extension delimiters:
555
556 @<Glob...@>=
557 @!area_delimiter:pool_pointer; {the most recent `\./', if any}
558 @!ext_delimiter:pool_pointer; {the most recent `\..', if any}
559 @z
560
561 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
562 % [29.516] more_name
563 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
564 @x
565   if (c=">")or(c=":") then
566 @y
567   if c="/" then
568 @z
569
570 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
571 % [29.520] default format
572 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
573 @x
574 @d format_default_length=20 {length of the |TEX_format_default| string}
575 @d format_area_length=11 {length of its area part}
576 @d format_ext_length=4 {length of its `\.{.fmt}' part}
577 @y
578 Under Linux we don't give the area part, instead depending
579 on the path searching that will happen during file opening.
580
581 @d format_default_length=9 {length of the |TEX_format_default| string}
582 @d format_area_length=0 {length of its area part}
583 @d format_ext_length=4 {length of its `\.{.fmt}' part}
584 @z
585
586 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
587 % [29.521] plain format location
588 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
589 @x
590 TEX_format_default:='TeXformats:plain.fmt';
591 @y
592 TEX_format_default:='plain.fmt';
593 @z
594
595 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
596 % [29.524] format file opening: only try once, with path search
597 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
598 @x
599   pack_buffered_name(0,loc,j-1); {try first without the system file area}
600   if w_open_in(fmt_file) then goto found;
601   pack_buffered_name(format_area_length,loc,j-1);
602     {now try the system format file area}
603   if w_open_in(fmt_file) then goto found;
604 @y
605   pack_buffered_name(0,loc,j-1);
606   if w_open_in(fmt_file) then goto found;
607 @z
608
609 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
610 % [29.525] make_name_string
611 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
612 @x
613 which simply makes a \TeX\ string from the value of |name_of_file|, should
614 ideally be changed to deduce the full name of file~|f|, which is the file
615 most recently opened, if it is possible to do this in a \PASCAL\ program.
616 @^system dependencies@>
617
618 This routine might be called after string memory has overflowed, hence
619 we dare not use `|str_room|'.
620
621 @p function make_name_string:str_number;
622 var k:1..file_name_size; {index into |name_of_file|}
623 begin if (pool_ptr+name_length>pool_size)or(str_ptr=max_strings)or
624  (cur_length>0) then
625   make_name_string:="?"
626 else  begin for k:=1 to name_length do append_char(xord[name_of_file[k]]);
627   make_name_string:=make_string;
628   end;
629 end;
630 @y
631 which simply makes a \TeX\ string from the value of |name_of_file|, should
632 ideally be changed to deduce the full name of file~|f|, which is the file
633 most recently opened, if it is possible to do this in a \PASCAL\ program.
634 With the Berkeley {\mc UNIX} version, we know that |name_of_file|
635 contains |name_of_file| prepended with the directory name that was found
636 by path searching.
637 If |name_of_file| starts with |'./'|, we don't use that part of the
638 name, since {\mc UNIX} users understand that.
639 @^system dependencies@>
640
641 This routine might be called after string memory has overflowed, hence
642 we dare not use `|str_room|'.
643
644 @p function make_name_string:str_number;
645 var k,@!kstart:1..file_name_size; {index into |name_of_file|}
646 begin
647 k:=1;
648 while (k<file_name_size) and (xord[name_of_file[k]]<>" ") do
649     incr(k);
650 name_length:=k-1; {the real |name_length|}
651 if (pool_ptr+name_length>pool_size)or(str_ptr=max_strings)or
652  (cur_length>0) then
653   make_name_string:="?"
654 else begin
655   if (xord[name_of_file[1]]=".") and (xord[name_of_file[2]]="/") then
656       kstart:=3
657   else
658       kstart:=1;
659   for k:=kstart to name_length do append_char(xord[name_of_file[k]]);
660   make_name_string:=make_string;
661   end
662 end;
663 @z
664
665 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
666 % [30.563] opening tfm file: now path searching is done
667 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
668 % Set temp_int to value of first byte
669 @x
670 @ @<Open |tfm_file| for input@>=
671 file_opened:=false;
672 if aire="" then pack_file_name(nom,TEX_font_area,".tfm")
673 else pack_file_name(nom,aire,".tfm");
674 if not b_open_in(tfm_file) then abort;
675 file_opened:=true
676 @y
677 @ Here we have to ``prime the pump'' for the |temp_int| trick explained below.
678
679  @<Open |tfm_file| for input@>=
680 file_opened:=false;
681 pack_file_name(nom,aire,".tfm");
682 if not b_open_in(tfm_file) then abort;
683 begin
684       var temp_int:integer;
685       temp_int:=tfm_file^;
686       if temp_int<0 then temp_int:=temp_int+256;
687 end;
688 file_opened:=true
689 @z
690