@x Tell WEAVE to print only the changes: \pageno=\contentspagenumber \advance\pageno by 1 @y we insert stuff that causes only the changes to be TeXed \def\botofcontents{\vfill \centerline{(This listing shows the changes for {\sc WAITS} only)}} \pageno=\contentspagenumber \advance\pageno by 1 \let\maybe=\iffalse @z @x Changes for debugging: @d debug==@{ {change this to `$\\{debug}\equiv\null$' when debugging} @d gubed==@t@>@} {change this to `$\\{gubed}\equiv\null$' when debugging} @y (normally it's not changed) @d debug==@{ {change this to `$\\{debug}\equiv\null$' when debugging} @d gubed==@t@>@} {change this to `$\\{gubed}\equiv\null$' when debugging} @z @x Changes for statistics-gathering: @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 (normally we gather them, to see if TeX is getting too big) @d stat== {change this to `$\\{stat}\equiv\.{@@\}}$' when not gathering usage statistics} @d tats== {change this to `$\\{tats}\equiv\.{@@\}}$' when not gathering usage statistics} @z @x Changes to the compiler directives: @{@&$C-,A+,D-@} {no range check, catch arithmetic overflow, no debug overhead} @!debug @{@&$C+,D+@}@+ gubed {but turn everything on when debugging} @y @{@&$C-,A+,D-,W+@}{no range check, catch arithmetic overflow, no debug overhead} @!debug @{@&$C+,D+,W+@}@+ gubed {but turn everything on when debugging} {the `|W+|' switch catches more syntax errors} @z @x System-dependent character set change: (The present file \.{WEAVE.WEB} does not contain any of the non-ASCII characters, because it is intended to be used with all implementations of \.{WEB}. It was originally created on a Stanford system that has a convenient extended character set, then ``sanitized'' by applying another program that transliterated all of the non-standard characters into standard equivalents.) @= for i1 to @'37 do xchr[i]' '; @y The code shown here is intended to be used on the Stanford {\sc SAIL} system, and at other installations like CMU and ISI where essentially the same extended character set is used. The fact that {\sc SAIL} has |'}'| in the wrong place turns out to cause no difficulty in this case. @= for i1 to @'37 do xchr[i]chr(i); xchr[left_arrow]chr(@'137); xchr[not_equal]chr(@'33); xchr[@'33]chr(@'176); @z @x Opening the input files: @p procedure open_input; {prepare to read |web_file| and |change_file|} begin reset(web_file); reset(change_file); end; @y We open the files in a special mode that allows us to distinguish |form_feed| from |carriage_return|. Local scuttlebutt says that nine buffers gives best results at {\mc SAIL}. @p procedure open_input; {prepare to read |web_file| and |change_file|} begin reset(web_file,'','/E/N:9'); reset(change_file,'','/E/N:9'); end; @z @x Opening |tex_file|: rewrite(tex_file); @y rewrite(tex_file,'','/N:9'); @z @x Array input for efficiency: @=@!buffer: array[0..long_buf_size] of ASCII_code; @y We use a special feature of the local \PASCAL\ that reads text into another array |aux_buffer| first, thus saving a bunch of procedure-call overhead. @=@!buffer: array[0..long_buf_size] of ASCII_code; @!aux_buffer:array[0..buf_size] of text_char; @^system dependencies@> @z @x New input_ln function: @p function input_ln(var f:text_file):boolean; {inputs a line or returns |false|} var final_limit:0..buf_size; {|limit| without trailing blanks} begin limit0; final_limit0; if eof(f) then input_lnfalse else begin while not eoln(f) do begin buffer[limit]xord[f^]; get(f); incr(limit); if buffer[limit-1]" " then final_limitlimit; if limit=buf_size then begin while not eoln(f) do get(f); decr(limit); {keep |buffer[buf_size]| empty} if final_limit>limit then final_limitlimit; print_nl('! Input line too long'); loc0; error; @.Input line too long@> end; end; read_ln(f); limitfinal_limit; input_lntrue; end; end; @y @p function input_ln(var f:text_file):boolean; {inputs a line or returns |false|} label restart,done; var n: integer; {the number of characters input by Hedrick's extended |read|} @!k:0..buf_size; {index into the buffers} begin restart: if eof(f) then begin limit0; input_lnfalse; end else begin read(f,aux_buffer:n); if (line=1)(n=29)(aux_buffer[0]='C')(aux_buffer[8]=chr(@'26)) then begin while (f^chr(form_feed))(not eof(f)) do begin read_ln(f); read(f,aux_buffer:n); {skip file directory page} end; end; if n0 then for k0 to limit-1 do buffer[k]xord[aux_buffer[k]] else if f^=chr(form_feed) then begin line((line div @'200000)+1)*@'200000+1; read_ln(f); goto restart; end; end else begin limitbuf_size-1; for k0 to limit-1 do buffer[k]xord[aux_buffer[k]]; print_nl('! Input line too long'); loc0; error; @.Input line too long@> while not eoln(f) do read(f,aux_buffer); end; loop@+ begin if limit=0 then goto done; if buffer[limit-1]" " then goto done; decr(limit); end; done: read_ln(f); input_lntrue; end; end; @^system dependencies@> @z @x Putting the file page number into error messages: print_ln('l.', line:1, ')'); @y print_ln('p.',1+(line div @'200000):1,',l.', line mod @'200000:1, ')'); @z @x New procedure write_end_of_page: \TeX\ control sequence. @y \TeX\ control sequence. The |write_end_of_page| routine is used to break the output into pages for ease in editing. @z @x @d out5==@+begin oot5 @y @d out5==@+begin oot5 @p procedure write_end_of_page; begin if out_ptr>0 then flush_buffer(out_ptr,false); write(tex_file,xchr[form_feed]); {write a page mark} out_line((out_line div @'200000)+1)*@'200000+1; end; @^system dependencies@> @z @x Page number on warning message: begin print_nl('! Line had to be broken (output l.',out_line:1); @.Line had to be broken@> @y begin print_nl('! Line had to be broken (output p.', @.Line had to be broken@> 1+(out_line div @'200000):1,',l.',out_line mod @'200000:1); @^system dependencies@> @z @x Page number on trace output header: begin print_nl('Tracing after l.',line:1,':'); mark_harmless; @y begin print_nl('Tracing after p.',1+(line div @'200000):1, ',l.',line mod @'200000:1,':'); @^system dependencies@> @z @x Calling write_end_of_page in Phase II: @= out("\"); if buffer[loc-1]"*" then out("M") @.\\M@> else begin out("N"); print('*',module_count:1); @.\\N@> update_terminal; {print a progress report} end; out_mod(module_count); out2(".")(" ") @y @= if buffer[loc-1]"*" then out2("\")("M") @.\\M@> else begin write_end_of_page; out2("\")("N"); @.\\N@> print('*',module_count:1); update_terminal; {print a progress report} end; out_mod(module_count); out2(".")(" ") @^system dependencies@> @z @x Calling write_end_of_page in Phase III: finish_line; out4("\")("i")("n")("x"); finish_line; @.\\inx@> @; @; @y finish_line; write_end_of_page; out4("\")("i")("n")("x"); finish_line; @.\\inx@> @; @; write_end_of_page; @^system dependencies@> @z