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

  1. % dvicopy.ch for C compilation with web2c.
  2. % The original version of this file was created by Monika Jayme and
  3. % Klaus Guntermann at TH Darmstadt (THD), FR Germany.
  4. %                                       (xitikgun@ddathd21.bitnet)
  5. % Some parts are borrowed from the changes to dvitype, vftovp and vptovf.
  6. %
  7. % History:
  8. %  July 90   THD  First versions for dvicopy 0.91 and 0.92
  9. %  Aug 09 90 THD  Updated to dvicopy 1.0 and released
  10. %  Mar 20 91 THD  Updated to dvicopy 1.2
  11. %
  12.  
  13.  
  14. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  15. % [0] WEAVE: print changes only
  16. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  17. @x
  18. \pageno=\contentspagenumber \advance\pageno by 1
  19. @y
  20. \pageno=\contentspagenumber \advance\pageno by 1
  21. \let\maybe=\iffalse
  22. @z
  23.  
  24. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  25. % [1] Change banner string and preamble comment
  26. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  27. @x
  28. @d banner=='This is DVIcopy, Version 1.2' {printed when the program starts}
  29. @y
  30. @d banner=='This is DVIcopy, Version 1.2' {more is printed later}
  31. @z
  32.  
  33. @x
  34. @d preamble_comment=='DVIcopy 1.2 output from '
  35. @y
  36. @d preamble_comment==' DVIcopy 1.2 output from '
  37. @z
  38.  
  39. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  40. % [3] Change filenames in program statement
  41. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  42. @x
  43. program DVI_copy(@!dvi_file,@!out_file,@!output);
  44. @y
  45. program DVI_copy;
  46. @z
  47.  
  48. @x
  49.   begin print_ln(banner);@/
  50. @y
  51.   begin print (banner); print_ln (version_string);
  52. @z
  53.  
  54. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  55. % [5] Make name_length match the system constant.
  56. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  57. @x
  58. @<Constants...@>=
  59. @y
  60. @d name_length==PATH_MAX
  61.  
  62. @<Constants...@>=
  63. @z
  64.  
  65. @x
  66. @!name_length=50; {a file name shouldn't be longer than this}
  67. @y
  68. @z
  69.  
  70. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  71. % [11] Use `stdout' instead of `output'.
  72. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  73. @x
  74. @d print(#)==write(output,#)
  75. @y
  76. @d output == stdout
  77. @d print(#)==write(output,#)
  78. @z
  79.  
  80. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  81. % [12] Use C macros for incr/decr
  82. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  83. @x
  84. @d incr(#) == #:=#+1 {increase a variable by unity}
  85. @d decr(#) == #:=#-1 {decrease a variable by unity}
  86. @y
  87. @z
  88.  
  89. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  90. % [14] Permissive input.
  91. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  92. @x
  93. @!ASCII_code=" ".."~"; {a subrange of the integers}
  94. @y
  95. @!ASCII_code=0..255; {a subrange of the integers}
  96. @z
  97.  
  98. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  99. % [15] The text_char type is used as an array index into xord.  The
  100. % default type `char' produces signed integers, which are bad array
  101. % indices in C.
  102. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  103. @x
  104. @d text_char == char {the data type of characters in text files}
  105. @d first_text_char=0 {ordinal number of the smallest element of |text_char|}
  106. @d last_text_char=127 {ordinal number of the largest element of |text_char|}
  107. @y
  108. @d text_char == ASCII_code {the data type of characters in text files}
  109. @d first_text_char=0 {ordinal number of the smallest element of |text_char|}
  110. @d last_text_char=255 {ordinal number of the largest element of |text_char|}
  111. @z
  112.  
  113. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  114. % [23] Remove non-local goto
  115. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  116. @x
  117. @ If an input (\.{DVI}, \.{TFM}, \.{VF}, or other) file is badly malformed,
  118. the whole process must be aborted; \.{\title} will give up, after issuing
  119. an error message about what caused the error. These messages will, however,
  120. in most cases just indicate which input file caused the error. One of the
  121. programs \.{DVItype}, \.{TFtoPL} or \.{VFtoVP} should then be used to
  122. diagnose the error in full detail.
  123.  
  124. Such errors might be discovered inside of subroutines inside of subroutines,
  125. so a procedure called |jump_out| has been introduced. This procedure, which
  126. transfers control to the label |final_end| at the end of the program,
  127. contains the only non-local |@!goto| statement in \.{\title}.
  128. @^system dependencies@>
  129. Some \PASCAL\ compilers do not implement non-local |goto| statements. In
  130. such cases the |goto final_end| in |jump_out| should simply be replaced
  131. by a call on some system procedure that quietly terminates the program.
  132. @^system dependencies@>
  133.  
  134. @d abort(#)==begin print_ln(' ',#,'.'); jump_out;
  135.     end
  136.  
  137. @<Error handling...@>=
  138. @<Basic printing procedures@>@;
  139. procedure close_files_and_terminate; forward;
  140. @#
  141. procedure jump_out;
  142. begin mark_fatal; close_files_and_terminate;
  143. goto final_end;
  144. end;
  145. @y
  146. @ If an input (\.{DVI}, \.{TFM}, \.{VF}, or other) file is badly malformed,
  147. the whole process must be aborted; \.{\title} will give up, after issuing
  148. an error message about what caused the error. These messages will, however,
  149. in most cases just indicate which input file caused the error. One of the
  150. programs \.{DVItype}, \.{TFtoPL} or \.{VFtoVP} should then be used to
  151. diagnose the error in full detail.
  152.  
  153. Such errors might be discovered inside of subroutines inside of subroutines,
  154. so a procedure called |jump_out| has been introduced. This procedure is
  155. actually a macro which calls |uexit()| with a non-zero exit status.
  156.  
  157. @d abort(#)==begin print_ln(' ',#,'.'); jump_out;
  158.     end
  159.  
  160. @<Error handling...@>=
  161. @<Basic printing procedures@>@;
  162. procedure close_files_and_terminate; forward;
  163. @#
  164. procedure jump_out;
  165. begin mark_fatal; close_files_and_terminate;
  166. uexit(1);
  167. end;
  168. @z
  169.  
  170. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  171. % [51] Fix casting problem in C.
  172. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  173. @x
  174. @d comp_spair(#) == if a<128 then #:=a*256+b @+ else #:=(a-256)*256+b
  175. @d comp_upair(#) == #:=a*256+b
  176. @y
  177. @d comp_spair(#) == if a<128 then #:=a*toint(256)+b
  178.                              @+ else #:=(a-toint(256))*toint(256)+b
  179. @d comp_upair(#) == #:=a*toint(256)+b
  180. @z
  181.  
  182. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  183. % [52]
  184. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  185. @x
  186. if a<128 then #:=(a*256+b)*256+c @+ else #:=((a-256)*256+b)*256+c
  187. @d comp_utrio(#) == #:=(a*256+b)*256+c
  188. @y
  189. if a<128 then #:=(a*toint(256)+b)*toint(256)+c @+
  190. else #:=((a-toint(256))*toint(256)+b)*toint(256)+c
  191. @d comp_utrio(#) == #:=(a*toint(256)+b)*toint(256)+c
  192. @z
  193.  
  194. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  195. % [53]
  196. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  197. @x
  198. if a<128 then #:=((a*256+b)*256+c)*256+d
  199. else #:=(((a-256)*256+b)*256+c)*256+d
  200. @y
  201. if a<128 then #:=((a*toint(256)+b)*toint(256)+c)*toint(256)+d
  202. else #:=(((a-toint(256))*toint(256)+b)*toint(256)+c)*toint(256)+d
  203. @z
  204.  
  205. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  206. % [63]
  207. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  208. @x
  209. @ For \.{TFM} and \.{VF} files we just append the apropriate extension
  210. to the file name packet; in addition a system dependent area part
  211. (usually different for \.{TFM} and \.{VF} files) is prepended if
  212. the file name packet contains no area part.
  213. @^system dependencies@>
  214.  
  215. @d append_to_name(#)==
  216.   if cur_name_length<name_length then
  217.     begin incr(cur_name_length); cur_name[cur_name_length]:=#;
  218.     end
  219.   else overflow(str_name_length,name_length)
  220. @d make_font_name_end(#)==
  221.   append_to_name(#[l]); make_name
  222. @d make_font_name(#)==
  223.   cur_name_length:=0; for l:=1 to # do make_font_name_end
  224. @y
  225. @ For \.{TFM} and \.{VF} files we just append the apropriate extension
  226. to the file name packet.
  227. Since files are actually searched through path definitions given in
  228. the environment variables area definitions are ignored here.
  229. To reduce the required changes we ignore most of the parameters given
  230. to |make_font_name| and just keep the requested extension.
  231. @^system dependencies@>
  232.  
  233. @d append_to_name(#)==
  234.