1 : # Use perl
2 eval 'exec perl -S $0 "$@"'
3 if $running_under_some_shell;
4
5 # This is html2ps version 1.0 beta3, an HTML-to-PostScript converter.
6 # Copyright (C) 1995-2000 Jan Karrman.
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #
22 # Author: Jan Karrman, Dept. of Scientific Computing, Uppsala University,
23 # Sweden, e-mail: jan@tdb.uu.se.
24
25
26 # Set the name of the global configuration file. See the installation notes
27 # and manual page for more details on configuration files.
28
29 $globrc='/usr/local/lib/html2ps/html2psrc';
30 $ug='/usr/local/lib/html2ps/html2ps.html';
31
32 $conf=<<'EOR';
33 @html2ps {
34 package {
35 PerlMagick: 0;
36 ImageMagick: 0;
37 pbmplus: 0;
38 netpbm: 0;
39 djpeg: 0;
40 Ghostscript: 0;
41 TeX: 0;
42 dvips: 0;
43 libwww-perl: 0;
44 jfriedl: 0;
45 geturl: "";
46 check: "";
47 path: "";
48 }
49 paper {
50 type: A4;
51 height: "";
52 width: "";
53 }
54 option {
55 twoup: 0;
56 base: "";
57 check: 0;
58 toc: "";
59 debug: 0;
60 DSC: 0;
61 encoding: "ISO-8859-1";
62 rcfile: "";
63 frame: 0;
64 grayscale: 0;
65 help: 0;
66 hyphenate: 0;
67 scaleimage: 1;
68 cookie: "";
69 language: "";
70 landscape: 0;
71 scalemath: 1;
72 number: 0;
73 startno: "";
74 output: "";
75 original: 0;
76 rootdir: "";
77 xref: 0;
78 scaledoc: 1;
79 style: "";
80 titlepage: 0;
81 text: 0;
82 underline: 0;
83 colour: 0;
84 version: 0;
85 web: "";
86 duplex: "";
87 }
88 margin {
89 middle: 2cm;
90 }
91 xref {
92 text: "[p $N]";
93 passes: 1;
94 }
95 quote {
96 en {
97 open: "“";
98 close: "”";
99 open2: "`";
100 close2: "'";
101 }
102 sv {
103 open: "”";
104 close: "”";
105 open2: "'";
106 close2: "'";
107 }
108 da {
109 open: "»";
110 close: "«";
111 }
112 no {
113 open: "«";
114 close: "»";
115 }
116 fr {
117 open: "« ";
118 close: " »";
119 }
120 de {
121 open: "„";
122 close: "“";
123 open2: "‚";
124 close2: "`";
125 }
126 fi: sv;
127 es: en;
128 it: no;
129 nn: no;
130 nb: no;
131 }
132 toc {
133 heading: "<H1>Table of Contents</H1>";
134 level: 6;
135 indent: 1em;
136 }
137 titlepage {
138 content: "<DIV align=center>
139 <H1><BIG>$T</BIG></H1>
140 <H2>$[author]</H2></DIV>";
141 margin-top: 4cm;
142 }
143 font {
144 times {
145 names: "Times-Roman
146 Times-Italic
147 Times-Bold
148 Times-BoldItalic";
149 }
150 new-century-schoolbook {
151 names: "NewCenturySchlbk-Roman
152 NewCenturySchlbk-Italic
153 NewCenturySchlbk-Bold
154 NewCenturySchlbk-BoldItalic";
155 }
156 helvetica {
157 names: "Helvetica
158 Helvetica-Oblique
159 Helvetica-Bold
160 Helvetica-BoldOblique";
161 }
162 helvetica-narrow {
163 names: "Helvetica-Narrow
164 Helvetica-Narrow-Oblique
165 Helvetica-Narrow-Bold
166 Helvetica-Narrow-BoldOblique";
167 }
168 palatino {
169 names: "Palatino-Roman
170 Palatino-Italic
171 Palatino-Bold
172 Palatino-BoldItalic";
173 }
174 avantgarde {
175 names: "AvantGarde-Book
176 AvantGarde-BookOblique
177 AvantGarde-Demi
178 AvantGarde-DemiOblique";
179 }
180 bookman {
181 names: "Bookman-Light
182 Bookman-LightItalic
183 Bookman-Demi
184 Bookman-DemiItalic";
185 }
186 courier {
187 names: "Courier
188 Courier-Oblique
189 Courier-Bold
190 Courier-BoldOblique";
191 }
192 }
193 hyphenation {
194 min: 8;
195 start: 4;
196 end: 3;
197 en {
198 file: "";
199 extfile: "";
200 }
201 }
202 header {
203 left: "";
204 center: "";
205 right: "";
206 odd-left: "";
207 odd-center: "";
208 odd-right: "";
209 even-left: "";
210 even-center: "";
211 even-right: "";
212 font-family: Helvetica;
213 font-size: 8pt;
214 font-style: normal;
215 font-weight: normal;
216 color: black;
217 alternate: 1;
218 }
219 footer {
220 left: "";
221 center: "";
222 right: "";
223 odd-left: "";
224 odd-center: "";
225 odd-right: "";
226 even-left: "";
227 even-center: "";
228 even-right: "";
229 font-family: Helvetica;
230 font-size: 8pt;
231 font-style: normal;
232 font-weight: normal;
233 color: black;
234 alternate: 1;
235 }
236 frame {
237 width: 0.6pt;
238 margin: 0.5cm;
239 color: black;
240 }
241 justify {
242 word: 15pt;
243 letter: 0pt;
244 }
245 draft {
246 text: DRAFT;
247 print: "";
248 dir: 0;
249 font-family: Helvetica;
250 font-style: normal;
251 font-weight: bold;
252 color: F0F0F0;
253 }
254 colour {
255 black: 000000;
256 green: 008000;
257 silver: C0C0C0;
258 lime: 00FF00;
259 gray: 808080;
260 olive: 808000;
261 white: FFFFFF;
262 yellow: FFFF00;
263 maroon: 800000;
264 navy: 000080;
265 red: FF0000;
266 blue: 0000FF;
267 purple: 800080;
268 teal: 008080;
269 fuchsia: FF00FF;
270 aqua: 00FFFF;
271 }
272 html2psrc: "$HOME/.html2psrc";
273 imgalt: "[IMAGE]";
274 datefmt: "%e %b %Y %R";
275 locale: "";
276 doc-sep: "<!--NewPage-->";
277 ball-radius: 0.25em;
278 numbstyle: 0;
279 showurl: 0;
280 seq-number: 0;
281 extrapage: 1;
282 break-table: 0;
283 forms: 1;
284 textarea-data: 0;
285 page-break: 1;
286 expand-acronyms: 0;
287 spoof: "";
288 ssi: 1;
289 prefilled: 0;
290 }
291
292 BODY {
293 font-family: Times;
294 font-size: 11pt;
295 text-align: left;
296 background: white;
297 }
298
299 H1, H2, H3, H4, H5, H6 {
300 font-weight: bold;
301 margin-top: 0.8em;
302 margin-bottom: 0.5em;
303 }
304 H1 { font-size: 19pt }
305 H2 { font-size: 17pt }
306 H3 { font-size: 15pt }
307 H4 { font-size: 13pt }
308 H5 { font-size: 12pt }
309 H6 { font-size: 11pt }
310
311 P, OL, UL, DL, BLOCKQUOTE, PRE {
312 margin-top: 1em;
313 margin-bottom: 1em;
314 }
315
316 P {
317 line-height: 1.2em;
318 text-indent: 0;
319 }
320
321 OL, UL, DD { margin-left: 2em }
322
323 TT, KBD, PRE { font-family: Courier }
324
325 PRE { font-size: 9pt }
326
327 BLOCKQUOTE {
328 margin-left: 1em;
329 margin-right: 1em;
330 }
331
332 ADDRESS {
333 margin-top: 0.5em;
334 margin-bottom: 0.5em;
335 }
336
337 TABLE {
338 margin-top: 1.3em;
339 margin-bottom: 1em;
340 }
341
342 DIV.noprint { display: none }
343
344 DEL { text-decoration: line-through }
345
346 A:link, HR { color: black }
347
348 @page {
349 margin-left: 2.5cm;
350 margin-right: 2.5cm;
351 margin-top: 3cm;
352 margin-bottom: 3cm;
353 }
354
355 EOR
356
357 eval "require POSIX";
358 $posix = !$@;
359
360 %extend=('quote',1, 'font',1, 'colour',1, 'hyphenation',1);
361 %fal=("serif","times", "sans_serif","helvetica", "monospace","courier");
362 @fo=("p","pre","h1","h2","h3","h4","h5","h6","i","b","tt","kbd","cite","samp",
363 "address","blockquote","ol","ul","dl","dt","dd","table","header","footer");
364 %quote=('','en');
365 %valid=('font',1, 'font_files',1, 'margin,left',1, 'margin,right',1,
366 'margin,top',1, 'margin,bottom',1);
367 %cm=('cm',1, 'mm',0.1, 'in',2.54, 'pt',2.54/72, 'pc',2.54/6);
368 %pt=('cm',72/2.54, 'mm',72/25.4, 'in',72, 'pt',1, 'pc',12);
369 %space=('thinsp',6, '#8201',6, 'ensp',2, '#8194',2, 'emsp',1, '#8195',1);
370 $space=join('|',keys %space);
371 %vars=("T","Ti", "N","Pn", "U","UR", "H","h", "A","Au");
372 %height=("letter",27.9, "legal",35.6, "arche",121.9, "archd",91.4, "archc",61,
373 "archb",45.7, "archa",30.5, "flsa",33, "flse",33, "halfletter",21.6,
374 "11x17",43.2, "ledger",27.9);
375 %width=("letter",21.6, "legal",21.6, "arche",91.4, "archd",61, "archc",45.7,
376 "archb",30.5, "archa",22.9, "flsa",21.6, "flse",21.6, "halfletter",14,
377 "11x17",27.9, "ledger",43.2);
378
379 $version="html2ps version 1.0 beta3";
380 $opts="2|b:|c|C:|d|D|e:|f:|F|g|h|H|i:|k:|l:|L|m:|n|N:|o:|O|r:|R|s:|S:|t|T|u|"
381 ."U|v|W:|x:";
382 %optalias=( 'twoup','2', 'base','b', 'check','c', 'toc','C', 'debug','d',
383 'DSC','D', 'encoding','e', 'rcfile','f', 'frame','F', 'grayscale','g',
384 'help','h', 'hyphenate','H', 'scaleimage','i', 'cookie','k', 'language','l',
385 'landscape','L', 'scalemath','m', 'number','n', 'startno','N', 'output','o',
386 'original','O', 'rootdir','r', 'xref','R', 'scaledoc','s', 'style','S',
387 'titlepage','t', 'text','T', 'underline','u', 'colour','U', 'version','v',
388 'web','W', 'duplex','x');
389 %type=( 'paper,height',2, 'paper,width',2, 'option,i',3, 'option,m',3,
390 'option,N',4, 'option,s',3, 'option,x',4, 'xref,passes',4, 'draft,print',5);
391
392 $usage=<<EOU;
393 Usage:
394 html2ps [-2cdDFghHLnORtTuUv] [-b URL] [-C string] [-e encoding]
395 [-f file[:file[:...]]] [-i num] [-k file] [-l lang] [-m num] [-N num]
396 [-o file] [-r path] [-s num] [-S string] [-W string] [-x num]
397 [file|URL [file|URL [...]]]
398
399 EOU
400
401 $usage.="The html2ps users guide is available as $ug\n\n" if(-r $ug);
402
403 $args="@ARGV";
404 &Getopts($opts) || die $usage;
405
406 if($opt_d) {
407 open(DBG,">html2ps.dbg") || die "Error opening debug file: html2ps.dbg\n";
408 print STDERR "***** Writing debug info to html2ps.dbg\n";
409 print DBG "***** $version\n***** Command: $0 $args\n***** Perl: $]\n";
410 print DBG "***** HTML2PSPATH=$ENV{'HTML2PSPATH'}\n";
411 }
412 undef $/;
413 $user=0;
414 $V='(-?\d+\.?\d*|-?\d*\.?\d+)';
415 &getconf($conf);
416 &pagedef;
417 undef %AT_page;
418 for(@fo,"draft") {
419 eval "\$deffnt{'$_'}=defined \$$_\{'font-family'\}?"
420 ."\$$_\{'font-family'\}:\$body{'font-family'}";
421 }
422 $user=1;
423 if(open(RC,$globrc)) {
424 $conf=<RC>;
425 print DBG "***** Global file $globrc:\n$conf" if($opt_d);
426 &getconf($conf);
427 close RC;
428 } else {
429 &dbg("Warning: cannot open the global resource file: $globrc\n") if($globrc);
430 }
431 $html2psrc=~s/^(~|\$HOME)/$ENV{"HOME"}/;
432 $prc=$html2psrc;
433 if($opt_f) {
434 ($prc=$opt_f)=~s/^:/$html2psrc:/;
435 $prc=~s/:$/:$html2psrc/;
436 $prc=~s/::/:$html2psrc:/;
437 }
438 $cwd=$posix?POSIX::getcwd():"";
439 opendir(DIR,$cwd);
440 @local=readdir DIR;
441 closedir DIR;
442 $globrc=~/html2psrc/;
443 $gdir=$`;
444 $hpath=$ENV{"HTML2PSPATH"}?$ENV{"HTML2PSPATH"}:".:";
445 $hpath=~s/^:/$gdir:/;
446 $hpath=~s/:$/:$gdir/;
447 $hpath=~s/::/:$gdir:/;
448 $cur=$hpath=~s/(^|:)\.($|:)/$1$cwd$2/;
449 @hpath=split(/:/,$hpath);
450 for(@hpath) {
451 if(opendir(DIR,$_)) {
452 @files=readdir DIR;
453 $files{$_}=" @files ";
454 closedir DIR;
455 }
456 }
457 @rc=split(/:/,$prc);
458 for $rc (@rc) {
459 $found=0;
460 S:for $dir (@hpath) {
461 if(-r $rc && !grep(/^$rc$/,@local) || $files{$dir}=~/ $rc /) {
462 chdir $dir if($files{$dir}=~/ $rc / && $cwd);
463 if(open(RC,$rc)) {
464 $conf=<RC>;
465 print DBG "***** Personal file $rc:\n$conf" if($opt_d);
466 &getconf($conf);
467 close RC;
468 $found=1;
469 }
470 last S;
471 }
472 }
473 &dbg("Error opening resource file: $rc\n") if($opt_f && !$found);
474 }
475 chdir $cwd if($cwd);
476 $user=2;
477 &getconf($opt_S) if($opt_S);
478 print DBG "*****\n" if($opt_d);
479 &pagedef;
480 ($pagew,$pageh)=split /\s+/, $AT_page{'size'} if(defined $AT_page{'size'});
481
482 require Image::Magick if($package{'PerlMagick'});
483 $geturl=$package{'geturl'};
484 $ulanch="f";
485 $f=72/2.54;
486 $giftopm="giftopnm" if($package{'netpbm'});
487 $giftopm="giftoppm" if($package{'pbmplus'});
488
489 for(keys %option){eval "\$opt_$_='$option{$_}' if(!defined \$opt_$_)"};
490 die $usage if $opt_h;
491 die "$version\n" if $opt_v;
492 &dbg("$version\n") if ($opt_v||$opt_d);
493 die "Ghostscript is required to generate DSC PostScript\n"
494 if($opt_D && !$package{'Ghostscript'});
495 die "Ghostscript is required to generate cross references\n"
496 if($opt_R && !$package{'Ghostscript'});
497 $tmpname=$posix?POSIX::tmpnam():"h2p_$$";
498 ($scr=$tmpname)=~/\w+$/;
499 $tempdir=$`;
500
501 if($opt_u) {$ulanch="t"};
502 if(defined $opt_x && $opt_x!~/^[0-2]$/) {
503 die "Illegal duplex value: $opt_x\n";
504 }
505 $V='(-?\d+\.?\d*|-?\d*\.?\d+)';
506 for $o ($opt_s,$opt_i,$opt_m,$opt_N) {
507 die "Non numeric: $o\n" if(defined($o) && $o!~/^$V$/);
508 }
509
510 $twoup=$opt_2?"t":"f";
511 $xp=$extrapage?"t":"f";
512
513 die "Invalid option: -W $opt_W\n" if($opt_W!~/^[abflprsL\d]*$/);
514 $tocdoc=$opt_C=~/[ft]/;
515 if($tocdoc && !defined $opt_W) {$opt_W=4};
516 $mult=$#ARGV>0 || $opt_W;
517 $maxlev=$opt_W=~/(\d+)/?$1:4;
518 $link=$opt_W=~/l/;
519 $local=$opt_W=~/s/;
520 $rel=$opt_W=~/r/;
521 $below=$opt_W=~/b/;
522 $layer=$opt_W=~/L/;
523 $prompt=$opt_W=~/p/;
524
525 if($opt_C && $opt_C!~/^(b?[ft]|[ft]b?|b?h|hb?)$/)
526 {die "Invalid option: -C $opt_C\n"};
527 $tc=$opt_C?"t":"f";
528 $rev=$opt_C=~/t/;
529 $first=$opt_C=~/b/ || $opt_R;
530 $th=$tocdoc?"f":"t";
531 $oeh=0;
532 $oef=0;
533
534 @now=localtime;
535 @gmnow=gmtime;
536 POSIX::setlocale(&POSIX::LC_TIME,$locale) if($posix);
537 $R='(\s*>|[^a-zA-Z0-9>][^>]*>)';
538 $S='([\w.:/%-]+)|"([^"]*)"|\'([^\']*)\'';
539 $X='[\da-fA-F]';
540 $IM='(gif|jpeg|jpg|png|xbm|xpm|ps|eps)';
541
542 for('odd-left','odd-center','odd-right','even-left','even-center','even-right')
543 {
544 $oeh=1 if defined $header{$_};
545 $oef=1 if defined $footer{$_};
546 }
547 %metarc=();
548 for $a ('left','center','right') {
549 if(defined $header{"odd-$a"} || defined $header{"even-$a"}) {
550 $oeh=1;
551 }
552 if(defined $footer{"odd-$a"} || defined $footer{"even-$a"}) {
553 $oef=1;
554 }
555 for('','odd-','even-') {
556 $apa=$header{$_.$a};
557 $numb=1 if($apa=~/(^|[^\$])\$N/);
558 &spec($header{$_.$a});
559 &spec($footer{$_.$a});
560 $header{$_.$a}="($apa)";
561 $apa=$footer{$_.$a};
562 $numb=1 if($apa=~/(^|[^\$])\$N/);
563 $footer{$_.$a}="($apa)";
564 &varsub($header{$_.$a},$footer{$_.$a});
565 }
566 }
567 if($oeh) {
568 $yz="/YY [[{$header{'odd-left'}}{$header{'even-left'}}]"
569 ."[{$header{'odd-right'}}{$header{'even-right'}}]"
570 ."[{$header{'odd-center'}}{$header{'even-center'}}]] D\n";
571 } else {
572 $ind=$header{'alternate'};
573 $yz="/YY [[{$header{'left'}}$ind][{$header{'right'}}".(1-$ind)
574 ."][{$header{'center'}}2]] D\n";
575 }
576 if($oef) {
577 $yz.="/ZZ [[{$footer{'odd-left'}}{$footer{'even-left'}}]"
578 ."[{$footer{'odd-right'}}{$footer{'even-right'}}]"
579 ."[{$footer{'odd-center'}}{$footer{'even-center'}}]] D";
580 } else {
581 $ind=$footer{'alternate'};
582 $yz.="/ZZ [[{$footer{'left'}}$ind][{$footer{'right'}}".(1-$ind)
583 ."][{$footer{'center'}}2]] D";
584 }
585 $number=$opt_n || !$numb && ($opt_C || $opt_N || $opt_R)?"t":"f";
586 $tih=$titlepage{'content'};
587 $toch=$toc{'heading'};
588 for ($imgalt,$xref{'text'},$tih,$toch,$inh,$draft{'text'}) {
589 &spec($_);
590 }
591
592 for ($paper{'height'},$paper{'width'},$margin{'middle'},$frame{'margin'},
593 $mlr,$mrl,$mtl,$mbl,$mll,$mrr,$mtr,$mbr,$pagew,$pageh) {
594 &getval($_,1);
595 }
596 $opt_s*=0.65 if($opt_2 && $opt_L);
597 $opt_N=1 if(!defined $opt_N);
598 $opt_N=int($opt_N-1);
599 $mm=int($margin{'middle'}*$f);
600 $is=0.8*$opt_i;
601 $msc=1/$opt_s;
602 $mag=1200*$opt_m*$opt_s;
603 $xref=$opt_R?"t":"f";
604 $xref{'text'}=~s/\$N/) WB pN WB (/g;
605
606 $d=int($f*$frame{'margin'});
607 for (0..10) {
608 $temp=2**(-$_/2);
609 $width{"a$_"}=int($temp*2**(-1/4)*1000+.5)/10;
610 $height{"a$_"}=int($temp*2**(1/4)*1000+.5)/10;
611 $width{"b$_"}=int($temp*1000+.5)/10;
612 $height{"b$_"}=int($temp*2**(1/2)*1000+.5)/10;
613 }
614 if(!$pagew || !$pageh) {
615 if($width{"\L$paper{'type'}"}) {
616 $paper{'width'}=$width{"\L$paper{'type'}"} if(!defined $paper{'width'});
617 $paper{'height'}=$height{"\L$paper{'type'}"} if(!defined $paper{'height'});
618 ($pagew,$pageh)=($paper{'width'},$paper{'height'});
619 } elsif($paper{'type'}) {
620 &dbg("Unknown paper type: $paper{'type'}\n");
621 }
622 }
623 if($opt_L) {
624 $wl=$pageh-$mll-$mrl;
625 $wr=$pageh-$mlr-$mrr;
626 $hl=int(($pagew-$mtl-$mbl)*$f+.5);
627 $hr=int(($pagew-$mtr-$mbr)*$f+.5);
628 $xl=int($mtl*$f+.5);
629 $xr=int($mtr*$f+.5);
630 $yl=int($mll*$f+.5);
631 $yr=int($mlr*$f+.5);
632 $rot=" 90 rotate";
633 } else {
634 $wl=$pagew-$mll-$mrl;
635 $wr=$pagew-$mlr-$mrr;
636 $hl=int(($pageh-$mtl-$mbl)*$f+.5);
637 $hr=int(($pageh-$mtr-$mbr)*$f+.5);
638 $xl=int($mll*$f+.5);
639 $xr=int($mlr*$f+.5);
640 $yl=int(($pageh-$mtl)*$f+.5);
641 $yr=int(($pageh-$mtr)*$f+.5);
642 $rot="";
643 }
644
645 if($opt_2) {
646 $wl=($wl-$margin{'middle'})/2;
647 $wr=($wr-$margin{'middle'})/2;
648 }
649 $wl=int($wl*$f+.5);
650 $wr=int($wr*$f+.5);
651 $pag=int($pageh*$f+.5);
652 $fe=$opt_F?"t":"f";
653 $cf=$opt_U?"t":"f";
654 $tp=$opt_t?"t":"f";
655 $rm=$numbstyle?"t":"f";
656 $pa=$showurl?"t":"f";
657 $nh=$seq_number?"t":"f";
658 $bt=$break_table?"t":"f";
659 $ea=$expand_acronyms?"t":"f";
660 $fi=$prefilled?"t":"f";
661 $latin1=$opt_e=~/ISO-8859-1/i;
662 $lt=$del{'text-decoration'}=~/^line-through$/i?"SE":"WB";
663 if(!$opt_x && defined $opt_x) {
664 $dupl="[{false statusdict/setduplexmode get exec} stopped cleartomark";
665 }
666 if($opt_x) {
667 $dupl="[{true statusdict/setduplexmode get exec} stopped cleartomark";
668 }
669 if($opt_x==2) {
670 $dupl.="\n[{true statusdict/settumble get exec} stopped cleartomark";
671 }
672
673 %head=("html",1, "head",1, "title",1, "base",1, "meta",1, "link",1, "style",1,
674 "script",1, "isindex",1);
675 %algn=("left",1, "center",2, "right",3, "justify",4, "char",5);
676 %f=("void",1, "above",2, "below",3, "hsides",4, "lhs",5, "rhs",6, "vsides",7,
677 "box",8, "border",9);
678 %r=("none",1, "groups",2, "rows",3, "cols",4, "all",5);
679 %v=("top",1, "middle",2, "bottom",3, "baseline",4);
680 %it=("radio",0, "checkbox",1, "text",2, "password",2, "image",3);
681 %ssy=(200,"\\", 201, "(", 202, ")");
682 %lity=("I",0, "i",1, "A",2, "a",3, "1",4, "disc",5, "square",6, "circle",7);
683 $ltr=join('|',keys %lity);
684 %tex=('`a',"\340", '\^a',"\342", '`e',"\350", '`e',"\350", 'c\{c\}',"\347",
685 "'e","\351", '\^e',"\352", '"e',"\353", '\^i',"\356", '"i',"\357",
686 '\^o',"\364", '`u',"\371", '\^u',"\373", '"u',"\374", '"y',"\377",
687 'aa',"\345", '"a',"\344", '"o',"\366", 'ae',"\346", 'oe',"\225");
688 @hind=(0,0,0,0,0,0);
689 $ltrs='A-Za-z\222-\226\300-\377';
690 %ent=(
691 "lsquo|#8216",96,
692 "rsquo|#8217",39,
693 "circ|#710",141,
694 "tilde|#732",142,
695 "permil|#8240",143,
696 "dagger|#8224",144,
697 "Dagger|#8225",145,
698 "Yuml|#376",146,
699 "scaron|#353",147,
700 "Scaron|#352",148,
701 "oelig|#339",149,
702 "OElig|#338",150,
703 "lsaquo|#8249",151,
704 "rsaquo|#8250",152,
705 "sbquo|#8218",153,
706 "bdquo|#8222",154,
707 "ldquo|#8220",155,
708 "rdquo|#8221",156,
709 "ndash|#8211",157,
710 "mdash|#8212",158,
711 "trade|#8482",159,
712 "nbsp",160,
713 "iexcl",161,
714 "cent",162,
715 "pound",163,
716 "curren",164,
717 "yen",165,
718 "brvbar",166,
719 "sect",167,
720 "uml",168,
721 "copy",169,
722 "ordf",170,
723 "laquo",171,
724 "not",172,
725 "reg",174,
726 "macr",175,
727 "deg",176,
728 "plusmn",177,
729 "sup2",178,
730 "sup3",179,
731 "acute",180,
732 "micro",181,
733 "para",182,
734 "middot",183,
735 "cedil",184,
736 "sup1",185,
737 "ordm",186,
738 "raquo",187,
739 "frac14",188,
740 "frac12",189,
741 "frac34",190,
742 "iquest",191,
743 "Agrave",192,
744 "Aacute",193,
745 "Acirc",194,
746 "Atilde",195,
747 "Auml",196,
748 "Aring",197,
749 "AElig",198,
750 "Ccedil",199,
751 "Egrave",200,
752 "Eacute",201,
753 "Ecirc",202,
754 "Euml",203,
755 "Igrave",204,
756 "Iacute",205,
757 "Icirc",206,
758 "Iuml",207,
759 "ETH",208,
760 "Ntilde",209,
761 "Ograve",210,
762 "Oacute",211,
763 "Ocirc",212,
764 "Otilde",213,
765 "Ouml",214,
766 "times",215,
767 "Oslash",216,
768 "Ugrave",217,
769 "Uacute",218,
770 "Ucirc",219,
771 "Uuml",220,
772 "Yacute",221,
773 "THORN",222,
774 "szlig",223,
775 "agrave",224,
776 "aacute",225,
777 "acirc",226,
778 "atilde",227,
779 "auml",228,
780 "aring",229,
781 "aelig",230,
782 "ccedil",231,
783 "egrave",232,
784 "eacute",233,
785 "ecirc",234,
786 "euml",235,
787 "igrave",236,
788 "iacute",237,
789 "icirc",238,
790 "iuml",239,
791 "eth",240,
792 "ntilde",241,
793 "ograve",242,
794 "oacute",243,
795 "ocirc",244,
796 "otilde",245,
797 "ouml",246,
798 "divide",247,
799 "oslash",248,
800 "ugrave",249,
801 "uacute",250,
802 "ucirc",251,
803 "uuml",252,
804 "yacute",253,
805 "thorn",254,
806 "yuml",255);
807 %symb=(
808 "alpha|#945",141,
809 "beta|#946",142,
810 "gamma|#947",147,
811 "delta|#948",144,
812 "epsilon|#949",145,
813 "zeta|#950",172,
814 "eta|#951",150,
815 "theta|#952",161,
816 "thetasym|#977",112,
817 "iota|#953",151,
818 "kappa|#954",153,
819 "lambda|#955",154,
820 "mu|#956",155,
821 "nu|#957",156,
822 "xi|#958",170,
823 "pi|#960",160,
824 "piv|#982",166,
825 "omicron|#959",157,
826 "rho|#961",162,
827 "sigma|#963",163,
828 "sigmaf|#962",126,
829 "tau|#964",164,
830 "upsilon|#965",165,
831 "upsih|#978",241,
832 "phi|#966",146,
833 "phiv",152,
834 "chi|#967",143,
835 "psi|#968",171,
836 "omega|#969",167,
837 "Alpha|#913",101,
838 "Beta|#914",102,
839 "Gamma|#915",107,
840 "Delta|#916",104,
841 "Epsilon|#917",105,
842 "Zeta|#918",132,
843 "Eta|#919",110,
844 "Theta|#920",121,
845 "Iota|#921",111,
846 "Kappa|#922",113,
847 "Lambda|#923",114,
848 "Mu|#924",115,
849 "Nu|#925",116,
850 "Xi|#926",130,
851 "Omicron|#927",117,
852 "Pi|#928",120,
853 "Rho|#929",122,
854 "Sigma|#931",123,
855 "Tau|#932",124,
856 "Upsilon|#933",125,
857 "Phi|#934",106,
858 "Chi|#935",103,
859 "Psi|#936",131,
860 "Omega|#937",127,
861 "fnof|#402",246,
862 "perp|#8869",136,
863 "plusmn|#177",261,
864 "cdot|#183",327,
865 "or|#8744",332,
866 "and|#8743",331,
867 "le|#8804",243,
868 "ge|#8805",263,
869 "equiv|#8801",272,
870 "cong|#8773",100,
871 "asymp|#8776",273,
872 "ne|#8800",271,
873 "sub|#8834",314,
874 "sube|#8838",315,
875 "sup|#8835",311,
876 "supe|#8839",312,
877 "isin|#8712",316,
878 "larr|#8592",254,
879 "rarr|#8594",256,
880 "uarr|#8593",255,
881 "darr|#8595",257,
882 "harr|#8596",253,
883 "lArr|#8656",334,
884 "rArr|#8658",336,
885 "uArr|#8657",335,
886 "dArr|#8659",337,
887 "hArr|#8660",333,
888 "forall|#8704","042",
889 "exist|#8707","044",
890 "infin|#8734",245,
891 "nabla|#8711",321,
892 "part|#8706",266,
893 "hellip|#8230",274,
894 "int|#8747",362,
895 "sum|#8721",345,
896 "prod|#8719",325,
897 "real|#8476",302,
898 "image|#8465",301,
899 "bull|#8226",267,
900 "prime|#8242",242,
901 "Prime|#8243",262,
902 "oline|#8254",140,
903 "frasl|#8260",244,
904 "weierp|#8472",303,
905 "alefsym|#8501",300,
906 "crarr|#8629",277,
907 "empty|#8709",306,
908 "notin|#8713",317,
909 "ni|#8715","047",
910 "minus|#8722","055",
911 "lowast|#8727","052",
912 "radic|#8730",326,
913 "prop|#8733",265,
914 "ang|#8736",320,
915 "cap|#8745",307,
916 "cup|#8746",310,
917 "sim|#8764",176,
918 "nsub|#8836",313,
919 "oplus|#8853",305,
920 "otimes|#8855",304,
921 "sdot|#8901",327,
922 "lceil|#8968",351,
923 "rceil|#8969",371,
924 "lfloor|#8970",353,
925 "rfloor|#8971",373,
926 "lang|#9001",341,
927 "rang|#9002",361,
928 "spades|#9824",252,
929 "clubs|#9827",247,
930 "hearts|#9829",251,
931 "diams|#9830",250,
932 "loz|#9674",340);
933
934 $pc=')WB NL NP(';
935 $nimg=-1;
936 $nm=-1;
937 @font=();
938 @size=();
939 @styl=();
940 @alig=();
941 @colr=();
942 @topm=();
943 @botm=();
944 @lftm=();
945 @rgtm=();
946 @z1=();
947 @z2=();
948 @z3=();
949 &Subst($doc_sep);
950 ($toct=$toch)=~s|<[\w/!?][^>]*>||g;
951 $dh="/h0 [()($toct)] D\n";
952 &Subst($toch);
953 $toch=~s/ H\(/ -1 H(/g;
954 $toch="($toch)";
955 &varsub($toch);
956 &Subst($tih);
957 $tih=~s/ H\(/ -1 H(/g;
958 $tih="($tih)";
959 &varsub($tih);
960 $mn=0;
961 $nfont=0;
962 $mi=0;
963 for (@fo) {&setel($_)};
964 %arr=%draft;
965 &fs("draft");
966
967 if(!$latin1 && !defined $fontid{"times"}) {
968 $fontid{"times"}=$nfont++;
969 @docfonts=(@docfonts,split(/\s+/,$font_names{"times"}));
970 }
971 $wind=0;
972 $wf="t";
973 if(!$latin1) {
974 $wind=$fontid{"times"};
975 $wf="f";
976 }
977
978 for $k (keys %font_files){
979 @ff=split(/\s+/,$font_files{$k});
980 @fn=split(/\s+/,$font_names{$k});
981 for (0..3) {
982 if($ff[$_]) {
983 $ff{$fn[$_]}=$ff[$_];
984 } elsif(!$ff{$fn[$_]}) {
985 $ff{$fn[$_]}=$ff[0];
986 }
987 $fr{$fn[$_]}=$k;
988 }
989 }
990 $pta=defined $p{"text-align"}?$p{"text-align"}:$body{"text-align"};
991 $pal=0;
992 $pal=1 if($pta=~/^c/i);
993 $pal=2 if($pta=~/^r/i);
994 $pal=3 if($pta=~/^j/i);
995 $bgcol=&col2rgb($body{"background"});
996 if(!$bgcol) {$bgcol="[16#FF 16#FF 16#FF]"};
997 if(!$p{"color"}) {$p{"color"}="black"};
998 $tcol=&col2rgb($p{"color"});
999 $lcol=&col2rgb($a__link{"color"});
1000 if($lcol) {
1001 $Lc="/Lc t D\n/Dl $lcol D\n";
1002 $Lc.=$tcol ne $lcol?"/LX t D":"/LX f D";
1003 } else {
1004 $Lc="/Lc f D\n/LX f D";
1005 }
1006 $pcol=&col2rgb($pre{"color"});
1007 if(!$pcol) {$pcol="[0 0 0]"};
1008 $deftbg=&col2rgb($table{"background"});
1009 $hc=&col2rgb($hr{"color"});
1010 if(!$hc) {$hc="[0 0 0]"};
1011 $fcol=&col2rgb($frame{"color"});
1012 if(!$fcol) {$fcol="[0 0 0]"};
1013 for ($p{"font-size"},$pre{"font-size"},$header{"font-size"},$frame{'width'},
1014 $footer{"font-size"},$justify{'letter'},$justify{'word'},
1015 $titlepage{'margin-top'}) {
1016 &getval($_,2);
1017 }
1018 for ($p{"line-height"},$p{"text-indent"},$p{"margin-top"},$toc{'indent'},
1019 $ball_radius) {
1020 &getval($_,0);
1021 }
1022 $fl="/FL [/".join("\n/",@docfonts)."] D";
1023 for $k (keys %ff) {
1024 $f=$ff{$k};
1025 if(defined $fontid{$fr{$k}} && !defined($cont{$f})) {
1026 open(FONT,$f) || &dbg("Error opening fontfile $f\n");
1027 ($cont{$f}=<FONT>)=~s/(^|\r?\n|\r)%.*//g;
1028 close FONT;
1029 }
1030 }
1031 $fontdef="";
1032 for (keys %cont) {
1033 $fontdef.=$cont{$_};
1034 }
1035 &ent($yz);
1036 &ent($xref{'text'});
1037 &ent($draft{'text'});
1038
1039 $lnum=0;
1040 for (keys %quote_open) {
1041 $lid{$_}=$lnum++;
1042 if(!defined $quote_close{$_}) {$quote_close{$_}=$quote_open{$_}};
1043 if(!defined $quote_open2{$_}) {$quote_open2{$_}=$quote_open{$_}};
1044 if(!defined $quote_close2{$_}) {$quote_close2{$_}=$quote_close{$_}};
1045 &ent($quote_open{$_});
1046 &ent($quote_close{$_});
1047 &ent($quote_open2{$_});
1048 &ent($quote_close2{$_});
1049 push(@qo,$quote_open{$_});
1050 push(@qc,$quote_close{$_});
1051 push(@qo2,$quote_open2{$_});
1052 push(@qc2,$quote_close2{$_});
1053 }
1054 $qo=join(')(',@qo);
1055 $qc=join(')(',@qc);
1056 $qo2=join(')(',@qo2);
1057 $qc2=join(')(',@qc2);
1058 $hyphenation_file{''}=$hyphenation_file{'en'};
1059 $br=$collapse_br?"f":"t";
1060 $gd=0;
1061 $ddr=defined $draft{'print'};
1062 if($ddr) {
1063 if($draft{'print'}==0) {
1064 $draft="f";
1065 } else {
1066 $gd=1;
1067 $draft="t";
1068 }
1069 }
1070 if(-e '/dev/null' || !-e 'nul') {
1071 $pathsep=':';
1072 $gs='gs';
1073 } else {
1074 $pathsep=';';
1075 $gs='gswin32c';
1076 }
1077 $gb=$gs_bug?"t":"f";
1078 for (keys %quote) {$lid{$_}=$lid{$quote{$_}}};
1079 $ENV{'PATH'}.="$pathsep$package{'path'}" if($package{'path'});
1080 $delim="%-- End of variable part --";
1081 $cd="/Cd {aload length 2 idiv dup dict begin {D} repeat currentdict end} D";
1082
1083 $mysymb=<<EOF;
1084 /MySymbol 10 dict dup begin
1085 /FontType 3 D /FontMatrix [.001 0 0 .001 0 0 ] D /FontBBox [25 -10 600 600] D
1086 /Encoding 256 array D 0 1 255{Encoding exch /.notdef put}for
1087 Encoding (e) 0 get /euro put
1088 /Metrics 2 dict D Metrics begin
1089 /.notdef 0 D
1090 /euro 651 D
1091 end
1092 /BBox 2 dict D BBox begin
1093 /.notdef [0 0 0 0] D
1094 /euro [25 -10 600 600] D
1095 end
1096 /CharacterDefs 2 dict D CharacterDefs begin
1097 /.notdef {} D
1098 /euro{newpath 114 600 moveto 631 600 lineto 464 200 lineto 573 200 lineto
1099 573 0 lineto -94 0 lineto 31 300 lineto -10 300 lineto closepath clip
1100 50 setlinewidth newpath 656 300 moveto 381 300 275 0 360 arc stroke
1101 -19 350 moveto 600 0 rlineto -19 250 moveto 600 0 rlineto stroke}d
1102 end
1103 /BuildChar{0 begin
1104 /char E D /fontdict E D /charname fontdict /Encoding get char get D
1105 fontdict begin
1106 Metrics charname get 0 BBox charname get aload pop setcachedevice
1107 CharacterDefs charname get exec
1108 end
1109 end}D
1110 /BuildChar load 0 3 dict put /UniqueID 1 D
1111 end
1112 definefont pop
1113 EOF
1114
1115 $P0=<<EOC;
1116 %%Creator: $version
1117 %%EndComments
1118 save
1119 2000 dict begin
1120 /d {bind def} bind def
1121 /D {def} d
1122 /t true D
1123 /f false D
1124 $fl
1125 /WF $wf D
1126 /WI $wind D
1127 /F $opt_s D
1128 /IW $wr F div D
1129 /IL $hr F div D
1130 /PS $pag D
1131 /EF [@font] D
1132 /EZ [@size] D
1133 /Ey [@styl] D
1134 /EG [@alig] D
1135 /Tm [@topm] D
1136 /Bm [@botm] D
1137 /Lm [@lftm] D
1138 /Rm [@rgtm] D
1139 /EU [@colr] D
1140 /NO $number D
1141 $yz
1142 /Ts EZ 0 get D
1143 /TU $twoup D
1144 /Xp $xp D
1145 /AU $ulanch D
1146 /SN $opt_N D
1147 /Cf $cf D
1148 /Tp $tp D
1149 /Fe $fe D
1150 /TI $toc{'indent'} Ts mul D
1151 /Fm $d D
1152 /xL $xl D
1153 /xR $xr D
1154 /yL $yl D
1155 /yR $yr D
1156 /Wl $wl F div D
1157 /Wr $wr F div D
1158 /hL $hl F div D
1159 /hR $hr F div D
1160 /FE {newpath Fm neg Fm M CP BB IW Fm add Fm L IW Fm add IL Fm add neg L CP BB
1161 Fm neg IL Fm add neg L closepath} D
1162 /LA {PM 0 eq{/IW Wl D /IL hL D}{/IW Wr D /IL hR D}ie /W IW D /LL W D /LS W D
1163 /LE IL D TU PM 0 eq and{IW $mm F div add SA{Sf div}if 0 translate}
1164 {PM 0 eq{xL yL}{xR yR}ie translate$rot F SA{Sf mul}if dup scale
1165 CS CF FS Cf{CA CL get VC}if /Bb f D}ie 0 0 M
1166 TF not Tc or {Cf{gsave SA{1 Sf div dup scale}if Cb VC FE fill grestore}if}if}D
1167 /Pi $p{"text-indent"} Ts mul D
1168 /SG [$is $opt_i $msc] D
1169 /Ab $justify{'word'} D
1170 /J $justify{'letter'} D
1171 /Tc $tc D
1172 /NH $toc{'level'} D
1173 /Nf $nh D
1174 /Pa $pa D
1175 /LH $p{"line-height"} D
1176 /XR $xref D
1177 /Xr {/pN E D ( $xref{'text'} )WB} D
1178 /Db $bgcol D
1179 /Dt $tcol D
1180 /eA $ea D
1181 /Fi $fi D
1182 /bT $bt D
1183 $Lc
1184 /Br $ball_radius D
1185 /IA ($imgalt) D
1186 /DS {/PF f D($doc_sep)pop RC ZF} D
1187 /Gb $gb D
1188 /Mb $br D
1189 /Hc $hc D
1190 /Bl 3 D
1191 /MI -$mi D
1192 /DX ($draft{'text'}) D
1193 /Di $draft{'dir'} D
1194 /Tt $titlepage{'margin-top'} D
1195 /Th {$tih} D
1196 /tH {$toch} D
1197 /FD $fontid{"\L$font"} D
1198 /Dy $styl D
1199 /cD $col D
1200 /FW $frame{'width'} D
1201 /FU $fcol D
1202 /ET {/RM $rm D /A0 $pal D /PN SN D /OU t D /Ou t D /W IW D /LL W D D1
1203 Ms not TP and{Ip}if /TF f D} D
1204 $dupl
1205 $delim
1206 $mysymb
1207 EOC
1208
1209 $reenc=<<EOD;
1210 WF{FL{reencodeISO D}forall}{4 1 FL length 1 sub{FL E get reencodeISO D}for}ie
1211 /Symbol dup dup findfont dup length dict begin
1212 {1 index /FID ne{D}{pop pop}ie}forall /Encoding [Encoding aload pop]
1213 dup 128 /therefore put D currentdict end definefont D
1214 EOD
1215 $defs=<<EOD;
1216 /reencodeISO {
1217 dup dup findfont dup length dict begin{1 index /FID ne{D}{pop pop}ie}forall
1218 /Encoding ISOLatin1Encoding D currentdict end definefont} D
1219 /ISOLatin1Encoding [
1220 /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
1221 /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
1222 /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
1223 /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
1224 /space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright
1225 /parenleft/parenright/asterisk/plus/comma/hyphen/period/slash
1226 /zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon
1227 /less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N
1228 /O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright
1229 /asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m
1230 /n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde
1231 /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
1232 /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
1233 /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
1234 /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
1235 /.notdef/space/exclamdown/cent/sterling/currency/yen/brokenbar
1236 /section/dieresis/copyright/ordfeminine/guillemotleft/logicalnot
1237 /hyphen/registered/macron/degree/plusminus/twosuperior/threesuperior
1238 /acute/mu/paragraph/periodcentered/cedilla/onesuperior/ordmasculine
1239 /guillemotright/onequarter/onehalf/threequarters/questiondown
1240 /Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla
1241 /Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex
1242 /Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
1243 /multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute
1244 /Thorn/germandbls/agrave/aacute/acircumflex/atilde/adieresis
1245 /aring/ae/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave
1246 /iacute/icircumflex/idieresis/eth/ntilde/ograve/oacute/ocircumflex
1247 /otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex/udieresis
1248 /yacute/thorn/ydieresis
1249 ] D
1250 [128/backslash 129/parenleft 130/parenright 141/circumflex 142/tilde
1251 143/perthousand 144/dagger 145/daggerdbl 146/Ydieresis 147/scaron 148/Scaron
1252 149/oe 150/OE 151/guilsinglleft 152/guilsinglright 153/quotesinglbase
1253 154/quotedblbase 155/quotedblleft 156/quotedblright 157/endash 158/emdash
1254 159/trademark]
1255 aload length 2 idiv 1 1 3 -1 roll{pop ISOLatin1Encoding 3 1 roll put}for
1256 /colorimage where{pop}{
1257 /colorimage {
1258 pop pop /Pr E D {/Cv Pr D /Gr Cv length 3 idiv string D 0 1 Gr length 1 sub
1259 {Gr E dup /i E 3 mul D Cv i get 0.299 mul Cv i 1 add get 0.587 mul add
1260 Cv i 2 add get 0.114 mul add cvi put}for Gr} image} D
1261 }ie
1262 /pdfmark where{pop}{userdict /pdfmark /cleartomark load put}ie
1263 EOD
1264
1265 $P1=<<EOT;
1266 $cd
1267 /EX {EC cvx exec} D
1268 /DU {} d
1269 /BB {pop pop}d
1270 /ie {ifelse} d
1271 /E {exch} d
1272 /M {moveto} d
1273 /R {rmoveto} d
1274 /L {lineto} d
1275 /RL {rlineto} d
1276 /CP {currentpoint} d
1277 /SW {stringwidth} d
1278 /GI {getinterval} d
1279 /PI {putinterval} d
1280 /Sg {setgray} d
1281 /LW {setlinewidth} d
1282 /S {dup () ne OU and{0 Co R AT 3 eq LB and HF not and A1 0 ne A2 0 ne or and
1283 {A2 0 32 A1 0 6 -1 roll awidthshow}{show}ie 0 Co neg R}{pop}ie
1284 OU PH 3 eq or{/Ms t D}if} D
1285 /U {OU{gsave CP currentfont /FontInfo get /UnderlinePosition get
1286 0 E currentfont /FontMatrix get dtransform E pop add newpath M dup SW pop
1287 CJ 0 RL stroke grestore}if} D
1288 /B {OU Br 0 gt and{CP Ts neg Ts .33 mul R gsave 0 Sg
1289 CP newpath Ts Br mul 0 360 arc closepath UI 2 mod 0 eq{stroke}{fill}ie
1290 grestore M CP E Ts Br 1 add mul sub E BB /Ms t D}if}D
1291 /NP {Ms TP not or PA and OU and{TP{OR}if f1{mF k2 /mF E D /YC 0 D}if
1292 TP TU not PM 0 eq or and{showpage}if DU Ip TE not{LA}if 0.6 LW
1293 /CI 0 D /TP t D /Hs f D /hl 6 D /Hv 6 D /HI hi D /Ms f D}if Bs XO BO M} D
1294 /Np {LE sub CP E pop gt PL 0 eq and{NP}if}D
1295 /Ip {/PN PN 1 add D /Pn RM{1}{4}ie PN Ns D /PM PN SN sub 2 mod D} D
1296 /GP {E dup 3 -1 roll get PN 1 add 2 mod get dup type /integertype eq
1297 {get 0 get}{E pop}ie}d
1298 /Fc {dup 2 GP exec SW pop /S1 E D dup 1 GP exec SW pop /S2 E D 0 GP exec SW
1299 pop /S3 E D S1 0 gt{S2 2 mul S1 add S3 2 mul S1 add 2 copy lt{E}if pop}{0}ie
1300 S2 S3 add 2 copy lt{E}if pop IW .9 mul div dup 1 gt{1 E div}{pop 1}ie}D
1301 /OR {Df{Sd}if tp not{gsave SA{1 Sf div dup scale}if Fe{Cf{FU VC}if FW LW
1302 1 setlinejoin FE stroke}if /YO {60 F div dup 40 gt{pop 40}if}D /cs CS D
1303 /cf CF D /CF 0 D /pf PF D /PF f D /Fn FN D /At AT D /AT 0 D /FN EF Hf 1 add
1304 get D Fz Fs FS ZZ Fc Fz mul Fs FS EU Hf 1 add get dup type /arraytype eq
1305 Cf and{VC}{pop 0 Sg}ie IW IL neg YO sub M ZZ 1 GP exec dup SW pop neg 0 R Sh
1306 0 IL neg YO sub M ZZ 0 GP exec Sh ZZ 2 GP exec dup SW pop IW E sub 2 div
1307 IL neg YO sub M Sh Fz Fs FS NO{/AW IW Pn SW pop sub D AW 2 div IL neg YO sub
1308 S1 0 gt S2 AW .45 mul gt or S3 AW .45 mul gt or{Fz 2 mul sub}if M Pn Sh}if
1309 EU Hf get dup type /arraytype eq Cf and{VC}{pop 0 Sg}ie YY Fc /FN EF Hf get D
1310 Hz mul HS FS IW YO M YY 1 GP exec dup SW pop neg 0 R Sh 0 YO M YY 0 GP exec Sh
1311 YY 2 GP exec dup SW pop IW E sub 2 div YO M Sh /FN Fn D /AT At D t Pb XO SZ
1312 SL get neg R /PF pf D grestore /CF 0 D cs cf FS}if}D
1313 /Sh {dup () ne{CP Hz 4 div sub BB show CP CS add BB}{pop}ie}D
1314 /Pb {/OU E D /Ou OU D /PB t D 0 0 M Ba{/Sa save D /BP t D /Fl t D RC /PL 0 D
1315 /PH 0 D /W IW D /LE IL .7 mul D /EO 0 D SI ZF /YA 0 D /BO 0 D /C1 () D
1316 BA 0 Ts neg R Bb{Xl Yl Xh Yh}if Bb CP Sa restore M
1317 {/Yh E D /Xh E D /Yl E D /Xl E D}if /Fl t D}if
1318 BL /OU t D /HM f D /Ou t D /PB f D} D
1319 /Bs {/BP Ba not D}D
1320 $defs$fontdef$reenc
1321 /SF {/CS E D SZ SL CS put FO SL FN put /YI CS LH neg mul D dup ST cvs ( ) join
1322 CS ST cvs join C1 E join ( NF ) join /C1 E D CS NF /Wf WF FN 0 gt or D
1323 /BW Wf{( ) SW pop}{0}ie D}D
1324 /NF {/cS E D /cF E D cF 0 ge{FL cF get}{cF -1 eq{/Symbol}{/MySymbol}ie}ie
1325 findfont cS scalefont setfont} D
1326 /FS {CF or /CF E D FR SL CF put CF CF 0 ge{FN 4 mul add}if E SF} D
1327 /PC {SH /BP f D fin not GL not and{NL}if /HM t D /LL LS D} D
1328 /BS {/TX E D Wf{/fin f D /CW 0 D /LK 0 D /SC 0 D
1329 /RT TX D {RT ( ) search{/NW E D pop /RT E D /WH NW SW pop D CW WH add LL gt
1330 {TX SC LK SC sub 1 sub NN GI GL{SH cF cS OC
1331 2 copy cS ne E cF ne or{NF}{pop pop}ie}{PC /CW WH BW add D}ie
1332 /SC LK D}
1333 {GL{JC}if
1334 /CW CW WH add BW add D /HM t D}ie /GL f D /Ph f D
1335 /LK LK NW length 1 add add D}{pop exit}ie}loop
1336 /fin t D TX SC LK SC sub GI SH RT () ne{GL not{CC}if}if
1337 /LC TX length D /WH RT SW pop D CW WH add Hy{HC SW pop add}if LL gt
1338 {RT GL{SH cF cS OC 2 copy cS ne E cF ne or{NF}{pop pop}ie
1339 Hy{/Ph t D}if /LL LS D}{NL /LL LS D SH}ie}
1340 {RT PC Hy{CC}if /Ph Ph Hy or D}ie RT () ne{/GL t D /HM t D}if}
1341 {TX SW pop LL le{TX SH}{/NW () D 0 2 TX length 1 sub
1342 {/CW E D TX 0 CW GI dup SW pop LL gt{pop NW SH /HM t D NL/LL W XO sub MR sub D
1343 /CW CW 2 sub NN D /TX TX CW TX length CW sub GI D TX BS exit}
1344 {/NW E D}ie}for}ie}ie /HM t D}D
1345 /CC {C0 length 0 gt{JC}if /C0 [C1 L1 YA YB Mf NS NB TB AF Bw] D
1346 /C1 () D /L0 L1 D /YA 0 D /YB 0 D /Mf 0 D /NS 0 D /NB 0 D}D
1347 /JC {C0 aload length 0 gt{pop pop pop NB add /NB E D NS add /NS E D
1348 dup Mf gt{/Mf E D}{pop}ie dup YB gt{/YB E D}{pop}ie
1349 dup YA gt{/YA E D}{pop}ie pop C1 join /C1 E D /C0 [] D}if}D
1350 /OC {C0 length 0 gt{C1 L1 L0 sub YA YB Mf NS NB TB AF Bw GL C0 aload pop
1351 /Bw E D /AF E D /TB E D /NB E D /NS E D /Mf E D /YB E D /YA E D /C0 [] D
1352 /L1 E D /C1 E D Ph{HC SH}if NL /GL E D /Bw E D /AF E D /TB E D /NB E D /NS E D
1353 /Mf E D /YB E D /YA E D /L1 E D /LL W L1 sub XO sub MR sub WH sub D /CW 0 D
1354 C1 E join /C1 E D}if}D
1355 /BT {/LB t D dup length string copy RS dup dup () ne E ( ) ne and
1356 {/CI 0 D /LS LL D /LL W L1 sub XO sub MR sub D BS}
1357 {dup ( ) eq{/GL f D}if dup () eq L1 0 eq or{pop}{SH /BP f D /Ph f D}ie}ie
1358 /LB f D} D
1359 /BL {CP E pop XO E M} D
1360 /NL {JC /GL f D /SK W XO sub MR sub L1 sub TB{Bw add}if D
1361 /YA LF{Mf HM Fl not and PF or{LH mul}if}{0 /LF t D}ie YA 2 copy lt{E}if pop D
1362 C1 () ne{/FB YB Mf SA{Sf mul}if 4 div 2 copy lt{E}if pop D}if Fl{/Ya YA D}if
1363 CP E pop YA sub YB sub LE neg lt Fl not and PB not and{NP}if NT TL BL
1364 OU PF not and PB or{/RE L1 TB{Bw sub}if
1365 W XO sub MR sub div YA YB add LE BO add div 2 copy lt{E}if pop D
1366 RE 1 gt{BL 1 RE div dup scale}if}if
1367 AT 2 le{SK AT mul 2 div YA neg R}if
1368 AT 3 eq{0 YA neg R TB{/NB NB 1 sub D /NS NS 1 sub D}if /NB NB 1 sub NN D
1369 /A3 NS 6 mul NB add D NS NB add 0 eq
1370 {/A1 0 D /A2 0 D}
1371 {NS 0 eq{/A1 SK NB div dup J gt{pop 0}if D /A2 0 D}{J A3 mul SK lt
1372 {/A1 J D /A2 SK J NB mul sub NS div dup Ab gt{/A1 0 D pop 0}if D}
1373 {/A1 SK A3 div D /A2 A1 6 mul D}ie}ie}ie /A1 A1 NN D /A2 A2 NN D}if
1374 AT 4 eq{0 YA neg R PH 2 le{PD 0 lt{/PD L1 D}if PD M1 gt{/M1 PD D}if
1375 L1 PD sub M2 gt{/M2 L1 PD sub D}if}{DV ID 1 sub get 0 ge{Lo 0 R}if}ie}if
1376 F0 cF ne Cs cS ne or{F0 Cs NF}if
1377 /ms Ms D /Ms f D CP FB sub
1378 C1 cvx exec XO EO sub L1 add TB{BW sub}if dup LM gt{/LM E D}{pop}ie
1379 PH 0 eq PH 4 eq or Ms and{HF not{/PO t D /AH t D}if
1380 BB CP YA add E AT 3 eq LB and{A1 sub}if TB{BW sub}if E BB}
1381 {pop pop}ie Ms HM PH 3 eq and or{/BP f D /Fl f D}if
1382 /Lo 0 D /L1 0 D /F0 cF D /Cs cS D BP not{0 YB NN neg R}if
1383 OU f1 and mF not and{k2 /f1 f D}if
1384 OU PF not and PB or{RE 1 gt{RE dup scale}if}if /Ms ms Ms or D
1385 /C1 AF{(Cp )}{()}ie D /YA 0 D /YB 0 D BL
1386 AT 4 eq LB not and PH 3 ge and
1387 {ID DV length lt{DV ID get dup 0 ge{DO E sub /Lo E D /L1 Lo D}{pop}ie
1388 /ID ID 1 add D}if}if /T t D CD{/LN LN 1 add D PD}if
1389 /PD -1 D /NS 0 D /NB 0 D /TB f D /Ph f D /Mf 0 D /HM f D} D
1390 /RS {/TM E D /CN 0 D TM{10 eq{TM CN ( ) PI}if /CN CN 1 add D}forall
1391 /CN 0 D /BK HM EN and{0}{1}ie D TM
1392 {dup 32 ne{TM CN 3 2 roll put /CN CN 1 add D /BK 0 D}
1393 {pop BK 0 eq{TM CN 32 put /CN CN 1 add D}if /BK 1 D}ie}forall
1394 TM 0 CN GI dup dup () ne E ( ) ne and
1395 {dup CN 1 sub get 32 eq{/EN f D}{/EN t D}ie}if} D
1396 /join {2 copy length E length add string dup 4 2 roll 2 index 0 3 index
1397 PI E length E PI}d
1398 /WR {(\\n) search{dup () ne BP not or
1399 {Li 4 le CP E pop YI Li mul add LE add 0 lt and PL 0 eq and{NP}if
1400 SH NL pop /Li Li 1 sub D WR}{pop pop WR}ie}{SH}ie /CI 0 D /BP f D} D
1401 /SH {dup dup () ne E ( ) ne and PF or CS Mf gt and{/Mf CS D}if
1402 T not Wf and{( ) E join /T t D}if dup BP{/MF CS D}if
1403 AT 3 eq{2 copy length dup 0 gt{/NB E NB add D
1404 {( ) search{/NS NS 1 add D pop pop}{pop exit}ie}loop}{pop pop}ie}if
1405 CD PD 0 lt and{dup DC search{SW pop /PD E L1 add D pop pop}{pop}ie}if
1406 0 Np dup SW pop L1 add /L1 E D dup () ne
1407 {C1 (\\() join E join (\\)) join AU AF and UF or Wf and{( U ) join}if
1408 sF{( s ) join}if ( S ) join
1409 /C1 E D dup length 1 sub get 32 eq /TB E D /Bw BW D}{pop pop}ie} D
1410 /BG {AI LG BC add add 0 eq} D
1411 /ON {OU{Ty AR AI NN get dup 1 add Ln Ns Ty 2 mod 0 eq{(. )}{(\\) )}ie join
1412 dup SW pop neg 0 R CP E 0 lt{0 E M}{pop}ie CP BB show /Ms t D}if} D
1413 /Ln {AR AI 3 -1 roll put}D
1414 /SP {dup CI lt BP not and{dup CI sub 0 E R /CI E D}{pop}ie} D
1415 /BN {PF{WR /HM f D}{BT NL}ie} D
1416 /NN {dup 0 lt{pop 0}if} D
1417 /h {(h) HI ST cvs join cvx exec dup 1 get E Nf{0 get E join}{pop}ie} D
1418 /H {/fn FN D /Hi E 1 add D 1 sub /HL E D /H2 HL 2 add D /GS EZ H2 get D
1419 E Tm H2 get GS mul BE dup 0 gt{1 sub}{pop EG H2 get dup 0 lt{pop AT}if}ie NA
1420 WW Np /SL SL 1 add D /FN EF H2 get D GS Ey H2 get FS
1421 EU H2 get Sc Hs not HL Hl lt and Hs HL hl lt and or Hi 0 eq or
1422 {/HI Hi D /Hs t D /hl HL D /Hv HL D}if HL Hl lt{/hi Hi D}if
1423 Nf HI 0 gt and{(h) Hi ST cvs join cvx exec 0 get WB}if
1424 /HF t D /AH f D /PO f D} D
1425 /EH {Bm H2 get GS mul BE OA /SL SL 1 sub NN D /CF 0 D /FN fn D
1426 SZ SL get FR SL get FS /HF f D /GS Ts D ()Ec} D
1427 /P {E PF{WR}{PO{EP}{BN}ie Ts 4 mul Np AE not{Tm 0 get Ts mul neg SP}if
1428 dup 0 ge AH and{Pi Pd}if}ie 1 sub dup 0 lt{pop AV AL get}if /AT E D /PO t D} D
1429 /EP {PF{WR}{BN Ts 4 mul Np}ie AE not{Bm 0 get Ts mul neg SP}if
1430 /AT AV AL get D /PO f D} D
1431 /BE {E PO{EP}{BN}ie Ts 4 mul Np neg SP} D
1432 /HR {/Aw W EO sub D /RW E dup 0 gt{Aw mul}{neg}ie dup Aw gt{pop Aw}if D /RZ E D
1433 E BN Ts neg SP 1 sub 2 div Aw RW sub mul EO add CP E pop M PF{0 Ps neg R}if
1434 0 Np OU{gsave RZ LW Cf{Hc VC}{0 Sg}ie CP BB RW 0 RL CP BB stroke grestore}if
1435 /CI 0 D /BP f D PF not{Ts neg SP}if /Ms t D} D
1436 /AD {I NL EG 14 get dup 0 lt{pop AT}if NA /AE t D Tm 14 get Ts mul neg SP
1437 Cf{EU 14 get dup -1 eq{pop CA CL get}if Sc}if} D
1438 /DA {BN ()ES OA /AE f D ()Ec Bm 14 get Ts mul neg SP} D
1439 /PR {/MW E D /Li E D Tm 1 get Ps mul BE 0 NA /FN Fp D /PF t D SI /SL SL 1 add D
1440 /CF 0 D Ps CS mul Ts div MW WC mul CS mul Ts div dup LL gt PL 0 eq and
1441 {LL div div}{pop}ie Ey 1 get FS CP E pop LE add YI neg div cvi dup Li lt
1442 AH and{4 lt YI Li mul 5 mul LE add 0 gt or PL 0 eq and{NP}if}{pop}ie
1443 EU 1 get Sc /GS Ps D}D
1444 /RP {WR NL () /PF f D SI /FN 0 D ES Bm 1 get Ps mul neg SP OA /GS Ts D} D
1445 /SI {/XO Lm 15 get BC NN mul Lm 16 get AI UI sub NN mul add
1446 Lm 17 get UI NN mul add Lm 20 get LG NN mul add Ts mul
1447 PF{Lm 1 get Ps mul add}if EO add D
1448 /MR Rm 15 get BC NN mul Rm 16 get AI UI sub NN mul add
1449 Rm 17 get UI NN mul add Rm 20 get LG NN mul add Ts mul
1450 PF{Rm 1 get Ps mul add}if D /LL W XO sub MR sub D} D
1451 /DT {/cC E D BN /LG LG 1 sub D SI /LG LG 1 add D WW 2 div Np BL} D
1452 /DD {WB Cc 0 eq cC 0 eq and L1 0 eq or Lm 20 get Ts mul L1 sub TB{BW add}if
1453 Ts 2 div lt or NL /LF E D SI BL /cC 0 D} D
1454 /DL {Dc LG Cc put /Cc E D BG{Tm 18 get Ts mul BE}{BN}ie /LG LG 1 add D BL} D
1455 /LD {BN LG 0 gt{/LG LG 1 sub D}if /Cc Dc LG get D SI
1456 BG{()Bm 18 get Ts mul BE}if BL} D
1457 /UL {BG{Tm 17 get Ts mul BE}{BN}ie NR AI NN 0 put /UI UI 1 add D
1458 /AI AI 1 add D SI BL} D
1459 /LU {BN /UI UI 1 sub D /AI AI 1 sub D SI BG{()Bm 17 get Ts mul BE}if BL} D
1460 /OL {E BG{Tm 16 get Ts mul BE}{BN}ie TR AI NN Ty put /Ty E D NR AI NN 1 put
1461 /AI AI 1 add D SI BL 1 Ln} D
1462 /LO {BN /AI AI 1 sub D /Ty TR AI get D SI BG{()Bm 16 get Ts mul BE}if BL} D
1463 /LI {E BN -1 SP /BP f D /CI 0 D 0 Np NR AI 1 sub NN get 1 eq
1464 {dup dup 0 gt E 4 le and{/Ty E D}{pop}ie
1465 /L1 L1 Ty AR AI NN get Ns SW pop XO sub dup 0 lt{pop 0}if add D ( ON )}
1466 {pop ( B )}ie C1 E join /C1 E D CS Mf gt{/Mf CS D}if BL} D
1467 /BQ {Tm 15 get Ts mul BE /BC BC 1 add D SI BL} D
1468 /QB {Bm 15 get Ts mul BE /BC BC 1 sub D SI BL} D
1469 /Al {E EP 1 sub dup 0 lt{pop AV AL get}if NA} D
1470 /Ea {EP OA} D
1471 /WB {PF{WR}{BT}ie} D
1472 /F1 {WB /FN 0 D CS 0 FS} D
1473 /F2 {WB /FN WI D CS 0 FS} D
1474 /HY {/Hy t D WB /Hy f D} D
1475 /YH {WB} D
1476 /A {/LT E D LT 1 eq{/RN E D}if /Lh E D WB /C1 C1 ( Cp ) join D
1477 Lc AF not and{Cl Sc}if /AF t D} D
1478 /EA {Lc AF and{Ec}{WB}ie TL Pa AF and Lh 0 ne and
1479 {( \\() Lh join (\\)) join /AF f D WB}if /AF f D} D
1480 /TL {C1 ( Tl ) apa /C1 E D} d
1481 /apa {AF OU and Lh 0 ne LT 1 eq or and{LT 1 eq{RN ( /) E ST cvs join}
1482 {(\\() Lh join (\\)) join}ie E join join}{pop}ie} d
1483 /Cp {/Xc CP /Yc E D D} D
1484 /SS {Cf{dup 0 ge{EU E get dup -1 eq{pop CA CL get}if}{pop CA CL get}ie Sc}
1485 {pop}ie SZ SL get /SL SL 1 add D} D
1486 /I {WB 8 SS 1 FS} D
1487 /EM {WB 8 SS /CF CF 1 xor D 0 FS} D
1488 /BD {WB 9 SS 2 FS} D
1489 /TT {WB 10 SS /FN Fp D 0 FS} D
1490 /KB {WB 11 SS /FN Fp D 2 FS} D
1491 /CT {WB 12 SS 1 FS} D
1492 /SM {WB 13 SS /FN Fp D 0 FS} D
1493 /Q {/QL QL 1 add D QO QL 2 mod get La get join WB} D
1494 /EQ {QC QL 2 mod get La get join WB /QL QL 1 sub D} D
1495 /RO {WB -1 SS /CF 0 D 0 FS} D
1496 /SY {WB -1 SS -1 FS} D
1497 /MY {WB -1 SS -2 FS} D
1498 /ES {WB /SL SL 1 sub NN D /CF 0 D /FN FO SL get D SZ SL get FR SL get FS ()Ec}D
1499 /FZ {3 sub 1.2 E exp GS mul E WB TL /C1 C1 ( Cp ) join D /SL SL 1 add D 0 FS} D
1500 /Ef {WB TL ()ES /C1 C1 ( Cp ) join D} D
1501 /BZ {dup /Bf E D FZ}D
1502 /Sc {dup -1 ne Cf and{/CL CL 1 add D dup 0 eq{pop [0 0 0]}if
1503 dup CA E CL E put VS ( VC ) join C1 E join /C1 E D}{pop}ie} D
1504 /Ec {WB Cf{/CL CL 1 sub NN D CA CL get VS ( VC ) join C1 E join /C1 E D}if} D
1505 /VS {dup type /arraytype eq{([) E {ST cvs join ( ) join}forall (]) join}if} D
1506 /VC {{255 div}forall setrgbcolor} D
1507 /Sl {dup type /integertype ne{Ds}if /La E D WB}d
1508 /UN {WB /UF t D} D
1509 /NU {WB /UF f D} D
1510 /SE {WB /sF t D} D
1511 /XE {WB /sF f D} D
1512 /sM {/C1 C1 ( k1 ) join D}d
1513 /eM {/C1 C1 ( k2 ) join D}d
1514 /k1 {/YC CP E pop Ts add D /mF t D /f1 t D}d
1515 /k2 {gsave 3 LW -9 CP E pop Ts 0.2 mul sub M -9 YC L stroke grestore /mF f D}d
1516 /Ac {/AC E D WB}d
1517 /Ca {eA{( \\()join AC join(\\) )join}if WB}d
1518 /s {OU{gsave 0 CS .25 mul R dup SW pop CJ 0 RL stroke grestore}if}D
1519 /CJ {AT 3 eq LB and{E dup dup length 1 sub A1 mul E
1520 {( ) search{pop pop E A2 add E}{pop exit}ie}loop 3 -1 roll add
1521 W CP pop sub 2 copy gt{E}if pop}if}D
1522 /So {/Co E D} D
1523 /SO {C1 Yo ST cvs join ( So ) join /C1 E D (j) SW pop 2 div Pd} D
1524 /Se {E WB CS E div Pd}D
1525 /Pd {dup type /stringtype eq{SW pop}if dup /L1 E L1 add D
1526 ST cvs ( 0 R ) join C1 E join /C1 E D} D
1527 /Sp {0.35 CO} D
1528 /Sb {-0.2 CO} D
1529 /CO {OV Io Yo put /Yo E CS mul Yo add D /Io Io 1 add D -1.5 Io mul 3 add FZ SO
1530 CS Yo add dup YA gt{/YA E D}{pop}ie
1531 Yo neg dup YB gt{/YB E D}{pop}ie} D
1532 /Es {ES /Io Io 1 sub NN D /Yo OV Io get D SO} D
1533 /SB {/N2 0 D 0 1 NI{/N E D{IX N2 get 0 lt{/N2 N2 1 add D}{exit}ie}loop
1534 /K WS N get FC N get mul D /NY AY N2 get D /BV NY array D
1535 0 1 NY 1 sub{/TM K string D currentfile TM readhexstring pop pop BV E TM put}
1536 for BM N BV put /N2 N2 1 add D}for} D
1537 /IC [{/MA E D /MB 0 D}{2 div /MA E D /MB MA D}{/MB E CS sub D /MA CS D}
1538 {pop /MA YS AB mul D /MB 1 AB sub YS mul D}{pop /MA 0 D /MB 0 D}] D
1539 /IP {BV N get /N N 1 add D} D
1540 /II {/K E D IX K get 0 lt{/EC E D}if /TY E D
1541 TY 4 eq{/Y E D /X E D}if TY 3 eq{/AB E D}if
1542 /XW AX K get D /YW AY K get D /IS SG IT K get get D /XS XW IS mul D
1543 /YS YW IS mul D YS IC TY get exec /MA MA Fl not{3 add}if D} D
1544 /IM {II /ty TY D /xs XS D /ys YS D /ya YA D /yb YB D /ma MA D /mb MB D /k K D
1545 /ec EC D /BP f D /CI 0 D WB TL L1 xs add dup XO add MR add W gt
1546 {pop /ma ma Fl{3 add}if D NL /YA ma D /YB mb D /YS ys D /L1 xs D}
1547 {/L1 E D ma YA gt{/YA ma D}if mb YB gt{/YB mb D}if}ie /TB f D
1548 OU{CP E pop YS sub LE neg lt Fl not and PB not and{NP /YA ma D /YB mb D}if
1549 /BP f D ty ST cvs ( ) join IX k get 0 lt{(\\() join ec join (\\) ) join}if
1550 k ST cvs join ty 3 eq{AB ST cvs ( ) join E join}if
1551 ty 4 eq{X ST cvs ( ) join Y ST cvs join ( ) join E join}if C1 E join
1552 ( DI ) join FP 2 eq FP 1 eq AF and or{( FM ) join}if
1553 ( Il Cp ) apa /C1 E D /EN f D}if /HM t D /T f D} D
1554 /DI {II /Xc CP /Yc E D D /YN YW neg D /HM t D /CI 0 D /K2 IX K get D gsave
1555 TY 4 eq{OX X IS mul add OY FY add YS sub Y IS mul sub}
1556 {/FY YS D CP MB sub 2 copy /OY E D /OX E D}ie
1557 translate K2 0 ge{/DP AZ K2 get D /BV BM K2 get D XS YS scale /N 0 D XW YW DP
1558 [XW 0 0 YN 0 YW] {IP} FC K2 get 1 eq{image}{f 3 colorimage}ie}
1559 {EX}ie grestore XS 0 R /Ms t D} D
1560 /FM {gsave 0 Sg CP MB sub translate XS neg 0 M 0 YS RL XS 0 RL 0 YS neg RL
1561 XS neg 0 RL stroke grestore} D
1562 /NA {/AT E D /AL AL 1 add D AV AL AT put} D
1563 /OA {AL 0 gt{/AL AL 1 sub D /AT AV AL get D}if} D
1564 /D1 {/BR {CP E pop E BN Mb{CP E pop eq{0 YI R}if}{pop}ie} D
1565 /Sn {OU{C1 E ST cvs join ( Ld ) join /C1 E D}{pop}ie} D} D
1566 /D1 {/BR {BN} D /Sn {OU {C1 E ST cvs join ( Ld ) join /C1 E D} {pop} ie} D} D
1567 /TC {/TF t D /ML 0 D HN{SW pop dup ML gt{/ML E D}{pop}ie}forall NP /RM RM not D
1568 RC /OU Tc D Ep /PN 0 D Ms not TP and{Ip}if /W IW ML sub Ts sub D
1569 /A0 0 D TH{/BR {( ) join BT} D /Sn {pop} D /Au () D}if} D
1570 /TN {0 eq{E EA PF HF or not XR and{HN E get Xr}{pop}ie}
1571 {OU{Tn 0 ge{() BN}if /Tn E D}{pop}ie WB}ie} D
1572 /NT {OU LB not and Tn 0 ge and{PL 0 eq{Ms not{CS CF FS}if CP dup
1573 /y E YA sub D W 9 sub CS -1.8 mul XO L1 add 2 add{y M (.) show}for
1574 HN Tn get dup SW pop IW E sub y M show CP BB M}if /Tn -1 D}if} D
1575 /Ld {/DN E D HN DN Pn put [/View [/XYZ -4 Fl{PS}{CP YA add US E pop}ie null]
1576 /Dest DN ST cvs cvn /DEST pdfmark} D
1577 /C {ND 1 eq{1 sub}if TI mul /XO E D NL Nf not{pop()}if 0 3 -1 roll 1 A} D
1578 /OP {BP not{NP}if PN 2 mod 0 eq{NP}if}D
1579 /Ep {Xp PN 2 mod 0 eq and OU and{/Pn (-) D showpage /PM 1 D LA}if}D
1580 /Dg [73 86 88 76 67 68 77] D
1581 /Rd [0 [1 1 0][2 1 0][3 1 0][2 1 1][1 1 1][2 2 1][3 3 1][4 4 1][2 1 2]] D
1582 /Ns {/m E D /c E 32 mul D /j m 1000 idiv D /p j 12 add string D
1583 c 96 le m 0 gt and{c 32 le {/i 0 D /d 77 D /l 100 D /m m j 1000 mul sub D
1584 j -1 1 {pop p i d c add put /i i 1 add D}for
1585 4 -2 0 {/j E D /n m l idiv D /m m n l mul sub D /d Dg j get D
1586 n 0 gt {/x Rd n get D x 0 get -1 1 {pop p i d c add put /i i 1 add D}for
1587 p i x 1 get sub Dg x 2 get j add get c add put}if /l l 10 idiv D
1588 }for p 0 i GI}
1589 {/i ST length 1 sub D m {1 sub dup 0 ge{dup 26 mod c add 1 add
1590 ST i 3 -1 roll put 26 idiv dup 0 eq{pop exit}if}if /i i 1 sub D}loop
1591 ST i ST length i sub GI}ie}
1592 {m p cvs}ie} D
1593 /US {matrix currentmatrix matrix defaultmatrix matrix invertmatrix
1594 matrix concatmatrix transform} D
1595 /GB {Gb{US}if}D
1596 /Tl {/Rn E D Xc CP pop ne{
1597 [/Rect [Xc 1 sub Yc cS 0.25 mul sub GB CP E 1 add E cS 0.85 mul add GB]
1598 /Subtype /Link /Border [0 0 Cf Lc and LX and AU or{0}{1}ie] Rn type
1599 /nametype eq {/Dest Rn}{/Action [/Subtype /URI /URI Rn] Cd}ie
1600 /ANN pdfmark}if} D
1601 /Il {/Rn E D [/Rect [Xc Yc GB Xc XS add Yc YS add GB] /Subtype /Link
1602 /Border [0 0 0] Rn type /nametype eq{/Dest Rn}
1603 {/Action [/Subtype /URI /URI Rn] Cd}ie /ANN pdfmark} D
1604 /XP {[{/Z Bz 2 div D Z 0 R Z Z RL Z neg Z RL Z neg Z neg RL Z Z neg RL
1605 Fi cH 1 eq and{fill}if} {Bz 0 RL 0 Bz RL Bz neg 0 RL 0 Bz neg RL
1606 Fi cH 1 eq and{fill}if} {0 -5 R Bz 0 RL 0 21 RL Bz neg 0 RL 0 -21 RL}]} D
1607 /MS {/Sm E D WB}D
1608 /O {BN()Sm BX} D
1609 /BX {/Bt E D Bt 2 lt{/Ch E D CS 0.8 mul}{11 mul}ie W XO sub MR sub
1610 2 copy gt{E}if pop /HZ E D Bt 2 eq{Fi not{pop()}if ( )E join /Ft E D TT
1611 /PF t D /MW 1 D /Li 1 D /Fw Ft SW pop D Fw HZ gt{/HZ Fw 8 add D}if
1612 HZ ST cvs( )join}{WB Ch ST cvs( )join}ie L1 HZ add XO add MR add W gt{NL}if
1613 Bt 2 eq{Ft ES Fw neg HM{CS sub}if Pd}if Bt ST cvs join( Bx )join
1614 Bt 2 eq HM and{CS Pd}if C1 E join /C1 E D /L1 L1 HZ add D /T f D
1615 ( ) Pd /PF f D Bt 2 lt{YA CS .8 mul lt{/YA CS .8 mul D}if}
1616 {YB 5 lt{/YB 5 D}if YA 21 lt{/YA 21 D}if}ie /CI 0 D} D
1617 /Bx {dup 2 eq{E /Bz E D}{E /cH E D /Bz CS .8 mul D}ie
1618 OU {gsave 0 Sg XP E get exec stroke grestore}{pop}ie Bz 0 R /Ms t D}D
1619 /SD {FD 4 mul Dy add DZ NF newpath 0 0 M DX t charpath pathbbox
1620 3 -1 roll sub /DY E D E dup /X1 E D sub WM mul WX DY mul add WM DG mul E div
1621 /DF E D /DR WX DF mul DY mul WM div 2 div D} d
1622 /Sd {gsave 0 IL Di mul neg translate IL IW atan Di 0 eq{neg}if rotate
1623 FD 4 mul Dy add DZ NF DR X1 sub DY 2 div neg M cD VC DX show grestore} d
1624 /Pt {/tp t D Tp{NP /Pn (TP) D 0 Tt neg R Th BN NP Ep ET RC ZF}if /tp f D} D
1625 /RC {/AI 0 D /LG 0 D /BC 0 D /UI 0 D /PF f D /Cc 0 D /cC 0 D /Dc 10 array D
1626 /NR [0 1 9{pop 0}for] D /La Ds D /AR 10 array D /TR 10 array D /AV 30 array D
1627 SI /AL -1 D /AT A0 D AT NA /OV 9 array D /Yo 0 D /Co 0 D /Io 0 D /Hy f D
1628 /Ph f D /CL -1 D Ct Sc}D
1629 /ZF {/FR [0 1 30{pop 0}for] D /SZ [0 1 30{pop 0}for] D /FO [0 1 30{pop 0}for] D
1630 /SL 0 D /CF 0 D /FN 0 D 0 Ts SF}D
1631 /QO [[($qo)][($qo2)]] D
1632 /QC [[($qc)][($qc2)]] D
1633 /Hf EF length 2 sub D
1634 /Hz EZ Hf get D
1635 /HS Ey Hf get D
1636 /Fz EZ Hf 1 add get D
1637 /Fs Ey Hf 1 add get D
1638 /LE IL D
1639 /Ps EZ 1 get D
1640 /Fp EF 1 get D
1641 /XO 0 D
1642 /YI 0 D
1643 /CI 0 D
1644 /FP 0 D
1645 /WW Ts 7 mul D
1646 /Mf 0 D
1647 /YA 0 D
1648 /YB 0 D
1649 /Cs Ts D
1650 /GS Ts D
1651 /F0 0 D
1652 /NS 0 D
1653 /NB 0 D
1654 /N 0 D
1655 /C0 [] D
1656 /C1 () D
1657 /Lo 0 D
1658 /L1 0 D
1659 /LM 0 D
1660 /PH 0 D
1661 /EC 0 D
1662 /Lh 0 D
1663 /LT 0 D
1664 /CH 1 string D
1665 /ST 16 string D
1666 /CA 9 array D
1667 /HC (\\255) D
1668 /HM f D
1669 /PF f D
1670 /EN f D
1671 /TB f D
1672 /UF f D
1673 /sF f D
1674 /AE f D
1675 /AF f D
1676 /BP t D
1677 /CD f D
1678 /PA t D
1679 /GL f D
1680 /T t D
1681 /HF f D
1682 /AH f D
1683 /SA f D
1684 /PB f D
1685 /f1 f D
1686 /mF f D
1687 /OX 0 D
1688 /OY 0 D
1689 /FY 0 D
1690 /EO 0 D
1691 /FB 0 D
1692 /PL 0 D
1693 /Bw 0 D
1694 /PD -1 D
1695 /TP f D
1696 /tp f D
1697 /TH $th D
1698 /Ty 4 D
1699 /Tn -1 D
1700 /Fl t D
1701 /LB t D
1702 /PM 1 D
1703 /Ms f D
1704 /Ba f D
1705 /Bb f D
1706 /Hl 3 D
1707 /hl 6 D
1708 /Hv 6 D
1709 /Hs f D
1710 /HI 0 D
1711 /hi 0 D
1712 /PO t D
1713 /TE f D
1714 /LF t D
1715 /BO 0 D
1716 /Sm 1 D
1717 /Bf 3 D
1718 /A1 0 D
1719 /A2 0 D
1720 /Ds $lid{'en'} D
1721 /QL -1 D
1722 /Cb Db D
1723 /Ct Dt D
1724 /Cl Dl D
1725 EOT
1726
1727 $tbl=<<EOT;
1728 /TS {
1729 tables E get /table E D
1730 table aload pop /rdesc E D /cdesc E D /tdesc E D
1731 tdesc aload pop /capalg E D /caption E D /rules E D /frame E D /nfoot E D
1732 /nhead E D /ncol E D /nrow E D /border E D /twid E D /units E D /talign E D
1733 /flow E D /clear E D /tclass E D pop pop
1734 /w W D /eps 0.1 D /OU f D /PL 1 D
1735 /FN EF 21 get D EZ 21 get Ey 21 get FS
1736 0 1 1{
1737 /pass E D
1738 0 1 nrow{
1739 /irow E D
1740 /cells rdesc irow get 6 get D
1741 0 1 ncol{
1742 /icol E D
1743 /cell cells icol get D
1744 cell 0 ne{
1745 cell aload pop /ang E D /CB E D pop pop pop
1746 /DV E D /bot E D /top E D /right E D /left E D /nowrap E D /valign E D
1747 /dp E D /align E D /rspan E D /cspan E D /cclass E D /ctype E D /cmax E D
1748 /cmin E D /proc E D
1749 rspan 0 eq{/rspan nrow irow sub 1 add D}if
1750 cspan 0 eq{/cspan ncol icol sub 1 add D}if
1751 pass 0 eq cspan 1 eq and pass 1 eq cspan 1 gt and or{
1752 /W 1e5 D /LL W D /PH 1 D
1753 ctype 1 eq{() BD}if
1754 RC align NA
1755 AT 4 eq{/CD t D /DC dp D /LN 0 D /M1 0 D /M2 0 D}{/CD f D}ie
1756 0 0 M /LM 0 D proc exec BN
1757 AT 4 eq{
1758 LN array astore cell 15 3 -1 roll put
1759 cdesc icol get dup dup 5 get M1 lt{5 M1 put}{5 get /M1 E D}ie
1760 dup 6 get M2 lt{6 M2 put}{6 get /M2 E D}ie
1761 /LM M1 M2 add D
1762 }if
1763 /CD f D
1764 ang 0 ne{/LM CP E pop neg D}if
1765 /thiswid LM left add right add eps add D
1766 /oldmin 0 D /oldmax 0 D
1767 0 1 cspan 1 sub{
1768 icol add cdesc E get dup 2 get /oldmax E oldmax add D
1769 1 get /oldmin E oldmin add D
1770 }for
1771 thiswid oldmax ge{
1772 0 1 cspan 1 sub{
1773 icol add cdesc E get dup 2 E 2 get oldmax 0 eq
1774 {pop thiswid cspan div}{thiswid mul oldmax div}ie
1775 put
1776 }for
1777 }if
1778 nowrap 1 eq{
1779 thiswid oldmin ge{
1780 0 1 cspan 1 sub{
1781 icol add cdesc E get dup 1 E 1 get oldmin 0 eq
1782 {pop thiswid cspan div}{thiswid mul oldmin div}ie
1783 put
1784 }for
1785 }if
1786 }{
1787 /W 0 D /LL W D /PH 2 D
1788 ctype 1 eq{() ES () BD}if
1789 0 0 M /LM 0 D RC proc exec BN
1790 /thiswid LM left add right add eps add D
1791 thiswid oldmin ge{
1792 0 1 cspan 1 sub{
1793 icol add cdesc E get dup 1 E 1 get oldmin 0 eq
1794 {pop thiswid cspan div}{thiswid mul oldmin div}ie
1795 put
1796 }for
1797 }if
1798 }ie
1799 ctype 1 eq{() ES}if
1800 }if
1801 }if
1802 }for
1803 }for
1804 }for
1805 /tmin 0 D /tmax 0 D
1806 0 1 ncol{
1807 cdesc E get dup 1 get E 2 get 2 copy gt{pop dup}if
1808 tmax add /tmax E D tmin add /tmin E D
1809 }for
1810 twid 0 lt{twid neg IW gt{IW neg}{twid}ie /twid E D}if
1811 tdesc 0 twid neg tmin 2 copy lt{E}if pop put
1812 tdesc 1 twid neg tmax 2 copy lt{E}if pop put
1813 /W w D /LL W D /OU t D /PH 0 D /PL 0 D
1814 } D
1815 /PT {
1816 /PL PL 1 add D
1817 tables E get /table E D Tm 21 get Ts mul BE
1818 PL 2 ge{save}if
1819 /SL SL 1 add D /FN EF 21 get D EZ 21 get Ey 21 get FS
1820 table aload pop /rdesc E D /cdesc E D /tdesc E D
1821 tdesc aload pop /capalg E D /caption E D /rules E D /frame E D /nfoot E D
1822 /nhead E D /ncol E D /nrow E D /border E D /twid E D /units E D /talign E D
1823 /flow E D /clear E D /tclass E D /tmax E D /tmin E D
1824 /w W D /xo XO D /mr MR D /ll LL D /lg LG D /ai AI D /bc BC D /nr NR D /ar AR D
1825 /tr TR D /ui UI D /ph PH D /a0 A0 D /pf PF D /at AT D /av AV D /al AL D
1826 /Le LE D /la La D
1827 talign 0 lt{/talign AL 0 gt{AV AL get}{A0 2 le{A0}{0}ie}ie D}if
1828 ph 1 eq ph 2 eq or{
1829 NL ph 1 eq{tmax}{tmin}ie dup XO add LM gt{/LM E XO add D}{pop}ie LM E
1830 }{
1831 /PH 3 D /LE 1e5 D RC %ZF
1832 border 0 gt{/border 1 D}if
1833 /twidth 0 D /avail W xo sub D
1834 twid 0 eq{0 1 ncol{cdesc E get dup 2 get E 3 get dup 0 gt{div neg dup twid lt
1835 {/twid E D}{pop}ie}{pop pop}ie}for}if
1836 /twid twid dup 0 lt{neg avail 2 copy gt{E}if pop}{avail mul}ie D
1837 /OK t D 0 1 ncol{cdesc E get dup 1 get E 3 get twid mul gt{/OK f D}if}for
1838 0 1 ncol{
1839 cdesc E get dup 1 get /colmin E D dup 3 get /cwid E twid mul D dup
1840 tmax avail le{2 get}if
1841 tmin avail le tmax avail gt and{
1842 dup 2 get E 1 get dup 3 1 roll sub avail tmin sub mul tmax tmin sub div add
1843 }if
1844 tmin avail gt{1 get}if
1845 0 E colmin cwid lt OK and{pop cwid}if dup /twidth E twidth add D put
1846 }for
1847 /OU f D CP
1848 tmin twid le{
1849 0 1 ncol{cdesc E get dup 0 get twidth div twid mul 0 E put}for
1850 /twidth twid D
1851 }if
1852 CP printcap CP E pop sub /caphig E D pop
1853 0 1 1{
1854 /pass E D
1855 0 1 nrow{
1856 /irow E D
1857 /cells rdesc irow get 6 get D
1858 0 1 ncol{
1859 /icol E D
1860 /cell cells icol get D
1861 cell 0 ne{
1862 cell aload pop /ang E D /CB E D pop pop pop
1863 /DV E D /bot E D /top E D /right E D /left E D /nowrap E D /valign E D
1864 /dp E D /align E D /rspan E D /cspan E D /cclass E D /ctype E D /cmax E D
1865 /cmin E D /proc E D
1866 rspan 0 eq{/rspan nrow irow sub 1 add D}if
1867 cspan 0 eq{/cspan ncol icol sub 1 add D}if
1868 /W 0 D
1869 0 1 cspan 1 sub{icol add cdesc E get 0 get /W E W add D}for
1870 pass 0 eq rspan 1 eq and pass 1 eq rspan 1 gt and or{
1871 ctype 1 eq{() BD}if
1872 /W W left sub right sub D /XO 0 D /EO 0 D SI
1873 /A0 align D RC align NA
1874 AT 4 eq{
1875 /DC dp D /DO 0 D /ID 1 D
1876 0 1 DV length 1 sub{DV E get dup DO gt{/DO E D}{pop}ie}for
1877 /Lo DO DV 0 get sub D /L1 Lo D
1878 }if
1879 0 0 M /BP t D /Fl t D /MF 0 D /FB 0 D
1880 proc exec T not{/CI 0 D}if BN 0 FB neg R MF 0 eq{/MF CS D}if
1881 CP /thishig E neg bot add top add CI add D pop
1882 ang 0 ne{/thishig LM bot add top add D}if
1883 cell 16 MF put cell 17 Ya put cell 18 thishig put
1884 valign 4 eq{
1885 /below thishig Ya sub D
1886 rdesc irow get dup dup 4 get Ya lt
1887 {4 Ya put}{4 get /Ya E D}ie
1888 dup 5 get below lt{5 below put}{5 get /below E D}ie
1889 /thishig Ya below add D
1890 }if
1891 ctype 1 eq{()ES}if
1892 /oldhig 0 D
1893 0 1 rspan 1 sub{
1894 irow add rdesc E get 0 get /oldhig E oldhig add D
1895 }for
1896 thishig oldhig ge{
1897 0 1 rspan 1 sub{
1898 irow add rdesc E get dup 0 E 0 get oldhig 0 eq
1899 {pop thishig rspan div}{thishig mul oldhig div}ie
1900 put
1901 }for
1902 }if
1903 }if
1904 }if
1905 }for
1906 }for
1907 }for M RC %ZF
1908 /thight 0 D /racc 0 D /maxh 0 D /brk 0 D /rbeg nhead nfoot add D
1909 rbeg 1 nrow{
1910 rdesc E get dup 0 get dup /thight E thight add D
1911 brk 0 eq{/racc E D}{/racc E racc add D}ie
1912 racc maxh gt{/maxh racc D}if 2 get /brk E D
1913 }for
1914 ph 3 ge{thight caphig add E}if
1915 ph 0 eq ph 4 eq or{
1916 /PH 4 D /LE Le D /OU Ou D /yoff 0 D /headsz 0 D
1917 0 1 nhead 1 sub{rdesc E get 0 get headsz add /headsz E D}for
1918 /footsz 0 D
1919 0 1 nfoot 1 sub{rdesc E nhead add get 0 get footsz add /footsz E D}for
1920 /ahig LE BO add MI add D /maxh maxh headsz add footsz add D
1921 /thight thight headsz add footsz add D
1922 tmin avail gt maxh ahig gt or
1923 {/Sf avail tmin div dup ahig maxh div gt{pop ahig maxh div}if D /SA t D}
1924 {/Sf 1 D}ie
1925 tclass 1 eq thight LE 15 sub gt and
1926 {/SA t D LE 15 sub thight div dup Sf lt{/Sf E D}{pop}ie}if
1927 SA{Sf Sf scale /ll ll Sf div D /xo xo Sf div D /LE LE Sf div D
1928 /mr mr Sf div D /BO BO Sf div D /ahig ahig Sf div D}if
1929 nhead nfoot add getwid
1930 LE CP E pop add capalg 0 eq{caphig sub}if
1931 bT{f}{dup thight lt thight ahig lt and}ie
1932 E headsz sub footsz sub rwid lt or{NP}if
1933 capalg 0 eq{printcap -8 SP}if
1934 CP /ycur E D pop
1935 printhead
1936 rbeg 1 nrow{/row E D row
1937 getwid
1938 ycur yoff add rwid sub footsz sub LE add 0 lt
1939 {nfoot 0 gt{printfoot}if Tf NP /rbeg irow1 D
1940 Ba{MI /MI MI SA{Sf div}if D MI SP /MI E D}if
1941 CP /ycur E D pop /yoff 0 D printhead}if
1942 irow1 printrow
1943 }for
1944 printfoot /row row 1 add D Tf
1945 0 ycur yoff add M
1946 capalg 1 eq{/EO 0 D SI -3 SP printcap}if
1947 Sf 1 lt{1 Sf div dup scale /ll ll Sf mul D /xo xo Sf mul D /LE LE Sf mul D
1948 /mr mr Sf mul D /BO BO Sf mul D /SA f D}if
1949 /EO 0 D
1950 }if
1951 }ie
1952 /W w D /XO xo D /MR mr D /LL ll D /LG lg D /AI ai D /BC bc D /NR nr D /AR ar D
1953 /TR tr D /UI ui D /PH ph D /A0 a0 D /PF pf D /AT at D /AV av D /AL al D
1954 /La la D
1955 /SL SL 1 sub NN D /CF 0 D /FN 0 D SZ SL get FR SL get FS Wf not{()F2}if
1956 PL 2 ge{Ms E restore Ms or /Ms E D PH 1 eq PH 2 eq or
1957 {/LM E D}if PH 3 ge{/CI 0 D NL 0 E neg R}if
1958 }if
1959 /PL PL 1 sub D /CI 0 D /BP f D /PO f D () Bm 21 get Ts mul BE BL %CF CS SF
1960 } D
1961 /printcap{
1962 capalg 0 ge{
1963 SA{/W w Sf div D}
1964 {talign 1 eq{/XO xo ll twidth sub 2 div add D}if
1965 talign 2 eq{/XO xo ll twidth sub add D}if
1966 /W XO twidth add D
1967 }ie /XO xo D /LL W XO sub MR sub D
1968 /PA f D /Fl capalg 0 eq D
1969 1 NA BL caption exec BN OA /PA t D
1970 }if
1971 } D
1972 /getwid{
1973 /irow1 E D
1974 /irow2 irow1 D
1975 /rwid 0 D
1976 {rdesc irow2 get dup 0 get rwid add /rwid E D 2 get 0 eq
1977 {exit}{/irow2 irow2 1 add D}ie
1978 }loop
1979 } D
1980 /printrow{
1981 /xoff ll twidth PL 2 ge{Sf div}if sub talign mul 2 div D
1982 /xleft xoff xo add D
1983 /irow E D
1984 /cells rdesc irow get 6 get D
1985 0 1 ncol{
1986 /icol E D
1987 /cell cells icol get D
1988 cell 0 ne{
1989 cell aload pop /ang E D /CB E D /cvsize E D /above E D /fontsz E D
1990 /DV E D /bot E D /top E D /right E D /left E D /nowrap E D /valign E D
1991 /dp E D /align E D /rspan E D /cspan E D /cclass E D /ctype E D /cmax E D
1992 /cmin E D /proc E D
1993 rspan 0 eq{/rspan nrow irow sub 1 add D}if
1994 cspan 0 eq{/cspan ncol icol sub 1 add D}if
1995 /width 0 D
1996 0 1 cspan 1 sub{icol add cdesc E get 0 get /width E width add D}for
1997 /rhight rdesc irow get 0 get D
1998 /hight rhight D
1999 1 1 rspan 1 sub{irow add rdesc E get 0 get /hight E hight add D}for
2000 /W xo xoff add width add right sub D
2001 ang 0 ne{/W xo xoff add hight add right sub D}if
2002 /EO xo xoff add left add D SI
2003 Cf{
2004 gsave CB VC xo xoff add ycur yoff add M
2005 0 hight neg RL width 0 RL 0 hight RL width neg 0 RL fill
2006 grestore
2007 }if
2008 ctype 1 eq{() BD}if
2009 /A0 align D RC
2010 AT 4 eq{
2011 /DC dp D /ID 1 D /DO cdesc icol get 5 get D /Lo DO DV 0 get sub D /L1 Lo D
2012 }if
2013 ang 0 ne{
2014 gsave ang 90 eq
2015 {xoff ycur add hight cvsize sub 2 div sub ycur hight sub xoff sub}
2016 {xoff ycur sub width add hight cvsize sub 2 div add ycur xoff add}ie
2017 translate ang rotate
2018 }if
2019 valign 3 le{0 ycur yoff add top sub
2020 hight cvsize sub valign 1 sub mul 2 div sub M}
2021 {0 ycur yoff add top sub above add rdesc irow get 4 get sub M}ie
2022 /PA f D /BP t D /Fl t D
2023 BL proc exec BN
2024 ang 0 ne{grestore}if
2025 /PA t D
2026 ctype 1 eq{() ES}if
2027 }if
2028 /xoff xoff cdesc icol get 0 get add D
2029 }for
2030 /yoff yoff rhight sub D
2031 } D
2032 /printhead {0 1 nhead 1 sub{printrow}for} D
2033 /printfoot {nhead 1 nhead nfoot add 1 sub{printrow}for} D
2034 /Tf {
2035 OU{rules 2 ge{/yoff 0 D
2036 gsave 0 Sg
2037 [0 1 nhead 1 sub{}for rbeg 1 row 1 sub{}for nhead 1 nhead nfoot add 1 sub{}for]{
2038 /irow E D
2039 /xoff ll twidth PL 2 ge{Sf div}if sub talign mul 2 div D
2040 /cells rdesc irow get 6 get D
2041 0 1 ncol{
2042 /icol E D
2043 /cell cells icol get D
2044 cell 0 ne{
2045 /rspan cell 6 get D
2046 /cspan cell 5 get D
2047 rspan 0 eq{/rspan nrow irow sub 1 add D}if
2048 cspan 0 eq{/cspan ncol icol sub 1 add D}if
2049 /width 0 D
2050 0 1 cspan 1 sub{icol add cdesc E get 0 get /width E width add D}for
2051 /rhight rdesc irow get 0 get D
2052 /hight rhight D
2053 1 1 rspan 1 sub{irow add rdesc E get 0 get /hight E hight add D}for
2054 xo xoff add width add ycur yoff add M
2055 0 hight neg icol cspan add 1 sub ncol lt
2056 {cdesc icol 1 add get 4 get dup rules 3 le{1 eq}{pop t}ie
2057 {1 eq{0.8}{0.3}ie
2058 LW RL CP stroke M}{pop R}ie}{R}ie
2059 irow nhead nfoot add 1 sub ne nfoot 0 eq or
2060 {irow rspan add 1 sub nrow lt
2061 {rdesc irow rspan add get 3 get}{nfoot 0 eq{0}{1}ie}ie
2062 dup rules 2 mod 0 eq{1 eq}{pop t}ie
2063 {1 eq irow rspan add nhead eq or irow rspan add row eq nfoot 0 gt and or
2064 {0.8}{0.3}ie LW width neg 0 RL CP stroke M}{pop}ie}if
2065 }if
2066 /xoff xoff cdesc icol get 0 get add D
2067 }for
2068 /yoff yoff rhight sub D
2069 }forall
2070 grestore
2071 /Ms t D
2072 }if
2073 frame 1 gt{
2074 gsave
2075 1 LW 0 Sg
2076 xleft ycur M CP BB
2077 0 yoff frame 5 eq frame 7 ge or{RL}{R}ie
2078 twidth 0 frame 3 eq frame 4 eq or frame 8 ge or{RL}{R}ie CP BB
2079 0 yoff neg frame 6 ge{RL}{R}ie
2080 twidth neg 0 frame 2 eq frame 4 eq or frame 8 ge or{RL}{R}ie
2081 closepath stroke
2082 grestore
2083 /Ms t D
2084 }if
2085 }if
2086 } D
2087 EOT
2088
2089 &openps if($opt_o);
2090 $ntab=-1;
2091 $tables="/tables [";
2092 @docs=$#ARGV<0?("-"):@ARGV;
2093 if($tocdoc) {$#docs=0};
2094 for (@docs) {$levl{$_}=1};
2095 $nref=0;
2096 $nhd=0;
2097 $nlnk=1;
2098 $ndoc=0;
2099 $nrem=0;
2100 $toc=$first?"Pt\n":"";
2101 $toc.="/BO 0 D TC /Ba f D Bs /AU f D /UR () D RC ZF\n";
2102 $toc.="()F2" if(!$latin1);
2103 $toc.="tH WB\n" if(!$tocdoc);
2104 $fl1="";
2105 $fl2="";
2106 $np="NP RC ZF";
2107 $P3="";
2108 while($html=shift @docs) {
2109 $ndoc++;
2110 $ba2="";
2111 $P2="(";
2112 $banner="";
2113 undef @links;
2114 $level=$levl{$html};
2115 if(&h2p) {
2116 if($ndoc==1) {
2117 $toc=~s/\$T/$ti/g;
2118 $toc=~s/\$A/$au/g;
2119 $toc=~s/[\200-\377]+/)F1($&)F2(/g if(!$latin1);
2120 }
2121 if($layer) {
2122 @docs=(@docs,@links);
2123 } else {
2124 @docs=(@links,@docs);
2125 }
2126 $rem=$#docs+1;
2127 if($rem && $opt_W) {
2128 &dbg("At least $rem document".($rem>1?"s":"")." remaining\n");
2129 }
2130 if($banner) {
2131 $_="/Ba t D /BA {($banner)BN} D\nBs f Pb CP /BO E D pop\n";
2132 &Subst($_);
2133 s/ H\(/ -1 H(/g;
2134 } else {
2135 $_="/Ba f D /BO 0 D Bs";
2136 }
2137 if($tocdoc && $first && $ndoc==1) {
2138 $TC=" TC\n";
2139 $et=" NP Ep ET /Tc f D";
2140 } else {
2141 $TC="";
2142 $et="";
2143 }
2144 $_.="\n/UR ($html) D\n/Ti ($ti) D\n/Au ($au) D\n/Df $draft D\n/ME [";
2145 for $i (sort {$metarc{$a} <=> $metarc{$b}} keys %metarc){
2146 $_.="($meta{$i})";
2147 }
2148 $_.="] D\n$TC";
2149 if($ndoc==1) {$top=$_};
2150 if(!$tocdoc) {
2151 $toc.="ND 1 gt{Ts 3 mul Np $refs{$html}()0 C()BD($ti)ES()$refs{$html}"
2152 ." 1 TN()EA()BN}if\n";
2153 }
2154 $hv=0;
2155 while($P2=~s/(\d) (\d) H\(([^\s<)]*)/$1 $2 $nhd H($3)WB $nref Sn(/) {
2156 $nhd++;
2157 if($hv+1<$2) {
2158 for($hv+1..$2-1) {
2159 push(@z1,-$nref);
2160 push(@z2,$_);
2161 }
2162 }
2163 $hv=$2;
2164 $hind[$hv-1]++;
2165 for $i ($hv..5) {$hind[$i]=0};
2166 $hind=join('.',@hind[0..$hv-1]);
2167 $hst=$3;
2168 $'=~/\)EH/;
2169 ($htxt=$hst.$`)=~s/\)EA\(//g;
2170 if(!$tocdoc) {
2171 $toc.="$hv NH le{$nref($hind\\240\\240)$hv C($htxt)$nref 1 TN()EA()BN}if\n";
2172 }
2173 push(@z1,$nref);
2174 push(@z2,$hv);
2175 $nref++;
2176 $htxt=~s/(\s+|\)BR\()/ /g;
2177 $htxt=~s/(^\s+|\)[^(]*\(|\s+$)//g;
2178 $htxt="" if(!$latin1);
2179 $dh.="/h$nhd [($hind\\240\\240)($htxt)] D\n";
2180 }
2181 if($tocdoc) {
2182 if($ndoc==1 && !$first) {
2183 $toc="TC RC ZF $_ $P2 WB () BN\n";
2184 $P2="";
2185 $P3="";
2186 $np="";
2187 $_="";
2188 }
2189 }
2190 $P3.="$fl1\n/Cb $bg D /Ct $tcol D /Cl $lcol D /CL -1 D Ct Sc\n";
2191 if($ndoc==1 && !$first) {$P3.="Pt\n"};
2192 $P3.="$fl2\n$_\n$np\n$P2";
2193 if($tocdoc && $ndoc==1 && !$first) {
2194 $np="/Cb $bg D NP RC ZF";
2195 } else {
2196 $fl1="WB NL$et";
2197 $fl2="DS";
2198 $np="0 BO R";
2199 }
2200 }
2201 }
2202
2203 $P3.=($P3!~/\)\s*$/?"()":"")."WB NL";
2204 if(!$tocdoc && $first && $nhd){$P3="$toc/OU t D /Cb $bg D NP Ep ET $P3"};
2205 if(!$first && ($tocdoc || !$tocdoc && $nhd)){$P3.=" $toc"};
2206
2207 if($ntab>=0) {
2208 $_="$tables] D";
2209 &ack($_);
2210 y/\t\f/ /;
2211 s/[\200-\377]/sprintf("\\%3.3o",ord($&))/eg;
2212 s/\)XX/)9 9 PR/g;
2213 s/ H\(/ -1 H(/g;
2214 $tables=$_;
2215 }
2216 $_="%!PS\n%%Title: $title\n$P0$P1";
2217 if($nimg>=0) {
2218 $_.="/AX [".join(' ',@XS)."] D\n/AY [".join(' ',@YS)."] D\n"
2219 ."/IX [".join(' ',@IX)."] D\n/IT [".join(' ',@IT)."] D\n";
2220 if($nm>=0) {
2221 $_.="/AZ [".join(' ',@DP)."] D\n/WS [".join(' ',@WS)."] D\n"
2222 ."/FC [".join(' ',@FC)."] D\n/NI $nm D\n/BM ".($nm+1)." array D\nSB\n";
2223 for $i (0..$nm) {$_.="$BM[$i]\n\n"}
2224 }
2225 $_.="\n$pv%Endpv\n" if($nps);
2226 }
2227 @kw=split(/[, ]+/,$kw);
2228 @Kw=();
2229 for $i (@kw){push(@Kw,$i) if(!grep(/^$i$/,@Kw))};
2230 $kw=join(', ',@Kw);
2231 for $i (0..$#z2) {
2232 $n=0;
2233 $j=$i;
2234 while($j++<=$#z2 && $z2[$j]>$z2[$i]) {$n++ if($z2[$j]==$z2[$i]+1)};
2235 push(@z3,$n);
2236 }
2237 $tdef=$ntab>=0?"$tbl$tables\n0 1 $ntab\{TS}for RC ZF\n":"";
2238 $hd="/Hr [@z1]D\n/HV [@z2]D\n/Cn [@z3]D";
2239 &cut($hd);
2240 if($gd) {
2241 $sd="/Df t D /DG IW IW mul IL IL mul add sqrt D IW IL IW IL lt{E}if"
2242 ." /WM E D /WX E D /DZ 180 D gsave SD /DZ DZ DF mul D SD grestore\n";
2243 } else {
2244 $sd="/Df f D\n";
2245 }
2246 $_.=<<EOD;
2247 [/Creator ($version) /Author ($Au) /Keywords ($kw) /Subject ($su)
2248 /Title ($title) /DOCINFO pdfmark
2249 /ND $ndoc D
2250 /HN [1 1 $nref\{pop (??)}for] D
2251 $dh$hd
2252 Hr length 0 gt{[/PageMode /UseOutlines /DOCVIEW pdfmark}if
2253 /Hn 1 D
2254 0 1 Hr length 1 sub{
2255 /Bn E D [Cn Bn get dup 0 gt{/Count E HV Bn get Bl ge{neg}if}{pop}ie
2256 /Dest Hr Bn get dup abs ST cvs cvn E 0 ge{(h)Hn ST cvs join cvx exec
2257 dup 1 get E Nf{0 get E join}{pop}ie /Hn Hn 1 add D}{()}ie
2258 /Title E dup length 255 gt{0 255 getinterval}if /OUT pdfmark}for
2259 ZF /FN Fp D Ps 0 FS /WC Wf{( )}{<A1A1>}ie SW pop D
2260 ET RC ZF
2261 $sd$rfs$tdef$top$P3
2262 /TE t D NP TU PM 0 eq and{/Pn () D showpage}if end restore
2263 EOD
2264
2265 if(($first || $opt_R) && $xref{'passes'}) {
2266 &dbg("Inserting cross references\n") if($opt_d);
2267 for $i (1..$xref{'passes'}) {&ref};
2268 }
2269 &fin;
2270
2271 sub h2p {
2272 if($html eq '-') {
2273 $_=<>;
2274 } elsif($html=~m|://|) {
2275 if(($prompt || $nrem>50) && $level>1) {
2276 &prompt("Retrieve document $html (y/n/q)? ",$ans);
2277 if($ans=~/q/i) {undef @docs};
2278 return 0 unless($ans=~/y/i);
2279 }
2280 &geturl($html,$_) || return;
2281 $nrem++;
2282 if($contyp!~m|text/html|i) {$_=" <plaintext>\n$_"};
2283 unless(($ba2)=$html=~m|(.*://.*/)|) {$ba2=$html."/"};
2284 } else {
2285 if(open(FILE,$html)) {
2286 &dbg("Reading $html\n") if($opt_W || $opt_d);
2287 $_=<FILE>;
2288 if(!/<HTML/i && $html!~/html?$/i && ($html!~/\.ps$/i || $ndoc>1)) {
2289 $_=" <plaintext>\n$_";
2290 }
2291 close FILE;
2292 $var{DOCUMENT_NAME}=$html;
2293 if($posix) {
2294 $var{LAST_MODIFIED}=POSIX::strftime("%c",localtime((stat $html)[9]));
2295 $var{DATE_LOCAL}=POSIX::strftime("%c",@now);
2296 $var{DATE_GMT}=POSIX::strftime("%c",@gmnow);
2297 }
2298 $mod=(stat $html)[9];
2299 } else {
2300 &dbg("*** Error opening $html\n");
2301 return 0;
2302 }
2303 }
2304
2305 if(/^%!/ && /$delim/) {
2306 $psin=1;
2307 &openps if($opt_o);
2308 $_=$P0.$';
2309 for $s ("b","c","cw","g","t") {
2310 &dbg("Option -$s ignored\n") if(eval "\$opt_$s");
2311 }
2312 &fin;
2313 }
2314
2315 &hb($_,$head);
2316 $head=~/<title$R\s*([\w\W]*)<\/title/i;
2317 ($ti=$2)=~s/\s+/ /g;
2318 $ti=$doctit{$html} if(!$ti);
2319 $ti=~s/\s*$//g;
2320 &spec($ti);
2321 &ent($ti);
2322 $ti="<Untitled>" if(!$ti);
2323 $title=$ti if(!$title);
2324 $draft="f" if(!$ddr);
2325 %meta=();
2326 $au="";
2327 while($head=~/<meta\s[^>]*(name|http-equiv)\s*=\s*["']?\s*(\w+)$R/gi) {
2328 $k=lc $2;
2329 ($v)=$&=~/content\s*=\s*["']\s*([^"']+)/i;
2330 $v=~s/\s+/ /g;
2331 $v=~s/\s*$//g;
2332 &spec($v);
2333 &ent($v);
2334 $meta{$k}=$v;
2335 if($k=~/author/) {$au=$au?"$au, $v":$v};
2336 if($k=~/keywords/) {$kw=$kw?"$kw, $v":$v};
2337 if($k=~/subject/ && !$su) {$su=$v};
2338 if(!$ddr && $k=~/status/ && $v=~/draft/i) {$draft="t";$gd=1};
2339 }
2340 $Au.=($Au?" + ":"").$au if($au);
2341 $b2=$opt_b;
2342 unless($b2) {
2343 ($b2)=$head=~/<base\s+href\s*=\s*"([^"]*)"$R/i;
2344 unless($b2) {($b2)=$head=~/<base\s+href\s*=\s*([\w\.-]+)$R/i}
2345 unless($b2) {$b2=$ba2}
2346 }
2347 $b2=~s|[^/]*$||;
2348 ($b1)=$b2=~m|(.*://[^/]*)/|;
2349 unless($b1) {$b1=$opt_r};
2350 unless($b2) {$b2=$html=~m|(.*/)[^/]*$|?$1:""};
2351 if(!defined $B2) {$B2=$b2};
2352 $levl{$b2.$html}=$levl{$html};
2353
2354 while($link && $head=~/<link\s+[^>]*rel\s*=\s*["']?next$R/gi) {
2355 if(($lnk)=$&=~/href\s*=\s*["']?\s*([^"' >]*)/gi) {
2356 if($lnk=~m|.+//[^/]+$|) {$lnk=$&."/"}
2357 if($lnk=~m|://|) {
2358 $rlnk=0;
2359 } else {
2360 $rlnk=1;
2361 if($lnk=~m|^/|) {$lnk=$b1.$lnk} else {$lnk=$b2.$lnk}
2362 }
2363 while($lnk!~m|^\.\./| && $lnk=~m|[^/]*/\.\./|) {$lnk=$`.$'};
2364 $lnk=~s|/\./|/|g;
2365 if(&follow && !$levl{$lnk}) {
2366 $levl{$lnk}=$level+1;
2367 push(@links,$lnk);
2368 }
2369 }
2370 }
2371 ($battr)=/<BODY$R/i;
2372 ($lang)=$battr=~/\slang\s*=\s*['"]?([a-zA-Z-]+)/i;
2373 ($lang)=$head=~/<html[^>]+lang\s*=\s*['"]?([a-zA-Z-]+)/i if(!$lang);
2374 $lang=$opt_l if($opt_l);
2375 $lang='en' if(!$lang);
2376 $lang=lc $lang;
2377 if($battr=~/\stext\s*=\s*['"]?\s*#?(\w+)/i) {$tcol=&col2rgb($1)};
2378 if(!$tcol) {$tcol="Dt"};
2379 if($battr=~/\slink\s*=\s*['"]?\s*#?(\w+)/i) {$lcol=&col2rgb($1)};
2380 if(!$lcol) {$lcol="Dl"};
2381 &inihyph if($opt_H);
2382 ($bg)=$battr=~/BGCOLOR\s*=\s*["']?\s*#?(\w+)/i;
2383 $bg=&col2rgb($bg);
2384 if($bg) {
2385 ($red,$grn,$blu)=@cvec;
2386 } else {
2387 ($red,$grn,$blu)=$bgcol=~/#(\w+).*#(\w+).*#(\w+)/;
2388 $bg="Db";
2389 }
2390
2391 $temp="";
2392 while(/<object$R/i) {
2393 $temp.=$`;
2394 $tag=$&;
2395 $end=$';
2396 $type=$tag=~/type\s*=\s*($S)/i?$+:"";
2397 $uaddr=$tag=~/data\s*=\s*($S)/i?$+:"";
2398 if($type=~/^text\/(html|plain)$/i
2399 || !$type && $uaddr=~m"(\.html?|://.+/|://[^/]+)$"i) {
2400 $tag=~/data\s*=\s*/i;
2401 if(&open($uaddr,$idoc)) {
2402 if($type=~/plain/i) {
2403 $idoc="<XMP>$idoc</XMP>";
2404 } else {
2405 &hb($idoc,$dum);
2406 }
2407 $_=$idoc;
2408 $_.=$' if($end=~/<\/object>/i);
2409 } else {
2410 &dbg("\n*** Error opening $uaddr\n");
2411 $_=$end;
2412 }
2413 } else {
2414 $temp.=$tag;
2415 $_=$end;
2416 }
2417 }
2418 $_=$temp.$_;
2419
2420 if($opt_c && defined $package{'check'}) {
2421 $file=$html;
2422 if($html=~m|://|) {
2423 open(SCRATCH,">$scr");
2424 print SCRATCH;
2425 close SCRATCH;
2426 $file="$scr";
2427 }
2428 &dbg(`$package{'check'} $file`);
2429 }
2430
2431 if(!$latin1) {
2432 if($opt_e=~/EUC-/i) {
2433 s/([\216\217\241-\376].)+/\000$&\000/g;
2434 &spec($_);
2435 s/\000(.+?)\000/)F1($1)F2(/g;
2436 } elsif($opt_e=~/SHIFT-JIS/i) {
2437 s/[\201-\237\340-\374][@-~\200-\374]/$&\000/g;
2438 s/[\241-\337]+(?!\000)/$&\000/g;
2439 s/[ -~\t\n\r\240]+(?!\000)/\002$&\001/g;
2440 &spec($_);
2441 s/\000//g;
2442 } else {
2443 while(/\e\$B([^\e]*)/) {
2444 $beg=$`;
2445 $end=$';
2446 $mat=$1;
2447 $mat=~s/\s//g;
2448 $_="$beg\001$mat$end";
2449 }
2450 s/\e\([BJ]/\002/g;
2451 &spec($_);
2452 }
2453 s/\001/)F1(/g;
2454 s/\002/)F2(/g;
2455 $_=")F2($_";
2456 y/\000-\010\013\016-\037\177//d;
2457 } else {
2458 &spec($_);
2459 y/\000-\010\013\016-\037\177-\237//d;
2460 }
2461 s/(\r\n|\r)/\n/g;
2462 $refs{$html}=$nref++ if(!defined $refs{$html});
2463 $_="\004$lang\004)WB $refs{$html} Sn($_";
2464
2465 # Yes, I know Perl has case-insensitive pattern matching. But on my system
2466 # it takes about 10 times longer to run!
2467
2468 $pt="";
2469 if(/<[pP][lL][aA][iI][nN][tT][eE][xX][tT]$R/) {$_=$`;$pt=$'};
2470 while($_){
2471 if(/(<[lL][iI][sS][tT][iI][nN][gG]$R)/) {$_=$`; $tag=$1; $rest=$';
2472 if(/<[xX][mM][pP]$R/){$_=$`; &Subst($_); $P2.="$_)XX("; $_=$'.$tag.$rest;
2473 if(m|</[xX][mM][pP]$R|) {$P2.="$`)RP("; $_=$'}
2474 else {$P2.=$'; $_=""}}
2475 else {&Subst($_); $P2.="$_)XX("; $_=$rest;
2476 if(m|</[lL][iI][sS][tT][iI][nN][gG]$R|) {$P2.="$`)RP("; $_=$'}
2477 else {$P2.=$'; $_=""}}}
2478 elsif(/<[xX][mM][pP]$R/) {$_=$`; &Subst($_); $P2.="$_)XX("; $_=$';
2479 if(m|</[xX][mM][pP]$R|) {$P2.="$`)RP("; $_=$'}
2480 else {$P2.=$'; $_=""}}
2481 else {&Subst($_);$P2.=$_; $_=""}
2482 }
2483 $pt=~s/\f/$pc/g;
2484 if($pt) {$P2.=")XX($pt"};
2485 $P2.=")";
2486 if($plain) {$P2.="RP ()"};
2487 while($P2=~/XX\(/) {
2488 $beg=$`;
2489 $'=~/\)(RP|$)/;
2490 $mat=$`;
2491 $end=$&.$';
2492 $mat=~s/(.*\n){30}.*/$&)WR(/g;
2493 ($temp=$mat)=~s/\)[^(]+\(//g;
2494 @prel=split(' *\n',$temp);
2495 $maxl=0;
2496 for $line (@prel) {
2497 $line=~s/\\.../x/g;
2498 while($line=~/\t+/) {
2499 $sp=' ' x (length($&)*8-length($`)%8);
2500 $line=~s/\t+/$sp/;
2501 $mat=~s/\t+/$sp/;
2502 }
2503 $ll=length($line);
2504 $maxl=$ll if($ll > $maxl);
2505 }
2506 $P2="$beg ".($#prel+1)." $maxl PR($mat$end";
2507 }
2508 $P1=~s/[\200-\377]/sprintf("\\%3.3o",ord($&))/eg;
2509 $P2=~s/[\200-\377]/sprintf("\\%3.3o",ord($&))/eg;
2510 $P2=~y/\t\f/ /;
2511 1;
2512 }
2513 sub Subst{
2514 local($_)=@_;
2515 if($page_break) {
2516 s/<!--NewPage-->/$pc/g;
2517 s/<(\?|hr\s+class\s*=\s*["']?)\s*page-break$R/$pc/gi;
2518 }
2519 s/<!--OddPage-->/)WB NL OP(/g;
2520 if($ssi && $html!~m|://|) {
2521 while(/<!--#(include|config|echo)\s+(\w+)\s*="([^"]+)"\s*-->/) {
2522 $inc="";
2523 $file=$3;
2524 if($1 eq "include" && (substr($file,0,1) ne "/" || $opt_r)) {
2525 if(substr($file,0,1) ne "/") {
2526 $file=$B2.$file;
2527 } elsif($2 eq "virtual") {
2528 $file=$opt_r.$file;
2529 }
2530 if(open INC,$file) {
2531 $inc=<INC>;
2532 &spec($inc);
2533 close INC;
2534 }
2535 } elsif ($1 eq "config" && $2 eq "timefmt") {
2536 if($posix) {
2537 $var{LAST_MODIFIED}=POSIX::strftime($3,localtime((stat $html)[9]));
2538 $var{DATE_LOCAL}=POSIX::strftime($3,@now);
2539 $var{DATE_GMT}=POSIX::strftime($3,@gmnow);
2540 }
2541 } elsif ($1 eq "echo") {
2542 $inc=$var{$3};
2543 }
2544 $_=$`.$inc.$';
2545 }
2546 }
2547 s/(­?|­?|<!--hy-->)/)HY(/g;
2548 while(/<!--/) {
2549 $_=$`;
2550 &getcom;
2551 $_.=$rest;
2552 }
2553 $temp="";
2554 while(/<([^"'>]*=\s*["'])/) {
2555 $temp.=$`."<";
2556 $_=$1.$';
2557 while(/^[^"'>]*=\s*(["'])/) {
2558 $temp.=$&;
2559 $_=$';
2560 if(/$1/) {
2561 ($tg=$`)=~y/>/\003/;
2562 $temp.=$tg.$&;
2563 $_=$';
2564 }
2565 }
2566 }
2567 $_=$temp.$_;
2568 $a='[aA][lL][iI][gG][nN]';
2569 $Y='[sS][tT][yY][lL][eE]';
2570 $A="($a\\s*=\"?|$Y\\s*=\\s*\"?[tT][eE][xX][tT]-\\s*$a:)";
2571 $I='[lL][eE][fF][tT]';
2572 $C='[cC][eE][nN][tT][eE][rR]';
2573 $D='[rR][iI][gG][hH][tT]';
2574 $J='[jJ][uU][sS][tT][iI][fF][yY]';
2575 $s='[sS][eE][lL][eE][cC][tT]';
2576 $F='[fF][oO][nN][tT]';
2577 $U='[cC][oO][lL][oO][rR]';
2578 $O='[cC][oO][mM][pP][aA][cC][tT]';
2579 s/<\w+[^>]*\s+[iI][dD]\s*=\s*($S)[^>]*>/$&<a name="$+">/g;
2580 s|<[dD][eE][lL]$R[\w\W]*?</[dD][eE][lL]>||g if($del{'display'}=~/^none$/);
2581 $ndiv=1;
2582 s|</?[dD][iI][vV]\d$R||g;
2583 s|<(/?)([dD][iI][vV])([>\s])|"<$1$2".($1?--$ndiv:$ndiv++).$3|eg;
2584 while(/<[dD][iI][vV](\d+)$R/) {
2585 $dbeg=$`;
2586 $dnum=$1;
2587 $dattr=$2;
2588 $dend=$';
2589 $div="";
2590 $ediv="";
2591 if($2=~/class\s*=\s*["']?noprint$R/i) {
2592 $_=$dbeg;
2593 $_.=$' if($dend=~/<\/[dD][iI][vV]$dnum>/);
2594 } else {
2595 if($dattr=~/$A\s*($I|$C|$D|$J)/) {
2596 $div.=")".$algn{"\L$2"}." Al(";
2597 $ediv.=")Ea(";
2598 }
2599 if($dattr=~/lang\s*=\s*["']?([a-zA-Z-]+)/i) {
2600 $lang=lc $1;
2601 $div.="\004$lang\004";
2602 &inihyph if($opt_H);
2603 $dbeg=~/(\004[^\004]*\004)[^\004]*$/;
2604 $ediv.=$1;
2605 }
2606 $dend=~s|</[dD][iI][vV]$dnum>|$ediv)BR(|;
2607 $_="$dbeg$div)BR($dend";
2608 }
2609 }
2610 s|<$C$R|)2 Al(|g;
2611 s|</$C$R|)Ea(|g;
2612 s|<(\w+)/([^/]+)/|<$1>$2</$1>|g;
2613 s/(<\w+[^>]*>)\n|\n(<\/\w+>)/$+/g;
2614 s|(<[lL][iI])$R\s*<[pP]>|)0 P($1$2|g;
2615 s/<[hH]([1-6])\s+$A\s*($I|$C|$D|$J)$R/)$algn{"\L$3"} $1 H(/g;
2616 s|<[hH]([1-6])$R|)0 $1 H(|g;
2617 s|</[hH][1-6]>|)EH(|g;
2618 s|<[bB][rR]$R|)BR(|g;
2619 s/<[pP]\s+[^>]*$A\s*($I|$C|$D|$J)$R/)$algn{"\L$2"} P(/g;
2620 s|<[pP]$R|)0 P(|g;
2621 s|</[pP]>|)EP(|g;
2622 s|<[aA][dD][dD][rR][eE][sS][sS]$R|)AD(|g;
2623 s|</[aA][dD][dD][rR][eE][sS][sS]>|)DA(|g;
2624 s|<[pP][rR][eE]$R\n?|)XX(|g;
2625 s|\n? *</[pP][rR][eE]>|)RP(|g;
2626 s|<[dD][tT]\s[^>]*$O$R|)1 DT(|g;
2627 s|<[dD][tT]$R|)0 DT(|g;
2628 s|<[dD][dD]$R|)DD(|g;
2629 s|<[dD][lL]\s[^>]*$O$R|)1 DL(|g;
2630 s|<[dD][lL]$R|)0 DL(|g;
2631 s|</[dD][lL]>|)LD(|g;
2632 s|<[uU][lL]$R|)UL(|g;
2633 s|</[uU][lL]>|)LU(|g;
2634 s|<[mM][eE][nN][uU]$R|)UL(|g;
2635 s|</[mM][eE][nN][uU]>|)LU(|g;
2636 s|<[dD][iI][rR]$R|)UL(|g;
2637 s|</[dD][iI][rR]>|)LU(|g;
2638 s|<[oO][lL]\s[^>]*[sS][tT][aA][rR][tT]\s*=\s*['"]?(-?\d+)$R|$&)WB $1 Ln(|g;
2639 s|<[oO][lL]\s[^>]*[tT][yY][pP][eE]\s*=\s*['"]?([1iIaA])$R|)$lity{$1} OL(|g;
2640 s|<[oO][lL]$R|)4 OL(|g;
2641 s|</[oO][lL]>|)LO(|g;
2642 s|<[lL][iI]\s[^>]*[vV][aA][lL][uU][eE]\s*=\s*['"]?(-?\d+)$R|$&)WB $1 Ln(|g;
2643 s|<[lL][iI]\s[^>]*[tT][yY][pP][eE]\s*=\s*['"]?($ltr)$R|)$lity{$1} LI(|g;
2644 s|<[lL][iI]$R|)-1 LI(|g;
2645 s|</[lL][iI]$R||g;
2646 s"<([bB][qQ]|[bB][lL][oO][cC][kK][qQ][uU][oO][tT][eE])$R")BQ("g;
2647 s"</([bB][qQ]|[bB][lL][oO][cC][kK][qQ][uU][oO][tT][eE])>")QB("g;
2648 s|<[sS][tT][rR][oO][nN][gG]$R|)BD(|g;
2649 s|</[sS][tT][rR][oO][nN][gG]>|)ES(|g;
2650 s|<[sS][aA][mM][pP]$R|)SM(|g;
2651 s|</[sS][aA][mM][pP]>|)ES(|g;
2652 s|<[qQ]$R(\s*)|$2)Q(|g;
2653 s|(\s*)</[qQ]>|)EQ($1|g;
2654 s|<[cC][iI][tT][eE]$R|)CT(|g;
2655 s|</[cC][iI][tT][eE]>|)ES(|g;
2656 s|<[vV][aA][rR]$R|)I(|g;
2657 s|</[vV][aA][rR]>|)ES(|g;
2658 s|<[bB]$R|)BD(|g;
2659 s|</[bB]>|)ES(|g;
2660 s|<[iI]$R|)I(|g;
2661 s|</[iI]>|)ES(|g;
2662 s|<[tT][tT]$R|)TT(|g;
2663 s|</[tT][tT]>|)ES(|g;
2664 s|<[uU]$R|)UN(|g;
2665 s|</[uU]>|)NU(|g;
2666 s|<[sS]([tT][rR][iI][kK][eE])?$R|)SE(|g;
2667 s|</[sS]([tT][rR][iI][kK][eE])?>|)XE(|g;
2668 s|<[dD][fF][nN]$R|)I(|g;
2669 s|</[dD][fF][nN]>|)ES(|g;
2670 s|<[eE][mM]$R|)EM(|g;
2671 s|</[eE][mM]>|)ES(|g;
2672 s|<[cC][oO][dD][eE]$R|)SM(|g;
2673 s|</[cC][oO][dD][eE]>|)ES(|g;
2674 s|<[kK][bB][dD]$R|)KB(|g;
2675 s|</[kK][bB][dD]>|)ES(|g;
2676 s|<[bB][iI][gG]$R|)4 FZ(|g;
2677 s|</[bB][iI][gG]>|)ES(|g;
2678 s|<[sS][mM][aA][lL][lL]$R|)2 FZ(|g;
2679 s|</[sS][mM][aA][lL][lL]>|)ES(|g;
2680 s|<[iI][nN][sS]$R|)sM WB(|g;
2681 s|</[iI][nN][sS]>|)WB eM(|g;
2682 s|<[dD][eE][lL]$R|)sM $lt(|g;
2683 s|</[dD][eE][lL]>|)XE eM(|g;
2684 s|<[aA][cC][rR][oO][nN][yY][mM][^>]+[tT][iI][tT][lL][eE]\s*=\s*($S)[^>]*>|)($+)Ac(|g;
2685 s|</[aA][cC][rR][oO][nN][yY][mM]>|)Ca(|g;
2686 s|<[fF][oO][rR][mM][\w\W]*?</[fF][oO][rR][mM]>||g if(!$forms);
2687 s|</?[fF][oO][rR][mM]$R|)Ts BE(|g;
2688 s/<$s[^>]*[mM][uU][lL][tT][iI][pP][lL][eE]$R/)1 MS(<table>/g;
2689 s/<$s$R/)0 MS(<table>/g;
2690 s|</$s>|</table>|g;
2691 s/<[oO][pP][tT][iI][oO][nN]$R/<tr><td>)O(/g;
2692 while(/<[iI][nN][pP][uU][tT]$R/) {
2693 $beg=$`;
2694 $iattr=$1;
2695 $rest=$';
2696 $it=2;
2697 if($iattr=~/type\s*=\s*["']?(\w+)/i) {$it=$it{"\L$1"}};
2698 if($it<2) {
2699 $it=($iattr=~/\schecked\W/i?1:0) ." $it";
2700 } elsif($it==2) {
2701 $siz=$iattr=~/size\s*=\s*["']?(\d+)/i?$1:12;
2702 $ival=$iattr=~/value\s*=\s*($S)/i?$+:"";
2703 $it="($ival)$siz $it";
2704 }
2705 if(defined($it)) {
2706 $cmd=$it==3?"<img $iattr":")$it BX(";
2707 } else {
2708 $cmd="";
2709 }
2710 $_=$beg.$cmd.$rest;
2711 }
2712 while(/<[tT][eE][xX][tT][aA][rR][eE][aA]$R/) {
2713 $beg=$`;
2714 $txatr=$1;
2715 $rest=$';
2716 if($rest=~m|</[tT][eE][xX][tT][aA][rR][eE][aA]>|) {
2717 $rest=$';
2718 $data=$prefilled||$textarea_data?$`:"";
2719 $rows=4;
2720 $cols=20;
2721 if($txatr=~/rows\s*=\s*["']?(\d+)/i) {$rows=$1};
2722 if($txatr=~/cols\s*=\s*["']?(\d+)/i) {$cols=$1};
2723 $nl=$data=~y/\n/\n/;
2724 for ($nl..$rows) {$data.="\n"};
2725 $data=~/(.*\n){$rows}/;
2726 $tfont=$prefilled?"TT":"0 FZ";
2727 ($data=$&)=~s/.*\n/<tr height=24><td valign=top>)$tfont($&)ES(/g;
2728 $wi=10*$cols;
2729 $frame=$prefilled?"frame=box":"border";
2730 $_="$beg<table $frame width=$wi cellpadding=2>$data</table>$rest";
2731 } else {
2732 $_=$beg.$rest;
2733 }
2734 }
2735 $nfnt=1;
2736 s|<(/?)($F)([>\s])|"<$1$2".($1?--$nfnt:$nfnt++).$3|eg;
2737 while(/<$F(\d+)([^>]*)$U\s*=\s*["']?\s*#?(\w+)$R/) {
2738 $rgb=&col2rgb($3);
2739 $_=$`.($rgb?")WB $rgb Sc(":"")."<font$2$4";
2740 $temp=$';
2741 $temp=~s|</$F$1>|</font>)Ec(| if($rgb);
2742 $_.=$temp;
2743 }
2744 $base{"+"}="Bf add ";
2745 $base{"-"}="Bf add ";
2746 s/<$F\d*\s[^>]*[sS][iI][zZ][eE]\s*=\s*["']?([+-]?)(\d+\.?\d*)$R/)$1$2 $base{$1}FZ(/g;
2747 s|<$F\d*$R|)3 FZ(|g;
2748 s|</$F\d*>|)Ef(|g;
2749 s|<[bB][aA][sS][eE]$F\s[^>]*[sS][iI][zZ][eE]\s*=\s*["']?(\d+)$R|)$1 BZ(|g;
2750 while(/(<[aA]\s+[^>]*)[nN][aA][mM][eE]\s*=\s*(["']?)([^"'\s>]*)$R([^\s<)]*)/) {
2751 $lnk="$html#$3";
2752 $refs{$lnk}=$nref++ unless(defined $refs{$lnk});
2753 $_="$`$1$4$5)WB $refs{$lnk} Sn($'";
2754 }
2755 while(/<[aA]\s+[^>]*[hH][rR][eE][fF]\s*=\s*["']?\s*([^"'\s>]*)$R/) {
2756 $beg=$`;
2757 $tag=$&;
2758 $rest=$';
2759 $lnk=$1;
2760 $revtoc=$tag=~/rev\s*=['"]?\s*toc/i;
2761 $html=~m|[^/]*$|;
2762 $lnk=~s/^\Q$&#/#/;
2763 $loc=$lnk=~/^#/;
2764 if($loc) {
2765 $html=~m|[^/]*$|;
2766 $lnk=$&.$lnk;
2767 }
2768 if($lnk=~m|.+//[^/]+$|) {$lnk=$&."/"}
2769 if($lnk=~m|://|) {
2770 $rlnk=0;
2771 } else {
2772 $rlnk=1;
2773 if($lnk=~m|^/|) {$lnk=$b1.$lnk} elsif($lnk!~m|^\w+:|) {$lnk=$b2.$lnk};
2774 }
2775 while($lnk!~m|^\.\./| && $lnk=~m|[^/]*/\.\./|) {$lnk=$`.$'};
2776 $lnk=~s"(^|/)\./"$1"g;
2777 ($doc)=$lnk=~/([^#]*)/;
2778 ($doctit{$doc})=$tag=~/title\s*=['"]([^'"]*)['"]/i;
2779 $T=0;
2780 $anch=2;
2781 if($loc || grep(/^\Q$doc\E$/,(@docs,@links))
2782 || $opt_W && !$link && $level<=$maxlev && &follow){
2783 $refs{$lnk}=$nref++ unless(defined $refs{$lnk});
2784 $anch="$refs{$lnk} 1";
2785 $ltype=$rev && $revtoc && $ndoc==1 || $opt_C=~/f/ && $ndoc==1?1:0;
2786 $rest=~s|</a>|)$refs{$lnk} $ltype TN TL()Ec /AF f D(|i;
2787 if(&follow && !$levl{$doc}) {
2788 &dbg("Link: $doc\n") if($opt_d);
2789 $levl{$doc}=$level+1;
2790 push(@links,$doc);
2791 }
2792 } elsif(defined $refs{$lnk}) {
2793 $anch="$refs{$lnk} 1";
2794 }
2795 $addr=$dum{$lnk}?"R$dum{$lnk}":0;
2796 if(!$dum{$lnk} && $lnk=~m|://|) {
2797 $dum{$lnk}=$nlnk++;
2798 $rfs.="/R$dum{$lnk} ($lnk) D\n";
2799 $addr="R$dum{$lnk}";
2800 }
2801 $_=$beg.")$addr $anch A(".$rest;
2802 }
2803 s|</[aA]>|)EA(|g;
2804 if((!$mult || $doc_sep eq $pc && $mult)
2805 && m|<[bB][aA][nN][nN][eE][rR]$R([\w\W]*)</[bB][aA][nN][nN][eE][rR]>|) {
2806 $banner=$2;
2807 $_=$`.$';
2808 }
2809 while(/<[tT][aA][bB][lL][eE]([^>]*)>/) {
2810 local($beg)=$`;
2811 local($rest)=$';
2812 $tattr=$1;
2813 $tag=$&;
2814 $rest=~/(<\/[tT][aA][bB][lL][eE]>|$)/;
2815 $table=$`;
2816 $rest=$';
2817 while($table=~/<[tT][aA][bB][lL][eE]([^>]*)>/) {
2818 $tattr=$1;
2819 $table=$';
2820 $beg.=$tag.$`;
2821 $tag=$&;
2822 }
2823 ($tla)=$tattr=~/lang\s*=\s*["']?([a-zA-Z-]+)/i;
2824 if(!$tla) {($tla)=$beg=~/\004_?([^\004]*)\004[^\004]*$/};
2825 $ntab++;
2826 $table=~s/^\s*//;
2827 undef %cells;
2828 undef %rd;
2829 undef @cali;
2830 undef @cval;
2831 undef @cgrp;
2832 undef @cwid;
2833 undef @codc;
2834 undef @r0;
2835 undef @c0;
2836 ($capat,$cap)=$table=~m|<caption$R([\w\W]*)</caption>|i;
2837 $capat=~/ALIGN\s*=\s*["']?\s*(\w+)/i;
2838 $capa=0;
2839 $capa=1 if("\L$1" eq "bottom");
2840 $capa=-1 if($cap!~/\S/);
2841 $bord=0;
2842 if($tattr=~/border/i) {
2843 ($bord)=$'=~/^\s*=\s*["']?(\d+)/;
2844 if(!$bord && $bord ne "0") {$bord=1};
2845 }
2846 ($talgn)=$tattr=~/ALIGN\s*=\s*["']?\s*(\w+)/i;
2847 $tal=-1;
2848 $tal=0 if($talgn=~/^left$/i);
2849 $tal=1 if($talgn=~/^center$/i);
2850 $tal=2 if($talgn=~/^right$/i);
2851 ($fra)=$tattr=~/FRAME\s*=\s*["']?\s*(\w+)/i;
2852 if($fra && $f{"\L$fra"}) {$fra=$f{"\L$fra"}} else {$fra=$bord?9:1};
2853 ($rul)=$tattr=~/RULES\s*=\s*["']?\s*(\w+)/i;
2854 if($rul && $r{"\L$rul"}) {$rul=$r{"\L$rul"}} else {$rul=$bord?5:1};
2855 unless(($twid)=$tattr=~/WIDTH\s*=\s*["']?(\d+\.?\d*%?)/i) {$twid=0};
2856 $twid=$twid=~/%$/?$`/100:-$twid;
2857 ($cpad)=$tattr=~/CELLPADDING\s*=\s*["']?\s*$V/i;
2858 if($tattr=~/CELLSPACING\s*=\s*["']?\s*$V/i && $1!=0) {$cpad+=$1/2};
2859 ($tbg)=$tattr=~/BGCOLOR\s*=\s*["']?\s*#?(\w+)/i;
2860 $tbg=&col2rgb($tbg);
2861 ($tcl)=$tattr=~/CLASS\s*=\s*["']?\s*(\w+)/i;
2862 $tcl="\L$tcl" eq "telelista"? 1: 0;
2863 $ic=0;
2864 $span=1;
2865 undef $gal;
2866 undef $gva;
2867 undef $odc;
2868 undef $gwi;
2869 $cgs=0;
2870 while($table=~/<[cC][oO][lL]([^>]*>)/g && $span>0) {
2871 $cola=$1;
2872 $ab=$`;
2873 $aft=$';
2874 $cola=~/(^|\s)ALIGN\s*=\s*["']?\s*(\w+)/i;
2875 $alg=$algn{"\L$2"};
2876 ($val)=$cola=~/VALIGN\s*=\s*["']?\s*(\w+)/i;
2877 $val=$v{"\L$val"};
2878 ($odc)=$cola=~/CHAR\s*=\s*["']?(.)/i;
2879 unless(($wid)=$cola=~/WIDTH\s*=\s*["'](\d+%?)/i) {$wid=0};
2880 if($wid=~/%$/) {$wid=$`/100};
2881 ($span)=$cola=~/SPAN\s*=\s*["']?\s*(\d+)/i;
2882 if(!$span && $span ne "0") {$span=1};
2883 $us=1;
2884 if($cola=~/^GROUP/i) {
2885 $gal=$alg;
2886 $gva=$val;
2887 $gdc=$odc;
2888 $gwi=$wid;
2889 $cgs=1;
2890 if($aft=~/<COL\s/i) {
2891 $us=$`=~m|</?COLGROUP|i;
2892 }
2893 } else {
2894 while($ab=~/<COLGROUP/i) {$ab=$'};
2895 if($ab=~m|</COLGROUP|i) {
2896 undef $gal;
2897 undef $gva;
2898 undef $odc;
2899 undef $gwi;
2900 }
2901 if(!$alg) {$alg=$gal};
2902 if(!$val) {$val=$gva};
2903 if(!$odc) {$odc=$gdc};
2904 if(!$wid) {$wid=$gwi};
2905 if($span eq "0") {
2906 $ic++;
2907 push(@cali,$alg);
2908 push(@cval,$val);
2909 push(@cwid,$wid);
2910 push(@codc,$odc);
2911 push(@cgrp,1);
2912 }
2913 }
2914 if($us) {
2915 for (1..$span) {
2916 $ic++;
2917 push(@cali,$alg);
2918 push(@cval,$val);
2919 push(@cwid,$wid);
2920 push(@codc,$odc);
2921 push(@cgrp,$cgs);
2922 $cgs=0;
2923 }
2924 }
2925 }
2926 $table=~/<t[hd][\s>]/i;
2927 if($`!~/<tr/i) {$table="<TR>$table"};
2928 $nrow=-1;
2929 $ncol=-1;
2930 $nhead=0;
2931 $nfoot=0;
2932 $nb=0;
2933 unless($table=~/<tbody$R/i || $table=~s|</tfoot>|$&<tbody>|i) {
2934 $table=~s|</thead>|$&<tbody>|i;
2935 }
2936 while($table=~/<[tT][rR]\s*([^>]*)>/g) {
2937 $nrow++;
2938 $ab=$`;
2939 $row=$';
2940 $rattr=$1;
2941 for $j (@c0) {
2942 $cells{"$nrow,$j,0"}=1;
2943 }
2944 $rgrp=0;
2945 if($ab=~/<tbody$R/i) {
2946 $ib=0;
2947 while($ab=~/<[tT][bB][oO][dD][yY]$R/g) {
2948 $ib++;
2949 $battr=$1;
2950 if($ib>$nb) {
2951 $rgrp=1;
2952 $nb=$ib;
2953 }
2954 }
2955 } else {
2956 if($ab=~/<tfoot$R/i) {
2957 $nfoot++;
2958 $battr=$1;
2959 } elsif($ab=~/<thead$R/i) {
2960 $nhead++;
2961 $battr=$1;
2962 }
2963 }
2964 $battr=~/(^|\s)ALIGN\s*=\s*["']?\s*(\w+)/i;
2965 $balgn=$algn{"\L$2"};
2966 $battr=~/VALIGN\s*=\s*["']?\s*(\w+)/i;
2967 $bva=$v{"\L$1"};
2968 ($bdc)=$battr=~/CHAR\s*=\s*["']?(.)/i;
2969 $rd{"$nrow,0"}=0;
2970 $rd{"$nrow,1"}=0;
2971 $rd{"$nrow,2"}=0 unless($rd{"$nrow,2"});
2972 $rd{"$nrow,3"}=$rgrp;
2973 $rattr=~/(^|\s)ALIGN\s*=\s*["']?\s*(\w+)/i;
2974 $ralgn=$algn{"\L$2"};
2975 $rattr=~/VALIGN\s*=\s*["']?\s*(\w+)/i;
2976 $rva=$v{"\L$1"};
2977 ($rla[$nrow])=$rattr=~/lang\s*=\s*["']?([a-zA-Z-]+)/i;
2978 ($rbg)=$rattr=~/BGCOLOR\s*=\s*["']?\s*#?(\w+)/i;
2979 $rbg[$nrow]=&col2rgb($rbg);
2980 ($rdc)=$rattr=~/CHAR\s*=\s*["']?(.)/i;
2981 if($row=~/<tr/i) {$row=$`};
2982 $rh[$nrow]=$rattr=~/HEIGHT\s*=\s*["']?(\d+)/i?$1:0;
2983 $icol=0;
2984 $colsp=1;
2985 while($row=~/<[tT]([hH]|[dD])(\s*[^>]*)>/g && $colsp>0) {
2986 $cattr=$2;
2987 $cell=$';
2988 $ctype=$1=~/h/i?1:0;
2989 if($cell=~/<t[hd]/i) {$cell=$`};
2990 $cell=~s/\s+$//;
2991 $cell=~s/\)HY\($/\255/;
2992 $cell=~s/[\200-\377]([^\\]|\\20.)/$&)WB(/g if(!$latin1);
2993 ($rowsp)=$cattr=~/ROWSPAN\s*=\s*["']?(\d+)/i;
2994 $rsp=$rowsp;
2995 if(!$rsp) {
2996 if($rsp eq "0") {
2997 push(@c0,$icol);
2998 } else {
2999 $rowsp=1;
3000 }
3001 $rsp=1;
3002 }
3003 ($colsp)=$cattr=~/COLSPAN\s*=\s*["']?(\d+)/i;
3004 $csp=$colsp;
3005 if(!$csp) {
3006 if($csp eq "0") {
3007 push(@r0,$nrow);
3008 $csp=$ncol-$icol<0? 1: $ncol-$icol+1;
3009 } else {
3010 $colsp=1;
3011 $csp=1;
3012 }
3013 }
3014 ($cdc)=$cattr=~/CHAR\s*=\s*["']?(.)/i;
3015 while($cells{"$nrow,$icol,0"}==1) {$icol++};
3016 #
3017 for $i ($nrow..$nrow+$rsp-2) {$rd{"$i,2"}=1};
3018 for $j ($icol..$icol+$csp-1) {
3019 for $i ($nrow..$nrow+$rsp-1) {
3020 $cells{"$i,$j,0"}=1;
3021 }
3022 }
3023 if($colsp) {
3024 for $j ($ncol+1..$icol+$csp) {
3025 for $i (@r0) {
3026 $cells{"$i,$j,0"}=1;
3027 }
3028 }
3029 }
3030 if($ic<$icol+$csp) {
3031 for ($ic..$icol+$csp-1) {
3032 push(@cali,$cali[$ic-1]);
3033 push(@cval,$cval[$ic-1]);
3034 push(@cgrp,0);
3035 }
3036 $ic=$icol+$csp;
3037 }
3038 $cal=$ctype;
3039 $cal=$balgn-1 if($balgn);
3040 $cal=$ralgn-1 if($ralgn);
3041 $cal=$cali[$icol]-1 if($cali[$icol]);
3042 if($cattr=~/(^|\s)ALIGN\s*=\s*["']?\s*(\w+)/i) {
3043 $cal=$algn{"\L$2"}-1 if($algn{"\L$2"});
3044 }
3045 $cvl=2;
3046 $cvl=$cval[$icol] if($cval[$icol]);
3047 $cvl=$bva if($bva);
3048 $cvl=$rva if($rva);
3049 if($cattr=~/VALIGN\s*=\s*["']?\s*(\w+)/i) {
3050 $cvl=$v{"\L$1"} if($v{"\L$1"});
3051 }
3052 ($cbg)=$cattr=~/BGCOLOR\s*=\s*["']?\s*#?(\w+)/i;
3053 $cbg=&col2rgb($cbg);
3054 for($rbg[$nrow],$tbg,$deftbg,$bg) {$cbg=$_ if(!$cbg)};
3055 $now=0;
3056 $ro=$cattr=~/class\s*=\s*["']?rot(-?90)/i?$1:0;
3057 if($cattr=~/NOWRAP/i || $cal==4 || $ro) {$now=1};
3058 $dc=".";
3059 $dc=$bdc if($bdc || $bdc eq "0");
3060 $dc=$rdc if($rdc || $rdc eq "0");
3061 $dc=$codc[$icol] if($codc[$icol] || $codc[$icol] eq "0");
3062 $dc=$cdc if($cdc || $cdc eq "0");
3063 ($wid)=$cattr=~/WIDTH\s*=\s*["'](\d+%)/i;
3064 if($wid=~/%$/) {$wid=$`/100};
3065 if($wid>$cwid[$icol]) {$cwid[$icol]=$wid};
3066 if($cpad || $cpad eq "0") {
3067 $clm=$cpad;
3068 $crm=$cpad;
3069 $ctm=$cpad;
3070 $cbm=$cpad;
3071 } else {
3072 $clm=$rul<5?8:4;
3073 $crm=$rul<5?8:4;
3074 $ctm=2;
3075 $cbm=6;
3076 }
3077 if($tcl==1) {
3078 $clm=$icol>0?12:2;
3079 $crm=12;
3080 $ctm=0;
3081 $cbm=0;
3082 }
3083 if($rul==1 && $fra==1 && $icol==0 && $tal==0) {$clm=0};
3084 ($lang)=$cattr=~/lang\s*=\s*["']?([a-zA-Z-]+)/i;
3085 for($rla[$nrow],$tla) {$lang=$_ if(!$lang)};
3086 $lang=lc $lang;
3087 &inihyph if($opt_H);
3088 $cbg=~/#(\w+).*#(\w+).*#(\w+)/;
3089 &img($cell,$1,$2,$3);
3090 @cll=("{(\004$lang\004)WB($cell)}",0,0,$ctype,0,$colsp,$rowsp,$cal,
3091 "($dc)",$cvl,$now,$clm,$crm,$ctm,$cbm,0,0,0,0,$cbg,$ro);
3092 for $i (0..$#cll) {$cells{"$nrow,$icol,$i"}=$cll[$i]};
3093 $icol+=$csp;
3094 if($icol-1>$ncol) {$ncol=$icol-1};
3095 }
3096 }
3097 for $j (0..$ncol) {
3098 for $i (0..$nrow) {
3099 if($cells{"$i,$j,0"} && $cells{"$i,$j,0"}!=1) {
3100 if($cells{"$i,$j,6"}>$nrow-$i+1) {$cells{"$i,$j,6"}=$nrow-$i+1};
3101 if($cells{"$i,$j,6"}>1) {$rd{"$i,2"}=1};
3102 }
3103 }
3104 }
3105 $rd{"$nrow,2"}=0;
3106 $rw="[";
3107 for $i (0..$nrow) {
3108 $rw.="[$rh[$i] ".$rd{"$i,1"}." ".$rd{"$i,2"}." ".$rd{"$i,3"}." 0 0 [";
3109 for $j (0..$ncol) {
3110 $cbg="";
3111 for($rbg[$i],$tbg,$deftbg,$bg) {$cbg=$_ if(!$cbg)};
3112 $temp="[{()}0 0 0 0 1 1 0(.)0 0 $clm $crm $ctm $cbm 0 0 0 0 $cbg $ro]";
3113 if($cells{"$i,$j,0"}==1) {
3114 $temp="0";
3115 } elsif($cells{"$i,$j,0"}) {
3116 $temp="[";
3117 for $k (0..$#cll) {
3118 $temp.=$cells{"$i,$j,$k"}." ";
3119 }
3120 $temp.="]";
3121 }
3122 $rw.="$temp\n";
3123 }
3124 $rw.="]]\n";
3125 }
3126 if($nrow==$nhead+$nfoot-1) {
3127 $nhead=0;
3128 $nfoot=0;
3129 }
3130 $tdesc="[0 0 $tcl 0 0 $tal 0 $twid $bord $nrow $ncol"
3131 ." $nhead $nfoot $fra $rul {($cap)} $capa]\n";
3132 $cdesc="[";
3133 for (0..$ncol) {
3134 unless($wid=$cwid[$_]) {$wid=0};
3135 $cdesc.="[0 0 0 $wid $cgrp[$_] 0 0]";
3136 }
3137 $cdesc.="]\n";
3138 $tables.="[$tdesc $cdesc $rw]]\n";
3139 $_=$beg.")$ntab PT(".$rest;
3140 }
3141 &img($_,$red,$grn,$blu);
3142 &ack($_);
3143 $_[0]=$_;
3144 }
3145 sub getcom{
3146 $com=$&;
3147 $'=~/--\s*(--|>)/;
3148 $com.=$`.$&;
3149 $rest=$';
3150 while($1 eq "--") {
3151 $'=~/(>)/ if($'!~/--\s*(--|>)/);
3152 $com.=$`.$&;
3153 $rest=$';
3154 }
3155 }
3156 sub getl {
3157 ($l)=@_;
3158 if(!$lid{$l}) {
3159 while($l=~s/-[^-]+$// && !$lid{$l}) {};
3160 }
3161 $lid{$l};
3162 }
3163 sub ack {
3164 local($_)=@_;
3165 chdir $tempdir;
3166 while (/<[mM][aA][tT][hH]/) {
3167 $beg=$`;
3168 $rest=$&.$';
3169 $rest=~m|</[mM][aA][tT][hH]>|;
3170 $end=$';
3171 $math=$`;
3172 if(&math2sym($math)) {
3173 $_=$beg.$sym.$end;
3174 } elsif($package{'TeX'} && $package{'dvips'}) {
3175 $math=~s|\\200|\\|g;
3176 $math=~s|\\201|\(|g;
3177 $math=~s|\\202|\)|g;
3178 &math2tex($math);
3179 open(SCRATCH,">$scr.tex");
3180 print SCRATCH $tex;
3181 close SCRATCH;
3182 `tex $scr.tex`;
3183 `dvips -E -o $scr.ps $scr.dvi`;
3184 open(LOG,"$scr.log");
3185 $log=<LOG>;
3186 close LOG;
3187 ($h,$d)=$log=~/[\w\W]*$prog: +([\d.]+)pt: +([\d.]+)/ ? ($1,$2) : (1,0);
3188 $above=$h+$d>0?sprintf("%.4f",$h/($h+$d)):0;
3189 open(PS,"$scr.ps");
3190 $pic=<PS>;
3191 if($pic=~/^%!/ && $pic=~/%%BoundingBox: +$V +$V +$V +$V/) {
3192 $xs=$3-$1;
3193 $ys=$4-$2;
3194 $llx=$1;
3195 $lly=$2;
3196 $ps="";
3197 for $i (split(/\n/,$pic)) {
3198 $ps.=$i."\n" if($i && $i!~/^%/);
3199 }
3200 if($ps=~/\nTeXDict begin/) {
3201 if(!$ph) {
3202 $ph="/DH {1 F div dup scale /showpage {} D\n$`$&} D\n%EndDH\n";
3203 $pv=$ph.$pv;
3204 }
3205 $ps="save -$llx -$lly translate\nDH$' restore";
3206 }
3207 }
3208 $nimg++;
3209 $nps--;
3210 push(@XS,$xs);
3211 push(@YS,$ys);
3212 push(@IX,$nps);
3213 push(@IT,2);
3214 $pv.="/P$nimg {$ps} D\n";
3215 $eps{"P$nimg"}=$ps;
3216 $_=$beg.")$above 3 (P$nimg) $nimg IM(".$end;
3217 } else {
3218 $math=~s/<math$R//i;
3219 $_=$beg.$math.$end;
3220 }
3221 }
3222 chdir $cwd;
3223 s|<[sS][uU][bB]$R|)Sb(|g;
3224 s|<[sS][uU][pP]$R|)Sp(|g;
3225 s"</[sS][uU]([bB]|[pP])>")Es("g;
3226 s|<[A-Za-z/!?]\w*$R||g;
3227 &ent($_);
3228 y/\003/>/;
3229 s/\004([^\004]*)\004/")".&getl($1)." Sl($&"/eg;
3230 if($opt_H) {
3231 &dbg("Inserting potential hyphenation points\n") if($opt_d && $ndoc>0);
3232 $temp="";
3233 while(/\004([^\004]*)\004/) {
3234 $temp.=$`;
3235 $lang=$1;
3236 $end=$';
3237 if($end=~/\004([^\004]*)\004/) {
3238 $htext=$`;
3239 $end=$&.$';
3240 } else {
3241 $htext=$end;
3242 $end="";
3243 }
3244 $apa="";
3245 while($htext=~/(..?)\(([^)]*)/) {
3246 $slut=$';
3247 if($1 eq "XX") {
3248 $apa.=$`.$&;
3249 if($'=~/RP\(/) {
3250 $apa.=$`;
3251 $htext=$&.$';
3252 } else {
3253 $apa.=$slut;
3254 $htext="";
3255 }
3256 } elsif($1 eq ") ") {
3257 $apa.=$`.$&;
3258 $htext=$';
3259 } else {
3260 $apa.="$`$1(";
3261 $htext=$';
3262 ($txt=$2)=~s/[$ltrs]{$hyphenation{'min'},}/&hyph($&)/eg;
3263 $apa.=$txt;
3264 }
3265 }
3266 $_=$apa.$slut.$end;
3267 }
3268 $_=$temp.$_;
3269 }
3270 s/\004([^\004]*)\004//g;
3271 $_[0]=$_;
3272 }
3273 sub ent {
3274 local($_)=@_;
3275 s|&#x($X+);?|"&#".hex($1).";"|egi;
3276 for $char (keys %ent) {s/&($char)(;|$|(?=\W))/chr($ent{$char})/eg};
3277 for $char (keys %symb) {s/&($char)(;|$|(?=\W))/)SY(\\$symb{$char})ES(/g};
3278 s/&(euro|#8364)(;|$|(?=\W))/)MY(e)ES(/g;
3279 s|<?|<|g;
3280 s|>?|>|g;
3281 s|"?|"|g;
3282 s/&($space);?/)$space{$1} Se(/g;
3283 s|&#(\d+);?|$1==38?"\005":$1<256?chr($1):$&|eg;
3284 s/(\005|&?)/\&/g;
3285 $_[0]=$_;
3286 }
3287 sub spec {
3288 $_[0]=~s/(\\|\(;|$|(?=\W)))/\\200/g;
3289 $_[0]=~s/(\(|((;|$|(?=\W)))/\\201/g;
3290 $_[0]=~s/(\)|)(;|$|(?=\W)))/\\202/g;
3291 $_[0]=~s/&(there4|#8756|#[xX]2234)(;|$|(?=\W))/)SY(\\200)ES(/g;
3292 }
3293 sub math2tex {
3294 local($_)=@_;
3295 local($beg,$rest);
3296 %a=("line","overline",
3297 "cub","overbrace",
3298 "hat","widehat",
3299 "tilde","widetilde",
3300 "larr", "overleftarrow",
3301 "rarr", "overrightarrow");
3302 %b=("line","underline",
3303 "cub","underbrace",
3304 "hat","widehat",
3305 "tilde","widetilde");
3306 %s=("medium","\\big",
3307 "large","\\Big",
3308 "huge","\\bigg");
3309 ($mattr)=/<math$R/i;
3310 $st=$mattr=~/class\s*=\s*["']?chem/i?'\rm ':'';
3311 $di=$mattr=~/class\s*=\s*["']?displayed/i?'\displaystyle ':'';
3312 s/<math$R//gi;
3313 s/\\/\\backslash/g;
3314 s/__/_\\>_/gi;
3315 s/\^\^/^\\>^/gi;
3316 s/_([^_]+)_/_{$1}/g;
3317 s/\^([^^]+)\^/^{$1}/g;
3318 s/ ?/\\,/g;
3319 s/&sp;?/\\>/g;
3320 s/ ?/\\;/g;
3321 s/ ?/\\>/g;
3322 s/ε?/\\varepsilon /g;
3323 s/υ?/\\upsilon /g;
3324 s/ϖ?/\\varpi /g;
3325 s/ς?/\\varsigma /g;
3326 s/ϑ?/\\vartheta /g;
3327 s/ϕ?/\\varphi /g;
3328 s/ϒ?/\\Upsilon /g;
3329 s/ο?/o/g;
3330 s/±?/\\pm /g;
3331 s/∨?/\\vee /g;
3332 s/∧?/\\wedge /g;
3333 s/≈?/\\approx /g;
3334 s/⊆?/\\subseteq /g;
3335 s/⊂?/\\subset /g;
3336 s/⊇?/\\supseteq /g;
3337 s/⊃?/\\supset /g;
3338 s/∈?/\\in /g;
3339 s/←?/\\leftarrow /g;
3340 s/→?([_^])/\\mathop\\rightarrow\\limits$1 /g;
3341 s/→?/\\rightarrow /g;
3342 s/↑?/\\uparrow /g;
3343 s/↓?/\\downarrow /g;
3344 s/↔?/\\leftrightarrow /g;
3345 s/⇐?/\\Leftarrow /g;
3346 s/⇒?/\\Rightarrow /g;
3347 s/⇑?/\\Uparrow /g;
3348 s/⇓?/\\Downarrow /g;
3349 s/∃?/\\exists /g;
3350 s/&inf;?/\\infty /g;
3351 s/&?int;?/\\int\\limits /g;
3352 s/&?sum;?/\\sum\\limits /g;
3353 s/&?prod;?/\\prod\\limits /g;
3354 s/&pd;?/\\partial /g;
3355 s/{?/\\{/g;
3356 s/}?/\\}/g;
3357 s/<t>/\\hbox{/gi;
3358 s/<b>/\\bf /gi;
3359 s/<bt>/{\\bf\\hbox{/gi;
3360 s/<sub$R/_{/gi;
3361 s/<sup$R/\^{/gi;
3362 s/<box\s*size=["']?(\w+)["']?>/{\\def\\lft{$s{$1}}\\def\\rgt{$s{$1}}/gi;
3363 s/<box$R/{/gi;
3364 s/<text\s*>/\\hbox{/gi;
3365 s/([\(\[\|])\s*<left>/\\lft$1/gi;
3366 s/<right>/\\rgt /gi;
3367 s/<(atop|choose|over)>/\\\L$1 /gi;
3368 s/<of>/}\\of{/gi;
3369 s/<bar>/\\overline{/gi;
3370 s/<vec>/\\overrightarrow{/gi;
3371 s/<hat>/\\widehat{/gi;
3372 s/<tilde>/\\widetilde{/gi;
3373 s/<(sqrt|root|vec|dot|ddot|hat|tilde)>/\\\L$1\{/gi;
3374 while(/<above\s+sym\s*=\s*["']?equals["']?\s*>/i) {
3375 $beg=$`."\\overline{\\overline{";
3376 $rest=$';
3377 $rest=~s/<\/above>/}}/i;
3378 $_=$beg.$rest;
3379 }
3380 s/<above\s*>/\\overline{/gi;
3381 s/<above\s+sym\s*=\s*["']?(\w+)["']?\s*>/\\$a{$1}\{/gi;
3382 s/<below\s*>/\\underline{/gi;
3383 s/<below\s+sym\s*=\s*["']?(\w+)["']?\s*>/\\$b{$1}\{/gi;
3384 s/<\/(math|row|item|b)>//gi;
3385 s/<\/(box|t|sup|sub|sqrt|root|vec|bar|dot|ddot|hat|tilde|above|below|text|array)>/}/gi;
3386 s/<\/bt>/}}/gi;
3387 s/<?/< /gi;
3388 s/>?/>/gi;
3389 s/&(\w+);?/\\$1 /gi;
3390 s/<array$R/\\matrix{/gi;
3391 s/<row>\s*<item$R//i;
3392 s/<row>\s*<item$R/\\cr /gi;
3393 s/<item>/&/gi;
3394 s/<[^ ]$R//gi;
3395 s/\n*$//;
3396 $tex="\\batchmode\\magnification=$mag\\hsize=40cm\\nopagenumbers\n"
3397 ."\\def\\lft{\\left}\\def\\rgt{\\right}\n\\setbox0=\\hbox{\$$st$di".$_."\$}\n"
3398 ."\\immediate\\write0{$prog: \\the\\ht0: \\the\\dp0}\\box0\n\\end\n";
3399 }
3400 sub Getopts {
3401 local($optlist)=@_;
3402 local(@args,$_,$opt,$opts,$rest,$olist,$plist,$found,@popts);
3403 local($errs)=0;
3404 local($[)=0;
3405 @args=split( /\|/, $optlist );
3406 for $opt (@args) {
3407 if(substr($opt,-1,1) ne ':') {$olist.=$opt}
3408 else {$plist.=$opt}
3409 }
3410 @popts=split(/:/,$plist);
3411 while(@ARGV && ($_=$ARGV[0]) =~ /^-(.*)/) {
3412 $opt=$1;
3413 if($opt=~/^-/ && $optalias{"\L$'"}) {$opt=$optalias{"\L$'"}};
3414 if($opt =~ /^[$olist]+$/) {
3415 while ($char=chop $opt) {eval "\$opt_$char=1"}
3416 shift(@ARGV);
3417 }
3418 else {
3419 $found=0;
3420 for $opts (@popts) {
3421 $rest=substr($opt,length($opts));
3422 if(index($opt,$opts)==0) {
3423 $found=1;
3424 shift(@ARGV);
3425 if(length($rest)==0) {
3426 ++$errs unless @ARGV;
3427 $rest=shift(@ARGV);
3428 }
3429 eval "\$opt_$opts=\$rest";
3430 }
3431 }
3432 if(!$found) {
3433 &dbg("Unknown option: $opt\n");
3434 ++$errs;
3435 shift(@ARGV);
3436 }
3437 }
3438 }
3439 $errs==0;
3440 }
3441 sub openps {
3442 open(STDOUT,">$opt_o") || die "*** Error opening $opt_o for output\n";
3443 }
3444 sub getalt {
3445 if($imgcmd eq "img") {
3446 $alt="";
3447 $match=0;
3448 if($img=~/alt\s*=\s*"([^"]*)"/i) {$alt=$1; $match=1};
3449 if(!$match && $img=~/alt\s*=\s*([\w\.-]+)/i) {$alt=$1; $match=1};
3450 if(!$match) {$alt=")WB IA WB("};
3451 $text="$alt )WB(";
3452 return;
3453 }
3454 if($imgcmd eq "hr") {
3455 $text=$img=~/align\s*=\s*["']?(left|center|right)/i?")$algn{lc $1} ":")2 ";
3456 $text.=$img=~/size\s*=\s*["']?$V/i?$1:.6;
3457 $wd=1;
3458 if($img=~/width\s*=\s*["']?$V(%?)/i) {$wd=$2?$1/100:-$1};
3459 $text.=" $wd HR(";
3460 return;
3461 }
3462 if($imgcmd eq "fig") {
3463 $text=")BN(";
3464 }
3465 }
3466 sub xbmtops {
3467 $fc=1;
3468 $dp=1;
3469 ($xs,$ys)=$pic=~/^#define.* (\d+)[\w\W]*^#define.* (\d+)/;
3470 $nd=2*int(($xs+7)/8)*$ys;
3471 ($pic)=$pic=~/[^#].* char.*[\w\W]*{([\w\W]*)}/;
3472 $pic=~s/[ ,\n\r]*0x[ ,]*//g;
3473 $pic=~y/01246789bdef/f7bd91e62480/;
3474 $bm=unpack("H*", pack("h*",$pic));
3475 }
3476 sub pmtops {
3477 pmtoraw($pm) if($pm=~/^P([1-3])/);
3478 $pm=~/^P([4-6])/;
3479 $maptype=$1;
3480 return if(!$maptype);
3481 $pm=$';
3482 $bm="";
3483 $nint=3;
3484 $dp=8;
3485 if($maptype==4) {
3486 $nint=2;
3487 $dp=1;
3488 }
3489 undef @num;
3490 $found=0;
3491 while($pm && $found<$nint) {
3492 if($pm=~/^\s*(\d+)/) {$num[$found]=$1};
3493 if($num[$found]) {
3494 $found++;
3495 $pm=$';
3496 } elsif($pm=~/^\s*#.*\n/) {
3497 $pm=$';
3498 } else {
3499 return;
3500 }
3501 }
3502 ($b)=$pm=~/\s([\w\W]*)/;
3503 ($xs,$ys,$bits)=@num;
3504 return if($bits>255);
3505 $fc=1;
3506 if($maptype==6) {
3507 $fc=3;
3508 $nd=6*$xs*$ys;
3509 $bm=unpack("H*",$b);
3510 } else {
3511 $bm=unpack("H*",$b);
3512 if($maptype==4) {
3513 $nd=2*int(($xs+7)/8)*$ys;
3514 $bm=~y/0123456789abcdef/fedcba9876543210/;
3515 } else {
3516 $nd=2*$xs*$ys;
3517 }
3518 }
3519 }
3520 sub trans {
3521 $next = 13;
3522 $temp = ord substr($pic,10,1);
3523 if($temp & 0x80) {$next += 3*2**(($temp & 0x07) + 1)} else {return};
3524 $byte = ord substr($pic,$next,1);
3525 while($byte != 0x3b && $next <= length $pic) {
3526 if($byte == 0x21) {
3527 if(ord substr($pic,$next+1,1) == 0xf9) {
3528 if(ord substr($pic,$next+3,1) & 0x01) {
3529 &dbg("Transparent\n") if($opt_d);
3530 $src{$URL}=$pic;
3531 $idx = 3*(ord substr($pic,$next+6,1))+13;
3532 substr($pic,$idx,3) = pack("H*",$red.$grn.$blu) if($idx<length $pic);
3533 }
3534 return;
3535 $next += 2;
3536 &skip;
3537 } else {
3538 $next += 2;
3539 &skip;
3540 }
3541 } elsif($byte == 0x2c) {
3542 $next += 10;
3543 $temp = ord substr($pic,$next-1,1);
3544 if($temp & 0x80) {$next += 3*2**(($temp & 0x07) + 1)};
3545 $next++;
3546 &skip;
3547 } else {return}
3548 }
3549 }
3550 sub skip {
3551 $byte = ord substr($pic,$next,1);
3552 while($byte != 0) {
3553 $next += $byte + 1;
3554 $byte = ord substr($pic,$next,1);
3555 }
3556 $next++;
3557 $byte = ord substr($pic,$next,1);
3558 }
3559 sub run {
3560 &dbg("@_\n") if($opt_d);
3561 $pm=`@_`;
3562 }
3563 sub geturl {
3564 local($url)=@_;
3565 &dbg("Retrieving $url");
3566 if($package{'libwww-perl'} || $package{'jfriedl'}) {
3567 warn "\n";
3568 &gu();
3569 if($code==401) {
3570 &prompt("\nDocument requires username and password\n\nUsername: ",$user);
3571 &prompt("Password: ",$pass);
3572 &gu($user,$pass);
3573 }
3574 $_[1]=$cont;
3575 } elsif(defined $geturl) {
3576 &dbg("...");
3577 $_[1]=`$geturl '$url'`;
3578 if($?) {
3579 &dbg("\n*** Error opening $url\n");
3580 return 0;
3581 }
3582 &dbg("done\n");
3583 if($_[1]=~/\r?\n\r?\n/) {
3584 $_[1]=$';
3585 $dhead=$`;
3586 ($code)=$dhead=~/HTTP\/\S+ +(\d+)/i;
3587 ($contyp)=$dhead=~/Content-type:\s+(.*)/i;
3588 } else {
3589 $code=500;
3590 }
3591 }
3592 $_[0]=$url;
3593 $code<300;
3594 }
3595 sub gu {
3596 if($package{'libwww-perl'}) {
3597 require LWP::UserAgent;
3598 $ua=new LWP::UserAgent;
3599 $ua->env_proxy();
3600 if ($opt_k) {
3601 require HTTP::Cookies;
3602 $cookie_jar = HTTP::Cookies::Netscape->new(File => $opt_k, AutoSave => 1);
3603 $ua->cookie_jar($cookie_jar);
3604 }
3605 $req = HTTP::Request->new(GET => $url);
3606 $req->authorization_basic(@_) if(@_);
3607 $ua->agent($spoof) if($spoof);
3608 my $res = $ua->request($req);
3609 $code=$res->code;
3610 $contyp=$res->header('content-type');
3611 $cont=$res->content;
3612 } else {
3613 require "www.pl";
3614 @opts=@_?("authorization=$_[0]:$_[1]"):();
3615 push(@opts,"quiet") if(!$opt_d);
3616 $www::useragent=$spoof if($spoof);
3617 ($status,$memo,%info)=&www::open_http_url(*FILE,$url,@opts);
3618 $code=$info{'CODE'};
3619 ($contyp)=$info{'HEADER'}=~/Content-type:\s+(.*)/i;
3620 $cont=<FILE>;
3621 }
3622 }
3623 sub pictops {
3624 if($opt_g) {
3625 $fc=1;
3626 $pg1="pgm";
3627 $pg2="|ppmtopgm";
3628 } else {
3629 $fc=3;
3630 $pg1="ppm";
3631 $pg2="";
3632 }
3633 ($type)=$URL=~/([^\?]+)\??/;
3634 ($type)=$type=~/\.(\w+)$/;
3635 $bm="";
3636 $ps="";
3637 $pm="";
3638 if($opt_U && $src{$URL} && !$cmd{$URL.$red.$grn.$blu}) {
3639 $pic=$src{$URL};
3640 } elsif($URL=~m|://|) {
3641 &geturl($URL,$pic) || return;
3642 } else {
3643 $flag=0;
3644 if($opt_O) {
3645 $orig=$URL;
3646 unless($orig=~s/\.\w*$/.ps/) {$orig.=".ps"};
3647 if(open(ORIG,"$orig")) {
3648 $pic=<ORIG>;
3649 close ORIG;
3650 if($pic=~/^%!/ && $pic=~/%%BoundingBox:/) {
3651 $flag=1;
3652 &dbg("Using $orig as original for $URL\n") if($opt_d);
3653 }
3654 }
3655 }
3656 if(!$flag) {
3657 if(open(PIC,"$URL")) {
3658 binmode PIC;
3659 $pic=<PIC>;
3660 close PIC;
3661 } else {
3662 &dbg("*** Error opening $URL\n");
3663 return;
3664 }
3665 }
3666 }
3667 $pic=~s/^[\n\r]*//;
3668 &trans if($pic=~/^GIF/);
3669 if($pic=~/^P[1-6]/) {
3670 $pm=$pic;
3671 } else {
3672 open(SCRATCH,">$scr");
3673 binmode(SCRATCH);
3674 print SCRATCH "$pic";
3675 close SCRATCH;
3676 if($pic=~/^%!/ && $pic=~/%%BoundingBox: +$V +$V +$V +$V/) {
3677 $xs=$3-$1;
3678 $ys=$4-$2;
3679 $ps="save\n0 0 M\nIS IS scale\n/showpage {}D\n".(0-$1)." ".(0-$2)." translate\n";
3680 for $i (split(/\n/,$pic)) {
3681 $ps.=$i."\n" if($i && $i!~/^%/);
3682 }
3683 $ps.="restore";
3684 } elsif($type=~/.xbm$/i || $pic=~/^#define/) {
3685 &xbmtops;
3686 } elsif($package{'ImageMagick'}) {
3687 if($package{'PerlMagick'}) {
3688 $imobj=Image::Magick->new;
3689 $mess=$imobj->Read($scr);
3690 if($mess) {
3691 &dbg("$mess\n");
3692 } else {
3693 $mess=$imobj->Write("$scr\.$pg1");
3694 &dbg("$mess\n") if($mess);
3695 }
3696 undef $imobj;
3697 } else {
3698 # &run("convert $scr $pg1:-");
3699 &run("convert $scr $scr\.$pg1");
3700 }
3701 open(PNM,"$scr\.$pg1");
3702 binmode PNM;
3703 $pm=<PNM>;
3704 close PNM;
3705 if(!$pm && $pic=~/^\377\330/ && $package{'djpeg'}) {
3706 &run("djpeg $scr$pg2");
3707 }
3708 } elsif($pic=~/^\377\330/ && $package{'djpeg'}) {
3709 &run("djpeg $scr$pg2");
3710 } elsif($package{'pbmplus'} || $package{'netpbm'}) {
3711 if($pic=~/^GIF/) {
3712 &run("$giftopm $scr");
3713 } else {
3714 &run("anytopnm $scr");
3715 }
3716 if($opt_g && $pm=~/^P6/) {
3717 open(SCRATCH,">$scr");
3718 binmode(SCRATCH);
3719 print SCRATCH $pm;
3720 close SCRATCH;
3721 &run("ppmtopgm $scr");
3722 }
3723 }
3724 }
3725 &pmtops if(!$bm);
3726 return if(!$bm);
3727 $bm=substr($bm,0,$nd);
3728 $pad=$nd-length($bm);
3729 if($pad) {$bm.="f" x $pad};
3730 $bm=~s/(.{60})/$1\n/g;
3731 }
3732 sub math2sym {
3733 local($_)=@_;
3734 s/<math$R//gi;
3735 for $char (keys %symb) {s/&($char)(;|$|(?=\W))/\\$symb{$char}/g};
3736 $stat=!/([&<][a-zA-Z]|[_^{])/;
3737 s/[a-zA-Z\s]*[a-zA-Z][a-zA-Z\s]*/)ES()I($&)ES()SY(/g;
3738 s/(\\200|\\201|\\202)/)RO($&)ES(/g;
3739 $sym=")SY($_)ES(";
3740 $stat;
3741 }
3742 sub varsub {
3743 for (@_) {
3744 s/\\\\/\000/g;
3745 s/\([^)]+\)/()$&join /g;
3746 s/(^|[^\\])\$(T|N|U|H|A)/$1)join $vars{$2} join(/g;
3747 s/(^|[^\\])\$D\{"(.*?)"\}/"$1".POSIX::strftime($+,@now)/eg if($posix);
3748 s/(^|[^\\])\$D/"$1".POSIX::strftime($datefmt,@now)/eg if($posix);
3749 # while(/(?=[^\\])\${([^}]+)}/) {
3750 while(/(?=[^\\])\$\[([^]]+)\]/) {
3751 if(!defined $metarc{lc $1}) {
3752 $metarc{lc $1}=$mn++;
3753 }
3754 $_="$`)join ME $metarc{lc $1} get join($'";
3755 }
3756 s/\\\$/\$/g;
3757 s/\000/\\\\/g;
3758 s/\(\)join//g;
3759 s/\(\) ?(\([^)]*\)|\w+) ?join/ $1/g;
3760 }
3761 }
3762 sub follow {
3763 return 0 if(!$opt_W);
3764 $H=$lnk=~/\.html?(#|$)/i || $lnk=~m|.+//.+/[^/\.]*$|;
3765 $T=$rev && ($revtoc && $ndoc==1 || $ndoc>1 && $H);
3766 $L=$b1=~m|://| && $lnk=~m"^$b1(/|$)" || $b1!~m|://| && $lnk!~m|://|;
3767 $B=$B2 && $lnk=~/^$B2/ || !$B2 && $lnk!~m"(^\.\.|://)";
3768 return $rlnk && ($H || $T) if($rel);
3769 return $L && ($H || $T) if($local);
3770 return $B && ($H || $T) if($below);
3771 return $H || $T if($rev);
3772 $H;
3773 }
3774 sub DSC {
3775 &dbg("Generating DSC PostScript\n") if($opt_d);
3776 %op=("moveto",2, "rmoveto",2, "lineto",2, "rlineto",2, "translate",2,
3777 "scale",2, "show",1, "awidthshow",6, "stroke",0, "save",0, "restore",0,
3778 "gsave",0, "grestore",0, "showpage",0, "newpath",0, "setlinewidth",1,
3779 "setlinejoin",1, "setgray",1, "closepath",0, "fill",0, "arc",5,
3780 "setrgbcolor",3, "rotate",1, "image",5, "colorimage",7);
3781 %sho=("moveto","M", "rmoveto","RM", "lineto","L", "rlineto","RL", "show","S",
3782 "showpage","N", "awidthshow","A");
3783 $i=0;
3784 $po="/OU true D\n";
3785 for (keys %op) {
3786 $cmd=$sho{$_}?$sho{$_}:$_;
3787 push(@val,$cmd);
3788 $in{$_}=$i++;
3789 $j=$op{$_}+1;
3790 $extra="";
3791 if(/showpage/) {$extra="Bb{Xl Yl Xh Yh}if Pn "};
3792 if(/image/) {$extra="K ";$j++};
3793 $t=$op{$_}?"$op{$_} copy $extra$in{$_} $j array astore":"[$extra$in{$_}]";
3794 $po.="/$_ {OU {$t ==} if $_}d\n";
3795 }
3796 $po.="/pdfmark {$i] ==} D\n";
3797 $in{"pdfmark"}=$i++;
3798 push(@val,"pdfmark");
3799 $po.="/NF {OU{2 copy E $i 3 array astore ==}if ONF}d\n"
3800 ."/EX {[IS EC] ==} D\n/Cd {} D\n/DU {TU PM 1 eq and TP and{Pn ==}if}d\n"
3801 ."/BB {US Bb{dup Yl lt{dup /Yl E D}if dup Yh gt{/Yh E D}{pop}ie\n"
3802 ." dup Xl lt{dup /Xl E D}if dup Xh gt{/Xh E D}{pop}ie}\n"
3803 ." {/Yl E D /Yh Yl D /Xl E D /Xh Xl D /Bb t D}ie}D\n";
3804 $in{"Nf"}=$i++;
3805 s|/(NF.*)|/O$1|;
3806 s|/BB .*|$po|;
3807 push(@val,"Nf");
3808 if($psin) {
3809 ($ti)=/%%Title: (.*)/;
3810 if(m|/BM (\d+)|) {
3811 $nbit=$1;
3812 for $vec ("IT","WS") {
3813 /\/$vec \[(.*)\]/;
3814 @$vec=split(' ',$1);
3815 }
3816 /\nSB/;
3817 for (0..$nbit-1) {
3818 $'=~/\n\n/;
3819 push(@BM,$`);
3820 }
3821 }
3822 ($epsf)=/(\n\/P\d+_?\d* [\w\W]*)%Endpv/;
3823 while($epsf=~/\n\/(P\d+_?\d*) \{/g) {
3824 $pid=$1;
3825 $rest=$';
3826 $temp=$'=~/\/P\d+_?\d* \{/?$`:$rest;
3827 ($eps{$pid})=$temp=~/([\w\W]*)} D/;
3828 }
3829 if(/\/DH {/) {
3830 $'=~/%EndDH/;
3831 $ph="/DH {$`";
3832 }
3833 }
3834 $j=-1;
3835 for $i (0..$#IT) {
3836 $j++ if($IT[$i] == 0);
3837 push(@ix,$j);
3838 }
3839 $dfn="/F $opt_s D\n$ph";
3840 for (keys %sho) {
3841 $dfn.="/$sho{$_} {$_} d\n";
3842 }
3843
3844 open(SCR,">$scr.ps");
3845 print SCR "$_ quit\n";
3846 close SCR;
3847 $cd{')]'}="Cd ";
3848 $io="($in{'image'}|$in{'colorimage'})";
3849 $_="";
3850 $temp="";
3851 $pn="";
3852 $start=1;
3853 $EPS="%%EndPageSetup";
3854 $pp=0;
3855 $n=0;
3856
3857 for $line (split(/\r?\n/,`$gs -q -dNODISPLAY $scr.ps -c quit`)) {
3858 if(!$pp) {
3859 $mv="";
3860 $cx="";
3861 $cy="";
3862 }
3863 if($start && $line!~/ $in{"pdfmark"}\]$/) {
3864 $pdf=$temp;
3865 $temp="";
3866 $start=0;
3867 }
3868 $pp=$line=~/^\[(\S+) (\S+) ($in{'moveto'}|$in{'rmoveto'}|$in{'Nf'})\]$/;
3869 S:{
3870 if($pp && $3==$in{"Nf"}) {
3871 $fn="$1 $2 $val[$3]\n";
3872 last S;
3873 }
3874 if($pp && $3==$in{"moveto"}) {
3875 $cx=$1;
3876 $cy=$2;
3877 $mv=sprintf("%.1f %.1f %s\n",$1,$2,$val[$3]);
3878 last S;
3879 }
3880 if($pp && $3==$in{"rmoveto"}) {
3881 if($mv) {
3882 $cx+=$1;
3883 $cy+=$2;
3884 $mv=sprintf("%.1f %.1f %s\n",$cx,$cy,$val[$in{"moveto"}]);
3885 } else {
3886 $temp.=sprintf("%.1f %.1f %s\n",$1,$2,$val[$3]) if($1||$2);
3887 }
3888 last S;
3889 }
3890 if($line=~s/^\[(.*)\((\S*)\) ($in{"showpage"})\]$/pgsave restore $val[$3]/) {
3891 $pbb="";
3892 if($1) {
3893 ($llx,$lly,$urx,$ury)=split(/ /,$1);
3894 $llx=int($llx);
3895 $lly=int($lly);
3896 $urx=int($urx+1);
3897 $ury=int($ury+1);
3898 $pbb="%%PageBoundingBox: $llx $lly $urx $ury\n";
3899 if(!defined($Llx) || $llx<$Llx) {$Llx=$llx};
3900 if(!defined($Lly) || $lly<$Lly) {$Lly=$lly};
3901 if(!defined($Urx) || $urx>$Urx) {$Urx=$urx};
3902 if(!defined($Ury) || $ury>$Ury) {$Ury=$ury};
3903 }
3904 $pn.="," if($pn && $2);
3905 $n++;
3906 @df=();
3907 for(0..$#docfonts) {
3908 push(@df,$docfonts[$_]) if($uf{$_}==$n);
3909 }
3910 push(@df,"Symbol") if($uf{"-1"}==$n);
3911 $fu="";
3912 $tmp=@df?"%%PageResources: font":"";
3913 &splitline(@df);
3914 $_.="%%Page: $pn$2 $n\n$fu$pbb%%BeginPageSetup\n/pgsave save D\n$temp$line\n";
3915 $EPS="%%EndPageSetup";
3916 $temp="";
3917 $line="";
3918 $fn="";
3919 $mv="";
3920 $pn="";
3921 last S;
3922 }
3923 if($line=~/^\[([^(]*)(\(.*\)) ($in{"show"}|$in{"awidthshow"})\]$/) {
3924 if(length $2>2) {
3925 $line="$fn$1$2 $val[$3]";
3926 if($fn=~/(\S+) Nf/ && $uf{$1}!=$n+1) {
3927 $uf{$1}=$n+1;
3928 $fnt=$1<0?"Symbol":$docfonts[$1];
3929 $line="%%IncludeResource: font $fnt\n$line";
3930 }
3931 $fn="";
3932 $pp=0;
3933 } else {
3934 $pp=1;
3935 }
3936 last S;
3937 }
3938 if($line=~/^\[(\S+) (\S+) ($in{"scale"})\]$/) {
3939 $line=$1!=1||$2!=1?"$1 $2 $val[$3]\n$EPS":"$EPS";
3940 $EPS="";
3941 last S;
3942 }
3943 if($line=~/^\[(.*) (\d+) $io\]$/) {
3944 $li=$BM[$2]=~y/\n/\n/+2;
3945 $line="\/picstr $WS[$ix[$2]] string D\n$1\n"
3946 ."%%BeginData: $li Hex Lines\n$val[$3]\n$BM[$2]\n%%EndData";
3947 last S;
3948 }
3949 if($line=~/^\((.*)\)$/) {
3950 $pn=$1;
3951 $line="";
3952 last S;
3953 }
3954 last S if($line=~s/^\[([^\/].* )?(\d+)\]$/$1$val[$2]/);
3955 last S if($line=~s/(\)\])? (\/\w+) $in{"pdfmark"}\]$/$1 $cd{$1}$2 pdfmark/);
3956 last S if($line=~s/^\[(\S+) \((P\d+.*)\)\]$/\/IS $1 D\n$eps{$2}/);
3957 &dbg("$line\n");
3958 }
3959 if(!$pp && $mv.$line) {
3960 $mv=~s/\.0//g;
3961 $temp.="$mv$line\n";
3962 }
3963 }
3964 @nf=();
3965 @sf=();
3966 $fontdef="";
3967 for(0..$#docfonts) {
3968 $ff=$ff{$docfonts[$_]};
3969 if($ff && $uf{$_}>0) {
3970 push(@sf,$docfonts[$_]);
3971 $fontdef.="%%BeginResource: font $docfonts[$_]\n$cont{$ff}\n%%EndResource\n";
3972 $cont{$ff}="";
3973 }
3974 push(@nf,$docfonts[$_]) if(!$ff && $uf{$_}>0);
3975 }
3976 push(@nf,"Symbol") if($uf{"-1"}>0);
3977 $ti="@ARGV" unless($psin);
3978 $or=$opt_L?"Landscape":"Portrait";
3979 $setup="%%BeginSetup\n";
3980 $setup.="$dupl\n" if($dupl);
3981 $setup.="$fontdef" if($fontdef);
3982 $fu="";
3983 $tmp=@nf?"%%DocumentNeededResources: font":"";
3984 &splitline(@nf);
3985 $tmp=@sf?"%%DocumentSuppliedResources: font":"";
3986 &splitline(@sf);
3987 s/\\(200|201|202)/\\$ssy{$1}/g;
3988 $dd="Clean7Bit";
3989 $dd="Clean8Bit" if(($fontdef.$_)=~/[\200-\377]/);
3990 $dd="Binary" if(($fontdef.$_)=~/[\000-\010\013-\014\016-\036]/);
3991 $time=localtime;
3992 print <<EOT;
3993 %!PS-Adobe-3.0
3994 %%Title: $title
3995 %%Creator: $version
3996 %%CreationDate: $time
3997 $fu%%DocumentData: $dd
3998 %%Orientation: $or
3999 %%BoundingBox: $Llx $Lly $Urx $Ury
4000 %%Pages: $n
4001 %%EndComments
4002 %%BeginProlog
4003 /d {bind def} bind def
4004 /D {def} d
4005 /ie {ifelse} d
4006 /E {exch} d
4007 /t true D
4008 /f false D
4009 $fl
4010 $cd
4011 $defs
4012 $mysymb/Nf {dup 0 ge{FL E get}{-1 eq{/Symbol}{/MySymbol}ie}ie findfont
4013 E scalefont setfont} D
4014 /IP {currentfile picstr readhexstring pop} D
4015 /WF $wf D
4016 $dfn%%EndProlog
4017 $setup$reenc$pdf%%EndSetup
4018 $_%%EOF
4019 EOT
4020 }
4021 sub splitline {
4022 for (@_) {
4023 if(length($tmp.$_)>78) {
4024 $fu.="$tmp\n";
4025 $tmp="%%+ font";
4026 }
4027 $tmp.=" $_";
4028 }
4029 $fu.="$tmp\n" if($tmp);
4030 }
4031 sub ref {
4032 @pnum=();
4033 /.*\s*$/;
4034 open(SCR,">$scr.ps");
4035 print SCR "$`HN{==}forall $& quit\n";
4036 close SCR;
4037 $pnum=`$gs -q -dNODISPLAY $scr.ps -c quit`;
4038 while($pnum=~/\([^)]*\)/g) {push(@pnum,$&)};
4039 $pnum="@pnum";
4040 &cut($pnum);
4041 s|/HN [^D]*D|/HN [$pnum] D|;
4042 }
4043 sub cut {
4044 $_[0]=~s/(.{70}[^ \n]*) ([^ ])/$1\n$2/g;
4045 }
4046 sub fin {
4047 if($opt_D) {
4048 &DSC;
4049 } else {
4050 print;
4051 }
4052 if($opt_d) {
4053 print DBG "\n";
4054 close DBG;
4055 }
4056 unlink "$scr","$scr.ps","$scr.ppm","$scr.tex","$scr.dvi","$scr.log" if($scr);
4057 exit;
4058 }
4059 sub col2rgb {
4060 $rgb=$colour{"\L$_[0]"}?($colour{"\L$_[0]"}):$_[0];
4061 @cvec=$rgb=~/($X$X)($X$X)($X$X)/?($1,$2,$3):();
4062 @cvec?"[16#$1 16#$2 16#$3]":"";
4063 }
4064 sub inihyph {
4065 if($hyphenation_file{$lang}) {
4066 $hyfile=$hyphenation_file{$lang};
4067 } else {
4068 &dbg("No hyphenation file for language '$lang'\n");
4069 $lng=$lang;
4070 while($lng=~s/-?[^-]+$// && !$hyphenation_file{$lng}) {};
4071 $hyfile=$hyphenation_file{$lng};
4072 &dbg(" ..using $hyfile\n");
4073 }
4074 if($init{$hyfile}) {
4075 $rep{$lang}=$refl{$hyfile};
4076 return;
4077 }
4078 if(open(HYPH,$hyfile)) {
4079 &dbg("Reading hyphenation patterns from $hyfile\n") if($opt_d);
4080 <HYPH>=~/\\patterns{.*/;
4081 close HYPH;
4082 $def=$`;
4083 ($patterns=$')=~s/\^\^($X$X)/chr hex $1/eg;
4084 $upp{$lang}='';
4085 $low{$lang}='';
4086 while ($def=~/\\lccode(`\\?\^\^|")($X$X)=(`\\?\^\^|")($X$X)/g) {
4087 if($2 ne $4) {
4088 $uc=$2;
4089 $lc=$4;
4090 if($`=~/\n$/ || $`!~/%.*$/) {
4091 $upp{$lang}.=chr hex $uc;
4092 $low{$lang}.=chr hex $lc;
4093 }
4094 }
4095 }
4096 while ($def=~/\\let\\(\w+)=(\^\^|")($X$X)/g) {
4097 $key=$1;
4098 $value=chr hex $3;
4099 $tex{$key}=$value if($`=~/\n$/ || $`!~/%.*$/);
4100 }
4101 for $key (keys %tex) {
4102 $patterns=~s/\\$key */$tex{$key}/g;
4103 }
4104 if($lang=~/^de/) {
4105 %de=('"a',228, '"o',246, '"u',252, '\3', 223);
4106 $patterns=~s/\\c\{[^}]*\}//g;
4107 $patterns=~s/\\n\{([^}]*)\}/$1/g;
4108 $patterns=~s/("a|"o|"u|\\3)/chr $de{$1}/eg;
4109 $upp{"de"}=~s/\337//;
4110 $low{"de"}=~s/\377//;
4111 }
4112 if($lang=~/^is/ && !$upp{"is"}) {
4113 %is=("'a","\341", "'e","\351", "'i","\355", "'o","\363", "'u","\372",
4114 "'y","\375", '"x',"\346", '"o',"\366", "'d","\360", "`t","\376");
4115 $isch=join("|",keys %is);
4116 $patterns=~s/($isch)/$is{$1}/g;
4117 $upp{"is"}="\301\311\315\323\332\335\306\326\336\320";
4118 $low{"is"}="\341\351\355\363\372\375\346\366\376\360";
4119 }
4120 if($lang=~/^fi/ && !$upp{"fi"}) {
4121 $upp{"fi"}="\304\326";
4122 $low{"fi"}="\344\366";
4123 }
4124 if($lang=~/^fr/ && !$upp{"fr"}) {
4125 $upp{"fr"}="\300\302\307\311\310\312\313\316\317\324\326\333\226";
4126 $low{"fr"}="\340\342\347\351\350\352\353\356\357\364\366\373\225";
4127 }
4128 if($lang=~/^es/ && !$upp{"es"}) {
4129 $upp{"es"}="\301\311\315\323\321\332\334";
4130 $low{"es"}="\341\351\355\363\361\372\374";
4131 }
4132 $patterns=~s/\{([\w\W]*?)\}/[$1]/g;
4133 $patterns=~/}/;
4134 $end=$`;
4135 if($def.$'=~/\\hyphenation\[.*/) {
4136 $'=~/]/;
4137 $hyext=$`;
4138 }
4139 ($patterns=$end)=~s/%.*//g;
4140 for $key (split('\s+',$patterns)) {
4141 $value=$key;
4142 $key=~s/\d//g;
4143 $value=~s/^([$ltrs.])/0$1/;
4144 $value=~s/[$ltrs](\d)/$1/g;
4145 $value=~s/[$ltrs.]/0/g;
4146 $patt{"$key,$lang"}=$value if($value=~/^\d+$/);
4147 }
4148 } else {
4149 &dbg("Cannot open hyphenation file: $hyfile\n");
4150 }
4151 $hext=$hyphenation_extfile{$lang};
4152 for(split('\s*:\s*',$hext)) {
4153 if(open(HEXT,$_)) {
4154 &dbg("Reading hyphenation extensions from $_\n") if($opt_d);
4155 $hyext.=<HEXT>;
4156 close HEXT;
4157 } else {
4158 &dbg("Cannot open hyphenation extension file: $_\n");
4159 }
4160 }
4161 if($hyext) {
4162 for $key (keys %tex) {
4163 $hyext=~s/$key */$tex{$key}/g;
4164 }
4165 for $key (split('\s+',$hyext)) {
4166 $key=~s/\s+//g;
4167 $value="00$key\0";
4168 $key=~s/-//g;
4169 $value=~s/[$ltrs]/0/g;
4170 $value=~s/0-/1/g;
4171 $hext{"$key,$lang"}=$value;
4172 }
4173 }
4174 $refl{$hyfile}=$lang;
4175 $rep{$lang}=$lang;
4176 $init{$hyfile}=1;
4177 }
4178 sub hyph {
4179 $word="\L$_[0]";
4180 eval "\$word=~y/$upp{$rep{$lang}}/$low{$rep{$lang}}/" if($upp{$rep{$lang}});
4181 $len=length($word);
4182 $h=$hext{"$word,$rep{$lang}"};
4183 if($h) {
4184 @br=split(//,$h);
4185 } else {
4186 @br=(0) x ($len+3);
4187 for $i (0..$len) {
4188 for $j (0..$len-$i) {
4189 $str=substr(".$word.",$j,$i+2);
4190 $pstr=$patt{"$str,$rep{$lang}"};
4191 if($pstr) {
4192 @patt=split(//,$pstr);
4193 for $k (0..$#patt) {
4194 $br[$k+$j]=$patt[$k] if($br[$k+$j]<$patt[$k]);
4195 }
4196 }
4197 }
4198 }
4199 }
4200 $hword="";
4201 for $i (0..$len-1) {
4202 $hword.=substr($_[0],$i,1);
4203 if(($h || $i>$hyphenation{'start'}-2 && $i<$len-$hyphenation{'end'})
4204 && $br[$i+2]%2==1) {$hword.=")HY("};
4205 }
4206 $hword.=")YH(" if(length $word < length $hword);
4207 $hword;
4208 }
4209 sub setel {
4210 $el=$_[0];
4211 eval "\%arr=\%$el";
4212 &fs($el);
4213 push(@font,$fontid{"\L$font"});
4214 push(@styl,$styl);
4215 push(@size,$arr{'font-size'});
4216 push(@alig,$algn{$arr{'text-align'}}-1);
4217 push(@topm,$arr{'margin-top'});
4218 push(@botm,$arr{'margin-bottom'});
4219 push(@lftm,$arr{'margin-left'});
4220 push(@rgtm,$arr{'margin-right'});
4221 push(@colr,$col eq "[16#00 16#00 16#00]"?0:$col);
4222 $temp=$arr{'margin-top'}*$arr{'font-size'};
4223 $mi=$temp if($temp>$mi);
4224 $temp=$arr{'margin-bottom'}*$arr{'font-size'};
4225 $mi=$temp if($temp>$mi);
4226 }
4227 sub fs {
4228 $arr{'font-family'}='times' if($el ne 'p' && !$latin1 && !defined $arr{$_});
4229 for ("font-family","font-size") {
4230 $arr{$_}=$body{$_} if(!defined $arr{$_});
4231 }
4232 ($font=$arr{'font-family'})=~s/\W/-/g;
4233 if(!$font_names{"\L$font"}) {$font=$fal{$font}};
4234 if(!$font_names{"\L$font"}) {
4235 &dbg("Unknown font: $arr{'font-family'}, using $deffnt{$_[0]}\n");
4236 $font=$deffnt{$_[0]};
4237 }
4238 if(!defined $fontid{"\L$font"}) {
4239 $fontid{"\L$font"}=$nfont++;
4240 @names=split(/\s+/,$font_names{"\L$font"});
4241 for($#names+1..3) {push(@names,$names[0])};
4242 @docfonts=(@docfonts,@names);
4243 }
4244 &getval($arr{"font-size"},2);
4245 for ('left','right','top','bottom') {
4246 $arr{"margin-$_"}=0 if(!defined $arr{"margin-$_"});
4247 }
4248 for ($arr{"text-indent"},$arr{"margin-top"},$arr{"margin-bottom"},
4249 $arr{"margin-left"},$arr{"margin-right"}) {
4250 &getval($_,0);
4251 }
4252 $styl=$arr{'font-style'}=~/^(i|o)/+2*($arr{'font-weight'}=~/^b/);
4253 $col=$arr{'color'}?&col2rgb($arr{'color'}):-1;
4254 }
4255 sub img {
4256 local($_,$red,$grn,$blu)=@_;
4257 local($beg,$end);
4258 ($red,$grn,$blu)=("FF","FF","FF") if(!$opt_U);
4259 while (/<(img|fig|hr|overlay|object)\s/i) {
4260 $imgcmd="\L$1";
4261 $beg=$`;
4262 $'=~/>/;
4263 $img=" $`";
4264 $end=$';
4265 $img=~s/\n/ /g;
4266 if($imgcmd ne "object" || $img=~/data\s*=\s*['"]?([\w\/\.:~%-]+\.$IM)/i
4267 || $img=~/type\s*=\s*['"]?(image\/|application\/postscript)/i){
4268 if($opt_T) {
4269 &getalt;
4270 } else {
4271 $al=0;
4272 $off="";
4273 ($align)=$img=~/align\s*=\s*['"]?(\w*)/i;
4274 if($align=~/^middle$/i) {$al=1};
4275 if($align=~/^top$/i) {$al=2};
4276 if($imgcmd eq "overlay") {
4277 $al=4;
4278 $xoff=0;
4279 $yoff=0;
4280 if($img=~/\s*x\s*=\s*['"]?(\d+)/i) {$xoff=$1};
4281 if($img=~/\s*y\s*=\s*['"]?(\d+)/i) {$yoff=$1};
4282 $off="$xoff $yoff ";
4283 }
4284 $url="";
4285 if($img=~/\s(src|data)\s*=\s*($S)/i) {($url)=$+=~/([^ \n]*)/};
4286 &dbg("Image: $url\n") if($opt_d && $url);
4287 $URL=$url;
4288 unless($url=~m|://|) {
4289 $url=~s/^file://;
4290 if($url=~m|^/|) {$URL=$b1.$url} else {$URL=$b2.$url}
4291 }
4292 while($URL!~m|^\.\./| && $URL=~m|[^/]*/\.\./|) {$URL=$`.$'};
4293 $URL=~s|/\./|/|g;
4294 $text=$src{$URL}?$cmd{$URL.$red.$grn.$blu}:$cmd{$URL};
4295 if(!$text || $opt_U && $src{$URL} && !$cmd{$URL.$red.$grn.$blu}) {
4296 if(!$url || $failed{$url}) {
4297 &getalt;
4298 } else {
4299 &pictops;
4300 if($bm || $ps) {
4301 &dbg("Size: $xs*$ys\n") if($opt_d);
4302 $nimg++;
4303 push(@XS,$xs);
4304 push(@YS,$ys);
4305 if($bm) {
4306 $nm++;
4307 push(@DP,$dp);
4308 push(@BM,$bm);
4309 push(@WS,int(($xs-1)*$dp/8)+1);
4310 push(@FC,$fc);
4311 push(@IX,$nm);
4312 push(@IT,0);
4313 }
4314 if($ps) {
4315 $nps--;
4316 push(@IX,$nps);
4317 push(@IT,1);
4318 $nli=30000;
4319 $n=1;
4320 $npr=$ps=~s|(.*\n){$nli}|sprintf("$&} D\n/P$nimg\_%d {",$n++)|eg;
4321 if($npr) {
4322 $proc=" (";
4323 for $i (0..$npr) {
4324 $proc.="P$nimg\_$i ";
4325 }
4326 $proc.=")";
4327 $pv.="/P$nimg\_0 {$ps} D\n";
4328 $eps{"P$nimg\_0"}=$ps;
4329 } else {
4330 $proc=" (P$nimg)";
4331 $pv.="/P$nimg {$ps} D\n";
4332 $eps{"P$nimg"}=$ps;
4333 }
4334 }
4335 $text="$proc $nimg IM(";
4336 $cmd{$URL}=$text if(!$cmd{$URL});
4337 $cmd{$URL.$red.$grn.$blu}=$text if($src{$URL});
4338 $proc="";
4339 $end=$' if($imgcmd eq "object" && $end=~m|</object>|i);
4340 } else {
4341 &getalt;
4342 $failed{"$url"}=1;
4343 }
4344 }
4345 } elsif($imgcmd eq "object" && $end=~m|</object>|i) {
4346 $end=$';
4347 }
4348 }
4349 if($cmd{$URL}) {
4350 $text=")".$off.$al.$text;
4351 if($imgcmd eq "fig") {
4352 $end=~m|</fig>|i;
4353 $fig=$`;
4354 $end=$';
4355 $over="";
4356 while($fig=~/(<overlay$R)/ig) {$over.=$1};
4357 ($dum,$cap)=$fig=~m|<caption$R([\w\W]*)</caption>|i;
4358 ($dum,$cred)=$fig=~m|<credit$R([\w\W]*)</credit>|i;
4359 $text=")BN($text$over)BN($cap)BN($cred)BN(";
4360 }
4361 }
4362 }
4363 $_=$beg.$text.$end;
4364 }
4365 s|<[hH][rR]$R|)2 1 1 HR(|g;
4366 $_[0]=$_;
4367 }
4368 sub getval{
4369 local($val,$unit)=$_[0]=~/$V\s*(\w*)/g;
4370 $val*=$cm{$unit} if($_[1]==1 && defined $cm{$unit});
4371 $val*=$pt{$unit} if($_[1]==2 && defined $pt{$unit});
4372 $_[0]=$val;
4373 }
4374 sub getconf {
4375 local($_)=@_;
4376 while(/\@import\s+(([\w.\/-]+)|"([^"]*)"|'([^']*)')\s*;/) {
4377 if(open(SS,$+) && !$read{$+}) {
4378 $conf=<SS>;
4379 $_=$`.$conf.$';
4380 print DBG "***** $+:\n$conf" if($opt_d);
4381 close SS;
4382 $read{$+}=1;
4383 } else {
4384 &dbg($read{$+}?"Infinite \@import loop: $+\n":"Error opening: $+\n");
4385 $_=$`.$';
4386 }
4387 }
4388 @block=();
4389 while(&getblk($_)){};
4390 }
4391 sub getblk {
4392 local($_)=@_;
4393 local ($beg,$match,$end,$blk,$key,$val,$id,$temp);
4394 while(/^\s*\/\*/) {
4395 /\*\/|$/;
4396 $_=$';
4397 }
4398 return 0 if !/\S/;
4399 /[\w,:.@\s-]+\{/;
4400 $_=$';
4401 ($id=$&)=~s/^\s*|\s*\{//g;
4402 $id=lc $id;
4403 push(@block,"\L$id");
4404 if($#block==1) {
4405 $valid{$id}=1 if(!$user);
4406 if($id eq "color") {$id="colour"};
4407 if(!$valid{$id}) {
4408 &dbg("Error in configuration file: unknown block name '$id'\n");
4409 }
4410 }
4411 $blk="";
4412 W:while(/\s*(\/\*|[\w][\w-]*\s*:|[\w,:.\s-]+\{|\})\s*/) {
4413 $blk.=$1 if($1 ne "/*");
4414 $beg=$`;
4415 $match=$1;
4416 $end=$';
4417 S:{
4418 if($match=~/\{$/) {
4419 $temp=$match.$end;
4420 $blk.=&getblk($temp);
4421 $_=$temp;
4422 last S;
4423 }
4424 if($match=~/:$/) {
4425 ($key=$`)=~s/\s*$//;
4426 # $end=~/([\w.\$-]+|"[^"]*"|'[^']*')\s*;?/;
4427 $end=~/("[^"]*"|'[^']*'|.*?(?= *(\/\*|;|}|$)))/m;
4428 $blk.=$`.$&;
4429 $_=$';
4430 ($val=$1)=~s/^["']|["']$//g;
4431 $val=~s/'|\\/\\$&/g;
4432 $typ=1;
4433 $typ=2 if($val=~/^$V(cm|mm|in|pt|pc|em)$/);
4434 $typ=3 if($val=~/^$V$/);
4435 $typ=4 if($val=~/^-?\d+$/);
4436 $typ=5 if($val eq "0" || $val eq "1");
4437 if($block[0] eq '@html2ps') {
4438 if($#block==0) {
4439 if(!$user) {
4440 $valid{$key}=1;
4441 $type{$key}=$typ if(!defined $type{$key});
4442 }
4443 if($valid{$key}) {
4444 if($typ>=$type{$key}) {
4445 $key=~s/-/_/g;
4446 eval "\$$key='$val'" if($user || $val ne '');
4447 # print DBG "\$$key='$val'\n" if($opt_d && $user);
4448 } elsif($user) {
4449 &dbg("Error in configuration file: bad value for $key: $val\n");
4450 }
4451 } else {
4452 &dbg("Error in configuration file: unknown key '$key'\n");
4453 }
4454 }
4455 if($#block==1) {
4456 if($id eq "option" && $optalias{$key}) {$key=$optalias{$key}};
4457 if(!$user) {
4458 $valid{"$id,$key"}=1;
4459 $type{"$id,$key"}=$typ if(!defined $type{"$id,$key"});
4460 }
4461 if($valid{"$id,$key"} || $extend{$id}) {
4462 if($typ>=$type{"$id,$key"} || $id eq "colour") {
4463 eval "\$$id\{'$key'}='$val'" if($user || $val ne '');
4464 # print DBG "\$$id\{'$key'}='$val'\n" if($opt_d && $user);
4465 } elsif($user) {
4466 &dbg("Error in configuration file: bad value for $key: $val\n");
4467 }
4468 } else {
4469 &dbg("Error in block '$id' in configuration file:"
4470 ." unknown key '$key'\n");
4471 }
4472 }
4473 if($#block>1) {
4474 $temp="$block[$#block-1]_$key";
4475 $valid{$temp}=1 if(!$user);
4476 $parblk=$block[$#block-1];
4477 if($valid{$temp}) {
4478 eval "\$$parblk\_$key\{'$id'}='$val'";
4479 # print DBG "\$$parblk\_$key\{'$id'}='$val'\n" if($opt_d && $user);
4480 } elsif($valid{$parblk}) {
4481 &dbg("Error in block '$parblk' in configuration file:"
4482 ." unknown key '$key'\n");
4483 }
4484 }
4485 } else {
4486 for $i (split(',\s*',$id)) {
4487 $i=~s/@/AT_/;
4488 $i=~s/\./_/;
4489 $i=~s/ *:/__/;
4490 eval "\$$i\{'\L$key'}='\L$val'";
4491 # print DBG "\$$i\{'\L$key'}='\L$val'\n" if($opt_d && $user);
4492 }
4493 }
4494 last S;
4495 }
4496 if($match eq "/*") {
4497 /\*\/|$/;
4498 $_=$';
4499 last S;
4500 }
4501 last W;
4502 }
4503 }
4504 pop(@block);
4505 $_[0]=$end;
4506 $blk;
4507 }
4508 sub prompt {
4509 local($/)="\n";
4510 &dbg($_[0]);
4511 chop($_[1]=<STDIN>);
4512 }
4513 sub dbg {
4514 print STDERR $_[0];
4515 print DBG $_[0];
4516 }
4517 sub hb {
4518 local($_)=@_;
4519 local($head,$body,$beg,$end,$match,$tag);
4520 #If neither </HEAD> nor <BODY> can be found, find the separation point (messy).
4521 if(!/<(body|\/head)/i || $`=~/<plaintext|<xmp|<listing|<!--/i) {
4522 $head="";
4523 $int="";
4524 S1: while(/<(\/?\w+|!--|!|\?)/) {
4525 S2:{
4526 $beg=$`;
4527 $end=$';
4528 $match=$&;
4529 $tag=$1;
4530 if($tag eq "!--") {
4531 $int.=$`;
4532 &getcom;
4533 $int.=$com;
4534 $_=$rest;
4535 last S2;
4536 }
4537 if($tag=~/[!?]/) {
4538 $end=~/>/;
4539 $int.="$beg$match$`>";
4540 $_=$';
4541 last S2;
4542 }
4543 $tag=~s|/||;
4544 last S1 if(!$head{"\L$tag"});
4545 $end=~/$R/;
4546 $head.=$int.$beg.$match.$&;
4547 $int="";
4548 $_=$';
4549 }
4550 }
4551 $body=$int.$_;
4552 } else {
4553 $head=$`;
4554 $body=$&.$';
4555 }
4556 $_[0]=$body;
4557 $_[1]=$head;
4558 }
4559 sub open {
4560 if($_[0]=~m|://|) {
4561 &geturl($_[0],$_[1]);
4562 } elsif(open(FILE,$_[0])) {
4563 $_[1]=<FILE>;
4564 close FILE;
4565 } else {
4566 0;
4567 }
4568 }
4569 sub pagedef {
4570 for $margin ('left','right','top','bottom') {
4571 ($m)=$margin=~/(.)/;
4572 if(defined $margin{$margin}) {
4573 &dbg("'margin { margin-$margin:... }' is obsolete, use '\@page'\n");
4574 $AT_page{"margin-$margin"}=$margin{$margin} if(!defined $AT_page{"margin-$margin"});
4575 }
4576 for $page ('left','right') {
4577 ($p)=$page=~/(.)/;
4578 eval "\$m$m$p=\$AT_page\{'margin'} if(defined \$AT_page\{'margin'})";
4579 eval "\$m$m$p=\$AT_page\{'margin-$margin'} if(defined \$AT_page\{'margin-$margin'})";
4580 eval "\$m$m$p=\$AT_page__$page\{'margin'} if(defined \$AT_page__$page\{'margin'})";
4581 eval "\$m$m$p=\$AT_page__$page\{'margin-$margin'} if(defined \$AT_page__$page\{'margin-$margin'})";
4582 }
4583 }
4584 }
4585 sub pmtoraw {
4586 @pars=();
4587 ($temp)=@_;
4588 for $i (0..3) {
4589 1 while ($temp=~s/^\s*#.*//);
4590 next if($pars[0] eq 'P1' && $i == 3);
4591 $temp=~s/\s*(\S+)\s*//;
4592 $pars[$i]=$1;
4593 }
4594 $temp=~s/#.*//g;
4595 $pars[0]=~s/\d/$&+3/e;
4596 $_[0]="$pars[0]\n$pars[1] $pars[2]\n";
4597 if($pars[0] eq 'P4') {
4598 $temp=~s/\s//g;
4599 $_[0].=pack("B*",$temp);
4600 } else {
4601 $_[0].="255\n";
4602 while ($temp=~/\d+/g) {
4603 $_[0].=pack("C",int(255*$&/$pars[3]+.5));
4604 }
4605 }
4606 }
This page was automatically generated by the LXR engine.
Free-text search provided by Glimpse