ACCENTS.CHG - WEB change file for ACCENTS 1 for MS-DOS and Turbo Pascal.
DOS-TP 1.0: Written by Jiri Zlatuska, April 1991;
            based on change files for VFTOVP and VPTOVF 1.2
            by P. Breitenlohner.

% No line numbers refer to .WEB, as of ????.

@x limbo l.10
\def\PASCAL{Pascal}
@y
\def\PASCAL{Pascal}
\def\TP{\hbox{Turbo Pascal}} % Version 4.0 or later
@z
%---------------------------------------
@x limbo l.17 - print only changed modules
\def\topofcontents{\null
@y
%\let\maybe=\iffalse
\def\topofcontents{\null
@z
%---------------------------------------
@x limbo l.24
  \vfill}
@y
  \centerline{(DOS-TP Version 1, April 1991)}
  \vfill}
@z
%---------------------------------------
@x [1] m.1 l.58 - banner
@d banner=='This is ACCENTS, Version 1' {printed when the program starts}
@y
@d TP_dir(#)==@\@={$@>#@=}@>
@#
@d banner=='This is ACCENTS, Version 1/DOS-TP 1'
           {printed when the program starts}
@z
%---------------------------------------
@x [1] m.2 l.72 -
@d print(#)==write(#)
@y
@d integer==long_int {we will use |Integer| for two-byte integers}
@d xchr==Xchr(ASCII)
@#
@d print(#)==write(#)
@z
%---------------------------------------
@x [1] m.2 l.75 - unit DOS
@p program ACCENTS(@!T_tfm_file,@!vf_file,@!adj_file,@!tfm_file,@!output);
@y
@p program ACCENTS(@!T_tfm_file,@!vf_file,@!tfm_file,@!output);
uses DOS; {unit DOS used for |get_env|, file and path names}
@z
%---------------------------------------
@x [1] m.2 l.82 - DOS initializations
  begin print_ln(banner);@/
  print_ln(copyright);
  print_ln('Distributed under terms of GNU General Public License');@/
@y
  @!name_of_file:path_str; {a DOS file name}
  begin @<Initialize DOS variables@>@/
  print_ln(banner);@/
  print_ln(copyright);
  print_ln('Distributed under terms of GNU General Public License');@/
@z
%---------------------------------------
@x [1] m.4 l.96 constants - file handling
@<Constants...@>=
@y
@d vf_buf_size=1024 {size of buffer for |vf_file|}
@d tfm_buf_size=256 {size of buffer (words) for |tfm_file|}
@d adj_buf_size=1024 {size of buffer for |adj_file|}

@<Constants...@>=
@z
%---------------------------------------
@x [1] m.4 l.103 constants - file names
@!name_length=50; {a file name shouldn't be longer than this}
@y
@!name_length=size_of(path_str)-1;
  {a file name shouldn't be longer than this}
@z
%---------------------------------------
@x [1] m.5 l.108 - optimization
@d incr(#) == #:=#+1 {increase a variable by unity}
@d decr(#) == #:=#-1 {decrease a variable by unity}
@y
@d incr(#) == inc(#) {increase a variable by unity}
@d decr(#) == dec(#) {decrease a variable by unity}
@z
%---------------------------------------
@x
@d othercases == others: {default for cases not listed explicitly}
@y
@d othercases == else {default for cases not listed explicitly}
@z
%---------------------------------------
@x [1] m.5 l.117 - optimization
@!byte=0..255; {unsigned eight-bit quantity}
@y
@!five_choices = 1..5; {used when there are five variants in a record}
@!aux_word = record@;@/
  case five_choices of
  1: (@!b3,@!b2,@!b1,@!b0 : byte);
  2: (@!s3,@!s2,@!s1,@!s0 : short_int);
  3: (@!ww1,@!ww0 : word);
  4: (@!ii1,@!ii0 : Integer);
  5: (@!llll0 : integer);
  end; {used to access individual bytes}
@z
%---------------------------------------
@x [3] m.10 l.290 - file handling
@!T_tfm_file:packed file of byte;
@y
@!T_tfm_file:file;
@!T_tfm_open:boolean; {|true| if |T_tfm_file| has been opened}
@!T_tfm_buf:array[0..tfm_buf_size-1] of aux_word; {input buffer}
@!T_tfm_words:word; {number of words in buffer}
@!T_tfm_count:word; {last word read from buffer}
@!T_tfm_eof:boolean; {|true| if \.{TFM} file has been exhausted}
@z
%---------------------------------------
@x [3] m.11 l.299 - file handling
reset(T_tfm_file);
@y
assign(T_tfm_file,in_dir+in_name+'.tfm');
TP_dir(I-)@; reset(T_tfm_file,1); TP_dir(I+)@;
if io_result<>0 then
  begin write_ln('! File ',in_dir+in_name+'.tfm',' not found'); halt(4);
  end;
T_tfm_open:=true;
@z
%---------------------------------------
@x    dynamic memory allocation
@!T_index=0..T_tfm_size; {address of a byte in |tfm|}
@y
@!T_index=0..T_tfm_size; {address of a byte in |tfm|}
@!p_tfm=array [-1000..T_tfm_size] of byte;
@z
%---------------------------------------
@x    dynamic memory allocation
@ @<Glob...@>=
@!T_tfm:array [-1000..T_tfm_size] of byte; {the \.{TFM} input data all goes here}
 {the negative addresses avoid range checks for invalid characters}
@y
@ |T_tfm| array is allocated dynamically.
@d T_tfm==p_T_tfm^

@<Glob...@>=
@!p_T_tfm:^p_tfm; {the \.{TFM} input data all goes here}
 {the negative addresses avoid range checks for invalid characters}
@z
%---------------------------------------
@x [4] m.24 l.596 - file handling
read(T_tfm_file,T_tfm[0]);
if T_tfm[0]>127 then abort('The first byte of the input file exceeds 127!');
@.The first byte...@>
if eof(T_tfm_file) then abort('The input file is only one byte long!');
@.The input...one byte long@>
read(T_tfm_file,T_tfm[1]); T_lf:=T_tfm[0]*@'400+T_tfm[1];
@y
block_read(T_tfm_file,T_tfm[0],1,T_tfm_ptr);
if eof(T_tfm_file) then abort('The input file is only one byte long!');
@.The input...one byte long@>
if T_tfm[0]>127 then abort('The first byte of the input file exceeds 127!');
@.The first byte...@>
block_read(T_tfm_file,T_tfm[1],T_tfm_size,T_tfm_ptr);
T_lf:=T_tfm[0]*@'400+T_tfm[1];
@z
%---------------------------------------
@x [4] m.24 l.607 - file handling
for T_tfm_ptr:=2 to 4*T_lf-1 do
  begin if eof(T_tfm_file) then
@y
if T_tfm_ptr<4*T_lf-1 then
@z
%---------------------------------------
@x [4] m.24 l.611 - file handling
  read(T_tfm_file,T_tfm[T_tfm_ptr]);
  end;
if not eof(T_tfm_file) then
@y
if (T_tfm_ptr>=4*T_lf) or (not eof(T_tfm_file)) then
@z
%---------------------------------------
@x [4] m.26 l.668 - optimization
@!T_char_base,@!T_width_base,@!T_height_base,@!T_depth_base,@!T_italic_base,
@!T_lig_kern_base,@!T_kern_base,@!T_exten_base,@!T_param_base:integer;
@y
@!T_char_base,@!T_width_base,@!T_height_base,@!T_depth_base,@!T_italic_base,
@!T_lig_kern_base,@!T_kern_base,@!T_exten_base,@!T_param_base:Integer;
@z
%---------------------------------------
@x [2] m.21 l.627 - file handling
@!vf_file:packed file of 0..255;
@!tfm_file:packed file of 0..255;
@y
@!vf_file:file;
@!vf_buf:array[0..vf_buf_size-1] of byte; {output buffer}
@!vf_count:word; {next byte to be written to buffer}
@!tfm_file:file;
@!tfm_buf:array[0..tfm_buf_size-1] of byte; {output buffer}
@!tfm_count:word; {next byte to be written to buffer}
@z
%---------------------------------------
@x [2] m.22 l.637 - file handling
rewrite(vf_file); rewrite(tfm_file);
@y
assign(vf_file,out_dir+out_name+out_ext);
TP_dir(I-)@; rewrite(vf_file,1); TP_dir(I+)@;
if io_result<>0 then
  begin write_ln('! Unable to open output file ',out_dir+out_name+out_ext);
  halt(4);
  end;
vf_count:=0;
assign(tfm_file,out_dir+out_name+'.tfm');
TP_dir(I-)@; rewrite(tfm_file,1); TP_dir(I+)@;
if io_result<>0 then
  begin write_ln('! Unable to open output file ',out_dir+out_name+'.tfm');
  halt(4);
  end;
tfm_count:=0;
@z
%---------------------------------------
@x      extract font names from file names
fname_start:=vf_ptr;
for k:= 1 to T_tfm[T_family] do vf_store(T_tfm[T_family+k]);
fname_length:=vf_ptr-fname_start;
vtitle_start:=vf_ptr;
for k:= 1 to T_tfm[T_family] do vf_store(T_tfm[T_family+k]);
vtitle_length:=vf_ptr-vtitle_start;
@y
fname_start:=vf_ptr;
for k:= 1 to byte(in_name[0]) do vf_store(byte(in_name[k]));
fname_length:=vf_ptr-fname_start;
vtitle_start:=vf_ptr;
for k:= 1 to byte(out_name[0]) do vf_store(byte(out_name[k]));
vf_store(".");vf_store("V");vf_store("F");
vtitle_length:=vf_ptr-vtitle_start;
@z
%---------------------------------------
@x [10] m.146 l.2582 - dynamic memory allocation
@d pending=4 {$f(x,y)$ is being evaluated}
@y
@d pending=4 {$f(x,y)$ is being evaluated}
@#
@d hash==p_hash^
@d class==p_class^
@d lig_z==p_lig_z^
@d hash_list==p_hash_list^
@z
%---------------------------------------
@x [10] m.147 l.2587 - dynamic memory allocation
@!hash:array[0..hash_size] of 0..66048; {$256x+y+1$ for $x\le257$ and $y\le255$}
@!class:array[0..hash_size] of simple..pending;
@!lig_z:array[0..hash_size] of 0..257;
@!hash_ptr:0..hash_size; {the number of nonzero entries in |hash|}
@!hash_list:array[0..hash_size] of 0..hash_size; {list of those nonzero entries}
@y
@!p_hash:^a_hash;
@!p_class:^a_class;
@!p_lig_z:^a_lig_z;
@!hash_ptr:0..hash_size; {the number of nonzero entries in |hash|}
@!p_hash_list:^a_hash_list;
@z
%---------------------------------------
@x [10] m.150 l.2639 hash_input - arithmetic
key:=256*c+y+1; h:=(1009*key) mod hash_size;
@y
key:=256*integer(c)+y+1; h:=(1009*key) mod hash_size;
@z
%---------------------------------------
@x [10] m.152 l.2675 eval - arithmetic
begin key:=256*x+y+1; h:=(1009*key) mod hash_size;
@y
begin key:=256*integer(x)+y+1; h:=(1009*key) mod hash_size;
@z
%---------------------------------------
@x [11] m.156 l.2770 - file handling
@d out(#)==write(tfm_file,#)
@y
@d out(#)==
  begin if tfm_count>=tfm_buf_size then
    begin block_write(tfm_file,tfm_buf,tfm_count); tfm_count:=0;
    end;
  tfm_buf[tfm_count]:=#; incr(tfm_count);
  end
@z
%---------------------------------------
@x [11] m.157 l.2782 - file handling
@<Output the parameters@>
@y
@<Output the parameters@>;
block_write(tfm_file,tfm_buf,tfm_count); close(tfm_file)
@z
%---------------------------------------
@x [12] m.175 l.3035 - file handling
@d vout(#)==write(vf_file,#)
@y
@d vout(#)==
  begin if vf_count>=vf_buf_size then
    begin block_write(vf_file,vf_buf,vf_count); vf_count:=0;
    end;
  vf_buf[vf_count]:=#; incr(vf_count);
  end
@z
%---------------------------------------
@x [12] m.177 l.3060 - file handling
until vcount mod 4 = 0
@y
until vcount mod 4 = 0;
block_write(vf_file,vf_buf,vf_count); close(vf_file)
@z
%---------------------------------------
@x [2] m.5 l.125 - file handling
@!adj_file:text;
@y
@!adj_file:text;
@!adj_buf:array[0..adj_buf_size-1] of char; {input buffer}
@z
%---------------------------------------
@x [2] m.6 l.128 - file handling
reset(adj_file);
adj_present:=true;  {set to false if default adjustment file not found}
@y
assign(adj_file,adj_dir+adj_name+adj_ext); set_text_buf(adj_file,adj_buf);
TP_dir(I-)@; reset(adj_file); TP_dir(I+)@;
if io_result<>0 then
     begin write_ln('! File ',adj_dir+adj_name+adj_ext,' not found');
           if adj_present then halt(4);
  end
  else adj_present:=true;
@z
%---------------------------------------
@x [14] m.182 l.3159 - additions
This section should be replaced, if necessary, by changes to the program
that are necessary to make \.{ACCENTS} work at a particular installation.
It is usually best to design your change file so that all changes to
previous sections preserve the section numbering; then everybody's version
will be consistent with the printed program. More extensive changes,
which introduce new sections, can be inserted here; then only the index
itself will get a new section number.
@^system dependencies@>
@y
The following sections, as recommended, contain the changes necessary to
make \.{VPtoVF} work under \TP\ and DOS.
@^system dependencies@>

@ Here are the additional types needed for DOS.

@<Types...@>=
@!a_hash=array[0..hash_size] of 0..66048;
  {$256x+y+1$ for $x\le257$ and $y\le255$}
@!a_class=array[0..hash_size] of simple..pending;
@!a_lig_z=array[0..hash_size] of 0..257;
@!a_hash_list=array[0..hash_size] of 0..hash_size;
  {list of those nonzero entries}

@ And here are the additional global variables needed for DOS.

@<Glob...@>=
@!in_dir,@!out_dir,@!adj_dir:dir_str; {dir part of DOS file names}
@!in_name,@!out_name,@!adj_name:name_str; {name part of DOS file names}
@!in_ext,@!out_ext,@!adj_ext:ext_str; {ext part of DOS file names}

@ Here is the additional initialization needed for DOS.

@<Initialize DOS variables@>=
new(p_hash); new(p_class); new(p_lig_z); new(p_hash_list); file_mode:=0;
new(p_T_tfm);
@<Determine the input and output file names@>;

@ If the name of the input file is not specified in the command line,
we have to prompt for it.

@<Determine the input and output file names@>=
if param_count>0 then name_of_file:=param_str(1)
else  begin write('Input file [.TFM]: '); read_ln(name_of_file);
  if name_of_file='' then
    begin write_ln('Usage:  ACCENTS [<tfm> [<vf> [<adj>]]]'); halt;
    end;
  end;
f_split(name_of_file,in_dir,in_name,in_ext);
if in_ext='' then in_ext:='.tfm';
if param_count>0 then name_of_file:=param_str(2)
else  begin write('Output file [','V'+in_name,'.VF]: '); read_ln(name_of_file);
  end;
f_split(name_of_file,out_dir,out_name,out_ext);
if out_name='' then out_name:='V'+in_name;
if out_ext='' then out_ext:='.vf';
if param_count>0 then name_of_file:=param_str(3)
else  begin write('Adjustment file (optional) [',in_name,'.ADJ]: '); read_ln(name_of_file);
  end;
f_split(name_of_file,adj_dir,adj_name,adj_ext);
if adj_name='' then
       begin adj_name:=in_name;
       adj_present:=false;  {do not insist on finding this file}
       end;
if adj_ext='' then adj_ext:='.adj'
@z
%---------------------------------------
