$OpenBSD: patch-jenscript_jenscript_SH,v 1.6 2000/04/24 14:49:13 espie Exp $ --- jenscript/jenscript.SH.orig Tue Jan 16 18:20:31 1990 +++ jenscript/jenscript.SH Mon Apr 24 16:48:43 2000 @@ -20,14 +20,12 @@ echo "Extracting jenscript (with variabl : Protect any dollar signs and backticks that you do not want interpreted : by putting a backslash in front. You may delete these comments. $spitshell >jenscript <>jenscript <<'!NO!SUBS!' ($program) = ($0 =~ m#([^/]+)$#); $mflag = $gflag = $xflag = $nflag = $sflag = $dflag = $eflag = $kflag = 0; +$tflag = 0; $columns = 1; $curcolumn = 0; $printpage = 0; @@ -61,6 +60,7 @@ while($_ = $ARGV[0], /^-/){ # get option elsif(s/^d//){ $dflag = 1; } elsif(s/^E//){ $eflag = 1; } elsif(s/^k//){ $kflag = 1; } + elsif(s/^t//){ $tflag = 1; } elsif(s/^(\d)//){ $columns = $1; } elsif(/^f$/){ $kfont = $ARGV[0]; shift; last; } elsif(/^f(.+)/){ $kfont = $1; last; } @@ -87,27 +87,33 @@ $afont ne "" ? ($afont, $afont, $afont, $xflag ? ("Courier", "Courier-Bold", "Courier-Oblique", "Courier", "Courier") : ("Times-Roman", "Times-Bold", "Times-Italic", "Times-Roman", "Times-Roman"); -($height, $width, $offsetx, $offsety) = - $sflag ? (650, 440, 120, 150) : # B5 -# (730, 550, 60, 60); # A4 - (700, 550, 60, 40); # letter +($PageHeight, $PageWidth, $PageOffset) = + $sflag ? (842, 596, 60): # A4 + (792, 612, 40); # letter +$offsetx = $offsety = $PageOffset; +$height = $PageHeight - 2 * $offsety; +$width = $PageWidth - 2 * $offsetx; +# LandScape turn +($height, $width, $offsetx, $offsety) = ($width, $height, $offsety, $offsetx) + if ($tflag); $linepitch = $lines ? $height / $lines : $fontsize * 7.0 / 6.0; ($kfont, $jfontsize) = $kfont ne "" ? ($kfont, $fontsize) : - $fontsize < 5 ? ("jis16", 3.84) : +# $fontsize < 5 ? ("jis16", 3.84) : $fontsize < 7 ? ("jis24", 5.76) : $fontsize < 12 ? ("jis32", 7.68) : - ("jis50", 12) ; + ("jis48", 12) ; $_ = $kfont; $texfont = /^jisj/ || /^dmj/ || /^dgj/ ; -#define NORMAL 0 -#define COMMENT 1 -#define STRING 2 -#define LITERAL 3 -#define KEYWORD 4 + +use constant NORMAL => 0; +use constant COMMENT => 1; +use constant STRING => 2; +use constant LITERAL => 3; +use constant KEYWORD => 4; +use constant VGRINDEFS => '/usr/share/misc/vgrindefs'; $mode = $outmode = NORMAL; -#define VGRINDEFS "/usr/lib/vgrindefs" if(! open(vdef,VGRINDEFS)){ $language = ""; } @@ -132,6 +138,8 @@ if($language){ s/\\://g; split(/:/); $pat = $_[0]; + # handle C++ + $pat =~ s/\+/\\+/g; shift(@_); next if $language !~ /^($pat)$/; $pb = $bb = $be = $cb = $ce = $sb = @@ -295,7 +303,7 @@ while(<>){ nextline: do flush(); $posx = 0; - if(($posy -= $linepitch) <= 0){ + if(m/^\s*\cl\s*$/ || (($posy -= $linepitch) <= 0)){ if(++$curcolumn >= $columns){ do endpage(1); $curcolumn = 0; @@ -417,13 +425,17 @@ sub prologue { print "%%Creator: jenscript\n" if ! $nflag; print "%%Title: Jenscript\n" if ! $nflag; print "%%CreationDate: $date\n" if ! $nflag; + print "%%BoundingBox: 0 0 $PageWidth $PageHeight\n"; + print "%%Orientation: Landscape\n" if $tflag; print "%%EndComments\n" if ! $nflag; print "%%DocumentFonts: $kfont",$afont ne "" ? " $afont" : "", "\n"; print "save/EnscriptJob exch def\n"; print "/StartEnscriptDoc{\$enscript begin}def\n"; print "/\$enscript 60 dict def \$enscript begin\n"; print "/EndEnscriptDoc{end}def\n"; - print "/StartPage{/svpg save def }def\n"; + print "/StartPage{/svpg save def\n"; + print "[ 0 1 -1 0 $PageWidth 0 ] concat\n" if $tflag; + print "}def\n"; print "/EndPage{svpg restore showpage}def\n"; print "/SetStTime{statusdict /manualfeedtimeout 120 put} def\n"; print "/SetStatus{statusdict /manualfeed true put\n"; @@ -445,7 +457,7 @@ sub prologue { print "/FK { /$keywordfont findfont [$xfontsize 0 0 $fontsize 0 0] makefont setfont } bind def\n"; print "/FC { /$commentfont findfont [$xfontsize 0 0 $fontsize 0 0] makefont setfont } bind def\n"; print "/FS { /$stringfont findfont [$xfontsize 0 0 $fontsize 0 0] makefont setfont } bind def\n"; - print "/FL { /$litefalfont findfont [$xfontsize 0 0 $fontsize 0 0] makefont setfont } bind def\n"; + print "/FL { /$literalfont findfont [$xfontsize 0 0 $fontsize 0 0] makefont setfont } bind def\n"; } print "/FJ { /$kfont findfont $jfontsize scalefont setfont } bind def\n"; print "/N { FN show } bind def\n";