home *** CD-ROM | disk | FTP | other *** search
/ Dream 45 / Amiga_Dream_45.iso / Amiga / Magazine / Dossier-LaTeX / AmiWeb2C.lha / source / web2c-6.1 / web2c / mp / mp.chch < prev    next >
Text File  |  1995-04-10  |  9KB  |  307 lines

  1. Changes for MP.CH by Andreas Scherer, April 10, 1995.
  2.  
  3. @x l.301 of MP.WEB
  4. @^system dependencies@>
  5. @y
  6. @^system dependencies@>
  7.  
  8. @d file_name_size == PATH_MAX
  9. @z
  10.  
  11. @x l.135
  12. @!file_name_size=FILENAMESIZE; {file names shouldn't be longer than this}
  13. @y
  14. @z
  15.  
  16. @x l.680 of MP.WEB
  17. @!alpha_file=packed file of text_char; {files that contain textual data}
  18. @!byte_file=packed file of eight_bits; {files that contain binary data}
  19. @y
  20. @z
  21.  
  22. Undo this change in MP.CH completely.
  23.  
  24. @x l.217
  25. is crucial for our purposes.  We make real_name_of_file hold the
  26. |name_of_file| plus a directory specifier to open the file in Unix.
  27. @^system dependencies@>
  28.  
  29. @<Glob...@>=
  30. @!name_of_file,@!real_name_of_file:packed array[1..file_name_size] of char;@;@/
  31.   {on some systems this may be a \&{record} variable}
  32. @!name_length:0..file_name_size;@/{this many characters are actually
  33.   relevant in |name_of_file| (the rest are blank)}
  34. @y
  35. is crucial for our purposes. We shall assume that |name_of_file| is a variable
  36. of an appropriate type such that the \PASCAL\ run-time system being used to
  37. implement \MP\ can open a file whose external name is specified by
  38. |name_of_file|.
  39. @^system dependencies@>
  40.  
  41. @<Glob...@>=
  42. @!name_of_file:packed array[1..file_name_size] of char;@;@/
  43.   {on some systems this may be a \&{record} variable}
  44. @!name_length:0..file_name_size;@/{this many characters are actually
  45.   relevant in |name_of_file| (the rest are blank)}
  46. @z
  47.  
  48. Path searching is done with KPathSea.
  49.  
  50. @x l.292
  51. An external C procedure, |test_access| is used to check whether or not the
  52. open will work, and it returns
  53. |true| or |false|. The |name_of_file| global holds the file name whose access
  54. is to be tested.
  55. The first parameter for |test_access| is the access mode,
  56. one of |read_access_mode| or |write_access_mode|.
  57.  
  58. We also implement path searching in |test_access|:  its second parameter is
  59. one of the ``file path'' constants defined below.  If |name_of_file|
  60. doesn't start with |'/'| then |test_access| tries prepending pathnames
  61. from the appropriate path list until success or the end of path list
  62. is reached.
  63. On return, |real_name_of_file| contains the original name with the path
  64. that succeeded (if any) prepended.  It is the name used in the various
  65. open procedures.
  66.  
  67. Note that |a_open_in| has been redefined to take an additional argument,
  68. which should be one of the ``file path'' specifiers.
  69. Path searching is not done for output files.
  70.  
  71. In the C-Version |X_open_in| and |X_open_out|, |w_open_in| and |w_open_out|
  72. are completely replaced by C preprocessor macros.  We retain
  73. the testaccess() routine since it was already written in C and it
  74. implements the path searching mechanism.
  75. @d read_access_mode=4  {``read'' mode for |test_access|}
  76. @d write_access_mode=2 {``write'' mode for |test_access|}
  77.  
  78. @d no_file_path=0    {no path searching should be done}
  79. @d TeX_font_file_path=3 {path specifier for \.{TFM} files}
  80. @d MF_input_file_path=6 {path specifier for \.{.mf} \.{input} files}
  81. @d MP_input_file_path=9 {path specifier for \.{input} files}
  82. @d MP_mem_file_path=10 {path specifier for \.{MEM} files}
  83. @d MP_pool_file_path=11  {path specifier for the pool file}
  84.  
  85. @y
  86. @d no_file_path=-1 {no path searching should be done}
  87. @z
  88.  
  89. Path searching is done with KPathSea.
  90.  
  91. @x l.535
  92. if a_open_in(pool_file,MP_pool_file_path) then
  93. @y
  94. if a_open_in(pool_file,MP_POOL_PATH) then
  95. @z
  96.  
  97. @x l.588
  98. if (history <> spotless) and (history <> warning_issued) then
  99.     uexit(1)
  100. else
  101.     uexit(0);
  102. @y
  103. uexit(history);
  104. @z
  105.  
  106. @x l.3389 of MP.WEB
  107. @!word_file = file of memory_word;
  108. @y
  109. @=#include "texmfmem.h";@>
  110. @z
  111.  
  112. `abs()' will be done by ways of a C macro, so we don't want to evaluate
  113. `take_fraction' multiple times (it's in the `inner loop', remember!).
  114.  
  115. @x l.8078 of MP.WEB
  116. get_pen_scale:=s*square_rt(abs(take_fraction(a,d)-take_fraction(b,c)));
  117. @y
  118. a:=take_fraction(a,d)-take_fraction(b,c);
  119. get_pen_scale:=s*square_rt(abs(a));
  120. @z
  121.  
  122. This change is necessary for file name conventions of the AmigaOS.
  123. Probably it won't hurt the UNIX syntax.
  124.  
  125. @x l.936
  126. else  begin if (c="/") then
  127. @y
  128. else  begin if (c="/")or(c=":") then
  129. @z
  130.  
  131. @x l.956
  132. @d mem_default_length=9 {length of the |MP_mem_default| string}
  133. @d mem_area_length=0 {length of its area part}
  134. @d mem_ext_length=4 {length of its `\.{.mem}' part}
  135. @d mem_extension=".mem" {the extension, as a \.{WEB} constant}
  136.  
  137. @<Glob...@>=
  138. @!MP_mem_default:packed array[1..mem_default_length] of char;
  139. @y
  140. @d mem_area_length=0 {length of its area part}
  141. @d mem_ext_length=4 {length of its `\.{.mem}' part}
  142. @d mem_extension=".mem" {the extension, as a \.{WEB} constant}
  143.  
  144. @<Glob...@>=
  145. @!mem_default_length: integer;
  146. @!MP_mem_default: c_char_pointer;
  147. @z
  148.  
  149. Undo this change in MP.CH completely.
  150.  
  151. @x l.1014
  152. which simply makes a \MP\ string from the value of |name_of_file|, should
  153. ideally be changed to deduce the full name of file~|f|, which is the file
  154. most recently opened, if it is possible to do this in a \PASCAL\ program.
  155. With the C version, we know that |real_name_of_file|
  156. contains |name_of_file| prepended with the directory name that was found
  157. by path searching.
  158. If |real_name_of_file| starts with |'./'|, we don't use that part of the
  159. name, since {\mc UNIX} users understand that.
  160. @^system dependencies@>
  161.  
  162. This routine might be called after string memory has overflowed, hence
  163. we dare not use `|str_room|'.
  164.  
  165. @p function make_name_string:str_number;
  166. var @!k,@!kstart:1..file_name_size; {index into |name_of_file|}
  167. begin
  168. k:=1;
  169. while (k<file_name_size) and (xord[real_name_of_file[k]]<>" ") do
  170.     incr(k);
  171. name_length:=k-1; {the real |name_length|}
  172. if str_overflowed then
  173.   make_name_string:="?"
  174. else  begin
  175.   if (xord[real_name_of_file[1]]=".") and (xord[real_name_of_file[2]]="/") then
  176.     kstart:=3
  177.   else
  178.     kstart:=1;
  179.   str_room(name_length-kstart-1);
  180.   for k:=kstart to name_length do append_char(xord[real_name_of_file[k]]);
  181.   make_name_string:=make_string;
  182.   end;
  183. end;
  184. @y
  185. which simply makes a \MP\ string from the value of |name_of_file|, should
  186. ideally be changed to deduce the full name of file~|f|, which is the file
  187. most recently opened, if it is possible to do this in a \PASCAL\ program.
  188. @^system dependencies@>
  189.  
  190. This routine might be called after string memory has overflowed, hence
  191. we dare not use `|str_room|'.
  192.  
  193. @p function make_name_string:str_number;
  194. var @!k:1..file_name_size; {index into |name_of_file|}
  195. begin if (pool_ptr+name_length>pool_size)or(str_ptr=max_strings) then
  196.   make_name_string:="?"
  197. else  begin for k:=1 to name_length do append_char(xord[name_of_file[k]]);
  198.   make_name_string:=make_string;
  199.   end;
  200. end;
  201. @z
  202.  
  203. Undo this change in MP.CH completely.
  204.  
  205. @x l.1061
  206. {These are all replaced by macros in C which call makenamestring}
  207. @y
  208. function a_make_name_string(var @!f:alpha_file):str_number;
  209. begin a_make_name_string:=make_name_string;
  210. end;
  211. function b_make_name_string(var @!f:byte_file):str_number;
  212. begin b_make_name_string:=make_name_string;
  213. end;
  214. function w_make_name_string(var @!f:word_file):str_number;
  215. begin w_make_name_string:=make_name_string;
  216. end;
  217. @z
  218.  
  219. Path searching is done with KPathSea.
  220.  
  221. @x l.1115
  222.   try_extension:=a_open_in(cur_file,MF_input_file_path)
  223. else try_extension:=a_open_in(cur_file,MP_input_file_path);
  224. @y
  225.   try_extension:=a_open_in(cur_file,MF_INPUT_PATH)
  226. else try_extension:=a_open_in(cur_file,MP_INPUT_PATH);
  227. @z
  228.  
  229. This fixes a problem in the first step of the TRAP test.
  230. At least with SAS/C++ 6.55 on the Amiga it is not possible to
  231. write to a file whose file pointer is still active in READ mode.
  232.  
  233. @x l.14520
  234. @ Open |wr_file[n]| using file name~|s| and update |wr_fname[n]|.
  235.  
  236. @p procedure open_write_file(s:str_number; n:readf_index);
  237. begin str_scan_file(s);
  238. pack_cur_name;
  239. while not a_open_out(wr_file[n]) do
  240.   prompt_file_name("file name for write output","");
  241. wr_fname[n]:=s;
  242. add_str_ref(s);
  243. end;
  244. @y
  245. @ Open |wr_file[n]| using file name~|s| and update |wr_fname[n]|.
  246. The Amiga operating system does not permit write access to a file that is
  247. currently opened in read mode.  To avoid desaster, we look for the file to
  248. be opened in the list of |read_from| files and close it if present.
  249.  
  250. @d amiga==ifdef('_AMIGA')
  251. @d agima==endif('_AMIGA')
  252.  
  253. @p procedure open_write_file(s:str_number; n:readf_index);
  254. amiga@;
  255. label done;
  256. var @!n0:readf_index; {Scratch variable}
  257. agima@;
  258. begin
  259.   str_scan_file(s);
  260.   pack_cur_name;
  261. amiga@;
  262.   for n0:=0 to read_files-1 do begin
  263.     if rd_fname[n0]<>0 then begin
  264.       if str_vs_str(s,rd_fname[n0])=0 then begin
  265.         a_close(rd_file[n0]);
  266.         delete_str_ref(rd_fname[n0]);
  267.         rd_fname[n0]:=0;
  268.         if n0=read_files-1 then read_files:=n0;
  269.         goto done;
  270.       end;
  271.     end;
  272.   end;
  273. done: do_nothing;
  274. agima@;
  275. while not a_open_out(wr_file[n]) do
  276.   prompt_file_name("file name for write output","");
  277. wr_fname[n]:=s;
  278. add_str_ref(s);
  279. end;
  280. @z
  281.  
  282. @x l.1275
  283. if a_open_in(ps_tab_file,MP_pool_file_path) then
  284. @y
  285. if a_open_in(ps_tab_file,MP_POOL_PATH) then
  286. @z
  287.  
  288. @x l.1340
  289. set_paths;
  290. @y
  291. set_paths (
  292.   MP_MEM_PATH_BIT +
  293.   MP_INPUT_PATH_BIT +
  294.   MP_POOL_PATH_BIT +
  295.   TFM_FILE_PATH_BIT +
  296.   MF_INPUT_PATH_BIT);
  297. @z
  298.  
  299. @x l.1356
  300. if (history <> spotless) and (history <> warning_issued) then
  301.     uexit(1)
  302. else
  303.     uexit(0);
  304. @y
  305. uexit(history);
  306. @z
  307.