home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / unixtex-6.1b-src.tgz / tar.out / contrib / unixtex / web2c / tex / tex.ch < prev    next >
Text File  |  1996-09-28  |  73KB  |  2,008 lines

  1. % tex.ch for C compilation with web2c, derived from various other change files.
  2. % By Tim Morgan, UC Irvine ICS Department, and many others.
  3. %
  4. % Modification history:
  5. % (05/28/86) ETM Started with TeX 2.0
  6. % (06/03/87) ETM Brought up to TeX 2.2
  7. % (09/26/87) ETM Brought up to TeX 2.3
  8. % (10/01/87) ETM Brought up to TeX 2.5
  9. % (12/21/87) ETM Brought up to TeX 2.7
  10. % (01/14/88) ETM Brought up to TeX 2.9
  11. % (02/20/88) PAM Revised format and module numbers
  12. % (03/01/88) ETM Eliminated some unused variables and unnecesary tests
  13. % (05/09/88) ETM Added yet another casting bug fix
  14. % (06/21/88) ETM Brought up to TeX version 2.93
  15. % (12/11/88) ETM Brought up to TeX version 2.94
  16. % (01/12/89) PAM Brought up to TeX version 2.95
  17. % (02/14/89) ETM Brought up to TeX version 2.96
  18. % (03/10/89) ETM Brought up to TeX version 2.98
  19. % (07/06/89) ETM Brought up to TeX version 2.991
  20. % (11/30/89) KB  To version 2.992 (8-bit).
  21. % (01/10/90) SR  To version 2.993.
  22. % (03/27/90) KY  To version 3.0.
  23. % (more recent changes in ChangeLog)
  24. % The module numbers in this change file refer to the published text in
  25. % TeX: The Program, Volume B of Computers&Typesetting.
  26.  
  27.  
  28. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  29. % [0] WEAVE: print changes only.
  30. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  31. @x
  32.   \def\?##1]{\hbox to 1in{\hfil##1.\ }}
  33.   }
  34. @y
  35.   \def\?##1]{\hbox{Changes to \hbox to 1em{\hfil##1}.\ }}
  36.   }
  37. \let\maybe=\iffalse
  38. @z
  39.  
  40. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  41. % [1.2] banner
  42. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  43. @x
  44. @d banner=='This is TeX, Version 3.1415' {printed when \TeX\ starts}
  45. @y
  46. @d banner=='This is TeX, Version 3.1415' {more is printed later}
  47. @z
  48.  
  49. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  50. % [1.4] program header
  51. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  52. @x
  53. Actually the heading shown here is not quite normal: The |program| line
  54. does not mention any |output| file, because \ph\ would ask the \TeX\ user
  55. to specify a file name if |output| were specified here.
  56. @^system dependencies@>
  57.  
  58. @d mtype==t@&y@&p@&e {this is a \.{WEB} coding trick:}
  59. @f mtype==type {`\&{mtype}' will be equivalent to `\&{type}'}
  60. @f type==true {but `|type|' will not be treated as a reserved word}
  61.  
  62. @p @t\4@>@<Compiler directives@>@/
  63. program TEX; {all file names are defined dynamically}
  64. label @<Labels in the outer block@>@/
  65. @y
  66.  
  67. @d mtype==t@&y@&p@&e {this is a \.{WEB} coding trick:}
  68. @f mtype==type {`\&{mtype}' will be equivalent to `\&{type}'}
  69. @f type==true {but `|type|' will not be treated as a reserved word}
  70.  
  71. @p @t\4@>@<Compiler directives@>@/
  72. program TEX; {all file names are defined dynamically}
  73. @z
  74.  
  75. @x
  76. @<Labels in the out...@>=
  77. start_of_TEX@t\hskip-2pt@>, end_of_TEX@t\hskip-2pt@>,@,final_end;
  78.   {key control points}
  79. @y
  80. @<Labels in the outer block@>=
  81. start_of_TEX@t\hskip-2pt@>, end_of_TEX@t\hskip-2pt@>,@,final_end;
  82.   {key control points}
  83. @z
  84.  
  85. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  86. % [1.7] debug..gubed, stat..tats
  87. % Here we change these WEB symbols, which are used much as #ifdef's
  88. % are in C, into something which will get translated into actual #ifdef's.
  89. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  90. @x
  91. @d debug==@{ {change this to `$\\{debug}\equiv\null$' when debugging}
  92. @d gubed==@t@>@} {change this to `$\\{gubed}\equiv\null$' when debugging}
  93. @y
  94. @d debug==ifdef('DEBUG')
  95. @d gubed==endif('DEBUG')
  96. @z
  97. @x
  98. @d stat==@{ {change this to `$\\{stat}\equiv\null$' when gathering
  99.   usage statistics}
  100. @d tats==@t@>@} {change this to `$\\{tats}\equiv\null$' when gathering
  101.   usage statistics}
  102. @y
  103. @d stat==ifdef('STAT')
  104. @d tats==endif('STAT')
  105. @z
  106.  
  107. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  108. % [1.8] Same, for `init..tini'.
  109. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  110. @x
  111. @d init== {change this to `$\\{init}\equiv\.{@@\{}$' in the production version}
  112. @d tini== {change this to `$\\{tini}\equiv\.{@@\}}$' in the production version}
  113. @y
  114. @d init==ifdef('INITEX')
  115. @d tini==endif('INITEX')
  116. @z
  117.  
  118. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  119. % [1.9] Turn off all compiler directives.
  120. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  121. @x
  122. @{@&$C-,A+,D-@} {no range check, catch arithmetic overflow, no debug overhead}
  123. @!debug @{@&$C+,D+@}@+ gubed {but turn everything on when debugging}
  124. @y
  125. @z
  126.  
  127. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  128. % [1.11] Compile-time constants: some enlarged, dvi_buf_size 16K for
  129. % BSD I/O, file_name_size is set from the system constant.
  130. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  131. @x
  132. @<Constants...@>=
  133. @!mem_max=30000; {greatest index in \TeX's internal |mem| array;
  134.   must be strictly less than |max_halfword|;
  135.   must be equal to |mem_top| in \.{INITEX}, otherwise |>=mem_top|}
  136. @!mem_min=0; {smallest index in \TeX's internal |mem| array;
  137.   must be |min_halfword| or more;
  138.   must be equal to |mem_bot| in \.{INITEX}, otherwise |<=mem_bot|}
  139. @!buf_size=500; {maximum number of characters simultaneously present in
  140.   current lines of open files and in control sequences between
  141.   \.{\\csname} and \.{\\endcsname}; must not exceed |max_halfword|}
  142. @!error_line=72; {width of context lines on terminal error messages}
  143. @!half_error_line=42; {width of first lines of contexts in terminal
  144.   error messages; should be between 30 and |error_line-15|}
  145. @!max_print_line=79; {width of longest text lines output; should be at least 60}
  146. @!stack_size=200; {maximum number of simultaneous input sources}
  147. @!max_in_open=6; {maximum number of input files and error insertions that
  148.   can be going on simultaneously}
  149. @!font_max=75; {maximum internal font number; must not exceed |max_quarterword|
  150.   and must be at most |font_base+256|}
  151. @!font_mem_size=20000; {number of words of |font_info| for all fonts}
  152. @!param_size=60; {maximum number of simultaneous macro parameters}
  153. @!nest_size=40; {maximum number of semantic levels simultaneously active}
  154. @!max_strings=3000; {maximum number of strings; must not exceed |max_halfword|}
  155. @!string_vacancies=8000; {the minimum number of characters that should be
  156.   available for the user's control sequences and font names,
  157.   after \TeX's own error messages are stored}
  158. @!pool_size=32000; {maximum number of characters in strings, including all
  159.   error messages and help texts, and the names of all fonts and
  160.   control sequences; must exceed |string_vacancies| by the total
  161.   length of \TeX's own strings, which is currently about 23000}
  162. @!save_size=600; {space for saving values outside of current group; must be
  163.   at most |max_halfword|}
  164. @!trie_size=8000; {space for hyphenation patterns; should be larger for
  165.   \.{INITEX} than it is in production versions of \TeX}
  166. @!trie_op_size=500; {space for ``opcodes'' in the hyphenation patterns}
  167. @!dvi_buf_size=800; {size of the output buffer; must be a multiple of 8}
  168. @!file_name_size=40; {file names shouldn't be longer than this}
  169. @!pool_name='TeXformats:TEX.POOL                     ';
  170.   {string of length |file_name_size|; tells where the string pool appears}
  171. @y
  172. @d file_name_size == PATH_MAX
  173.  
  174. @<Constants...@>=
  175. @!mem_max=262140; {greatest index in \TeX's internal |mem| array;
  176.   must be strictly less than |max_halfword|;
  177.   must be equal to |mem_top| in \.{INITEX}, otherwise |>=mem_top|}
  178. @!mem_min=0; {smallest index in \TeX's internal |mem| array;
  179.   must be |min_halfword| or more;
  180.   must be equal to |mem_bot| in \.{INITEX}, otherwise |<=mem_bot|}
  181. @!buf_size=3000; {maximum number of characters simultaneously present in
  182.   current lines of open files and in control sequences between
  183.   \.{\\csname} and \.{\\endcsname}; must not exceed |max_halfword|}
  184. @!error_line=79; {width of context lines on terminal error messages}
  185. @!half_error_line=50; {width of first lines of contexts in terminal
  186.   error messages; should be between 30 and |error_line-15|}
  187. @!max_print_line=79; {width of longest text lines output; should be at least 60}
  188. @!stack_size=300; {maximum number of simultaneous input sources}
  189. @!max_in_open=15; {maximum number of input files and error insertions that
  190.   can be going on simultaneously}
  191. @!font_max=255; {maximum internal font number; must not exceed |max_quarterword|
  192.   and must be at most |font_base+256|}
  193. @!font_mem_size=100000; {number of words of |font_info| for all fonts}
  194. @!param_size=60; {maximum number of simultaneous macro parameters}
  195. @!nest_size=40; {maximum number of semantic levels simultaneously active}
  196. @!max_strings=15000; {maximum number of strings; must not exceed |max_halfword|}
  197. @!string_vacancies=100000; {the minimum number of characters that should be
  198.   available for the user's control sequences and font names,
  199.   after \TeX's own error messages are stored}
  200. @!pool_size=124000; {maximum number of characters in strings, including all
  201.   error messages and help texts, and the names of all fonts and
  202.   control sequences; must exceed |string_vacancies| by the total
  203.   length of \TeX's own strings, which is currently about 23000}
  204. @!save_size=4000; {space for saving values outside of current group; must be
  205.   at most |max_halfword|}
  206. @!trie_size=30000; {space for hyphenation patterns; should be larger for
  207.   \.{INITEX} than it is in production versions of \TeX.  This much is
  208.   needed for English, German, and Portuguese.}
  209. @!trie_op_size=751; {space for ``opcodes'' in the hyphenation patterns;
  210.   best if relatively prime to 313, 361, and 1009, according to {\tt
  211.   rocky@watson.ibm.com}.}
  212. @!neg_trie_op_size=-751; {for lower |trie_op_hash| array bound;
  213.   must be equal to |-trie_op_size|.}
  214. @!min_trie_op=0; {first possible trie op code for any language}
  215. @!max_trie_op=500; {largest possible trie op code for any language}
  216. @!dvi_buf_size=16384; {size of the output buffer; must be a multiple of 8}
  217. @!pool_name=TEX_POOL_NAME; {name comes from \.{site.h}.}
  218.   {string of length |file_name_size|; tells where the string pool appears}
  219. @!mem_top=262140; {largest index in the |mem| array dumped by \.{INITEX};
  220.   must be substantially larger than |mem_bot|,
  221.   equal to |mem_max| in \.{INITEX}, else not greater than |mem_max|}
  222. @z
  223.  
  224. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  225. % [1.12] Sensitive compile-time constants.  For C we change mem_base and
  226. % hi_mem_base to reflect our use of 0-origin vs pc's use of
  227. % negative-origin.  Despite the fact that it is a ``sensitive''
  228. % constant, we're going to make mem_top a #define in the C code for
  229. % readability and ease of modification (it's up above) -- it needs
  230. % to be changed for the trip test.
  231. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  232. @x
  233. @d mem_bot=0 {smallest index in the |mem| array dumped by \.{INITEX};
  234.   must not be less than |mem_min|}
  235. @d mem_top==30000 {largest index in the |mem| array dumped by \.{INITEX};
  236.   must be substantially larger than |mem_bot|
  237.   and not greater than |mem_max|}
  238. @d font_base=0 {smallest internal font number; must not be less
  239.   than |min_quarterword|}
  240. @d hash_size=2100 {maximum number of control sequences; it should be at most
  241.   about |(mem_max-mem_min)/10|}
  242. @d hash_prime=1777 {a prime number equal to about 85\pct! of |hash_size|}
  243. @d hyph_size=307 {another prime; the number of \.{\\hyphenation} exceptions}
  244. @y
  245. @d mem_bot=0 {smallest index in the |mem| array dumped by \.{INITEX};
  246.   must not be less than |mem_min|}
  247. @d font_base=0 {smallest internal font number; must not be less
  248.   than |min_quarterword|}
  249. @d hash_size=9500 {maximum number of control sequences; it should be at most
  250.   about |(mem_max-mem_min)/10|}
  251. @d hash_prime=7919 {a prime number equal to about 85\pct! of |hash_size|}
  252. @d hyph_size=607 {another prime; the number of \.{\\hyphenation} exceptions}
  253. @z
  254.  
  255. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  256. % [1.16] Use C macros for `incr' and `decr'.
  257. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  258. @x
  259. @d incr(#) == #:=#+1 {increase a variable by unity}
  260. @d decr(#) == #:=#-1 {decrease a variable by unity}
  261. @y
  262. @z
  263.  
  264. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  265. % [??] The text_char type is used as an array index into xord.  The
  266. % default type `char' produces signed integers, which are bad array
  267. % indices in C.
  268. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  269. @x
  270. @d text_char == char {the data type of characters in text files}
  271. @y
  272. @d text_char == ASCII_code {the data type of characters in text files}
  273. @z
  274.  
  275. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  276. % [2.23] Allow any character as input.
  277. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  278. @x
  279. for i:=0 to @'37 do xchr[i]:=' ';
  280. for i:=@'177 to @'377 do xchr[i]:=' ';
  281. @y
  282. for i:=0 to @'37 do xchr[i]:=chr(i);
  283. for i:=@'177 to @'377 do xchr[i]:=chr(i);
  284. @z
  285.  
  286. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  287. % [3.25] Remove file types we don't need.
  288. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  289. @x
  290. The program actually makes use also of a third kind of file, called a
  291. |word_file|, when dumping and reloading base information for its own
  292. initialization.  We shall define a word file later; but it will be possible
  293. for us to specify simple operations on word files before they are defined.
  294.  
  295. @y
  296. I/O in C is done using standard I/O.  We will define the path numbers
  297. in an include file for C which are used in searching for files to be
  298. read.  We'll define all the file types in C also.
  299. @z
  300.  
  301. @x
  302. @!alpha_file=packed file of text_char; {files that contain textual data}
  303. @!byte_file=packed file of eight_bits; {files that contain binary data}
  304. @y
  305. @z
  306.  
  307. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  308. % [3.27] Do file opening in C.
  309. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  310. @x
  311. @ The \ph\ compiler with which the present version of \TeX\ was prepared has
  312. extended the rules of \PASCAL\ in a very convenient way. To open file~|f|,
  313. we can write
  314. $$\vbox{\halign{#\hfil\qquad&#\hfil\cr
  315. |reset(f,@t\\{name}@>,'/O')|&for input;\cr
  316. |rewrite(f,@t\\{name}@>,'/O')|&for output.\cr}}$$
  317. The `\\{name}' parameter, which is of type `{\bf packed array
  318. $[\langle\\{any}\rangle]$ of \\{char}}', stands for the name of
  319. the external file that is being opened for input or output.
  320. Blank spaces that might appear in \\{name} are ignored.
  321.  
  322. The `\.{/O}' parameter tells the operating system not to issue its own
  323. error messages if something goes wrong. If a file of the specified name
  324. cannot be found, or if such a file cannot be opened for some other reason
  325. (e.g., someone may already be trying to write the same file), we will have
  326. |@!erstat(f)<>0| after an unsuccessful |reset| or |rewrite|.  This allows
  327. \TeX\ to undertake appropriate corrective action.
  328. @:PASCAL H}{\ph@>
  329. @^system dependencies@>
  330.  
  331. \TeX's file-opening procedures return |false| if no file identified by
  332. |name_of_file| could be opened.
  333.  
  334. @d reset_OK(#)==erstat(#)=0
  335. @d rewrite_OK(#)==erstat(#)=0
  336.  
  337. @p function a_open_in(var f:alpha_file):boolean;
  338.   {open a text file for input}
  339. begin reset(f,name_of_file,'/O'); a_open_in:=reset_OK(f);
  340. end;
  341. @#
  342. function a_open_out(var f:alpha_file):boolean;
  343.   {open a text file for output}
  344. begin rewrite(f,name_of_file,'/O'); a_open_out:=rewrite_OK(f);
  345. end;
  346. @#
  347. function b_open_in(var f:byte_file):boolean;
  348.   {open a binary file for input}
  349. begin reset(f,name_of_file,'/O'); b_open_in:=reset_OK(f);
  350. end;
  351. @#
  352. function b_open_out(var f:byte_file):boolean;
  353.   {open a binary file for output}
  354. begin rewrite(f,name_of_file,'/O'); b_open_out:=rewrite_OK(f);
  355. end;
  356. @#
  357. function w_open_in(var f:word_file):boolean;
  358.   {open a word file for input}
  359. begin reset(f,name_of_file,'/O'); w_open_in:=reset_OK(f);
  360. end;
  361. @#
  362. function w_open_out(var f:word_file):boolean;
  363.   {open a word file for output}
  364. begin rewrite(f,name_of_file,'/O'); w_open_out:=rewrite_OK(f);
  365. end;
  366. @y
  367. @ All of the file opening functions are defined in C.
  368. @z
  369.  
  370. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  371. % [3.28] Do file closing in C.
  372. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  373. @x
  374. @ Files can be closed with the \ph\ routine `|close(f)|', which
  375. @^system dependencies@>
  376. should be used when all input or output with respect to |f| has been completed.
  377. This makes |f| available to be opened again, if desired; and if |f| was used for
  378. output, the |close| operation makes the corresponding external file appear
  379. on the user's area, ready to be read.
  380.  
  381. These procedures should not generate error messages if a file is
  382. being closed before it has been successfully opened.
  383.  
  384. @p procedure a_close(var f:alpha_file); {close a text file}
  385. begin close(f);
  386. end;
  387. @#
  388. procedure b_close(var f:byte_file); {close a binary file}
  389. begin close(f);
  390. end;
  391. @#
  392. procedure w_close(var f:word_file); {close a word file}
  393. begin close(f);
  394. end;
  395. @y
  396. @ And all the file closing routines as well.
  397. @z
  398.  
  399. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  400. % [3.31] Do `input_ln' in C.
  401. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  402. @x
  403. @p function input_ln(var f:alpha_file;@!bypass_eoln:boolean):boolean;
  404.   {inputs the next line or returns |false|}
  405. var last_nonblank:0..buf_size; {|last| with trailing blanks removed}
  406. begin if bypass_eoln then if not eof(f) then get(f);
  407.   {input the first character of the line into |f^|}
  408. last:=first; {cf.\ Matthew 19\thinspace:\thinspace30}
  409. if eof(f) then input_ln:=false
  410. else  begin last_nonblank:=first;
  411.   while not eoln(f) do
  412.     begin if last>=max_buf_stack then
  413.       begin max_buf_stack:=last+1;
  414.       if max_buf_stack=buf_size then
  415.         @<Report overflow of the input buffer, and abort@>;
  416.       end;
  417.     buffer[last]:=xord[f^]; get(f); incr(last);
  418.     if buffer[last-1]<>" " then last_nonblank:=last;
  419.     end;
  420.   last:=last_nonblank; input_ln:=true;
  421.   end;
  422. end;
  423. @y
  424. We define |input_ln| in C, for efficiency.
  425. @z
  426.  
  427. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  428. % [3.32] `term_in' and `term_out' are standard input and output.
  429. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  430. @x
  431. @<Glob...@>=
  432. @!term_in:alpha_file; {the terminal as an input file}
  433. @!term_out:alpha_file; {the terminal as an output file}
  434. @y
  435. @d term_in==stdin {the terminal as an input file}
  436. @d term_out==stdout {the terminal as an output file}
  437. @z
  438.  
  439. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  440. % [3.33] We don't need to open terminal files.
  441. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  442. @x
  443. @ Here is how to open the terminal files
  444. in \ph. The `\.{/I}' switch suppresses the first |get|.
  445. @^system dependencies@>
  446.  
  447. @d t_open_in==reset(term_in,'TTY:','/O/I') {open the terminal for text input}
  448. @d t_open_out==rewrite(term_out,'TTY:','/O') {open the terminal for text output}
  449. @y
  450. @ Here is how to open the terminal files.  |t_open_out| does nothing.
  451. |t_open_in|, on the other hand, does the work of ``rescanning,'' or getting
  452. any command line arguments the user has provided.  It's defined in C.
  453.  
  454. @d t_open_out == {output already open for text output}
  455. @z
  456.  
  457. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  458. % [3.34] Flushing output.
  459. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  460. @x
  461. these operations can be specified in \ph:
  462. @^system dependencies@>
  463.  
  464. @d update_terminal == break(term_out) {empty the terminal output buffer}
  465. @d clear_terminal == break_in(term_in,true) {clear the terminal input buffer}
  466. @y
  467. these operations can be specified with {\mc UNIX}.  |update_terminal|
  468. does an |fflush| (via the macro |flush|). |clear_terminal| is redefined
  469. to do nothing, since the user should control the terminal.
  470. @^system dependencies@>
  471.  
  472. @d update_terminal == flush (term_out)
  473. @d clear_terminal == do_nothing
  474. @z
  475.  
  476. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  477. % [3.37] Reading the command line.
  478. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  479. @x
  480. @ The following program does the required initialization
  481. without retrieving a possible command line.
  482. It should be clear how to modify this routine to deal with command lines,
  483. if the system permits them.
  484. @^system dependencies@>
  485.  
  486. @p function init_terminal:boolean; {gets the terminal input started}
  487. label exit;
  488. begin t_open_in;
  489. loop@+begin wake_up_terminal; write(term_out,'**'); update_terminal;
  490. @.**@>
  491.   if not input_ln(term_in,true) then {this shouldn't happen}
  492.     begin write_ln(term_out);
  493.     write(term_out,'! End of file on the terminal... why?');
  494. @.End of file on the terminal@>
  495.     init_terminal:=false; return;
  496.     end;
  497.   loc:=first;
  498.   while (loc<last)and(buffer[loc]=" ") do incr(loc);
  499.   if loc<last then
  500.     begin init_terminal:=true;
  501.     return; {return unless the line was all blank}
  502.     end;
  503.   write_ln(term_out,'Please type the name of your input file.');
  504.   end;
  505. exit:end;
  506. @y
  507. @ The following program does the required initialization.
  508. Iff anything has been specified on the command line, then |t_open_in|
  509. will return with |last > first|.
  510. @^system dependencies@>
  511.  
  512. @p
  513. function init_terminal:boolean; {gets the terminal input started}
  514. label exit;
  515. begin
  516.     t_open_in;
  517.     if last > first then begin
  518.         loc := first;
  519.         while (loc < last) and (buffer[loc]=' ') do
  520.         incr(loc);
  521.         if loc < last then begin
  522.             init_terminal := true;
  523.             goto exit;
  524.         end;
  525.     end;
  526.     loop@+begin
  527.         wake_up_terminal; write(term_out, '**'); update_terminal;
  528. @.**@>
  529.         if not input_ln(term_in,true) then begin {this shouldn't happen}
  530.             write_ln(term_out);
  531.             write(term_out, '! End of file on the terminal... why?');
  532. @.End of file on the terminal@>
  533.             init_terminal:=false;
  534.         return;
  535.         end;
  536.  
  537.         loc:=first;
  538.         while (loc<last)and(buffer[loc]=" ") do
  539.             incr(loc);
  540.  
  541.         if loc<last then begin
  542.            init_terminal:=true;
  543.            return; {return unless the line was all blank}
  544.         end;
  545.         write_ln(term_out, 'Please type the name of your input file.');
  546.     end;
  547. exit:
  548. end;
  549. @z
  550.  
  551. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  552. % [4.51] Open the pool file using a path, and can't do string
  553. % assignments directly.  (`strcpy' and `strlen' work here because
  554. % `pool_name' is a constant string, and thus ends in a null and doesn't
  555. % start with a space.)
  556. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  557. @x
  558. name_of_file:=pool_name; {we needn't set |name_length|}
  559. if a_open_in(pool_file) then
  560. @y
  561. vstrcpy (name_of_file+1, pool_name); {copy the string}
  562. name_of_file[0] := ' ';
  563. name_of_file[strlen (pool_name) +1 ] := ' ';
  564. name_length := strlen (pool_name);
  565. if a_open_in (pool_file, TEX_POOL_PATH) then
  566. @z
  567.  
  568. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  569. % [4.51,52,53] Make `TEX.POOL' lowercase in messages, and change how
  570. % it's read.
  571. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  572. @x
  573. else  bad_pool('! I can''t read TEX.POOL.')
  574. @y
  575. else begin
  576.    {Like |bad_pool|, but must not close file if we never opened it}
  577.    wake_up_terminal; write_ln(term_out, '! I can''t read tex.pool.');
  578.    get_strings_started:= false; return;
  579. end
  580. @z
  581. @x
  582. begin if eof(pool_file) then bad_pool('! TEX.POOL has no check sum.');
  583. @.TEX.POOL has no check sum@>
  584. read(pool_file,m,n); {read two digits of string length}
  585. @y
  586. begin if eof(pool_file) then bad_pool('! tex.pool has no check sum.');
  587. @.TEX.POOL has no check sum@>
  588. read(pool_file,m); read(pool_file,n); {read two digits of string length}
  589. @z
  590. @x
  591.     bad_pool('! TEX.POOL line doesn''t begin with two digits.');
  592. @y
  593.     bad_pool('! tex.pool line doesn''t begin with two digits.');
  594. @z
  595. @x
  596.   bad_pool('! TEX.POOL check sum doesn''t have nine digits.');
  597. @y
  598.   bad_pool('! tex.pool check sum doesn''t have nine digits.');
  599. @z
  600. @x
  601. done: if a<>@$ then bad_pool('! TEX.POOL doesn''t match; TANGLE me again.');
  602. @y
  603. done: if a<>@$ then bad_pool('! tex.pool doesn''t match; tangle me again.');
  604. @z
  605.  
  606. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  607. % [5.61] Eliminate the misleading message ``(no format preloaded)''.
  608. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  609. @x
  610. wterm(banner);
  611. if format_ident=0 then wterm_ln(' (no format preloaded)')
  612. else  begin slow_print(format_ident); print_ln;
  613.   end;
  614. @y
  615. wterm (banner);
  616. wterm (version_string);
  617. if format_ident>0 then slow_print(format_ident); 
  618. print_ln;
  619. @z
  620.  
  621. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  622. % [6.81] Eliminate nonlocal goto, since C doesn't have them.
  623. % Plus, it's nicer just to do an exit with the appropriate status code
  624. % under Unix.  We call it `uexit' because there's a WEB symbol called
  625. % `exit' already.  We use a C macro to change `uexit' back to `exit'.
  626. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  627. @x
  628. @<Error hand...@>=
  629. procedure jump_out;
  630. begin goto end_of_TEX;
  631. end;
  632. @y
  633. @d do_final_end==begin
  634.    update_terminal;
  635.    ready_already:=0;
  636.    if (history <> spotless) and (history <> warning_issued) then
  637.        uexit(1)
  638.    else
  639.        uexit(0);
  640.    end
  641. @<Error hand...@>=
  642. procedure jump_out;
  643. begin
  644. close_files_and_terminate;
  645. do_final_end;
  646. end;
  647. @z
  648.  
  649. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  650. % [6.84] Implement the switch-to-editor option.
  651. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  652. @x
  653. line ready to be edited. But such an extension requires some system
  654. wizardry, so the present implementation simply types out the name of the
  655. file that should be
  656. edited and the relevant line number.
  657. @^system dependencies@>
  658.  
  659. There is a secret `\.D' option available when the debugging routines haven't 
  660. been commented~out.
  661. @^debugging@>
  662. @y
  663. line ready to be edited.
  664. We do this by calling the external procedure |call_edit| with a pointer to
  665. the filename, its length, and the line number.
  666. However, here we just set up the variables that will be used as arguments,
  667. since we don't want to do the switch-to-editor until after TeX has closed
  668. its files.
  669. @^system dependencies@>
  670.  
  671. There is a secret `\.D' option available when the debugging routines haven't
  672. been commented~out.
  673. @^debugging@>
  674. @d edit_file==input_stack[base_ptr]
  675. @z
  676. @x
  677. "E": if base_ptr>0 then
  678.   begin print_nl("You want to edit file ");
  679. @.You want to edit file x@>
  680.   slow_print(input_stack[base_ptr].name_field);
  681.   print(" at line "); print_int(line);
  682.   interaction:=scroll_mode; jump_out;
  683. @y
  684. "E": if base_ptr>0 then
  685.     begin
  686.     edit_name_start:=str_start[edit_file.name_field];
  687.     edit_name_length:=str_start[edit_file.name_field+1] -
  688.                   str_start[edit_file.name_field];
  689.     edit_line:=line;
  690.     jump_out;
  691. @z
  692.  
  693. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  694. % [7.104] `remainder' is a library routine on some systems, so change
  695. % its name to avoid conflicts.
  696. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  697. @x
  698. @<Glob...@>=
  699. @!arith_error:boolean; {has arithmetic overflow occurred recently?}
  700. @!remainder:scaled; {amount subtracted to get an exact division}
  701. @y
  702. @d remainder == tex_remainder
  703. @<Glob...@>=
  704. @!arith_error:boolean; {has arithmetic overflow occurred recently?}
  705. @!remainder:scaled; {amount subtracted to get an exact division}
  706. @z
  707.  
  708. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  709. % [7.109] Define glue_ratio in C.
  710. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  711. @x
  712. @!glue_ratio=real; {one-word representation of a glue expansion factor}
  713. @y
  714. @z
  715.  
  716. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  717. % [8.110] Make it easy to change constants.  Do not increase
  718. % max_quarterword without changing the memoryword structure in
  719. % `texmfmem.h'.
  720. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  721. @x
  722. @d min_quarterword=0 {smallest allowable value in a |quarterword|}
  723. @d max_quarterword=255 {largest allowable value in a |quarterword|}
  724. @d min_halfword==0 {smallest allowable value in a |halfword|}
  725. @d max_halfword==65535 {largest allowable value in a |halfword|}
  726. @y
  727. @d min_quarterword=0 {smallest allowable value in a |quarterword|}
  728. @d max_quarterword=255 {largest allowable value in a |quarterword|}
  729. @d min_halfword==0 {smallest allowable value in a |halfword|}
  730. @d max_halfword==262143 {largest allowable value in a |halfword|}
  731. @z
  732.  
  733. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  734. % [8.112] Efficiency.
  735. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  736. @x
  737. The inner loop of \TeX\ will run faster with respect to compilers
  738. that don't optimize expressions like `|x+0|' and `|x-0|', if these
  739. macros are simplified in the obvious way when |min_quarterword=0|.
  740. @^inner loop@>@^system dependencies@>
  741.  
  742. @d qi(#)==#+min_quarterword
  743.   {to put an |eight_bits| item into a quarterword}
  744. @d qo(#)==#-min_quarterword
  745.   {to take an |eight_bits| item out of a quarterword}
  746. @d hi(#)==#+min_halfword
  747.   {to put a sixteen-bit item into a halfword}
  748. @d ho(#)==#-min_halfword
  749.   {to take a sixteen-bit item from a halfword}
  750. @y
  751. The inner loop of \TeX\ will run faster with respect to compilers
  752. that don't optimize expressions like `|x+0|' and `|x-0|', if these
  753. macros are simplified in the obvious way when |min_quarterword=0|.
  754. So they have been simplified here in the obvious way.
  755. @^inner loop@>@^system dependencies@>
  756.  
  757. @d qi(#)==# {to put an |eight_bits| item into a quarterword}
  758. @d qo(#)==# {to take an |eight_bits| item from a quarterword}
  759. @d hi(#)==# {to put a sixteen-bit item into a halfword}
  760. @d ho(#)==# {to take a sixteen-bit item from a halfword}
  761. @z
  762.  
  763. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  764. % [8.113] We've put the memory structure into the include file
  765. % `texmf.h', since it's too hard to translate automatically.  Also,
  766. % remove the `word_file' type.
  767. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  768. @x
  769. @!quarterword = min_quarterword..max_quarterword; {1/4 of a word}
  770. @!halfword=min_halfword..max_halfword; {1/2 of a word}
  771. @!two_choices = 1..2; {used when there are two variants in a record}
  772. @!four_choices = 1..4; {used when there are four variants in a record}
  773. @!two_halves = packed record@;@/
  774.   @!rh:halfword;
  775.   case two_choices of
  776.   1: (@!lh:halfword);
  777.   2: (@!b0:quarterword; @!b1:quarterword);
  778.   end;
  779. @!four_quarters = packed record@;@/
  780.   @!b0:quarterword;
  781.   @!b1:quarterword;
  782.   @!b2:quarterword;
  783.   @!b3:quarterword;
  784.   end;
  785. @!memory_word = record@;@/
  786.   case four_choices of
  787.   1: (@!int:integer);
  788.   2: (@!gr:glue_ratio);
  789.   3: (@!hh:two_halves);
  790.   4: (@!qqqq:four_quarters);
  791.   end;
  792. @!word_file = file of memory_word;
  793. @y
  794. @!quarterword=min_quarterword..max_quarterword;
  795. @!halfword=min_halfword..max_halfword;
  796. @!two_choices = 1..2; {used when there are two variants in a record}
  797. @!four_choices = 1..4; {used when there are four variants in a record}
  798. @=#include "texmfmem.h";@>
  799. @z
  800.  
  801. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  802. % [9.116] Change `mem' to `zmem', so we can define mem to be a register
  803. % pointer to the memory array for speed.
  804. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  805. @x
  806. @!mem : array[mem_min..mem_max] of memory_word; {the big dynamic storage area}
  807. @y
  808. @!zmem : array[mem_min..mem_max] of memory_word; {the big dynamic storage area}
  809. @z
  810.  
  811. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  812. % [9.127] Fix casting problem in C.
  813. % There are several of these.  They come from the rules C uses for
  814. % comparing signed and unsigned quantities.  Just doing the comparison
  815. % can result in incorrect evaluation wrt the way Pascal would do it.
  816. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  817. @x
  818. if r>p+1 then @<Allocate from the top of node |p| and |goto found|@>;
  819. @y
  820. if r>toint(p+1) then @<Allocate from the top of node |p| and |goto found|@>;
  821. @z
  822.  
  823. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  824. % [11.165] Fix the word `free' so that it doesn't conflict with the
  825. % standard C library routine of the same name.
  826. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  827. @x
  828. been included. (You may want to decrease the size of |mem| while you
  829. @^debugging@>
  830. are debugging.)
  831. @y
  832. been included. (You may want to decrease the size of |mem| while you
  833. @^debugging@>
  834. are debugging.)
  835.  
  836. @d free==free_arr
  837. @z
  838.  
  839. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  840. % [12.174,176] Eliminate some unsigned comparisons to zero.
  841. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  842. @x
  843.         begin if (font(p)<font_base)or(font(p)>font_max) then
  844.           print_char("*")
  845. @y
  846.         begin if (font(p)>font_max) then
  847.           print_char("*")
  848. @z
  849.  
  850. @x
  851. @p procedure print_font_and_char(@!p:integer); {prints |char_node| data}
  852. begin if p>mem_end then print_esc("CLOBBERED.")
  853. else  begin if (font(p)<font_base)or(font(p)>font_max) then print_char("*")
  854. @y
  855. @p procedure print_font_and_char(@!p:integer); {prints |char_node| data}
  856. begin if p>mem_end then print_esc("CLOBBERED.")
  857. else  begin if (font(p)>font_max) then print_char("*")
  858. @z
  859.  
  860. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  861. % [12.186] Don't worry about strange floating point values.
  862. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  863. @x
  864.   if glue_sign(p)=shrinking then print("- ");
  865.   if abs(mem[p+glue_offset].int)<@'4000000 then print("?.?")
  866.   else if abs(g)>float_constant(20000) then
  867. @y
  868.   if glue_sign(p)=shrinking then print("- ");
  869.   { The Unix |pc| folks removed this restriction with a remark that
  870.     invalid bit patterns were vanishingly improbable, so we follow
  871.     their example without really understanding it.
  872.   |if abs(mem[p+glue_offset].int)<@'4000000 then print('?.?')|
  873.   |else| }
  874.   if fabs(g)>float_constant(20000) then
  875. @z
  876.  
  877. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  878. % [17.241] Do `fix_date_and_time' in C.
  879. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  880. @x
  881. @ The following procedure, which is called just before \TeX\ initializes its
  882. input and output, establishes the initial values of the date and time.
  883. @^system dependencies@>
  884. Since standard \PASCAL\ cannot provide such information, something special
  885. is needed. The program here simply specifies July 4, 1776, at noon; but
  886. users probably want a better approximation to the truth.
  887.  
  888. @p procedure fix_date_and_time;
  889. begin time:=12*60; {minutes since midnight}
  890. day:=4; {fourth day of the month}
  891. month:=7; {seventh month of the year}
  892. year:=1776; {Anno Domini}
  893. end;
  894. @y
  895. @ The following procedure, which is called just before \TeX\ initializes its
  896. input and output, establishes the initial values of the date and time.
  897. It calls a macro-defined |date_and_time| routine.  |date_and_time|
  898. in turn is a C macro, which calls |get_date_and_time|, passing
  899. it the addresses of the day, month, etc., so they can be set by the
  900. routine.  |get_date_and_time| also sets up interrupt catching if that
  901. is conditionally compiled in the C code.
  902. @^system dependencies@>
  903.  
  904. @d fix_date_and_time==date_and_time(time,day,month,year)
  905. @z
  906.  
  907. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  908. % [17.253] Change eqtb to zeqtb.
  909. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  910. @x
  911. @!eqtb:array[active_base..eqtb_size] of memory_word;
  912. @y
  913. @!zeqtb:array[active_base..eqtb_size] of memory_word;
  914. @z
  915.  
  916. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  917. % [18.262] Remove more unsigned comparisons to zero.
  918. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  919. @x
  920. else if (text(p)<0)or(text(p)>=str_ptr) then print_esc("NONEXISTENT.")
  921. @y
  922. else if (text(p)>=str_ptr) then print_esc("NONEXISTENT.")
  923. @z
  924.  
  925. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  926. % [29.513] Area and extension rules for filenames.
  927. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  928. @x
  929. @ The file names we shall deal with for illustrative purposes have the
  930. following structure:  If the name contains `\.>' or `\.:', the file area
  931. consists of all characters up to and including the final such character;
  932. otherwise the file area is null.  If the remaining file name contains
  933. `\..', the file extension consists of all such characters from the first
  934. remaining `\..' to the end, otherwise the file extension is null.
  935. @^system dependencies@>
  936.  
  937. We can scan such file names easily by using two global variables that keep track
  938. of the occurrences of area and extension delimiters:
  939.  
  940. @<Glob...@>=
  941. @!area_delimiter:pool_pointer; {the most recent `\.>' or `\.:', if any}
  942. @!ext_delimiter:pool_pointer; {the relevant `\..', if any}
  943. @y
  944. @ The file names we shall deal with for illustrative purposes have the
  945. following structure:  If the name contains `\./', the file area
  946. consists of all characters up to and including the final such character;
  947. otherwise the file area is null.  If the remaining file name contains
  948. `\..', the file extension consists of all such characters from the last
  949. `\..' to the end, otherwise the file extension is null.
  950. @^system dependencies@>
  951.  
  952. We can scan such file names easily by using two global variables that keep
  953. track of the occurrences of area and extension delimiters:
  954.  
  955. @<Glob...@>=
  956. @!area_delimiter:pool_pointer; {the most recent `\./', if any}
  957. @!ext_delimiter:pool_pointer; {the most recent `\..', if any}
  958. @z
  959.  
  960. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  961. % [29.514] TeX area directories.
  962. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  963. @x
  964. @d TEX_area=="TeXinputs:"
  965. @.TeXinputs@>
  966. @d TEX_font_area=="TeXfonts:"
  967. @.TeXfonts@>
  968. @y
  969. In C, the default paths are specified in a separate
  970. file, \.{site.h}.  The file opening procedures do path searching
  971. based either on those default paths, or on paths given by the user
  972. in environment variables.
  973. @z
  974.  
  975. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  976. % [29.516] more_name
  977. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  978. @x
  979. else  begin str_room(1); append_char(c); {contribute |c| to the current string}
  980.   if (c=">")or(c=":") then
  981.     begin area_delimiter:=cur_length; ext_delimiter:=0;
  982.     end
  983.   else if (c=".")and(ext_delimiter=0) then ext_delimiter:=cur_length;
  984. @y
  985. else  begin str_room(1); append_char(c); {contribute |c| to the current string}
  986.   if (c="/") then
  987.     begin area_delimiter:=cur_length; ext_delimiter:=0;
  988.     end
  989.   else if c="." then ext_delimiter:=cur_length;
  990. @z
  991.  
  992. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  993. % [29.519] In pack_file_name, leave room for the extra null we append at
  994. % the end of a filename in make_c_string.
  995. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  996. @x
  997. if k<=file_name_size then name_length:=k@+else name_length:=file_name_size;
  998. @y
  999. if k<file_name_size then name_length:=k@+else name_length:=file_name_size-1;
  1000. @z
  1001.  
  1002. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1003. % [29.520] The default format.
  1004. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1005. @x
  1006. @d format_default_length=20 {length of the |TEX_format_default| string}
  1007. @d format_area_length=11 {length of its area part}
  1008. @d format_ext_length=4 {length of its `\.{.fmt}' part}
  1009. @y
  1010. Under {\mc UNIX} we don't give the area part, instead depending
  1011. on the path searching that will happen during file opening.  Also, the
  1012. length will be set in the main program.
  1013.  
  1014. @d format_area_length=0 {length of its area part}
  1015. @d format_ext_length=4 {length of its `\.{.fmt}' part}
  1016. @z
  1017.  
  1018. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1019. % [29.521] Where `plain.fmt' is.
  1020. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1021. @x
  1022. @!TEX_format_default:packed array[1..format_default_length] of char;
  1023.  
  1024. @ @<Set init...@>=
  1025. TEX_format_default:='TeXformats:plain.fmt';
  1026. @y
  1027. @!format_default_length: integer;
  1028. @!TEX_format_default: c_char_pointer;
  1029.  
  1030. @ We set the name of the default format file and the length of that name
  1031. in C, instead of Pascal, since we want them to depend on the name of the
  1032. program.
  1033. @z
  1034.  
  1035. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1036. % [29.523] Change to pack_buffered_name as with pack_file_name.
  1037. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1038. @x
  1039. if k<=file_name_size then name_length:=k@+else name_length:=file_name_size;
  1040. @y
  1041. if k<file_name_size then name_length:=k@+else name_length:=file_name_size-1;
  1042. @z
  1043.  
  1044. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1045. % [29.524] Format file opening: only try once, with path searching.
  1046. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1047. @x
  1048.   pack_buffered_name(0,loc,j-1); {try first without the system file area}
  1049.   if w_open_in(fmt_file) then goto found;
  1050.   pack_buffered_name(format_area_length,loc,j-1);
  1051.     {now try the system format file area}
  1052.   if w_open_in(fmt_file) then goto found;
  1053. @y
  1054.   pack_buffered_name(0,loc,j-1);
  1055.   if w_open_in(fmt_file) then goto found;
  1056. @z
  1057.  
  1058. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1059. % (still [29.524]) replace `PLAIN' in error messages with `default'.
  1060. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1061. @x
  1062.   wterm_ln('Sorry, I can''t find that format;',' will try PLAIN.');
  1063. @y
  1064.   wterm_ln('Sorry, I can''t find that format;',' will try the default.');
  1065. @z
  1066. @x
  1067.   wterm_ln('I can''t find the PLAIN format file!');
  1068. @.I can't find PLAIN...@>
  1069. @y
  1070.   wterm_ln('I can''t find the default format file!');
  1071. @.I can't find default format...@>
  1072. @z
  1073.  
  1074. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1075. % [29.532] `logname' is declared in <unistd.h> on some systems.
  1076. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1077. @x
  1078. ship out a box of stuff, we shall use the macro |ensure_dvi_open|.
  1079. @y
  1080. ship out a box of stuff, we shall use the macro |ensure_dvi_open|.
  1081.  
  1082. @d log_name == texmf_log_name
  1083. @z
  1084.  
  1085. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1086. % [29.536] Adjust for C string conventions.
  1087. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1088. @x
  1089. @!months:packed array [1..36] of char; {abbreviations of month names}
  1090. @y
  1091. @!months:c_char_pointer;
  1092. @z
  1093.  
  1094. @x
  1095. begin wlog(banner);
  1096. slow_print(format_ident); print("  ");
  1097. print_int(day); print_char(" ");
  1098. months:='JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC';
  1099. @y
  1100. begin wlog (banner);
  1101. wlog (version_string);
  1102. slow_print(format_ident); print("  ");
  1103. print_int(day); print_char(" ");
  1104. months := ' JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC';
  1105. @z
  1106.  
  1107. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1108. % [29.537] Use a path when calling a_open_in to do a \input; also, try
  1109. % to open the file with and without the `.tex' extension, regardless of
  1110. % whether the file already has an extension.  This allows filenames like
  1111. % `foo' and `foo.bar.tex', as well as `foo.tex' and `foo.bar'.
  1112. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1113. @x
  1114. if cur_ext="" then cur_ext:=".tex";
  1115. pack_cur_name;
  1116. loop@+  begin begin_file_reading; {set up |cur_file| and new level of input}
  1117.   if a_open_in(cur_file) then goto done;
  1118.   if cur_area="" then
  1119.     begin pack_file_name(cur_name,TEX_area,cur_ext);
  1120.     if a_open_in(cur_file) then goto done;
  1121.     end;
  1122. @y
  1123. pack_cur_name;
  1124. loop@+begin
  1125.   begin_file_reading; {set up |cur_file| and new level of input}
  1126.   {If we have an extension try the current name first, to avoid looking
  1127.    for names like |"article.sty.tex"|.}
  1128.   if (cur_ext <> "") and a_open_in (cur_file, TEX_INPUT_PATH) then goto done;
  1129.  
  1130.   {That failed. Next, append |".tex"| if (1)~it's not already there; and
  1131.    (2)~it doesn't overflow |name_of_file|, and
  1132.    (3)~it changes the actual file looked for (e.g., |"afourteenlongf"|
  1133.    and |"afourteenlongf.tex"| are the same file under System V).
  1134.    
  1135.    We ignore the presence or absence of an extension, because we want to
  1136.    allow input files like |"foo.bar.tex"|.}
  1137.   if (cur_ext <> ".tex") and (name_length + 5 < file_name_size)
  1138.      and (not extension_irrelevant_p (name_of_file, 'tex'))
  1139.   then begin
  1140.     name_of_file[name_length + 1] := ".";
  1141.     name_of_file[name_length + 2] := "t";
  1142.     name_of_file[name_length + 3] := "e";
  1143.     name_of_file[name_length + 4] := "x";
  1144.     name_length := name_length + 4;
  1145.     if a_open_in (cur_file, TEX_INPUT_PATH) then goto done;
  1146.     {If failed, take away our addition.}
  1147.     name_length := name_length - 4;
  1148.     name_of_file[name_length + 1] := " ";
  1149.   end;
  1150.   
  1151.   {That failed too. If there was no extension, try the name just as it
  1152.    was given, so we will find an input file |"foo"|. We do this after
  1153.    trying with |".tex"| appended, because if someone is writing a
  1154.    program |foo|, they might like to call their documentation
  1155.    |"foo.tex"|, and we don't want to input the binary executable |foo|.}
  1156.   if (cur_ext = "") and a_open_in (cur_file, TEX_INPUT_PATH) then goto done;
  1157.   
  1158.   {Couldn't find the file.  Possibly invoke an external program to
  1159.    create it.  If that claims success, try one last open.}
  1160.   if make_tex_tex and a_open_in (cur_file, TEX_INPUT_PATH) then goto done;
  1161. @z
  1162.  
  1163. % Knuth should fix this -- sometimes lines go over the |max_print_line|.
  1164. % ... But now I don't remember what caused this, so I'll comment this
  1165. % out until it happens again.
  1166. % @x
  1167. % if term_offset+length(name)>max_print_line-2 then print_ln
  1168. % @y
  1169. % if term_offset+length(name)>max_print_line-3 then print_ln
  1170. % @z
  1171.  
  1172. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1173. % [29.537] Get rid of return of filename to string pool.
  1174. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1175. @x
  1176. if name=str_ptr-1 then {we can conserve string pool space now}
  1177.   begin flush_string; name:=cur_name;
  1178.   end;
  1179. @y
  1180. @z
  1181.  
  1182. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1183. % [30.563] Don't use font_area's in TFM opening, and invoke an external
  1184. % program if the first open fails.
  1185. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1186. @x
  1187. file_opened:=false;
  1188. if aire="" then pack_file_name(nom,TEX_font_area,".tfm")
  1189. else pack_file_name(nom,aire,".tfm");
  1190. if not b_open_in(tfm_file) then abort;
  1191. file_opened:=true
  1192. @y
  1193. file_opened := false;
  1194. pack_file_name (nom, aire, ".tfm");
  1195. if not b_open_in(tfm_file) then begin
  1196.   if make_tex_tfm then begin
  1197.     if not b_open_in(tfm_file) then abort;
  1198.   end else
  1199.     abort;
  1200. end;
  1201. file_opened:=true
  1202. @z
  1203.  
  1204. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1205. % [30.564] Reading the tfm file.  As a special case, whenever we open a
  1206. % tfm file, we read its first byte into `tfm_temp' right away.  TeX
  1207. % looks at `fbyte' before calling `fget', so it ends up seeing every
  1208. % byte.  This is Pascal-like I/O.
  1209. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1210. @x
  1211. @d fget==get(tfm_file)
  1212. @d fbyte==tfm_file^
  1213. @y
  1214. @d fget==tfm_temp:=getc(tfm_file)
  1215. @d fbyte==tfm_temp
  1216. @z
  1217.  
  1218. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1219. % [32.597] We only want `eof' on the TFM file to be true if we
  1220. % previously had EOF, not if we're at EOF now.  This is like `feof', and
  1221. % unlike our implementation of `eof' elsewhere.
  1222. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1223. @x
  1224. if eof(tfm_file) then abort;
  1225. @y
  1226. if feof(tfm_file) then abort;
  1227. @z
  1228.  
  1229. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1230. % [32.597] write_dvi
  1231. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1232. @x
  1233. @p procedure write_dvi(@!a,@!b:dvi_index);
  1234. var k:dvi_index;
  1235. begin for k:=a to b do write(dvi_file,dvi_buf[k]);
  1236. end;
  1237. @y
  1238. In C, we use a macro to call |fwrite| or |write| directly, writing all
  1239. the bytes to be written in one shot.  Much better even than writing four
  1240. bytes at a time.
  1241. @z
  1242.  
  1243. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1244. % [38.859] Fix a casting/expression evaluation problem.
  1245. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1246. @x
  1247. if abs(fit_class-fitness(r))>1 then d:=d+adj_demerits;
  1248. @y
  1249. if abs(toint(fit_class)-toint(fitness(r)))>1 then d:=d+adj_demerits;
  1250. @z
  1251.  
  1252. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1253. % [39.875] Another casting problem.
  1254. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1255. @x
  1256. repeat if type(r)<>delta_node then
  1257.   begin line_diff:=line_number(r)-best_line;
  1258. @y
  1259. repeat if type(r)<>delta_node then
  1260.   begin line_diff:=toint(line_number(r))-toint(best_line);
  1261. @z
  1262.  
  1263. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1264. % [42.920,921,923,924] Allow larger hyphenation tries.
  1265. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1266. @x
  1267. Comparatively few different number sequences $n_0\ldots n_k$ actually occur,
  1268. since most of the |n|'s are generally zero. Therefore the number sequences
  1269. are encoded in such a way that |trie_op|$(z_k)$ is only one byte long.
  1270. If |trie_op(@t$z_k$@>)<>min_quarterword|, when $p_1\ldots p_k$ has matched
  1271. the letters in |hc[(l-k+1)..l@,]| of language |t|,
  1272. we perform all of the required operations
  1273. for this pattern by carrying out the following little program: Set
  1274. |v:=trie_op(@t$z_k$@>)|. Then set |v:=v+op_start[t]|,
  1275. |hyf[l-hyf_distance[v]]:=@tmax@>(hyf[l-hyf_distance[v]], hyf_num[v])|,
  1276. and |v:=hyf_next[v]|; repeat, if necessary, until |v=min_quarterword|.
  1277. @y
  1278. The theory that comparatively few different number sequences $n_0\ldots n_k$
  1279. actually occur, since most of the |n|'s are generally zero, seems to fail
  1280. at least for the large German hyphenation patterns.
  1281. Therefore the number sequences cannot any longer be encoded in such a way
  1282. that |trie_op|$(z_k)$ is only one byte long.
  1283. We have introduced a new constant |max_trie_op| for the maximum allowable
  1284. hyphenation operation code value; |max_trie_op| might be different for
  1285. \TeX\ and \.{INITEX} and must not exceed |max_halfword|.
  1286. An opcode will occupy a halfword if |max_trie_op| exceeds |max_quarterword|
  1287. or a quarterword otherwise.
  1288. @^system dependencies@>
  1289. If |trie_op(@t$z_k$@>)<>min_trie_op|, when $p_1\ldots p_k$ has matched
  1290. the letters in |hc[(l-k+1)..l@,]| of language |t|,
  1291. we perform all of the required operations
  1292. for this pattern by carrying out the following little program: Set
  1293. |v:=trie_op(@t$z_k$@>)|. Then set |v:=v+op_start[t]|,
  1294. |hyf[l-hyf_distance[v]]:=@tmax@>(hyf[l-hyf_distance[v]], hyf_num[v])|,
  1295. and |v:=hyf_next[v]|; repeat, if necessary, until |v=min_trie_op|.
  1296. @z
  1297. @x
  1298. @!trie_pointer=0..trie_size; {an index into |trie|}
  1299. @y
  1300. @!trie_opcode=min_trie_op..max_trie_op;  {a trie opcode}
  1301. @!trie_pointer=0..trie_size; {an index into |trie|}
  1302. @z
  1303. @x
  1304. @ @d trie_link(#)==trie[#].rh {``downward'' link in a trie}
  1305. @d trie_char(#)==trie[#].b1 {character matched at this trie location}
  1306. @d trie_op(#)==trie[#].b0 {program for hyphenation at this trie location}
  1307. @y
  1308. @ For more than 255 trie op codes, the three fields |trie_link|, |trie_char|,
  1309. and |trie_op| will no longer fit into one memory word; thus using web2c
  1310. we define |trie| as three array instead of an array of records.
  1311. The variant will be implented by reusing the opcode field later on with
  1312. another macro.
  1313. @d trie_link(#)==trie_trl[#] {``downward'' link in a trie}
  1314. @d trie_char(#)==trie_trc[#] {character matched at this trie location}
  1315. @d trie_op(#)==trie_tro[#] {program for hyphenation at this trie location}
  1316. @z
  1317. @x
  1318. @!trie:array[trie_pointer] of two_halves; {|trie_link|, |trie_char|, |trie_op|}
  1319. @y
  1320. @!trie_trl:array[trie_pointer] of halfword; {|trie_link|}
  1321. @!trie_tro:array[trie_pointer] of halfword; {|trie_op| and |trie_link|}
  1322. @!trie_trc:array[trie_pointer] of quarterword; {|trie_char|}
  1323. @z
  1324. @x
  1325. @!hyf_next:array[1..trie_op_size] of quarterword; {continuation code}
  1326. @y
  1327. @!hyf_next:array[1..trie_op_size] of trie_opcode; {continuation code}
  1328. @z
  1329. @x
  1330.     begin if trie_op(z)<>min_quarterword then
  1331. @y
  1332.     begin if trie_op(z)<>min_trie_op then
  1333. @z
  1334. @x
  1335. until v=min_quarterword;
  1336. @y
  1337. until v=min_trie_op;
  1338. @z
  1339.  
  1340. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1341. % [43.943] Larger tries, also in documentation parts.
  1342. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1343. @x
  1344. |hyf_next[@t$v^\prime$@>]=min_quarterword|.
  1345. @y
  1346. |hyf_next[@t$v^\prime$@>]=min_trie_op|.
  1347. @z
  1348. @x
  1349. $$\hbox{|@t$v^\prime$@>:=new_trie_op(0,1,min_quarterword)|,\qquad
  1350. @y
  1351. $$\hbox{|@t$v^\prime$@>:=new_trie_op(0,1,min_trie_op)|,\qquad
  1352. @z
  1353.  
  1354. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1355. % [43.943] web2c can't parse negative lower bounds in arrays.  Sorry.
  1356. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1357. @x
  1358. @!init@! trie_op_hash:array[-trie_op_size..trie_op_size] of 0..trie_op_size;
  1359. @y
  1360. @!init@! trie_op_hash:array[neg_trie_op_size..trie_op_size] of 0..trie_op_size;
  1361. @z
  1362.  
  1363. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1364. % [43.943,944] Larger hyphenation tries.
  1365. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1366. @x
  1367. @!trie_used:array[ASCII_code] of quarterword;
  1368. @y
  1369. @!trie_used:array[ASCII_code] of trie_opcode;
  1370. @z
  1371. @x
  1372. @!trie_op_val:array[1..trie_op_size] of quarterword;
  1373. @y
  1374. @!trie_op_val:array[1..trie_op_size] of trie_opcode;
  1375. @z
  1376. @x
  1377. tini
  1378. @y
  1379. tini@;
  1380. @!max_op_used:trie_opcode; {largest opcode used for any language}
  1381. @!small_op:boolean; {flag used while dumping or undumping}
  1382. @z
  1383. @x
  1384. |new_trie_op| could return |min_quarterword| (thereby simply ignoring
  1385. @y
  1386. |new_trie_op| could return |min_trie_op| (thereby simply ignoring
  1387. @z
  1388. @x
  1389. function new_trie_op(@!d,@!n:small_number;@!v:quarterword):quarterword;
  1390. label exit;
  1391. var h:-trie_op_size..trie_op_size; {trial hash location}
  1392. @!u:quarterword; {trial op code}
  1393. @y
  1394. function new_trie_op(@!d,@!n:small_number;@!v:trie_opcode):trie_opcode;
  1395. label exit;
  1396. var h:neg_trie_op_size..trie_op_size; {trial hash location}
  1397. @!u:trie_opcode; {trial op code}
  1398. @z
  1399.  
  1400. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1401. % [43.944] Another casting problem, and use |neg_trie_op_size|.
  1402. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1403. @x
  1404. begin h:=abs(n+313*d+361*v+1009*cur_lang) mod (trie_op_size+trie_op_size)
  1405.   - trie_op_size;
  1406. @y
  1407. begin h:=abs(toint(n)+313*toint(d)+361*toint(v)+1009*toint(cur_lang))
  1408.   mod (trie_op_size - neg_trie_op_size)
  1409.   + neg_trie_op_size;
  1410. @z
  1411.  
  1412. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1413. % [43.944,945,946] And larger tries again.
  1414. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1415. @x
  1416.     if u=max_quarterword then
  1417.       overflow("pattern memory ops per language",
  1418.         max_quarterword-min_quarterword);
  1419.     incr(trie_op_ptr); incr(u); trie_used[cur_lang]:=u;
  1420. @y
  1421.     if u=max_trie_op then
  1422.       overflow("pattern memory ops per language",
  1423.       max_trie_op-min_trie_op);
  1424.     incr(trie_op_ptr); incr(u); trie_used[cur_lang]:=u;
  1425.     if u>max_op_used then max_op_used:=u;
  1426. @z
  1427. @x
  1428. op_start[0]:=-min_quarterword;
  1429. @y
  1430. op_start[0]:=-min_trie_op;
  1431. @z
  1432. @x
  1433. for k:=0 to 255 do trie_used[k]:=min_quarterword;
  1434. @y
  1435. for k:=0 to 255 do trie_used[k]:=min_trie_op;
  1436. @z
  1437. @x
  1438. trie_op_ptr:=0;
  1439. @y
  1440. max_op_used:=min_trie_op;
  1441. trie_op_ptr:=0;
  1442. @z
  1443. @x
  1444. @t\hskip10pt@>@!trie_o:packed array[trie_pointer] of quarterword;
  1445. @y
  1446. @t\hskip10pt@>@!trie_o:packed array[trie_pointer] of trie_opcode;
  1447. @z
  1448.  
  1449. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1450. % [43.947] A casting problem.
  1451. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1452. @x
  1453. begin h:=abs(trie_c[p]+1009*trie_o[p]+@|
  1454.     2718*trie_l[p]+3142*trie_r[p]) mod trie_size;
  1455. @y
  1456. begin h:=abs(toint(trie_c[p])+1009*toint(trie_o[p])+@|
  1457.     2718*toint(trie_l[p])+3142*toint(trie_r[p])) mod trie_size;
  1458. @z
  1459.  
  1460. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1461. % [43.950,958,960,963] Larger tries.
  1462. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1463. @x
  1464. @d trie_back(#)==trie[#].lh {backward links in |trie| holes}
  1465. @y
  1466. @d trie_back(#)==trie_tro[#] {use the opcode field now for backward links}
  1467. @z
  1468. @x
  1469. @<Move the data into |trie|@>=
  1470. h.rh:=0; h.b0:=min_quarterword; h.b1:=min_quarterword; {|trie_link:=0|,
  1471.   |trie_op:=min_quarterword|, |trie_char:=qi(0)|}
  1472. if trie_root=0 then {no patterns were given}
  1473.   begin for r:=0 to 256 do trie[r]:=h;
  1474. @y
  1475. @d clear_trie == {clear |trie[r]|}
  1476.   begin trie_link(r):=0;
  1477.   trie_op(r):=min_trie_op;
  1478.   trie_char(r):=min_quarterword; {|trie_char:=qi(0)|}
  1479.   end
  1480. @<Move the data into |trie|@>=
  1481. if trie_root=0 then {no patterns were given}
  1482.   begin for r:=0 to 256 do clear_trie;
  1483. @z
  1484. @x
  1485.   repeat s:=trie_link(r); trie[r]:=h; r:=s;
  1486. @y
  1487.   repeat s:=trie_link(r); clear_trie; r:=s;
  1488. @z
  1489. @x
  1490. @!v:quarterword; {trie op code}
  1491. @y
  1492. @!v:trie_opcode; {trie op code}
  1493. @z
  1494. @x
  1495. if trie_o[q]<>min_quarterword then
  1496. @y
  1497. if trie_o[q]<>min_trie_op then
  1498. @z
  1499. @x
  1500. trie_c[p]:=si(c); trie_o[p]:=min_quarterword;
  1501. @y
  1502. trie_c[p]:=si(c); trie_o[p]:=min_trie_op;
  1503. @z
  1504. @x
  1505. l:=k; v:=min_quarterword;
  1506. @y
  1507. l:=k; v:=min_trie_op;
  1508. @z
  1509. @x
  1510. @!h:two_halves; {template used to zero out |trie|'s holes}
  1511. @y
  1512. @z
  1513.  
  1514. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1515. % [49.1275] Same stuff as for \input, this time for \openin. There seems
  1516. % to be no reasonable way to make this into a subroutine ...
  1517. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1518. @x
  1519.   if cur_ext="" then cur_ext:=".tex";
  1520.   pack_cur_name;
  1521.   if a_open_in(read_file[n]) then read_open[n]:=just_open;
  1522. @y
  1523.   pack_cur_name;
  1524.   if (cur_ext <> "") and a_open_in (read_file[n], TEX_INPUT_PATH)
  1525.   then read_open[n] := just_open
  1526.  
  1527.   else if (cur_ext <> ".tex") and (name_length + 5 < file_name_size)
  1528.      and (not extension_irrelevant_p (name_of_file, 'tex'))
  1529.   then begin
  1530.     name_of_file[name_length + 1] := ".";
  1531.     name_of_file[name_length + 2] := "t";
  1532.     name_of_file[name_length + 3] := "e";
  1533.     name_of_file[name_length + 4] := "x";
  1534.     name_length := name_length + 4;
  1535.     if a_open_in (read_file[n], TEX_INPUT_PATH)
  1536.     then read_open[n] := just_open
  1537.  
  1538.     else begin
  1539.       name_length := name_length - 4;
  1540.       name_of_file[name_length + 1] := " ";
  1541.       if (cur_ext = "") and a_open_in (read_file[n], TEX_INPUT_PATH)
  1542.       then read_open[n] := just_open
  1543.   
  1544.       else if make_tex_tex and a_open_in (read_file[n], TEX_INPUT_PATH)
  1545.       then read_open[n] := just_open;
  1546.     end;
  1547.   end;
  1548. @z
  1549.  
  1550. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1551. % [50.1302] Eliminate now-unused variable `w' in `store_fmt_file'.
  1552. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1553. @x
  1554. @!x: integer; {something to dump}
  1555. @!w: four_quarters; {four ASCII codes}
  1556. @y
  1557. @!x: integer; {something to dump}
  1558. @z
  1559.  
  1560. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1561. % [50.1303] Ditto, for `load_fmt_file'.
  1562. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1563. @x
  1564. @!x: integer; {something undumped}
  1565. @!w: four_quarters; {four ASCII codes}
  1566. @y
  1567. @!x: integer; {something undumped}
  1568. @z
  1569.  
  1570. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1571. % [50.??] Do reading and writing of `fmt_file' in C.
  1572. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1573. @x
  1574. @d dump_wd(#)==begin fmt_file^:=#; put(fmt_file);@+end
  1575. @d dump_int(#)==begin fmt_file^.int:=#; put(fmt_file);@+end
  1576. @d dump_hh(#)==begin fmt_file^.hh:=#; put(fmt_file);@+end
  1577. @d dump_qqqq(#)==begin fmt_file^.qqqq:=#; put(fmt_file);@+end
  1578. @y
  1579. @z
  1580.  
  1581. @x
  1582. @d undump_wd(#)==begin get(fmt_file); #:=fmt_file^;@+end
  1583. @d undump_int(#)==begin get(fmt_file); #:=fmt_file^.int;@+end
  1584. @d undump_hh(#)==begin get(fmt_file); #:=fmt_file^.hh;@+end
  1585. @d undump_qqqq(#)==begin get(fmt_file); #:=fmt_file^.qqqq;@+end
  1586. @y
  1587. @z
  1588.  
  1589. @x
  1590. x:=fmt_file^.int;
  1591. @y
  1592. undump_int(x);        {This reads the first word of the \.{.fmt} file}
  1593. @z
  1594.  
  1595. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1596. % [??] Make dumping/undumping more efficient.
  1597. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1598. @x
  1599. for k:=0 to str_ptr do dump_int(str_start[k]);
  1600. k:=0;
  1601. while k+4<pool_ptr do
  1602.   begin dump_four_ASCII; k:=k+4;
  1603.   end;
  1604. k:=pool_ptr-4; dump_four_ASCII;
  1605. @y
  1606. dump_things(str_start[0], str_ptr+1);
  1607. dump_things(str_pool[0], pool_ptr);
  1608. @z
  1609.  
  1610. @x
  1611. for k:=0 to str_ptr do undump(0)(pool_ptr)(str_start[k]);
  1612. k:=0;
  1613. while k+4<pool_ptr do
  1614.   begin undump_four_ASCII; k:=k+4;
  1615.   end;
  1616. k:=pool_ptr-4; undump_four_ASCII;
  1617. @y
  1618. undump_things(str_start[0], str_ptr+1);
  1619. undump_things(str_pool[0], pool_ptr);
  1620. @z
  1621.  
  1622. @x
  1623. repeat for k:=p to q+1 do dump_wd(mem[k]);
  1624. x:=x+q+2-p; var_used:=var_used+q-p;
  1625. p:=q+node_size(q); q:=rlink(q);
  1626. until q=rover;
  1627. var_used:=var_used+lo_mem_max-p; dyn_used:=mem_end+1-hi_mem_min;@/
  1628. for k:=p to lo_mem_max do dump_wd(mem[k]);
  1629. x:=x+lo_mem_max+1-p;
  1630. dump_int(hi_mem_min); dump_int(avail);
  1631. for k:=hi_mem_min to mem_end do dump_wd(mem[k]);
  1632. @y
  1633. repeat
  1634.  dump_things(mem[p], q+2-p);
  1635. x:=x+q+2-p; var_used:=var_used+q-p;
  1636. p:=q+node_size(q); q:=rlink(q);
  1637. until q=rover;
  1638. var_used:=var_used+lo_mem_max-p; dyn_used:=mem_end+1-hi_mem_min;@/
  1639. dump_things(mem[p], lo_mem_max+1-p);
  1640. x:=x+lo_mem_max+1-p;
  1641. dump_int(hi_mem_min); dump_int(avail);
  1642. dump_things(mem[hi_mem_min], mem_end+1-hi_mem_min);
  1643. @z
  1644.  
  1645. @x
  1646. repeat for k:=p to q+1 do undump_wd(mem[k]);
  1647. p:=q+node_size(q);
  1648. if (p>lo_mem_max)or((q>=rlink(q))and(rlink(q)<>rover)) then goto bad_fmt;
  1649. q:=rlink(q);
  1650. until q=rover;
  1651. for k:=p to lo_mem_max do undump_wd(mem[k]);
  1652. @y
  1653. repeat
  1654.   undump_things(mem[p], q+2-p);
  1655. p:=q+node_size(q);
  1656. if (p>lo_mem_max)or((q>=rlink(q))and(rlink(q)<>rover)) then goto bad_fmt;
  1657. q:=rlink(q);
  1658. until q=rover;
  1659. undump_things(mem[p], lo_mem_max+1-p);
  1660. @z
  1661.  
  1662. @x
  1663. for k:=hi_mem_min to mem_end do undump_wd(mem[k]);
  1664. @y
  1665. undump_things(mem[hi_mem_min], mem_end+1-hi_mem_min);
  1666. @z
  1667.  
  1668. @x
  1669. while k<l do
  1670.   begin dump_wd(eqtb[k]); incr(k);
  1671.   end;
  1672. @y
  1673. dump_things(eqtb[k], l-k);
  1674. @z
  1675.  
  1676. @x
  1677. while k<l do
  1678.   begin dump_wd(eqtb[k]); incr(k);
  1679.   end;
  1680. @y
  1681. dump_things(eqtb[k], l-k);
  1682. @z
  1683.  
  1684. @x
  1685. for j:=k to k+x-1 do undump_wd(eqtb[j]);
  1686. @y
  1687. undump_things(eqtb[k], x);
  1688. @z
  1689.  
  1690. @x
  1691. for p:=hash_used+1 to undefined_control_sequence-1 do dump_hh(hash[p]);
  1692. @y
  1693. dump_things(hash[hash_used+1], undefined_control_sequence-1-hash_used);
  1694. @z
  1695.  
  1696. @x
  1697. for p:=hash_used+1 to undefined_control_sequence-1 do undump_hh(hash[p]);
  1698. @y
  1699. undump_things(hash[hash_used+1], undefined_control_sequence-1-hash_used);
  1700. @z
  1701.  
  1702. @x
  1703. for k:=0 to fmem_ptr-1 do dump_wd(font_info[k]);
  1704. dump_int(font_ptr);
  1705. for k:=null_font to font_ptr do
  1706.   @<Dump the array info for internal font number |k|@>;
  1707. @y
  1708. @<Dump the array info for internal font number |k|@>;
  1709. @z
  1710.  
  1711. @x
  1712. for k:=0 to fmem_ptr-1 do undump_wd(font_info[k]);
  1713. undump_size(font_base)(font_max)('font max')(font_ptr);
  1714. for k:=null_font to font_ptr do
  1715.   @<Undump the array info for internal font number |k|@>
  1716. @y
  1717. @<Undump the array info for internal font number |k|@>;
  1718. @z
  1719.  
  1720. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1721. % [50.1322] Writing font info (almost at end of dump stuff).
  1722. % Knuth's code writes all the information relevant to a single font
  1723. % in the same section of the fmt file.  But it's a lot faster to
  1724. % write the arrays of information out, one whole array at a time.
  1725. % So that's the way we handle dumping and undumping font info.
  1726. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1727. @x
  1728. @ @<Dump the array info for internal font number |k|@>=
  1729. begin dump_qqqq(font_check[k]);
  1730. dump_int(font_size[k]);
  1731. dump_int(font_dsize[k]);
  1732. dump_int(font_params[k]);@/
  1733. dump_int(hyphen_char[k]);
  1734. dump_int(skew_char[k]);@/
  1735. dump_int(font_name[k]);
  1736. dump_int(font_area[k]);@/
  1737. dump_int(font_bc[k]);
  1738. dump_int(font_ec[k]);@/
  1739. dump_int(char_base[k]);
  1740. dump_int(width_base[k]);
  1741. dump_int(height_base[k]);@/
  1742. dump_int(depth_base[k]);
  1743. dump_int(italic_base[k]);
  1744. dump_int(lig_kern_base[k]);@/
  1745. dump_int(kern_base[k]);
  1746. dump_int(exten_base[k]);
  1747. dump_int(param_base[k]);@/
  1748. dump_int(font_glue[k]);@/
  1749. dump_int(bchar_label[k]);
  1750. dump_int(font_bchar[k]);
  1751. dump_int(font_false_bchar[k]);@/
  1752. print_nl("\font"); print_esc(font_id_text(k)); print_char("=");
  1753. print_file_name(font_name[k],font_area[k],"");
  1754. if font_size[k]<>font_dsize[k] then
  1755.   begin print(" at "); print_scaled(font_size[k]); print("pt");
  1756.   end;
  1757. end
  1758. @y
  1759. @ @<Dump the array info for internal font number |k|@>=
  1760. begin dump_things(font_info[0], fmem_ptr);
  1761. dump_int(font_ptr);
  1762. dump_things(font_check[null_font], font_ptr+1-null_font);
  1763. dump_things(font_size[null_font], font_ptr+1-null_font);
  1764. dump_things(font_dsize[null_font], font_ptr+1-null_font);
  1765. dump_things(font_params[null_font], font_ptr+1-null_font);
  1766. dump_things(hyphen_char[null_font], font_ptr+1-null_font);
  1767. dump_things(skew_char[null_font], font_ptr+1-null_font);
  1768. dump_things(font_name[null_font], font_ptr+1-null_font);
  1769. dump_things(font_area[null_font], font_ptr+1-null_font);
  1770. dump_things(font_bc[null_font], font_ptr+1-null_font);
  1771. dump_things(font_ec[null_font], font_ptr+1-null_font);
  1772. dump_things(char_base[null_font], font_ptr+1-null_font);
  1773. dump_things(width_base[null_font], font_ptr+1-null_font);
  1774. dump_things(height_base[null_font], font_ptr+1-null_font);
  1775. dump_things(depth_base[null_font], font_ptr+1-null_font);
  1776. dump_things(italic_base[null_font], font_ptr+1-null_font);
  1777. dump_things(lig_kern_base[null_font], font_ptr+1-null_font);
  1778. dump_things(kern_base[null_font], font_ptr+1-null_font);
  1779. dump_things(exten_base[null_font], font_ptr+1-null_font);
  1780. dump_things(param_base[null_font], font_ptr+1-null_font);
  1781. dump_things(font_glue[null_font], font_ptr+1-null_font);
  1782. dump_things(bchar_label[null_font], font_ptr+1-null_font);
  1783. dump_things(font_bchar[null_font], font_ptr+1-null_font);
  1784. dump_things(font_false_bchar[null_font], font_ptr+1-null_font);
  1785. for k:=null_font to font_ptr do begin
  1786.   print_nl("\font"); print_esc(font_id_text(k)); print_char("=");
  1787.   print_file_name(font_name[k],font_area[k],"");
  1788.   if font_size[k]<>font_dsize[k] then begin
  1789.     print(" at "); print_scaled(font_size[k]); print("pt");
  1790.   end;
  1791. end;
  1792. end
  1793. @z
  1794.  
  1795. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1796. % [50.1322] Reading font info for C (nearly done with undump stuff).
  1797. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1798. @x
  1799. @ @<Undump the array info for internal font number |k|@>=
  1800. begin undump_qqqq(font_check[k]);@/
  1801. undump_int(font_size[k]);
  1802. undump_int(font_dsize[k]);
  1803. undump(min_halfword)(max_halfword)(font_params[k]);@/
  1804. undump_int(hyphen_char[k]);
  1805. undump_int(skew_char[k]);@/
  1806. undump(0)(str_ptr)(font_name[k]);
  1807. undump(0)(str_ptr)(font_area[k]);@/
  1808. undump(0)(255)(font_bc[k]);
  1809. undump(0)(255)(font_ec[k]);@/
  1810. undump_int(char_base[k]);
  1811. undump_int(width_base[k]);
  1812. undump_int(height_base[k]);@/
  1813. undump_int(depth_base[k]);
  1814. undump_int(italic_base[k]);
  1815. undump_int(lig_kern_base[k]);@/
  1816. undump_int(kern_base[k]);
  1817. undump_int(exten_base[k]);
  1818. undump_int(param_base[k]);@/
  1819. undump(min_halfword)(lo_mem_max)(font_glue[k]);@/
  1820. undump(0)(font_mem_size)(bchar_label[k]);
  1821. undump(min_quarterword)(non_char)(font_bchar[k]);
  1822. undump(min_quarterword)(non_char)(font_false_bchar[k]);
  1823. end
  1824. @y
  1825. @  The way this is done in C makes the reference to
  1826. the internal font number meaningless, but putting the code
  1827. here preserves the association with the WEB modules.
  1828.  
  1829. @<Undump the array info for internal font number |k|@>=
  1830. begin undump_things(font_info[0], fmem_ptr);
  1831. undump_size(font_base)(font_max)('font max')(font_ptr);
  1832. undump_things(font_check[null_font], font_ptr+1-null_font);
  1833. undump_things(font_size[null_font], font_ptr+1-null_font);
  1834. undump_things(font_dsize[null_font], font_ptr+1-null_font);
  1835. undump_things(font_params[null_font], font_ptr+1-null_font);
  1836. undump_things(hyphen_char[null_font], font_ptr+1-null_font);
  1837. undump_things(skew_char[null_font], font_ptr+1-null_font);
  1838. undump_things(font_name[null_font], font_ptr+1-null_font);
  1839. undump_things(font_area[null_font], font_ptr+1-null_font);
  1840. undump_things(font_bc[null_font], font_ptr+1-null_font);
  1841. undump_things(font_ec[null_font], font_ptr+1-null_font);
  1842. undump_things(char_base[null_font], font_ptr+1-null_font);
  1843. undump_things(width_base[null_font], font_ptr+1-null_font);
  1844. undump_things(height_base[null_font], font_ptr+1-null_font);
  1845. undump_things(depth_base[null_font], font_ptr+1-null_font);
  1846. undump_things(italic_base[null_font], font_ptr+1-null_font);
  1847. undump_things(lig_kern_base[null_font], font_ptr+1-null_font);
  1848. undump_things(kern_base[null_font], font_ptr+1-null_font);
  1849. undump_things(exten_base[null_font], font_ptr+1-null_font);
  1850. undump_things(param_base[null_font], font_ptr+1-null_font);
  1851. undump_things(font_glue[null_font], font_ptr+1-null_font);
  1852. undump_things(bchar_label[null_font], font_ptr+1-null_font);
  1853. undump_things(font_bchar[null_font], font_ptr+1-null_font);
  1854. undump_things(font_false_bchar[null_font], font_ptr+1-null_font);
  1855. end
  1856. @z
  1857.  
  1858. % The hyphenation patterns.
  1859. @x
  1860. for k:=0 to trie_max do dump_hh(trie[k]);
  1861. dump_int(trie_op_ptr);
  1862. for k:=1 to trie_op_ptr do
  1863.   begin dump_int(hyf_distance[k]);
  1864.   dump_int(hyf_num[k]);
  1865.   dump_int(hyf_next[k]);
  1866.   end;
  1867. @y
  1868. dump_things(trie_trl[0], trie_max+1);
  1869. dump_things(trie_tro[0], trie_max+1);
  1870. dump_things(trie_trc[0], trie_max+1);
  1871. dump_int(trie_op_ptr);
  1872. dump_things(hyf_distance[1], trie_op_ptr);
  1873. dump_things(hyf_num[1], trie_op_ptr);
  1874. dump_things(hyf_next[1], trie_op_ptr);
  1875. @z
  1876.  
  1877. @x
  1878. for k:=0 to j do undump_hh(trie[k]);
  1879. undump_size(0)(trie_op_size)('trie op size')(j); @+init trie_op_ptr:=j;@+tini
  1880. for k:=1 to j do
  1881.   begin undump(0)(63)(hyf_distance[k]); {a |small_number|}
  1882.   undump(0)(63)(hyf_num[k]);
  1883.   undump(min_quarterword)(max_quarterword)(hyf_next[k]);
  1884.   end;
  1885. @y
  1886. undump_things(trie_trl[0], j+1);
  1887. undump_things(trie_tro[0], j+1);
  1888. undump_things(trie_trc[0], j+1);
  1889. undump_size(0)(trie_op_size)('trie op size')(j); @+init trie_op_ptr:=j;@+tini
  1890. undump_things(hyf_distance[1], j);
  1891. undump_things(hyf_num[1], j);
  1892. undump_things(hyf_next[1], j);
  1893. @z
  1894.  
  1895. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1896. % [50.1327] As with TFM files, `eof' here means `have we previously
  1897. % encountered the end-of-file', not `are we at the end of the file'.
  1898. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1899. @x
  1900. if (x<>69069)or eof(fmt_file) then goto bad_fmt
  1901. @y
  1902. if (x<>69069)or feof(fmt_file) then goto bad_fmt
  1903. @z
  1904.  
  1905. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1906. % [50.1328] Eliminate possibly wrong word `preloaded' from format_idents.
  1907. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1908. @x
  1909. print(" (preloaded format="); print(job_name); print_char(" ");
  1910. @y
  1911. print(" (format="); print(job_name); print_char(" ");
  1912. @z
  1913.  
  1914. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1915. % [51.1332] `uexit' argument depends on `history'; add call to
  1916. % set_paths; make the main program a procedure, so that uses of `eqtb'
  1917. % will work.
  1918. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1919. @x
  1920. @p begin @!{|start_here|}
  1921. @y
  1922. @p procedure tex_body;
  1923. begin @!{|start_here|}
  1924. @z
  1925.  
  1926. @x
  1927. t_open_out; {open the terminal for output}
  1928. @y
  1929. t_open_out; {open the terminal for output}
  1930. {get default file paths from the environment}
  1931. set_paths (TEX_FORMAT_PATH_BIT + TEX_INPUT_PATH_BIT + TEX_POOL_PATH_BIT
  1932.            + TFM_FILE_PATH_BIT);
  1933. @z
  1934.  
  1935. @x
  1936. end_of_TEX: close_files_and_terminate;
  1937. final_end: ready_already:=0;
  1938. end.
  1939. @y
  1940. close_files_and_terminate;
  1941. final_end: do_final_end;
  1942. end {|tex_body|};
  1943. @z
  1944.  
  1945. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1946. % [51.1333] Print new line before termination; switch to editor if
  1947. % necessary.
  1948. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1949. @x
  1950.     slow_print(log_name); print_char(".");
  1951.     end;
  1952.   end;
  1953. @y
  1954.     slow_print(log_name); print_char(".");
  1955.     end;
  1956.   end;
  1957. print_ln;
  1958. if (edit_name_start<>0) and (interaction>batch_mode) then
  1959.     call_edit(str_pool,edit_name_start,edit_name_length,edit_line);
  1960. @z
  1961.  
  1962. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1963. % [52.1338] Core-dump in debugging mode on 0 input.  Under Unix, it's
  1964. % not possible to switch into the debugger while a program is running.
  1965. % The best approximation is to do a core dump, then run the debugger on
  1966. % it later.
  1967. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1968. @x
  1969.     begin goto breakpoint;@\ {go to every label at least once}
  1970.     breakpoint: m:=0; @{'BREAKPOINT'@}@\
  1971.     end
  1972. @y
  1973.     dump_core {Do something to cause a core dump}
  1974. @z
  1975.  
  1976. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1977. % [54.1376] Add editor-switch variables to globals.
  1978. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1979. @x
  1980. This section should be replaced, if necessary, by any special
  1981. modifications of the program
  1982. that are necessary to make \TeX\ work at a particular installation.
  1983. It is usually best to design your change file so that all changes to
  1984. previous sections preserve the section numbering; then everybody's version
  1985. will be consistent with the published program. More extensive changes,
  1986. which introduce new sections, can be inserted here; then only the index
  1987. itself will get a new section number.
  1988. @^system dependencies@>
  1989. @y
  1990. Here is a temporary integer, used as a holder during reading and writing of
  1991. TFM files, and a temporary |memory_word|, used in reading/writing format
  1992. files.
  1993. Also, the variables used to hold ``switch-to-editor'' information.
  1994. @^<system dependencies@>
  1995.  
  1996. @<Glob...@>=
  1997. @!edit_name_start: pool_pointer;
  1998. @!edit_name_length,@!edit_line,@!tfm_temp: integer;
  1999.  
  2000. @ The |edit_name_start| will be set to point into |str_pool| somewhere after
  2001. its beginning if \TeX\ is supposed to switch to an editor on exit.
  2002.  
  2003. @<Set init...@>=
  2004. edit_name_start:=0;
  2005. @z
  2006.