Debian Codegraph @

texk/web2c/dvitype.ch

raw
1 % dvitype.ch for C compilation with web2c.
2 %
3 % 04/04/83 (PC) Merged with Pavel's change file and made to work with the
4 % version 1.0 of DVItype released with version 0.95 of TeX in
5 % February, 1983.
6 % 04/18/83 (PC) Added changes to module 47 so that it would work the same
7 % when input was a file (or pipe) as with a terminal.
8 % 06/29/83 (HWT) Brought up to version 1.1 as released with version 0.99 of
9 % TeX, with new change file format
10 % 07/28/83 (HWT) Brought up to version 2 as released with version 0.999.
11 % Only the banner changes.
12 % 11/21/83 (HWT) Brought up to version 2.2 as released with version 1.0.
13 % 02/19/84 (HWT) Made it use the TEXFONTS environment variable.
14 % 03/23/84 (HWT) Brought up to version 2.3.
15 % 07/11/84 (HWT) Brought up to version 2.6 as released with version 1.1.
16 % 11/07/84 (ETM) Brought up to version 2.7 as released with version 1.2.
17 % 03/09/88 (ETM) Brought up to version 2.9
18 % 03/16/88 (ETM) Converted for use with WEB to C.
19 % 11/30/89 (KB) To version 3.
20 % 01/16/90 (SR) To version 3.2.
21 % (more recent changes in the ChangeLog)
22
23 @x [0] l.29
24 \def\(#1){} % this is used to make section names sort themselves better
25 @y
26 \def\({} % this is used to make section names sort themselves better
27 @z
28
29 @x [0] l.32
30 \def\title{DVI$\,$\lowercase{type}}
31 @y
32 \def\title{DVI$\,$\lowercase{type} changes for C}
33 @z
34
35 @x [0] l.50 WEAVE: print changes only.
36 \pageno=\contentspagenumber \advance\pageno by 1
37 @y
38 \pageno=\contentspagenumber \advance\pageno by 1
39 \let\maybe=\iffalse
40 @z
41
42 @x [1.1] l.90 Define my_name
43 @d banner=='This is DVItype, Version 3.6' {printed when the program starts}
44 @y
45 @d my_name=='dvitype'
46 @d banner=='This is DVItype, Version 3.6' {printed when the program starts}
47 @z
48
49 % [1.3] Specify the output file to simplify web2c, and don't print the
50 % banner until later.
51 @x [1.3] l.126
52 @d print(#)==write(#)
53 @d print_ln(#)==write_ln(#)
54 @y
55 @d print(#)==write(stdout, #)
56 @d print_ln(#)==write_ln(stdout, #)
57 @z
58
59 @x [1.3] l.134 kpse initialize
60 procedure initialize; {this procedure gets things started properly}
61 var i:integer; {loop index for initializations}
62 begin print_ln(banner);@/
63 @y
64 @<Define \(|parse_arguments|@>
65 procedure initialize; {this procedure gets things started properly}
66 var i:integer; {loop index for initializations}
67 begin
68 kpse_set_program_name (argv[0], my_name);
69 parse_arguments;
70 print (banner);
71 print_ln (version_string);
72 @z
73
74 @x [1.4] l.140 Purge non-local 'goto'.
75 @ If the program has to stop prematurely, it goes to the
76 `|final_end|'. Another label, |done|, is used when stopping normally.
77
78 @d final_end=9999 {label for the end of it all}
79 @d done=30 {go here when finished with a subtask}
80
81 @<Labels...@>=final_end,done;
82 @y
83 @ Label |done| is used when stopping normally.
84
85 @d done=30 {go here when finished with a subtask}
86
87 @<Labels...@>=done;
88 @z
89
90 % There have been no complaints that these values are too small, and adjusting
91 % them dynamically requires resizing a large number of arrays, so
92 % doesn't seem worth the effort.
93 @x [1.5] l.152 More fonts, more widths, no max filename length, no dialog.
94 @!max_fonts=100; {maximum number of distinct fonts per \.{DVI} file}
95 @!max_widths=10000; {maximum number of different characters among all fonts}
96 @y
97 @!max_fonts=500; {maximum number of distinct fonts per \.{DVI} file}
98 @!max_widths=25000; {maximum number of different characters among all fonts}
99 @z
100
101 @x [1.5] l.155
102 @!terminal_line_length=150; {maximum number of characters input in a single
103 line of input from the terminal}
104 @y
105 @z
106
107 @x [1.5] l.158
108 @!name_size=1000; {total length of all font file names}
109 @!name_length=50; {a file name shouldn't be longer than this}
110 @y
111 @!name_size=10000; {total length of all font file names}
112 @z
113
114 @x [1.7] l.172 Remove non-local goto.
115 so a procedure called |jump_out| has been introduced. This procedure, which
116 simply transfers control to the label |final_end| at the end of the program,
117 contains the only non-local |goto| statement in \.{DVItype}.
118 @y
119 so a procedure called |jump_out| has been introduced. We avoid the
120 non-local |goto| in the original.
121 @z
122
123 @x [1.7] l.177
124 @d abort(#)==begin print(' ',#); jump_out;
125 end
126 @d bad_dvi(#)==abort('Bad DVI file: ',#,'!')
127 @.Bad DVI file@>
128
129 @p procedure jump_out;
130 begin goto final_end;
131 end;
132 @y
133 @d jump_out==uexit(1)
134 @d abort(#)==begin write_ln(stderr,#); jump_out; end
135 @d bad_dvi(#)==abort('Bad DVI file: ',#,'!')
136 @.Bad DVI file@>
137 @z
138
139 @x [2.8] l.201 Permissive input.
140 @!ASCII_code=" ".."~"; {a subrange of the integers}
141 @y
142 @!ASCII_code=0..255; {a subrange of the integers}
143 @z
144
145 % [2.9] The text_char type is used as an array index into `xord'. The
146 % default type `char' produces signed integers, which are bad array
147 % indices in C.
148 @x [2.9] l.221
149 @d text_char == char {the data type of characters in text files}
150 @d first_text_char=0 {ordinal number of the smallest element of |text_char|}
151 @d last_text_char=127 {ordinal number of the largest element of |text_char|}
152 @y
153 @d text_char == ASCII_code {the data type of characters in text files}
154 @d first_text_char=0 {ordinal number of the smallest element of |text_char|}
155 @d last_text_char=255 {ordinal number of the largest element of |text_char|}
156 @z
157
158 @x [4.23] l.877 Fix up opening the files.
159 @p procedure open_dvi_file; {prepares to read packed bytes in |dvi_file|}
160 begin reset(dvi_file);
161 cur_loc:=0;
162 end;
163 @#
164 procedure open_tfm_file; {prepares to read packed bytes in |tfm_file|}
165 begin reset(tfm_file,cur_name);
166 end;
167 @y
168 @p procedure open_dvi_file; {prepares to read packed bytes in |dvi_file|}
169 begin
170 resetbin (dvi_file, dvi_name);
171 cur_loc := 0;
172 end;
173 @#
174 procedure open_tfm_file; {prepares to read packed bytes in |tfm_file|}
175 var full_name: ^char;
176 begin
177 full_name := kpse_find_tfm (cur_name);
178 if full_name then begin
179 tfm_file := fopen (full_name, FOPEN_RBIN_MODE);
180 end else begin
181 tfm_file := nil;
182 end;
183 end;
184 @z
185
186 @x [4.24] l.894 No arbitrary limit on filename length.
187 @!cur_name:packed array[1..name_length] of char; {external name,
188 with no lower case letters}
189 @y
190 @!cur_name:^char; {external name}
191 @z
192
193 @x [4.28] l.987 dvi_length and move_to_byte.
194 @p function dvi_length:integer;
195 begin set_pos(dvi_file,-1); dvi_length:=cur_pos(dvi_file);
196 end;
197 @#
198 procedure move_to_byte(n:integer);
199 begin set_pos(dvi_file,n); cur_loc:=n;
200 end;
201 @y
202 @p function dvi_length:integer;
203 begin
204 xfseek (dvi_file, 0, 2, dvi_name);
205 cur_loc := xftell(dvi_file, dvi_name);
206 dvi_length := cur_loc;
207 end;
208 @#
209 procedure move_to_byte(n:integer);
210 begin
211 xfseek (dvi_file, n, 0, dvi_name);
212 cur_loc:=n;
213 end;
214 @z
215
216 @x [6.42] l.1300 [42-43] Initialize optional variables sooner.
217 @!count:array[0..9] of integer; {the count values on the current page}
218
219 @ @<Set init...@>=
220 out_mode:=the_works; max_pages:=1000000; start_vals:=0; start_there[0]:=false;
221 @y
222 @!count:array[0..9] of integer; {the count values on the current page}
223
224 @ Initializations are done sooner now.
225 @z
226
227 @x [6.45] l.1317 No dialog.
228 @ The |input_ln| routine waits for the user to type a line at his or her
229 terminal; then it puts ASCII-code equivalents for the characters on that line
230 into the |buffer| array. The |term_in| file is used for terminal input,
231 and |term_out| for terminal output.
232 @^system dependencies@>
233
234 @<Glob...@>=
235 @!buffer:array[0..terminal_line_length] of ASCII_code;
236 @!term_in:text_file; {the terminal, considered as an input file}
237 @!term_out:text_file; {the terminal, considered as an output file}
238 @y
239 @ No dialog.
240 @z
241
242 @x [6.47] l.1343 No input_ln.
243 @p procedure input_ln; {inputs a line from the terminal}
244 var k:0..terminal_line_length;
245 begin update_terminal; reset(term_in);
246 if eoln(term_in) then read_ln(term_in);
247 k:=0;
248 while (k<terminal_line_length)and not eoln(term_in) do
249 begin buffer[k]:=xord[term_in^]; incr(k); get(term_in);
250 end;
251 buffer[k]:=" ";
252 end;
253 @y
254 @z
255
256 @x [6.48] l.1354 No dialog.
257 @ The global variable |buf_ptr| is used while scanning each line of input;
258 it points to the first unread character in |buffer|.
259
260 @<Glob...@>=
261 @!buf_ptr:0..terminal_line_length; {the number of characters read}
262 @y
263 @ No dialog.
264 @z
265
266 @x [6.49] l.1360 No dialog.
267 @ Here is a routine that scans a (possibly signed) integer and computes
268 the decimal value. If no decimal integer starts at |buf_ptr|, the
269 value 0 is returned. The integer should be less than $2^{31}$ in
270 absolute value.
271
272 @p function get_integer:integer;
273 var x:integer; {accumulates the value}
274 @!negative:boolean; {should the value be negated?}
275 begin if buffer[buf_ptr]="-" then
276 begin negative:=true; incr(buf_ptr);
277 end
278 else negative:=false;
279 x:=0;
280 while (buffer[buf_ptr]>="0")and(buffer[buf_ptr]<="9") do
281 begin x:=10*x+buffer[buf_ptr]-"0"; incr(buf_ptr);
282 end;
283 if negative then get_integer:=-x @+ else get_integer:=x;
284 end;
285
286 @y
287 @ No dialog.
288 @z
289
290 @x [6.50] l.1379 [50-55] No dialog.
291 @ The selected options are put into global variables by the |dialog|
292 procedure, which is called just as \.{DVItype} begins.
293 @^system dependencies@>
294
295 @p procedure dialog;
296 label 1,2,3,4,5;
297 var k:integer; {loop variable}
298 begin rewrite(term_out); {prepare the terminal for output}
299 write_ln(term_out,banner);
300 @<Determine the desired |out_mode|@>;
301 @<Determine the desired |start_count| values@>;
302 @<Determine the desired |max_pages|@>;
303 @<Determine the desired |resolution|@>;
304 @<Determine the desired |new_mag|@>;
305 @<Print all the selected options@>;
306 end;
307
308 @ @<Determine the desired |out_mode|@>=
309 1: write(term_out,'Output level (default=4, ? for help): ');
310 out_mode:=the_works; input_ln;
311 if buffer[0]<>" " then
312 if (buffer[0]>="0")and(buffer[0]<="4") then out_mode:=buffer[0]-"0"
313 else begin write(term_out,'Type 4 for complete listing,');
314 write(term_out,' 0 for errors and fonts only,');
315 write_ln(term_out,' 1 or 2 or 3 for something in between.');
316 goto 1;
317 end
318
319 @ @<Determine the desired |start...@>=
320 2: write(term_out,'Starting page (default=*): ');
321 start_vals:=0; start_there[0]:=false;
322 input_ln; buf_ptr:=0; k:=0;
323 if buffer[0]<>" " then
324 repeat if buffer[buf_ptr]="*" then
325 begin start_there[k]:=false; incr(buf_ptr);
326 end
327 else begin start_there[k]:=true; start_count[k]:=get_integer;
328 end;
329 if (k<9)and(buffer[buf_ptr]=".") then
330 begin incr(k); incr(buf_ptr);
331 end
332 else if buffer[buf_ptr]=" " then start_vals:=k
333 else begin write(term_out,'Type, e.g., 1.*.-5 to specify the ');
334 write_ln(term_out,'first page with \count0=1, \count2=-5.');
335 goto 2;
336 end;
337 until start_vals=k
338
339 @ @<Determine the desired |max_pages|@>=
340 3: write(term_out,'Maximum number of pages (default=1000000): ');
341 max_pages:=1000000; input_ln; buf_ptr:=0;
342 if buffer[0]<>" " then
343 begin max_pages:=get_integer;
344 if max_pages<=0 then
345 begin write_ln(term_out,'Please type a positive number.');
346 goto 3;
347 end;
348 end
349
350 @ @<Determine the desired |resolution|@>=
351 4: write(term_out,'Assumed device resolution');
352 write(term_out,' in pixels per inch (default=300/1): ');
353 resolution:=300.0; input_ln; buf_ptr:=0;
354 if buffer[0]<>" " then
355 begin k:=get_integer;
356 if (k>0)and(buffer[buf_ptr]="/")and
357 (buffer[buf_ptr+1]>"0")and(buffer[buf_ptr+1]<="9") then
358 begin incr(buf_ptr); resolution:=k/get_integer;
359 end
360 else begin write(term_out,'Type a ratio of positive integers;');
361 write_ln(term_out,' (1 pixel per mm would be 254/10).');
362 goto 4;
363 end;
364 end
365
366 @ @<Determine the desired |new_mag|@>=
367 5: write(term_out,'New magnification (default=0 to keep the old one): ');
368 new_mag:=0; input_ln; buf_ptr:=0;
369 if buffer[0]<>" " then
370 if (buffer[0]>="0")and(buffer[0]<="9") then new_mag:=get_integer
371 else begin write(term_out,'Type a positive integer to override ');
372 write_ln(term_out,'the magnification in the DVI file.');
373 goto 5;
374 end
375 @y
376 @ No dialog (50).
377 @ No dialog (51).
378 @ No dialog (52).
379 @ No dialog (53).
380 @ No dialog (54).
381 @ No dialog (55).
382 @z
383
384 @x [6.56] l.1489 Fix printing of floating point number.
385 print_ln(' Resolution = ',resolution:12:8,' pixels per inch');
386 if new_mag>0 then print_ln(' New magnification factor = ',new_mag/1000:8:3)
387 @y
388 print (' Resolution = ');
389 print_real (resolution, 12, 8);
390 print_ln (' pixels per inch');
391 if new_mag > 0
392 then begin
393 print (' New magnification factor = ');
394 print_real (new_mag / 1000.0, 8, 3);
395 print_ln('')
396 end
397 @z
398
399 @x [7.59] l.1518 We use r for something else.
400 @!r:0..name_length; {index into |cur_name|}
401 @y
402 @!r:0..name_size; {current filename length}
403 @z
404
405 @x [7.62] l.1597 <Load the new font...> close the file when we're done
406 if out_mode=errors_only then print_ln(' ');
407 @y
408 if out_mode=errors_only then print_ln(' ');
409 if tfm_file then
410 xfclose (tfm_file, cur_name); {should be the |kpse_find_tfm| result}
411 free (cur_name); {We |xmalloc|'d this before we got called.}
412 @z
413
414 @x [7.64] l.1631 Don't set default_directory_name.
415 @d default_directory_name=='TeXfonts:' {change this to the correct name}
416 @d default_directory_name_length=9 {change this to the correct length}
417
418 @<Glob...@>=
419 @!default_directory:packed array[1..default_directory_name_length] of char;
420 @y
421 In Web2C, users have a path searched for fonts, there's no single
422 default directory.
423 @z
424
425 @x [7.65] l.1637 Remove initialization of default_directory.
426 @ @<Set init...@>=
427 default_directory:=default_directory_name;
428 @y
429 @ (No initialization needs to be done. Keep this module to preserve
430 numbering.)
431 @z
432
433 @x [7.66] l.1640 Don't append `.tfm' here, and keep lowercase.
434 @ The string |cur_name| is supposed to be set to the external name of the
435 \.{TFM} file for the current font. This usually means that we need to
436 prepend the name of the default directory, and
437 to append the suffix `\.{.TFM}'. Furthermore, we change lower case letters
438 to upper case, since |cur_name| is a \PASCAL\ string.
439 @^system dependencies@>
440
441 @<Move font name into the |cur_name| string@>=
442 for k:=1 to name_length do cur_name[k]:=' ';
443 if p=0 then
444 begin for k:=1 to default_directory_name_length do
445 cur_name[k]:=default_directory[k];
446 r:=default_directory_name_length;
447 end
448 else r:=0;
449 for k:=font_name[nf] to font_name[nf+1]-1 do
450 begin incr(r);
451 if r+4>name_length then
452 abort('DVItype capacity exceeded (max font name length=',
453 name_length:1,')!');
454 @.DVItype capacity exceeded...@>
455 if (names[k]>="a")and(names[k]<="z") then
456 cur_name[r]:=xchr[names[k]-@'40]
457 else cur_name[r]:=xchr[names[k]];
458 end;
459 cur_name[r+1]:='.'; cur_name[r+2]:='T'; cur_name[r+3]:='F'; cur_name[r+4]:='M'
460 @y
461 @ The string |cur_name| is supposed to be set to the external name of the
462 \.{TFM} file for the current font. We do not impose a maximum limit
463 here. It's too bad there is a limit on the total length of all
464 filenames, but it doesn't seem worth reprogramming all that.
465 @^system dependencies@>
466
467 @d name_start == font_name[nf]
468 @d name_end == font_name[nf+1]
469
470 @<Move font name into the |cur_name| string@>=
471 r := name_end - name_start;
472 cur_name := xmalloc_array (char, r);
473 {|strncpy| might be faster, but it's probably a good idea to keep the
474 |xchr| translation.}
475 for k := name_start to name_end do begin
476 cur_name[k - name_start] := xchr[names[k]];
477 end;
478 cur_name[r] := 0; {Append null byte for C.}
479 @z
480
481 @x [9.75] l.1775 Diagnose impossible cases.
482 sixty_four_cases(fnt_num_0): first_par:=o-fnt_num_0;
483 end;
484 @y
485 sixty_four_cases(fnt_num_0): first_par:=o-fnt_num_0;
486 othercases abort('internal error');
487 endcases;
488 @z
489
490 @x [9.80] l.1847 (major,minor) optionally show opcode
491 @d show(#)==begin flush_text; showing:=true; print(a:1,': ',#);
492 end
493 @d major(#)==if out_mode>errors_only then show(#)
494 @d minor(#)==if out_mode>terse then
495 begin showing:=true; print(a:1,': ',#);
496 @y
497 @d show(#)==begin flush_text; showing:=true; print(a:1,': ',#);
498 if show_opcodes and (o >= 128) then print (' {', o:1, '}');
499 end
500 @d major(#)==if out_mode>errors_only then show(#)
501 @d minor(#)==if out_mode>terse then
502 begin showing:=true; print(a:1,': ',#);
503 if show_opcodes and (o >= 128) then print (' {', o:1, '}');
504 @z
505
506 % skip_pages calls first_par, which can (uselessly) access w,x,y,z.
507 % https://tug.org/texmfbug/newbug.html#dvitypeinitglobal
508 @x [10.95] l.2171
509 @!down_the_drain:integer; {garbage}
510 begin showing:=false;
511 @y
512 @!down_the_drain:integer; {garbage}
513 begin
514 w:=0; x:=0; y:=0; z:=0; {|first_par| fetches these}
515 showing:=false;
516 @z
517
518 % show full fnt_def command after preamble but before bop, or between eop/bop.
519 % https://tug.org/texmfbug/newbug.html#dvitypefontoutput
520 @x [10.99] l.2222
521 procedure scan_bop;
522 var k:0..255; {command code}
523 begin repeat if eof(dvi_file) then bad_dvi('the file ended prematurely');
524 @.the file ended prematurely@>
525 k:=get_byte;
526 if (k>=fnt_def1)and(k<fnt_def1+4) then
527 begin define_font(first_par(k)); k:=nop;
528 end;
529 @y
530 procedure scan_bop;
531 var k:0..255; {command code}
532 @!a:integer; {byte number of the current command}
533 @!p:integer; {parameter of the current command}
534 @!o:0..255; {copy of command code}
535 begin repeat if eof(dvi_file) then bad_dvi('the file ended prematurely');
536 @.the file ended prematurely@>
537 a:=cur_loc;
538 k:=get_byte;
539 if (k>=fnt_def1)and(k<fnt_def1+4) then
540 begin
541 p:=first_par(k);
542 {Web2C's |dvitype| provides a |-show-opcodes| option, the output
543 from which requires that the opcode be in the variable |o|,
544 as it is elsewhere. So duplicate the value. Sorry.}
545 o:=k;
546 if max_pages>0 then
547 major('fntdef',k-fnt_def1+1:1,' ',p:1);
548 define_font(p);
549 if out_mode<>errors_only then print_ln(' ');
550 k:=nop;
551 end;
552 @z
553
554 @x [13.107] l.2404 (main) No dialog; remove unused label.
555 dialog; {set up all the options}
556 @y
557 @<Print all the selected options@>;
558 @z
559
560 @x [13.107] l.2421
561 final_end:end.
562 @y
563 end.
564 @z
565
566 @x [13.110] l.2469 Fix another floating point print.
567 print_ln('magnification=',mag:1,'; ',conv:16:8,' pixels per DVI unit')
568 @y
569 print ('magnification=', mag:1, '; ');
570 print_real (conv, 16, 8);
571 print_ln (' pixels per DVI unit')
572 @z
573
574 @x [14.112] l.2495 System-dependent changes.
575 This section should be replaced, if necessary, by changes to the program
576 that are necessary to make \.{DVItype} work at a particular installation.
577 It is usually best to design your change file so that all changes to
578 previous sections preserve the section numbering; then everybody's version
579 will be consistent with the printed program. More extensive changes,
580 which introduce new sections, can be inserted here; then only the index
581 itself will get a new section number.
582 @^system dependencies@>
583 @y
584 Parse a Unix-style command line.
585
586 @d argument_is (#) == (strcmp (long_options[option_index].name, #) = 0)
587
588 @<Define \(|parse_arguments|@> =
589 procedure parse_arguments;
590 const n_options = 8; {Pascal won't count array lengths for us.}
591 var @!long_options: array[0..n_options] of getopt_struct;
592 @!getopt_return_val: integer;
593 @!option_index: c_int_type;
594 @!current_option: 0..n_options;
595 @!end_num:^char; {for \.{page-start}}
596 begin
597 @<Define the option table@>;
598 repeat
599 getopt_return_val := getopt_long_only (argc, argv, '', long_options,
600 address_of (option_index));
601 if getopt_return_val = -1 then begin
602 do_nothing; {End of arguments; we exit the loop below.}
603
604 end else if getopt_return_val = "?" then begin
605 usage (my_name);
606
607 end else if argument_is ('help') then begin
608 usage_help (DVITYPE_HELP, nil);
609
610 end else if argument_is ('version') then begin
611 print_version_and_exit (banner, nil, 'D.E. Knuth', nil);
612
613 end else if argument_is ('output-level') then begin
614 if (optarg[0] < '0') or (optarg[0] > '4') or (optarg[1] <> 0) then begin
615 write_ln (stderr, 'Value for --output-level must be >= 0 and <= 4.');
616 uexit (1);
617 end;
618 out_mode := optarg[0] - '0';
619
620 end else if argument_is ('page-start') then begin
621 @<Determine the desired |start_count| values from |optarg|@>;
622
623 end else if argument_is ('max-pages') then begin
624 max_pages := atou (optarg);
625
626 end else if argument_is ('dpi') then begin
627 resolution := atof (optarg);
628
629 end else if argument_is ('magnification') then begin
630 new_mag := atou (optarg);
631
632 end; {Else it was a flag; |getopt| has already done the assignment.}
633 until getopt_return_val = -1;
634
635 {Now |optind| is the index of first non-option on the command line.}
636 if (optind + 1 <> argc) then begin
637 write_ln (stderr, my_name, ': Need exactly one file argument.');
638 usage (my_name);
639 end;
640 dvi_name := extend_filename (cmdline (optind), 'dvi');
641 end;
642
643 @ Here are the options we allow. The first is one of the standard GNU options.
644 @.-help@>
645
646 @<Define the option...@> =
647 current_option := 0;
648 long_options[current_option].name := 'help';
649 long_options[current_option].has_arg := 0;
650 long_options[current_option].flag := 0;
651 long_options[current_option].val := 0;
652 incr (current_option);
653
654 @ Another of the standard options.
655 @.-version@>
656
657 @<Define the option...@> =
658 long_options[current_option].name := 'version';
659 long_options[current_option].has_arg := 0;
660 long_options[current_option].flag := 0;
661 long_options[current_option].val := 0;
662 incr (current_option);
663
664 @ How verbose to be.
665 @.-output-level@>
666
667 @<Define the option...@> =
668 long_options[current_option].name := 'output-level';
669 long_options[current_option].has_arg := 1;
670 long_options[current_option].flag := 0;
671 long_options[current_option].val := 0;
672 incr (current_option);
673 out_mode := the_works; {default}
674
675 @ What page to start at.
676 @.-page-start@>
677
678 @<Define the option...@> =
679 long_options[current_option].name := 'page-start';
680 long_options[current_option].has_arg := 1;
681 long_options[current_option].flag := 0;
682 long_options[current_option].val := 0;
683 incr (current_option);
684
685 @ Parsing the starting page specification is a bit complicated.
686
687 @<Determine the desired |start_count|...@> =
688 k := 0; {which \.{\\count} register we're on}
689 m := 0; {position in |optarg|}
690 while optarg[m] do begin
691 if optarg[m] = "*" then begin
692 start_there[k] := false;
693 incr (m);
694
695 end else if optarg[m] = "." then begin
696 incr (k);
697 if k >= 10 then begin
698 write_ln (stderr, my_name, ': More than ten count registers specified.');
699 uexit (1);
700 end;
701 incr (m);
702
703 end else begin
704 start_count[k] := strtol (optarg + m, address_of (end_num), 10);
705 if end_num = optarg + m then begin
706 write_ln (stderr, my_name, ': -page-start values must be numeric or *.');
707 uexit (1);
708 end;
709 start_there[k] := true;
710 m := m + end_num - (optarg + m);
711 end;
712 end;
713 start_vals := k;
714
715 @ How many pages to do.
716 @.-max-pages@>
717
718 @<Define the option...@> =
719 long_options[current_option].name := 'max-pages';
720 long_options[current_option].has_arg := 1;
721 long_options[current_option].flag := 0;
722 long_options[current_option].val := 0;
723 incr (current_option);
724 max_pages := 1000000; {default}
725
726 @ Resolution, in pixels per inch.
727 @.-dpi@>
728
729 @<Define the option...@> =
730 long_options[current_option].name := 'dpi';
731 long_options[current_option].has_arg := 1;
732 long_options[current_option].flag := 0;
733 long_options[current_option].val := 0;
734 incr (current_option);
735 resolution := 300.0; {default}
736
737 @ Magnification to apply.
738 @.-magnification@>
739
740 @<Define the option...@> =
741 long_options[current_option].name := 'magnification';
742 long_options[current_option].has_arg := 1;
743 long_options[current_option].flag := 0;
744 long_options[current_option].val := 0;
745 incr (current_option);
746 new_mag := 0; {default is to keep the old one}
747
748 @ Whether to show numeric opcodes.
749 @.-show-opcodes@>
750
751 @<Define the option...@> =
752 long_options[current_option].name := 'show-opcodes';
753 long_options[current_option].has_arg := 0;
754 long_options[current_option].flag := address_of (show_opcodes);
755 long_options[current_option].val := 1;
756 incr (current_option);
757
758 @ @<Glob...@> =
759 @!show_opcodes: c_int_type;
760
761 @ An element with all zeros always ends the list.
762
763 @<Define the option...@> =
764 long_options[current_option].name := 0;
765 long_options[current_option].has_arg := 0;
766 long_options[current_option].flag := 0;
767 long_options[current_option].val := 0;
768
769 @ Global filenames.
770
771 @<Global...@> =
772 @!dvi_name:const_c_string;
773 @z