|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T d
Length: 12492 (0x30cc) Types: TextFile Names: »dvitype.ch«
└─⟦060c9c824⟧ Bits:30007080 DKUUG TeX 2/12/89 └─⟦this⟧ »./tex82/texware/dvitype.ch«
% Change file for the DVItype processor, for use with WEB to C % This file was created by Howard Trickey, CSD.Trickey@SCORE, and modified % by Pavel Curtis, Pavel@Cornell. % History: % ?? (HT) Original version. % 4/4/83 (PC) Merged with Pavel's change file and made to work with the % version 1.0 of DVItype released with version 0.95 of TeX in % February, 1983. % 4/18 (PC) Added changes to module 47 so that it would work the same % when input was a file (or pipe) as with a terminal. % 6/29 (HWT) Brought up to version 1.1 as released with version 0.99 of % TeX, with new change file format % 7/28 (HWT) Brought up to version 2 as released with version 0.999. % Only the banner changes. % 11/21 (HWT) Brought up to version 2.2 as released with version 1.0. % 2/19/84 (HWT) Made it use TEXFONTS environment. % 3/23/84 (HWT) Brought up to version 2.3. % 7/11/84 (HWT) Brought up to version 2.6 as released with version 1.1. % 11/7/84 (ETM) Brought up to version 2.7 as released with version 1.2. % 3/9/88 (ETM) Brought up to version 2.9 % 3/16/88 (ETM) Converted for use with WEB to C. % The module numbers used in this file refer to those in the red-covered % listing (Version 2, July 1983) (same numbers as in blue-covered). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [0] WEAVE: print changes only %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x \pageno=\contentspagenumber \advance\pageno by 1 @y \pageno=\contentspagenumber \advance\pageno by 1 \let\maybe=\iffalse \def\title{DVI$\,$\lowercase{type} changes for C} @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [1] Change banner string %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @d banner=='This is DVItype, Version 2.9' {printed when the program starts} @y @d banner=='This is DVItype, C Version 2.9' {printed when the program starts} @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [3] Change filenames in program statement %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @d print(#)==write(#) @d print_ln(#)==write_ln(#) @p program DVI_type(@!dvi_file,@!output); @y @d print(#)==write(dvityout,#) @d print_ln(#)==write_ln(dvityout,#) @p program DVI_type; @z @x begin print_ln(banner);@/ @y begin setpaths; {read environment, to find TEXFONTS, if there} rewrite(dvityout,'dvitype.out'); {prepare typescript for output} print_ln(banner);@/ @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [5] Increase name_length %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @!name_length=50; {a file name shouldn't be longer than this} @y @!name_length=100; {a file name shouldn't be longer than this} @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Remove non-local goto %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @ If the \.{DVI} file is badly malformed, the whole process must be aborted; \.{DVItype} will give up, after issuing an error message about the symptoms that were noticed. Such errors might be discovered inside of subroutines inside of subroutines, so a procedure called |jump_out| has been introduced. This procedure, which simply transfers control to the label |final_end| at the end of the program, contains the only non-local |goto| statement in \.{DVItype}. @^system dependencies@> @d abort(#)==begin print(' ',#); jump_out; end @d bad_dvi(#)==abort('Bad DVI file: ',#,'!') @.Bad DVI file@> @p procedure jump_out; begin goto final_end; end; @y @ If the \.{DVI} file is badly malformed, the whole process must be aborted; \.{DVItype} will give up, after issuing an error message about the symptoms that were noticed. Such errors might be discovered inside of subroutines inside of subroutines, so a procedure called |jump_out| has been introduced. This procedure is actually a macro which calls exit() with a non-zero exit status. @d jump_out==uexit(1) @d abort(#)==begin print(' ',#); jump_out; end @d bad_dvi(#)==abort('Bad DVI file: ',#,'!') @.Bad DVI file@> @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [23] Fix up opening the binary files %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @p procedure open_dvi_file; {prepares to read packed bytes in |dvi_file|} begin reset(dvi_file); cur_loc:=0; end; @# procedure open_tfm_file; {prepares to read packed bytes in |tfm_file|} begin reset(tfm_file,cur_name); end; @y In C, we use the external |test_access| procedure, which also does path searching based on the user's environment or the default path. @d read_access_mode=4 {``read'' mode for |test_access|} @d write_access_mode=2 {``write'' mode for |test_access|} @d no_file_path=0 {no path searching should be done} @d font_file_path=3 {path specifier for \.{TFM} files} @p procedure open_dvi_file; {prepares to read packed bytes in |dvi_file|} begin if argc <> 2 then begin write_ln('Usage: dvitype <dvi-file>'); jump_out; end; argv(1, cur_name); if test_access(read_access_mode,no_file_path) then reset(dvi_file, real_name_of_file) else begin write_ln('DVI file not found'); jump_out; end; cur_loc:=0; end; @# procedure open_tfm_file; {prepares to read packed bytes in |tfm_file|} begin if test_access(read_access_mode,font_file_path) then reset(tfm_file,real_name_of_file) else begin write_ln('TFM file not found'); jump_out end; end; @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [25] Declare real_name_of_file %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x |dvi_file|, and |cur_name| is a string variable that will be set to the current font metric file name before |open_tfm_file| is called. @<Glob...@>= @!cur_loc:integer; {where we are about to look, in |dvi_file|} @!cur_name:packed array[1..name_length] of char; {external name, with no lower case letters} @y |dvi_file|, and |cur_name| is a string variable that will be set to the current font metric file name before |open_tfm_file| is called. In C, we also have a |real_name_of_file| string, that gets set by the external |test_access| procedure after path searching. @<Glob...@>= @!cur_loc:integer; {where we are about to look, in |dvi_file|} @!cur_name,@!real_name_of_file:packed array[1..name_length] of char; {external name} @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [28] Make dvi_length() and move_to_byte() work. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @p function dvi_length:integer; begin set_pos(dvi_file,-1); dvi_length:=cur_pos(dvi_file); end; @# procedure move_to_byte(n:integer); begin set_pos(dvi_file,n); cur_loc:=n; end; @y @p function dvi_length:integer; begin zfseek(dvi_file, 0, 2); dvi_length:=ftell(dvi_file); end; @# procedure move_to_byte(n:integer); begin zfseek(dvi_file, n, 0); cur_loc:=n; end; @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [45] Define term_in and term_out and declare dvityout %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x and |term_out| for terminal output. @^system dependencies@> @<Glob...@>= @!buffer:array[0..terminal_line_length] of ASCII_code; @!term_in:text_file; {the terminal, considered as an input file} @!term_out:text_file; {the terminal, considered as an output file} @y and |term_out| for terminal output. @^system dependencies@> @d term_in==stdin @d term_out==stdout @<Glob...@>= @!buffer:array[0..terminal_line_length] of ASCII_code; @!dvityout:text; @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [46] Define update_terminal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @d update_terminal == break(term_out) {empty the terminal output buffer} @y @d update_terminal == flush(term_out) {empty the terminal output buffer} @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [47] Fix input_ln. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @p procedure input_ln; {inputs a line from the terminal} var k:0..terminal_line_length; begin update_terminal; reset(term_in); if eoln(term_in) then read_ln(term_in); k:=0; while (k<terminal_line_length)and not eoln(term_in) do begin buffer[k]:=xord[term_in^]; incr(k); get(term_in); end; buffer[k]:=" "; end; @y @p procedure input_ln; {inputs a line from the terminal} var k:0..terminal_line_length; begin update_terminal; if eoln(term_in) then read_ln(term_in); k:=0; while (k<terminal_line_length)and not eoln(term_in) do begin buffer[k]:=xord[getc(term_in)]; incr(k); end; buffer[k]:=" "; end; @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [50] Remove call to rewrite(term_out) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x begin rewrite(term_out); {prepare the terminal for output} @y begin @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Fix printing of floating point number %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x print_ln(' Resolution = ',resolution:12:8,' pixels per inch'); if new_mag>0 then print_ln(' New magnification factor = ',new_mag/1000:8:3) @y print(' Resolution = '); print_real(resolution,12,8); print_ln(' pixels per inch'); if new_mag>0 then begin print(' New magnification factor = '); print_real(new_mag/1000.0,8,3); print_ln('') end @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [64] Set default_directory_name %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @d default_directory_name=='TeXfonts:' {change this to the correct name} @d default_directory_name_length=9 {change this to the correct length} @<Glob...@>= @!default_directory:packed array[1..default_directory_name_length] of char; @y Actually, under UNIX the standard area is defined in an external ``site.h'' file. And the user have a path serached for fonts, by setting the TEXFONTS environment variable. @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [65] Remove initialization of now-defunct array %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @ @<Set init...@>= default_directory:=default_directory_name; @y @ (No initialization to be done. Keep this module to preserve numbering.) @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [66] Fix addition of ".tfm" suffix for portability and keep lowercase %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x @ The string |cur_name| is supposed to be set to the external name of the \.{TFM} file for the current font. This usually means that we need to prepend the name of the default directory, and to append the suffix `\.{.TFM}'. Furthermore, we change lower case letters to upper case, since |cur_name| is a \PASCAL\ string. @y @ The string |cur_name| is supposed to be set to the external name of the \.{TFM} file for the current font. This usually means that we need to, at most sites, append the suffix ``.tfm''. @z @x if p=0 then begin for k:=1 to default_directory_name_length do cur_name[k]:=default_directory[k]; r:=default_directory_name_length; end else r:=0; @y r:=0; @z @x if (names[k]>="a")and(names[k]<="z") then cur_name[r]:=xchr[names[k]-@'40] else cur_name[r]:=xchr[names[k]]; end; cur_name[r+1]:='.'; cur_name[r+2]:='T'; cur_name[r+3]:='F'; cur_name[r+4]:='M' @y cur_name[r]:=xchr[names[k]]; end; cur_name[r+1]:='.'; cur_name[r+2]:='t'; cur_name[r+3]:='f'; cur_name[r+4]:='m' @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [106] Print newline at end of program; remove unused label %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x final_end:end. @y print_ln(' '); end. @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Fix another floating point print %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @x print_ln('magnification=',mag:1,'; ',conv:16:8,' pixels per DVI unit') @y print('magnification=',mag:1,'; '); print_real(conv,16,8); print_ln(' pixels per DVI unit') @z