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 / mf / mf.ch < prev    next >
Text File  |  1996-09-28  |  51KB  |  1,410 lines

  1. % mf.ch for C compilation with web2c, derived from various other change
  2. % files: INITEX.CH for Berkeley Unix TeX 1.1 (by Howard Trickey and
  3. % Pavel Curtis), by Paul Richards.  web2c modifications by Tim Morgan,
  4. % et al.
  5. %
  6. % Modification history:
  7. % (more recent changes in ChangeLog)
  8. % Revision 2.0  90/3/27   20:20:00  ken
  9. %       To version 2.0.
  10. % Revision 1.9  90/1/20   09:05:32  karl
  11. %       To version 1.9.
  12. % Revision 1.8  89/11/30  09:08:16  karl
  13. %     To version 1.8 (8-bit).
  14. % Revision 1.7  88/12/27  15:02:24  mackay
  15. %    Cosmetic upgrade for version 1.7
  16. % Revision 1.6  88/12/11  15:59:15  morgan
  17. %    Brought up to MF version 1.6
  18. % Revision 1.5  88/03/02  13:25:44  morgan
  19. %    More C changes
  20. % Revision 1.4  87/12/09  12:50:00  hesse
  21. %    Changes for C version
  22. % Revision 1.3  87/03/07  21:15:21  mackay
  23. %    Minor changes found on archive version on SCORE
  24. % Revision 1.2  86/09/29  21:46:43  mackay
  25. %    Made no-debug the default, and changed version number
  26. %    to correspond with improved mf.web file
  27. %    (Got rid of debug code to avoid bug in range check
  28. %    code of VAX4.3 BSD and SUN3 version 3.1 Os pc interpreter)
  29. % Revision 1.0  86/01/31  15:46:08  richards
  30. % Released for MF 1.0;
  31. %     Incorporates: New binary I/O library, separate optimized
  32. %     arithmetic for takefraction/makefraction, new graphics interface.
  33.  
  34.  
  35. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  36. % [0] WEAVE: print changes only.
  37. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  38. @x
  39. \def\botofcontents{\vskip 0pt plus 1fil minus 1.5in}
  40. @y
  41. \def\botofcontents{\vskip 0pt plus 1fil minus 1.5in}
  42. \let\maybe=\iffalse
  43. \def\title{\MF\ changes for C}
  44. \def\glob{13}\def\gglob{20, 25} % these are defined in module 1
  45. @z
  46.  
  47. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  48. % [1.2] banner
  49. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  50. @x
  51. @d banner=='This is METAFONT, Version 2.71' {printed when \MF\ starts}
  52. @y
  53. @d banner=='This is METAFONT, Version 2.71' {more is printed later}
  54. @z
  55.  
  56. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  57. % [1.7] Convert `debug..gubed' and `stat..tats' into #ifdefs.
  58. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  59. @x
  60. @d debug==@{ {change this to `$\\{debug}\equiv\null$' when debugging}
  61. @d gubed==@t@>@} {change this to `$\\{gubed}\equiv\null$' when debugging}
  62. @f debug==begin
  63. @f gubed==end
  64. @#
  65. @d stat==@{ {change this to `$\\{stat}\equiv\null$' when gathering
  66.   usage statistics}
  67. @d tats==@t@>@} {change this to `$\\{tats}\equiv\null$' when gathering
  68.   usage statistics}
  69. @y
  70. @d stat==ifdef('STAT')
  71. @d tats==endif('STAT')
  72. @d debug==ifdef('DEBUG')
  73. @d gubed==endif('DEBUG')
  74. @z
  75.  
  76. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  77. % [1.8] Same, for `init..tini'.
  78. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  79. @x
  80. @d init== {change this to `$\\{init}\equiv\.{@@\{}$' in the production version}
  81. @d tini== {change this to `$\\{tini}\equiv\.{@@\}}$' in the production version}
  82. @y
  83. @d init==ifdef('INIMF')
  84. @d tini==endif('INIMF')
  85. @z
  86.  
  87. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  88. % [??] Get rid of compiler directives.
  89. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  90. @x
  91. @<Compiler directives@>=
  92. @{@&$C-,A+,D-@} {no range check, catch arithmetic overflow, no debug overhead}
  93. @!debug @{@&$C+,D+@}@+ gubed {but turn everything on when debugging}
  94. @y
  95. @<Compiler directives@>=
  96. @{No compiler directives for C.@}
  97. @z
  98.  
  99. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  100. % [1.11] Compile-time constants.  Although we only change a few of
  101. % these, listing them all makes the patch file for a big Metafont simpler.
  102. % 16K for BSD I/O; file_name_size is set from the system constant.
  103. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  104. @x
  105. @<Constants...@>=
  106. @!mem_max=30000; {greatest index in \MF's internal |mem| array;
  107.   must be strictly less than |max_halfword|;
  108.   must be equal to |mem_top| in \.{INIMF}, otherwise |>=mem_top|}
  109. @!max_internal=100; {maximum number of internal quantities}
  110. @!buf_size=500; {maximum number of characters simultaneously present in
  111.   current lines of open files; must not exceed |max_halfword|}
  112. @!error_line=72; {width of context lines on terminal error messages}
  113. @!half_error_line=42; {width of first lines of contexts in terminal
  114.   error messages; should be between 30 and |error_line-15|}
  115. @!max_print_line=79; {width of longest text lines output; should be at least 60}
  116. @!screen_width=768; {number of pixels in each row of screen display}
  117. @!screen_depth=1024; {number of pixels in each column of screen display}
  118. @!stack_size=30; {maximum number of simultaneous input sources}
  119. @!max_strings=2000; {maximum number of strings; must not exceed |max_halfword|}
  120. @!string_vacancies=8000; {the minimum number of characters that should be
  121.   available for the user's identifier names and strings,
  122.   after \MF's own error messages are stored}
  123. @!pool_size=32000; {maximum number of characters in strings, including all
  124.   error messages and help texts, and the names of all identifiers;
  125.   must exceed |string_vacancies| by the total
  126.   length of \MF's own strings, which is currently about 22000}
  127. @!move_size=5000; {space for storing moves in a single octant}
  128. @!max_wiggle=300; {number of autorounded points per cycle}
  129. @!gf_buf_size=800; {size of the output buffer, must be a multiple of 8}
  130. @!file_name_size=40; {file names shouldn't be longer than this}
  131. @!pool_name='MFbases:MF.POOL                         ';
  132.   {string of length |file_name_size|; tells where the string pool appears}
  133. @.MFbases@>
  134. @!path_size=300; {maximum number of knots between breakpoints of a path}
  135. @!bistack_size=785; {size of stack for bisection algorithms;
  136.   should probably be left at this value}
  137. @!header_size=100; {maximum number of \.{TFM} header words, times~4}
  138. @!lig_table_size=5000; {maximum number of ligature/kern steps, must be
  139.   at least 255 and at most 32510}
  140. @!max_kerns=500; {maximum number of distinct kern amounts}
  141. @!max_font_dimen=50; {maximum number of \&{fontdimen} parameters}
  142. @y
  143. @d file_name_size == PATH_MAX
  144.  
  145. @<Constants...@>=
  146. @!mem_max=262140; {greatest index in \MF's internal |mem| array;
  147.   must be strictly less than |max_halfword|;
  148.   must be equal to |mem_top| in \.{INIMF}, otherwise |>=mem_top|}
  149. @!max_internal=300; {maximum number of internal quantities}
  150. @!buf_size=3000; {maximum number of characters simultaneously present in
  151.   current lines of open files; must not exceed |max_halfword|}
  152. @!error_line=79; {width of context lines on terminal error messages}
  153. @!half_error_line=50; {width of first lines of contexts in terminal
  154.   error messages; should be between 30 and |error_line-15|}
  155. @!max_print_line=79; {width of longest text lines output; should be at least 60}
  156. @!screen_width=1664; {number of pixels in each row of screen display}
  157. @!screen_depth=1200; {number of pixels in each column of screen display}
  158. @!stack_size=300; {maximum number of simultaneous input sources}
  159. @!max_strings=7500; {maximum number of strings; must not exceed |max_halfword|}
  160. @!string_vacancies=74000; {the minimum number of characters that should be
  161.   available for the user's identifier names and strings,
  162.   after \MF's own error messages are stored}
  163. @!pool_size=100000; {maximum number of characters in strings, including all
  164.   error messages and help texts, and the names of all identifiers;
  165.   must exceed |string_vacancies| by the total
  166.   length of \MF's own strings, which is currently about 22000}
  167. @!move_size=20000; {space for storing moves in a single octant}
  168. @!max_wiggle=1000; {number of autorounded points per cycle}
  169. @!gf_buf_size=16384; {size of the output buffer, must be a multiple of 8}
  170. @!pool_name='mf.pool';
  171.   {string of length |file_name_size|; tells where the string pool appears}
  172. @!path_size=1000; {maximum number of knots between breakpoints of a path}
  173. @!bistack_size=1500; {size of stack for bisection algorithms;
  174.   should probably be left at this value}
  175. @!header_size=100; {maximum number of \.{TFM} header words, times~4}
  176. @!lig_table_size=15000; {maximum number of ligature/kern steps, must be
  177.   at least 255 and at most 32510}
  178. @!max_kerns=2500; {maximum number of distinct kern amounts}
  179. @!max_font_dimen=50; {maximum number of \&{fontdimen} parameters}
  180. @!mem_top=262140; {largest index in the |mem| array dumped by \.{INIMF};
  181.   must be substantially larger than |mem_min|
  182.   and not greater than |mem_max|}
  183. @z
  184.  
  185. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  186. % [1.12] Sensitive compile-time constants.  mem_top is made into a
  187. % #define, so it is easier to change for the trap test.
  188. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  189. @x
  190. @d mem_min=0 {smallest index in the |mem| array, must not be less
  191.   than |min_halfword|}
  192. @d mem_top==30000 {largest index in the |mem| array dumped by \.{INIMF};
  193.   must be substantially larger than |mem_min|
  194.   and not greater than |mem_max|}
  195. @d hash_size=2100 {maximum number of symbolic tokens,
  196.   must be less than |max_halfword-3*param_size|}
  197. @d hash_prime=1777 {a prime number equal to about 85\pct! of |hash_size|}
  198. @d max_in_open=6 {maximum number of input files and error insertions that
  199.   can be going on simultaneously}
  200. @d param_size=150 {maximum number of simultaneous macro parameters}
  201. @y
  202. @d mem_min=0 {smallest index in the |mem| array, must not be less
  203.   than |min_halfword|}
  204. @d hash_size=9500 {maximum number of symbolic tokens,
  205.   must be less than |max_halfword-3*param_size|}
  206. @d hash_prime=7919 {a prime number equal to about 85\pct! of |hash_size|}
  207. @d max_in_open=15 {maximum number of input files and error insertions that
  208.   can be going on simultaneously}
  209. @d param_size=150 {maximum number of simultaneous macro parameters}
  210. @z
  211.  
  212. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  213. % [??] Use C macros for `incr' and `decr'.
  214. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  215. @x
  216. @d incr(#) == #:=#+1 {increase a variable by unity}
  217. @d decr(#) == #:=#-1 {decrease a variable by unity}
  218. @y
  219. @z
  220.  
  221. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  222. % [??] The text_char type is used as an array index into xord.  The
  223. % default type `char' produces signed integers, which are bad array
  224. % indices in C.
  225. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  226.  
  227. @x
  228. @d text_char == char {the data type of characters in text files}
  229. @y
  230. @d text_char == ASCII_code {the data type of characters in text files}
  231. @z
  232.  
  233. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  234. % [1.22] Allow any character as input.
  235. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  236. @x
  237. @^character set dependencies@>
  238. @^system dependencies@>
  239.  
  240. @<Set init...@>=
  241. for i:=0 to @'37 do xchr[i]:=' ';
  242. for i:=@'177 to @'377 do xchr[i]:=' ';
  243. @y
  244. @^character set dependencies@>
  245. @^system dependencies@>
  246.  
  247. @d tab = @'11 { ASCII horizontal tab }
  248. @d form_feed = @'14 { ASCII form feed }
  249.  
  250. @<Set init...@>=
  251. for i:=0 to @'37 do xchr[i]:=chr(i);
  252. for i:=@'177 to @'377 do xchr[i]:=chr(i);
  253. @z
  254.  
  255. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  256. % [3.25] Remove file types we don't need.
  257. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  258. @x
  259. The program actually makes use also of a third kind of file, called a
  260. |word_file|, when dumping and reloading base information for its own
  261. initialization.  We shall define a word file later; but it will be possible
  262. for us to specify simple operations on word files before they are defined.
  263.  
  264. @y
  265. I/O in C is done using standard I/O.  We will define the path numbers
  266. in an include file for C which are used in searching for files to be
  267. read.  We'll define all the file types in C also.
  268. @z
  269.  
  270. @x
  271. @!alpha_file=packed file of text_char; {files that contain textual data}
  272. @!byte_file=packed file of eight_bits; {files that contain binary data}
  273. @y
  274. @z
  275.  
  276. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  277. % [3.27] Do file opening in C.
  278. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  279. @x
  280. @ The \ph\ compiler with which the present version of \MF\ was prepared has
  281. extended the rules of \PASCAL\ in a very convenient way. To open file~|f|,
  282. we can write
  283. $$\vbox{\halign{#\hfil\qquad&#\hfil\cr
  284. |reset(f,@t\\{name}@>,'/O')|&for input;\cr
  285. |rewrite(f,@t\\{name}@>,'/O')|&for output.\cr}}$$
  286. The `\\{name}' parameter, which is of type `\ignorespaces|packed
  287. array[@t\<\\{any}>@>] of text_char|', stands for the name of
  288. the external file that is being opened for input or output.
  289. Blank spaces that might appear in \\{name} are ignored.
  290.  
  291. The `\.{/O}' parameter tells the operating system not to issue its own
  292. error messages if something goes wrong. If a file of the specified name
  293. cannot be found, or if such a file cannot be opened for some other reason
  294. (e.g., someone may already be trying to write the same file), we will have
  295. |@!erstat(f)<>0| after an unsuccessful |reset| or |rewrite|.  This allows
  296. \MF\ to undertake appropriate corrective action.
  297. @:PASCAL H}{\ph@>
  298. @^system dependencies@>
  299.  
  300. \MF's file-opening procedures return |false| if no file identified by
  301. |name_of_file| could be opened.
  302.  
  303. @d reset_OK(#)==erstat(#)=0
  304. @d rewrite_OK(#)==erstat(#)=0
  305.  
  306. @p function a_open_in(var @!f:alpha_file):boolean;
  307.   {open a text file for input}
  308. begin reset(f,name_of_file,'/O'); a_open_in:=reset_OK(f);
  309. end;
  310. @#
  311. function a_open_out(var @!f:alpha_file):boolean;
  312.   {open a text file for output}
  313. begin rewrite(f,name_of_file,'/O'); a_open_out:=rewrite_OK(f);
  314. end;
  315. @#
  316. function b_open_out(var @!f:byte_file):boolean;
  317.   {open a binary file for output}
  318. begin rewrite(f,name_of_file,'/O'); b_open_out:=rewrite_OK(f);
  319. end;
  320. @#
  321. function w_open_in(var @!f:word_file):boolean;
  322.   {open a word file for input}
  323. begin reset(f,name_of_file,'/O'); w_open_in:=reset_OK(f);
  324. end;
  325. @#
  326. function w_open_out(var @!f:word_file):boolean;
  327.   {open a word file for output}
  328. begin rewrite(f,name_of_file,'/O'); w_open_out:=rewrite_OK(f);
  329. end;
  330. @y
  331. @ All of the file opening functions are defined in C.
  332. @z
  333.  
  334. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  335. % [3.28] Do file closing in C.
  336. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  337. @x
  338. @ Files can be closed with the \ph\ routine `|close(f)|', which
  339. @^system dependencies@>
  340. should be used when all input or output with respect to |f| has been completed.
  341. This makes |f| available to be opened again, if desired; and if |f| was used for
  342. output, the |close| operation makes the corresponding external file appear
  343. on the user's area, ready to be read.
  344.  
  345. @p procedure a_close(var @!f:alpha_file); {close a text file}
  346. begin close(f);
  347. end;
  348. @#
  349. procedure b_close(var @!f:byte_file); {close a binary file}
  350. begin close(f);
  351. end;
  352. @#
  353. procedure w_close(var @!f:word_file); {close a word file}
  354. begin close(f);
  355. end;
  356. @y
  357. @ And all the file closing routines as well.
  358. @z
  359.  
  360. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  361. % [3.30] Do `input_ln' in C.
  362. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  363. @x
  364. Standard \PASCAL\ says that a file should have |eoln| immediately
  365. before |eof|, but \MF\ needs only a weaker restriction: If |eof|
  366. occurs in the middle of a line, the system function |eoln| should return
  367. a |true| result (even though |f^| will be undefined).
  368.  
  369. @p function input_ln(var @!f:alpha_file;@!bypass_eoln:boolean):boolean;
  370.   {inputs the next line or returns |false|}
  371. var @!last_nonblank:0..buf_size; {|last| with trailing blanks removed}
  372. begin if bypass_eoln then if not eof(f) then get(f);
  373.   {input the first character of the line into |f^|}
  374. last:=first; {cf.\ Matthew 19\thinspace:\thinspace30}
  375. if eof(f) then input_ln:=false
  376. else  begin last_nonblank:=first;
  377.   while not eoln(f) do
  378.     begin if last>=max_buf_stack then
  379.       begin max_buf_stack:=last+1;
  380.       if max_buf_stack=buf_size then
  381.         @<Report overflow of the input buffer, and abort@>;
  382.       end;
  383.     buffer[last]:=xord[f^]; get(f); incr(last);
  384.     if buffer[last-1]<>" " then last_nonblank:=last;
  385.     end;
  386.   last:=last_nonblank; input_ln:=true;
  387.   end;
  388. end;
  389. @y
  390. We define |input_ln| in C, for efficiency.
  391. @z
  392.  
  393. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  394. % [??] `term_in' and `term_out' are standard input and output.
  395. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  396. @x
  397. @<Glob...@>=
  398. @!term_in:alpha_file; {the terminal as an input file}
  399. @!term_out:alpha_file; {the terminal as an output file}
  400. @y
  401. @d term_in==stdin {the terminal as an input file}
  402. @d term_out==stdout {the terminal as an output file}
  403. @z
  404.  
  405. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  406. % [3.32] We don't need to open the terminal files.
  407. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  408. @x
  409. @ Here is how to open the terminal files
  410. in \ph. The `\.{/I}' switch suppresses the first |get|.
  411. @^system dependencies@>
  412.  
  413. @d t_open_in==reset(term_in,'TTY:','/O/I') {open the terminal for text input}
  414. @d t_open_out==rewrite(term_out,'TTY:','/O') {open the terminal for text output}
  415. @y
  416. @ Here is how to open the terminal files.  |t_open_out| does nothing.
  417. |t_open_in|, on the other hand, does the work of ``rescanning,'' or getting
  418. any command line arguments the user has provided.  It's defined in C.
  419.   
  420. @d t_open_out == {output already open for text output}
  421. @z
  422.  
  423. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  424. % [3.33] Flushing output.
  425. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  426. @x
  427. these operations can be specified in \ph:
  428. @^system dependencies@>
  429.  
  430. @d update_terminal == break(term_out) {empty the terminal output buffer}
  431. @d clear_terminal == break_in(term_in,true) {clear the terminal input buffer}
  432. @y
  433. these operations can be specified with {\mc UNIX}.  |update_terminal|
  434. does an |fflush| (via the macro |flush|). |clear_terminal| is redefined
  435. to do nothing, since the user should control the terminal.
  436. @^system dependencies@>
  437.  
  438. @d update_terminal == flush (term_out)
  439. @d clear_terminal == do_nothing
  440. @z
  441.  
  442. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  443. % [3.36] Reading the command line.
  444. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  445. @x
  446. @ The following program does the required initialization
  447. without retrieving a possible command line.
  448. It should be clear how to modify this routine to deal with command lines,
  449. if the system permits them.
  450. @^system dependencies@>
  451.  
  452. @p function init_terminal:boolean; {gets the terminal input started}
  453. label exit;
  454. begin t_open_in;
  455. loop@+begin wake_up_terminal; write(term_out,'**'); update_terminal;
  456. @.**@>
  457.   if not input_ln(term_in,true) then {this shouldn't happen}
  458.     begin write_ln(term_out);
  459.     write(term_out,'! End of file on the terminal... why?');
  460. @.End of file on the terminal@>
  461.     init_terminal:=false; return;
  462.     end;
  463.   loc:=first;
  464.   while (loc<last)and(buffer[loc]=" ") do incr(loc);
  465.   if loc<last then
  466.     begin init_terminal:=true;
  467.     return; {return unless the line was all blank}
  468.     end;
  469.   write_ln(term_out,'Please type the name of your input file.');
  470.   end;
  471. exit:end;
  472. @y
  473. @ The following program does the required initialization.
  474. Iff anything has been specified on the command line, then |t_open_in|
  475. will return with |last > first|.
  476. @^system dependencies@>
  477.  
  478. @p
  479. function init_terminal:boolean; {gets the terminal input started}
  480. label exit;
  481. begin
  482.     t_open_in;
  483.     if last > first then begin
  484.         loc := first;
  485.         while (loc < last) and (buffer[loc]=' ') do
  486.         incr(loc);
  487.         if loc < last then begin
  488.             init_terminal := true;
  489.             goto exit;
  490.         end;
  491.     end;
  492.     loop@+begin
  493.         wake_up_terminal; write(term_out, '**'); update_terminal;
  494. @.**@>
  495.         if not input_ln(term_in,true) then begin {this shouldn't happen}
  496.             write_ln(term_out);
  497.             write(term_out, '! End of file on the terminal... why?');
  498. @.End of file on the terminal@>
  499.             init_terminal:=false;
  500.         return;
  501.         end;
  502.  
  503.         loc:=first;
  504.         while (loc<last)and(buffer[loc]=" ") do
  505.             incr(loc);
  506.  
  507.         if loc<last then begin
  508.            init_terminal:=true;
  509.            return; {return unless the line was all blank}
  510.         end;
  511.         write_ln(term_out, 'Please type the name of your input file.');
  512.     end;
  513. exit:
  514. end;
  515. @z
  516.  
  517. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  518. % [4.51] Open the pool file using a path, and can't do string
  519. % assignments directly.  (`strcpy' and `strlen' work here because
  520. % `pool_name' is a constant string, and thus ends in a null and doesn't
  521. % start with a space.)
  522. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  523. @x
  524. name_of_file:=pool_name; {we needn't set |name_length|}
  525. if a_open_in(pool_file) then
  526. @y
  527. vstrcpy (name_of_file+1, pool_name); {copy the string}
  528. name_of_file[0] := ' ';
  529. name_of_file[strlen (pool_name) + 1] := ' ';
  530. name_length := strlen (pool_name);
  531. if a_open_in (pool_file, MF_POOL_PATH) then
  532. @z
  533.  
  534. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  535. % [4.51,52,53] Make `TEX.POOL' lowercase in messages, and change how
  536. % it's read.
  537. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  538. @x
  539. else  bad_pool('! I can''t read MF.POOL.')
  540. @y
  541. else  bad_pool('! I can''t read mf.pool.')
  542. @z
  543.  
  544. @x
  545. begin if eof(pool_file) then bad_pool('! MF.POOL has no check sum.');
  546. @.MF.POOL has no check sum@>
  547. read(pool_file,m,n); {read two digits of string length}
  548. @y
  549. begin if eof(pool_file) then bad_pool('! mf.pool has no check sum.');
  550. @.MF.POOL has no check sum@>
  551. read(pool_file,m); read(pool_file,n); {read two digits of string length}
  552. @z
  553.  
  554. @x
  555.     bad_pool('! MF.POOL line doesn''t begin with two digits.');
  556. @y
  557.     bad_pool('! mf.pool line doesn''t begin with two digits.');
  558. @z
  559.  
  560. @x
  561.   bad_pool('! MF.POOL check sum doesn''t have nine digits.');
  562. @y
  563.   bad_pool('! mf.pool check sum doesn''t have nine digits.');
  564. @z
  565.  
  566. @x
  567. done: if a<>@$ then bad_pool('! MF.POOL doesn''t match; TANGLE me again.');
  568. @y
  569. done: if a<>@$ then bad_pool('! mf.pool doesn''t match; tangle me again.');
  570. @z
  571.  
  572. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  573. % Print rest of banner, eliminate the misleading message ``(no base
  574. % preloaded)''.
  575. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  576. @x
  577. wterm(banner);
  578. if base_ident=0 then wterm_ln(' (no base preloaded)')
  579. else  begin slow_print(base_ident); print_ln;
  580.   end;
  581. @y
  582. wterm (banner);
  583. wterm (version_string);
  584. if base_ident>0 then slow_print(base_ident); print_ln;
  585. @z
  586.  
  587. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  588. % [??] Eliminate non-local goto.
  589. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  590. @x
  591. @<Error hand...@>=
  592. procedure jump_out;
  593. begin goto end_of_MF;
  594. end;
  595. @y
  596. @d do_final_end==begin
  597.    update_terminal;
  598.    ready_already:=0;
  599.    if (history <> spotless) and (history <> warning_issued) then
  600.        uexit(1)
  601.    else
  602.        uexit(0);
  603.    end
  604. @<Error hand...@>=
  605. procedure jump_out;
  606. begin
  607. close_files_and_terminate;
  608. do_final_end;
  609. end;
  610. @z
  611.  
  612. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  613. % [6.79] Handle the switch-to-editor option.
  614. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  615. @x
  616. line ready to be edited. But such an extension requires some system
  617. wizardry, so the present implementation simply types out the name of the
  618. file that should be
  619. edited and the relevant line number.
  620. @^system dependencies@>
  621.  
  622. There is a secret `\.D' option available when the debugging routines haven't
  623. been commented~out.
  624. @^debugging@>
  625. @y
  626. line ready to be edited.
  627. We do this by calling the external procedure |call_edit| with a pointer to
  628. the filename, its length, and the line number.
  629. However, here we just set up the variables that will be used as arguments,
  630. since we don't want to do the switch-to-editor until after \MF\ has closed
  631. its files.
  632. @^system dependencies@>
  633.  
  634. There is a secret `\.D' option available when the debugging routines have
  635. not been commented out.
  636. @^debugging@>
  637. @d edit_file==input_stack[file_ptr]
  638. @z
  639. @x
  640. "E": if file_ptr>0 then
  641.   begin print_nl("You want to edit file ");
  642. @.You want to edit file x@>
  643.   slow_print(input_stack[file_ptr].name_field);
  644.   print(" at line "); print_int(line);@/
  645.   interaction:=scroll_mode; jump_out;
  646. @y
  647. "E": if file_ptr>0 then
  648.     begin
  649.     edit_name_start:=str_start[edit_file.name_field];
  650.     edit_name_length:=str_start[edit_file.name_field+1] -
  651.                   str_start[edit_file.name_field];
  652.     edit_line:=line;
  653.     jump_out;
  654. @z
  655.  
  656. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  657. % [9.153] Make it easy to build a bigger Metafont.  (Nothing is changed
  658. % in the basic version.)
  659. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  660. @x
  661. @d min_quarterword=0 {smallest allowable value in a |quarterword|}
  662. @d max_quarterword=255 {largest allowable value in a |quarterword|}
  663. @d min_halfword==0 {smallest allowable value in a |halfword|}
  664. @d max_halfword==65535 {largest allowable value in a |halfword|}
  665. @y
  666. @d min_quarterword=0 {smallest allowable value in a |quarterword|}
  667. @d max_quarterword=255 {largest allowable value in a |quarterword|}
  668. @d min_halfword==0 {smallest allowable value in a |halfword|}
  669. @d max_halfword==262143 {largest allowable value in a |halfword|}
  670. @z
  671.  
  672. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  673. % [??] Efficiency.
  674. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  675. @x
  676. @ The operation of subtracting |min_halfword| occurs rather frequently in
  677. \MF, so it is convenient to abbreviate this operation by using the macro
  678. |ho| defined here.  \MF\ will run faster with respect to compilers that
  679. don't optimize the expression `|x-0|', if this macro is simplified in the
  680. obvious way when |min_halfword=0|. Similarly, |qi| and |qo| are used for
  681. input to and output from quarterwords.
  682. @^system dependencies@>
  683.  
  684. @d ho(#)==#-min_halfword
  685.   {to take a sixteen-bit item from a halfword}
  686. @d qo(#)==#-min_quarterword {to read eight bits from a quarterword}
  687. @d qi(#)==#+min_quarterword {to store eight bits in a quarterword}
  688.  
  689. @y
  690. @ The operation of subtracting |min_halfword| occurs rather frequently in
  691. \MF, so it is convenient to abbreviate this operation by using the macro
  692. |ho| defined here.  \MF\ will run faster with respect to compilers that
  693. don't optimize the expression `|x-0|', if this macro is simplified in the
  694. obvious way when |min_halfword=0|. Similarly, |qi| and |qo| are used for
  695. input to and output from quarterwords.
  696. So they have been simplified here in the obvious way.
  697. @^system dependencies@>
  698.  
  699. @d ho(#)==#
  700. @d qo(#)==#
  701. @d qi(#)==#
  702. @z
  703.  
  704. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  705. % [??] We've put the memory structure into the include file `texmf.h',
  706. % since it's too hard to translate automatically.  Also, remove the
  707. % `word_file' type.
  708. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  709. @x
  710. @!two_halves = packed record@;@/
  711.   @!rh:halfword;
  712.   case two_choices of
  713.   1: (@!lh:halfword);
  714.   2: (@!b0:quarterword; @!b1:quarterword);
  715.   end;
  716. @!four_quarters = packed record@;@/
  717.   @!b0:quarterword;
  718.   @!b1:quarterword;
  719.   @!b2:quarterword;
  720.   @!b3:quarterword;
  721.   end;
  722. @!memory_word = record@;@/
  723.   case three_choices of
  724.   1: (@!int:integer);
  725.   2: (@!hh:two_halves);
  726.   3: (@!qqqq:four_quarters);
  727.   end;
  728. @!word_file = file of memory_word;
  729. @y
  730. @=#include "texmfmem.h";@>
  731. @z
  732.  
  733. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  734. % [??] Fix an unsigned/signed problem in getnode.
  735. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  736. @x
  737. if r>p+1 then @<Allocate from the top of node |p| and |goto found|@>;
  738. @y
  739. if r>toint(p+1) then @<Allocate from the top of node |p| and |goto found|@>;
  740. @z
  741.  
  742. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  743. % [11.178] Change the word `free' so that it doesn't conflict with the
  744. % standard C library routine of the same name.
  745. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  746. @x
  747. been included. (You may want to decrease the size of |mem| while you
  748. @^debugging@>
  749. are debugging.)
  750. @y
  751. been included. (You may want to decrease the size of |mem| while you
  752. @^debugging@>
  753. are debugging.)
  754.  
  755. @d free==free_arr
  756. @z
  757.  
  758. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  759. % [??] Eliminate two unsigned comparisons to zero.
  760. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  761. @x
  762. repeat if (p>=lo_mem_max)or(p<mem_min) then clobbered:=true
  763.   else if (rlink(p)>=lo_mem_max)or(rlink(p)<mem_min) then clobbered:=true
  764. @y
  765. repeat if (p>=lo_mem_max) then clobbered:=true
  766.   else if (rlink(p)>=lo_mem_max) then clobbered:=true
  767. @z
  768.  
  769. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  770. % [12.194] Do `fix_date_and_time' in C.
  771. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  772. @x
  773. @ The following procedure, which is called just before \MF\ initializes its
  774. input and output, establishes the initial values of the date and time.
  775. @^system dependencies@>
  776. Since standard \PASCAL\ cannot provide such information, something special
  777. is needed. The program here simply specifies July 4, 1776, at noon; but
  778. users probably want a better approximation to the truth.
  779.  
  780. Note that the values are |scaled| integers. Hence \MF\ can no longer
  781. be used after the year 32767.
  782.  
  783. @p procedure fix_date_and_time;
  784. begin internal[time]:=12*60*unity; {minutes since midnight}
  785. internal[day]:=4*unity; {fourth day of the month}
  786. internal[month]:=7*unity; {seventh month of the year}
  787. internal[year]:=1776*unity; {Anno Domini}
  788. end;
  789. @y
  790. @ The following procedure, which is called just before \MF\ initializes its
  791. input and output, establishes the initial values of the date and time.
  792. It is calls an externally defined |date_and_time|, even though it could
  793. be done from Pascal.
  794. The external procedure also sets up interrupt catching.
  795. @^system dependencies@>
  796.  
  797. Note that the values are |scaled| integers. Hence \MF\ can no longer
  798. be used after the year 32767.
  799.  
  800. @p procedure fix_date_and_time;
  801. begin
  802.     date_and_time(internal[time],internal[day],internal[month],internal[year]);
  803.     internal[time] := internal[time] * unity;
  804.     internal[day] := internal[day] * unity;
  805.     internal[month] := internal[month] * unity;
  806.     internal[year] := internal[year] * unity;
  807. end;
  808. @z
  809.  
  810. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  811. % [12.199] Allow <tab> and <form feed> as input.
  812. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  813. @x
  814. for k:=0 to " "-1 do char_class[k]:=invalid_class;
  815. for k:=127 to 255 do char_class[k]:=invalid_class;
  816. @y
  817. for k:=0 to " "-1 do char_class[k]:=invalid_class;
  818. for k:=127 to 255 do char_class[k]:=invalid_class;
  819. char_class[tab]:=space_class;
  820. char_class[form_feed]:=space_class;
  821. @z
  822.  
  823. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  824. % [\approx 329] |valid_range| uses |abs|, which we have defined as a C
  825. % macro.  Some C preprocessors cannot expand the giant argument here.
  826. % So we add a temporary.
  827. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  828. @x
  829. @p procedure edge_prep(@!ml,@!mr,@!nl,@!nr:integer);
  830. var @!delta:halfword; {amount of change}
  831. @y
  832. @p procedure edge_prep(@!ml,@!mr,@!nl,@!nr:integer);
  833. var @!delta:halfword; {amount of change}
  834. temp:integer;
  835. @z
  836.  
  837. @x
  838. if not valid_range(m_min(cur_edges)+m_offset(cur_edges)-zero_field) or@|
  839.  not valid_range(m_max(cur_edges)+m_offset(cur_edges)-zero_field) then
  840. @y
  841. temp := m_offset (cur_edges) - zero_field;
  842. if not valid_range (m_min (cur_edges) + temp)
  843.    or not valid_range (m_max (cur_edges) + temp)
  844. then
  845. @z
  846.  
  847. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  848. % [\approx 530] |make_fraction| and |take_fraction| are defined as C
  849. % macros, to make the parameters work right.  Their expansions are too
  850. % long for some preprocessors, just as in the previous change.
  851. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  852. @x
  853.   alpha:=take_fraction(take_fraction(major_axis,
  854.       make_fraction(gamma,beta)),n_cos)@|
  855.     -take_fraction(take_fraction(minor_axis,
  856.       make_fraction(delta,beta)),n_sin);
  857.   alpha:=(alpha+half_unit) div unity;
  858.   gamma:=pyth_add(take_fraction(major_axis,n_cos),
  859.     take_fraction(minor_axis,n_sin));
  860. @y
  861.   alpha := make_fraction (gamma, beta);
  862.   alpha := take_fraction (major_axis, alpha);
  863.   alpha := take_fraction (alpha, n_cos);
  864.   alpha := (alpha+half_unit) div unity;
  865.   gamma := take_fraction (minor_axis, n_sin);
  866.   gamma := pyth_add (take_fraction (major_axis, n_cos), gamma);
  867. @z
  868.  
  869. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  870. % [27.564] The window functions are defined externally, in C.
  871. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  872. @x
  873. @p function init_screen:boolean;
  874. begin init_screen:=false;
  875. end;
  876. @#
  877. procedure update_screen; {will be called only if |init_screen| returns |true|}
  878. begin @!init wlog_ln('Calling UPDATESCREEN');@+tini {for testing only}
  879. end;
  880. @y
  881. {These functions/procedures are defined externally in C.}
  882. @z
  883.  
  884. @x
  885. @p procedure blank_rectangle(@!left_col,@!right_col:screen_col;
  886.   @!top_row,@!bot_row:screen_row);
  887. var @!r:screen_row;
  888. @!c:screen_col;
  889. begin @{@+for r:=top_row to bot_row-1 do
  890.   for c:=left_col to right_col-1 do
  891.     screen_pixel[r,c]:=white;@+@}@/
  892. @!init wlog_cr; {this will be done only after |init_screen=true|}
  893. wlog_ln('Calling BLANKRECTANGLE(',left_col:1,',',
  894.   right_col:1,',',top_row:1,',',bot_row:1,')');@+tini
  895. end;
  896. @y
  897. {Same thing}
  898. @z
  899.  
  900. @x
  901. @p procedure paint_row(@!r:screen_row;@!b:pixel_color;var @!a:trans_spec;
  902.   @!n:screen_col);
  903. var @!k:screen_col; {an index into |a|}
  904. @!c:screen_col; {an index into |screen_pixel|}
  905. begin @{ k:=0; c:=a[0];
  906. repeat incr(k);
  907.   repeat screen_pixel[r,c]:=b; incr(c);
  908.   until c=a[k];
  909.   b:=black-b; {$|black|\swap|white|$}
  910.   until k=n;@+@}@/
  911. @!init wlog('Calling PAINTROW(',r:1,',',b:1,';');
  912.   {this is done only after |init_screen=true|}
  913. for k:=0 to n do
  914.   begin wlog(a[k]:1); if k<>n then wlog(',');
  915.   end;
  916. wlog_ln(')');@+tini
  917. end;
  918. @y
  919. {Same thing}
  920. @z
  921.  
  922. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  923. % [38.765] Area and extension rules.
  924. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  925. @x
  926. @ The file names we shall deal with for illustrative purposes have the
  927. following structure:  If the name contains `\.>' or `\.:', the file area
  928. consists of all characters up to and including the final such character;
  929. otherwise the file area is null.  If the remaining file name contains
  930. `\..', the file extension consists of all such characters from the first
  931. remaining `\..' to the end, otherwise the file extension is null.
  932. @^system dependencies@>
  933.  
  934. We can scan such file names easily by using two global variables that keep track
  935. of the occurrences of area and extension delimiters:
  936.  
  937. @<Glob...@>=
  938. @!area_delimiter:pool_pointer; {the most recent `\.>' or `\.:', if any}
  939. @!ext_delimiter:pool_pointer; {the relevant `\..', if any}
  940. @y
  941. @ The file names we shall deal with for illustrative purposes have the
  942. following structure:  If the name contains `\./', the file area
  943. consists of all characters up to and including the final such character;
  944. otherwise the file area is null.  If the remaining file name contains
  945. `\..', the file extension consists of all such characters from the first
  946. remaining `\..' to the end, otherwise the file extension is null.
  947. @^system dependencies@>
  948.  
  949. We can scan such file names easily by using two global variables that keep
  950. track of the occurrences of area and extension delimiters:
  951.  
  952. @<Glob...@>=
  953. @!area_delimiter:pool_pointer; {the most recent `\./', if any}
  954. @!ext_delimiter:pool_pointer; {the most recent `\..', if any}
  955. @z
  956.  
  957. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  958. % [38.766] MF area directories.
  959. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  960. @x
  961. @d MF_area=="MFinputs:"
  962. @.MFinputs@>
  963. @y
  964. In C, the default paths are specified in a separate
  965. file, \.{site.h}.  The file opening procedures do path searching
  966. based either on those default paths, or on paths given by the user
  967. in environment variables.
  968. @z
  969.  
  970. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  971. % [38.768] more_name
  972. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  973. @x
  974. begin if c=" " then more_name:=false
  975. else  begin if (c=">")or(c=":") then
  976. @y
  977. begin if (c=" ")or(c=tab) then more_name:=false
  978. else  begin if (c="/") then
  979. @z
  980.  
  981. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  982. % [38.771] In pack_file_name, leave room for the extra null we append at
  983. % the end of a filename in make_c_string.
  984. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  985. @x
  986. if k<=file_name_size then name_length:=k@+else name_length:=file_name_size;
  987. @y
  988. if k<file_name_size then name_length:=k@+else name_length:=file_name_size-1;
  989. @z
  990.  
  991. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  992. % [38.772] The default base.
  993. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  994. @x
  995. @d base_default_length=18 {length of the |MF_base_default| string}
  996. @d base_area_length=8 {length of its area part}
  997. @d base_ext_length=5 {length of its `\.{.base}' part}
  998. @y
  999. In C, we don't give the area part, instead depending
  1000. on the path searching that will happen during file opening.  Also, the
  1001. length will be set in the main program.
  1002.  
  1003. @d base_area_length=0 {length of its area part}
  1004. @d base_ext_length=5 {length of its `\.{.base}' part}
  1005. @z
  1006.  
  1007. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1008. % [38.773] Where `plain.base' is.
  1009. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1010. @x
  1011. @!MF_base_default:packed array[1..base_default_length] of char;
  1012.  
  1013. @ @<Set init...@>=
  1014. MF_base_default:='MFbases:plain.base';
  1015. @y
  1016. @!base_default_length: integer;
  1017. @!MF_base_default: c_char_pointer;
  1018.  
  1019. @ We set the name of the default format file and the length of that name
  1020. in C, instead of Pascal, since we want them to depend on the name of the
  1021. program.
  1022. @z
  1023.  
  1024. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1025. % [38.775] Change to pack_buffered_name as with pack_file_name.
  1026. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1027. @x
  1028. if k<=file_name_size then name_length:=k@+else name_length:=file_name_size;
  1029. @y
  1030. if k<file_name_size then name_length:=k@+else name_length:=file_name_size-1;
  1031. @z
  1032.  
  1033. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1034. % [38.776] Base file opening: only try once, with path searching.
  1035. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1036. @x
  1037.   pack_buffered_name(0,loc,j-1); {try first without the system file area}
  1038.   if w_open_in(base_file) then goto found;
  1039.   pack_buffered_name(base_area_length,loc,j-1);
  1040.     {now try the system base file area}
  1041.   if w_open_in(base_file) then goto found;
  1042. @y
  1043.   pack_buffered_name(0,loc,j-1);
  1044.   if w_open_in(base_file) then goto found;
  1045. @z
  1046.  
  1047. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1048. % (still [38.776]) Replace `PLAIN' in error messages with `default'.
  1049. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1050. @x
  1051.   wterm_ln('Sorry, I can''t find that base;',' will try PLAIN.');
  1052. @y
  1053.   wterm_ln('Sorry, I can''t find that base;',' will try the default.');
  1054. @z
  1055. @x
  1056.   wterm_ln('I can''t find the PLAIN base file!');
  1057. @.I can't find PLAIN...@>
  1058. @y
  1059.   wterm_ln('I can''t find the default base file!');
  1060. @.I can't find default base...@>
  1061. @z
  1062.  
  1063. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1064. % [38.778] Make scan_file_name ignore leading tabs as well as spaces.
  1065. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1066. @x
  1067. @p procedure scan_file_name;
  1068. label done;
  1069. begin begin_name;
  1070. while buffer[loc]=" " do incr(loc);
  1071. @y
  1072. @p procedure scan_file_name;
  1073. label done;
  1074. begin begin_name;
  1075. while (buffer[loc]=" ")or(buffer[loc]=tab) do incr(loc);
  1076. @z
  1077.  
  1078. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1079. % [38.782] `logname' is declared in <unistd.h> on some systems.
  1080. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1081. @x
  1082. `\.{.base}' and `\.{.tfm}' in the names of \MF's output files.
  1083. @y
  1084. `\.{.base}' and `\.{.tfm}' in the names of \MF's output files.
  1085.  
  1086. @d log_name == texmf_log_name
  1087. @z
  1088.  
  1089. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1090. % [38.783] <Scan file name...> needs similar leading tab treatment.
  1091. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1092. @x
  1093. @ @<Scan file name in the buffer@>=
  1094. begin begin_name; k:=first;
  1095. while (buffer[k]=" ")and(k<last) do incr(k);
  1096. @y
  1097. @ @<Scan file name in the buffer@>=
  1098. begin begin_name; k:=first;
  1099. while ((buffer[k]=" ")or(buffer[k]=tab))and(k<last) do incr(k);
  1100. @z
  1101.  
  1102. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1103. % [??] Adjust for C string conventions.
  1104. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1105. @x
  1106. @!months:packed array [1..36] of char; {abbreviations of month names}
  1107. @y
  1108. @!months:c_char_pointer;
  1109. @z
  1110.  
  1111. @x
  1112. begin wlog(banner);
  1113. slow_print(base_ident); print("  ");
  1114. print_int(round_unscaled(internal[day])); print_char(" ");
  1115. months:='JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC';
  1116. @y
  1117. begin wlog(banner);
  1118. wlog (version_string);
  1119. slow_print(base_ident); print("  ");
  1120. print_int(round_unscaled(internal[day])); print_char(" ");
  1121. months := ' JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC';
  1122. @z
  1123.  
  1124.  
  1125. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1126. % [38.789] a_open_in of input file needs path specifier; also, try to
  1127. % open the file with and without the `.mf'.
  1128. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1129. @x
  1130. if cur_ext="" then cur_ext:=".mf";
  1131. pack_cur_name;
  1132. loop@+  begin begin_file_reading; {set up |cur_file| and new level of input}
  1133.   if a_open_in(cur_file) then goto done;
  1134.   if cur_area="" then
  1135.     begin pack_file_name(cur_name,MF_area,cur_ext);
  1136.     if a_open_in(cur_file) then goto done;
  1137.     end;
  1138. @y
  1139. pack_cur_name;
  1140. loop@+begin
  1141.   begin_file_reading; {set up |cur_file| and new level of input}
  1142.   {See comments in \.{tex.ch}.}
  1143.   if (cur_ext <> ".mf") and (name_length + 4 < file_name_size)
  1144.      and (not extension_irrelevant_p (name_of_file, 'mf'))
  1145.   then begin
  1146.     name_of_file[name_length + 1] := ".";
  1147.     name_of_file[name_length + 2] := "m";
  1148.     name_of_file[name_length + 3] := "f";
  1149.     name_length := name_length + 3;
  1150.   end;
  1151.   if a_open_in (cur_file, MF_INPUT_PATH) then goto done;
  1152.  
  1153.   {Try without |".mf"|.}
  1154.   if cur_ext = ".mf" then cur_ext := "";
  1155.   pack_cur_name;
  1156.   if a_open_in (cur_file, MF_INPUT_PATH) then goto done;
  1157.  
  1158.   {Couldn't find the file.  Put |".mf"| back into the filename if we
  1159.    removed it, and then invoke an external program.  If it succeeds, try
  1160.    opening the file once more.}
  1161.   if cur_ext = "" then begin
  1162.     cur_ext := ".mf";
  1163.     pack_cur_name;
  1164.   end;
  1165.   if make_tex_mf then begin
  1166.     if a_open_in (cur_file, MF_INPUT_PATH) then goto done;
  1167.   end;
  1168. @z
  1169.  
  1170. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1171. % [38.789] Get rid of return of filename to string pool.
  1172. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1173. @x
  1174. if name=str_ptr-1 then {we can conserve string pool space now}
  1175.   begin flush_string(name); name:=cur_name;
  1176.   end;
  1177. @y
  1178. @z
  1179.  
  1180. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1181. % [??.???] another C casting problem
  1182. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1183. @x
  1184. if (m_min(cur_edges)+tx<=0)or(m_max(cur_edges)+tx>=8192)or@|
  1185.  (n_min(cur_edges)+ty<=0)or(n_max(cur_edges)+ty>=8191)or@|
  1186. @y
  1187. if (toint(m_min(cur_edges))+tx<=0)or(m_max(cur_edges)+tx>=8192)or@|
  1188.  (toint(n_min(cur_edges))+ty<=0)or(n_max(cur_edges)+ty>=8191)or@|
  1189. @z
  1190.  
  1191. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1192. % [??] `threshold' is both a function and a variable, and broken C
  1193. % compilers (e.g., many versions of pcc), get confused by that.  Since
  1194. % the function is used much less often than the variable, we'll change
  1195. % the function name.
  1196. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  1197. @x
  1198. @p function threshold(@!m:integer):scaled;
  1199. var @!d:scaled; {lower bound on the smallest interval size}
  1200. begin excess:=min_cover(0)-m;
  1201. if excess<=0 then threshold:=0
  1202. else  begin repeat d:=perturbation;
  1203.   until min_cover(d+d)<=m;
  1204.   while min_cover(d)>m do d:=perturbation;
  1205.   threshold:=d;
  1206. @y
  1207. @p function threshold_fn(@!m:integer):scaled;
  1208. var @!d:scaled; {lower bound on the smallest interval size}
  1209. begin excess:=min_cover(0)-m;
  1210. if excess<=0 then threshold_fn:=0
  1211. else  begin repeat d:=perturbation;
  1212.   until min_cover(d+d)<=m;
  1213.   while min_cover(d)>m do d:=perturbation;
  1214.   threshold_fn:=d;
  1215. @z
  1216.  
  1217. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1218. % [??] Change the call to the threshold function.
  1219. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  1220. @x
  1221. begin d:=threshold(m); perturbation:=0;
  1222. @y
  1223. begin d:=threshold_fn(m); perturbation:=0;
  1224. @z
  1225.  
  1226. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1227. % [45.1128] Writing the tfm file.
  1228. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1229. @x
  1230. @d tfm_out(#)==write(tfm_file,#) {output one byte to |tfm_file|}
  1231.  
  1232. @p procedure tfm_two(@!x:integer); {output two bytes to |tfm_file|}
  1233. begin tfm_out(x div 256); tfm_out(x mod 256);
  1234. end;
  1235. @#
  1236. procedure tfm_four(@!x:integer); {output four bytes to |tfm_file|}
  1237. begin if x>=0 then tfm_out(x div three_bytes)
  1238. else  begin x:=x+@'10000000000; {use two's complement for negative values}
  1239.   x:=x+@'10000000000;
  1240.   tfm_out((x div three_bytes) + 128);
  1241.   end;
  1242. x:=x mod three_bytes; tfm_out(x div unity);
  1243. x:=x mod unity; tfm_out(x div @'400);
  1244. tfm_out(x mod @'400);
  1245. end;
  1246. @#
  1247. procedure tfm_qqqq(@!x:four_quarters); {output four quarterwords to |tfm_file|}
  1248. begin tfm_out(qo(x.b0)); tfm_out(qo(x.b1)); tfm_out(qo(x.b2));
  1249. tfm_out(qo(x.b3));
  1250. end;
  1251. @y
  1252. Under {\mc UNIX}, we are using the binary input and output routines.
  1253. Hence, we redefine all the {\mc TFM} input and output in terms of those
  1254. routines.
  1255.  
  1256. @d tfm_out(#) == b_write_byte(tfm_file, #)
  1257. @d tfm_two(#) == b_write_2_bytes(tfm_file, #)
  1258. @d tfm_four(#) == b_write_4_bytes(tfm_file, #)
  1259.  
  1260. @p procedure tfm_qqqq(@!x:four_quarters); {output four quarterwords to |tfm_file|}
  1261. begin tfm_out(qo(x.b0)); tfm_out(qo(x.b1)); tfm_out(qo(x.b2));
  1262. tfm_out(qo(x.b3));
  1263. end;
  1264. @z
  1265.  
  1266. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1267. % [47.1148] write_gf
  1268. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1269. @x
  1270. @<Declare generic font output procedures@>=
  1271. procedure write_gf(@!a,@!b:gf_index);
  1272. var k:gf_index;
  1273. begin for k:=a to b do write(gf_file,gf_buf[k]);
  1274. end;
  1275. @y
  1276. In C, we use a macro to call |fwrite| or |write| directly, writing all
  1277. the bytes to be written in one shot.  Much better even than writing four
  1278. bytes at a time.
  1279. @z
  1280.  
  1281. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1282. % [??] init_gf:  C needs k to be 0..256 instead of 0..255.
  1283. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1284. @x
  1285. procedure init_gf;
  1286. var @!k:eight_bits; {runs through all possible character codes}
  1287. @y
  1288. procedure init_gf;
  1289. var @!k:0..256; {runs through all possible character codes}
  1290. @z
  1291.  
  1292. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1293. % [??] Fix signed/unsigned comparison problem in C.
  1294. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1295. @x
  1296. if prev_m-m_offset(cur_edges)+x_off>gf_max_m then
  1297.   gf_max_m:=prev_m-m_offset(cur_edges)+x_off
  1298. @y
  1299. if prev_m-toint(m_offset(cur_edges))+x_off>gf_max_m then
  1300.   gf_max_m:=prev_m-m_offset(cur_edges)+x_off
  1301. @z
  1302.  
  1303. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1304. % [??] Reading and writing of `base_file'.
  1305. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1306. @x
  1307. @d dump_wd(#)==begin base_file^:=#; put(base_file);@+end
  1308. @d dump_int(#)==begin base_file^.int:=#; put(base_file);@+end
  1309. @d dump_hh(#)==begin base_file^.hh:=#; put(base_file);@+end
  1310. @d dump_qqqq(#)==begin base_file^.qqqq:=#; put(base_file);@+end
  1311. @y
  1312. @z
  1313.  
  1314. @x
  1315. @d undump_wd(#)==begin get(base_file); #:=base_file^;@+end
  1316. @d undump_int(#)==begin get(base_file); #:=base_file^.int;@+end
  1317. @d undump_hh(#)==begin get(base_file); #:=base_file^.hh;@+end
  1318. @d undump_qqqq(#)==begin get(base_file); #:=base_file^.qqqq;@+end
  1319. @y
  1320. @z
  1321.  
  1322. @x
  1323. x:=base_file^.int;
  1324. @y
  1325. undump_int(x);
  1326. @z
  1327.  
  1328. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1329. % [??] `eof' here means `have we previously encountered the
  1330. % end-of-file', not `are we at the end of the file'.
  1331. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1332. @x
  1333. undump_int(x);@+if (x<>69069)or eof(base_file) then goto off_base
  1334. @y
  1335. undump_int(x);@+if (x<>69069)or feof(base_file) then goto off_base
  1336. @z
  1337.  
  1338. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1339. % [??] Eliminate possibly wrong word `preloaded' from base_idents.
  1340. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1341. @x
  1342. print(" (preloaded base="); print(job_name); print_char(" ");
  1343. @y
  1344. print(" (base="); print(job_name); print_char(" ");
  1345. @z
  1346.  
  1347. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1348. % [49.1197] `uexit' argument depends on `history', procedureize the main
  1349. % programs, and add call to set_paths.
  1350. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1351. @x
  1352. t_open_out; {open the terminal for output}
  1353. @y
  1354. t_open_out; {open the terminal for output}
  1355. set_paths (MF_BASE_PATH_BIT + MF_INPUT_PATH_BIT + MF_POOL_PATH_BIT);
  1356. @z
  1357.  
  1358. @x
  1359. end_of_MF: close_files_and_terminate;
  1360. final_end: ready_already:=0;
  1361. @y
  1362. close_files_and_terminate;
  1363. final_end: do_final_end;
  1364. @z
  1365.  
  1366. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1367. % [49.1198] Print new line before termination; switch to editor if
  1368. % necessary. 
  1369. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1370. @x
  1371.     slow_print(log_name); print_char(".");
  1372.     end;
  1373.   end;
  1374. @y
  1375.     slow_print(log_name); print_char(".");
  1376.     end;
  1377.   end;
  1378. print_ln;
  1379. if (edit_name_start<>0) and (interaction>batch_mode) then
  1380.     call_edit(str_pool,edit_name_start,edit_name_length,edit_line);
  1381. @z
  1382.  
  1383. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1384. % [51.1207,1208] Add editor-switch variable to globals.
  1385. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1386. @x
  1387. This section should be replaced, if necessary, by any special
  1388. modifications of the program
  1389. that are necessary to make \MF\ work at a particular installation.
  1390. It is usually best to design your change file so that all changes to
  1391. previous sections preserve the section numbering; then everybody's version
  1392. will be consistent with the published program. More extensive changes,
  1393. which introduce new sections, can be inserted here; then only the index
  1394. itself will get a new section number.
  1395. @^system dependencies@>
  1396. @y
  1397. Here are the variables used to hold ``switch-to-editor'' information.
  1398. @^system dependencies@>
  1399.  
  1400. @<Global...@>=
  1401. @!edit_name_start: pool_pointer;
  1402. @!edit_name_length,@!edit_line: integer;
  1403.  
  1404. @ The |edit_name_start| will be set to point into |str_pool| somewhere after
  1405. its beginning if \MF\ is supposed to switch to an editor on exit.
  1406.  
  1407. @<Set init...@>=
  1408. edit_name_start:=0;
  1409. @z
  1410.