home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / tex / texsrc2 / Src / fontutil / vptovf / old-ch < prev    next >
Text File  |  1993-02-21  |  9KB  |  307 lines

  1. % vptovf.ch for C compilation with web2c.
  2.  
  3.  
  4. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  5. % [0] WEAVE: print changes only.
  6. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  7. @x
  8. \pageno=\contentspagenumber \advance\pageno by 1
  9. @y
  10. \pageno=\contentspagenumber \advance\pageno by 1
  11. \let\maybe=\iffalse
  12. \def\title{VP$\,$\lowercase{to}$\,$VF changes for C}
  13. @z
  14.  
  15. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  16. % [1] Change banner string.
  17. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  18. @x
  19. @d banner=='This is VPtoVF, Version 1.3' {printed when the program starts}
  20. @y
  21. @d banner=='This is VPtoVF, Version 1.3' {more is printed later}
  22. @z
  23.  
  24. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  25. % [2] Remove filenames from program statement, and print the banner later.
  26. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  27. @x
  28. @p program VPtoVF(@!vpl_file,@!vf_file,@!tfm_file,@!output);
  29. @y
  30. @p program VPtoVF;
  31. @z
  32.  
  33. @x
  34.   begin print_ln(banner);@/
  35. @y
  36.   begin
  37. @z
  38.  
  39. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  40. % [6] Open VPL file.
  41. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  42. @x
  43. reset(vpl_file);
  44. @y
  45. if (argc < 4) or (argc > n_options + 4)
  46. then begin
  47.   print_ln ('Usage: vptovf [-verbose] <vpl file> <vfm file> <tfm file>.');
  48.   uexit (1);
  49. end;
  50. @<Initialize the option variables@>;
  51. @<Parse arguments@>;
  52. argv (optind, vpl_name);
  53. reset (vpl_file, vpl_name);
  54. if verbose then begin
  55.   print (banner);
  56.   print_ln (banner);
  57. end;
  58. @z
  59.  
  60. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  61. % [21] Declare filename variables.
  62. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  63. @x
  64. @!tfm_file:packed file of 0..255;
  65. @y
  66. @!tfm_file:packed file of 0..255;
  67. @!vf_name,@!tfm_name,@!vpl_name:packed array[1..PATH_MAX] of char;
  68. @z
  69.  
  70. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  71. % [22] Open output files.
  72. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  73. @x
  74. @ On some systems you may have to do something special to write a
  75. packed file of bytes. For example, the following code didn't work
  76. when it was first tried at Stanford, because packed files have to be
  77. opened with a special switch setting on the \PASCAL\ that was used.
  78. @^system dependencies@>
  79.  
  80. @<Set init...@>=
  81. rewrite(vf_file); rewrite(tfm_file);
  82. @y
  83. @ On some systems you may have to do something special to write a
  84. packed file of bytes.
  85. @^system dependencies@>
  86.  
  87. @<Set init...@>=
  88. argv(optind + 1, vf_name);
  89. rewrite(vf_file, vf_name);
  90. argv(optind + 2, tfm_name);
  91. rewrite(tfm_file, tfm_name);
  92. @z
  93.  
  94. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  95. % [89] `index' is not a good choice for an identifier.
  96. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  97. @x
  98. |k|th element of its list.
  99.  
  100. @<Glob...@>=
  101. @!index:array[pointer] of byte;
  102. @y
  103. |k|th element of its list.
  104.  
  105. @d index == index_type
  106.  
  107. @<Glob...@>=
  108. @!index:array[pointer] of byte;
  109. @z
  110.  
  111. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  112. % [118] No output unless verbose.
  113. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  114. @x
  115. @<Print |c| in octal notation@>;
  116. @y
  117. if verbose then @<Print |c| in octal notation@>;
  118. @z
  119.  
  120. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  121. % [144] Output of real numbers.
  122. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  123. @x
  124. @ @d round_message(#)==if delta>0 then print_ln('I had to round some ',
  125. @.I had to round...@>
  126.   #,'s by ',(((delta+1) div 2)/@'4000000):1:7,' units.')
  127. @y
  128. @ @d round_message(#)==if delta>0 then begin print('I had to round some ',
  129. @.I had to round...@>
  130.   #,'s by '); print_real((((delta+1) div 2)/@'4000000),1,7);
  131.   print_ln(' units.'); end
  132. @z
  133.  
  134. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  135. % [152] Fix up the mutually recursive procedures a la pltotf.
  136. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  137. @x
  138. @p function f(@!h,@!x,@!y:indx):indx; forward;@t\2@>
  139.   {compute $f$ for arguments known to be in |hash[h]|}
  140. @y
  141. @p 
  142. ifdef('notdef') 
  143. function f(@!h,@!x,@!y:indx):indx; begin end;@t\2@>
  144.   {compute $f$ for arguments known to be in |hash[h]|}
  145. endif('notdef')
  146. @z
  147.  
  148. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  149. % [153] Finish fixing up f.
  150. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  151. @x
  152. @p function f;
  153. @y
  154. @p function f(@!h,@!x,@!y:indx):indx; 
  155. @z
  156.  
  157. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  158. % [156] Change TFM-byte output to fix ranges.
  159. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  160. @x
  161. @d out(#)==write(tfm_file,#)
  162. @y
  163. @d out(#)==putbyte(#,tfm_file)
  164. @z
  165.  
  166. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  167. % [165] Fix output of reals.
  168. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  169. @x
  170. @p procedure out_scaled(x:fix_word); {outputs a scaled |fix_word|}
  171. var @!n:byte; {the first byte after the sign}
  172. @!m:0..65535; {the two least significant bytes}
  173. begin if abs(x/design_units)>=16.0 then
  174.   begin print_ln('The relative dimension ',x/@'4000000:1:3,
  175.     ' is too large.');
  176. @.The relative dimension...@>
  177.   print('  (Must be less than 16*designsize');
  178.   if design_units<>unity then print(' =',design_units/@'200000:1:3,
  179.       ' designunits');
  180. @y
  181. @p procedure out_scaled(x:fix_word); {outputs a scaled |fix_word|}
  182. var @!n:byte; {the first byte after the sign}
  183. @!m:0..65535; {the two least significant bytes}
  184. begin if fabs(x/design_units)>=16.0 then
  185.   begin print('The relative dimension ');
  186.     print_real(x/@'4000000,1,3);
  187.     print_ln(' is too large.');
  188. @.The relative dimension...@>
  189.   print('  (Must be less than 16*designsize');
  190.   if design_units<>unity then begin print(' =');
  191.     print_real(design_units/@'200000,1,3);
  192.     print(' designunits');
  193.   end;
  194. @z
  195.  
  196. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  197. % [141] char_remainder[c] is unsigned, and label_table[sort_ptr].rr
  198. % might be -1, and if -1 is coerced to being unsigned, it will be bigger
  199. % than anything else.
  200. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  201. @x
  202.   while label_table[sort_ptr].rr>char_remainder[c] do
  203. @y
  204.   while label_table[sort_ptr].rr>toint(char_remainder[c]) do
  205. @z
  206.  
  207. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  208. % [175] Change VF-byte output to fix ranges.
  209. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  210. @x
  211. @d vout(#)==write(vf_file,#)
  212. @y
  213. @d vout(#)==putbyte(#,vf_file)
  214. @z
  215.  
  216. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  217. % [181] Be quiet unless verbose. 
  218. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  219. @x
  220. read_input; print_ln('.');@/
  221. @y
  222. read_input;
  223. if verbose then print_ln('.');
  224. @z
  225.  
  226. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  227. % [182] System-dependent changes.
  228. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  229. @x
  230. @* System-dependent changes.
  231. This section should be replaced, if necessary, by changes to the program
  232. that are necessary to make \.{VPtoVF} work at a particular installation.
  233. It is usually best to design your change file so that all changes to
  234. previous sections preserve the section numbering; then everybody's version
  235. will be consistent with the printed program. More extensive changes,
  236. which introduce new sections, can be inserted here; then only the index
  237. itself will get a new section number.
  238. @^system dependencies@>
  239. @y
  240. @* System-dependent changes.  We want to parse a Unix-style command line.
  241.  
  242. @<Parse arguments@> =
  243. begin
  244.   @<Define the option table@>;
  245.   repeat
  246.     getopt_return_val := getopt_long_only (argc, gargv, '', long_options,
  247.                                            address_of_int (option_index));
  248.     if getopt_return_val <> -1
  249.     then begin
  250.       if getopt_return_val = "?"
  251.       then uexit (1); {|getopt| has already given an error message.}
  252.       {We don't have any non-flag options.}
  253.     end;
  254.   until getopt_return_val = -1;
  255.  
  256.   {Now |optind| is the index of firs