% Change file for Metafont in C, derived from various other change % files. Originally derived from INITEX.CH for Berkeley Unix TeX 1.1 (by % Howard Trickey and Pavel Curtis), by Paul Richards. % web2c modifications by Tim Morgan, et al. % % Modification history: % % Revision 2.0 90/3/27 20:20:00 ken % To version 2.0. % Revision 1.9 90/1/20 09:05:32 karl % To version 1.9. % Revision 1.8 89/11/30 09:08:16 karl % To version 1.8 (8-bit). % Revision 1.7 88/12/27 15:02:24 mackay % Cosmetic upgrade for version 1.7 % Revision 1.6 88/12/11 15:59:15 morgan % Brought up to MF version 1.6 % Revision 1.5 88/03/02 13:25:44 morgan % More C changes % Revision 1.4 87/12/09 12:50:00 hesse % Changes for C version % Revision 1.3 87/03/07 21:15:21 mackay % Minor changes found on archive version on SCORE % Revision 1.2 86/09/29 21:46:43 mackay % Made no-debug the default, and changed version number % to correspond with improved mf.web file % (Got rid of debug code to avoid bug in range check % code of VAX4.3 BSD and SUN3 version 3.1 Os pc interpreter) % Revision 1.0 86/01/31 15:46:08 richards % Released for MF 1.0; % Incorporates: New binary I/O library, separate optimized % arithmetic for takefraction/makefraction, new graphics interface. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [0] WEAVE: only print changes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x \def\botofcontents{\vskip 0pt plus 1fil minus 1.5in} @y \def\botofcontents{\vskip 0pt plus 1fil minus 1.5in} \let\maybe=\iffalse \def\title{{\logo opqrstuq} changes for C} \def\glob{13}\def\gglob{20, 25} % these are defined in module 1 @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [1.2] banner line %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @d banner=='This is METAFONT, Version 2.0' {printed when \MF\ starts} @y @d banner=='This is METAFONT, C Version 2.0' {printed when \MF\ starts} @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [1.7] debug..gubed, stat..tats %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @d debug==@{ {change this to `$\\{debug}\equiv\null$' when debugging} @d gubed==@t@>@} {change this to `$\\{gubed}\equiv\null$' when debugging} @f debug==begin @f gubed==end @# @d stat==@{ {change this to `$\\{stat}\equiv\null$' when gathering usage statistics} @d tats==@t@>@} {change this to `$\\{tats}\equiv\null$' when gathering usage statistics} @y @d stat==ifdef('STAT') @d tats==endif('STAT') @d debug==ifdef('DEBUG') @d gubed==endif('DEBUG') @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [1.8] init..tini %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @d init== {change this to `$\\{init}\equiv\.{@@\{}$' in the production version} @d tini== {change this to `$\\{tini}\equiv\.{@@\}}$' in the production version} @y @d init==ifdef('INIMF') @d tini==endif('INIMF') @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Get rid of compiler directives %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @= @{@&$C-,A+,D-@} {no range check, catch arithmetic overflow, no debug overhead} @!debug @{@&$C+,D+@}@+ gubed {but turn everything on when debugging} @y @= @{No compiler directives for C.@} @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [1.11] Compile-time constants. Although we only change a few of % these, listing them all makes the patch file for a big Metafont simpler. % 16K for BSD I/O; file_name_size becomes FILENAMESIZE. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @= @!mem_max=30000; {greatest index in \MF's internal |mem| array; must be strictly less than |max_halfword|; must be equal to |mem_top| in \.{INIMF}, otherwise |>=mem_top|} @!max_internal=100; {maximum number of internal quantities} @!buf_size=500; {maximum number of characters simultaneously present in current lines of open files; must not exceed |max_halfword|} @!error_line=72; {width of context lines on terminal error messages} @!half_error_line=42; {width of first lines of contexts in terminal error messages; should be between 30 and |error_line-15|} @!max_print_line=79; {width of longest text lines output; should be at least 60} @!screen_width=768; {number of pixels in each row of screen display} @!screen_depth=1024; {number of pixels in each column of screen display} @!stack_size=30; {maximum number of simultaneous input sources} @!max_strings=2000; {maximum number of strings; must not exceed |max_halfword|} @!string_vacancies=8000; {the minimum number of characters that should be available for the user's identifier names and strings, after \MF's own error messages are stored} @!pool_size=32000; {maximum number of characters in strings, including all error messages and help texts, and the names of all identifiers; must exceed |string_vacancies| by the total length of \MF's own strings, which is currently about 22000} @!move_size=5000; {space for storing moves in a single octant} @!max_wiggle=300; {number of autorounded points per cycle} @!gf_buf_size=800; {size of the output buffer, must be a multiple of 8} @!file_name_size=40; {file names shouldn't be longer than this} @!pool_name='MFbases:MF.POOL '; {string of length |file_name_size|; tells where the string pool appears} @.MFbases@> @!path_size=300; {maximum number of knots between breakpoints of a path} @!bistack_size=785; {size of stack for bisection algorithms; should probably be left at this value} @!header_size=100; {maximum number of \.{TFM} header words, times~4} @!lig_table_size=5000; {maximum number of ligature/kern steps, must be at least 255 and at most 32510} @!max_kerns=500; {maximum number of distinct kern amounts} @!max_font_dimen=50; {maximum number of \&{fontdimen} parameters} @y @d file_name_size == FILENAMESIZE {Get value from \.{site.h}.} @= @!mem_max=262140; {greatest index in \MF's internal |mem| array; must be strictly less than |max_halfword|; must be equal to |mem_top| in \.{INIMF}, otherwise |>=mem_top|} @!max_internal=300; {maximum number of internal quantities} @!buf_size=3000; {maximum number of characters simultaneously present in current lines of open files; must not exceed |max_halfword|} @!error_line=79; {width of context lines on terminal error messages} @!half_error_line=50; {width of first lines of contexts in terminal error messages; should be between 30 and |error_line-15|} @!max_print_line=79; {width of longest text lines output; should be at least 60} @!screen_width=1664; {number of pixels in each row of screen display} @!screen_depth=1200; {number of pixels in each column of screen display} @!stack_size=300; {maximum number of simultaneous input sources} @!max_strings=7500; {maximum number of strings; must not exceed |max_halfword|} @!string_vacancies=74000; {the minimum number of characters that should be available for the user's identifier names and strings, after \MF's own error messages are stored} @!pool_size=100000; {maximum number of characters in strings, including all error messages and help texts, and the names of all identifiers; must exceed |string_vacancies| by the total length of \MF's own strings, which is currently about 22000} @!move_size=20000; {space for storing moves in a single octant} @!max_wiggle=1000; {number of autorounded points per cycle} @!gf_buf_size=16384; {size of the output buffer, must be a multiple of 8} @!pool_name='mf.pool'; {string of length |file_name_size|; tells where the string pool appears} @!path_size=1000; {maximum number of knots between breakpoints of a path} @!bistack_size=1500; {size of stack for bisection algorithms; should probably be left at this value} @!header_size=100; {maximum number of \.{TFM} header words, times~4} @!lig_table_size=15000; {maximum number of ligature/kern steps, must be at least 255 and at most 32510} @!max_kerns=2500; {maximum number of distinct kern amounts} @!max_font_dimen=50; {maximum number of \&{fontdimen} parameters} @!mem_top=262140; {largest index in the |mem| array dumped by \.{INIMF}; must be substantially larger than |mem_min| and not greater than |mem_max|} @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [1.12] Sensitive compile-time constants. mem_top is made into a % #define, so it is easier to change for the trip test. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @d mem_min=0 {smallest index in the |mem| array, must not be less than |min_halfword|} @d mem_top==30000 {largest index in the |mem| array dumped by \.{INIMF}; must be substantially larger than |mem_min| and not greater than |mem_max|} @d hash_size=2100 {maximum number of symbolic tokens, must be less than |max_halfword-3*param_size|} @d hash_prime=1777 {a prime number equal to about 85\pct! of |hash_size|} @d max_in_open=6 {maximum number of input files and error insertions that can be going on simultaneously} @d param_size=150 {maximum number of simultaneous macro parameters} @y @d mem_min=0 {smallest index in the |mem| array, must not be less than |min_halfword|} @d hash_size=9500 {maximum number of symbolic tokens, must be less than |max_halfword-3*param_size|} @d hash_prime=7919 {a prime number equal to about 85\pct! of |hash_size|} @d max_in_open=15 {maximum number of input files and error insertions that can be going on simultaneously} @d param_size=150 {maximum number of simultaneous macro parameters} @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [??] Use C macros for incr() and decr(). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @d incr(#) == #:=#+1 {increase a variable by unity} @d decr(#) == #:=#-1 {decrease a variable by unity} @y @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [??] The text_char type is used as an array index into xord. The % default type `char' produces signed integers, which are bad array % indices in C. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @d text_char == char {the data type of characters in text files} @y @d text_char == ASCII_code {the data type of characters in text files} @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [1.22] permissive input %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @^character set dependencies@> @^system dependencies@> @= for i:=0 to @'37 do xchr[i]:=' '; for i:=@'177 to @'377 do xchr[i]:=' '; @y @^character set dependencies@> @^system dependencies@> @d tab = @'11 { ASCII horizontal tab } @d form_feed = @'14 { ASCII form feed } @= for i:=0 to @'37 do xchr[i]:=chr(i); for i:=@'177 to @'377 do xchr[i]:=chr(i); @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [3.25] add real_name_of_file array for search path resolution %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x is crucial for our purposes. We shall assume that |name_of_file| is a variable of an appropriate type such that the \PASCAL\ run-time system being used to implement \MF\ can open a file whose external name is specified by |name_of_file|. @^system dependencies@> @= @!name_of_file:packed array[1..file_name_size] of char;@;@/ {on some systems this may be a \&{record} variable} @!name_length:0..file_name_size;@/{this many characters are actually relevant in |name_of_file| (the rest are blank)} @y is crucial for our purposes. We make |real_name_of_file| hold the |name_of_file| plus a directory specifier to open the file in {\mc UNIX}. @^system dependencies@> @= @!name_of_file,@!real_name_of_file:packed array[1..file_name_size] of char;@;@/ {on some systems this may be a \&{record} variable} @!name_length:0..file_name_size;@/{this many characters are actually relevant in |name_of_file| (the rest are blank)} @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [3.26] file opening %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @ The \ph\ compiler with which the present version of \MF\ was prepared has extended the rules of \PASCAL\ in a very convenient way. To open file~|f|, we can write $$\vbox{\halign{#\hfil\qquad&#\hfil\cr |reset(f,@t\\{name}@>,'/O')|&for input;\cr |rewrite(f,@t\\{name}@>,'/O')|&for output.\cr}}$$ The `\\{name}' parameter, which is of type `\ignorespaces|packed array[@t\<\\{any}>@>] of text_char|', stands for the name of the external file that is being opened for input or output. Blank spaces that might appear in \\{name} are ignored. The `\.{/O}' parameter tells the operating system not to issue its own error messages if something goes wrong. If a file of the specified name cannot be found, or if such a file cannot be opened for some other reason (e.g., someone may already be trying to write the same file), we will have |@!erstat(f)<>0| after an unsuccessful |reset| or |rewrite|. This allows \MF\ to undertake appropriate corrective action. @:PASCAL H}{\ph@> @^system dependencies@> \MF's file-opening procedures return |false| if no file identified by |name_of_file| could be opened. @d reset_OK(#)==erstat(#)=0 @d rewrite_OK(#)==erstat(#)=0 @p function a_open_in(var @!f:alpha_file):boolean; {open a text file for input} begin reset(f,name_of_file,'/O'); a_open_in:=reset_OK(f); end; @# function a_open_out(var @!f:alpha_file):boolean; {open a text file for output} begin rewrite(f,name_of_file,'/O'); a_open_out:=rewrite_OK(f); end; @# function b_open_out(var @!f:byte_file):boolean; {open a binary file for output} begin rewrite(f,name_of_file,'/O'); b_open_out:=rewrite_OK(f); end; @# function w_open_in(var @!f:word_file):boolean; {open a word file for input} begin reset(f,name_of_file,'/O'); w_open_in:=reset_OK(f); end; @# function w_open_out(var @!f:word_file):boolean; {open a word file for output} begin rewrite(f,name_of_file,'/O'); w_open_out:=rewrite_OK(f); end; @y @ The \ph\ compiler with which the present version of \MF\ was prepared has extended the rules of \PASCAL\ in a very convenient way for file opening. {\mc UNIX} \PASCAL\ isn't nearly as nice as \ph. Normally, it bombs out if a file open fails. An external C procedure, |test_access| is used to check whether or not the open will work, and it returns |true| or |false|. The |name_of_file| global holds the file name whose access is to be tested. The first parameter for |test_access| is the access mode, one of |read_access_mode| or |write_access_mode|. We also implement path searching in |test_access|: its second parameter is one of the ``file path'' constants defined below. If |name_of_file| doesn't start with |'/'| then |test_access| tries prepending pathnames from the appropriate path list until success or the end of path list is reached. On return, |real_name_of_file| contains the original name with the path that succeeded (if any) prepended. It is the name used in the various open procedures. Note that |a_open_in| has been redefined to take an additional argument, which should be one of the ``file path'' specifiers. Path searching is not done for output files. In the C version, |X_open_in|, |X_open_out|, |w_open_in|, and |w_open_out| are all completely replaced by C preprocessor macros. We retain the testaccess() routine since it was already written in C and it implements the path searching mechanism. @d read_access_mode=4 {``read'' mode for |test_access|} @d write_access_mode=2 {``write'' mode for |test_access|} @d no_file_path=0 {no path searching should be done} @d MF_input_file_path=6 {path specifier for \.{input} files} @d MF_base_file_path=7 {path specifier for base files} @d MF_pool_file_path=8 {path specifier for the pool file} @z @x @ Files can be closed with the \ph\ routine `|close(f)|', which @^system dependencies@> should be used when all input or output with respect to |f| has been completed. This makes |f| available to be opened again, if desired; and if |f| was used for output, the |close| operation makes the corresponding external file appear on the user's area, ready to be read. @p procedure a_close(var @!f:alpha_file); {close a text file} begin close(f); end; @# procedure b_close(var @!f:byte_file); {close a binary file} begin close(f); end; @# procedure w_close(var @!f:word_file); {close a word file} begin close(f); end; @y @ Files are closed in C via the macros |aclose|, |bclose|, and |wclose|. @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [3.30] We have our own input_ln, implemented in C. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x Standard \PASCAL\ says that a file should have |eoln| immediately before |eof|, but \MF\ needs only a weaker restriction: If |eof| occurs in the middle of a line, the system function |eoln| should return a |true| result (even though |f^| will be undefined). @p function input_ln(var @!f:alpha_file;@!bypass_eoln:boolean):boolean; {inputs the next line or returns |false|} var @!last_nonblank:0..buf_size; {|last| with trailing blanks removed} begin if bypass_eoln then if not eof(f) then get(f); {input the first character of the line into |f^|} last:=first; {cf.\ Matthew 19\thinspace:\thinspace30} if eof(f) then input_ln:=false else begin last_nonblank:=first; while not eoln(f) do begin if last>=max_buf_stack then begin max_buf_stack:=last+1; if max_buf_stack=buf_size then @; end; buffer[last]:=xord[f^]; get(f); incr(last); if buffer[last-1]<>" " then last_nonblank:=last; end; last:=last_nonblank; input_ln:=true; end; end; @y @ The |input_ln| function is defined in an external C routine. @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [??] term_in/term_out are stdin/stdout. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @= @!term_in:alpha_file; {the terminal as an input file} @!term_out:alpha_file; {the terminal as an output file} @y @d term_in==stdin {the terminal as an input file} @d term_out==stdout {the terminal as an output file} @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [3.32] We don't need to open the terminal files. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @ Here is how to open the terminal files in \ph. The `\.{/I}' switch suppresses the first |get|. @^system dependencies@> @d t_open_in==reset(term_in,'TTY:','/O/I') {open the terminal for text input} @d t_open_out==rewrite(term_out,'TTY:','/O') {open the terminal for text output} @y @ Here is how to open the terminal files. |t_open_out| does nothing. |t_open_in|, on the other hand, does the work of ``rescanning,'' or getting any command line arguments the user has provided. It's coded in C externally. @d t_open_out == {output already open for text output} @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [3.33] Flushing output. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x these operations can be specified in \ph: @^system dependencies@> @d update_terminal == break(term_out) {empty the terminal output buffer} @d clear_terminal == break_in(term_in,true) {clear the terminal input buffer} @d wake_up_terminal == do_nothing {cancel the user's cancellation of output} @y these operations can be specified in C: @^system dependencies@> @d update_terminal == flush(term_out) {empty the terminal output buffer} @d clear_terminal == flush(term_in) {clear the terminal input buffer} @d wake_up_terminal == do_nothing {cancel the user's cancellation of output} @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [3.36] rescanning the command line %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @ The following program does the required initialization without retrieving a possible command line. It should be clear how to modify this routine to deal with command lines, if the system permits them. @^system dependencies@> @p function init_terminal:boolean; {gets the terminal input started} label exit; begin t_open_in; loop@+begin wake_up_terminal; write(term_out,'**'); update_terminal; @.**@> if not input_ln(term_in,true) then {this shouldn't happen} begin write_ln(term_out); write(term_out,'! End of file on the terminal... why?'); @.End of file on the terminal@> init_terminal:=false; return; end; loc:=first; while (loc first|. @^system dependencies@> @p function init_terminal:boolean; {gets the terminal input started} label exit; begin t_open_in; if last > first then begin loc := first; while (loc < last) and (buffer[loc]=' ') do incr(loc); if loc < last then begin init_terminal := true; goto exit; end; end; loop@+begin wake_up_terminal; write(term_out, '**'); update_terminal; @.**@> if not input_ln(term_in,true) then begin {this shouldn't happen} write_ln(term_out); write(term_out, '! End of file on the terminal... why?'); @.End of file on the terminal@> init_terminal:=false; return; end; loc:=first; while (loc@$ then bad_pool('! MF.POOL doesn''t match; TANGLE me again.'); @y done: if a<>@$ then bad_pool('! mf.pool doesn''t match; tangle me again.'); @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [??] Eliminate the misleading message ``(no format preloaded)''. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x if base_ident=0 then wterm_ln(' (no base preloaded)') else begin print(base_ident); print_ln; end; @y if base_ident>0 then print(base_ident); print_ln; @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [??] Eliminate non-local goto. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x procedure that quietly terminates the program. @= procedure jump_out; begin goto end_of_MF; end; @y procedure that quietly terminates the program. Use the value of |history| to determine what exit code to use. @= procedure jump_out; begin close_files_and_terminate; ready_already:=0; if (history <> spotless) and (history <> warning_issued) then uexit(1) else uexit(0); end; @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [6.79] Handle the switch-to-editor option. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x line ready to be edited. But such an extension requires some system wizardry, so the present implementation simply types out the name of the file that should be edited and the relevant line number. @^system dependencies@> There is a secret `\.D' option available when the debugging routines haven't been commented~out. @^debugging@> @y line ready to be edited. We do this by calling the external procedure |calledit| with a pointer to the filename, its length, and the line number. However, here we just set up the variables that will be used as arguments, since we don't want to do the switch-to-editor until after TeX has closed its files. @^system dependencies@> There is a secret `\.D' option available when the debugging routines have not been commented out. @^debugging@> @d edit_file==input_stack[file_ptr] @z @x "E": if file_ptr>0 then begin print_nl("You want to edit file "); @.You want to edit file x@> print(input_stack[file_ptr].name_field); print(" at line "); print_int(line);@/ interaction:=scroll_mode; jump_out; @y "E": if file_ptr>0 then begin edit_name_start:=str_start[edit_file.name_field]; edit_name_length:=str_start[edit_file.name_field+1] - str_start[edit_file.name_field]; edit_line:=line; jump_out; @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [7.107,108] Replace make_fraction with an external routine. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @p function make_fraction(@!p,@!q:integer):fraction; var @!f:integer; {the fraction bits, with a leading 1 bit} @!n:integer; {the integer part of $\vert p/q\vert$} @!negative:boolean; {should the result be negated?} @!be_careful:integer; {disables certain compiler optimizations} begin if p>=0 then negative:=false else begin negate(p); negative:=true; end; if q<=0 then begin debug if q=0 then confusion("/");@;@+gubed@;@/ @:this can't happen /}{\quad \./@> negate(q); negative:=not negative; end; n:=p div q; p:=p mod q; if n>=8 then begin arith_error:=true; if negative then make_fraction:=-el_gordo@+else make_fraction:=el_gordo; end else begin n:=(n-1)*fraction_one; @; if negative then make_fraction:=-(f+n)@+else make_fraction:=f+n; end; end; @ The |repeat| loop here preserves the following invariant relations between |f|, |p|, and~|q|: (i)~|0<=p @= f:=1; repeat be_careful:=p-q; p:=be_careful+p; if p>=0 then f:=f+f+1 else begin double(f); p:=p+q; end; until f>=fraction_one; be_careful:=p-q; if be_careful+p>=0 then incr(f) @y We have replaced the \PASCAL\ version of |make_fraction| with either a C or assembly language equivalent for efficiency. @ This section was deleted when |make_fraction| was removed. @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [7.109,110,111] And ditto for take_fraction. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @p function take_fraction(@!q:integer;@!f:fraction):integer; var @!p:integer; {the fraction so far} @!negative:boolean; {should the result be negated?} @!n:integer; {additional multiple of $q$} @!be_careful:integer; {disables certain compiler optimizations} begin @=0| and |q>0|@>; if f; be_careful:=n-el_gordo; if be_careful+p>0 then begin arith_error:=true; n:=el_gordo-p; end; if negative then take_fraction:=-(n+p) else take_fraction:=n+p; end; @ @=0| and |q>0|@>= if f>=0 then negative:=false else begin negate(f); negative:=true; end; if q<0 then begin negate(q); negative:=not negative; end; @ The invariant relations in this case are (i)~$\lfloor(qf+p)/2^k\rfloor =\lfloor qf_0/2^{28}+{1\over2}\rfloor$, where $k$ is an integer and $f_0$ is the original value of~$f$; (ii)~$2^k\L f<2^{k+1}$. @^inner loop@> @= p:=fraction_half; {that's $2^{27}$; the invariants hold now with $k=28$} if q=0| and |q>0|@>= if f>=0 then negative:=false else begin negate(f); negative:=true; end; if q<0 then begin negate(q); negative:=not negative; end; @ This section was deleted when |take_fraction| was replaced by an external routine. @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [9.153] Make it easy to build a bigger Metafont. (Nothing is changed % in the basic version.) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @d min_quarterword=0 {smallest allowable value in a |quarterword|} @d max_quarterword=255 {largest allowable value in a |quarterword|} @d min_halfword==0 {smallest allowable value in a |halfword|} @d max_halfword==65535 {largest allowable value in a |halfword|} @y @d min_quarterword=0 {smallest allowable value in a |quarterword|} @d max_quarterword=511 {largest allowable value in a |quarterword|} @d min_halfword==0 {smallest allowable value in a |halfword|} @d max_halfword==262143 {largest allowable value in a |halfword|} @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [??] Efficiency in C. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @ The operation of subtracting |min_halfword| occurs rather frequently in \MF, so it is convenient to abbreviate this operation by using the macro |ho| defined here. \MF\ will run faster with respect to compilers that don't optimize the expression `|x-0|', if this macro is simplified in the obvious way when |min_halfword=0|. Similarly, |qi| and |qo| are used for input to and output from quarterwords. @^system dependencies@> @d ho(#)==#-min_halfword {to take a sixteen-bit item from a halfword} @d qo(#)==#-min_quarterword {to read eight bits from a quarterword} @d qi(#)==#+min_quarterword {to store eight bits in a quarterword} @y @ The operation of subtracting |min_halfword| occurs rather frequently in \MF, so it is convenient to abbreviate this operation by using the macro |ho| defined here. \MF\ will run faster with respect to compilers that don't optimize the expression `|x-0|', if this macro is simplified in the obvious way when |min_halfword=0|. Similarly, |qi| and |qo| are used for input to and output from quarterwords. We need not do this in C, since the min_xxx values are all zero, and we can't depend on most C compilers to optimize this. @^system dependencies@> @d ho(#)==# @d qo(#)==# @d qi(#)==# @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [??] Put the memory structure into an include file; it's too hard % to translate automatically. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @!two_halves = packed record@;@/ @!rh:halfword; case two_choices of 1: (@!lh:halfword); 2: (@!b0:quarterword; @!b1:quarterword); end; @!four_quarters = packed record@;@/ @!b0:quarterword; @!b1:quarterword; @!b2:quarterword; @!b3:quarterword; end; @!memory_word = record@;@/ case three_choices of 1: (@!int:integer); 2: (@!hh:two_halves); 3: (@!qqqq:four_quarters); end; @y @=#include "memory.h";@> @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [??] Fix an unsigned/signed problem in getnode. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x if r>p+1 then @; @y if r>toint(p+1) then @; @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [11.178] Change the word `free' so that it doesn't conflict with the % standard C library routine of the same name. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x been included. (You may want to decrease the size of |mem| while you @^debugging@> are debugging.) @y been included. (You may want to decrease the size of |mem| while you @^debugging@> are debugging.) @d free==free_arr @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [??] Eliminate two unsigned comparisons to zero. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x repeat if (p>=lo_mem_max)or(p=lo_mem_max)or(rlink(p)=lo_mem_max) then clobbered:=true else if (rlink(p)>=lo_mem_max) then clobbered:=true @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [12.194] fix_date_and_time %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @ The following procedure, which is called just before \MF\ initializes its input and output, establishes the initial values of the date and time. @^system dependencies@> Since standard \PASCAL\ cannot provide such information, something special is needed. The program here simply specifies July 4, 1776, at noon; but users probably want a better approximation to the truth. Note that the values are |scaled| integers. Hence \MF\ can no longer be used after the year 32767. @p procedure fix_date_and_time; begin internal[time]:=12*60*unity; {minutes since midnight} internal[day]:=4*unity; {fourth day of the month} internal[month]:=7*unity; {seventh month of the year} internal[year]:=1776*unity; {Anno Domini} end; @y @ The following procedure, which is called just before \MF\ initializes its input and output, establishes the initial values of the date and time. It is calls an externally defined |date_and_time|, even though it could be done from Pascal. The external procedure also sets up interrupt catching. @^system dependencies@> Note that the values are |scaled| integers. Hence \MF\ can no longer be used after the year 32767. @p procedure fix_date_and_time; begin date_and_time(internal[time],internal[day],internal[month],internal[year]); internal[time] := internal[time] * unity; internal[day] := internal[day] * unity; internal[month] := internal[month] * unity; internal[year] := internal[year] * unity; end; @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [12.199] Allow and
as input. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x for k:=0 to " "-1 do char_class[k]:=invalid_class; for k:=127 to 255 do char_class[k]:=invalid_class; @y for k:=0 to " "-1 do char_class[k]:=invalid_class; for k:=127 to 255 do char_class[k]:=invalid_class; char_class[tab]:=space_class; char_class[form_feed]:=space_class; @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [27.564] The window functions are defined externally, in C. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @p function init_screen:boolean; begin init_screen:=false; end; @# procedure update_screen; {will be called only if |init_screen| returns |true|} begin @!init wlog_ln('Calling UPDATESCREEN');@+tini {for testing only} end; @y {These functions/procedures are defined externally in C.} @z @x @p procedure blank_rectangle(@!left_col,@!right_col:screen_col; @!top_row,@!bot_row:screen_row); var @!r:screen_row; @!c:screen_col; begin @{@+for r:=top_row to bot_row-1 do for c:=left_col to right_col-1 do screen_pixel[r,c]:=white;@+@}@/ @!init wlog_cr; {this will be done only after |init_screen=true|} wlog_ln('Calling BLANKRECTANGLE(',left_col:1,',', right_col:1,',',top_row:1,',',bot_row:1,')');@+tini end; @y {Same thing} @z @x @p procedure paint_row(@!r:screen_row;@!b:pixel_color;var @!a:trans_spec; @!n:screen_col); var @!k:screen_col; {an index into |a|} @!c:screen_col; {an index into |screen_pixel|} begin @{ k:=0; c:=a[0]; repeat incr(k); repeat screen_pixel[r,c]:=b; incr(c); until c=a[k]; b:=black-b; {$|black|\swap|white|$} until k=n;@+@}@/ @!init wlog('Calling PAINTROW(',r:1,',',b:1,';'); {this is done only after |init_screen=true|} for k:=0 to n do begin wlog(a[k]:1); if k<>n then wlog(','); end; wlog_ln(')');@+tini end; @y {Same thing} @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [38.765] Area and extension rules. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @ The file names we shall deal with for illustrative purposes have the following structure: If the name contains `\.>' or `\.:', the file area consists of all characters up to and including the final such character; otherwise the file area is null. If the remaining file name contains `\..', the file extension consists of all such characters from the first remaining `\..' to the end, otherwise the file extension is null. @^system dependencies@> We can scan such file names easily by using two global variables that keep track of the occurrences of area and extension delimiters: @= @!area_delimiter:pool_pointer; {the most recent `\.>' or `\.:', if any} @!ext_delimiter:pool_pointer; {the relevant `\..', if any} @y @ The file names we shall deal with for illustrative purposes have the following structure: If the name contains `\./', the file area consists of all characters up to and including the final such character; otherwise the file area is null. If the remaining file name contains `\..', the file extension consists of all such characters from the first remaining `\..' to the end, otherwise the file extension is null. @^system dependencies@> We can scan such file names easily by using two global variables that keep track of the occurrences of area and extension delimiters: @= @!area_delimiter:pool_pointer; {the most recent `\./', if any} @!ext_delimiter:pool_pointer; {the most recent `\..', if any} @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [38.766] MF area directories don't exist. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @d MF_area=="MFinputs:" @.MFinputs@> @y In C, the default paths are specified in a separate file, \.{site.h}. The file opening procedures do path searching based either on those default paths, or on paths given by the user in environment variables. @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [38.768] more_name %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x begin if c=" " then more_name:=false else begin if (c=">")or(c=":") then @y begin if (c=" ")or(c=tab) then more_name:=false else begin if (c="/") then @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [38.772] The default base. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @d base_default_length=18 {length of the |MF_base_default| string} @d base_area_length=8 {length of its area part} @d base_ext_length=5 {length of its `\.{.base}' part} @y In C, we don't give the area part, instead depending on the path searching that will happen during file opening. @d base_default_length=10 {length of the |MF_base_default| string} @d base_area_length=0 {length of its area part} @d base_ext_length=5 {length of its `\.{.base}' part} @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [38.773] Location of plain.base. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x MF_base_default:='MFbases:plain.base'; @y MF_base_default:='plain.base'; @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [38.776] w_open_in of base file needs to be called only once %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x pack_buffered_name(0,loc,j-1); {try first without the system file area} if w_open_in(base_file) then goto found; pack_buffered_name(base_area_length,loc,j-1); {now try the system base file area} if w_open_in(base_file) then goto found; @y pack_buffered_name(0,loc,j-1); if w_open_in(base_file) then goto found; @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % (still [29.524]) Replace `PLAIN' in error messages with `default'. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x wterm_ln('Sorry, I can''t find that base;',' will try PLAIN.'); @y wterm_ln('Sorry, I can''t find that base;',' will try the default.'); @z @x wterm_ln('I can''t find the PLAIN base file!'); @.I can't find PLAIN...@> @y wterm_ln('I can''t find the default base file!'); @.I can't find default base...@> @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [38.777] make_name_string %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x which simply makes a \MF\ string from the value of |name_of_file|, should ideally be changed to deduce the full name of file~|f|, which is the file most recently opened, if it is possible to do this in a \PASCAL\ program. @^system dependencies@> This routine might be called after string memory has overflowed, hence we dare not use `|str_room|'. @p function make_name_string:str_number; var @!k:1..file_name_size; {index into |name_of_file|} begin if (pool_ptr+name_length>pool_size)or(str_ptr=max_strings) then make_name_string:="?" else begin for k:=1 to name_length do append_char(xord[name_of_file[k]]); make_name_string:=make_string; end; end; @y which simply makes a \MF\ string from the value of |name_of_file|, should ideally be changed to deduce the full name of file~|f|, which is the file most recently opened, if it is possible to do this in a \PASCAL\ program. With the C version, we know that |real_name_of_file| contains |name_of_file| prepended with the directory name that was found by path searching. If |real_name_of_file| starts with |'./'|, we don't use that part of the name, since {\mc UNIX} users understand that. @^system dependencies@> This routine might be called after string memory has overflowed, hence we dare not use `|str_room|'. @p function make_name_string:str_number; var @!k,@!kstart:1..file_name_size; {index into |name_of_file|} begin k:=1; while (k" ") do incr(k); name_length:=k-1; {the real |name_length|} if (pool_ptr+name_length>pool_size)or(str_ptr=max_strings) then make_name_string:="?" else begin if (xord[real_name_of_file[1]]=".") and (xord[real_name_of_file[2]]="/") then kstart:=3 else kstart:=1; for k:=kstart to name_length do append_char(xord[real_name_of_file[k]]); make_name_string:=make_string; end; end; @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [38.780] Change the make_name_strings to be C macros. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x function a_make_name_string(var @!f:alpha_file):str_number; begin a_make_name_string:=make_name_string; end; function b_make_name_string(var @!f:byte_file):str_number; begin b_make_name_string:=make_name_string; end; function w_make_name_string(var @!f:word_file):str_number; begin w_make_name_string:=make_name_string; end; @y {These are all replaced by macros in C which call |makenamestring|.} @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [38.778] Make scan_file_name ignore leading tabs as well as spaces. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @p procedure scan_file_name; label done; begin begin_name; while buffer[loc]=" " do incr(loc); @y @p procedure scan_file_name; label done; begin begin_name; while (buffer[loc]=" ")or(buffer[loc]=tab) do incr(loc); @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [38.783] needs similar leading tab treatment %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @ @= begin begin_name; k:=first; while (buffer[k]=" ")and(k= begin begin_name; k:=first; while ((buffer[k]=" ")or(buffer[k]=tab))and(km do d:=perturbation; threshold:=d; @y @p function threshold_fn(@!m:integer):scaled; var @!d:scaled; {lower bound on the smallest interval size} begin excess:=min_cover(0)-m; if excess<=0 then threshold_fn:=0 else begin repeat d:=perturbation; until min_cover(d+d)<=m; while min_cover(d)>m do d:=perturbation; threshold_fn:=d; @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [??] Change the call to the threshold function. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x begin d:=threshold(m); perturbation:=0; @y begin d:=threshold_fn(m); perturbation:=0; @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [45.1128] Writing the tfm file. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @d tfm_out(#)==write(tfm_file,#) {output one byte to |tfm_file|} @p procedure tfm_two(@!x:integer); {output two bytes to |tfm_file|} begin tfm_out(x div 256); tfm_out(x mod 256); end; @# procedure tfm_four(@!x:integer); {output four bytes to |tfm_file|} begin if x>=0 then tfm_out(x div three_bytes) else begin x:=x+@'10000000000; {use two's complement for negative values} x:=x+@'10000000000; tfm_out((x div three_bytes) + 128); end; x:=x mod three_bytes; tfm_out(x div unity); x:=x mod unity; tfm_out(x div @'400); tfm_out(x mod @'400); end; @# procedure tfm_qqqq(@!x:four_quarters); {output four quarterwords to |tfm_file|} begin tfm_out(qo(x.b0)); tfm_out(qo(x.b1)); tfm_out(qo(x.b2)); tfm_out(qo(x.b3)); end; @y Under {\mc UNIX}, we are using the binary input and output routines. Hence, we redefine all the {\mc TFM} input and output in terms of those routines. @d tfm_out(#) == b_write_byte(tfm_file, #) @d tfm_two(#) == b_write_2_bytes(tfm_file, #) @d tfm_four(#) == b_write_4_bytes(tfm_file, #) @p procedure tfm_qqqq(@!x:four_quarters); {output four quarterwords to |tfm_file|} begin tfm_out(qo(x.b0)); tfm_out(qo(x.b1)); tfm_out(qo(x.b2)); tfm_out(qo(x.b3)); end; @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [45.1134] Add file name to b_open_out call in . %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x pack_job_name(".tfm"); while not b_open_out(tfm_file) do @y pack_job_name(".tfm"); while not b_open_out(tfm_file, name_of_file) do @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [47.1148] write_gf %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @= procedure write_gf(@!a,@!b:gf_index); var k:gf_index; begin for k:=a to b do write(gf_file,gf_buf[k]); end; @y For C, this is going to be handled by a macro |b_write_buf|, which will do the output using |fwrite| or |write|. @d write_gf(#) == b_write_buf(gf_file, gf_buf, #) @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [??] init_gf: C needs k to be 0..256 instead of 0..255. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x procedure init_gf; var @!k:eight_bits; {runs through all possible character codes} @y procedure init_gf; var @!k:0..256; {runs through all possible character codes} @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [??] Fix signed/unsigned comparison problem in C. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x if prev_m-m_offset(cur_edges)+x_off>gf_max_m then gf_max_m:=prev_m-m_offset(cur_edges)+x_off @y if prev_m-toint(m_offset(cur_edges))+x_off>gf_max_m then gf_max_m:=prev_m-m_offset(cur_edges)+x_off @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [??] Leave the dump and undump macros for the preprocessor. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @d dump_wd(#)==begin base_file^:=#; put(base_file);@+end @d dump_int(#)==begin base_file^.int:=#; put(base_file);@+end @d dump_hh(#)==begin base_file^.hh:=#; put(base_file);@+end @d dump_qqqq(#)==begin base_file^.qqqq:=#; put(base_file);@+end @y @z @x @d undump_wd(#)==begin get(base_file); #:=base_file^;@+end @d undump_int(#)==begin get(base_file); #:=base_file^.int;@+end @d undump_hh(#)==begin get(base_file); #:=base_file^.hh;@+end @d undump_qqqq(#)==begin get(base_file); #:=base_file^.qqqq;@+end @y @z @x x:=base_file^.int; @y undump_int(x); @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [??] Eliminate possibly wrong word `preloaded' from base_idents. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x print(" (preloaded base="); print(job_name); print_char(" "); @y print(" (base="); print(job_name); print_char(" "); @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [49.1197] Add call to exit() depending upon value of `history'. % Also, add call to set_paths. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x t_open_out; {open the terminal for output} @y t_open_out; {open the terminal for output} set_paths; @z @x end_of_MF: close_files_and_terminate; final_end: ready_already:=0; @y close_files_and_terminate; final_end: ready_already:=0; if (history <> spotless) and (history <> warning_issued) then uexit(1) else uexit(0); @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [49.1198] print new line before termination; switch to editor if necessary. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x print(log_name); print_char("."); end; end; @y print(log_name); print_char("."); end; end; print_ln; if (edit_name_start<>0) and (interaction>batch_mode) then calledit(str_pool,edit_name_start,edit_name_length,edit_line); @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [51.1207,1208] Add editor-switch variable to globals. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x This section should be replaced, if necessary, by any special modifications of the program that are necessary to make \MF\ work at a particular installation. It is usually best to design your change file so that all changes to previous sections preserve the section numbering; then everybody's version will be consistent with the published program. More extensive changes, which introduce new sections, can be inserted here; then only the index itself will get a new section number. @^system dependencies@> @y Here are the variables used to hold ``switch-to-editor'' information. @^system dependencies@> @= @!edit_name_start: pool_pointer; @!edit_name_length,@!edit_line: integer; @ The |edit_name_start| will be set to point into |str_pool| somewhere after its beginning if \MF\ is supposed to switch to an editor on exit. @= edit_name_start:=0; @z