clewis@ecicrl.UUCP (Chris Lewis) (11/17/90)
Submitted-by: Chris Lewis <clewis@ecicrl.uucp> Archive-name: psroff2.0/Part07 #! /bin/sh # This is a shell archive. Remove anything before this line, then feed it # into a shell via "sh file" or similar. To overwrite existing files, # type "sh file -c". # The tool that generated this appeared in the comp.sources.unix newsgroup; # send mail to comp-sources-unix@uunet.uu.net if you want that tool. # Contents: audit.S cattab.c defs.h lib/Makefile utils.c # utils/calcfonts.S # Wrapped by clewis@ecicrl on Fri Nov 16 23:36:15 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH echo If this archive is complete, you will see the following message: echo ' "shar: End of archive 7 (of 16)."' if test -f 'audit.S' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'audit.S'\" else echo shar: Extracting \"'audit.S'\" \(11054 characters\) sed "s/^X//" >'audit.S' <<'END_OF_FILE' X%%STARTSHELL%% X# Psroff checking script 2.4 90/08/29 Xchkinst=false Xfor i Xdo X case $i in X install) X chkinst=true X ;; X *) X printerlist="$printerlist $i" X ;; X esac Xdone Xeval "`sed -n -e 's/[()]//g' \ X -e 's/^LIBDIR.*=[ ]*/LIBDIR=/p' \ X -e 's/^LJF.*=[ ]*/LJF=/p' \ X -e 's/^FONTDIR.*=[ ]*/FONTDIR=/p' \ X Makefile`" Xecho "LIBDIR = $LIBDIR" Xecho "LJF = $LJF" Xecho "FONTDIR = $FONTDIR" Xif [ -z "$FONTDIR" ] Xthen X echo "ERROR: That's odd, can't find a FONTDIR setting in Makefile" Xelif [ ! -d $FONTDIR ] Xthen X echo "ERROR: That's really odd, no such directory $FONTDIR" X echo " This is where CAT's width tables are supposed to be" X echo " It is usually /usr/lib/font" X FONTDIR= Xfi Xif [ -z "$LIBDIR" ] Xthen X echo "ERROR: Bad configuration - no LIBDIR setting" X exit 1 Xelif [ ! -d $LIBDIR ] Xthen X echo "INFO: You've not installed psroff yet - no LIBDIR ($LIBDIR) exists" X if $chkinst X then X echo "ERROR: Can't check installed version unless it's installed" X exit 1 X fi Xfi X Xif $chkinst Xthen X psrofflib=$LIBDIR/lib/psrofflib X libbase=$LIBDIR/lib Xelse X psrofflib=lib/psrofflib X libbase=lib Xfi X Xif [ ! -r $psrofflib ] Xthen X echo "ERROR: no $psrofflib to check" X exit 1 Xfi X Xeval `grep '^troff=' $psrofflib` Xecho "INFO: Your troff setting in psrofflib is troff=$troff" Xif [ -n "$troff" ] Xthen X # This should be -x, but Ultrix sh doesn't believe in it X if [ ! -f $troff ] X then X echo "ERROR: troff setting in $psrofflib ($troff) doesn't exist" X troff= X fi Xelse X mpath=`echo $PATH | sed -e 's/^:/.:/' -e 's/:$/:./' -e 's/:/ /g'` X echo "INFO: Your path is $mpath" X for i in $mpath X do X if [ -f $i/troff ] X then X echo "INFO: Troff appears to be $i/troff" X troff=$i/troff X break X fi X done X if [ -z "$troff" ] X then X echo "ERROR: Can't find troff!" X exit 1 X fi Xfi X Xeval `grep '^trofftype=' $psrofflib` Xecho "INFO: Your trofftype setting in $psrofflib is trofftype='$trofftype'" X Xif [ ! -r $FONTDIR/ftR -o ! -r $FONTDIR/ftI -o ! -r $FONTDIR/ftB -o \ X ! -r $FONTDIR/ftS ] Xthen Xcat <<! XWARNING: Missing one of the $FONTDIR/ft[RIBS] files. X I was hoping that FONTDIR was pointing at the place where X your version of troff keeps its width tables (by default X /usr/lib/font). Since this is not true, I will not be able X to tell with complete accuracy whether your trofftype setting X works. Therefore, take any ERROR messages about trofftype with X a grain of salt. You could always copy widths/widthps/ft[RIBS] X (after make widths) into $FONTDIR, but, I NEED a ftR from X your ORIGINAL troff distribution to test HEADERSIZE properly. X! Xfi X Xif [ -n "$FONTDIR" ] Xthen X arglist="-F$FONTDIR/./ftXX" Xfi Xfor i in $arglist -T. '' Xdo X echo "INFO: Testing '$i' trofftype setting" X $troff -t $i < /dev/null > /dev/null X rc=$? X if [ $rc = 0 ] X then X echo "... $i worked" X case $i in X -F*) X workingtype="-F$FONTDIR/\$width/ftXX" X ;; X -T*) X if [ -n "$FONTDIR" -a "$FONTDIR" != /usr/lib/font ] X then X echo "ERROR: FONTDIR must be /usr/lib/font with this" X echo " type of troff" X fi X workingtype="-T\$width" X ;; X *) X echo "INFO: Poor you, your troff doesn't understand -T or -F." X echo " This means that you'll have to put all of your" X echo " width files directly in $FONTDIR, and you'll not" X echo " be able to support multiple sets of width tables" X workingtype=" " X ;; X esac X break X else X echo "... $i didn't work" X fi Xdone Xif [ -z "$workingtype" ] Xthen X echo "ERROR: Oh my, your troff doesn't seem to work AT ALL!" X echo " It's giving me non-zero return codes when I try" X echo " all of the known different ways of setting width table" X echo " directory (including none!). Egads. Get Help!!!!!!!" X exit 1 Xfi X Xif [ "$workingtype" != "$trofftype" ] Xthen X echo "ERROR: You should have trofftype='$workingtype' in $psrofflib" X echo " Psroff won't work AT ALL without this fixed" Xelse X echo "INFO: Your trofftype setting ($trofftype) appears correct" Xfi X Xif [ ! -r $FONTDIR/ftR ] Xthen X echo "INFO: There isn't a $FONTDIR/ftR (it should be if you've installed" X echo " Troff on your system. Without it, I can't test HEADERSIZE" Xelse X hdrsize=`sed -n \ X -e 's/^#define[ ]*HEADERSIZE[ ]*\([0-9]*\).*/\1/p' defs.h` X echo "INFO: You have HEADERSIZE defined as $hdrsize" X bytecount=`wc -c $FONTDIR/ftR | sed -e 's/^[ ]*//g' -e 's/[ ].*//` X case $bytecount in X 224) X echo "INFO: You appear to have a Xenix-like troff - width tables" X echo " have no extraneous garbage. Lucky you!" X acthdr=0 X ;; X *) X echo "INFO: H'mm, you don't have a Xenix-like troff - Assuming" X echo " your troff puts a.out.h headers on width tables, I" X echo " will try compiling a teensy program to find out how" X echo " big a.out.h headers actually are...." X cat > AUDITP.c <<\! X#include <a.out.h> X#ifdef X_EXEC X/* Xenix I think.... */ X#define HEADERSIZE sizeof(struct xexec) X#endif X#ifdef F_LNNO X/* COFF format headers */ X#define HEADERSIZE (-sizeof(struct filehdr)) X#endif X#ifndef HEADERSIZE X/* Generalized V7 or BSD - non-coff format headers */ X#define HEADERSIZE sizeof(struct exec) X#endif Xmain() { Xprintf ("%d\n", HEADERSIZE); X} X! X rm -f AUDITP X if [ -z "$MAKE" ] X then X MAKE=make X fi X $MAKE AUDITP > /dev/null 2>&1 X if [ ! -f AUDITP ] X then X echo "INFO: H'm, Wouldn't compile ..." X # Common for 32 bitters (Sun/Ultrix f'r instance) X acthdr=-32 X else X acthdr=`./AUDITP` X fi X rm -f AUDITP AUDITP.c X case $acthdr in X -*) X echo 'INFO: The following HEADERSIZE is *purely* a guess:' X acthdr=`echo $acthdr | sed -e 's/-//'` X ;; X esac X echo "INFO: It looks like HEADERSIZE should be $acthdr" X ;; X esac X if [ "$hdrsize" != "$acthdr" ] X then X echo "ERROR: HEADERSIZE should be set to $acthdr, not $hdrsize" X else X echo "INFO: HEADERSIZE appears to be set correctly to $hdrsize" X fi Xfi X XTopts="`sed -e '/^[a-zA-Z]/!d' -e '/^troff/d' \ X -e '/^trofftype/d' -e 's/[ ].*//' $psrofflib | sort -u`" Xecho "INFO: Commencing psrofflib ($psrofflib) checking" Xif $chkinst Xthen X msgtyp='ERROR ' X troff2ps=$LIBDIR/troff2ps Xelse X msgtyp='WARNING' X troff2ps=./troff2ps Xfi X Xif [ ! -f $troff2ps ] Xthen X echo "WARNING: Can't test drivers, because troff2ps isn't built" Xfi Xrm -f PRINTERLIST X Xfor type in $Topts Xdo X troff="<not set>" X trofftype="<not set>" X width="<not set>" X t2arg="<not set>" X lparg="<not set>" X ptr="<not set>" X# If your system has no awk (or a busted one), you may have to X# comment out the "line=`awk ... $psrofflib" lines, and uncomment X# the sed script. If you do, you won't be able to continue X# psrofflib lines, so you'll have to "join" the entries in psrofflib X# (remembering to delete the name fields in the continuation lines). X line=`awk ' X $1 ~ /^#/ {next} X $0 ~ /^troff/ { print $0 } X $1 == "'$type'" { X seen=1 X print "F='T'" substr($0, length($1) + 1) X next X } X { if (seen) exit(0) } X ' $psrofflib` X eval "$line" X echo "INFO: psroff -T$type settings:" X echo " troff $troff" X echo " trofftype $trofftype" X echo " width $width" X if [ -n "$FONTDIR" -a ! -d $FONTDIR/$width ] X then X echo " * $msgtyp: FONTDIR/$width not installed yet" X echo " psroff -T$width won't work until you do" X fi X if [ ! -d widths/width${width} ] X then X echo " * WARNING: no widths/width${width} directory" X fi X echo " t2arg $t2arg" X drivertype=`echo $t2arg | sed -n -e 's/.*-T\([^ ]*\).*/\1/p'` X printertype=`echo $t2arg | sed -n -e 's/.*-p\([^ ]*\).*/\1/p'` X if [ -z "$drivertype" ] X then X echo " * INFO : no -T in $psrofflib t2arg - assuming ps" X drivertype=ps X fi X if [ -z "$printertype" ] X then X printertype=$drivertype X fi X echo " Driver type: $drivertype, library prefix: $printertype" X if [ -f $troff2ps ] X then X $troff2ps -T$drivertype < /dev/null > /dev/null 2>&1 X if [ $? != 0 ] X then X echo " * ERROR : troff2ps driver $drivertype not" \ X "configured psroff -T$width will die" X fi X fi X set +x X echo " lparg $lparg" X echo " ptr $ptr" X if [ ! -r $libbase/$printertype.lib ] X then X echo " * WARNING: no $libbase/$printertype.lib (no prolog)" X fi X if [ ! -r $libbase/$printertype.fonts ] X then X echo " * ERROR : Can't find $libbase/$printertype.fonts" X echo " Won't be able to give you list of fonts available" X continue X fi X echo "See $printertype.fonts below for listing of fonts" X echo $printertype >> PRINTERLIST Xdone X Xif [ -z "$printerlist" -a -s PRINTERLIST ] Xthen X printerlist=`sort -u PRINTERLIST` Xfi Xrm -f PRINTERLIST X Xfor printertype in $printerlist Xdo X ( X if [ -n "$FONTDIR" -a -d "$FONTDIR/$printertype" ] X then X ls $FONTDIR/$printertype | sed -n -e 's/^.*ft//p' | sort -u X fi X echo "troff2ps" X cat $libbase/$printertype.fonts X ) | awk ' X BEGIN { X fontdir = "'"$FONTDIR"'" X printertype = "'"$printertype"'" X catfonts[""] = 0 X fonts[""] = 0 X printf("\n\nPrinter type %s.fonts\n\n", printertype); X printf("%-4s %-20s %-25s %s\n", "Cat", "English Name", "Sequence", \ X "Flags"); X printf("Name\n\n"); X ignoring = 0 X } X $1 == "troff2ps" { X startlisting = 1; X next X } X $1 == "normal" || $1 == "symbol" { X ignoring = 1 X } X $1 !~ /^[A-Za-z][A-Za-z]*/ { X next X } X NF >= 1 { X if (ignoring) X next X if (startlisting) { X english = "" X sequence = "" X flags = "" X name = $1 X if (NF > 1) X english = $2 X if (NF > 2) X sequence = $3 X if (NF > 3) X flags = $4 X printf("%-4s %-20s %-25s %s\n", name, english, sequence, flags); X fonts[name] = 1 X } else { X catfonts[$1] = 1 X ftdirfound = 1 X } X } X END { X if (ftdirfound) { X for (name in fonts) { X if (name && !catfonts[name]) X printf(" FONT %s: do not use: %s/%s/ft%s not installed\n",\ X name, fontdir, printertype, name); X } X } X for (name in catfonts) { X if (name && !fonts[name]) { X printf(" FONT %s: do not use: %s/%s/ft%s exists, but", \ X name, fontdir, printertype, name) X printf(" not in %s.fonts\n", printertype) X } X } X }' X if [ -n "$LJF" -a -d "$LJF" -a "$printertype" = lj ] X then X echo "I'm checking $printertype.fonts file for missing font" X echo "files, please have patience" X sed -e '/^[A-Za-z][A-Za-z]*/!d' $libbase/$printertype.fonts | X while read troffname english sequence flags X do X for i in 6 7 8 9 10 11 12 14 16 18 20 22 24 28 36 X do X suffix= X case $flags in X n* | b*) ;; X p*) X suffix=pk X ;; X s*) X suffix=sfp X ;; X esac X if [ -n "$suffix" -a ! -r $LJF/$troffname.$i.$suffix ] X then X echo "ERROR: $LJF/$troffname.$i.$suffix missing" X fi X flags=`echo $flags | sed -e 's/.\(.*\)/\1/'` X done X done X fi Xdone END_OF_FILE if test 11054 -ne `wc -c <'audit.S'`; then echo shar: \"'audit.S'\" unpacked with wrong size! fi # end of 'audit.S' fi if test -f 'cattab.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'cattab.c'\" else echo shar: Extracting \"'cattab.c'\" \(9903 characters\) sed "s/^X//" >'cattab.c' <<'END_OF_FILE' X/* Copyright 1985, 1986, 1987, 1988 Chris Lewis X All Rights Reserved X X Permission to copy and further distribute is freely given provided X this copyright notice remains intact and that this software is not X sold for profit. X X Project: Generic Troff drivers X Module: cattab.c X Author: Chris Lewis X Specs: CAT Translation tables. X X Notes: X - There are two tables, one for normal and one for symbol fonts. X - The CAT code is calculated in the following way from the CAT X flash codes (see cat(5L)): X 1) if lower flash, the code is the flash code minus 1. X 2) if upper flash, the code is the flash code + 62 X (codes go from 0 to 107) X - Some CAT codes are not allocated - they are denoted as "NOC" X in the backend translation tables, but NTC here. X (the backend translation tables are indexed by CAT code). X - CAT codes of "NTC" in this table are "pseudo characters" which X are here so that a width entry index can be specified. For example, X "-" and \(hy are really the *same* CAT code, but have different X widths. Ditto _ and \ul. Another is that space isn't really X a character, but you gotta put its width somewhere. X - The width table index is the offset from the beginning of the X table (eg: not including any headers that your troff may X require). X - This table is primarily used for debugging and auxiliary purposes X and is scanned at most once per troff2ps run (-z dumps, during X *.fonts loading, and possibly in LJ w.r.t. font downloading), but X other programs use it more extensively. The backends have X the tables that are referenced on each character to obtain X printer-specific translations. X */ X X X#ifndef lint Xstatic char SCCSid[] = X "@(#)cattab.c: 2.1 Copyright 90/07/18 16:52:56 Chris Lewis"; X#endif X X#include "defs.h" X X/* +------------------------------------ Troff character name X | (NOC means no character only X | used here to terminate list) X | X | +----------------------------- N: standard font X | | S: symbol font X | | X | | +------------------------ CAT Output Code table index X | | | (must be sorted on this field!) X | | | X | | | +------------------- Width table index X | | | | X | | | | +---------------- Dummy used by dit2catwid X | | | | | X | | | | | +------------ Character description. X | | | | | | X v v v v v v */ X Xstruct cattab tabN[] = { X {"h", N, 0, 72, 0, "h"}, X {"t", N, 1, 84, 0, "t"}, X {"n", N, 2, 78, 0, "n"}, X {"m", N, 3, 77, 0, "m"}, X {"l", N, 4, 76, 0, "l"}, X {"i", N, 5, 73, 0, "i"}, X {"z", N, 6, 90, 0, "z"}, X {"s", N, 7, 83, 0, "s"}, X {"d", N, 8, 68, 0, "d"}, X {"b", N, 9, 66, 0, "b"}, X {"x", N, 10, 88, 0, "x"}, X {"f", N, 11, 70, 0, "f"}, X {"j", N, 12, 74, 0, "j"}, X {"u", N, 13, 85, 0, "u"}, X {"k", N, 14, 75, 0, "k"}, X {"", N, 15, -1, 0, NOC}, X {"p", N, 16, 80, 0, "p"}, X {"em", N, 17, 99, 0, "3/4 em"}, X {";", N, 18, 27, 0, ";"}, X {"", N, 19, -1, 0, NOC}, X {"a", N, 20, 65, 0, "a"}, X {"ru", N, 21, 100, 0, "horizontal rule"}, X {"c", N, 22, 67, 0, "c"}, X {"`", N, 23, 64, 0, "` open"}, X {"e", N, 24, 69, 0, "e"}, X {"'", N, 25, 7, 0, "' close"}, X {"o", N, 26, 79, 0, "o"}, X {"14", N, 27, 101, 0, "1/4"}, X {"r", N, 28, 82, 0, "r"}, X {"12", N, 29, 102, 0, "1/2"}, X {"v", N, 30, 86, 0, "v"}, X {"hy", N, 31, 96, 0, "hy hyphen"}, X {"w", N, 32, 87, 0, "w"}, X {"q", N, 33, 81, 0, "q"}, X {"/", N, 34, 15, 0, "/"}, X {".", N, 35, 14, 0, "."}, X {"g", N, 36, 71, 0, "g"}, X {"34", N, 37, 103, 0, "3/4"}, X {",", N, 38, 12, 0, ","}, X {"&", N, 39, 6, 0, "&"}, X {"y", N, 40, 89, 0, "y"}, X {"", N, 41, -1, 0, NOC}, X {"%", N, 42, 5, 0, "%"}, X {"", N, 43, -1, 0, NOC}, X {"Q", N, 44, 49, 0, "Q"}, X {"T", N, 45, 52, 0, "T"}, X {"O", N, 46, 47, 0, "O"}, X {"H", N, 47, 40, 0, "H"}, X {"N", N, 48, 46, 0, "N"}, X {"M", N, 49, 45, 0, "M"}, X {"L", N, 50, 44, 0, "L"}, X {"R", N, 51, 50, 0, "R"}, X {"G", N, 52, 39, 0, "G"}, X {"I", N, 53, 41, 0, "I"}, X {"P", N, 54, 48, 0, "P"}, X {"C", N, 55, 35, 0, "C"}, X {"V", N, 56, 54, 0, "V"}, X {"E", N, 57, 37, 0, "E"}, X {"Z", N, 58, 58, 0, "Z"}, X {"D", N, 59, 36, 0, "D"}, X {"B", N, 60, 34, 0, "B"}, X {"S", N, 61, 51, 0, "S"}, X {"Y", N, 62, 57, 0, "Y"}, X {"F", N, 63, 38, 0, "F"}, X {"X", N, 64, 56, 0, "X"}, X {"A", N, 65, 33, 0, "A"}, X {"W", N, 66, 55, 0, "W"}, X {"J", N, 67, 42, 0, "J"}, X {"U", N, 68, 53, 0, "U"}, X {"K", N, 69, 43, 0, "K"}, X {"0", N, 70, 16, 0, "0"}, X {"1", N, 71, 17, 0, "1"}, X {"2", N, 72, 18, 0, "2"}, X {"3", N, 73, 19, 0, "3"}, X {"4", N, 74, 20, 0, "4"}, X {"5", N, 75, 21, 0, "5"}, X {"6", N, 76, 22, 0, "6"}, X {"7", N, 77, 23, 0, "7"}, X {"8", N, 78, 24, 0, "8"}, X {"9", N, 79, 25, 0, "9"}, X {"*", N, 80, 10, 0, "*"}, X {"\\-", N, 81, 104, 0, "minus"}, X {"fi", N, 82, 105, 0, "fi"}, X {"fl", N, 83, 106, 0, "fl"}, X {"ff", N, 84, 107, 0, "ff"}, X {"ct", N, 85, 192, 0, "cent sign"}, X {"Fl", N, 86, 109, 0, "ffl"}, X {"Fi", N, 87, 108, 0, "ffi"}, X {"(", N, 88, 8, 0, "("}, X {")", N, 89, 9, 0, ")"}, X {"[", N, 90, 59, 0, "["}, X {"]", N, 91, 61, 0, "]"}, X {"de", N, 92, 110, 0, "degree"}, X {"dg", N, 93, 111, 0, "dagger"}, X {"=", N, 94, 29, 0, "="}, X {"rg", N, 95, 189, 0, "registered"}, X {":", N, 96, 26, 0, ":"}, X {"+", N, 97, 11, 0, "+"}, X {"", N, 98, -1, 0, NOC}, X {"!", N, 99, 1, 0, "!"}, X {"bu", N, 100, 97, 0, "bullet"}, X {"?", N, 101, 31, 0, "?"}, X {"fm", N, 102, 113, 0, "foot mark (minute)"}, X {"|", N, 103, 92, 0, "|"}, X {"", N, 104, -1, 0, NOC}, X {"co", N, 105, 190, 0, "copyright"}, X {"sq", N, 106, 98, 0, "square"}, X {"$", N, 107, 4, 0, "$"}, X {" ", N, NTC, 0, 0, "space"}, X {"\\|", N, NTC, 95, 0, "narrow space"}, X {"\\^", N, NTC, 118, 0, "half narrow space"}, X {"-", N, NTC, 13, 0, "hyphen character"}, X {NOC} X}; X Xstruct cattab tabS[] = { X {"*q", S, 0, 142, 0, "psi"}, X {"*h", S, 1, 127, 0, "theta"}, X {"*n", S, 2, 132, 0, "nu"}, X {"*m", S, 3, 131, 0, "mu"}, X {"*l", S, 4, 130, 0, "lambda"}, X {"*i", S, 5, 128, 0, "iota"}, X {"*z", S, 6, 125, 0, "zeta"}, X {"*s", S, 7, 137, 0, "sigma"}, X {"*d", S, 8, 123, 0, "delta"}, X {"*b", S, 9, 121, 0, "beta"}, X {"*c", S, 10, 133, 0, "xi"}, X {"*y", S, 11, 126, 0, "eta"}, X {"*f", S, 12, 140, 0, "phi"}, X {"*u", S, 13, 139, 0, "upsilon"}, X {"*k", S, 14, 129, 0, "kappa"}, X {"", S, 15, -1, 0, NOC}, X {"*p", S, 16, 135, 0, "pi"}, X {"@", S, 17, 32, 0, "@"}, X {"da", S, 18, 169, 0, "down arrow"}, X {"", S, 19, -1, 0, NOC}, X {"*a", S, 20, 120, 0, "alpha"}, X {"or", S, 21, 198, 0, "or (was star)"}, X {"*x", S, 22, 141, 0, "chi"}, X {"\"", S, 23, 2, 0, "double quote"}, X {"*e", S, 24, 124, 0, "epsilon"}, X {"eq", S, 25, 170, 0, "equation equal"}, X {"*o", S, 26, 134, 0, "omicron"}, X {"<-", S, 27, 167, 0, "left arrow"}, X {"*r", S, 28, 136, 0, "rho"}, X {"ua", S, 29, 168, 0, "up arrow"}, X {"*t", S, 30, 138, 0, "tau"}, X {"ul", S, 31, 116, 0, "ul"}, X {"\\", S, 32, 60, 0, "back slash"}, X {"*Q", S, 33, 154, 0, "Psi"}, X {"bs", S, 34, 197, 0, "bell system sign"}, X {"if", S, 35, 180, 0, "infinity"}, X {"*g", S, 36, 122, 0, "gamma"}, X {"ip", S, 37, 179, 0, "improper superset"}, X {"pt", S, 38, 185, 0, "proportional to"}, X {"rh", S, 39, 194, 0, "right hand"}, X {"*w", S, 40, 143, 0, "omega"}, X {"", S, 41, -1, 0, NOC}, X {"gr", S, 42, 182, 0, "gradient"}, X {"", S, 43, -1, 0, NOC}, X {"*F", S, 44, 153, 0, "Phi"}, X {"*H", S, 45, 146, 0, "Theta"}, X {"*W", S, 46, 155, 0, "Omega"}, X {"cu", S, 47, 174, 0, "union"}, X {"rn", S, 48, 158, 0, "root en"}, X {"ts", S, 49, 157, 0, "terminal sigma"}, X {"*L", S, 50, 147, 0, "Lambda"}, X {"mi", S, 51, 162, 0, "equation minus"}, X {"*G", S, 52, 144, 0, "Gamma"}, X {"is", S, 53, 184, 0, "integral sign"}, X {"*P", S, 54, 149, 0, "Pi"}, X {"sb", S, 55, 176, 0, "subset of"}, X {"sp", S, 56, 177, 0, "superset of"}, X {"ap", S, 57, 164, 0, "approximates"}, X {"pd", S, 58, 181, 0, "partial derivative"}, X {"*D", S, 59, 145, 0, "Delta"}, X {"sr", S, 60, 156, 0, "square root"}, X {"*S", S, 61, 150, 0, "Sigma"}, X {"~=", S, 62, 163, 0, "approx ="}, X {">", S, 63, 30, 0, ">"}, X {"*C", S, 64, 148, 0, "Xi"}, X {"<", S, 65, 28, 0, "<"}, X {"sl", S, 66, 117, 0, "slash"}, X {"ca", S, 67, 175, 0, "intersect"}, X {"*U", S, 68, 152, 0, "Upsilon"}, X {"no", S, 69, 183, 0, "logical not"}, X {"rc", S, 70, 210, 0, "right ceiling"}, X {"lt", S, 71, 200, 0, "left top brace"}, X {"bv", S, 72, 206, 0, "bold vertical"}, X {"lk", S, 73, 204, 0, "left ctr brace"}, X {"lb", S, 74, 201, 0, "left bot brace"}, X {"rt", S, 75, 202, 0, "right top brace"}, X {"rk", S, 76, 205, 0, "right ctr brace"}, X {"rb", S, 77, 203, 0, "right bot brace"}, X {"rf", S, 78, 208, 0, "right floor"}, X {"lf", S, 79, 207, 0, "left floor"}, X {"lc", S, 80, 209, 0, "left ceiling"}, X {"mu", S, 81, 171, 0, "multiply"}, X {"di", S, 82, 172, 0, "divide"}, X {"+-", S, 83, 173, 0, "plus-minus"}, X {"<=", S, 84, 160, 0, "<="}, X {">=", S, 85, 159, 0, ">="}, X {"==", S, 86, 161, 0, "identically equal"}, X {"!=", S, 87, 165, 0, "not equal"}, X {"{", S, 88, 91, 0, "{"}, X {"}", S, 89, 93, 0, "}"}, X {"aa", S, 90, 114, 0, "acute accent"}, X {"ga", S, 91, 115, 0, "grave accent"}, X {"^", S, 92, 62, 0, "^"}, X {"#", S, 93, 3, 0, "#"}, X {"lh", S, 94, 195, 0, "left hand"}, X {"mo", S, 95, 187, 0, "member of"}, X {"~", S, 96, 94, 0, "~"}, X {"es", S, 97, 186, 0, "empty set"}, X {"", S, 98, -1, 0, NOC}, X {"dd", S, 99, 193, 0, "dbl dagger"}, X {"br", S, 100, 191, 0, "box rule (was parallel sign)"}, X {"**", S, 101, 196, 0, "math *"}, X {"ib", S, 102, 178, 0, "improper subset"}, X {"ci", S, 103, 199, 0, "circle"}, X {"", S, 104, -1, 0, NOC}, X {"pl", S, 105, 188, 0, "equation plus"}, X {"->", S, 106, 166, 0, "right arrow"}, X {"sc", S, 107, 112, 0, "section"}, X {"_", S, NTC, 63, 0, "_"}, X {NOC} X}; END_OF_FILE if test 9903 -ne `wc -c <'cattab.c'`; then echo shar: \"'cattab.c'\" unpacked with wrong size! fi # end of 'cattab.c' fi if test -f 'defs.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'defs.h'\" else echo shar: Extracting \"'defs.h'\" \(10777 characters\) sed "s/^X//" >'defs.h' <<'END_OF_FILE' X/* Copyright 1988, 1989 23:13:57 Chris Lewis X All Rights Reserved X X Permission to copy and further distribute is freely given provided X this copyright notice remains intact and that this software is not X sold for profit. X X Project: Generic Troff drivers X Module: defs.h 2.10 90/11/16 23:13:57 X Author: Chris Lewis X Specs: Main header file - contains some customization X */ X X/* Official Release and Patch level: */ X#define T2VERSION "@(#)PSROFF Copyright 90/11/16 Chris Lewis - R2 P5" X X#ifndef LIBDIR X/* Don't touch this */ X#define LIBDIR "/usr/lib/troff2" X#endif X X/* Configuration parameters: X */ X X#undef BSD /* Define if you are a V7 or BSD machine */ X /* strchr vs. index etc.... */ X X#define ATT /* Define if you are some sort of SIII or SV system */ X X#undef BCOPY /* Define if you don't have memcpy and friends - eg: X oldish BSD systems */ X X#undef BCOPYLIB /* Define if BCOPY is defined and you have */ X /* a bcopy in your library */ X X#undef UNSIGNEDCHAR /* Define if chars are unsigned on your machine */ X X/* The name of a routine that can be called thusly: X VFPRINTF(stream, format, ap) X FILE *stream; X char *format; X va_list ap; X (eg: you have varargs.h and you have a routine functionally compatible X with System V vfprintf. I think BSD has one too) X X undef if you don't got, and maybe my fakeout will work. X */ X X#define VFPRINTF vfprintf X X/* If you have the stand-alone pk2sfp distribution, do not touch X anything from here on */ X X/* Font width file configuration: X X - If HEADERSIZE defined, use that many bytes as a prefix to the X compiled font width table. HEADERSIZE 0 is the correct definition X for Xenix and most System V Troffs. HEADERSIZE=32 works for Ultrix. X HEADERSIZE=0 works properly for Suns (I think). X - If COFF is defined instead, use a COFF header on the beginning of X the file. I personally know of no machine that supports these. X - If neither are defined, use a BSD/V7 style a.out.h header, this X is appropriate for V7 and BSD troffs X X The headers I write out do not have anything in them, so some X troff's may blow. Please let me know if they work for you... X If you do need the headers, and these doesn't work for you, enable X the COMPILE option in gfnttab. I know of no troff that *needs* X COMPILE on. X X */ X X#define HEADERSIZE 0 /* size of header in bytes */ X#undef COFF /* systems using COFF headers */ X X/* What do your CAT codes look like? X X If BSDHACK defined, the code to magnify the next lead by 64 replaces the X codes to set the tilt (tilt used only on 8-font CATs, which most CAT troff X programs don't support). X X Both FONT8 and BSDHACK code are *untested*. FONT8 probably does *not* X work. X */ X X#undef BSDHACK /* Has magnify lead opcode - untested */ X#undef FONT8 /* 8 Font device - untested */ X#define FONT4 /* Normal 4 font device */ X X /* define a command for decompressing an argument X file to stdout - allows you to compress SFP's. X undef if you don't got. The -d option may be X undocumented, but means decompress. "-dc" X is equivalent to zcat. -dc appears to be X in most versions of compress (eg: v3 & v4) */ X#define COMPRESS "/usr/lbin/compress -dc" X X/* Some postscript printers don't accept control-D as job termination X (DEC scriptwriters for instance). In that case, define this X macro. Alternately, if you have a proper printer manager that X does this sort of stuff, define it too. X */ X#undef NOCONTROLD X X/* define if you don't want your Postscript printer talking to you */ X#undef NOCHATTER X X/* The only advantage to commenting-out one of these is to make the X binary executable of troff2?? smaller. X */ X X/* Basic drivers: */ X#define PS /* Postscript */ X#define LJ /* Laserjet - psroff will not build with this undef'd */ X#define DT /* ditroff */ X X/* Laserjet driver config: */ X#define PK /* enable PK font downloading (needs LJ) */ X X#define SFP /* enable SFP incremental font downloading (needs PK). X You can still use SFP's without this turned on, but X you won't get incremental downloading */ X X#define PARTIAL /* partial (not incremental) font downloading */ X X#define INCR /* enable incremental font downloading (needs PARTIAL) */ X X#define MDLF 16 /* Max # downloaded fonts permitted by your laserjet X per *page*. 16 is correct for HPLJ+ and most II's. X IIP's are 32 I think. Some newer ones have higher X restrictions (don't put this too high even if X your printer supports it, you may run out of X memory) */ X X#define PRELOAD 0 /* set to number of LJ fonts permanently X downloaded to printer. The backend will X make sure that you don't go over the number X of fonts permitted by the printer */ X X#define DEBUG /* Do you want the debugger in? If you encounter X problems and you want help from me, you'll have X to have this turned on */ X X#define OPT /* Experimental code */ X X#define DEFPL 11 /* Default page length (11 inches). X DO NOT change unless you absolutely HAVE to. X You should only need to change this if you X desire your printer to use something different X as default. If so, you'll HAVE to change X your macro package to agree on the default - RT X owners take note! (the man macros are wrong) */ X X#define DEFOFF 0.5 /* Default page offset. DO NOT change unless you X absolutely HAVE to. You should only need this X if: your vendor has buggered your macros to X have a different default .po offset (Xenix), X and you aren't using the macro adapter X libraries that come with psroff (eg: you're X using troff2ps directly). See README/TROUBLE/ X psroff(1) (-O vs. -rO options) */ X X#define DEFYOFF 0 /* Default page vertical offset. See README/TROUBLE/ X psroff(1) -Y options too */ X X#define INSPECIAL /* enables ditroff graphics capability */ X X#define NODECMD "uuname -l" /* command to print on stdout the node name X of your machine. Use hostname on BSD-derived X systems that don't have UUCP. You can always X use "echo <nodename>" if necessary */ X X/* Edit no more .... */ X X#define MAXDLFONTS (MDLF - PRELOAD) /* # fonts troff2ps can download */ X X/* configuration verification */ X X#if defined(BSDHACK) && defined(FONT8) X#include "BSDHACK and FONT8 cannot be defined at the same time" X#endif X#if defined(FONT4) && defined(FONT8) X#include "FONT4 and FONT8 cannot be defined at the same time" X#endif X X#if !defined(LJ) && defined(PK) X#include "Pointless to define PK without LJ" X#endif X X#if !defined(PK) && (defined(INCR) || defined(PARTIAL)) X#include "Pointless to define INCR or PARTIAL without PK" X#endif X X#if defined(INCR) && !defined(PARTIAL) X#include "Don't support INCR without PARTIAL" X#endif X X#if defined(SFP) && !defined(PK) X#include "Can't define SFP without PK" X#endif X X#include <stdio.h> X#include <ctype.h> X X#ifdef BSD X#include <strings.h> X#define strchr index X#define strrchr rindex X#else X#include <string.h> X#endif X X#ifdef BCOPY X#define memcpy(to, from, len) bcopy(from, to, len) X#define clrarray(array, len) bzero(array, len) X#else X#define clrarray(array, len) memset(array, '\0', len) X#endif X X#ifdef UNSIGNEDCHAR X/* Ah heck, and this is probably not ANSI C either... */ X#define SIGNED(x) (((x)&0x80) ? ((x) - 256) : (x)) X#endif X X#define ESC 0x80 X#define FLASH 0x00 X#define CONTROL 0x40 X#define LEAD 0x60 X#define SIZE 0x50 X X#define DOWN 0 X#define UP 1 X#define LOWER 2 X#define UPPER 3 X#define FORWARD 4 X#define BACKWARD 5 X X#define TROFFRESOLUTION 432 X X#define SPECIAL /* define if you want to supports special directives */ X#define FORM /* define if you want the forms facility */ X XFILE *diagFile; X X#ifdef DEBUG X#define DBP(x) if (diagFile) dprintf x Xextern dprintf(); X#else X#define DBP(x) X#endif X Xtypedef int(*FUNC)(); X X#define FNULL (FUNC) NULL X Xstruct troff2befont { X short t2b_font; /* font (troff nomenclature) S=don't change */ X short t2b_xc; /* X-shift */ X short t2b_yc; /* Y-shift */ X short t2b_scale; /* point size scale adjust */ X char *t2b_charseq; /* character sequence - may include PS */ X}; X Xstruct cattab { X char *ch_name; X char ch_set; X unsigned char ch_catidx; X unsigned char ch_wididx; X unsigned char ch_info; /* used by some auxiliary programs */ X char *ch_desc; X}; X Xstruct backend { X char *bename; X FUNC beprolog, X beepilog, X beputchar, X bepage, X befontsel, /* special function F */ X beoverlay, /* special function O */ X bepassthru, /* special function P */ X bexlat, /* Xlate function */ X bedraw; /* Ditroff draw emulation routine */ X struct troff2befont X *bestdfont, /* standard font translate table */ X *besymfont; /* symbol font translate table */ X}; X X#define MAXFONTS 50 X Xstruct fonttable { X char *tab[4]; X long flags; X#ifdef INCR X struct downmaps *map; X#endif X#ifdef OPT X char *widthtable; X#endif X}; X X/* Symbolic names for tab entries in fonttable */ X#define troffName tab[0] /* troff name */ X#define fontName tab[1] /* back-end name (if used) */ X#define fontSeq tab[2] /* sequence to emit to shift to it X lj builtin's mostly */ X X/* fontFlags is 16 characters that reflect the state of the font X at a particular pointsize - mainly for lj */ X X/* Use of flags: X s: unloaded SFP X S: loaded SFP X p: unloaded PK X P: loaded PK X n: non-existant X b: builtin. X */ X#define fontFlags tab[3] X X X Xextern struct fonttable fonttable[MAXFONTS+1]; Xextern struct fonttable *xlatetable[8]; X Xstruct backend *be; X#define BNULL (struct backend *) NULL X Xextern char *skipblanks(); X X/* Common Back-end definitions */ X X#define N (unsigned char) (0xff) /* Use standard font */ X#define S (unsigned char) (0xfe) /* Use symbol font */ X#define D (unsigned char) (0xfd) /* Draw macro exists - use string directly */ X#define NTC (unsigned char) (0xfc) /* No font/Special flag */ X X#define NOC NULL X Xextern int currentPage; Xextern int pageoffset; Xextern int pageyoffset; Xextern int pagelength; Xextern int pagePending; X X#ifdef OPT Xextern char *widthtables; Xextern char *widthptr; Xextern int optimize; X#endif X Xextern int lastFont, lastPoints; Xextern int lastYPos, lastXPos, specXPos, specYPos; Xextern char *progname, *printer, *device; Xextern char **prologs; X Xint metrics; X XFILE *libopen(); X X/* Encoding format for generating width tables from font files */ X/* Used by pk2ditwid and friends */ Xstruct enctab { X char *e_name; X char *e_seq; X char e_wid; X}; X X/* Points in an inch */ X#define POINT 72.27 X X#define min(a,b) ((a) < (b) ? (a) : (b)) X#define max(a,b) ((a) > (b) ? (a) : (b)) X X/* debug flags */ X#define D_CAT 1 X#define D_SPEC 2 X#define D_CHAR 4 X#define D_FONT 8 X#define D_BEND 0x10 X#define D_PK 0x20 X#define D_VERB 0x40 X Xextern int debug; X Xextern char username[]; X Xextern char *mustmalloc(); X Xextern char *version, *shortversion; X X#ifdef ALONE X#undef PARTIAL X#undef INCR X#endif END_OF_FILE if test 10777 -ne `wc -c <'defs.h'`; then echo shar: \"'defs.h'\" unpacked with wrong size! fi # end of 'defs.h' fi if test -f 'lib/Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'lib/Makefile'\" else echo shar: Extracting \"'lib/Makefile'\" \(363 characters\) sed "s/^X//" >'lib/Makefile' <<'END_OF_FILE' X#2.1 90/07/18 X Xinclude ../makeincl X XLIBS = confid.ps lethead.ps \ X dj.fonts dj.lib \ X dt.fonts \ X jt.fonts \ X lj.fonts lj.lib \ X ps.fonts ps.lib \ X psrofflib X Xall: subst.done $(LIBS) X Xsubst.done: ../makeincl ../sedscript X rm -f psrofflib X touch subst.done X Xclean: X rm -f psrofflib X Xinstall: X cd $(LIBDIR)/lib ; rm -f $(LIBS) X cp $(LIBS) $(LIBDIR)/lib END_OF_FILE if test 363 -ne `wc -c <'lib/Makefile'`; then echo shar: \"'lib/Makefile'\" unpacked with wrong size! fi # end of 'lib/Makefile' fi if test -f 'utils.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'utils.c'\" else echo shar: Extracting \"'utils.c'\" \(9576 characters\) sed "s/^X//" >'utils.c' <<'END_OF_FILE' X/* Copyright 1985, 1986, 1987, 1988 Chris Lewis X All Rights Reserved X X Permission to copy and further distribute is freely given provided X this copyright notice remains intact and that this software is not X sold for profit. X X Project: Generic Troff drivers X Module: utils.c X Author: Chris Lewis X Specs: Utility functions X */ X X#include "defs.h" X X#ifndef lint Xstatic char SCCSid[] = X "@(#)utils.c: 2.3 Copyright 90/10/24 13:37:08 Chris Lewis"; X#endif X Xextern struct cattab tabN[], tabS[]; X Xint lastFont, lastPoints; Xint lastYPos, lastXPos; X Xextern char *malloc(); X Xchar *skipblanks(p) Xregister char *p; { X while (*p && isspace(*p)) p++; X return(p); X} X Xchar *gettok(p, bp) Xregister char *p, *bp; { X p = skipblanks(p); X while(*p && !isspace(*p)) *bp++ = *p++; X *bp = '\0'; X return(p); X} X Xinterp(buf, xlator, suf) Xchar *buf, *suf; FUNC xlator; { X register char *p; X char token[512]; X p = gettok(buf, token); X if (0 == strcmp(token, "include") || 0 == strcmp(token, "binclude")) { X int binary; X FILE *inc; X binary = (token[0] == 'b') ? 1: 0; X p = gettok(p, token); X DBP((D_SPEC, "Trying to include %s\n", token)); X if (!(inc = fopen(token, "r"))) { X strcat(token, "."); X strcat(token, suf); X DBP((D_SPEC, "Trying to include %s\n", token)); X if (!(inc = fopen(token, "r"))) { X char nbuf[512]; X if (token[0] != '/') { X sprintf(nbuf, "%s/%s", LIBDIR, token); X DBP((D_SPEC, "Trying to include %s\n", nbuf)); X inc = fopen(nbuf, "r"); X } X } X } X if (!inc) { X fprintf(stderr, "%s: cannot open file %s\n", progname, token); X exit(1); X } else { X DBP((D_SPEC, "Successfull include\n")); X if (binary || !xlator) X while ((binary = fread(token, 1, sizeof(token), inc)) > 0) X fwrite(token, 1, binary, stdout); X else X (*xlator)(inc); X fclose(inc); X } X } X X else { X fprintf(stderr, "%s: unknown directive: %s\n", progname, token); X exit(1); X } X} X Xchar nodename[25]; Xgetnodename() { X FILE *uuname; X if ((uuname = popen(NODECMD, "r")) == NULL) X strcpy(nodename, "<noname>"); X else { X fscanf(uuname, "%s", nodename); X if (pclose(uuname)) X strcpy(nodename, "<noname>"); X } X} X Xstruct fonttable fonttable[MAXFONTS+1]; Xstruct fonttable *xlatetable[8]; X X#define READFONT 0 X#define READNORM 1 X#define READSYMB 2 X Xloadfont(normfont, symfont) Xstruct troff2befont *normfont, *symfont; { X X char buffer[BUFSIZ]; X char buf[6][64]; X int tableindex; X int state, i, count; X register char *first; X extern int atoi(); X struct cattab *tab; X struct troff2befont *otab; X int done; X X FILE *fontfile; X X for (tableindex = 0; tableindex < 8; tableindex++) { X xlatetable[tableindex] = &fonttable[tableindex]; X } X X fontfile = libopen(printer, "fonts"); X X tableindex = 0; X X state = READFONT; X X while(fgets(buffer, sizeof(buffer), fontfile)) { X X first = buffer; X X for(;*first && isspace(*first); first++); X X if (!*first || *first == '#') X continue; X X switch(count = sscanf(first, "%s%s%s%s%s%s", X buf[0], buf[1], buf[2], buf[3], buf[4], buf[5])) { X case 1: buf[1][0] = '\0'; X case 2: buf[2][0] = '\0'; X case 3: buf[3][0] = '\0'; X case 4: buf[4][0] = '\0'; X case 5: buf[5][0] = '\0'; X case 6: X if (strcmp(buf[0], "normal") == 0) { X state = READNORM; X break; X } else if (strcmp(buf[0], "symbol") == 0) { X state = READSYMB; X break; X } X switch(state) { X case READFONT: X if (tableindex == MAXFONTS) { X fprintf(stderr, "%s: Too many fonts for %s!\n", X progname, printer); X exit(1); X } X for(i = 0; i < 4; i++) { X first = mustmalloc(strlen(buf[i])+1, X "fonttable"); X strcpy(first, buf[i]); X fonttable[tableindex].tab[i] = first; X } X#ifdef OPT X fonttable[tableindex].widthtable = (char *) NULL; X#endif X tableindex++; X break; X case READNORM: case READSYMB: X done = 0; X if (count <= 1) { X fprintf(stderr, "%s: bad font.%s line: %s\n", X progname, printer, buffer); X exit(1); X } X tab = (state == READNORM) ? tabN : tabS; X otab = (state == READNORM) ? normfont : symfont; X for (i = 0; tab[i].ch_name; i++) { X if (strcmp(tab[i].ch_name, buf[0]) == 0) { X switch(buf[1][0]) { X case 'N': X otab[i].t2b_font = N; break; X case 'S': X otab[i].t2b_font = S; break; X case 'D': X otab[i].t2b_font = D; break; X case '0': X case '1': X case '2': X case '3': X case '4': X case '5': X case '6': X case '7': X case '8': X case '9': X otab[i].t2b_font = atoi(buf[1]); X break; X default: X fprintf(stderr, "%s: bad font in %s\n", X progname, buffer); X exit(1); X } X switch(count) { X case 6: X otab[i].t2b_scale = atoi(buf[5]); X case 5: X otab[i].t2b_yc = atoi(buf[4]); X case 4: X otab[i].t2b_xc = atoi(buf[3]); X case 3: X octdecode(buf[2]); X first = mustmalloc(strlen(buf[2]) + 1, X "fonttable"); X strcpy(first, buf[2]); X otab[i].t2b_charseq = first; X } X done = 1; X break; X } X } X if (!done) { X fprintf(stderr, "%s: couldn't apply fonts.%s: %s\n", X progname, printer, buffer); X exit(1); X } X } X } X } X fclose(fontfile); X#ifdef OPT X loadwidth(xlatetable[0]); X loadwidth(xlatetable[1]); X loadwidth(xlatetable[2]); X loadwidth(xlatetable[3]); X#endif X} X X/* Translate any octal escapes *inplace* */ Xoctdecode(str) Xregister char *str; { X register char *from, *to; X int tmp, i; X from = to = str; X while(*from) { X if (*from != '\\') X *to++ = *from++; X else { X tmp = 0; X from++; X i = 3; X while(i-- > 0 && *from && *from >= '0' && *from <= '7') X tmp = (tmp << 3) + *from++ - '0'; X *to++ = tmp&0xff; X } X } X *to++ = '\0'; X} X X Xdumpsequence(sequence) Xregister char *sequence; { X printf("\t"); X for(;*sequence;sequence++) X if (isascii(*sequence) && isprint(*sequence)) X printf("%c", *sequence); X else X printf("\\%03o", (*sequence)&0xff); X} X Xdumpline(name, tp) Xregister char *name; Xregister struct troff2befont *tp; { X if (name != NOC) { X printf("%s\t", name); X switch(tp->t2b_font) { X case N: printf("N"); break; X case S: printf("S"); break; X case D: printf("D"); break; X default: printf("%d", tp->t2b_font); break; X } X dumpsequence(tp->t2b_charseq); X printf("\t%d\t%d\t%d", tp->t2b_xc, tp->t2b_yc, tp->t2b_scale); X printf("\n"); X } X} X Xdumplist(namelist, tp) Xregister struct cattab *namelist; Xregister struct troff2befont *tp; { X register int i; X for (i = 0; namelist[i].ch_name && namelist[i].ch_catidx != NTC; X i++, tp++) { X if (strlen(namelist[i].ch_name) == 0) X continue; X if (strcmp(namelist[i].ch_name, "hy") == 0) X dumpline("-", tp); X dumpline(namelist[i].ch_name, tp); X } X} X Xdumptables(bep) Xstruct backend *bep; { X if (!bep) { X fprintf(stderr, "%s: no backend selected for table dump\n", progname); X exit(1); X } X printf("normal\n"); X dumplist(tabN, bep->bestdfont); X printf("symbol\n"); X dumplist(tabS, bep->besymfont); X} X XFontSel(from, to) Xchar from, *to; { X#ifdef DEBUG X register int i; X#endif X register struct fonttable *p; X DBP((D_SPEC, "FontSel: %c -> %s\n", from, to)); X if (from < '1' || from > '8') { X fprintf(stderr, "Bad arguments to FontSel: %c %s\n", from, to); X return; X } X X for (p = fonttable; p->troffName; p++) X if (strcmp(p->troffName, to) == 0) { X xlatetable[from - '1'] = p; X break; X } X if (!p->troffName) { X fprintf(stderr, "Could not translate font %c (%s)\n", from, to); X } X#ifdef OPT X if (p->troffName && !p->widthtable) X loadwidth(p); X#endif X X#ifdef DEBUG X for (i = 0; i < 8; i++) X DBP((D_SPEC, "Font %d->%s\n", i+1, xlatetable[i]->fontName)); X#endif X} X XFILE *libopen(pref, suf) Xregister char *pref, *suf; { X X register char *buffer = mustmalloc(strlen(LIBDIR) + 50, "libopen"); X register FILE *library; X X sprintf(buffer, "%s.%s", pref, suf); X if ((library = fopen(buffer, "r")) == NULL) { X sprintf(buffer, "lib/%s.%s", pref, suf); X if ((library = fopen(buffer, "r")) == NULL) { X sprintf(buffer, "%s/%s.%s", LIBDIR, pref, suf); X if ((library = fopen(buffer, "r")) == NULL) { X fprintf(stderr, "Cannot find %s.%s in . or lib or %s\n", pref, suf, X LIBDIR); X exit(1); X } X } X } X free(buffer); X return(library); X} X XresetState() { X lastFont = -1; X lastPoints = -1; X lastYPos = -1; X lastXPos = -1; X} X Xdoprologs() { X if (!prologs) X return; X while(*prologs) X dospecial(*prologs++); X} X X#ifdef OPT Xloadwidth(p) Xstruct fonttable *p; { X FILE *f; X int c; X if ((int) p->widthtable == 1) X return; X p->widthtable = mustmalloc(224, "widthtable"); X strcpy(widthptr, "ft"); X strcat(widthptr, p->troffName); X DBP((D_SPEC, "Attempting to read font file %s\n", widthtables)); X if (f = fopen(widthtables, "r")) { X for (c = 0; c < HEADERSIZE; c++) getc(f); X if (224 != fread(p->widthtable, 1, 224, f)) { X fprintf(stderr, "%s: badly formed width table %s\n", X progname, widthtables); X free(p->widthtable); X p->widthtable = (char *) 1; X DBP((D_SPEC, "Load of %s failed\n", widthtables)); X } else { X for (c = 0; c < 224; c++) X p->widthtable[c] &= 0x3f; X DBP((D_SPEC, "Load of %s succeeded\n", widthtables)); X } X } else { X DBP((D_SPEC, "Failed to open widthtable %s\n", widthtables)); X free(p->widthtable); X p->widthtable = (char *) 1; X } X} X#endif X X#ifdef NULLCHECK Xmab() { X fprintf(stderr, "KABOOM\n"); X abort(); X} X#endif END_OF_FILE if test 9576 -ne `wc -c <'utils.c'`; then echo shar: \"'utils.c'\" unpacked with wrong size! fi # end of 'utils.c' fi if test -f 'utils/calcfonts.S' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'utils/calcfonts.S'\" else echo shar: Extracting \"'utils/calcfonts.S'\" \(9988 characters\) sed "s/^X//" >'utils/calcfonts.S' <<'END_OF_FILE' X#!/usr/bin/perl Xeval "exec /usr/bin/perl -S $0 $*" X if $running_under_some_shell; X#Copyright 1990/07/18 Chris Lewis 2.1 X X# Set to path of sfp2pk if you have it, otherwise NULL. X$sfp2pk = ''; X# Threshold for acceptable point sizes (default 10%). X$thresh = 1.1; X# Place to build new fonts X$newfonts = "/tmp/newfonts"; X# You might also want to adjust the "do gen"'s at the end. X X# Don't touch from here on. X$basedir = `pwd`; Xchop($basedir); X@pointlist = (6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 28, 36); X$verbose = 0; X$dirlist = ''; X# If non-null, each font matching this pattern not needed to X# build a particular size will be DELETED. X$discardpat = ""; X X$oldname = ''; X Xsub discard { X local($file) = $_[0]; X if ($discard && $file =~ $discardpat) { X unlink($file); X printf DISCARD ("deleted %s\n", $file); X } X} X Xsub gen { X local($outf, $engname, $escape, $outtype) = ($_[0], $_[1], $_[2], $_[3]); X if ($sfontonly && $outf ne 'S') { X return; X } X @namelist = @_; X shift(namelist); X shift(namelist); X shift(namelist); X shift(namelist); X unlink("$outf.build"); X foreach $pointsize (@pointlist) { X $found[$pointsize] = 0; X $missing = ''; X $cmdline = "$basedir/pk2sfp -m \\\n"; X $usedfonts = ''; X $looklist = ''; X for ($i = 0; $i <= $#namelist; $i++) { X ($rnamelist, $map) = split(/\//, $namelist[$i]); X $best = ''; X $bestratio = 1000; X $tmplist = ''; X X @alternates = split(/,/, $rnamelist); X foreach $rname (@alternates) { X $ratio = $ratios{$rname, $pointsize}; X if (!$ratio) { X $looked = "$rname(notfound)"; X } else { X ($np, $size) = split(/ /, $table{$rname, $pointsize}); X #$looked = sprintf("$rname$np.$size(%.2f)", $ratio); X $looked = sprintf("%s(%.2f)", $path{$rname, $pointsize}, X $ratio); X if ($ratio && $ratio <= $bestratio) { X $best = $rname; X $bestratio = $ratio; X $bestentry = $looked; X } X } X $looklist .= "$looked\n"; X $tmplist .= "$looked "; X } X if ($best && $bestratio <= $thresh) { X $usedfonts .= "$bestentry\n"; X $tdir = $path{$best, $pointsize}; X if (!$map) { X $map = $best; X if (! -r "$md/$map.$outtype") { X $map = $alternates[0]; X } X } X if (! -r "$md/$map.$outtype") { X $missing .= sprintf("Map file $map (for entry %s)\n", X $namelist[$i]); X } X $cmdline .= "\t$md/$map.$outtype $tdir\\\n"; X } else { X $missing .= "($tmplist) "; X } X } X if ($missing) { X chop($missing); X printf STDERR ("Missing $missing, won't generate $outf at $pointsize\n"); X printf STDERR ("Acceptable ones: $usedfonts\n"); X } else { X $cmdline .= "\t\t> t"; X $found[$pointsize] = 1; X chop($usedfonts); X printf STDERR ("Generating $outf at $pointsize using $usedfonts\n"); X if (system($cmdline)) { X printf STDERR ("failed ($!) $cmdline\n"); X exit(1); X } X if (system("$basedir/pk2sfp t > $newfonts/$outf.$pointsize.sfp")) { X printf STDERR ("pk2sfp sort to build $outf.$pointsize.sfp failed\n"); X exit(1); X } X unlink('t'); X if ($sfp2pk) { X if (system("$sfp2pk < $newfonts/$outf.$pointsize.sfp " . X "> $newfonts/$outf.$pointsize.pk")) { X printf STDERR ("sfp2pk < $outf.$pointsize.sfp failed\n"); X exit(1); X } X unlink("$newfonts/$outf.$pointsize.sfp"); X } X close(GEN); X } X } X open(TABLE, ">>lj.fonts.new"); X# The second field can be truncated, but none of the others. X#HI Helvetica-Italic \033(8U\033(s1p1s-3b04T nnnnpnnnnnnnnnn X#HB Helvetica-Bold \033(8U\033(s1p0s03b04T nnnnnnnnnnnnnnn X printf TABLE ("%-2s %-16.16s %-23s ", $outf, $engname, $escape); X foreach $pointsize (@pointlist) { X if ($found[$pointsize]) { X if ($sfp2pk) { X printf TABLE 'p'; X } else { X printf TABLE 's'; X } X } else { X printf TABLE 'n'; X } X } X printf TABLE "\n"; X close(TABLE); X} Xsub findcomplete { X foreach $name (sort keys(listofnames)) { X $complete{$name} = 0; X foreach $p (@pointlist) { X if ($ratios{$name, $p} <= $thresh) { X $complete{$name}++; X next; X } X } X } X foreach $name (sort keys(listofnames)) { X printf STDERR ("I have %d reasonable sizes of %s\n", $complete{$name}, X $name); X } X} X X Xsub dumplist { X foreach $name (sort keys(listofnames)) { X foreach $p (@pointlist) { X ($rp, $rs) = split(/ /, $table{$name, $p}); X printf STDERR ("%-8s %4d %4d %4d %4.4g%% %s\n", X $name, $p, $rp, $rs, (1 - $ratios{$name,$p}) * 100, X $path{$name, $p}); X } X } X} X Xwhile($arg = shift(@ARGV)) { X if ($arg eq '-v') { X $verbose = 1; X } elsif ($arg =~ /-S/) { X $sfontonly = 1; X } elsif ($arg =~ /^-D(.*)/) { X $basedir = $1; X } elsif ($arg =~ /^-s(.*)/) { X $sfp2pk = $1; X } elsif ($arg =~ /^-f(.*)/) { X $newfonts = $1; X } elsif ($arg !~ /^-/) { X if (-d $arg) { X $dirlist = "$dirlist $arg"; X } else { X printf STDERR ("No directory %s, skipping\n", $arg); X } X } else { X printf STDERR ("calcfonts: bad option %s\n", $arg); X exit(1); X } X} X Xif ($sfp2pk && ! -x $sfp2pk) { X printf STDERR X ("sfp2pk ($sfp2pk) not found - will generate SFP's not PK's\n"); X $sfp2pk = ''; X} X Xif (!$dirlist) { X printf STDERR ("No directories to search - aborting\n"); X exit(0); X} X X$md = "$basedir/maps"; X$dirlist = "$basedir/fonts $dirlist"; X Xunlink("$basedir/lj.fonts.new"); Xunlink("discard"); Xopen(DISCARD, ">discard"); X X$cmdline = X "find $dirlist -type f '(' -name '*pk' -o -name '*.sfp' ')' -print"; Xprintf STDERR ("Commandline: $cmdline\n"); Xopen(INLIST, "$cmdline|") || die "Cannot start $cmdline\n"; X Xwhile(<INLIST>) { X chop; X #/([a-z]+)([0-9]+)\s*:\s*(.*)/; X $path = $_; X if (/^\S+\/([a-z]+)([0-9]+)\.([0-9]+)pk/) { X $name = $1; X $points = $2; X $size = $3; X } elsif (/^\S+\/[a-z]+([0-9]+)\/([a-z]+)([0-9]+)\.pk/) { X $size = $1; X $name = $2; X $points = $3; X } elsif (/^\S+\/([a-z]+)([0-9]+)\.pk/) { X $size = 300; X $name = $1; X $points = $2; X } elsif (/^\S+\/([a-z]+)([0-9]+)\.sfp/) { X $size = 300; X $name = $1; X $points = $2; X } else { X printf STDERR ("Skipping %s\n", $path); X do discard($path); X next; X } X $listofnames{$name} = 1; X $actpoints = $points * $size / 300; X#printf("path: $path, name: $name, points: $points"); X#printf(" size: $size, actpoints: $actpoints\n"); X $foundany = 0; X foreach $needpoint (@pointlist) { X $ratio = $actpoints / $needpoint; X if ($ratio < 1) { X $ratio = 1 / $ratio; X } X#printf("ratio: (to get %d) %.2f\n", $needpoint, $ratio); X if ($ratios{$name, $needpoint} eq '') { X $ratios{$name, $needpoint} = 100; X } X X if ($ratio <= $ratios{$name, $needpoint}) { X $ratios{$name, $needpoint} = $ratio; X $table{$name, $needpoint} = "$points $size"; X $refcnt{$path}++; X if ($path{$name, $needpoint}) { X $opath = $path{$name, $needpoint}; X $refcnt{$opath}--; X if ($refcnt{$opath} == 0) { X printf DISCARD "%s\n", $opath; X do discard($opath); X } X } X $path{$name, $needpoint} = $path; X $foundany++; X } X } X if (!$foundany) { X do discard($path); X printf DISCARD "%s\n", $path; X } X} X Xif ($verbose) { X do findcomplete(); X do dumplist(); X} X X# Example of do gen call: X# do gen( X# 'R', Cat Troff name X# 'Times-Roman', English name (useful only in debugging) X# '\033(8U\033(s1p0s00b05T', Escape to emit if not present or builtin X# 'ROMAN8', map suffix to use. X# 'cmr,jmr', a font entry X# 'cmsy,jmsy', a font entry X# 'cmti,jmti', a font entry X# 'cmtrf,jmtrf'); a font entry X# X# There can be any number of font entries, and it is of the following X# generalized form: X# X# <font>,<font>,<font>..../<map prefix> X# X# Where: the list of fonts is a comma-separated list of X# PK/SFP font name prefixes of fonts that would be acceptable X# for merging with the other font entries to build the CAT font. X# A font with that prefix closest to each desired point size will X# be the one selected. In case of ties, the later one wins in the X# list. The map prefix (along with the suffix) is used to select X# which merge control file to use. See pk2sfp and utils/maps. X# If omitted, the map prefix will default to the font prefix that X# it used if present. If not present, it will default to the first X# font prefix. X# See LASERFONTS if you want more information on what the heck this X# junk is doing. X Xdo gen('R', 'Times-Roman', '\033(8U\033(s1p0s00b05T', 'ROMAN8', X 'cmr,jmr', 'cmsy,jmsy', 'cmti,jmti', 'cmtrf,jmtrf'); X Xdo gen('I', 'Times-Italic', '\033(8U\033(s1p1s-3b05T', 'ROMAN8', X 'cmsl,jmsl/cmr', 'cmsy,jmsy', 'cmti,jmti', 'cmtrf,jmtrf'); X Xdo gen('B', 'Times-Bold', '\033(8U\033(s1p0s03b05T', 'ROMAN8', X 'cmbx,jmbx/cmr', 'cmsy,jmsy', 'cmti,jmti', 'cmtrf,jmtrf'); X X# Shipped with psroff (as PK's): Xdo gen('S', 'Symbol', '\033(8M\033(s1p0s00b05T', 'MATH8', X 'cmr,jmr', 'cmsy,jmsy', 'cmmi,jmmi', 'cmtrf,jmtrf'); X Xdo gen('C', 'Courier', '\033(8U\033(s0p0s00b03T', 'ROMAN8', X 'cmtt,cmvtt,jmtt/cmtt', 'cmsy,jmsy', 'cmti,jmti', 'cmtrf,jmtrf'); X Xdo gen('CI', 'Courier-Italic', '\033(8U\033(s1p1s-3b03T', 'ROMAN8', X 'cmit,cmsltt,jmit,jmsltt/cmtt', 'cmsy,jmsy', 'cmti,jmti', 'cmtrf,jmtrf'); X Xdo gen('H', 'Helvetica', '\033(8U\033(s1p0s00b04T', 'ROMAN8', X 'cmss,lcmss,jmss/cmr', 'cmsy,jmsy', 'cmti,jmti', 'cmtrf,jmtrf'); X Xdo gen('HI', 'Helvetica-Italic', '\033(8U\033(s1p1s-3b04T', 'ROMAN8', X 'cmssi,lcmssi,jmssi/cmr', 'cmsy,jmsy', 'cmti,jmti', 'cmtrf,jmtrf'); X Xdo gen('HB', 'Helvetica-Bold', '\033(8U\033(s1p0s03b04T', 'ROMAN8', X 'cmssb,lcmssb,jmssbx/cmr', 'cmsy,jmsy', 'cmti,jmti', 'cmtrf,jmtrf'); X Xdo gen('E', 'English', '\033(8U\033(s1p0s00b05T', 'ROMAN8', X 'eufm/alnum', 'cmr', 'cmsy,jmsy', 'cmti,jmti', 'cmtrf,jmtrf'); X Xdo gen('EB', 'English-Bold', '\033(8U\033(s1p0s00b05T', 'ROMAN8', X 'eufb/alnum', 'cmr', 'cmsy,jmsy', 'cmti,jmti', 'cmtrf,jmtrf'); X X#"CI", "Courier-Italic", "\033(8U\033(s0p1s-3b03T", "ROMAN8", X#"CB", "Courier-Bold", "\033(8U\033(s0p0s03b03T", "ROMAN8", X#"L", "LinePrinter", "\033(8U\033(s0p0s00b00T", "ROMAN8", X#"LI", "LinePrinter-Ital", "\033(8U\033(s0p1s-3b00T", "ROMAN8", X#"LB", "LinePrinter-Bold", "\033(8U\033(s0p0s03b00T", "ROMAN8", END_OF_FILE if test 9988 -ne `wc -c <'utils/calcfonts.S'`; then echo shar: \"'utils/calcfonts.S'\" unpacked with wrong size! fi # end of 'utils/calcfonts.S' fi echo shar: End of archive 7 \(of 16\). cp /dev/null ark7isdone MISSING="" for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 16 archives. echo "Read the README to get started with psroff installation" rm -f ark[1-9]isdone ark[1-9][0-9]isdone else echo You still must unpack the following archives: echo " " ${MISSING} fi exit 0 -- Chris Lewis, Phone: TBA UUCP: uunet!utai!lsuc!ecicrl!clewis Moderator of the Ferret Mailing List (ferret-request@eci386) Psroff mailing list (psroff-request@eci386)