home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / tex / texsrc2 / Src / fontutil / gftodvi / ch next >
Text File  |  1993-05-21  |  28KB  |  832 lines

  1. % gftodvi.ch for C compilation with web2c.
  2. %
  3. % History:
  4. % 01/20/90 Karl        New gftodvi.web (same version number).
  5. % 12/02/89 Karl Berry    To version 3.
  6. % Revision 1.7.1.5  86/02/01  15:29:58  richards
  7. %     Released again for MF 1.0 package
  8. % Revision 1.7.1.4  86/02/01  15:06:50  richards
  9. %     Added: <nl> at end of successful run
  10. % Revision 1.7.1.3  86/01/27  16:39:48  richards
  11. %     Fixed: syntax error in previous edits
  12. % Revision 1.7.1.2  86/01/27  15:55:58  richards
  13. %     Added: dvi_buf_type declaration and redefined dvi_buf[] in
  14. %            terms of it, so we can use it as a parameter to b_write_buf()
  15. % Revision 1.7.1.1  86/01/27  15:39:10  richards
  16. %     First edit to use new binary I/O routines
  17. % Revision 1.7  85/10/21  21:55:50  richards
  18. %     Released for GFtoDVI 1.7
  19. % Revision 1.3.7.1  85/10/18  22:59:01  richards
  20. %     Updated for GFtoDVI Version 1.7 (Distributed w/ MF84 Version 0.9999)
  21. % Revision 1.3.5.1  85/10/09  17:02:35  richards
  22. %     First draft to run at 1.5 level
  23. % Revision 1.3  85/05/27  21:15:30  richards
  24. %     Updated for GFtoDVI Version 1.3 (Distributed w/ MF84 Version 0.91)
  25. % Revision 1.2  85/04/25  19:33:30  richards
  26. %     Updated to GFtoDVI Version 1.2 (Distributed w/ MF84 Version 0.81)
  27. % Revision 1.1  85/03/03  21:47:17  richards
  28. %     Updated for GF utilities distributed with MF Version 0.77
  29. % Revision 1.0  84/12/16  22:38:22  richards
  30. %     Updated for GFtoDVI Version 1.0 (New GF file format)
  31. % Revision 0.6  84/12/05  13:32:01  richards
  32. %     Updated for GFtoDVI Version 0.6; merged in changes from sdcarl!rusty
  33. %     Note: still has BUGFIX in section 199 to keep GFtoDVI from trying
  34. %     to use non-existent characters in a gray font
  35. % Revision 0.3  84/11/17  23:51:56  richards
  36. %     Base version for GFtoDVI Version 0.3
  37.  
  38.  
  39. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  40. % [0] WEAVE: print changes only.
  41. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  42. @x
  43. \pageno=\contentspagenumber \advance\pageno by 1
  44. @y
  45. \pageno=\contentspagenumber \advance\pageno by 1
  46. \let\maybe=\iffalse
  47. \def\title{GF$\,$\lowercase{to}$\,$DVI changes for C}
  48. @z
  49.  
  50. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  51. % [1] Change banner string.
  52. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  53. @x
  54. @d banner=='This is GFtoDVI, Version 3.0' {printed when the program starts}
  55. @y
  56. @d banner=='This is GFtoDVI, Version 3.0' {more is printed later}
  57. @z
  58.  
  59. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  60. % [3] Redirect output to term_out.
  61. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  62. @x
  63. @d print(#)==write(#)
  64. @d print_ln(#)==write_ln(#)
  65. @d print_nl(#)==@+begin write_ln; write(#);@+end
  66. @y
  67. @d term_out==stdout
  68. @d print(#)==write(term_out, #)
  69. @d print_ln(#)==write_ln(term_out, #)
  70. @d print_nl(#)==@+begin write_ln(term_out); write(term_out, #);@+end
  71. @z
  72.  
  73. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  74. % [still 3] Fix program header.
  75. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  76. @x
  77. @p program GF_to_DVI(@!output);
  78. label @<Labels in the outer block@>@/
  79. const @<Constants in the outer block@>@/
  80. type @<Types in the outer block@>@/
  81. var @<Globals in the outer block@>@/
  82. procedure initialize; {this procedure gets things started properly}
  83.   var @!i,@!j,@!m,@!n:integer; {loop indices for initializations}
  84.   begin print_ln(banner);@/
  85. @y
  86. @p program GF_to_DVI;
  87. const @<Constants in the outer block@>@/
  88. type @<Types in the outer block@>@/
  89. var @<Globals in the outer block@>@/
  90. procedure initialize; {this procedure gets things started properly}
  91.   var @!i,@!j,@!m,@!n:integer; {loop indices for initializations}
  92.       @<Local variables for initialization@>
  93.   begin
  94.     if argc > n_options + arg_options + 2
  95.     then begin
  96.       print_ln
  97.       ('Usage: gftodvi [-verbose] [-overflow-label-offset=<real>] <gf file>.');
  98. @.Usage: ...@>
  99.       uexit (1);
  100.     end;
  101.  
  102.     @<Initialize the option variables@>;
  103.     @<Parse arguments@>;
  104.     if verbose then begin
  105.       print (banner);
  106.       print_ln (version_string);
  107.     end;
  108. @z
  109.  
  110. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  111. % [4] Remove the final_end label.
  112. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  113. @x
  114. @ If the program has to stop prematurely, it goes to the
  115. `|final_end|'.
  116.  
  117. @d final_end=9999 {label for the end of it all}
  118.  
  119. @<Labels...@>=final_end;
  120. @y
  121. @ This module deleted, since it only defined the label |final_end|.
  122. @z
  123.  
  124. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  125. % [5] Make file_name_size match the system constant.
  126. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  127. @x
  128. @<Constants...@>=
  129. @y
  130. @d file_name_size==PATH_MAX {a file name shouldn't be longer than this}
  131. @<Constants...@>=
  132. @z
  133. @x
  134. @!file_name_size=50; {a file name shouldn't be longer than this}
  135. @y
  136. @z
  137.  
  138. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  139. % [8] Add newline to end of abort() message, and exit abnormally.
  140. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  141. @x
  142. @d abort(#)==@+begin print(' ',#); jump_out;@+end
  143. @y
  144. @d abort(#)==@+begin print_ln (#); uexit (1);@+end
  145. @z
  146.  
  147. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  148. % [8] Remove nonlocal goto.
  149. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  150. @x
  151. @p procedure jump_out;
  152. begin goto final_end;
  153. end;
  154. @y
  155. @p procedure jump_out;
  156. begin uexit(0);
  157. end;
  158. @z
  159.  
  160. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  161. % [11] The text_char type is used as an array index into xord.  The
  162. % default type `char' produces signed integers, which are bad array
  163. % indices in C.
  164. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  165. @x
  166. @d text_char == char {the data type of characters in text files}
  167. @y
  168. @d text_char == ASCII_code {the data type of characters in text files}
  169. @z
  170.  
  171. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  172. % [14] Allow any input character.
  173. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  174. @x
  175. for i:=0 to @'37 do xchr[i]:='?';
  176. for i:=@'177 to @'377 do xchr[i]:='?';
  177. @y
  178. for i:=1 to @'37 do xchr[i]:=chr(i);
  179. for i:=@'177 to @'377 do xchr[i]:=chr(i);
  180. @z
  181.  
  182.  
  183. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  184. % [15] Change `update_terminal' to `flush', `term_in' is stdin.
  185. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  186. @x
  187. Since the terminal is being used for both input and output, some systems
  188. need a special routine to make sure that the user can see a prompt message
  189. before waiting for input based on that message. (Otherwise the message
  190. may just be sitting in a hidden buffer somewhere, and the user will have
  191. no idea what the program is waiting for.) We shall call a system-dependent
  192. subroutine |update_terminal| in order to avoid this problem.
  193.  
  194. @d update_terminal == break(output) {empty the terminal output buffer}
  195.  
  196. @<Glob...@>=
  197. @!buffer:array[0..terminal_line_length] of 0..255;
  198. @!term_in:text_file; {the terminal, considered as an input file}
  199. @y
  200. Since the terminal is being used for both input and output, some systems
  201. need a special routine to make sure that the user can see a prompt message
  202. before waiting for input based on that message. (Otherwise the message
  203. may just be sitting in a hidden buffer somewhere, and the user will have
  204. no idea what the program is waiting for.) We shall call a system-dependent
  205. subroutine |update_terminal| in order to avoid this problem.
  206. @^system dependencies@>
  207.  
  208. @d update_terminal == flush (stdout) {empty the terminal output buffer}
  209. @d term_in == stdin {standard input}
  210.  
  211. @<Glob...@>=
  212. @!buffer:array[0..terminal_line_length] of 0..255;
  213. @z
  214.  
  215. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  216. % [17] Change term_in^, etc.
  217. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  218. @x
  219. @p procedure input_ln; {inputs a line from the terminal}
  220. begin update_terminal; reset(term_in);
  221. if eoln(term_in) then read_ln(term_in);
  222. line_length:=0;
  223. while (line_length<terminal_line_length)and not eoln(term_in) do
  224.   begin buffer[line_length]:=xord[term_in^]; incr(line_length);