diff options
Diffstat (limited to 'Build/source/texk/web2c/omegaware/odvicopy.web')
-rw-r--r-- | Build/source/texk/web2c/omegaware/odvicopy.web | 110 |
1 files changed, 56 insertions, 54 deletions
diff --git a/Build/source/texk/web2c/omegaware/odvicopy.web b/Build/source/texk/web2c/omegaware/odvicopy.web index cda08cc427f..a1bb27e5c78 100644 --- a/Build/source/texk/web2c/omegaware/odvicopy.web +++ b/Build/source/texk/web2c/omegaware/odvicopy.web @@ -1,5 +1,5 @@ % odvicopy.web: Omega version of file dvicopy.web -% +% % This file is part of the Omega project, which % is based in the web2c distribution of TeX. % @@ -23,6 +23,8 @@ % don't load fonts that are never used (August 25, 1992). % Version 1.4 fixed a typo (March 28, 1995). % Version 1.5 avoided cur_name_length identifier conflict (October 15, 1995). +% Version 1.6 minor cleanup: avoid unused or uninitialized variables, +% diagnose impossible cases (September 2009). % Here is TeX material that gets inserted after \input webmac \def\hang{\hangindent 3em\indent\ignorespaces} @@ -48,7 +50,7 @@ 1994,97 John Plaice and Yannis Haralambous} \centerline{Distributed under terms of GNU General Public License} \vskip 15pt - \centerline{(Version 1.5, March 1997)} + \centerline{(Version 1.6, September 2009)} \vfill} \def\botofcontents{\vfill \centerline{\hsize 5in\baselineskip9pt @@ -111,12 +113,12 @@ References to \.{DVIcopy} also apply to \.{ODVIcopy}. The |banner| and |preamble_comment| strings defined here should be changed whenever \.{ODVIcopy} gets modified. -@d banner=='This is ODVIcopy, Version 1.5' {printed when the program starts} +@d banner=='This is ODVIcopy, Version 1.6' {printed when the program starts} @d title=='ODVIcopy' {the name of this program, used in some messages} @d copyright== - '(C) 1990,95 P. Breitenlohner, 1994,97 J. Plaice and Y. Haralambous' + '(C) 1990,2009 P. Breitenlohner, 1994,98 J. Plaice and Y. Haralambous' @# -@d preamble_comment=='ODVIcopy 1.5 output from ' +@d preamble_comment=='ODVIcopy 1.6 output from ' @d comm_length=25 {length of |preamble_comment|} @d from_length=6 {length of its |' from '| part} @@ -1116,10 +1118,10 @@ or, if |upd=false|, a |put| command. var o:eight_bits; {|set1| or |put1|} begin @d comp_char(#) == +o:=dvi_char_cmd[upd]; {|set1| or |put1|} if (res>=0) and (res<@"100) then begin if (not upd)or(res>127)or(ext<>0) then - begin o:=dvi_char_cmd[upd]; {|set1| or |put1|} - if ext<0 then Incr(ext)(@"1000000); + begin if ext<0 then Incr(ext)(@"1000000); if ext=0 then #(o) @+ else @; begin if ext<@"100 then #(o+1) @+ else @; begin if ext<@"10000 then #(o+2) @+ else @; @@ -1639,8 +1641,8 @@ label found,exit; var p,@!q:pckt_pointer; {current and next packet} @!f:eight_bits; {a flag byte} @!e:int_24; {extension for a packet} -begin @<Locate a character packet and |goto found| if found@>; -if font_packet(cur_fnt)(cur_res)=invalid_packet then +begin q:=font_packet(cur_fnt)(cur_res); +if q=invalid_packet then begin if pckt_m_msg<10 then {stop telling after first 10 times} begin print_ln('---missing character packet for character ',cur_res:1, @.missing character packet...@> @@ -1650,6 +1652,7 @@ if font_packet(cur_fnt)(cur_res)=invalid_packet then end; find_packet:=false; return; end; +@<Locate a character packet and |goto found| if found@>; if pckt_s_msg<10 then {stop telling after first 10 times} begin print_ln('---substituted character packet with extension ', @.substituted character packet...@> @@ -1663,9 +1666,7 @@ found: cur_pckt:=p; cur_type:=f; find_packet:=true; exit: end; @ @<Locate a character packet and |goto found| if found@>= -q:=font_packet(cur_fnt)(cur_res); -while q<>invalid_packet do - begin p:=q; q:=invalid_packet; +repeat p:=q; q:=invalid_packet; cur_loc:=pckt_start[p]; cur_limit:=pckt_start[p+1]; if p=empty_packet then begin e:=0; f:=0; @@ -1675,13 +1676,13 @@ while q<>invalid_packet do 0: e:=0; 1: e:=pckt_ubyte; 2: e:=pckt_upair; - 3: e:=pckt_strio; - end; {there are no other cases} + othercases e:=pckt_strio; {|f div ext_flag = 3|} + endcases; if (f mod ext_flag)>=chain_flag then q:=pckt_upair; f:=f mod chain_flag; end; if e=cur_ext then goto found; - end +until q=invalid_packet @ The |start_packet| procedure is used to create the header bytes of a character packet for the character with residue~|cur_res| and @@ -1696,7 +1697,8 @@ var p,@!q:pckt_pointer; {current and next packet} @!e:int_32; {extension for a packet} @!cur_loc: byte_pointer; {current location in a packet} @!cur_limit: byte_pointer; {start of next packet} -begin @<Locate a character packet and |goto found| if found@>; +begin q:=font_packet(cur_fnt)(cur_res); +if q<>invalid_packet then @<Locate a character packet...@>; q:=font_packet(cur_fnt)(cur_res); pckt_dup:=false; goto not_found; found: pckt_dup:=true; pckt_prev:=p; not_found: pckt_ext:=cur_ext; pckt_res:=cur_res; pckt_room(6); @@ -1798,7 +1800,8 @@ case font_type(cur_fnt) of defined_font: confusion(str_fonts); loaded_font: bad_tfm; @<Cases for |bad_font|@>@;@/ - end; {there are no other cases} + othercases abort('internal error'); + endcases; end; @ To prepare |tfm_file| for input we |reset| it. @@ -1812,10 +1815,8 @@ if eof(tfm_file) then begin if eof(tfm_file) then @^system dependencies@> abort('---not loaded, TFM or OFM file can''t be opened!') - else font_extend(cur_fnt):=true @.TFM or OFM file can\'t be opened@> end -else font_extend(cur_fnt):=false @ It turns out to be convenient to read four bytes at a time, when we are inputting from \.{TFM} files. The input goes into global variables @@ -1999,13 +2000,14 @@ read_tfm_word; if first_two<>0 then tfm_width:=tfm_b0 else begin if # then read_tfm_word; - tfm_b01(tfm_width); + tfm_width:=tfm_b0*256+tfm_b1; end end @<TFM: Read past the header data@>= read_tfm_word; tfm_b01(first_two); if (first_two<>0) then begin + font_extend(cur_fnt):=false; ofm_level:=-1; tfm_b23(lh); read_tfm_word; tfm_b01(bc); tfm_b23(ec); @@ -2027,6 +2029,7 @@ if (first_two<>0) then begin end end else begin + font_extend(cur_fnt):=true; tfm_b23(ofm_level); read_tfm_word; tfm_b03(lf); read_tfm_word; tfm_b03(lh); @@ -2044,7 +2047,7 @@ else begin end; if ofm_level=1 then begin read_tfm_word; - nco:=(((tfm_b0*256+tfm_b1)*256+tfm_b2)*256+tfm_b3) div 2; + nco:=((tfm_b0*256+tfm_b1)*256+tfm_b2)*256+tfm_b3; read_tfm_word; read_tfm_word; extra_words:=(((tfm_b0*256+tfm_b1)*256+tfm_b2)*256+tfm_b3) div 2; for l:=1 to 12 do @@ -2093,7 +2096,7 @@ else begin if ec>=max_chars-font_chars(cur_fnt) then overflow(str_chars,max_chars); font_ec(cur_fnt):=ec; l:=bc; - while l<ec do begin + while l<=ec do begin read_tfm_word; tfm_width:=tfm_b0*256+tfm_b1; char_widths[n_chars]:=tfm_width; incr(n_chars); @@ -2102,7 +2105,7 @@ else begin for j:=l+1 to lprime do begin char_widths[n_chars]:=tfm_width; incr(n_chars); end; - l:=lprime; + l:=lprime+1; for j:=1 to extra_words do read_tfm_word; end; @@ -2529,19 +2532,15 @@ if cur_cmd<set1 then end else begin cur_res:=#; cur_upd:=(cur_cmd<put1); Decr(cur_cmd)(dvi_char_cmd[cur_upd]); - if font_extend(cur_fnt) then - begin - cur_ext:=0; - while cur_cmd>0 do - begin - cur_res:=cur_res*256+#; decr(cur_cmd); - end + if (cur_cmd=3)and(cur_res>127) then cur_res:=cur_res-128; + while cur_cmd>0 do + begin cur_ext:=cur_ext*256+cur_res; cur_res:=#; decr(cur_cmd); + end; + set_cur_char_tail +@d set_cur_char_tail(#)== + if font_extend(#) then + begin cur_res:=256*cur_ext+cur_res; cur_ext:=0; end - else - while cur_cmd>0 do - begin if cur_cmd=3 then if cur_res>127 then cur_ext:=-1; - cur_ext:=cur_ext*256+cur_res; cur_res:=#; decr(cur_cmd); - end; end; end @@ -2549,7 +2548,7 @@ end begin repeat cur_cmd:=dvi_ubyte; until cur_cmd<>nop; {skip over |nop|s} case dvi_par[cur_cmd] of -char_par: set_cur_char(dvi_ubyte); +char_par: set_cur_char(dvi_ubyte)(cur_fnt); no_par: do_nothing; dim1_par: cur_parm:=dvi_sbyte; num1_par: cur_parm:=dvi_ubyte; @@ -2793,7 +2792,6 @@ begin x:=vf_squad; if x<=0 then bad_font @+ else vf_pquad:=x; end; @# function vf_fixp:int_31; {result must be positive} -var x:int_32; {accumulator} begin vf_byte(tfm_b0); vf_byte(tfm_b1); vf_byte(tfm_b2); vf_byte(tfm_b3); Incr(vf_loc)(4);@/ if tfm_b0>0 then bad_font; @@ -2817,7 +2815,7 @@ set_cur_wp_end begin cur_cmd:=vf_ubyte; case dvi_par[cur_cmd] of char_par: - begin set_cur_char(vf_ubyte); set_cur_wp(vf_cur_fnt)(bad_font); + begin set_cur_char(vf_ubyte)(vf_cur_fnt); set_cur_wp(vf_cur_fnt)(bad_font); end; no_par: do_nothing; dim1_par: cur_parm:=vf_fix1; @@ -2834,7 +2832,8 @@ rule_par: cur_upd:=(cur_cmd=set_rule); end; fnt_par:cur_parm:=cur_cmd-fnt_num_0; -end; {there are no other cases} +othercases abort('internal error'); +endcases; cur_class:=dvi_cl[cur_cmd]; end; @@ -2907,8 +2906,7 @@ font type is changed to |vf_font_type|. @p function do_vf:boolean; {read a \.{VF} file} label reswitch,done,not_found,exit; -var temp_int:int_32; {integer for temporary variables} -@!temp_byte:int_8u; {byte for temporary variables} +var temp_byte:int_8u; {byte for temporary variables} @!k:byte_pointer; {index into |byte_mem|} @!l:int_15; {general purpose variable} @!save_ext:int_24; {used to save |cur_ext|} @@ -3058,12 +3056,12 @@ begin if cur_cmd<long_char then begin vf_limit:=cur_cmd; cur_ext:=0; cur_res:=vf_ubyte; vf_wp:=check_width(vf_fix3u); end -else if font_extend(cur_fnt) then - begin vf_limit:=vf_uquad; - cur_ext:=0; cur_res:=vf_squad; vf_wp:=check_width(vf_fix4); - end else begin vf_limit:=vf_uquad; - cur_ext:=vf_strio; cur_res:=vf_ubyte; vf_wp:=check_width(vf_fix4); + cur_ext:=vf_strio; cur_res:=vf_ubyte; + if font_extend(cur_fnt) then + begin cur_res:=256*cur_ext+cur_res; cur_ext:=0; + end; + vf_wp:=check_width(vf_fix4); end; Incr(vf_limit)(vf_loc); vf_push_loc[0]:=byte_ptr; vf_last_end[0]:=byte_ptr; @@ -3107,7 +3105,8 @@ reswitch:case cur_class of fnt_cl: vf_font; fnt_def_cl: bad_font; invalid_cl: if cur_cmd<>nop then bad_font; - end; {there are no other cases} + othercases abort('internal error'); + endcases; if vf_loc<vf_limit then vf_first_par else if last_pop then goto done else begin cur_class:=pop_cl; last_pop:=true; {final |pop|} @@ -3150,7 +3149,8 @@ else case cur_class of char_cl: move_zero:=(not cur_upd)or(vf_cur_fnt<>vf_fnt); rule_cl: move_zero:=not cur_upd; xxx_cl: move_zero:=true; -end; {there are no other cases} +othercases abort('internal error'); +endcases; if move_zero then begin decr(byte_ptr); decr(vf_ptr); end; @@ -3319,7 +3319,7 @@ processed. @<Set init...@>= n_opt:=0; {change this to indicate the presence of command line options} k_opt:=0; {just in case} - + @ The |input_ln| routine waits for the user to type a line at his or her terminal; then it puts ASCII-code equivalents for the characters on that line into the |byte_mem| array as a temporary string. \PASCAL's @@ -3894,10 +3894,11 @@ and draw boxes or leave blank spaces in the output. @p procedure do_font;@/ label done;@/ +var p:char_pointer; {index into |char_widths| and |char_pixels|} @<OUT: Declare additional local variables for |do_font|@>@; -@!p:char_pointer; {index into |char_widths| and |char_pixels|} begin @!debug if font_type(cur_fnt)=defined_font then confusion(str_fonts); gubed@; +p:=0; {such that |p| is used} @!device for p:=font_chars(cur_fnt)+font_bc(cur_fnt) to font_chars(cur_fnt)+font_ec(cur_fnt) do char_pixels[p]:=h_pixel_round(widths[char_widths[p]]); @@ -3926,7 +3927,7 @@ first parameter (if any) and |cur_class| to the command class. @p procedure pckt_first_par; begin cur_cmd:=pckt_ubyte; case dvi_par[cur_cmd] of -char_par: set_cur_char(pckt_ubyte); +char_par: set_cur_char(pckt_ubyte)(cur_fnt); no_par: do_nothing; dim1_par: cur_parm:=pckt_sbyte; num1_par: cur_parm:=pckt_ubyte; @@ -3940,7 +3941,8 @@ rule_par: cur_upd:=(cur_cmd=set_rule); end; fnt_par:cur_parm:=cur_cmd-fnt_num_0; -end; {there are no other cases} +othercases abort('internal error'); +endcases; cur_class:=dvi_cl[cur_cmd]; end; @@ -4211,7 +4213,8 @@ loop begin fnt_cl: dvi_font; fnt_def_cl: dvi_do_font(random_reading); invalid_cl: goto done; - end; {there are no other cases} + othercases abort('internal error'); + endcases; dvi_first_par; {get the next command} end @@ -4590,7 +4593,6 @@ out_four(cur_v_dimen); out_four(cur_h_dimen); the variable |@!p| is already declared. @<OUT: Declare additional local variables for |do_font|@>= -var @ And here is the device dependent code for |do_font|; if the \.{VF} file for a font could not be found, we simply assume this must be a real font. |