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

  1. % mft.ch for C compilation with web2c.
  2. % 11/27/89 Karl Berry        version 2.0.
  3. % 01/20/90 Karl            new mft.web (still 2.0, though).
  4. % (more recent changes in ../ChangeLog.W2C)
  5. % From Pierre Mackay's version for pc, which was in turn based on Howard
  6. % Trickey's and Pavel Curtis's change file for weave.
  7.  
  8.  
  9. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  10. % [0] WEAVE: print changes only.
  11. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  12. @x
  13. \pageno=\contentspagenumber \advance\pageno by 1
  14. @y
  15. \pageno=\contentspagenumber \advance\pageno by 1
  16. \let\maybe=\iffalse
  17. \def\title{MFT changes for C}
  18. @z
  19.  
  20. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  21. % [2] Change banner message.
  22. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  23. @x
  24. @d banner=='This is MFT, Version 2.0'
  25. @y
  26. @d banner=='This is MFT, Version 2.0' {more is printed later}
  27. @z
  28.  
  29. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  30. % [3] No need for the final label in C.
  31. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  32. @x
  33. @d end_of_MFT = 9999 {go here to wrap it up}
  34. @y
  35. @z
  36.  
  37. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  38. % [3] Main program header, remove external label.
  39. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  40. @x
  41. program MFT(@!mf_file,@!change_file,@!style_file,@!tex_file);
  42. label end_of_MFT; {go here to finish}
  43. const @<Constants in the outer block@>@/
  44. type @<Types in the outer block@>@/
  45. var @<Globals in the outer block@>@/
  46. @<Error handling procedures@>@/
  47. procedure initialize;
  48.   var @<Local variables for initialization@>@/
  49.   begin @<Set initial values@>@/
  50.   end;
  51. @y
  52. program MFT;
  53. const @<Constants in the outer block@>@/
  54. type @<Types in the outer block@>@/
  55. var @<Globals in the outer block@>@/
  56. @<Error handling procedures@>@/
  57. @<|scan_args| procedure@>@/
  58. procedure initialize;
  59.   var @<Local variables for initialization@>@/
  60.   begin @<Set initial values@>@/
  61.   end;
  62. @z
  63.  
  64. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  65. % [4] No compiler directives.
  66. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  67. @x
  68. @{@&$C+,A+,D-@} {range check, catch arithmetic overflow, no debug overhead}
  69. @y
  70. @z
  71.  
  72. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  73. % [13] The text_char type is used as an array index into xord.  The
  74. % default type `char' produces signed integers, which are bad array
  75. % indices in C.
  76. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  77. @x
  78. @d text_char == char {the data type of characters in text files}
  79. @y
  80. @d text_char == ASCII_code {the data type of characters in text files}
  81. @z
  82.  
  83. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  84. % [17] Allow any input character.
  85. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  86. @x
  87. for i:=0 to @'37 do xchr[i]:=' ';
  88. for i:=@'177 to @'377 do xchr[i]:=' ';
  89. @y
  90. for i:=1 to @'37 do xchr[i]:=chr(i);
  91. for i:=@'177 to @'377 do xchr[i]:=chr(i);
  92. @z
  93.  
  94. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  95. % [20] Terminal I/O.
  96. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  97. @x
  98. @d print(#)==write(term_out,#) {`|print|' means write on the terminal}
  99. @y
  100. @d term_out==stdout
  101. @d print(#)==write(term_out,#) {`|print|' means write on the terminal}
  102. @z
  103.  
  104. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  105. % [20] Remove term_out.
  106. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  107. @x
  108. @<Globals...@>=
  109. @!term_out:text_file; {the terminal as an output file}
  110. @y
  111. @z
  112.  
  113. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  114. % [21] Don't initialize the terminal.
  115. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  116. @x
  117. @ Different systems have different ways of specifying that the output on a
  118. certain file will appear on the user's terminal. Here is one way to do this
  119. on the \PASCAL\ system that was used in \.{WEAVE}'s initial development:
  120. @^system dependencies@>
  121.  
  122. @<Set init...@>=
  123. rewrite(term_out,'TTY:'); {send |term_out| output to the terminal}
  124. @y
  125. @ Different systems have different ways of specifying that the output on a
  126. certain file will appear on the user's terminal.
  127. @^system dependencies@>
  128.  
  129. @<Set init...@>=
  130. {nothing need be done}
  131. @z
  132.  
  133. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  134. % [22] `break' is `flush'.
  135. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  136. @x
  137. @d update_terminal == break(term_out) {empty the terminal output buffer}
  138. @y
  139. @d update_terminal == flush(term_out) {empty the terminal output buffer}
  140. @z
  141.  
  142. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  143. % [24] Open input files.
  144. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  145. @x
  146. @ The following code opens the input files.  Since these files were listed
  147. in the program header, we assume that the \PASCAL\ runtime system has
  148. already checked that suitable file names have been given; therefore no
  149. additional error checking needs to be done.
  150. @^system dependencies@>
  151.  
  152. @p procedure open_input; {prepare to read the inputs}
  153. begin reset(mf_file); reset(change_file); reset(style_file);
  154. end;
  155. @y
  156. @ The following code opens the input files.  This is called after
  157. |scan_args| has set the file name variables appropriately.
  158. @^system dependencies@>
  159.  
  160. @p procedure open_input; {prepare to read inputs}
  161. begin
  162.   if test_read_access (mf_file_name, MF_INPUT_PATH)
  163.   then reset (mf_file, mf_file_name)
  164.   else begin
  165.     print_pascal_string (mf_file_name);
  166.     print (': Metafont source file not found');
  167.     uexit (1);
  168.   end;
  169.   
  170.   reset (change_file, change_file_name);
  171.  
  172.   if test_read_access (style_file_name, TEX_INPUT_PATH)
  173.   then reset (style_file, style_file_name)
  174.   else begin
  175.     print_pascal_string (style_file_name);
  176.     print (': Style file not found');
  177.     uexit (1);
  178.   end;
  179. end;
  180. @z
  181.  
  182. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  183. % [26] Opening the .tex file.
  184. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  185. @x
  186. @ The following code opens |tex_file|.
  187. Since this file was listed in the program header, we assume that the
  188. \PASCAL\ runtime system has checked that a suitable external file name has
  189. been given.
  190. @^system dependencies@>
  191.  
  192. @<Set init...@>=
  193. rewrite(tex_file);
  194. @y
  195. @ The following code opens |tex_file|.
  196. The |scan_args| procedure is used to set up |tex_file_name| as required.
  197. @^system dependencies@>
  198.  
  199. @<Set init...@>=
  200. scan_args;
  201. rewrite (tex_file,tex_file_name);
  202. @z
  203.  
  204. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  205. % [28] Fix f^.
  206. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  207. @x
  208. if eof(f) then input_ln:=false
  209. else  begin while not eoln(f) do
  210.     begin buffer[limit]:=xord[f^]; get(f);
  211.     incr(limit);
  212.     if buffer[limit-1]<>" " then final_limit:=limit;
  213.     if limit=buf_size then
  214.       begin while not eoln(f) do get(f);
  215. @y
  216. if eof(f) then input_ln:=false
  217. else  begin while not eoln(f) do
  218.     begin buffer[limit]:=xord[getc(f)];
  219.     incr(limit);
  220.     if buffer[limit-1]<>" " then final_limit:=limit;
  221.     if limit=buf_size then
  222.       begin while not eoln(f) do vgetc(f);
  223. @z
  224.  
  225. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  226. % [31] Fix jump_out.
  227. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  228. @x
  229. @ The |jump_out| procedure just cuts across all active procedure levels
  230. and jumps out of the program. This is the only non-local \&{goto} statement
  231. in \.{MFT}. It is used when no recovery from a particular error has
  232. been provided.
  233.  
  234. Some \PASCAL\ compilers do not implement non-local |goto| statements.
  235. @^system dependencies@>
  236. In such cases the code that appears at label |end_of_MFT| should be
  237. copied into the |jump_out| procedure, followed by a call to a system procedure
  238. that terminates the program.
  239.  
  240. @d fatal_error(#)==begin new_line; print(#); error; mark_fatal; jump_out;
  241.   end
  242.  
  243. @<Error handling...@>=
  244. procedure jump_out;
  245. begin goto end_of_MFT;
  246. end;
  247. @y
  248. @ The |jump_out| procedure cleans up, prints appropriate messa