% This is etex_vms.ch, a WEB change file produced by webmerge.tex % to be applied to [--.knuth]tex.web % combining the changes (one after the other) from % 1. [-.web]etex.ch % 2. tex_vms.ch % 3. etex_vms.ech @x l.1 % This program is copyright (C) 1982 by D. E. Knuth; all rights are reserved. % Copying of this file is authorized only if (1) you are D. E. Knuth, or if % (2) you make absolutely no changes to your copy. (The WEB system provides % for alterations via an auxiliary file; the master file should stay intact.) % See Appendix H of the WEB manual for hints on how to install this program. % And see Appendix A of the TRIP manual for details about how to validate it. % TeX is a trademark of the American Mathematical Society. % METAFONT is a trademark of Addison-Wesley Publishing Company. @y % e-TeX is copyright (C) 1994,98 by the NTS team; all rights are reserved. % Copying of this file is authorized only if (1) you are a member of the % NTS team, or if (2) you make absolutely no changes to your copy. % (Programs such as PATCHWEB, TIE, or WEBMERGE allow the application of % several change files to tex.web; the master files tex.web and etex.ch % should stay intact.) % See etex_gen.tex for hints on how to install this program. % And see etripman.tex for details about how to validate it. % e-TeX and NTS are trademarks of the NTS group. % TeX is a trademark of the American Mathematical Society. % METAFONT is a trademark of Addison-Wesley Publishing Company. % This program is directly derived from Donald E. Knuth's TeX; % the change history which follows and the reward offered for finders of % bugs refer specifically to TeX; they should not be taken as referring % to e-TeX, although the change history is relevant in that it % demonstrates the evolutionary path followed. This program is not TeX; % that name is reserved strictly for the program which is the creation % and sole responsibility of Professor Knuth. @z @x l.50 % Although considerable effort has been expended to make the TeX program % correct and reliable, no warranty is implied; the author disclaims any % obligation or liability for damages, including but not limited to % special, indirect, or consequential damages arising out of or in % connection with the use or performance of this software. This work has % been a ``labor of love'' and the author hopes that users enjoy it. @y % A preliminary version of TeX--XeT was released in April 1992. % TeX--XeT version 1.0 was released in June 1992, % version 1.1 prevented arith overflow in glue computation (Oct 1992). % A preliminary e-TeX version 0.95 was operational in March 1994. % Version 1.0beta was released in May 1995. % Version 1.01beta fixed bugs in just_copy and every_eof (December 1995). % Version 1.02beta allowed 256 mark classes (March 1996). % Version 1.1 changed \group{type,level} -> \currentgroup{type,level}, % first public release (October 1996). % Version 2.0 development was started in March 1997; % fixed a ligature-\beginR bug in January 1998; % was released in March 1998. % Although considerable effort has been expended to make the e-TeX program % correct and reliable, no warranty is implied; the authors disclaim any % obligation or liability for damages, including but not limited to % special, indirect, or consequential damages arising out of or in % connection with the use or performance of this software. This work has % been a ``labor of love'' and the authors hope that users enjoy it. @z @x l.61 \let\mc=\ninerm % medium caps for names like SAIL @y \let\mc=\ninerm % medium caps for names like SAIL \def\eTeX{$\varepsilon$-\TeX} \font\revrm=xbmc10 % for right-to-left text % to generate xbmc10 (i.e., reflected cmbx10) use a file % xbmc10.mf containing: %+++++++++++++++++++++++++++++++++++++++++++++++++ % if unknown cmbase: input cmbase fi % extra_endchar := extra_endchar & % "currentpicture:=currentpicture " & % "reflectedabout((.5[l,r],0),(.5[l,r],1));"; % input cmbx10 %+++++++++++++++++++++++++++++++++++++++++++++++++ \ifx\beginL\undefined % this is TeX \def\XeT{X\kern-.125em\lower.5ex\hbox{E}\kern-.1667emT} \def\TeXeT{\TeX-\hbox{\revrm \XeT}} % for TeX-XeT \def\TeXXeT{\TeX-\hbox{\revrm -\XeT}} % for TeX--XeT \else \ifx\eTeXversion\undefined % this is \TeXeT \def\TeXeT{\TeX-{\revrm\beginR\TeX\endR}} % for TeX-XeT \def\TeXXeT{\TeX-{\revrm\beginR\TeX-\endR}} % for TeX--XeT \else % this is \eTeX \def\TeXeT{\TeX-{\TeXXeTstate=1\revrm\beginR\TeX\endR}} % for TeX-XeT \def\TeXXeT{\TeX-{\TeXXeTstate=1\revrm\beginR\TeX-\endR}} % for TeX--XeT \fi \fi @z @x l.64 \def\pct!{{\char`\%}} % percent sign in ordinary text @y \def\pct!{{\char`\%}} % percent sign in ordinary text \def\grp{\.{\char'173...\char'175}} @z @x l.80 \def\title{\TeX82} @y \def\title{\eTeX} % system dependent redefinitions of \title should come later % and should use: % \toks0=\expandafter{\title} % \edef\title{...\the\toks0...} \let\maybe=\iffalse % print only changed modules @z @x l.86 \pageno=3 @y \pageno=3 \let\maybe=\iffalse %%% PT 8-DEC-1997 17:49:48 \toks0=\expandafter{\title} \maybe \edef\title{\the\toks0\ 3.14159 [PD VMS 3.6]} \else \edef\title{\the\toks0\ 3.14159 [PD VMS 3.6] changes} \fi \def\LaTeX{{\rm L\kern-.3em\raise.33ex\hbox{\sc A}\kern-.15em\TeX}} @z @x l.91 This is \TeX, a document compiler intended to produce typesetting of high @y This is \eTeX, a program derived from and extending the capabilities of \TeX, a document compiler intended to produce typesetting of high @z @x l.179 If this program is changed, the resulting system should not be called @y This program contains code for various features extending \TeX, therefore this program is called `\eTeX' and not @z @x l.185 November 1984]. @y November 1984]. A similar test suite called the ``\.{e-TRIP} test'' is available for helping to determine whether a particular implementation deserves to be known as `\eTeX'. @z @x l.187 @d banner=='This is TeX, Version 3.14159' {printed when \TeX\ starts} @y This change file is the result of a long odyssey of change files beginning with the original change files created in 1984 by David Fuchs; many people have made significant contributions since then, the most notable of whom have been Brian Hamilton Kelly, Niel Kempson, and Adrian Clark @d banner=='This is TeX, Version 3.14159 [PD VMS 3.6]' @# @d eTeX_version_string=='3.14159-2.0' {current \eTeX\ version} @d eTeX_version=2 { \.{\\eTeXversion} } @d eTeX_revision==".0" { \.{\\eTeXrevision} } @# @d eTeX_banner=='This is e-TeX, Version ', eTeX_version_string, ';fMar06 [PD VMS 3.6f]' {printed when \eTeX\ starts} @# @d TEX==ETEX {change program name into |ETEX|} @# @d TeXXeT_code=0 {the \TeXXeT\ feature is optional} @# @d eTeX_states=1 {number of \eTeX\ state variables in |eqtb|} @z @x l.249 procedure initialize; {this procedure gets things started properly} @y @t\4@>@@/ procedure initialize; {this procedure gets things started properly} @z @x l.292 @d debug==@{ {change this to `$\\{debug}\equiv\null$' when debugging} @d gubed==@t@>@} {change this to `$\\{gubed}\equiv\null$' when debugging} @y @d debug==@{ @d gubed==@t\2@>@} @z @x l.297 @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== @d tats==@t\2@> @z @x l.310 the codewords `$|init|\ldots|tini|$'. @d init== {change this to `$\\{init}\equiv\.{@@\{}$' in the production version} @d tini== {change this to `$\\{tini}\equiv\.{@@\}}$' in the production version} @y the codewords `$|init|\ldots|tini|$' for declarations and by the codewords `$|Init|\ldots|Tini|$' for executable code. This distinction is helpful for implementations where a run-time switch differentiates between the two versions of the program. @d init== @d tini== @d Init==init if init_flag then begin @d Tini==end;@+tini @f Init==begin @f Tini==end @z @x l.319 @!init @@;@+tini @y @!Init @@;@+Tini @z @x l.321 @ If the first character of a \PASCAL\ comment is a dollar sign, \ph\ treats the comment as a list of ``compiler directives'' that will affect the translation of this program into machine language. The directives shown below specify full checking and inclusion of the \PASCAL\ debugger when \TeX\ is being debugged, but they cause range checking and other redundant code to be eliminated when the production system is being generated. Arithmetic overflow will be detected in all cases. @^system dependencies@> @^Overflow in arithmetic@> @= @{@&$C-,A+,D-@} {no range check, catch arithmetic overflow, no debug overhead} @!debug @{@&$C+,D+@}@+ gubed {but turn everything on when debugging} @y @ When the \PASCAL\ program generated as a result of `tangling' the \.{WEB} with the change file is compiled under VMS, command line qualifiers should be included to specify full checking and inclusion of debugger symbol records whilst \TeX\ is being debugged, but eliminate range checking and other redundant code when the production system is being generated. Arithmetic overflow should be detected in all cases. @^system dependencies@> @^Overflow in arithmetic@> Under VMS, we arrange to `inherit' the descriptions of standard system services and named constants from the precompiled \PASCAL\ environment held in |'SYS$LIBRARY:STARLET.PEN'|---we do \&{not} specify whether or not any specific level of run-time checks shall be included, because any such attribute applied within the source code cannot be overridden by a command line qualifier when \TeX\ is compiled. This library does not include \&{all} the library routines that are used by \TeX82 under VMS, so other routines are declared as required using \PASCAL's syntax for |extern| routines. @f extern==forward @= @/@=[inherit('sys$library:starlet')]@>@\ {allows us to use system symbols and routines} @z @x l.364 @d othercases == others: {default for cases not listed explicitly} @y Fortunately for us, VAX-\PASCAL\ \&{does} support this default mechanism. @d othercases == otherwise {default for cases not listed explicitly} @z @x l.373 @^system dependencies@> @= @!mem_max=30000; {greatest index in \TeX's internal |mem| array; must be strictly less than |max_halfword|; must be equal to |mem_top| in \.{INITEX}, otherwise |>=mem_top|} @!mem_min=0; {smallest index in \TeX's internal |mem| array; must be |min_halfword| or more; must be equal to |mem_bot| in \.{INITEX}, otherwise |<=mem_bot|} @!buf_size=500; {maximum number of characters simultaneously present in current lines of open files and in control sequences between \.{\\csname} and \.{\\endcsname}; 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} @!stack_size=200; {maximum number of simultaneous input sources} @!max_in_open=6; {maximum number of input files and error insertions that can be going on simultaneously} @!font_max=75; {maximum internal font number; must not exceed |max_quarterword| and must be at most |font_base+256|} @!font_mem_size=20000; {number of words of |font_info| for all fonts} @!param_size=60; {maximum number of simultaneous macro parameters} @!nest_size=40; {maximum number of semantic levels simultaneously active} @!max_strings=3000; {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 control sequences and font names, after \TeX'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 fonts and control sequences; must exceed |string_vacancies| by the total length of \TeX's own strings, which is currently about 23000} @!save_size=600; {space for saving values outside of current group; must be at most |max_halfword|} @!trie_size=8000; {space for hyphenation patterns; should be larger for \.{INITEX} than it is in production versions of \TeX} @!trie_op_size=500; {space for ``opcodes'' in the hyphenation patterns} @!dvi_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='TeXformats:TEX.POOL '; {string of length |file_name_size|; tells where the string pool appears} @y Since a number of arrays of |file_name_size| are used in this program to receive the full file specification of files when they are opened, it is necessary to extend this constant to 255, which is the maximum possible size that VAX/RMS can @.RMS@> @^Record Management Services@> return. It is not necessary, however, to pad out |pool_name| to this size (which would in any case prove ``difficult'' in WEB, because VAX-\PASCAL\ automatically pads short strings with spaces when assigned into longer variables. Furthermore, because the area where the pool file resides is specified at run time, we need to make |pool_name| into a variable which will be set shortly after we determine the value of the name of the format area. Here, we define the constant |pool_f_name| instead, which holds the name of the pool file without any area specification. @^system dependencies@> @= @!mem_max=327144; {greatest index in \TeX's internal |mem| array; must be strictly less than |max_halfword|; must be equal to |mem_top| in \.{INITEX}, otherwise |>=mem_top|} @!mem_min=0; {smallest index in \TeX's internal |mem| array; must be |min_halfword| or more; must be equal to |mem_bot| in \.{INITEX}, otherwise |<=mem_bot|} @!buf_size=2048; {maximum number of characters simultaneously present in current lines of open files and in control sequences between \.{\\csname} and \.{\\endcsname}; must not exceed |max_halfword|} @!size_input_line=133; {maximum size of an input line} @!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} @!stack_size=200; {maximum number of simultaneous input sources} @!max_in_open=12; {maximum number of input files and error insertions that can be going on simultaneously} @!font_max=255; {maximum internal font number; must not exceed |max_quarterword| and must be at most |font_base+256|} @!font_mem_size=81920; {number of words of |font_info| for all fonts} @!param_size=60; {maximum number of simultaneous macro parameters} @!nest_size=40; {maximum number of semantic levels simultaneously active} @!max_strings=15400; {maximum number of strings; must not exceed |max_halfword|} @!string_vacancies=160000; {the minimum number of characters that should be available for the user's control sequences and font names, after \TeX's own error messages are stored} @!pool_size=186000; {maximum number of characters in strings, including all error messages and help texts, and the names of all fonts and control sequences; must exceed |string_vacancies| by the total length of \TeX's own strings, which is currently about 23800 for VMS \TeX\ and 24550 for VMS \eTeX} @!save_size=2000; {space for saving values outside of current group; must be at most |max_halfword|} @!trie_size=45000; {space for hyphenation patterns; should be larger for \.{INITEX} than it is in production versions of \TeX} @# @!trie_op_size=1000; {space for ``opcodes'' in the hyphenation patterns} @!dvi_buf_size=1024; {size of the output buffer; must be a multiple of 8} @!VAX_block_length=512; {must be half |dvi_buf_size| on VMS} @!file_name_size=255; {file names shouldn't be longer than this} @# @!pool_f_name='ETEX.POOL'; {string \&{not} of length |file_name_size|; tells the name of the string pool} @z @x l.427 @d mem_bot=0 {smallest index in the |mem| array dumped by \.{INITEX}; must not be less than |mem_min|} @d mem_top==30000 {largest index in the |mem| array dumped by \.{INITEX}; must be substantially larger than |mem_bot| and not greater than |mem_max|} @d font_base=0 {smallest internal font number; must not be less than |min_quarterword|} @d hash_size=2100 {maximum number of control sequences; it should be at most about |(mem_max-mem_min)/10|} @d hash_prime=1777 {a prime number equal to about 85\pct! of |hash_size|} @d hyph_size=307 {another prime; the number of \.{\\hyphenation} exceptions} @y @d mem_bot=0 {smallest index in the |mem| array dumped by \.{INITEX}; must not be less than |mem_min|} @d mem_top==327144 {largest index in the |mem| array dumped by \.{INITEX}; must be substantially larger than |mem_bot| and not greater than |mem_max|} @d font_base=0 {smallest internal font number; must not be less than |min_quarterword|} @d hash_size=10000 {maximum number of control sequences; it should be at most about |(mem_max-mem_min)/10|} @d hash_prime=8501 {a prime number equal to about 85\pct! of |hash_size|} @d hyph_size=503 {another prime; the number of \.{\\hyphenation} exceptions} @z @x l.493 @d not_found=45 {go here when you've found nothing} @y @d not_found=45 {go here when you've found nothing} @d not_found1=46 {like |not_found|, when there's more than one} @d not_found2=47 {like |not_found|, when there's more than two} @d not_found3=48 {like |not_found|, when there's more than three} @d not_found4=49 {like |not_found|, when there's more than four} @z @x l.719 @^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@> The code shown here is intended to be used on VMS systems, and at other installations where only the printable ASCII set, plus |carriage_return|, |tab|, and |form_feed| will show up in text files. All |line_feed| and |null| characters are skipped. We also permit characters taken from columns 10--15 of the extended ISO character set; macro packages can then utilize these character codes for multilingual support. @d form_feed=@'14 {ASCII code used at end of a page} @d tab=@'11 @= xchr[0]:=' '; for i:=1 to @'37 do xchr[i]:=chr(i); xchr[form_feed]:=chr(form_feed); xchr[tab]:=chr(tab); for i:=@'177 to @'237 do xchr[i]:=' '; for i:=@'240 to @'377 do xchr[i]:=chr(i); @z @x l.766 The program actually makes use also of a third kind of file, called a |word_file|, when dumping and reloading base information for its own initialization. We shall define a word file later; but it will be possible for us to specify simple operations on word files before they are defined. @y The program actually makes use also of a third kind of file, called a |word_file|, when dumping and reloading base information for its own initialization. We shall define a word file later; but it will be possible for us to specify simple operations on word files before they are defined. Since the \.{WEB} already uses the name |text| for its own purposes, we have to define a macro to permit access to this VAX-\PASCAL\ file type identifier. @d VAX_text==@= text @> @z @x l.773 @!alpha_file=packed file of text_char; {files that contain textual data} @!byte_file=packed file of eight_bits; {files that contain binary data} @y @!alpha_file=VAX_text; {files that contain textual data} @!byte_block=packed array[0..VAX_block_length-1] of eight_bits; @!byte_file=packed file of byte_block; {files that contain binary data} @z @x l.784 implement \TeX\ 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 implement \TeX\ can open a file whose external name is specified by |name_of_file|. Any VAX-\PASCAL\ defaults may be supplied in |default_name|; this is used to expand partial file specifications given on such qualifiers as \.{/LOG}, in combination with other parts taken from the file specification of the \.{.TeX} file. @^system dependencies@> @= @!name_of_file, @!default_name:packed array[1..file_name_size] of char;@;@/ {on some systems this may be a \&{record} variable} @!name_length, @!deflt_length : file_size;@/ {this many characters are actually relevant in |name_of_file| (the rest are blank)} @z @x l.794 @ The \ph\ compiler with which the present version of \TeX\ 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 `{\bf packed array $[\langle\\{any}\rangle]$ of \\{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 \TeX\ to undertake appropriate corrective action. @:PASCAL H}{\ph@> @^system dependencies@> \TeX'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; @y @ Under VAX-\PASCAL, we can open files with names that are not known at compile time through use of the VAX-specific procedure |open|, which takes too many varied parameters to describe here: for example, the third parameter controls whether a new file shall be generated, or can enforce that an existing file cannot possibly be altered. @^system dependencies@> However, one in particular deserves special mention: the |user_action| parameter when included causes execution of a user-supplied routine which can manipulate the data structures used by RMS (Record Management Services) and thus @.RMS@> @^Record Management Services@> permit finer control over the actions undertaken during the opening or creation of files. All file manipulation procedures in VAX-\PASCAL\ (including |open|/|close|, |read|/|write|, etc.)\ can take an optional parameter which specifies whether or no the program shall continue execution after an error. Since we code to detect such errors, we nearly always make use of this facility. \TeX's file-opening procedures return |false| if no file identified by |name_of_file| could be opened: note that VAX-\PASCAL's |status| function returns zero if the previous file operation was successfully completed, |-1| if |eof| would be |true|, and a positive integer if any error was detected. When a |new| file is opened, we specify that it shall be deleted when the program exits; this ensures that output files are correctly discarded if \TeX\ is interrupted in its work. Later, when the files are closed, we can arrange to keep the files instead. VAX-\PASCAL's |open| procedure also allows us to specify a `default' file specification, which is used to supply defaults for those parts of the specification of the file being created that have not otherwise been provided by the user. Whenever a |word_file| is opened, the variable |fmt_count| is reset to zero to ensure that the first byte of the VAX block is that first accessed. @d VAX_user_action==@=user_action@> @# @d VAX_new==@= new @> @d VAX_readonly==@= readonly @> @# @d VAX_default==@= default @> @# @d VAX_disposition_delete==@=disposition:=delete@> @d VAX_ignore_error==@=error:=continue@> @p function a_open_in(var f:alpha_file):boolean; @z @x l.822 begin reset(f,name_of_file,'/O'); a_open_in:=reset_OK(f); @y begin open(f,name_of_file,VAX_readonly,VAX_user_action:=user_reset, VAX_ignore_error); if status(f)>0 then a_open_in:=false else begin reset(f,VAX_ignore_error); a_open_in:=status(f)<=0; end; @z @x l.827 begin rewrite(f,name_of_file,'/O'); a_open_out:=rewrite_OK(f); @y begin open(f,name_of_file,VAX_new,16383,VAX_disposition_delete, VAX_default:=default_name, VAX_user_action:=user_rewrite,VAX_ignore_error); if status(f)>0 then a_open_out:=false else begin linelimit(f,maxint); rewrite(f,VAX_ignore_error); a_open_out:=status(f)<=0; end; @z @x l.832 begin reset(f,name_of_file,'/O'); b_open_in:=reset_OK(f); @y begin open(f,name_of_file,VAX_readonly,VAX_user_action:=user_reset, VAX_ignore_error); if status(f)>0 then b_open_in:=false else begin reset(f,VAX_ignore_error); b_open_in:=status(f)<=0; end; @z @x l.837 begin rewrite(f,name_of_file,'/O'); b_open_out:=rewrite_OK(f); @y begin open(f,name_of_file,VAX_new,VAX_disposition_delete, VAX_default:=default_name, VAX_user_action:=user_rewrite,VAX_ignore_error); if status(f)>0 then b_open_out:=false else begin rewrite(f,VAX_ignore_error); b_open_out:=status(f)<=0; end; @z @x l.842 begin reset(f,name_of_file,'/O'); w_open_in:=reset_OK(f); @y begin open(f,name_of_file,VAX_readonly,VAX_user_action:=user_reset, VAX_ignore_error); if status(f)>0 then w_open_in:=false else begin reset(f,VAX_ignore_error); w_open_in:=status(f)<=0; end; fmt_count:=0; @z @x l.847 begin rewrite(f,name_of_file,'/O'); w_open_out:=rewrite_OK(f); @y begin open(f,name_of_file,VAX_new,VAX_disposition_delete, VAX_user_action:=user_rewrite,VAX_ignore_error); if status(f)>0 then w_open_out:=false else begin rewrite(f,VAX_ignore_error); w_open_out:=status(f)<=0; end; fmt_count:=0; @z @x l.850 @ 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. These procedures should not generate error messages if a file is being closed before it has been successfully opened. @p procedure a_close(var f:alpha_file); {close a text file} begin close(f); @y @ Files can be closed with the VAX-\PASCAL\ routine |close(f,disposition,error)|, 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 can make the corresponding external file appear in the user's directory, ready to be read: this depends upon the value of the |disposition| parameter, which can (\\{inter alia}) control whether the file is kept or discarded. If this parameter is not specified, then disposition of the file is determined by the corresponding parameter of the |open| routine. It is through this mechanism that we are able to ensure that all output files are discarded if the operation of \TeX\ is aborted by the user, and yet are kept if the program terminates correctly. These procedures should not generate error messages if a file is being closed before it has been successfully opened; the |error| parameter is used here to ensure that any such errors do not cause run-time failures. @d VAX_disposition_save==@=disposition:=save@> @p procedure a_close(var f:alpha_file); {close a text file} begin close(f,VAX_disposition_save,VAX_ignore_error); @z @x l.865 begin close(f); @y begin close(f,VAX_disposition_save,VAX_ignore_error); @z @x l.869 begin close(f); @y begin close(f,VAX_disposition_save,VAX_ignore_error); @z @x l.885 representing the beginning and ending of a line of text. @= @y representing the beginning and ending of a line of text. On VMS, we will read the lines first into an auxiliary buffer, in order to save the running time of procedure-call overhead. We have to be very careful to handle lines longer than the arbitrarily chosen length of the |aux_buf|. This buffer is declared using a VAX-\PASCAL\ extension for variable length strings, namely the |varying| array type. Such arrays actually appear as if they were a record declared with two fields, thus: |varying [max_size] of = record length: 0..max_size; body: packed array [1..max_size] of|. @d VAX_length(#)==#.@=length@> @d VAX_body(#)==#.@=body@> @f varying==array @= @!aux_buf:varying [size_input_line] of char; {where the characters go first} @z @x l.928 of characters at once, if such routines are available. The following code uses standard \PASCAL\ to illustrate what needs to be done, but finer tuning is often possible at well-developed \PASCAL\ sites. @^inner loop@> @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 of characters at once, if such routines are available. The following code uses VAX-\PASCAL\ extensions, such as |varying| strings to perform input of larger amounts of characters with a single input instruction. @^inner loop@> Under VAX-\PASCAL, it is not necessary to take special action to |bypass_eoln|, since the terminator character will be included in those read into the |aux_buf|. @p function input_ln(var f:alpha_file;@!bypass_eoln:boolean):boolean; {inputs the next line or returns |false|} label found; var @!len:integer; {length of line input} @!k:0..buf_size; {index into |buffer|} begin last:=first; {cf.\ Matthew 19\thinspace:\thinspace30} if status(f)<>0 then input_ln:=false else begin while not eoln(f) do begin read(f,aux_buf,VAX_ignore_error); len:=VAX_length(aux_buf); if last+len>=max_buf_stack then begin if last+len; end; for k:=last to last+len-1 do buffer[k]:=xord[aux_buf[k-last+1]]; last:=last+len; end; found: if last>first then if buffer[last-1]=" " then begin decr(last); goto found; end; input_ln:=true; read_ln(f,VAX_ignore_error); end; end; @z @x l.964 @ 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 under VMS. @^system dependencies@> The standard input and output proces-permanent files \.{SYS\$INPUT} and \.{SYS\$OUTPUT} @.SYS{\$}INPUT@> @.SYS{\$}OUTPUT@> are opened, and the addresses of the associated |FAB| and |RAB| noted so that special actions (such as flushing the input buffer) can be coded. Output occurs without any implicit carriage-control: this permits the output buffer to be flushed to the terminal without terminating the line of output; it is necessary to output the carriage-return, line-feed character pair explicitly when the line is to be terminated. @d VAX_sys_input==@= 'SYS$INPUT' @> @d VAX_sys_output==@= 'SYS$OUTPUT' @> @d VAX_PAS_FAB==@= PAS$FAB@> @d VAX_PAS_RAB==@= PAS$RAB@> @d VAX_carriage_control==@= carriage_control @> @d VAX_none==@= none @> @# @d t_open_in==begin open(term_in,VAX_sys_input); reset(term_in); in_FAB:=VAX_PAS_FAB(term_in); in_RAB:=VAX_PAS_RAB(term_in); end {open the terminal for text input} @d t_open_out==begin open(term_out,VAX_sys_output,VAX_carriage_control:=VAX_none); linelimit(term_out,maxint); rewrite(term_out); out_FAB:=VAX_PAS_FAB(term_out); out_RAB:=VAX_PAS_RAB(term_out); end {open the terminal for text output} @z @x l.982 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 on VMS in VAX-\PASCAL\ or DEC-\PASCAL, through manipulation of the data structures maintained in the |RAB| (Record Access Block) @^Record Access Block@> by RMS. @^RMS@> @^Record Management Services@> Since |wake_up_terminal| is only called just before output of an error message, there's no significant overhead in its being a procedure, and this saves 8k bytes of \PASCAL\ source compared with having it as a \.{WEB} definition. @^system dependencies@> To prevent spurious empty writes to the terminal in |batch_mode|, we apply a condition to |update_terminal|. @d VAX_RAB_purge_typeahead== @=RAB$V_PTA@> @d VAX_RAB_cancel_ctrlO== @=RAB$V_CCO@> @# @d update_terminal == if odd(selector) then write_ln(term_out) {empty the terminal output buffer} @d clear_terminal == in_RAB^.VAX_RAB_purge_typeahead:=true {clear the terminal input buffer} @.PTA@> @d crlf == chr(13),chr(10) @# @= procedure wake_up_terminal; begin out_RAB^.VAX_RAB_cancel_ctrlO:=true; write_ln(term_out); out_RAB^.VAX_RAB_cancel_ctrlO:=false; end; {cancel the user's cancellation of output} @.CCO@> @z @x l.1055 @ 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 @^system dependencies@> Since any command line passed to \TeX\ from DCL via \.{LIB\$GET\_VALUE} will have been ``up-cased'', we might consider converting everything to lower-case, so that all (usually lowercase) \TeX\ commands therein can be recognized; of course, any such commands which are named with upper-case letters would be ``ruined''. But, since we are using the full DCL command line interpreter interface, commands consisting of more than one word have to be enclosed in `\.{\char'042}' quotation marks, anyway. The correct case is thus preserved; and file names (which are by far the most common single word arguments) are case insensitive on VMS. Therefore, lower case conversion has not been implemented. @d VAX_cli_present==@= cli$present@> @d VAX_cli_get_value==@= cli$get_value@> @p function init_terminal:boolean; {gets the terminal input started} label exit; var command_line: packed array[1..256] of char; @!len: sixteen_bits; @!i: integer; begin t_open_in; if cmd_line_present then begin VAX_cli_get_value('COMMAND_LINE',command_line,len); i:=1; while (i<=len) and (command_line[i]=' ') do incr(i); if i<=len then begin loc:=first; last:=first; while i<=len do begin buffer[last]:=xord[command_line[i]]; incr(last); incr(i); end; init_terminal:=true; return; end; end; loop@+begin wake_up_terminal; write(term_out,'**'); update_terminal; @.**@> if not input_ln(term_in,true) then {this shouldn't happen} begin write(term_out,crlf); write_ln(term_out,'! End of file on the terminal... why?',crlf); @.End of file on the terminal@> init_terminal:=false; return; end; loc:=first; while (loc @z @x l.1296 (k<" ")or(k>"~") @y (k<" ")or((k>"~")and (k<160))or(k=255)or((k>=160)and not eight_qual) @z @x l.1298 @ When the \.{WEB} system program called \.{TANGLE} processes the \.{TEX.WEB} description that you are now reading, it outputs the \PASCAL\ program \.{TEX.PAS} and also a string pool file called \.{TEX.POOL}. The \.{INITEX} @.WEB@>@.INITEX@> @y @ When the \.{WEB} system program called \.{TANGLE} processes the \.{TEX.WEB} description that you are now reading, together with the merged change file for your system's implementation of \eTeX, it should output the \PASCAL\ program \.{ETEX.PAS} and also a string pool file called \.{ETEX.POOL}. The \.{EINITEX} @.WEB@>@.EINITEX@> @z @x l.1310 @ @d bad_pool(#)==begin wake_up_terminal; write_ln(term_out,#); @y @ As noted before, it is not necessary for the string |pool_name| to have the same length as the |array name_of_file|, because VAX-\PASCAL\ automatically pads such shorter strings with spaces when an assignment is made into a longer string variable. @d bad_pool(#)==begin wake_up_terminal; write_ln(term_out,#,crlf); @z @x l.1322 else bad_pool('! I can''t read TEX.POOL.') @.I can't read TEX.POOL@> @y else bad_pool('! I can''t read ETEX.POOL.') @.I can't read ETEX.POOL@> @z @x l.1326 begin if eof(pool_file) then bad_pool('! TEX.POOL has no check sum.'); @.TEX.POOL has no check sum@> @y begin if eof(pool_file) then bad_pool('! ETEX.POOL has no check sum.'); @.ETEX.POOL has no check sum@> @z @x l.1332 bad_pool('! TEX.POOL line doesn''t begin with two digits.'); @.TEX.POOL line doesn't...@> @y bad_pool('! ETEX.POOL line doesn''t begin with two digits.'); @.ETEX.POOL line doesn't...@> @z @x l.1346 @ The \.{WEB} operation \.{@@\$} denotes the value that should be at the end of this \.{TEX.POOL} file; any other value means that the wrong pool @y @ The \.{WEB} operation \.{@@\$} denotes the value that should be at the end of this \.{ETEX.POOL} file; any other value means that the wrong pool @z @x l.1354 bad_pool('! TEX.POOL check sum doesn''t have nine digits.'); @.TEX.POOL check sum...@> @y bad_pool('! ETEX.POOL check sum doesn''t have nine digits.'); @.ETEX.POOL check sum...@> @z @x l.1360 done: if a<>@$ then bad_pool('! TEX.POOL doesn''t match; TANGLE me again.'); @.TEX.POOL doesn't match@> @y done: if a<>@$ then bad_pool('! ETEX.POOL doesn''t match; TANGLE me again.'); @.ETEX.POOL doesn't match@> @z @x l.1387 \hang |new_string|, appends the output to the current string in the string pool. @y \hang |new_string|, appends the output to the current string in the string pool. \hang |edcmd_write|, prints the characters into the |edcmd_file| only. @z @x l.1393 \noindent The symbolic names `|term_and_log|', etc., have been assigned numeric codes that satisfy the convenient relations |no_print+1=term_only|, |no_print+2=log_only|, |term_only+2=log_only+1=term_and_log|. @y \noindent The symbolic names `|term_and_log|', etc., have been assigned numeric codes that satisfy the convenient relations |no_print+1=term_only|, |no_print+2=log_only|, |term_only+2=log_only+1=term_and_log|. The interface to various ``callable editors'', described toward the end of this program, necessitates the use of a separate output file (in addition to \TeX's 16 auxiliary output streams), |edcmd_file|, which is declared here, together with the associated value |edcmd_write| of the global |selector| variable. @z @x l.1411 @d max_selector=21 {highest selector setting} @= @!log_file : alpha_file; {transcript of \TeX\ session} @y @d edcmd_write=22 {printing is deflected to the |edcmd_file|} @d max_selector=22 {highest selector setting} @= @!log_file : alpha_file; {transcript of \TeX\ session} @!edcmd_file : alpha_file; {command file used when invoking some editors} @z @x l.1433 by changing |wterm|, |wterm_ln|, and |wterm_cr| in this section. @^system dependencies@> @d wterm(#)==write(term_out,#) @d wterm_ln(#)==write_ln(term_out,#) @d wterm_cr==write_ln(term_out) @d wlog(#)==write(log_file,#) @d wlog_ln(#)==write_ln(log_file,#) @d wlog_cr==write_ln(log_file) @y by changing |wterm|, |wterm_ln|, and |wterm_cr| in this section. @^system dependencies@> We also introduce here analogous macros for writing to the |diag_file|, which is used to generate diagnostic messages for use in conjunction with DEC's Language-sensitive editor (LSEdit). @^Language-sensitive editor@> @^LSE@> Yet another set of macros is concerned with writing to |temp_file|, which is a purely internal file, used to concatenate the various elements of \TeX's error messages for use in diagnostic and other files. @d wterm(#)==write(term_out,#) @d wterm_ln(#)==write_ln(term_out,#,crlf) @d wterm_cr==write_ln(term_out,crlf) @d wlog(#)==if log_qual then write(log_file,#) @d wlog_ln(#)==if log_qual then write_ln(log_file,#) @d wlog_cr==if log_qual then write_ln(log_file) @d wdiag(#)==if diag_qual then write(diag_file,#) @d wdiag_ln(#)==if diag_qual then write_ln(diag_file,#) @d wdiag_cr==if diag_qual then write_ln(diag_file) @d wtemp(#)==write(temp_file,#) @d wtemp_ln(#)==write_ln(temp_file,#) @d wtemp_cr==write_ln(temp_file) @= procedure diag_char(@!s:ASCII_code); var ch : char; begin ch := xchr[s]; wdiag(ch); if ch='"' then wdiag(ch) end; @# procedure temp_char(@!s:ASCII_code); var ch : char; begin ch := xchr[s]; wtemp(ch); if ch='"' then wtemp(ch) end; @# procedure diag_print( s : integer); var j : pool_pointer; begin j:=str_start[s]; while j < str_start[s+1] do begin diag_char(so(str_pool[j])); incr(j) end; end; @z @x l.1455 no_print,pseudo,new_string: do_nothing; @y no_print,pseudo,new_string: do_nothing; edcmd_write: write_ln(edcmd_file); @z @x l.1460 @ The |print_char| procedure sends one character to the desired destination, using the |xchr| array to map it into an external character compatible with |input_ln|. All printing comes through |print_ln| or |print_char|. @= procedure print_char(@!s:ASCII_code); {prints a single character} label exit; begin if @ then if selector= procedure print_char(@!s:ASCII_code); {prints a single character} label exit; begin if @ then if selector; case selector of term_and_log: begin wterm(xchr[s]); wlog(xchr[s]); incr(term_offset); incr(file_offset); if term_offset=max_print_line then begin wterm_cr; term_offset:=0; end; if file_offset=max_print_line then begin wlog_cr; file_offset:=0; end; end; log_only: begin wlog(xchr[s]); incr(file_offset); if file_offset=max_print_line then print_ln; end; term_only: begin wterm(xchr[s]); incr(term_offset); if term_offset=max_print_line then print_ln; end; no_print: do_nothing; pseudo: if tally} @y in_RAB^.VAX_RAB_purge_typeahead:=false; {turn off purging of typeahead} @.PTA@> term_offset:=0; {the user's line ended with \<\rm return>} @z @x l.1726 @ The global variable |interaction| has four settings, representing increasing amounts of user interaction: @y @ The global variable |interaction| has four settings, representing increasing amounts of user interaction: This version of \TeX\ can generate a diagnostics file for use with the \.{REVIEW} mode of DEC's Language-sensitive editor (LSEdit). @^Language-sensitive editor@> So whenever \TeX\ starts to generate an error message, we arrange for the text which is sent to the terminal and/or the transcript file to be copied also into our |temp_file|. @z @x l.1733 @d print_err(#)==begin if interaction=error_stop_mode then wake_up_terminal; print_nl("! "); print(#); end @= @!interaction:batch_mode..error_stop_mode; {current level of interaction} @y @d print_err(#)==begin if interaction=error_stop_mode then wake_up_terminal; print_nl("! "); copy_err:=save_it; rewrite(temp_file); print(#); {Other |print|s will add to |temp_file|} end @= @!interaction:batch_mode..error_stop_mode; {current level of interaction} @z @x l.1857 @ Here now is the general |error| routine. @y @ Here now is the general |error| routine, which completes output of the error message. @z @x l.1865 begin if history; @y begin if history; show_context; if interaction=error_stop_mode then @; @z @x l.1886 @ It is desirable to provide an `\.E' option here that gives the user an easy way to return from \TeX\ to the system editor, with the offending 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@> @y @ It is desirable to provide an `\.E' option here that gives the user an easy way to return from \TeX\ to the system editor, with the offending line ready to be edited. This version of \TeX\ invokes callable versions of various DEC editors, depending upon the value of the \.{/EDITOR} switch (normally set to \.{TEX\_EDIT}), @./EDITOR@> @.TEX_EDIT@> including \.{EDT}, \.{TPU}, DEC's Language-sensitive editor (LSEdit), and even @^EDT@> @^TPU@> @^Language-sensitive editor@> @^LSE@> \.{TECO}. @^TECO@> Other editors may be run in a sub-process by setting \.{/EDITOR} to any DCL command, including activating a command procedure. In addition, if the \.{/CONTINUE} qualifier is present on the command line, @./CONTINUE@> \TeX\ will continue processing after returning from the editor. @^system dependencies@> @z @x l.1903 "E": if base_ptr>0 then begin print_nl("You want to edit file "); @.You want to edit file x@> slow_print(input_stack[base_ptr].name_field); print(" at line "); print_int(line); interaction:=scroll_mode; jump_out; end; @y "E": if base_ptr>0 then begin if edit_file(input_stack[base_ptr],line) then begin if continue_qual then begin show_context; goto continue; end else begin interaction:=scroll_mode; jump_out; end end else begin print_nl("You want to edit file "); @.You want to edit file x@> slow_print(input_stack[base_ptr].name_field); print(" at line "); print_int(line); interaction:=scroll_mode; jump_out; end end; @z @x l.1935 @= begin error_count:=0; interaction:=batch_mode+c-"Q"; print("OK, entering "); case c of "Q":begin print_esc("batchmode"); decr(selector); end; "R":print_esc("nonstopmode"); "S":print_esc("scrollmode"); end; {there are no other cases} print("..."); print_ln; update_terminal; return; end @y @= begin error_count:=0; interaction:=batch_mode+c-"Q"; print("OK, entering "); case c of "Q":print_esc("batchmode"); "R":print_esc("nonstopmode"); "S":print_esc("scrollmode"); end; {there are no other cases} print("..."); print_ln; update_terminal; if c = "Q" then decr (selector); return; end @z @x l.2085 @ Users occasionally want to interrupt \TeX\ while it's running. If the \PASCAL\ runtime system allows this, one can implement a routine that sets the global variable |interrupt| to some nonzero value when such an interrupt is signalled. Otherwise there is probably at least a way to make |interrupt| nonzero using the \PASCAL\ debugger. @^system dependencies@> @^debugging@> @y @ Users occasionally want to interrupt \TeX\ while it's running. By using a VAX system service, we can declare an Asynchronous System Trap (AST) handler which will be called when the user types \.{Ctrl-C}. The AST handler then sets the global variable |interrupt| to some nonzero value when such an interrupt is signalled. @^system dependencies@> Since this variable may be changed at any time, we must prevent the compiler from applying optimizations to the code related to this variable (for example, it would not do for it to be held in a machine register), so we give it the VAX-\PASCAL\ `attribute' \.{volatile}, which is defined at this point. We also define a couple of other attributes that may be applied to affect the placement of variables under VAX-\PASCAL. Assuming that it's possible to assign an I/O channel to device \.{SYS\$COMMAND}, @.SYS{\$}COMMAND@> which should be the case provided the program is being run interactively, then the Control-C handler is declared by a call of the \.{\$QIOW} system service. @.{\$}QIOW@> Some parameters for this system service have to passed by the `immediate' parameter-passing mechanism; we take this opportunity to define all the means used in \TeX\ to override VAX-\PASCAL's default parameter-passing mechanisms. @d VAX_volatile==@= volatile @> @d VAX_unsafe==@= unsafe @> @d VAX_aligned==@= aligned @> @d VAX_static==@= static @> @# @d VAX_immed==@= %immed @> @d VAX_stdescr==@= %stdescr @> @d VAX_ref==@= %ref @> @# @d VAX_io_setmode==@= io$_setmode @> @d VAX_iom_ctrlcast==@= io$m_ctrlcast @> @# @d VAX_qiow==@= $qiow@> @d VAX_assign==@= $assign@> @# @z @x l.2093 @d check_interrupt==begin if interrupt<>0 then pause_for_instructions; end @= @!interrupt:integer; {should \TeX\ pause for instructions?} @y @d check_interrupt==begin if interrupt<>0 then pause_for_instructions; end @d enable_control_C== VAX_qiow(,tt_chan,VAX_io_setmode+VAX_iom_ctrlcast,,,, VAX_immed ctrlc_rout,,VAX_immed 3,,,); @= @!interrupt: [VAX_volatile] integer; {should \TeX\ pause for instruction?} @z @x l.2101 interrupt:=0; OK_to_interrupt:=true; @y interrupt:=0; OK_to_interrupt:=true; if VAX_assign('SYS$COMMAND',tt_chan,,)=VAX_ss_normal then enable_control_C; @z @x l.2345 @d set_glue_ratio_zero(#) == #:=0.0 {store the representation of zero ratio} @d set_glue_ratio_one(#) == #:=1.0 {store the representation of unit ratio} @d float(#) == # {convert from |glue_ratio| to type |real|} @d unfloat(#) == # {convert from |real| to type |glue_ratio|} @d float_constant(#) == #.0 {convert |integer| constant to |real|} @= @!glue_ratio=real; {one-word representation of a glue expansion factor} @y On VMS, we use some hackery to cause floating point numbers stored in |mem| to be |single|, but other |real| variables and expressions are done as |double| length reals. @d set_glue_ratio_zero(#) == #:=0.0 {store the representation of zero ratio} @d set_glue_ratio_one(#) == #:=1.0 {store the representation of unit ratio} @d real == double {use double precision reals for computation} @d float(#) == dble(#) {convert from |glue_ratio| to type |real|} {FIX ME} @d unfloat(#) == sngl(1.0@&D0 * #) {convert from |real| to type |glue_ratio|} @d float_constant(#) == #.0@&D0 {convert |integer| constant to |real|} @= @!glue_ratio=r@&e@&a@&l; {one-word representation of a glue expansion factor} @z @x l.2405 @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==327144+1 {largest allowable value in a |halfword|} @z @x l.2438 @d qi(#)==#+min_quarterword {to put an |eight_bits| item into a quarterword} @d qo(#)==#-min_quarterword {to take an |eight_bits| item out of a quarterword} @d hi(#)==#+min_halfword {to put a sixteen-bit item into a halfword} @d ho(#)==#-min_halfword {to take a sixteen-bit item from a halfword} @y @d qi(#)==# @d qo(#)==# @d hi(#)==# @d ho(#)==# @z @x l.2469 @!memory_word = record@;@/ case four_choices of 1: (@!int:integer); 2: (@!gr:glue_ratio); 3: (@!hh:two_halves); 4: (@!qqqq:four_quarters); end; @y @!memory_word = packed record@;@/ case four_choices of 1: (@!int:integer); 2: (@!gr:glue_ratio); 3: (@!hh:two_halves); 4: (@!qqqq:four_quarters); end; @z @x l.2476 @!word_file = file of memory_word; @y @!word_block = packed array[0..VAX_block_length-1] of memory_word; @!word_file = packed file of word_block; @z @x l.2965 This field occupies a full word instead of a halfword, because there's nothing to put in the other halfword; it is easier in \PASCAL\ to use the full word than to risk leaving garbage in the unused half. @y In addition there is a |mark_class| field that contains the mark class. @z @x l.2971 @d mark_ptr(#)==mem[#+1].int {head of the token list for a mark} @y @d mark_ptr(#)==link(#+1) {head of the token list for a mark} @d mark_class(#)==info(#+1) {the mark class} @z @x l.2980 @d adjust_ptr==mark_ptr {vertical list to be moved out of horizontal list} @y @d adjust_ptr(#)==mem[#+1].int {vertical list to be moved out of horizontal list} @z @x l.3069 the amount of surrounding space inserted by \.{\\mathsurround}. @y the amount of surrounding space inserted by \.{\\mathsurround}. In addition a |math_node| with |subtype>after| and |width=0| will be (ab)used to record a regular |math_node| reinserted after being discarded at a line break or one of the text direction primitives ( \.{\\beginL}, \.{\\endL}, \.{\\beginR}, and \.{\\endR} ). @z @x l.3073 @d after=1 {|subtype| for math node that winds up a formula} @y @d after=1 {|subtype| for math node that winds up a formula} @# @d M_code=2 @d begin_M_code=M_code+before {|subtype| for \.{\\beginM} node} @d end_M_code=M_code+after {|subtype| for \.{\\endM} node} @d L_code=4 @d begin_L_code=L_code+begin_M_code {|subtype| for \.{\\beginL} node} @d end_L_code=L_code+end_M_code {|subtype| for \.{\\endL} node} @d R_code=L_code+L_code @d begin_R_code=R_code+begin_M_code {|subtype| for \.{\\beginR} node} @d end_R_code=R_code+end_M_code {|subtype| for \.{\\endR} node} @# @d end_LR(#)==odd(subtype(#)) @d end_LR_type(#)==(L_code*(subtype(#) div L_code)+end_M_code) @d begin_LR_type(#)==(#-after+before) @z @x l.3546 math_node: print_char("$"); @y math_node: if subtype(p)>=L_code then print("[]") else print_char("$"); @z @x l.3713 begin print(", shifted "); print_scaled(shift_amount(p)); end; @y begin print(", shifted "); print_scaled(shift_amount(p)); end; if eTeX_ex then @; @z @x l.3735 arbitrary random value. The following code assumes that a properly formed nonzero |real| number has absolute value $2^{20}$ or more when it is regarded as an integer; this precaution was adequate to prevent floating point underflow on the author's computer. @y arbitrary random value. The following WEB macro simulates VAX/DEC-\PASCAL's predeclared routine |undefined|, which returns |true| if its argument is not a properly constituted |real| number. (The real function cannot be used, because it is currently unsupported on DEC-\PASCAL\ for AXP.) @d VAX_undefined(#)== (#::VAX_F_float.Sign and (#::VAX_F_float.Expo = 0)) @z @x l.3747 if abs(mem[p+glue_offset].int)<@'4000000 then print("?.?") @y if VAX_undefined(glue_set(p)) then print("?.?") @z @x l.3811 begin print_esc("math"); @y if subtype(p)>after then begin if end_LR(p) then print_esc("end") else print_esc("begin"); if subtype(p)>R_code then print_char("R") else if subtype(p)>L_code then print_char("L") else print_char("M"); end else begin print_esc("math"); @z @x l.3844 begin print_esc("mark"); print_mark(mark_ptr(p)); @y begin print_esc("mark"); if mark_class(p)<>null then begin print_char("s"); print_int(mark_class(p)); end; print_mark(mark_ptr(p)); @z @x l.4081 @d un_vbox=24 {unglue a box ( \.{\\unvbox}, \.{\\unvcopy} )} @y @d un_vbox=24 {unglue a box ( \.{\\unvbox}, \.{\\unvcopy} )} {( or \.{\\pagediscards}, \.{\\splitdiscards} )} @z @x l.4091 @d valign=33 {vertical table alignment ( \.{\\valign} )} @y @d valign=33 {vertical table alignment ( \.{\\valign} )} {or text direction directives ( \.{\\beginL}, etc.~)} @z @x l.4107 @d left_right=49 {variable delimiter ( \.{\\left}, \.{\\right} )} @y @d left_right=49 {variable delimiter ( \.{\\left}, \.{\\right} )} {( or \.{\\middle} )} @z @x l.4151 \.{\\insertpenalties} )} @y \.{\\insertpenalties} )} {( or \.{\\interactionmode} )} @z @x l.4153 @d set_shape=84 {specify fancy paragraph shape ( \.{\\parshape} )} @y @d set_shape=84 {specify fancy paragraph shape ( \.{\\parshape} )} {(or \.{\\interlinepenalties}, etc.~)} @z @x l.4163 @d prefix=93 {qualify a definition ( \.{\\global}, \.{\\long}, \.{\\outer} )} @y @d prefix=93 {qualify a definition ( \.{\\global}, \.{\\long}, \.{\\outer} )} {( or \.{\\protected} )} @z @x l.4166 @d read_to_cs=96 {read into a control sequence ( \.{\\read} )} @y @d read_to_cs=96 {read into a control sequence ( \.{\\read} )} {( or \.{\\readline} )} @z @x l.4181 @d input=max_command+4 {input a source file ( \.{\\input}, \.{\\endinput} )} @y @d input=max_command+4 {input a source file ( \.{\\input}, \.{\\endinput} )} {( or \.{\\scantokens} )} @z @x l.4186 @d the=max_command+9 {expand an internal quantity ( \.{\\the} )} @y @d the=max_command+9 {expand an internal quantity ( \.{\\the} )} {( or \.{\\unexpanded}, \.{\\detokenize} )} @z @x l.4289 user's output routine. @y user's output routine. A seventh quantity, |eTeX_aux|, is used by the extended features \eTeX. In vertical modes it is known as |LR_save| and holds the LR stack when a paragraph is interrupted by a displayed formula. In display math mode it is known as |LR_box| and holds a pointer to a prototype box for the display. In math mode it is known as |delim_ptr| and points to the most recent |left_noad| or |middle_noad| of a |math_left_group|. @z @x l.4304 @!head_field,@!tail_field: pointer; @y @!head_field,@!tail_field: pointer; @!eTeX_aux_field: pointer; @z @x l.4311 @d tail==cur_list.tail_field {final node on current list} @y @d tail==cur_list.tail_field {final node on current list} @d eTeX_aux==cur_list.eTeX_aux_field {auxiliary data for \eTeX} @d LR_save==eTeX_aux {LR stack when a paragraph is interrupted} @d LR_box==eTeX_aux {prototype box for display} @d delim_ptr==eTeX_aux {most recent left or right noad of a math left group} @z @x l.4342 mode:=vmode; head:=contrib_head; tail:=contrib_head; @y mode:=vmode; head:=contrib_head; tail:=contrib_head; eTeX_aux:=null; @z @x l.4358 incr(nest_ptr); head:=get_avail; tail:=head; prev_graf:=0; mode_line:=line; @y incr(nest_ptr); head:=get_avail; tail:=head; prev_graf:=0; mode_line:=line; eTeX_aux:=null; @z @x l.4712 @d output_routine_loc=local_base+1 {points to token list for \.{\\output}} @d every_par_loc=local_base+2 {points to token list for \.{\\everypar}} @d every_math_loc=local_base+3 {points to token list for \.{\\everymath}} @d every_display_loc=local_base+4 {points to token list for \.{\\everydisplay}} @d every_hbox_loc=local_base+5 {points to token list for \.{\\everyhbox}} @d every_vbox_loc=local_base+6 {points to token list for \.{\\everyvbox}} @d every_job_loc=local_base+7 {points to token list for \.{\\everyjob}} @d every_cr_loc=local_base+8 {points to token list for \.{\\everycr}} @d err_help_loc=local_base+9 {points to token list for \.{\\errhelp}} @d toks_base=local_base+10 {table of 256 token list registers} @y @d inter_line_penalties_loc=local_base+1 {additional penalties between lines} @d club_penalties_loc=local_base+2 {penalties for creating club lines} @d widow_penalties_loc=local_base+3 {penalties for creating widow lines} @d display_widow_penalties_loc=local_base+4 {ditto, just before a display} @d token_base=local_base+5 {table of token list parameters} @d output_routine_loc=token_base {points to token list for \.{\\output}} @d every_par_loc=token_base+1 {points to token list for \.{\\everypar}} @d every_math_loc=token_base+2 {points to token list for \.{\\everymath}} @d every_display_loc=token_base+3 {points to token list for \.{\\everydisplay}} @d every_hbox_loc=token_base+4 {points to token list for \.{\\everyhbox}} @d every_vbox_loc=token_base+5 {points to token list for \.{\\everyvbox}} @d every_job_loc=token_base+6 {points to token list for \.{\\everyjob}} @d every_cr_loc=token_base+7 {points to token list for \.{\\everycr}} @d every_eof_loc=token_base+8 {points to token list for \.{\\everyeof}} @d err_help_loc=token_base+9 {points to token list for \.{\\errhelp}} @d toks_base=token_base+10 {table of 256 token list registers} @z @x l.4787 othercases print_esc("errhelp") @y @/@@/ othercases print_esc("errhelp") @z @x l.4805 eq_level(par_shape_loc):=level_one;@/ @y eq_level(par_shape_loc):=level_one;@/ for k:=par_shape_loc+1 to token_base-1 do eqtb[k]:=eqtb[par_shape_loc]; @z @x l.4820 cat_code("\"):=escape; cat_code("%"):=comment; @y cat_code("\"):=escape; cat_code("%"):=comment; cat_code(form_feed):=car_ret; @z @x l.4833 if n=par_shape_loc then begin print_esc("parshape"); print_char("="); if par_shape_ptr=null then print_char("0") else print_int(info(par_shape_ptr)); @y if npar_shape_loc then begin print_int(penalty(equiv(n))); print_char(" "); print_int(penalty(equiv(n)+1)); if penalty(equiv(n))>1 then print_esc("ETC."); end else print_int(info(par_shape_ptr)); @z @x l.4955 @d count_base=int_base+int_pars {256 user \.{\\count} registers} @y @d tracing_assigns_code=int_pars {show assignments} @d tracing_groups_code=int_pars+1 {show save/restore groups} @d tracing_ifs_code=int_pars+2 {show conditionals} @d tracing_scan_tokens_code=int_pars+3 {show pseudo file open and close} @d tracing_nesting_code=int_pars+4 {show incomplete groups and ifs within files} @d pre_display_direction_code=int_pars+5 {text direction preceding a display} @d last_line_fit_code=int_pars+6 {adjustment for last line of paragraph} @d saving_vdiscards_code=int_pars+7 {save items discarded from vlists} @d saving_hyph_codes_code=int_pars+8 {save hyphenation codes for languages} @d eTeX_state_code=int_pars+9 {\eTeX\ state variables} @d count_base=int_base+eTeX_state_code+eTeX_states {256 user \.{\\count} registers} @z @x l.5016 @d error_context_lines==int_par(error_context_lines_code) @y @d error_context_lines==int_par(error_context_lines_code) @d tracing_assigns==int_par(tracing_assigns_code) @d tracing_groups==int_par(tracing_groups_code) @d tracing_ifs==int_par(tracing_ifs_code) @d tracing_scan_tokens==int_par(tracing_scan_tokens_code) @d tracing_nesting==int_par(tracing_nesting_code) @d pre_display_direction==int_par(pre_display_direction_code) @d last_line_fit==int_par(last_line_fit_code) @d saving_vdiscards==int_par(saving_vdiscards_code) @d saving_hyph_codes==int_par(saving_hyph_codes_code) @z @x l.5081 othercases print("[unknown integer parameter!]") @y @/@@/ othercases print("[unknown integer parameter!]") @z @x l.5222 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. @p procedure fix_date_and_time; begin time:=12*60; {minutes since midnight} day:=4; {fourth day of the month} month:=7; {seventh month of the year} year:=1776; {Anno Domini} @y The requisite information is obtained through a call of the \.{\$NUMTIM} system @.{\$}NUMTIM@> service. @d VAX_numtim==@= $numtim@> @p procedure fix_date_and_time; var t:array[1..7] of signed_halfword; {raw year, month, day and time} begin VAX_numtim(t); year:=t[1]; month:=t[2]; day:=t[3]; time:=t[4]*60+t[5]; {minutes since midnight} @z @x l.5612 @!j:small_number; {index into |buffer|} @y @!j:0..buf_size; {index into |buffer|} @z @x l.5616 {we will move |s| into the (empty) |buffer|} for j:=0 to l-1 do buffer[j]:=so(str_pool[k+j]); cur_val:=id_lookup(0,l); {|no_new_control_sequence| is |false|} @y {we will move |s| into the (possibly non-empty) |buffer|} if first+l>buf_size+1 then overflow("buffer size",buf_size); @:TeX capacity exceeded buffer size}{\quad buffer size@> for j:=0 to l-1 do buffer[first+j]:=so(str_pool[k+j]); cur_val:=id_lookup(first,l); {|no_new_control_sequence| is |false|} @z @x l.5691 primitive("parshape",set_shape,0);@/ @y primitive("parshape",set_shape,par_shape_loc);@/ @z @x l.5708 primitive("toks",toks_register,0);@/ @y primitive("toks",toks_register,mem_bot);@/ @z @x l.5741 expand_after: print_esc("expandafter"); @y expand_after: if chr_code=0 then print_esc("expandafter") @; @z @x l.5747 mark: print_esc("mark"); @y mark: begin print_esc("mark"); if chr_code>0 then print_char("s"); end; @z @x l.5758 read_to_cs: print_esc("read"); @y read_to_cs: if chr_code=0 then print_esc("read") @; @z @x l.5762 set_shape: print_esc("parshape"); @y set_shape: case chr_code of par_shape_loc: print_esc("parshape"); @@;@/ end; {there are no other cases} @z @x l.5763 the: print_esc("the"); @y the: if chr_code=0 then print_esc("the") @; @z @x l.5764 toks_register: print_esc("toks"); @y toks_register: @; @z @x l.5766 valign: print_esc("valign"); @y valign: if chr_code=0 then print_esc("valign")@/ @; @z @x l.5800 interpreted in one of four ways: @y interpreted in one of five ways: @z @x l.5820 the entries for that group. @y the entries for that group. Furthermore, in extended \eTeX\ mode, |save_stack[p-1]| contains the source line number at which the current level of grouping was entered. \yskip\hang 5) If |save_type(p)=restore_sa|, then |sa_chain| points to a chain of sparse array entries to be restored at the end of the current group. Furthermore |save_index(p)| and |save_level(p)| should replace the values of |sa_chain| and |sa_level| respectively. @z @x l.5830 @d level_boundary=3 {|save_type| corresponding to beginning of group} @y @d level_boundary=3 {|save_type| corresponding to beginning of group} @d restore_sa=4 {|save_type| when sparse array entries should be restored} @p@t\4@>@ @z @x l.5888 @ The following macro is used to test if there is room for up to six more @y @ The following macro is used to test if there is room for up to seven more @z @x l.5894 if max_save_stack>save_size-6 then overflow("save size",save_size); @y if max_save_stack>save_size-7 then overflow("save size",save_size); @z @x l.5916 begin check_full_save_stack; @y begin check_full_save_stack; if eTeX_ex then begin saved(0):=line; incr(save_ptr); end; @z @x l.5923 cur_boundary:=save_ptr; incr(cur_level); incr(save_ptr); cur_group:=c; @y cur_boundary:=save_ptr; cur_group:=c; @!stat if tracing_groups>0 then group_trace(false);@+tats@;@/ incr(cur_level); incr(save_ptr); @z @x l.5941 othercases do_nothing @y @/@@/ othercases do_nothing @z @x l.5963 the call, since |eq_save| makes the necessary test. @y the call, since |eq_save| makes the necessary test. @d assign_trace(#)==@!stat if tracing_assigns>0 then restore_trace(#); tats @z @x l.5967 begin if eq_level(p)=cur_level then eq_destroy(eqtb[p]) @y label exit; begin if eTeX_ex and(eq_type(p)=t)and(equiv(p)=e) then begin assign_trace(p,"reassigning")@;@/ eq_destroy(eqtb[p]); return; end; assign_trace(p,"changing")@;@/ if eq_level(p)=cur_level then eq_destroy(eqtb[p]) @z @x l.5970 end; @y assign_trace(p,"into")@;@/ exit:end; @z @x l.5977 begin if xeq_level[p]<>cur_level then @y label exit; begin if eTeX_ex and(eqtb[p].int=w) then begin assign_trace(p,"reassigning")@;@/ return; end; assign_trace(p,"changing")@;@/ if xeq_level[p]<>cur_level then @z @x l.5981 end; @y assign_trace(p,"into")@;@/ exit:end; @z @x l.5990 begin eq_destroy(eqtb[p]); eq_level(p):=level_one; eq_type(p):=t; equiv(p):=e; @y begin assign_trace(p,"globally changing")@;@/ begin eq_destroy(eqtb[p]); eq_level(p):=level_one; eq_type(p):=t; equiv(p):=e; end; assign_trace(p,"into")@;@/ @z @x l.5995 begin eqtb[p].int:=w; xeq_level[p]:=level_one; @y begin assign_trace(p,"globally changing")@;@/ begin eqtb[p].int:=w; xeq_level[p]:=level_one; end; assign_trace(p,"into")@;@/ @z @x l.6012 @p@t\4@>@@;@/ @y @p @z @x l.6019 begin if cur_level>level_one then @y @!a:boolean; {have we already processed an \.{\\aftergroup} ?} begin a:=false; if cur_level>level_one then @z @x l.6033 else begin if save_type(save_ptr)=restore_old_value then @y else if save_type(save_ptr)=restore_sa then begin sa_restore; sa_chain:=p; sa_level:=save_level(save_ptr); end else begin if save_type(save_ptr)=restore_old_value then @z @x l.6041 done: cur_group:=save_level(save_ptr); cur_boundary:=save_index(save_ptr) @y done: @!stat if tracing_groups>0 then group_trace(true);@+tats@;@/ if grp_stack[in_open]=cur_boundary then group_warning; {groups possibly not properly nested with files} cur_group:=save_level(save_ptr); cur_boundary:=save_index(save_ptr); if eTeX_ex then decr(save_ptr) @z @x l.6067 @ @= @y @ @= @z @x l.6155 @d end_match_token=@'7000 {$2^8\cdot|end_match|$} @y @d end_match_token=@'7000 {$2^8\cdot|end_match|$} @d protected_token=@'7001 {$2^8\cdot|end_match|+1$} @z @x l.6280 end_match: print("->"); @y end_match: if c=0 then print("->"); @z @x l.6301 else if cur_cmd=top_bot_mark then @y else if (cur_cmd=top_bot_mark)and(cur_chr0 then if cur_cmd>=if_test then if cur_cmd<=fi_or_else then begin print(": "); if cur_cmd=fi_or_else then begin print_cmd_chr(if_test,cur_if); print_char(" "); n:=0; l:=if_line; end else begin n:=1; l:=line; end; p:=cond_ptr; while p<>null do begin incr(n); p:=link(p); end; print("(level "); print_int(n); print_char(")"); print_if_line(l); end; print_char("}"); @z @x l.6475 the terminal, under control of the procedure |read_toks|.) @y the terminal, under control of the procedure |read_toks|.) Finally |18<=name<=19| indicates that we are reading a pseudo file created by the \.{\\scantokens} command. @z @x l.6692 @d mark_text=14 {|token_type| code for \.{\\topmark}, etc.} @d write_text=15 {|token_type| code for \.{\\write}} @y @d every_eof_text=14 {|token_type| code for \.{\\everyeof}} @d mark_text=15 {|token_type| code for \.{\\topmark}, etc.} @d write_text=16 {|token_type| code for \.{\\write}} @z @x l.6743 @@/ begin base_ptr:=input_ptr; input_stack[base_ptr]:=cur_input; {store current state} @y @@/ begin base_ptr:=input_ptr; input_stack[base_ptr]:=cur_input; {store current state} @; @z @x l.6749 if (name>17) or (base_ptr=0) then bottom_line:=true; @y if (name>19) or (base_ptr=0) then bottom_line:=true; @z @x l.6758 done: cur_input:=input_stack[input_ptr]; {restore original state} end; @y done: cur_input:=input_stack[input_ptr]; {restore original state} @; end; @z @x l.6785 @= if name<=17 then if terminal_input then if base_ptr=0 then print_nl("<*>") else print_nl(" ") else begin print_nl(" print_char(">"); end @y @= if name<=17 then begin @; if terminal_input then if base_ptr=0 then print_nl("<*>") else print_nl(" ") else begin print_nl(" print_char(">"); end; @; end @z @x l.6794 else begin print_nl("l."); print_int(line); end; @y else if index<>in_open then {input from a pseudo file} begin print_nl("l."); print_int(line_stack[index+1]); end else begin print_nl("l."); print_int(line); @; end; @z @x l.6798 @ @= case token_type of parameter: print_nl(" "); @y @ @= @; case token_type of parameter: print_nl(" "); @z @x l.6814 every_cr_text: print_nl(" "); @y every_cr_text: print_nl(" "); every_eof_text: print_nl(" "); @z @x l.6815 mark_text: print_nl(" "); write_text: print_nl(" "); othercases print_nl("?") {this should never happen} endcases @y mark_text: print_nl(" "); write_text: print_nl(" "); othercases print_nl("?") {this should never happen} endcases; @ @z @x l.6874 @= if trick_count=1000000 then set_trick_count; {|set_trick_count| must be performed} if tallyerror_line then print("...") @y @= if trick_count=1000000 then set_trick_count; {|set_trick_count| must be performed} if tally; if m+n<=error_line then p:=first_count+m else p:=first_count+(error_line-n-3); for q:=first_count to p-1 do print_char(trick_buf[q mod error_line]); if m+n>error_line then print("..."); @ @z @x l.6896 @= begin_pseudoprint; if buffer[limit]=end_line_char then j:=limit else j:=limit+1; {determine the effective end of the line} if j>0 then for i:=start to j-1 do begin if i=loc then set_trick_count; print(buffer[i]); end @y @= begin_pseudoprint; if buffer[limit]=end_line_char then j:=limit else j:=limit+1; {determine the effective end of the line} if j>0 then for i:=start to j-1 do begin if i=loc then set_trick_count; print(buffer[i]); end; if name<=17 then @ @z @x l.6905 @ @= begin_pseudoprint; if token_type= begin_pseudoprint; if token_type; @z @x l.7009 begin t:=cur_tok; cur_tok:=p; back_input; cur_tok:=t; @y begin t:=cur_tok; cur_tok:=p; if a then begin p:=get_avail; info(p):=cur_tok; link(p):=loc; loc:=p; start:=p; if cur_tok17 then a_close(cur_file); {forget it} @y if (name=18)or(name=19) then pseudo_close else if name>17 then a_close(cur_file); {forget it} @z @x l.7066 in_open:=0; open_parens:=0; max_buf_stack:=0; @y in_open:=0; open_parens:=0; max_buf_stack:=0; grp_stack[0]:=0; if_stack[0]:=null; @z @x l.7538 if not force_eof then @y if not force_eof then if name<=19 then begin if pseudo_input then {not end of file} firm_up_the_line {this sets |limit|} else if (every_eof<>null)and not eof_seen[index] then begin limit:=first-1; eof_seen[index]:=true; {fake one empty line} begin_token_list(every_eof,every_eof_text); goto restart; end else force_eof:=true; end else @z @x l.7541 else force_eof:=true; @y else if (every_eof<>null)and not eof_seen[index] then begin limit:=first-1; eof_seen[index]:=true; {fake one empty line} begin_token_list(every_eof,every_eof_text); goto restart; end else force_eof:=true; @z @x l.7544 begin print_char(")"); decr(open_parens); update_terminal; {show user that file has been read} @y begin if tracing_nesting>0 then if (grp_stack[in_open]<>cur_boundary)or@| (if_stack[in_open]<>cond_ptr) then file_warning; {give warning for some unfinished groups and/or conditionals} if name>=19 then begin print_char(")"); decr(open_parens); update_terminal; {show user that file has been read} end; @z @x l.7630 @t\4@>@@;@/ @y @t\4@>@@;@/ @t\4@>@@;@/ @z @x l.7637 procedure expand; @y procedure expand; label reswitch; @z @x l.7648 if cur_cmd @y reswitch: if cur_cmd @z @x l.7659 expand_after:@; @y expand_after:if cur_chr=0 then @ else @; @z @x l.7779 input: if chr_code=0 then print_esc("input")@+else print_esc("endinput"); @y input: if chr_code=0 then print_esc("input") @/@@/ else print_esc("endinput"); @z @x l.7782 if cur_chr>0 then force_eof:=true @y if cur_chr=1 then force_eof:=true @/@@/ @z @x l.7838 @d top_mark_code=0 {the mark in effect at the previous page break} @y @d marks_code==5 {add this for \.{\\topmarks} etc.} @# @d top_mark_code=0 {the mark in effect at the previous page break} @z @x l.7870 top_bot_mark: case chr_code of @y top_bot_mark: begin case (chr_code mod marks_code) of @z @x l.7876 endcases; @y endcases; if chr_code>=marks_code then print_char("s"); end; @z @x l.7882 begin if cur_mark[cur_chr]<>null then begin_token_list(cur_mark[cur_chr],mark_text); @y begin t:=cur_chr mod marks_code; if cur_chr>=marks_code then scan_register_num@+else cur_val:=0; if cur_val=0 then cur_ptr:=cur_mark[t] else @; if cur_ptr<>null then begin_token_list(cur_ptr,mark_text); @z @x l.7945 if info(r)<>end_match_token then @y if info(r)=protected_token then r:=link(r); if info(r)<>end_match_token then @z @x l.8255 @t\4\4@>@ @y @t\4\4@>@@; @t\4\4@>@ @z @x l.8299 |glue_val|, or |mu_val|. @y |glue_val|, or |mu_val| more than |mem_bot| (dynamic variable-size nodes cannot have these values) @z @x l.8302 primitive("count",register,int_val); @!@:count_}{\.{\\count} primitive@> primitive("dimen",register,dimen_val); @!@:dimen_}{\.{\\dimen} primitive@> primitive("skip",register,glue_val); @!@:skip_}{\.{\\skip} primitive@> primitive("muskip",register,mu_val); @y primitive("count",register,mem_bot+int_val); @!@:count_}{\.{\\count} primitive@> primitive("dimen",register,mem_bot+dimen_val); @!@:dimen_}{\.{\\dimen} primitive@> primitive("skip",register,mem_bot+glue_val); @!@:skip_}{\.{\\skip} primitive@> primitive("muskip",register,mem_bot+mu_val); @z @x l.8312 register: if chr_code=int_val then print_esc("count") else if chr_code=dimen_val then print_esc("dimen") else if chr_code=glue_val then print_esc("skip") else print_esc("muskip"); @y register: @; @z @x l.8328 var m:halfword; {|chr_code| part of the operand token} @y label exit; var m:halfword; {|chr_code| part of the operand token} @!q:halfword; {general purpose index} @!i:four_quarters; {character info} @z @x l.8354 end; @y exit:end; @z @x l.8375 begin scan_eight_bit_int; m:=toks_base+cur_val; end; scanned_result(equiv(m))(tok_val); @y if m=mem_bot then begin scan_register_num; if cur_val<256 then cur_val:=equiv(toks_base+cur_val) else begin find_sa_element(tok_val,cur_val,false); if cur_ptr=null then cur_val:=null else cur_val:=sa_ptr(cur_ptr); end; end else cur_val:=sa_ptr(m) else cur_val:=equiv(m); cur_val_level:=tok_val; @z @x l.8390 |glue_val|, |input_line_no_code|, or |badness_code|. @d input_line_no_code=glue_val+1 {code for \.{\\inputlineno}} @d badness_code=glue_val+2 {code for \.{\\badness}} @y |glue_val|, |last_node_type_code|, |input_line_no_code|, |badness_code|, |eTeX_version_code|, or one of the other codes for \eTeX\ extensions. @d last_node_type_code=glue_val+1 {code for \.{\\lastnodetype}} @d input_line_no_code=glue_val+2 {code for \.{\\inputlineno}} @d badness_code=glue_val+3 {code for \.{\\badness}} @d eTeX_int=glue_val+4 {first of \eTeX\ codes for integers} @d eTeX_dim=eTeX_int+8 {first of \eTeX\ codes for dimensions} @d eTeX_glue=eTeX_dim+9 {first of \eTeX\ codes for glue} @d eTeX_mu=eTeX_glue+1 {first of \eTeX\ codes for muglue} @d eTeX_expr=eTeX_mu+1 {first of \eTeX\ codes for expressions} @z @x l.8425 @+else print_esc("insertpenalties"); @y @/@@/ @+else print_esc("insertpenalties"); @z @x l.8434 othercases print_esc("badness") @y @/@@/ othercases print_esc("badness") @z @x l.8457 begin if m=0 then cur_val:=dead_cycles@+else cur_val:=insert_penalties; @y begin if m=0 then cur_val:=dead_cycles @/@@/ else cur_val:=insert_penalties; @z @x l.8462 begin scan_eight_bit_int; if box(cur_val)=null then cur_val:=0 @+else cur_val:=mem[box(cur_val)+m].sc; @y begin scan_register_num; fetch_box(q); if q=null then cur_val:=0 @+else cur_val:=mem[q+m].sc; @z @x l.8487 begin if par_shape_ptr=null then cur_val:=0 @y begin if m>par_shape_loc then @ else if par_shape_ptr=null then cur_val:=0 @z @x l.8493 implemented. The reference count for \.{\\lastskip} will be updated later. @y implemented. The reference count for \.{\\lastskip} will be updated later. A final \.{\\endM} node is temporarily removed. @z @x l.8499 if cur_chr>glue_val then begin if cur_chr=input_line_no_code then cur_val:=line else cur_val:=last_badness; {|cur_chr=badness_code|} @y if m>last_node_type_code then if m>=eTeX_glue then @@; else if m>=eTeX_dim then begin case m of @/@@/ end; {there are no other cases} cur_val_level:=dimen_val; end else begin case m of input_line_no_code: cur_val:=line; badness_code: cur_val:=last_badness; @/@@/ end; {there are no other cases} @z @x l.8505 cur_val_level:=cur_chr; @y if cur_chr=last_node_type_code then begin cur_val:=int_val; if (tail=head)or(mode=0) then cur_val:=-1; end else cur_val_level:=cur_chr; @z @x l.8507 case cur_chr of @y begin if (type(tail)=math_node)and(subtype(tail)=end_M_code) then remove_end_M; case cur_chr of @z @x l.8513 end; @y end; last_node_type_code: if (type(tail)<>math_node)or(subtype(tail)<>end_M_code) then if type(tail)<=unset_node then cur_val:=type(tail)+1 else cur_val:=unset_node+2; @z @x l.8514 end {there are no other cases} @y end; {there are no other cases} if LR_temp<>null then insert_end_M; end @z @x l.8519 glue_val: if last_glue<>max_halfword then cur_val:=last_glue; @y glue_val: if last_glue<>max_halfword then cur_val:=last_glue; last_node_type_code: cur_val:=last_node_type; @z @x l.8535 begin scan_eight_bit_int; case m of @y begin if (mlo_mem_stat_max) then begin cur_val_level:=sa_type(m); if cur_val_level255 then begin find_sa_element(cur_val_level,cur_val,false); if cur_ptr=null then if cur_val_level@; @z @x l.9129 @p function str_toks(@!b:pool_pointer):pointer; @y @p @t\4@>@@;@/ function str_toks(@!b:pool_pointer):pointer; @z @x l.9154 @p function the_toks:pointer; @y @p function the_toks:pointer; label exit; @z @x l.9158 begin get_x_token; scan_something_internal(tok_val,false); @y @!c:small_number; {value of |cur_chr|} begin @;@/ get_x_token; scan_something_internal(tok_val,false); @z @x l.9172 end; @y exit:end; @z @x l.9223 othercases print_esc("jobname") @y @/@@/ othercases print_esc("jobname") @z @x l.9232 @!c:number_code..job_name_code; {desired type of conversion} @y @!c:small_number; {desired type of conversion} @z @x l.9249 end {there are no other cases} @y @/@@/ end {there are no other cases} @z @x l.9265 end {there are no other cases} @y @/@@/ end {there are no other cases} @z @x l.9374 if cur_cmd<=max_command then goto done2; @y if cur_cmd>=call then if info(link(cur_chr))=protected_token then begin cur_cmd:=relax; cur_chr:=no_expand_flag; end; if cur_cmd<=max_command then goto done2; @z @x l.9422 @p procedure read_toks(@!n:integer;@!r:pointer); @y @p procedure read_toks(@!n:integer;@!r:pointer;@!j:halfword); @z @x l.9448 loop@+ begin get_token; @y @;@/ loop@+ begin get_token; @z @x l.9500 @d if_char_code=0 { `\.{\\if}' } @y @d unless_code=32 {amount added for `\.{\\unless}' prefix} @# @d if_char_code=0 { `\.{\\if}' } @z @x l.9555 if_test: case chr_code of @y if_test: begin if chr_code>=unless_code then print_esc("unless"); case chr_code mod unless_code of @z @x l.9572 othercases print_esc("if") endcases; @y @/@@/ othercases print_esc("if") endcases; end; @z @x l.9646 done: scanner_status:=save_scanner_status; @y done: scanner_status:=save_scanner_status; if tracing_ifs>0 then show_cur_cmd_chr; @z @x l.9662 begin p:=cond_ptr; if_line:=if_line_field(p); @y begin if if_stack[in_open]=cond_ptr then if_warning; {conditionals possibly not properly nested with files} p:=cond_ptr; if_line:=if_line_field(p); @z @x l.9699 begin @;@+save_cond_ptr:=cond_ptr;this_if:=cur_chr;@/ @; @y @!is_unless:boolean; {was this if preceded by `\.{\\unless}' ?} begin if tracing_ifs>0 then if tracing_commands<=1 then show_cur_cmd_chr; @;@+save_cond_ptr:=cond_ptr; is_unless:=(cur_chr>=unless_code); this_if:=cur_chr mod unless_code;@/ @; if is_unless then b:=not b; @z @x l.9742 if_false_code: b:=false; @y if_false_code: b:=false; @/@@/ @z @x l.9781 begin scan_eight_bit_int; p:=box(cur_val); @y begin scan_register_num; fetch_box(p); @z @x l.9871 if cur_chr>if_limit then @y begin if tracing_ifs>0 then if tracing_commands<=1 then show_cur_cmd_chr; if cur_chr>if_limit then @z @x l.9882 end @y end; end @z @x l.9952 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: @y following structure: If the name contains `\.>', `\.]' or `\.:', the directory consists of all characters up to and including the final such character; otherwise the directory 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: We also take this opportunity to add some more global definitions for an upcoming section. @z @x l.9963 @!area_delimiter:pool_pointer; {the most recent `\.>' or `\.:', if any} @y @!area_delimiter:pool_pointer; {the most recent `\.>', `\.]' or `\.:', if any} @!TEX_area, @!TEX_font_area:str_number; @!inp_name, @!fonts_name : packed array[1..file_name_size] of char; @!inp_len, @!fonts_len : file_size; @!i: integer; @z @x l.9973 @d TEX_area=="TeXinputs:" @.TeXinputs@> @d TEX_font_area=="TeXfonts:" @.TeXfonts@> @y For VMS, we handle setting the names for these two logicals by defining them in the \.{CLD} file. We'll deal with getting that information later. The code that follows here will be executed after we've read the command line and \.{CLD} file and assumes that the first |inp_len| characters of |inp_name| are the value to use for |TEX_area| and the first |fonts_len| characters of |fonts_name| are the value to use for |TEX_font_area|. This code must be inserted just after \TeX\ has initialized all of its strings but before its first attempt at reading a file. I apologize for adding |i| to the globals above, by the way. There's only so much searching for a global in \.{TEX.WEB} one can take. @^frustration@> @= VAX_cli_get_value('TEXINPUTS',inp_name,inp_len); str_room(inp_len); for i:=1 to inp_len do append_char(xord[inp_name[i]]); TEX_area:=make_string; @# VAX_cli_get_value('TEXFONTS',fonts_name,fonts_len); str_room(fonts_len); for i:=1 to fonts_len do append_char(xord[fonts_name[i]]); TEX_font_area:=make_string @z @x l.9985 @ And here's the second. The string pool might change as the file name is being scanned, since a new \.{\\csname} might be entered; therefore we keep |area_delimiter| and |ext_delimiter| relative to the beginning of the current string, instead of assigning an absolute address like |pool_ptr| to them. @^system dependencies@> @p function more_name(@!c:ASCII_code):boolean; begin if c=" " then more_name:=false else begin str_room(1); append_char(c); {contribute |c| to the current string} if (c=">")or(c=":") then begin area_delimiter:=cur_length; ext_delimiter:=0; end else if (c=".")and(ext_delimiter=0) then ext_delimiter:=cur_length; more_name:=true; end; end; @y @ And here's the second. The string pool might change as the file name is being scanned, since a new \.{\\csname} might be entered; therefore we keep |area_delimiter| and |ext_delimiter| relative to the beginning of the current string, instead of assigning an absolute address like |pool_ptr| to them. @^system dependencies@> On VMS, we support wildcards in filenames. But, since the single char wildcard `\.\%' is interpreted as comment delimiter in the \TeX\ input stream, the question mark `\.?' should be used for that purpose, instead. Here, we have to convert those `\.?' characters back to `\.\%'. @p function more_name(@!c:ASCII_code):boolean; begin if c=" " then more_name:=false else begin str_room(1); {check for enough string space to add one char} if (c="?") then c:="%"; {convert `\.?' ``single char wildcard'' into `\.\%'} append_char(c); {contribute |c| to the current string} if (c=">")or(c="]")or(c=":") then begin area_delimiter:=cur_length; ext_delimiter:=0; end else if (c=".")and(ext_delimiter=0) then ext_delimiter:=cur_length; more_name:=true; end; end; @z @x l.10002 @ The third. @^system dependencies@> @p procedure end_name; begin if str_ptr+3>max_strings then overflow("number of strings",max_strings-init_str_ptr); @:TeX capacity exceeded number of strings}{\quad number of strings@> if area_delimiter=0 then cur_area:="" else begin cur_area:=str_ptr; str_start[str_ptr+1]:=str_start[str_ptr]+area_delimiter; incr(str_ptr); end; if ext_delimiter=0 then begin cur_ext:=""; cur_name:=make_string; end else begin cur_name:=str_ptr; str_start[str_ptr+1]:=str_start[str_ptr]+ext_delimiter-area_delimiter-1; incr(str_ptr); cur_ext:=make_string; end; end; @y @ The third. We have to check to see if a logical name has been referred to, and if so, translate it. @^system dependencies@> @p procedure end_name; label restart,exit; var @!t:packed array[1..file_name_size] of char; @!i:pool_pointer; @!len:signed_halfword; begin restart: if (str_pool[str_start[str_ptr]+area_delimiter]=si(":")) and @| (pool_ptr=str_start[str_ptr]+area_delimiter+1) then begin cur_area:=make_string; len:=length(cur_area)-1; {don't include the colon} for i:=1 to len do t[i]:=xchr[so(str_pool[str_start[cur_area]+i-1])]; if not translate(t,len) then begin cur_ext:=""; cur_name:=""; {silly case} return; end; flush_string; {needn't remember logical name in |cur_area|} begin_name; for i:=1 to len do if not more_name(xord[t[i]]) then goto restart; goto restart; {heavy!} end; if str_ptr+3>max_strings then overflow("number of strings",max_strings-init_str_ptr); @:TeX capacity exceeded number of strings}{\quad number of strings@> if area_delimiter=0 then cur_area:="" else begin cur_area:=str_ptr; str_start[str_ptr+1]:=str_start[str_ptr]+area_delimiter; incr(str_ptr); end; if ext_delimiter=0 then begin cur_ext:=""; cur_name:=make_string; end else begin cur_name:=str_ptr; str_start[str_ptr+1]:=str_start[str_ptr]+ext_delimiter-area_delimiter-1; incr(str_ptr); cur_ext:=make_string; end; exit: end; @z @x l.10060 @d format_default_length=20 {length of the |TEX_format_default| string} @d format_area_length=11 {length of its area part} @d format_ext_length=4 {length of its `\.{.fmt}' part} @d format_extension=".fmt" {the extension, as a \.{WEB} constant} @= @!TEX_format_default:packed array[1..format_default_length] of char; @y We want to be able to load the name of the area where formats live from an argument on the command line (actually, this will work like the \.{/TEXINPUTS} and \.{/TEXFONTS} qualifiers mentioned above, except that here, the qualifier will be read by both \TeX\ and \.{INITEX}. Also, things are a little simpler since we don't deal with the string pool ourselves. On the other hand some \.{WEB} constants will be changed to variables since we cannot know at compile time how long the argument to \.{/TEXFORMATS} will be. @./TEXFORMATS@> We also will take this opportunity to set the value for |pool_name| since we need the value given by \.{/TEXFORMATS} to construct it. @d format_name_length=9 {length of |'plain.fmt'|} @d format_ext_length=4 {length of its `\.{.fmt}' part} @d format_extension=".fmt" {the extension, as a \.{WEB} constant} @d pool_name_length==@= length@>(pool_f_name) @= @!TEX_f_name_default:packed array[1..format_name_length] of char; {abbreviated name for conflict considerations} @!TEX_format_default:packed array[1..file_name_size] of char; @!pool_name:packed array[1..file_name_size] of char; @!format_area_length:file_size; {length of the area part} @!format_default_length:integer; {length of the whole mess upon construction} @z @x l.10069 TEX_format_default:='TeXformats:plain.fmt'; @.TeXformats@> @y TEX_f_name_default:='plain.fmt'; VAX_cli_get_value('TEXFORMATS',TEX_format_default,format_area_length); pool_name:=TEX_format_default; for i:=1 to pool_name_length do pool_name[i+format_area_length]:=pool_f_name[i]; for i:=1 to format_name_length do TEX_format_default[i+format_area_length]:=TEX_f_name_default[i]; format_default_length:=format_area_length+format_name_length; @z @x l.10074 @ @= if format_default_length>file_name_size then bad:=31; @y @ There used to be a consistency check here, but since the value it checked wouldn't be set until {\it after\/} the consistency checking, we've deleted it. Besides, our code will automatically guarantee consistancy simply by the way |TEX_format_default| is defined. @z @x l.10140 @ Operating systems often make it possible to determine the exact name (and possible version number) of a file that has been opened. The following routine, which simply makes a \TeX\ 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@> @y @ The VMS operating system is able to determine the exact name (and version number) of a file that has been opened through use of the |user_action| parameter of the |open| routine. The following routine makes a \TeX\ string from the value of |last_name[1..last_length]|, which is the full specification of the most recently opened file. @^system dependencies@> @z @x l.10150 @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)or (cur_length>0) 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 @p function make_name_string:str_number; var k:1..file_name_size; {index into |name_of_file|} begin if (pool_ptr+last_length>pool_size)or(str_ptr=max_strings)or (cur_length>0) then make_name_string:="?" else begin for k:=1 to last_length do append_char(xord[last_name[k]]); make_name_string:=make_string; end; end; @z @x l.10211 @ Here is a routine that manufactures the output file names, assuming that |job_name<>0|. It ignores and changes the current settings of |cur_area| and |cur_ext|. @y @ Here is a routine that manufactures the output file names, assuming that |job_name<>0|. It ignores and changes the current settings of |cur_area| and |cur_ext|. Similarly, |pack_default_name| extracts a (possibly partial) file specification from the appropriate command line qualifier, if used, and creates a string which may be used to provide defaults for part of a file specification when opening certain auxiliary files. The routine |clear_default_name| is also provided to ensure that no defaults are applied on successive calls of |open|. @z @x l.10217 @p procedure pack_job_name(@!s:str_number); {|s = ".log"|, |".dvi"|, or |format_extension|} begin cur_area:=""; cur_ext:=s; cur_name:=job_name; pack_cur_name; end; @y @p procedure pack_job_name(@!s:str_number); {|s = ".lis"|, |".dvi"|, |".dia"|, |format_extension|} begin cur_area:=""; cur_ext:=s; cur_name:=job_name; pack_cur_name; end;@# function pack_default_name(qual : boolean; df_name : packed array [l1..u1:integer] of char; df_len : file_size) : boolean; var k : integer; begin for k:=1 to file_name_size do default_name[k] := name_of_file[k]; deflt_length:=name_length; if qual then begin name_of_file := df_name; name_length := df_len; if name_length < file_name_size then for k:=name_length+1 to file_name_size do name_of_file[k]:=' '; end; pack_default_name := qual; {Result is whether file wanted} end;@# procedure clear_default_name; var k : integer; begin for k:=1 to file_name_size do default_name[k]:=' '; end; @z @x l.10223 @ If some trouble arises when \TeX\ tries to open a file, the following routine calls upon the user to supply another file name. Parameter~|s| is used in the error message to identify the type of file; parameter~|e| is the default extension if none is given. Upon exit from the routine, variables |cur_name|, |cur_area|, |cur_ext|, and |name_of_file| are ready for another attempt at file opening. @y @ If some trouble arises when \TeX\ tries to open a file, the following routine calls upon the user to supply another file name. Parameter~|s| is used in the error message to identify the type of file; parameter~|e| is the default extension if none is given. Upon exit from the routine, variables |cur_name|, |cur_area|, |cur_ext|, and |name_of_file| are ready for another attempt at file opening. Because this procedure invokes the |print_err| macro, but does not terminate the ``error'' (by invoking |error|), we have to take special measures to prevent everything from here onwards being written to the |temp_file| used for diagnostics. It does this by resetting the |temp_file|. @z @x l.10245 clear_terminal; prompt_input(": "); @; @y clear_terminal; prompt_input(": "); @; @; @z @x l.10263 @d ensure_dvi_open==if output_file_name=0 then begin if job_name=0 then open_log_file; pack_job_name(".dvi"); while not b_open_out(dvi_file) do prompt_file_name("file name for output",".dvi"); output_file_name:=b_make_name_string(dvi_file); end @y @d ensure_dvi_open==if output_file_name=0 then begin if job_name=0 then open_log_file; pack_job_name(".dvi"); if pack_default_name(dvi_qual,dvif_name,dvif_len) then begin while not b_open_out(dvi_file) do prompt_file_name("file name for output",".dvi"); output_file_name:=b_make_name_string(dvi_file); end else output_file_name:="."; clear_default_name; end @z @x l.10278 @ The |open_log_file| routine is used to open the transcript file and to help it catch up to what has previously been printed on the terminal. @p procedure open_log_file; @y @ The |open_log_file| routine is used to open the transcript file and to help it catch up to what has previously been printed on the terminal. @p @ @# procedure open_log_file; @z @x l.10287 if job_name=0 then job_name:="texput"; @.texput@> pack_job_name(".log"); while not a_open_out(log_file) do @; log_name:=a_make_name_string(log_file); @y if job_name=0 then job_name:="texput"; @.texput@> pack_job_name(".lis"); if pack_default_name(log_qual,logf_name,logf_len) then begin while not a_open_out(log_file) do @; log_name:=a_make_name_string(log_file); end else log_name:="."; clear_default_name; open_diag_file; @z @x l.10320 prompt_file_name("transcript file name",".log"); @y prompt_file_name("transcript file name",".lis"); @z @x l.10324 begin wlog(banner); @y begin wlog(eTeX_banner); @z @x l.10331 end @y if eTeX_ex then begin; wlog_cr; wlog('entering extended mode'); end; end @z @x l.10333 @ Let's turn now to the procedure that is used to initiate file reading when an `\.{\\input}' command is being processed. @y @ Let's turn now to the procedure that is used to initiate file reading when an `\.{\\input}' command is being processed. As originally used by \TeX82 under VMS, this procedure discarded the current file name (as returned to it by the operating system) after it had been printed. However, with this version of \TeX, with its capability of writing diagnostic files for use by LSEdit's review mode, we need to be able to report the full file specifications of any files that may be involved in |show_context|; therefore, we do not call |flush_string| here. @z @x l.10336 @p procedure start_input; {\TeX\ will \.{\\input} something} label done; begin scan_file_name; {set |cur_name| to desired file name} @y Here, |x_open_in|, a modified version of |a_open_in|, is inserted. This function is located here (and not next to |a_open_in|) to eliminate the neccessity of a forward declaration for the |pack_file_name| function. The new function |x_open_in| is intended to replace the calls to |a_open_in| in the procedures |start_input| and |open_or_close_in|. It extends the file opening functionality of |a_open_in| by a second try to open the file using the |TEX_area| path specification, when no explicit path was specified. The code needed for this purpose has been moved out of the |start_input| procedure. This change unifies the file search behaviour of the \.{\\input} and \.{\\openin} commands, a useful modification of \TeX\ recommended by the new edition of the \LaTeX\ macro package. The original function |a_open_in| is still used to read the \TeX\ pool file. When |start_input| decides to initiate the transcript file (this can only happen when |start_input| is called the first time!), the |cur_name| string get updated with the contents of |last_basename|. This string is the base name part of the file opened the previous |x_open_in| call. This modification reveals the correct job name when the primary input file specification contained wildcard characters in the base name part. @p function x_open_in(var f:alpha_file):boolean; begin open(f,name_of_file,VAX_readonly,VAX_user_action:=user_reset, VAX_ignore_error); if status(f)>0 then begin if cur_area="" then begin pack_file_name(cur_name,TEX_area,cur_ext); open(f,name_of_file,VAX_readonly,VAX_user_action:=user_reset, VAX_ignore_error); end; end; if status(f)>0 then x_open_in:=false else begin reset(f,VAX_ignore_error); x_open_in:=status(f)<=0; end; end; @# procedure start_input; {\TeX\ will \.{\\input} something} label done; var k:integer; begin scan_file_name; {set |cur_name| to desired file name} @z @x l.10340 pack_cur_name; loop@+ begin begin_file_reading; {set up |cur_file| and new level of input} if a_open_in(cur_file) then goto done; if cur_area="" then begin pack_file_name(cur_name,TEX_area,cur_ext); if a_open_in(cur_file) then goto done; end; end_file_reading; {remove the level that didn't work} prompt_file_name("input file name",".tex"); @y pack_cur_name; loop@+ begin begin_file_reading; {set up |cur_file| and new level of input} if x_open_in(cur_file) then goto done; end_file_reading; {remove the level that didn't work} prompt_file_name("input file name",".tex"); @z @x l.10350 done: name:=a_make_name_string(cur_file); if job_name=0 then begin job_name:=cur_name; open_log_file; end; {|open_log_file| doesn't |show_context|, so |limit| and |loc| needn't be set to meaningful values yet} @y done: name:=a_make_name_string(cur_file); if job_name=0 then begin if last_basenam_len = length(cur_name) then begin for k:=1 to last_basenam_len do str_pool[str_start[cur_name]+k-1]:=si(xord[last_basename[k]]); end else if (pool_ptr+last_basenam_len<=pool_size)and(str_ptr<>max_strings)and (cur_length<=0) then begin for k:=1 to last_basenam_len do append_char(xord[last_basename[k]]); cur_name:=make_string; end; job_name:=cur_name; open_log_file; end; {|open_log_file| doesn't |show_context|, so |limit| and |loc| needn't be set to meaningful values yet} @z @x l.10359 if name=str_ptr-1 then {we can conserve string pool space now} begin flush_string; name:=cur_name; end; @y @z @x l.10945 if not b_open_in(tfm_file) then abort; @y if not b_open_in(tfm_file) then abort; tfm_count:=0; @z @x l.10956 @d fget==get(tfm_file) @d fbyte==tfm_file^ @y @d fget==begin incr(tfm_count); if tfm_count=VAX_block_length then begin get(tfm_file,VAX_ignore_error); tfm_count:=0; end end @d fbyte==tfm_file^[tfm_count] @z @x l.11161 if eof(tfm_file) then abort; @y if status(tfm_file)<>0 then abort; @z @x l.11263 begin if tracing_lost_chars>0 then @y var old_setting: integer; {saved value of |tracing_online|} begin if tracing_lost_chars>0 then begin old_setting:=tracing_online; if eTeX_ex and(tracing_lost_chars>1) then tracing_online:=1; @z @x l.11270 end; @y tracing_online:=old_setting; end; end; @z @x l.11855 @ Some systems may find it more efficient to make |dvi_buf| a |packed| array, since output of four bytes at once may be facilitated. @^system dependencies@> @= @!dvi_buf:array[dvi_index] of eight_bits; {buffer for \.{DVI} output} @y @ Some systems may find it more efficient to make |dvi_buf| a |packed| array, since output of four bytes at once may be facilitated. On VMS, we get even more complicated than that, for efficiency. @d dvi_buf==d_buffer.b {buffer for \.{DVI} output} @= @!d_buffer: [VAX_volatile,VAX_aligned(9)] packed record case boolean of false: (@!b:packed array[dvi_index] of eight_bits); true: (@!l:byte_block; @!r:byte_block; @!j:eight_bits); end; @z @x l.11875 @ The actual output of |dvi_buf[a..b]| to |dvi_file| is performed by calling |write_dvi(a,b)|. For best results, this procedure should be optimized to run as fast as possible on each particular system, since it is part of \TeX's inner loop. It is safe to assume that |a| and |b+1| will both be multiples of 4 when |write_dvi(a,b)| is called; therefore it is possible on many machines to use efficient methods to pack four bytes per word and to output an array of words with one system call. @^system dependencies@> @^inner loop@> @^defecation@> @p procedure write_dvi(@!a,@!b:dvi_index); var k:dvi_index; begin for k:=a to b do write(dvi_file,dvi_buf[k]); end; @y @ The actual output of |dvi_buf[a..b]| to |dvi_file| is performed by calling |write| on the other variant of the |dvi_buf| record. Thus, we have to be sure that things line up properly, by padding out with ``signature'' bytes. @^system dependencies@> @^inner loop@> @^defecation@> @= if dvi_buf_size<>2*VAX_block_length then bad:=223; @z @x l.11900 begin write_dvi(0,half_buf-1); dvi_limit:=half_buf; @y begin if dvi_qual then write(dvi_file,d_buffer.l); dvi_limit:=half_buf; @z @x l.11903 else begin write_dvi(half_buf,dvi_buf_size-1); dvi_limit:=dvi_buf_size; @y else begin if dvi_qual then write(dvi_file,d_buffer.r); dvi_limit:=dvi_buf_size; @z @x l.11912 if dvi_limit=half_buf then write_dvi(half_buf,dvi_buf_size-1); if dvi_ptr>0 then write_dvi(0,dvi_ptr-1) @y if (dvi_limit=half_buf) and dvi_qual then write(dvi_file,d_buffer.r); for k:=dvi_ptr to dvi_buf_size do dvi_buf[k]:=223; if (dvi_ptr>0) and dvi_qual then write(dvi_file,d_buffer.l); if (dvi_ptr>half_buf) and dvi_qual then write(dvi_file,d_buffer.r); @z @x l.12238 this is essentially the depth of |push| commands in the \.{DVI} output. @y this is essentially the depth of |push| commands in the \.{DVI} output. For mixed direction text (\TeXXeT) the current text direction is called |cur_dir|. As the box being shipped out will never be used again and soon be recycled, we can simply reverse any R-text (i.e., right-to-left) segments of hlist nodes as well as complete hlist nodes embedded in such segments. Moreover this can be done iteratively rather than recursively. There are, however, two complications related to leaders that require some additional bookkeeping: (1)~One and the same hlist node might be used more than once (but never inside both L- and R-text); and (2)~leader boxes inside hlists must be aligned with respect to the left edge of the original hlist. A math node is changed into a kern node whenever the text direction remains the same, it is replaced by an |edge_node| if the text direction changes; the subtype of an an |hlist_node| inside R-text is changed to |reversed| once its hlist has been reversed. @!@^data structure assumptions@> @z @x l.12240 @d synch_h==if cur_h<>dvi_h then @y @d reversed=min_quarterword+1 {subtype for an |hlist_node| whose hlist has been reversed} @d dlist=min_quarterword+2 {subtype for an |hlist_node| from display math mode} @d left_to_right=0 @d right_to_left=1 @d reflected==1-cur_dir {the opposite of |cur_dir|} @# @d synch_h==if cur_h<>dvi_h then @z @x l.12300 @!g_order: glue_ord; {applicable order of infinity for glue} @y @z @x l.12308 @!edge:scaled; {left edge of sub-box, or right edge of leader space} @y @!edge:scaled; {right edge of sub-box or leader space} @!prev_p:pointer; {one step behind |p|} @z @x l.12309 @!glue_temp:real; {glue value before rounding} begin this_box:=temp_ptr; g_order:=glue_order(this_box); @y begin this_box:=temp_ptr; @z @x l.12315 save_loc:=dvi_offset+dvi_ptr; base_line:=cur_v; left_edge:=cur_h; @y save_loc:=dvi_offset+dvi_ptr; base_line:=cur_v; prev_p:=this_box+list_offset; if eTeX_ex then begin @; if subtype(this_box)=dlist then if cur_dir=right_to_left then begin cur_dir:=left_to_right; cur_h:=cur_h-width(this_box); end else subtype(this_box):=min_quarterword; if (cur_dir=right_to_left)and(subtype(this_box)<>reversed) then @; end; left_edge:=cur_h; @z @x l.12318 prune_movements(save_loc); @y if eTeX_ex then begin @; if subtype(this_box)=dlist then cur_dir:=right_to_left; end; prune_movements(save_loc); @z @x l.12337 p:=link(p); @y prev_p:=link(prev_p); {N.B.: not |prev_p:=p|, |p| might be |lig_trick|} p:=link(p); @z @x l.12362 kern_node,math_node:cur_h:=cur_h+width(p); @y kern_node:cur_h:=cur_h+width(p); math_node:begin if eTeX_ex then @; cur_h:=cur_h+width(p); end; @z @x l.12364 othercases do_nothing @y @/@@; othercases do_nothing @z @x l.12369 next_p:p:=link(p); @y next_p:prev_p:=p; p:=link(p); @z @x l.12376 temp_ptr:=p; edge:=cur_h; @y temp_ptr:=p; edge:=cur_h+width(p); if cur_dir=right_to_left then cur_h:=edge; @z @x l.12379 cur_h:=edge+width(p); cur_v:=base_line; @y cur_h:=edge; cur_v:=base_line; @z @x l.12401 begin if g_sign=stretching then begin if stretch_order(g)=g_order then begin vet_glue(float(glue_set(this_box))*stretch(g)); @^real multiplication@> rule_wd:=rule_wd+round(glue_temp); end; end else if shrink_order(g)=g_order then begin vet_glue(float(glue_set(this_box))*shrink(g)); rule_wd:=rule_wd-round(glue_temp); end; end; @y add_glue(rule_wd); @z @x l.12428 edge:=cur_h+rule_wd; lx:=0; @y if cur_dir=right_to_left then cur_h:=cur_h-10; edge:=cur_h+rule_wd; lx:=0; @z @x l.12434 cur_h:=edge-10; goto next_p; @y if cur_dir=right_to_left then cur_h:=edge else cur_h:=edge-10; goto next_p; @z @x l.12473 synch_h; save_h:=dvi_h; temp_ptr:=leader_box; @y synch_h; save_h:=dvi_h; temp_ptr:=leader_box; if cur_dir=right_to_left then cur_h:=cur_h+leader_wd; @z @x l.12489 @!g_order: glue_ord; {applicable order of infinity for glue} @y @z @x l.12498 @!glue_temp:real; {glue value before rounding} begin this_box:=temp_ptr; g_order:=glue_order(this_box); @y begin this_box:=temp_ptr; @z @x l.12544 cur_h:=left_edge+shift_amount(p); {shift the box right} @y if cur_dir=right_to_left then cur_h:=left_edge-shift_amount(p) else cur_h:=left_edge+shift_amount(p); {shift the box right} @z @x l.12556 begin synch_h; synch_v; dvi_out(put_rule); dvi_four(rule_ht); dvi_four(rule_wd); @y begin if cur_dir=right_to_left then cur_h:=cur_h-rule_wd; synch_h; synch_v; dvi_out(put_rule); dvi_four(rule_ht); dvi_four(rule_wd); cur_h:=left_edge; @z @x l.12564 begin if g_sign=stretching then begin if stretch_order(g)=g_order then begin vet_glue(float(glue_set(this_box))*stretch(g)); @^real multiplication@> rule_ht:=rule_ht+round(glue_temp); end; end else if shrink_order(g)=g_order then begin vet_glue(float(glue_set(this_box))*shrink(g)); rule_ht:=rule_ht-round(glue_temp); end; end; @y add_glue(rule_ht); @z @x l.12619 begin cur_h:=left_edge+shift_amount(leader_box); synch_h; save_h:=dvi_h;@/ @y begin if cur_dir=right_to_left then cur_h:=left_edge-shift_amount(leader_box) else cur_h:=left_edge+shift_amount(leader_box); synch_h; save_h:=dvi_h;@/ @z @x l.12656 @; @y @; if eTeX_ex then @; @z @x l.12747 print_nl("Output written on "); slow_print(output_file_name); @.Output written on x@> print(" ("); print_int(total_pages); print(" page"); if total_pages<>1 then print_char("s"); print(", "); print_int(dvi_offset+dvi_ptr); print(" bytes)."); b_close(dvi_file); @y if dvi_qual then begin b_close(dvi_file); print_nl("Output written on "); slow_print(output_file_name); @.Output written on x@> end else print_nl("NO output file --- would have had"); print(" ("); print_int(total_pages); print(" page"); if total_pages<>1 then print_char("s"); print(", "); print_int(dvi_offset+dvi_ptr); print(" bytes)."); @z @x l.12876 h:=0; @; @y h:=0; @; if TeXXeT_en then @; @z @x l.12886 exit: hpack:=r; @y exit: if TeXXeT_en then @; hpack:=r; @z @x l.12910 kern_node,math_node: x:=x+width(p); @y kern_node: x:=x+width(p); math_node: begin x:=x+width(p); if TeXXeT_en then @; end; @z @x l.13480 \TeX's \.{\\left} and \.{\\right}. The |nucleus| of such noads is @y \TeX's \.{\\left} and \.{\\right} as well as \eTeX's \.{\\middle}. The |nucleus| of such noads is @z @x l.13497 @d delimiter==nucleus {|delimiter| field in left and right noads} @y @d delimiter==nucleus {|delimiter| field in left and right noads} @d middle_noad==1 {|subtype| of right noad representing \.{\\middle}} @z @x l.13670 right_noad: begin print_esc("right"); print_delimiter(nucleus(p)); end; end; if subtype(p)<>normal then if subtype(p)=limits then print_esc("limits") else print_esc("nolimits"); if type(p)normal then if subtype(p)=limits then print_esc("limits") else print_esc("nolimits"); print_subsidiary_data(nucleus(p),"."); end; @z @x l.14268 done_with_noad: r:=q; r_type:=type(r); @y done_with_noad: r:=q; r_type:=type(r); if r_type=right_noad then begin r_type:=left_noad; cur_style:=style; @; end; @z @x l.14929 r_type:=t; @y if type(q)=right_noad then t:=open_noad; r_type:=t; @z @x l.14970 begin if style; @z @x l.15461 begin restart: align_state:=1000000; @; @y begin restart: align_state:=1000000; repeat get_x_or_protected; until cur_cmd<>spacer; @z @x l.15572 align_state:=1000000; @; @y align_state:=1000000; repeat get_x_or_protected; until cur_cmd<>spacer; @z @x l.15834 begin type(q):=hlist_node; width(q):=width(p); @y begin type(q):=hlist_node; width(q):=width(p); if nest[nest_ptr-1].mode_field=mmode then subtype(q):=dlist; {for |ship_out|} @z @x l.15852 n:=span_count(r); t:=width(s); w:=t; u:=hold_head; @y n:=span_count(r); t:=width(s); w:=t; u:=hold_head; subtype(r):=min_quarterword; {for |ship_out|} @z @x l.15975 There is one explicit parameter: |final_widow_penalty| is the amount of additional penalty to be inserted before the final line of the paragraph. @y There is one explicit parameter: |d| is true for partial paragraphs preceding display math mode; in this case the amount of additional penalty inserted before the final line is |display_widow_penalty| instead of |widow_penalty|. @z @x l.16002 procedure line_break(@!final_widow_penalty:integer); @y procedure line_break(@!d:boolean); @z @x l.16012 end; @y end; @# @t\4@>@ @z @x l.16032 link(tail):=new_param_glue(par_fill_skip_code); @y link(tail):=new_param_glue(par_fill_skip_code); last_line_fill:=link(tail); @z @x l.16097 @d active_node_size=3 {number of words in active nodes} @y @d active_node_size_normal=3 {number of words in normal active nodes} @z @x l.16260 background[6]:=shrink(q)+shrink(r); @y background[6]:=shrink(q)+shrink(r); @; @z @x l.16311 label exit,done,done1,continue,deactivate; @y label exit,done,done1,continue,deactivate,found,not_found; @z @x l.16603 total_demerits(q):=minimal_demerits[fit_class]; @y total_demerits(q):=minimal_demerits[fit_class]; if do_last_line_fit then @; @z @x l.16616 print(" t="); print_int(total_demerits(q)); @y print(" t="); print_int(total_demerits(q)); if do_last_line_fit then @; @z @x l.16715 if (b>inf_bad)or(pi=eject_penalty) then @y if do_last_line_fit then @; found: if (b>inf_bad)or(pi=eject_penalty) then @z @x l.16739 begin b:=0; fit_class:=decent_fit; {infinite stretch} @y begin if do_last_line_fit then begin if cur_p=null then {the