[comp.sources.atari.st] v02i037: texchang -- Change files for BibTeX, Tangle, and Weave

koreth@ssyx.ucsc.edu (Steven Grimm) (04/14/89)

Submitted-by: csrobe@cs.wm.edu (Chip Roberson)
Posting-number: Volume 2, Issue 37
Archive-name: texchang

[I'm still not too sure why this is needed, but what the heck. -sg]

The TeX system comes with a 'relatively' generic base of programs written
in Web that operate on some real or imaginary computer.  To compile these
programs for your system, you find an appropriate 'changefile' that describes
the system dependecies for your machine and include it into make.  This is
just the way god-emperor Knuth decided to do it.  It truly is a tangled
web that he has weaved.  ;-)

Anyway, anyone who wants to build a version of BibTeX, Tangle, and Weave
can get the original from the standard TeX archives at score and then
include their changefile and compile with their favorite Pascal compiler.
OR, they can wait until someone does the web2c conversion and creates
the appropriate changes there.  This seemed to be the quickest way
to get these programs to those who needed them.

#!/bin/sh
# shar:	Shell Archiver  (v1.22)
#
#	Run the following text with /bin/sh to create:
#	  bibtex
#	  tangle
#	  weave
#
sed 's/^X//' << 'SHAR_EOF' > bibtex &&
XBibTeX change file for the Atari ST
XAuthor: Nico Poppelier.
XDate  : December 27, 1988.
X
XSince the Prospero Pascal compiler strictly adheres to the
XISO Pascal standard (level 0), all occurrences of ':0' or ': 0'
Xin write and writeln statements have to be replaced by
X':1' and ': 1', respectively.
X(This was reported to Oren Patashnik, see TeXhax of Dec 88).
X
X@x
X@d banner=='This is BibTeX, Version 0.99c' {printed when the program starts}
X@y
X@d banner=='This is BibTeX, Version 0.99c for the Atari ST' {printed when the pr
X   ogram starts}
X@z
X
X@x
X@d term_out == tty
X@d term_in == tty
X@y
XFiles 'input' and 'output' are used for terminal input and output.
XProspero Pascal for the Atari ST requires us to mention
X|input| and |output| in the program header.
X@d term_out == output
X@d term_in == input
X@z
X
X@x
X@d debug == @{          { remove the `|@{|' when debugging }
X@d gubed == @t@>@}      { remove the `|@}|' when debugging }
X@y
X@d debug ==             { we are debugging }
X@d gubed == @t@>
X@z
X
X@x
X@d stat == @{           { remove the `|@{|' when keeping statistics }
X@d tats == @t@>@}       { remove the `|@}|' when keeping statistics }
X@y
X@d stat ==              { we are keeping statistics }
X@d tats == @t@>
X@z
X
X@x
X@d othercases == others: {default for cases not listed explicitly}
X@y
X@d othercases == otherwise {default for cases not listed explicitly}
X@z
X
X@x
Xprogram BibTEX;                 {all files are opened dynamically}
X@y
Xprogram BibTEX(@!input,@!output); {these files have to be specified here}
X@z
X
X@x
X@<Compiler directives@>=
X@{@&$C-,A+,D-@}  {no range check, catch arithmetic overflow, no debug overhead}
X@!debug @{@&$C+,D+@}@+ gubed  {but turn everything on when debugging}
X@y
XOn the Atari ST, things are different: Prospero Pascal does
Xnot allow in-comment directives
X@<Compiler directives@>=
X@z
X
X@x
X    write_ln (term_out,bad:0,' is a bad bad');
X@y
X    write_ln (term_out,bad:1,' is a bad bad');
X@z
X
X@x
X@!alpha_file=packed file of text_char;  {files that contain textual data}
X@y
X@!alpha_file=text;      {files that contain textual data}
X@z
X
X@x
X@d reset_OK(#)==erstat(#)=0
X@d rewrite_OK(#)==erstat(#)=0
X@y
X@d reset_OK(#)==fstat(#)
X@d rewrite_OK(#)==fstat(#)
X@z
X
X@x
Xfunction erstat(var f:file):integer; extern; {in the runtime library}
X@y
X@z
X
X@x
Xbegin reset(f,name_of_file,'/O'); a_open_in:=reset_OK(f);
X@y
Xbegin assign(f,name_of_file);
X      reset(f); a_open_in:=reset_OK(name_of_file);
X@z
X
X@x
Xbegin rewrite(f,name_of_file,'/O'); a_open_out:=rewrite_OK(f);
X@y
Xbegin assign(f,name_of_file);
X      rewrite(f); a_open_out:=rewrite_OK(name_of_file);
X@z
X
X@x
Xprocedure a_close(var f:alpha_file);  {close a text file}
Xbegin close(f);
X@y
Xprocedure a_close(var f:alpha_file);  {close a text file}
Xbegin close(f, true);
X@z
X
X@x
X@d overflow(#)==begin           {fatal error---close up shop}
X                print_overflow;
X                print_ln(#:0);
X@y
X@d overflow(#)==begin           {fatal error---close up shop}
X                print_overflow;
X                print_ln(#:1);
X@z
X
X@x
X    confusion ('Illegal string number:',s:0);
X@y
X    confusion ('Illegal string number:',s:1);
X@z
X
X@x
Xprint ('---line ',cur_aux_line:0,' of file ');
X@y
Xprint ('---line ',cur_aux_line:1,' of file ');
X@z
X
X@x
Xprint ('A level-',aux_ptr:0,' auxiliary file: ');
X@y
Xprint ('A level-',aux_ptr:1,' auxiliary file: ');
X@z
X
X@x
Xprint ('--line ',bst_line_num:0,' of file ');
X@y
Xprint ('--line ',bst_line_num:1,' of file ');
X@z
X
X@x
X  trace_pr_ln (' is an integer literal with value ',token_value:0);
X@y
X  trace_pr_ln (' is an integer literal with value ',token_value:1);
X@z
X
X@x
X    print (single_ptr + wiz_def_ptr : 0,': ');
X@y
X    print (single_ptr + wiz_def_ptr : 1,': ');
X@z
X
X@x
Xprint ('--line ',bib_line_num:0,' of file ');
X@y
Xprint ('--line ',bib_line_num:1,' of file ');
X@z
X
X@x
X    print ('Database file #',bib_ptr+1:0,': ');
X@y
X    print ('Database file #',bib_ptr+1:1,': ');
X@z
X
X@x
X    print_ln (total_fields:0,' fields:');
X@y
X    print_ln (total_fields:1,' fields:');
X@z
X
X@x
Xbib_err ('Your field is more than ',buf_size:0,' characters');
X@y
Xbib_err ('Your field is more than ',buf_size:1,' characters');
X@z
X
X@x
X    bib_err ('You''ve exceeded ',max_bib_files:0,' preamble commands');
X@y
X    bib_err ('You''ve exceeded ',max_bib_files:1,' preamble commands');
X@z
X
X@x
X  trace_pr_ln ('Sorting ',left_end:0,' through ',right_end:0);
X@y
X  trace_pr_ln ('Sorting ',left_end:1,' through ',right_end:1);
X@z
X
X@x
X    stk_int : trace_pr_ln (lit_stack[lit_stk_ptr]:0);
X@y
X    stk_int : trace_pr_ln (lit_stack[lit_stk_ptr]:1);
X@z
X
X@x
X    stk_int : print (stk_lt:0,' is an integer literal');
X@y
X    stk_int : print (stk_lt:1,' is an integer literal');
X@z
X
X@x
X    stk_int : print_ln (stk_lt:0);
X@y
X    stk_int : print_ln (stk_lt:1);
X@z
X
X@x
X    print_ln ('ptr=',lit_stk_ptr:0,', stack=');
X@y
X    print_ln ('ptr=',lit_stk_ptr:1,', stack=');
X@z
X
X@x
X      print_ln ('Pointer is ',str_ptr:0,' but should be ',cmd_str_ptr:0);
X@y
X      print_ln ('Pointer is ',str_ptr:1,' but should be ',cmd_str_ptr:1);
X@z
X
X@x
X        bst_string_size_exceeded (ent_str_size:0,', the entry');
X@y
X        bst_string_size_exceeded (ent_str_size:1,', the entry');
X@z
X
X@x
X            bst_string_size_exceeded (glob_str_size:0,', the global');
X@y
X            bst_string_size_exceeded (glob_str_size:1,', the global');
X@z
X
X@x
X        print ('There aren''t ',pop_lit2:0,' names in "');
X@y
X        print ('There aren''t ',pop_lit2:1,' names in "');
X@z
X
X@x
X                print ('Name ',pop_lit2:0,' in "');
X@y
X                print ('Name ',pop_lit2:1,' in "');
X@z
X
X@x
X    print ('Too many commas in name ',pop_lit2:0,' of "');
X@y
X    print ('Too many commas in name ',pop_lit2:1,' of "');
X@z
X
X@x
Xprint ('Name ',pop_lit2:0,' of "');
X@y
Xprint ('Name ',pop_lit2:1,' of "');
X@z
X
X@x
X    bst_ex_warn (pop_lit1:0,' isn''t valid ASCII');
X@y
X    bst_ex_warn (pop_lit1:1,' isn''t valid ASCII');
X@z
X
X@x
X    print ('Aborted at line ',bib_line_num:0,' of file ');
X@y
X    print ('Aborted at line ',bib_line_num:1,' of file ');
X@z
X
X@x
X    trace_pr_ln ('The ',num_bib_files:0,' database files are');
X@y
X    trace_pr_ln ('The ',num_bib_files:1,' database files are');
X@z
X
X@x
X    trace_pr ('all_marker=',all_marker:0,', ');
X@y
X    trace_pr ('all_marker=',all_marker:1,', ');
X@z
X
X@x
X    trace_pr_ln ('old_num_cites=',old_num_cites:0)
X@y
X    trace_pr_ln ('old_num_cites=',old_num_cites:1)
X@z
X
X@x
Xtrace_pr ('The ',num_cites:0);
X@y
Xtrace_pr ('The ',num_cites:1);
X@z
X
X@x
Xif (type_list[cite_ptr] = undefined) then
X    undefined : trace_pr ('unknown')
X@y
Xif (type_list[cite_ptr] = undefined) then
X    trace_pr ('unknown')
X@z
X
X@x
X        trace_pr (' ',entry_ints[int_ent_ptr]:0);
X@y
X        trace_pr (' ',entry_ints[int_ent_ptr]:1);
X@z
X
X@x
X            trace_pr_ln (wiz_fn_ptr:0,'--end-of-def--')
X@y
X            trace_pr_ln (wiz_fn_ptr:1,'--end-of-def--')
X@z
X
X@x
X            trace_pr (wiz_fn_ptr:0,'  quote_next_function    ')
X@y
X            trace_pr (wiz_fn_ptr:1,'  quote_next_function    ')
X@z
X
X@x
X            trace_pr (wiz_fn_ptr:0,'  `');
X@y
X            trace_pr (wiz_fn_ptr:1,'  `');
X@z
X
X@x
Xstat_pr ('You''ve used ',num_cites:0);
X@y
Xstat_pr ('You''ve used ',num_cites:1);
X@z
X
X@x
Xstat_pr_ln ('            ',wiz_def_ptr:0,' wiz_defined-function locations,');
X@y
Xstat_pr_ln ('            ',wiz_def_ptr:1,' wiz_defined-function locations,');
X@z
X
X@x
Xstat_pr_ln ('            ',str_ptr:0,' strings with ',str_start[str_ptr]:0,
X@y
Xstat_pr_ln ('            ',str_ptr:1,' strings with ',str_start[str_ptr]:1,
X@z
X
X@x
Xstat_pr_ln ('and the built_in function-call counts, ', total_ex_count:0,
X@y
Xstat_pr_ln ('and the built_in function-call counts, ', total_ex_count:1,
X@z
X
X@x
X    stat_pr_ln (' -- ',execution_count[blt_in_ptr]:0);
X@y
X    stat_pr_ln (' -- ',execution_count[blt_in_ptr]:1);
X@z
X
X@x
X                          print_ln ('(There were ',err_count:0,' warnings)');
X@y
X                          print_ln ('(There were ',err_count:1,' warnings)');
X@z
X
X@x
X                        print_ln ('(There were ',err_count:0,
X@y
X                        print_ln ('(There were ',err_count:1,
X@z
X
X
SHAR_EOF
chmod 0600 bibtex || echo "restore of bibtex fails"
sed 's/^X//' << 'SHAR_EOF' > tangle &&
XTANGLE change file for the Atari ST
XAuthor: Nico Poppelier.
XDate  : December 30, 1988.
X
XDue to an error in the Prospero Pascal compiler the control variable
Xof the FOR loops in sections 138, 182, and 184 are judged 'insecure',
Xi.e., it looks as if they are modified by a routine.
XTo avoid this 'error' a new loop variable k is introduced.
X
X@x
X\pageno=\contentspagenumber \advance\pageno by 1
X@y
X\pageno=\contentspagenumber \advance\pageno by 1
X% \let\maybe=\iffalse
X% \def\title{TANGLE changes for the Atari ST}
X\def\title{TANGLE, Version 2.8 for the Atari ST}
X@z
X
X@x
X@d banner=='This is TANGLE, Version 2.8'
X@y
X@d banner=='This is TANGLE, Version 2.8 for the Atari ST'
X@z
X
X@x
Xand the string pool output goes to file |pool|.
X@y
Xand the string pool output goes to file |pool|.
XProspero Pascal for the Atari ST requires us to mention
X|input| and |output| in the program header, too.
XThey are used for terminal input and output.
X@z
X
X@x
Xprogram TANGLE(@!web_file,@!change_file,@!Pascal_file,@!pool);
X@y
Xprogram TANGLE(@!input,@!output,
X               @!web_file,@!change_file,@!Pascal_file,@!pool);
X@z
X
X@x
Xprocedure initialize;
X@y
Xprocedure wait(delay:real); external; {from doslib}@/
Xprocedure initialize;
X@z
X
X@x
X@d debug==@{ {change this to `$\\{debug}\equiv\null$' when debugging}
X@d gubed==@t@>@} {change this to `$\\{gubed}\equiv\null$' when debugging}
X@y
X@d debug== {we are debugging}
X@d gubed==
X@z
X
X@x
X@d stat==@{ {change this to `$\\{stat}\equiv\null$'
X  when gathering usage statistics}
X@d tats==@t@>@} {change this to `$\\{tats}\equiv\null$'
X  when gathering usage statistics}
X@y
X@d stat== {we are gathering usage statistics}
X@d tats==
X@z
X
X@x
X@<Compiler directives@>=
X@{@&$C-,A+,D-@} {no range check, catch arithmetic overflow, no debug overhead}
X@!debug @{@&$C+,D+@}@+ gubed {but turn everything on when debugging}
X@y
XOn the Atari ST, things are different:
XProspero Pascal does not allow in-comment directives
X@<Compiler directives@>=
X@z
X
X@x
X@d othercases == others: {default for cases not listed explicitly}
X@y
X@d othercases == otherwise {default for cases not listed explicitly}
X@z
X
X@x
X@!max_toks=50000; {|1/zz| times the number of bytes in compressed \PASCAL\ code;
X
X  must be less than 65536}
X@y
X@!max_toks=51000; {|1/zz| times the number of bytes in compressed \PASCAL\ code;
X
X  must be less than 65536}
X@z
X
X@x
X@!text_file=packed file of text_char;
X@y
X@!text_file=text;
X@z
X
X@x
X@d print(#)==write(term_out,#) {`|print|' means write on the terminal}
X@y
X@d term_in==input
X@d term_out==output
X@d print(#)==write(term_out,#) {`|print|' means write on the terminal}
X@z
X
X@x
X@<Globals...@>=
X@!term_out:text_file; {the terminal as an output file}
X@y
X@z
X
X@x
Xrewrite(term_out,'TTY:'); {send |term_out| output to the terminal}
X@y
Xprint_ln(banner); {print a ``banner line''}
X@z
X
X@x
X@d update_terminal == break(term_out) {empty the terminal output buffer}
X@y
X@d update_terminal == {emptying the screen output buffer is not necessary}
X@z
X
X@x
X@ The following code opens |Pascal_file| and |pool|.
XSince these files were listed in the program header, we assume that the
X\PASCAL\ runtime system has checked that suitable external file names have
Xbeen given.
X@^system dependencies@>
X
X@<Set init...@>=
Xrewrite(Pascal_file); rewrite(pool);
X@y
X@ The following code opens |Pascal_file| and |pool|.
XActually, on the Atari ST this task is put off until later.
X@^system dependencies@>
X@z
X
X@x
X@!string_ptr:name_pointer; {next number to be given to a string of length |<>1|}
X@y
X@!string_ptr:name_pointer; {next number to be given to a string of length |<>1|}
X@!k:integer; {extra loop variable}
X@z
X
X@x
X  begin for loc:=0 to change_limit do buffer[loc]:=change_buffer[loc];
X@y
X  begin for k:=0 to change_limit do buffer[k]:=change_buffer[k];
X@z
X
X@x
X@!term_in:text_file; {the user's terminal as an input file}
X@y
X@z
X
X@x
Xreset(term_in,'TTY:','/I'); {open |term_in| as the terminal, don't do a |get|}
X@y
X@z
X
X@x
Xprint_ln(banner); {print a ``banner line''}
X@y
X@z
X
X@x
Xstat for zo:=0 to zz-1 do max_tok_ptr[zo]:=tok_ptr[zo];@+tats@;@/
X@y
Xstat for k:=0 to zz-1 do max_tok_ptr[k]:=tok_ptr[k];@+tats@;@/
X@z
X
X@x save pool and Pascal files only if they were written to.
Xif string_ptr>128 then @<Finish off the string pool file@>;
Xstat @<Print statistics about memory usage@>;@+tats@;@/
X@t\4\4@>{here files should be closed if the operating system requires it}
X@<Print the job |history|@>;
Xend.
X@y
Xif history<fatal_message then begin
X  if string_ptr>128 then begin @<Finish off the string pool file@>;
X    close(pool, true);
X  end;
X  close(Pascal_file, true);
Xend;
Xstat @<Print statistics about memory usage@>;@+tats@;@/
X@<Print the job |history|@>;
Xwait(3);
Xend.
X@z
X
X@x
Xfor string_ptr:=1 to 9 do
X@y
Xfor k:=1 to 9 do
X@z
X
X@x
Xfor string_ptr:=9 downto 1 do write(pool,xchr["0"+out_buf[string_ptr]]);
X@y
Xfor k:=9 downto 1 do write(pool,xchr["0"+out_buf[k]]);
X@z
X
X@x
Xfor zo:=1 to zz-1 do print('+',max_tok_ptr[zo]:1);
X@y
Xfor k:=1 to zz-1 do print('+',max_tok_ptr[k]:1);
X@z
X
X@x
XThis module should be replaced, if necessary, by changes to the program
Xthat are necessary to make \.{TANGLE} work at a particular installation.
XIt is usually best to design your change file so that all changes to
Xprevious modules preserve the module numbering; then everybody's version
Xwill be consistent with the printed program. More extensive changes,
Xwhich introduce new modules, can be inserted here; then only the index
Xitself will get a new module number.
X@y
XHere are the remaining changes to the program
Xthat are necessary to make \.{TANGLE} work on the Atari ST.
X
X@ @<Local...@>=
X@!ask,@!name_found: boolean;
X@!file_name,@!job_name: string;
X@!name_length,@!name_index: integer;
X
X@ Get the external file names, and then call |open|
Xto associate an external file with each file variable.
X
X@<Set init...@>=
Xgetcomm(job_name);
Xname_length:=l @& e @& n @& g @& t @& h(job_name); name_index:=1;
Xwhile (name_index <= name_length) and
X      (job_name[name_index] = ' ') do incr(name_index);
Xname_found:=name_index <= name_length;
Xif name_found then delete(job_name, 1, name_index-1);
X
Xif name_found then begin
X  file_name:=concat(job_name,'.WEB');
X  assign(web_file,file_name);
X  ask:=not fstat(file_name);
X  if ask then write_ln('Couldn''t open ',file_name);
Xend
Xelse ask:=true;
Xwhile ask do begin
X  write('Web file: ');
X  if eof then begin mark_fatal; jump_out; end;
X  read_ln(file_name);
X  if checkfn(file_name) then begin
X    ask:= not fstat(file_name);
X    if ask then write_ln('Couldn''t open ',file_name)
X           else assign(web_file,file_name);
X  end
X  else begin
X    ask:=true; write_ln('"',file_name,'" is not a good filename')
X  end;
Xend;
X
Xif name_found then begin
X  file_name:=concat(job_name,'.CH');
X  assign(change_file,file_name);
X  ask:=not fstat(file_name);
X  if ask then write_ln('Couldn''t open ',file_name);
Xend
Xelse ask:=true;
Xwhile ask do begin
X  write('Change file: ');
X  if eof then begin mark_fatal; jump_out; end;
X  read_ln(file_name);
X  if file_name='' then file_name:='empty.ch';
X  if checkfn(file_name) then begin
X    ask:=not fstat(file_name);
X    if ask then write_ln('Couldn''t open ',file_name)
X           else assign(change_file,file_name);
X  end
X  else begin
X    ask:=true; write_ln('"',file_name,'" is not a good filename')
X  end;
Xend;
X
Xif name_found then begin
X  file_name:=concat(job_name,'.PAS');
X  assign(Pascal_file,file_name);
X  ask:=not checkfn(file_name);
X  if ask then write_ln('"',file_name,'" is not a good filename')
Xend
Xelse ask:=true;
Xwhile ask do begin
X  write('Pascal file: ');
X  if eof then begin mark_fatal; jump_out; end;
X  read_ln(file_name);
X  ask := not checkfn(file_name);
X  if ask then
X    write_ln('"',file_name,'" is not a good filename')
X  else
X    assign(Pascal_file,file_name);
Xend;
X
Xif name_found then begin
X  file_name:=concat(job_name,'.POO');
X  assign(pool,file_name);
X  ask:=not checkfn(file_name);
X  if ask then write_ln('"',file_name,'" is not a good filename')
Xend
Xelse ask:=true;
Xwhile ask do begin
X  write('Pool file: ');
X  if eof then begin mark_fatal; jump_out; end;
X  read_ln(file_name);
X  ask := not checkfn(file_name);
X  if ask then
X    write_ln('"',file_name,'" is not a good filename')
X  else
X    assign(pool,file_name);
Xend;
X
Xrewrite(Pascal_file); rewrite(pool);
X@z
X
X
X
SHAR_EOF
chmod 0600 tangle || echo "restore of tangle fails"
sed 's/^X//' << 'SHAR_EOF' > weave &&
XWEAVE change file for the Atari ST
XAuthor: Nico Poppelier.
XDate  : December 30, 1988.
X        Increased max_refs and max_toks as in Version 2.6.
X
XDue to an error in the Prospero Pascal compiler the control
Xvariable of the FOR loop in section 85 is judged 'insecure',
Xi.e., it looks as if it is modified by a routine.
XTo avoid this error a new loop variable k is introduced.
X
X@x
X\pageno=\contentspagenumber \advance\pageno by 1
X@y
X\pageno=\contentspagenumber \advance\pageno by 1
X% \let\maybe=\iffalse
X% \def\title{WEAVE changes for the Atari ST}
X\def\title{WEAVE, Version 2.8 for the Atari ST}
X@z
X
X@x
X@d banner=='This is WEAVE, Version 2.8'
X@y
X@d banner=='This is WEAVE, Version 2.8 for the Atari ST'
X@z
X
X@x
Xand |change_file|, and the \TeX\ output goes to file |tex_file|.
X@y
Xand |change_file|, and the \TeX\ output goes to file |tex_file|.
XProspero Pascal requires us to mention |input| and |output|
Xin the program header, too.
XThey are used for terminal input and output.
X@z
X
X@x
Xprogram WEAVE(@!web_file,@!change_file,@!tex_file);
X@y
Xprogram WEAVE(@!input,@!output,
X              @!web_file,@!change_file,@!tex_file);
X@z
X
X@x
Xprocedure initialize;
X@y
Xprocedure wait(delay:real); external;
Xprocedure initialize;
X@z
X
X@x
X  begin @<Set initial values@>@/
X@y
X  begin @<Preset initial values@>@/
X  @<Set initial values@>@/
X@z
X
X@x
X@d debug==@{ {change this to `$\\{debug}\equiv\null$' when debugging}
X@d gubed==@t@>@} {change this to `$\\{gubed}\equiv\null$' when debugging}
X@y
X@d debug== {we are debugging}
X@d gubed==
X@z
X
X@x
X@d stat==@{ {change this to `$\\{stat}\equiv\null$'
X  when gathering usage statistics}
X@d tats==@t@>@} {change this to `$\\{tats}\equiv\null$'
X  when gathering usage statistics}
X@y
X@d stat== {we are gathering usage statistics}
X@d tats==
X@z
X
X@x
X@<Compiler directives@>=
X@{@&$C-,A+,D-@} {no range check, catch arithmetic overflow, no debug overhead}
X@!debug @{@&$C+,D+@}@+ gubed {but turn everything on when debugging}
X@y
XOn the Atari ST, things are a bit different:
XProspero Pascal does not allow in-comment directives.
X
X@<Compiler directives@>=
X@z
X
X@x
X@d othercases == others: {default for cases not listed explicitly}
X@y
X@d othercases == otherwise {default for cases not listed explicitly}
X@z
X
X@x
X@!max_refs=20000; {number of cross references; must be less than 65536}
X@!max_toks=20000; {number of symbols in \PASCAL\ texts being parsed;
X@y
X@!max_refs=30000; {number of cross references; must be less than 65536}
X@!max_toks=30000; {number of symbols in \PASCAL\ texts being parsed;
X@z
X
X@x
X@!text_file=packed file of text_char;
X@y
X@!text_file=text;
X@z
X
X@x
X@d print(#)==write(term_out,#) {`|print|' means write on the terminal}
X@y
X@d term_in==input
X@d term_out==output
X@d print(#)==write(term_out,#) {`|print|' means write on the terminal}
X@z
X
X@x
X@!term_out:text_file; {the terminal as an output file}
X@y
X@z
X
X@x
Xrewrite(term_out,'TTY:'); {send |term_out| output to the terminal}
X@y
X@z
X
X@x
X@d update_terminal == break(term_out) {empty the terminal output buffer}
X@y
X@d update_terminal == {emptying the output buffer is not necessary}
X@z
X
X@x
X@ The following code opens |tex_file|.
XSince this file was listed in the program header, we assume that the
X\PASCAL\ runtime system has checked that a suitable external file name has
Xbeen given.
X@^system dependencies@>
X
X@<Set init...@>=
Xrewrite(tex_file);
X@y
X@ The following code opens |tex_file|.
XActually, on the Atari ST this task is put off until later.
X@^system dependencies@>
X@z
X
X@x
X@!loc:0..long_buf_size; {the next character position to be read from the buffer}
X@y
X@!loc:0..long_buf_size; {the next character position to be read from the buffer}
X@!k:integer; {extra loop variable}
X@z
X
X@x
X  begin for loc:=0 to change_limit do buffer[loc]:=change_buffer[loc];
X@y
X  begin for k:=0 to change_limit do buffer[k]:=change_buffer[k];
X@z
X
X@x
X@!term_in:text_file; {the user's terminal as an input file}
X@y
X@z
X
X@x
Xreset(term_in,'TTY:','/I'); {open |term_in| as the terminal, don't do a |get|}
X@y
X@z
X
X@x
Xprint_ln(banner); {print a ``banner line''}
X@y
X@z
X
X@x
X@t\4\4@>{here files should be closed if the operating system requires it}
X@<Print the job |history|@>;
Xend.
X@y
Xif history<fatal_message then
X        @= close@>(tex_file, true);
X@<Print the job |history|@>; wait(3);
Xend.
X@z
X
X@x
XThis module should be replaced, if necessary, by changes to the program
Xthat are necessary to make \.{WEAVE} work at a particular installation.
XIt is usually best to design your change file so that all changes to
Xprevious modules preserve the module numbering; then everybody's version
Xwill be consistent with the printed program. More extensive changes,
Xwhich introduce new modules, can be inserted here; then only the index
Xitself will get a new module number.
X@y
XHere are the remaining changes to the program
Xthat are necessary to make \.{WEAVE} work on the Atari ST.
X
X@ @<Local...@>=
X@!ask,@!name_found:boolean;
X@!file_name,@!job_name:s @& t @& r @& i @& n @& g;
X@!name_length,@!name_index: integer;
X
X@ Get the external file names, and then call |open|
Xto associate an external file with each file variable.
X
X@<Preset init...@>=
Xprint_ln(banner); {print a ``banner'' line}
X
Xgetcomm(job_name);
Xname_length:=l @& e @& n @& g @& t @& h(job_name); name_index:=1;
Xwhile (name_index <= name_length) and
X      (job_name[name_index] = ' ') do incr(name_index);
Xname_found:=name_index <= name_length;
Xif name_found then delete(job_name, 1, name_index-1);
X
Xif name_found then begin
X  file_name:=concat(job_name,'.WEB');
X  assign(web_file,file_name);
X  ask:=not fstat(file_name);
X  if ask then write_ln('Couldn''t open ',file_name);
Xend
Xelse ask:=true;
Xwhile ask do begin
X  write('Web file: ');
X  if eof then begin mark_fatal; jump_out; end;
X  read_ln(file_name);
X  if checkfn(file_name) then begin
X    ask:= not fstat(file_name);
X    if ask then write_ln('Couldn''t open ',file_name)
X           else assign(web_file,file_name);
X  end
X  else begin
X    ask:=true; write_ln('"',file_name,'" is not a good filename')
X  end;
Xend;
X
Xif name_found then begin
X  file_name:=concat(job_name,'.CH');
X  assign(change_file,file_name);
X  ask:=not fstat(file_name);
X  if ask then write_ln('Couldn''t open ',file_name);
Xend
Xelse ask:=true;
Xwhile ask do begin
X  write('Change file: ');
X  if eof then begin mark_fatal; jump_out; end;
X  read_ln(file_name);
X  if file_name='' then file_name:='empty.ch';
X  if checkfn(file_name) then begin
X    ask:=not fstat(file_name);
X    if ask then write_ln('Couldn''t open ',file_name)
X           else assign(change_file,file_name);
X  end
X  else begin
X    ask:=true; write_ln('"',file_name,'" is not a good filename')
X  end;
Xend;
X
Xif name_found then begin
X  file_name:=concat(job_name,'.TEX');
X  assign(tex_file,file_name);
X  ask:=not checkfn(file_name);
X  if ask then write_ln('"',file_name,'" is not a good filename')
Xend
Xelse ask:=true;
Xwhile ask do begin
X  write('TeX file: ');
X  if eof then begin mark_fatal; jump_out; end;
X  read_ln(file_name);
X  ask := not checkfn(file_name);
X  if ask then
X    write_ln('"',file_name,'" is not a good filename')
X  else
X    assign(tex_file,file_name);
Xend;
X
Xrewrite(tex_file);
X@z
X
X
SHAR_EOF
chmod 0600 weave || echo "restore of weave fails"
exit 0