diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2010-04-12 16:35:45 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2010-04-12 16:35:45 +0000 |
commit | 1e19065af9e98c874f6b7d1a229868d9ca2f88bc (patch) | |
tree | e0058c664add0df4f4be7426b362469448ff5062 /Build/source/texk/web2c/dvicopy.ch | |
parent | fc9b52216e92282f7cd5fbc80707650a81e99317 (diff) |
gftopk, pktogf: dynamic memory allocation
git-svn-id: svn://tug.org/texlive/trunk@17819 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/dvicopy.ch')
-rw-r--r-- | Build/source/texk/web2c/dvicopy.ch | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/Build/source/texk/web2c/dvicopy.ch b/Build/source/texk/web2c/dvicopy.ch index c4ff1ee9232..5060d215ebe 100644 --- a/Build/source/texk/web2c/dvicopy.ch +++ b/Build/source/texk/web2c/dvicopy.ch @@ -15,6 +15,13 @@ \let\maybe=\iffalse @z +@x [1] No random reading on stdin, may be not seekable. +@d random_reading==true {should we skip around in the file?} +@y +@<Globals in the outer block@>= +@!random_reading:boolean; {should we skip around in the file?} +@z + @x [3] Set up kpathsea. procedure initialize; {this procedure gets things started properly} var @<Local variables for initialization@>@/ @@ -360,13 +367,13 @@ begin set_pos(dvi_file,n); dvi_loc:=n; end; @y @p function dvi_length:int_32; -begin xfseek(dvi_file, 0, 2, 'dvicopy'); -dvi_loc:=xftell(dvi_file, 'dvicopy'); +begin xfseek(dvi_file, 0, 2, dvi_name); +dvi_loc:=xftell(dvi_file, dvi_name); dvi_length:=dvi_loc; end; @# procedure dvi_move(n:int_32); -begin xfseek(dvi_file, n, 0, 'dvicopy'); +begin xfseek(dvi_file, n, 0, dvi_name); dvi_loc:=n; end; @z @@ -569,24 +576,27 @@ begin {Now |optind| is the index of first non-option on the command line. We can have zero, one, or two remaining arguments.} + if (optind > argc) or (optind + 2 < argc) then begin + write_ln (stderr, 'dvicopy: Need at most two file arguments.'); + usage ('dvicopy'); + end; + if optind = argc then begin + dvi_name := '<stdin>'; dvi_file := make_binary_file (stdin); - out_file := make_binary_file (stdout); - term_out := stderr; - - end else if optind + 1 = argc then begin - resetbin (dvi_file, extend_filename (cmdline (optind), 'dvi')); - out_file := make_binary_file (stdout); - term_out := stderr; + random_reading := false; + end else begin + dvi_name := extend_filename (cmdline (optind), 'dvi'); + resetbin (dvi_file, dvi_name); + random_reading := true; + end; - end else if optind + 2 = argc then begin - resetbin (dvi_file, extend_filename (cmdline (optind), 'dvi')); + if optind + 2 = argc then begin rewritebin (out_file, extend_filename (cmdline (optind + 1), 'dvi')); term_out := stdout; - end else begin - write_ln (stderr, 'dvicopy: Need at most two file arguments.'); - usage ('dvicopy'); + out_file := make_binary_file (stdout); + term_out := stderr; end; end; @@ -683,4 +693,5 @@ long_options[current_option].val := 0; @ @<Glob...@> = @!term_out:text; +@!dvi_name:const_c_string; @z |