% TOPS-20 change file for PKtoGF by Tomas Rokicki. Send bug reports to % rokicki@sushi.stanford.edu. @x [1] \pageno=\contentspagenumber \advance\pageno by 1 @y \pageno=\contentspagenumber \advance\pageno by 1 \let\maybe=\iffalse \def\ttw{{\mc TOPS-20}} \def\title{PKtoGF changes for \ttw} @z @x [4] @d banner=='This is PKtoGF, Version 1.0' @y @d banner=='This is PKtoGF, TOPS-20 Version 1.0' @z @x [6] @d print_ln(#)==write_ln(output,#) @d print(#)==write(output,#) @y @d print_ln(#)==write_ln(tty,#) @d print(#)==write(tty,#) @z @x [6] @p program PKtoGF(input, output); @y @p program PKtoGF; @z @x [8] @= @y @= @!max_rescan=200; {maximum length of a command line} @z @x [56] @p procedure open_gf_file; {prepares to write packed bytes in a |gf_file|} begin rewrite(gf_file,gf_name); gf_loc := 0 ; end; @# procedure open_pk_file; {prepares the input for reading} begin reset(pk_file,pk_name); pk_loc := 0 ; end; @y @p procedure open_gf_file; {prepares to write packed bytes in a |gf_file|} begin rewrite(gf_file,gf_name,'/O/B:8'); gf_loc := 0 ; end; @# procedure open_pk_file; {prepares the input for reading} begin reset(pk_file,pk_name,'/O/B:8'); pk_loc := 0 ; end; @z @x [92] @d get_line(#) == if eoln(input) then read_ln(input) ; i := 1 ; while not (eoln(input) or eof(input)) do begin #[i] := input^ ; incr(i) ; get(input) ; end ; #[i] := ' ' @y @d get_line(#) == if eoln(tty) then read_ln(tty) ; i := 1 ; while not (eoln(tty) or eof(tty)) do begin #[i] := tty^ ; incr(i) ; get(tty) ; end ; #[i] := ' ' @z @x [96] initialize ; dialog ; @y initialize ; startup := true ; @ ; if not startup then dialog ; @z @x [99] @* System-dependent changes. This section should be replaced, if necessary, by changes to the program that are necessary to make \.{PKtoGF} work at a particular installation. Any additional routines should be inserted here. @^system dependencies@> @y @* System-dependent changes. This section should be replaced, if necessary, by changes to the program that are necessary to make \.{PKtoGF} work at a particular installation. Any additional routines should be inserted here. @^system dependencies@> We call a system procedure to put the command line into the input buffer. We then read it in, skipping over the program name to the first blank. @d RSCAN=@'500 {ReSCAN buffer JSYS} @= jsys(RSCAN,1,i;0;j); {get the command line} if (i<>2) or (j<=0) then startup := false else begin if eoln(tty) then read_ln(tty); {for some TOPS-20's} read(tty,rescan_buffer:rescan_len); {read in rescan buffer} if rescan_len>max_rescan then abort('command line too long!'); read_ln(tty); if rescan_len=j-2 then startup := false else begin i:=1; while rescan_buffer[i]>' 'do incr(i); {skip invocation} while(i<=rescan_len) and (rescan_buffer[i]=' ')do incr(i); {skip spaces} if i>rescan_len then startup := false else begin for j := 1 to name_length do begin pk_name[j] := ' ' ; gf_name[j] := ' ' ; end ; j := 1 ; last_ext := -1 ; while ( i <= rescan_len ) and ( rescan_buffer[i] <> ' ' ) and ( rescan_buffer[i] <> '/' ) do begin pk_name[j] := rescan_buffer[i] ; gf_name[j] := rescan_buffer[i] ; if (rescan_buffer[i] = '.') and (last_ext = -1) then last_ext := j ; if rescan_buffer[i] in [':',']','>'] then last_ext := -1 ; incr(j) ; incr(i) ; end ; if last_ext = -1 then begin last_ext := j ; pk_name[j] := '.' ; pk_name[j+1] := 'p' ; pk_name[j+2] := 'k' ; end ; gf_name[last_ext] := '.' ; gf_name[last_ext+1] := 'g' ; gf_name[last_ext+2] := 'f' ; for i := last_ext+3 to name_length do gf_name[i] := ' ' ; end ; end ; end @ @= @!rescan_buffer:packed array[1..max_rescan] of char; @!rescan_len:integer; @!startup : boolean ; {did we have a file name?} @!last_ext : integer ; {where was the dot?} @z