home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-12-11 | 54.3 KB | 2,244 lines |
- Newsgroups: comp.sources.misc
- From: bkw@uecok.ECOK.EDU (Bill Walker)
- Subject: v26i098: wroff - text formatter for HP LaserJet with PDS 25-font cartridge, Part02/05
- Message-ID: <1991Dec10.063550.9672@sparky.imd.sterling.com>
- X-Md4-Signature: 85237917b80e5e5f836c6c820aab5975
- Date: Tue, 10 Dec 1991 06:35:50 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: bkw@uecok.ECOK.EDU (Bill Walker)
- Posting-number: Volume 26, Issue 98
- Archive-name: wroff/part02
- Environment: SCO, HPUX, MS-DOS, CPM-68K
-
- #! /bin/sh
- # 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: Fonts/lex.yy.c HPUX.make TestData/sampler source/command.c
- # source/init.c source/io.c source/util.c
- # Wrapped by kent@sparky on Tue Dec 10 00:26:38 1991
- 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 2 (of 5)."'
- if test -f 'Fonts/lex.yy.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Fonts/lex.yy.c'\"
- else
- echo shar: Extracting \"'Fonts/lex.yy.c'\" \(6297 characters\)
- sed "s/^X//" >'Fonts/lex.yy.c' <<'END_OF_FILE'
- X# include "stdio.h"
- X# define U(x) x
- X# define NLSTATE yyprevious=YYNEWLINE
- X# define BEGIN yybgin = yysvec + 1 +
- X# define INITIAL 0
- X# define YYLERR yysvec
- X# define YYSTATE (yyestate-yysvec-1)
- X# define YYOPTIM 1
- X# define YYLMAX 200
- X# define output(c) putc(c,yyout)
- X# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
- X# define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;}
- X# define yymore() (yymorfg=1)
- X# define ECHO fprintf(yyout, "%s",yytext)
- X# define REJECT { nstr = yyreject(); goto yyfussy;}
- Xint yyleng; extern char yytext[];
- Xint yymorfg;
- Xextern char *yysptr, yysbuf[];
- Xint yytchar;
- XFILE *yyin ={stdin}, *yyout ={stdout};
- Xextern int yylineno;
- Xstruct yysvf {
- X struct yywork *yystoff;
- X struct yysvf *yyother;
- X int *yystops;};
- Xstruct yysvf *yyestate;
- Xextern struct yysvf yysvec[], *yybgin;
- X#undef ECHO;
- X#define ECHO;
- X
- X# define YYNEWLINE 10
- Xyylex(){
- Xint nstr; extern int yyprevious;
- Xwhile((nstr = yylook()) >= 0)
- Xyyfussy: switch(nstr){
- Xcase 0:
- Xif(yywrap()) return(0); break;
- Xcase 1:
- X {putchar('E');}
- Xbreak;
- Xcase -1:
- Xbreak;
- Xdefault:
- Xfprintf(yyout,"bad switch yylook %d",nstr);
- X} return(0); }
- X/* end of yylex */
- Xint yyvstop[] ={
- X0,
- X
- X1,
- X0,
- X0};
- X# define YYTYPE char
- Xstruct yywork { YYTYPE verify, advance; } yycrank[] ={
- X0,0, 0,0, 0,0, 0,0,
- X0,0, 0,0, 0,0, 0,0,
- X0,0, 0,0, 0,0, 0,0,
- X0,0, 0,0, 0,0, 0,0,
- X0,0, 0,0, 0,0, 0,0,
- X0,0, 0,0, 0,0, 0,0,
- X0,0, 0,0, 0,0, 0,0,
- X1,3, 0,0, 0,0, 0,0,
- X0,0};
- Xstruct yysvf yysvec[] ={
- X0, 0, 0,
- Xyycrank+1, 0, 0,
- Xyycrank+0, yysvec+1, 0,
- Xyycrank+0, 0, yyvstop+1,
- X0, 0, 0};
- Xstruct yywork *yytop = yycrank+28;
- Xstruct yysvf *yybgin = yysvec+1;
- Xchar yymatch[] ={
- X00 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- X01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- X01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- X01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- X01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- X01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- X01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- X01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- X01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- X01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- X01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- X01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- X01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- X01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- X01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- X01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- X0};
- Xchar yyextra[] ={
- X0,0,0,0,0,0,0,0,
- X0};
- Xint yylineno =1;
- X# define YYU(x) x
- X# define NLSTATE yyprevious=YYNEWLINE
- Xchar yytext[YYLMAX];
- Xstruct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
- Xchar yysbuf[YYLMAX];
- Xchar *yysptr = yysbuf;
- Xint *yyfnd;
- Xextern struct yysvf *yyestate;
- Xint yyprevious = YYNEWLINE;
- Xyylook(){
- X register struct yysvf *yystate, **lsp;
- X register struct yywork *yyt;
- X struct yysvf *yyz;
- X int yych;
- X struct yywork *yyr;
- X# ifdef LEXDEBUG
- X int debug;
- X# endif
- X char *yylastch;
- X /* start off machines */
- X# ifdef LEXDEBUG
- X debug = 0;
- X# endif
- X if (!yymorfg)
- X yylastch = yytext;
- X else {
- X yymorfg=0;
- X yylastch = yytext+yyleng;
- X }
- X for(;;){
- X lsp = yylstate;
- X yyestate = yystate = yybgin;
- X if (yyprevious==YYNEWLINE) yystate++;
- X for (;;){
- X# ifdef LEXDEBUG
- X if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
- X# endif
- X yyt = yystate->yystoff;
- X if(yyt == yycrank){ /* may not be any transitions */
- X yyz = yystate->yyother;
- X if(yyz == 0)break;
- X if(yyz->yystoff == yycrank)break;
- X }
- X *yylastch++ = yych = input();
- X tryagain:
- X# ifdef LEXDEBUG
- X if(debug){
- X fprintf(yyout,"char ");
- X allprint(yych);
- X putchar('\n');
- X }
- X# endif
- X yyr = yyt;
- X if ( (int)yyt > (int)yycrank){
- X yyt = yyr + yych;
- X if (yyt <= yytop && yyt->verify+yysvec == yystate){
- X if(yyt->advance+yysvec == YYLERR) /* error transitions */
- X {unput(*--yylastch);break;}
- X *lsp++ = yystate = yyt->advance+yysvec;
- X goto contin;
- X }
- X }
- X# ifdef YYOPTIM
- X else if((int)yyt < (int)yycrank) { /* r < yycrank */
- X yyt = yyr = yycrank+(yycrank-yyt);
- X# ifdef LEXDEBUG
- X if(debug)fprintf(yyout,"compressed state\n");
- X# endif
- X yyt = yyt + yych;
- X if(yyt <= yytop && yyt->verify+yysvec == yystate){
- X if(yyt->advance+yysvec == YYLERR) /* error transitions */
- X {unput(*--yylastch);break;}
- X *lsp++ = yystate = yyt->advance+yysvec;
- X goto contin;
- X }
- X yyt = yyr + YYU(yymatch[yych]);
- X# ifdef LEXDEBUG
- X if(debug){
- X fprintf(yyout,"try fall back character ");
- X allprint(YYU(yymatch[yych]));
- X putchar('\n');
- X }
- X# endif
- X if(yyt <= yytop && yyt->verify+yysvec == yystate){
- X if(yyt->advance+yysvec == YYLERR) /* error transition */
- X {unput(*--yylastch);break;}
- X *lsp++ = yystate = yyt->advance+yysvec;
- X goto contin;
- X }
- X }
- X if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){
- X# ifdef LEXDEBUG
- X if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1);
- X# endif
- X goto tryagain;
- X }
- X# endif
- X else
- X {unput(*--yylastch);break;}
- X contin:
- X# ifdef LEXDEBUG
- X if(debug){
- X fprintf(yyout,"state %d char ",yystate-yysvec-1);
- X allprint(yych);
- X putchar('\n');
- X }
- X# endif
- X ;
- X }
- X# ifdef LEXDEBUG
- X if(debug){
- X fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1);
- X allprint(yych);
- X putchar('\n');
- X }
- X# endif
- X while (lsp-- > yylstate){
- X *yylastch-- = 0;
- X if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){
- X yyolsp = lsp;
- X if(yyextra[*yyfnd]){ /* must backup */
- X while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){
- X lsp--;
- X unput(*yylastch--);
- X }
- X }
- X yyprevious = YYU(*yylastch);
- X yylsp = lsp;
- X yyleng = yylastch-yytext+1;
- X yytext[yyleng] = 0;
- X# ifdef LEXDEBUG
- X if(debug){
- X fprintf(yyout,"\nmatch ");
- X sprint(yytext);
- X fprintf(yyout," action %d\n",*yyfnd);
- X }
- X# endif
- X return(*yyfnd++);
- X }
- X unput(*yylastch);
- X }
- X if (yytext[0] == 0 /* && feof(yyin) */)
- X {
- X yysptr=yysbuf;
- X return(0);
- X }
- X yyprevious = yytext[0] = input();
- X if (yyprevious>0)
- X output(yyprevious);
- X yylastch=yytext;
- X# ifdef LEXDEBUG
- X if(debug)putchar('\n');
- X# endif
- X }
- X }
- Xyyback(p, m)
- X int *p;
- X{
- Xif (p==0) return(0);
- Xwhile (*p)
- X {
- X if (*p++ == m)
- X return(1);
- X }
- Xreturn(0);
- X}
- X /* the following are only used in the lex library */
- Xyyinput(){
- X return(input());
- X }
- Xyyoutput(c)
- X int c; {
- X output(c);
- X }
- Xyyunput(c)
- X int c; {
- X unput(c);
- X }
- END_OF_FILE
- if test 6297 -ne `wc -c <'Fonts/lex.yy.c'`; then
- echo shar: \"'Fonts/lex.yy.c'\" unpacked with wrong size!
- fi
- # end of 'Fonts/lex.yy.c'
- fi
- if test -f 'HPUX.make' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'HPUX.make'\"
- else
- echo shar: Extracting \"'HPUX.make'\" \(5399 characters\)
- sed "s/^X//" >'HPUX.make' <<'END_OF_FILE'
- XFrom uokmax!servalan!chinet!nucsrl!marcal!marc Mon Sep 16 01:00:10 1991
- XReceived: by uecok.ECOK.EDU (smail2.5)
- X id AA21001; 16 Sep 91 01:00:10 CDT (Mon)
- XReceived: by uokmax.ecn.uoknor.edu id AA24045
- X (5.65c/IDA-1.4.4 for uecok!bw); Sat, 14 Sep 1991 15:58:58 -0500
- XReceived: by servalan.UUCP (smail2.5+apb/mje900117)
- X id AA02142; Sat, 14 Sep 91 15:41:05 CDT
- XReceived: by chinet.chi.il.us (/\==/\ Smail3.1.22.1 #22.1)
- X id <m0kLVGc-00025WC@chinet.chi.il.us>; Sat, 14 Sep 91 03:22 CDT
- XReceived: from sol by delta.nucsrl.uucp id aa26410; 13 Sep 91 21:48 CDT
- XReceived: from mcdchg.UUCP by vistatech.com (4.0/SMI-4.0)
- X id AA08664; Fri, 13 Sep 91 21:40:51 CDT
- XReceived: by mcdchg.chg.mcd.mot.com (/\=-/\ Smail3.1.18.1 #18.4)
- X id <m0kLLrj-0000u2C@mcdchg.chg.mcd.mot.com>; Fri, 13 Sep 91 18:19 EDT
- XMessage-Id: <m0kLLrj-0000u2C@mcdchg.chg.mcd.mot.com>
- XReceived: by marcal.marcal.com
- X (15.11.1.6/15.6) id AA24271; Fri, 13 Sep 91 16:53:36 -0500
- XFrom: Marc Veeneman <uokmax!marcal!marc>
- XSubject: Wroff changes
- XTo: uecok!bw
- XDate: Fri, 13 Sep 91 16:53:33 CDT
- XMailer: Elm [revision: 64.9]
- XStatus: RO
- X
- XThank you much for keeping me up-to-date, Bill.
- X
- XI'm sending you the Makefile, as revised, which works with
- Xmy machine. This is HP-UX, version 7.02, on the 800 series
- Xof HP's 9000s. The 800 series is meant to be a multiple
- Xuser box, not the 300,400,500,700 etc. machines which are
- Xsold as personal workstations. Much of the difference, of
- Xcourse, is in the interfaces available, not in the CPU. In
- Xfact 700s and 800s have the same RISC heart beating inside.
- X
- XHere's the Makefile:
- X------------------------------------------------------------------------
- X# First make a.out, the make manpage and make tut.
- X# THEN you may make install.
- X
- X# this is the command to print something on your laser printer
- XPRINT=lp
- X
- X# the owner of the system files --- need not be root
- XOWNER=root
- X
- X# directory to contain the font tables
- X# leave as it is for testing, but change it for production
- X#FONTS='"./Fonts"'
- X#here's where we keep it, but you will want to change it.
- X# Note: Change the occurrences of ECU to local
- XFONTS='"/usr/local/Fonts"'
- X# Note: HP-UX make cannot make sense out of $(FONTSDIR)
- X# so define it outside the cc argument.
- XFONTSDIR=/usr/local/Fonts
- X
- X#source is located in this directory
- XSOURCE=./source
- X
- X#documentation is contained in this directory
- XDOCDIR=./doc
- X
- X#local bin directory
- X#leave it as is for testing, but change it for actual installation
- X#BINDIR=./bin
- X# we use this, but again you will certainly want to change it
- X# Note: Change the occurrences of ECU to local
- XBINDIR=/usr/local/bin
- X
- X# Note: HP-UX cc didn't understand -i option, so it ignored it:
- X#CFLAGS = -DFONTSDIR='"$(FONTS)"' -i -DUNIX -g
- XCFLAGS = -DFONTSDIR='"$(FONTS)"' -DUNIX -g
- X
- X
- Xa.out :
- X cd source; make -f makefile -k "CC=$(CC)" "CFLAGS=$(CFLAGS)"; \
- X mv a.out ../a.out
- X
- X
- X# be sure you have write permission whereever these directories are
- Xinstall :
- X strip a.out
- X mv a.out $(BINDIR)/wroff
- X cp ./Fonts/* $(FONTSDIR)
- X# Note: this looks like a simple typo, chmod instead of chown:
- X# chmod $(OWNER) $(FONTSDIR)/*
- X chown $(OWNER) $(FONTSDIR)/*
- X chmod u+r $(FONTSDIR)/*
- X chmod go+rx $(BINDIR)/wroff
- X chown $(OWNER) $(BINDIR)/wroff
- X
- X
- X# make "manual page" documentation for wroff -- it is stored under DOCDIR
- X# note that we assume that the (unstripped) wroff executable is named "a.out"
- X# Note: Change a.out in manpage and tut to ./a.out
- X# For security reasons, never have local pwd
- X# in your path.
- X
- Xmanpage :
- X ./a.out $(DOCDIR)/macs.w $(DOCDIR)/wroff.1.w -p -k -o $(DOCDIR)/doc.pr
- X
- X# make a tutorial for wroff -- store it in the DOCDIR
- X# note that we assume that the (unstripped) wroff executable is named "a.out"
- X
- Xtut :
- X ./a.out $(DOCDIR)/macs.w $(DOCDIR)/wroff.tut.w -p -k -o $(DOCDIR)/tut.pr
- X
- X
- X#clean up the mess
- Xclean:
- X rm $(SOURCE)/*.o
- X
- X
- X# this will test wroff to see if it works at all
- Xtest :
- X $(BINDIR)/wroff $(DOCDIR)/welcome
- X $(BINDIR)/wroff $(DOCDIR)/welcome | $(PRINT)
- X
- X
- X# this will print a convenient "sampler" to demonstrate the available fonts
- Xsampler:
- X $(BINDIR)/wroff TestData/sampler | $(PRINT)
- X
- X-------------------------------------------------------------------------
- X
- XNow I'm going to go looking for WalkerTBL, but I don't think I've seen
- Xit come in. Did you send me a copy? If not, please do. I needed
- Xto format some number columns the other day and ended up frustrated.
- XI supposed you could pipe tbl output to WalkerROFF, but I'm always
- Xin too much of a hurry to learn new tricks.
- X
- XAnother little frustration came when our client jammed a full page
- Xof 12 point verbage in the monthly letter. Turns out I was unable
- Xto adjust the LineLength, ala nroff, to make a narrower right margin,
- Xand I couldn't figure out how to make the bottom margin smaller.
- X
- XOn the other hand, a longer tutorial may not be desirable either. I
- Xalways keep in mind that this is wonderful because it is simple, the
- Xvery thing that (supposedly) made U*ix popular.
- X
- XMostly, Bill, I'm delighted to see you breathing life into wroff.
- XYour students will benefit from ANYTHING, I suppose, but unnamed folks
- Xaround the world will benefit from wroff.
- X--
- XMarc Veeneman Marcal Systems Corporation voice: 1 708 516 4555
- Xmarcal.uucp!marc Custom Financial Service fax: 1 708 516 4411
- X
- END_OF_FILE
- if test 5399 -ne `wc -c <'HPUX.make'`; then
- echo shar: \"'HPUX.make'\" unpacked with wrong size!
- fi
- # end of 'HPUX.make'
- fi
- if test -f 'TestData/sampler' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'TestData/sampler'\"
- else
- echo shar: Extracting \"'TestData/sampler'\" \(4919 characters\)
- sed "s/^X//" >'TestData/sampler' <<'END_OF_FILE'
- X.fm RESET
- X\fMFont RESET will clear the printer to default\fP
- X.sp
- XThis is a print sampler.
- X.sp 4
- X.fm LGN9.5A
- X\fMFont LGN9.5A is Letter Gothic, Normal, 9.5 point, ASCII\fP
- X.sp
- X.fm LGN14L
- X\fMFont LGN14L is Letter Gothic, Norman, 14 point, LEGAL\fP
- X.sp
- X.fm TMN10B
- XFont TMN10B is a math font: \fM abcdefgh\fP
- X.sp
- X.fm PAFS4.8_12
- X\fMFont\fP PAFS4.8_12 \fM is PDP AFS 4.8 point, 12 lpi\fP
- X.sp
- X.fm PAFS4.8_16
- X\fMFont\fP PAFS4.8_16 \fM is PDP AFS 4.8 point, 16 lpi\fP
- X.sp
- X.fm PCLine14
- XFont PCLine14 is a line drawing font: \fM0123456789\fP
- X.sp
- X.fm TaxB12
- XFont TaxB12 is a tax form font, boldfaced: \fMabcdefgh\fP
- X.sp
- X.fm LineDraw12
- XFont LineDraw12 is a line drawing font: \fMabcdefgh\fP
- X.sp
- X.fm LGN14A
- X\fMFont LGN14A is Letter Gothic, Normal, 14 point, ASCII\fP
- X.sp
- X.fm LGB12A
- X\fMFont LGB12A is Letter Gothic, Bold, 12 point, ASCII\fP
- X.sp
- X.fm LP8.5PC
- X\fMFont LP8.5PC is Line Printer, 8.5 point, PC\fP
- X.sp
- X.fm ci12
- X\fMFont ci12 is Courier, Italic, 12 point, ASCII\fP
- X.sp
- X.fm cn12
- X\fMFont cn12 is Courier, Normal, 12 point, ASCII\fP
- X.sp
- X.fm pen7
- X\fMFont pen7 is Prestige Elite, Normal, 7 point, ASCII\fP
- X.sp
- X.fm lp8.5
- X\fMFont lp8.5 is a Line Printer, 8.5 point, ASCII\fP
- X.sp
- X.fm pb18
- X\fMFont pb18 is Presentation, Bold, 18 point, ASCII\fP
- X.sp
- X.fm pb16a
- X\fMFont pb16a is Presentation, Bold, 16 point, ASCII\fP
- X.sp
- X.fm pei10.l
- X\fMFont pei10.l is Prestige Elite, Italic, 10 point, Legal\fP
- X.sp
- X.fm pen10.l
- X\fMFont pen10.l is Prestige Elite, Normal, 10 point, Legal\fP
- X.sp
- X.fm peb10.l
- X\fMFont peb10.l is Prestige Elite, Bold, 10 point, Legal\fP
- X.sp
- X.fm ct12r-8
- X\fMFont ct12r-8 is Courier, Italic, 12 point, Roman-8\fP
- X.sp
- X.fm pb14
- X\fMFont pb14 is Presentation, Bold, 14 points, ASCII\fP
- X.sp
- X.fm HB14ECMA
- X\fMFont HB14ECMA is Helvetica, Bold, 14 point, ECMA, 10 series\fP
- X.sp
- X.fm TMN8A
- XFont TMN8A is Times Math, Normal, 8 point, MATH A \fMabcdefg1234567\fP
- X.sp
- X.fm HN10
- X\fMFont HN10 is Helvetica, Normal, 10 point, ASCII\fP
- X.sp
- X.fm HI10
- X\fMFont HI10 is Helvetica, Italic, 10 point, ASCII\fP
- X.sp
- X.fm HB8
- X\fMFont HB8 is Helvetica, Bold, 8 point, ASCII\fP
- X.sp
- X.fm HN8
- X\fMFont HN8 is Helvetica, Normal, 8 point, ASCII\fP
- X.sp
- X.fm HN6
- X\fMFont HN6 is Helvetic, Normal, 6 point, ASCII\fP
- X.sp
- X.fm trn12
- X\fMFont trn12 is Times Roman, Normal, 12 point, ASCII\fP
- X.sp
- X.fm trb12
- X\fMFont trb12 is Times Roman, Bold, 12 point, ASCII\fP
- X.sp
- X.fm tri12
- X\fMFont tri12 is Times Roman, Italic, 12 point, ASCII\fP
- X.sp
- X.fm trn8
- X\fMFont trn8 is Times Roman, Normal, 8 point, ASCII\fP
- X.sp
- X.fm tri10
- X\fMFont tri10 is Times Roman, Italic, 10 point, ASCII\fP
- X.sp
- X.fm trn10
- X\fMFont trn10 is Times Roman, Normal, 10 point, ASCII\fP
- X.sp
- X.fm trb10
- X\fMFont trb10 is Times Roman, Bold, 10 point, ASCII\fP
- X.sp
- X.fm lgn12
- X\fMFont lgn12 is Letter Gothic, Normal, 12 point, ASCII\fP
- X.sp
- X.fm lgi12
- X\fMFont lgi12 is Letter Gothic, Italic, 12 point, ASCII\fP
- X.sp
- X.fm PB18L
- X\fMFont PB18L is Presentation, Bold, 18 point, Legal\fP
- X.sp
- X.fm PB16L
- X\fMFont PB16L is Presentation, Bold, 16 point, Legal\fP
- X.sp
- X.fm PB14L
- X\fMFont PB14L is Presentation, Bold, 14 point, Legal\fP
- X.sp
- X.fm HB14
- X\fMFont HB14 is Helvetica, Bold, 14 point, ASCII\fP
- X.sp
- X.fm TMN8B
- XFont TMN8B is Times Math, Normal, 8 point, MATH B \fMabcdef123456\fP
- X.sp
- X.fm HB12
- X\fMFont HB12 is Helvetica, Bold, 12 point, ASCII\fP
- X.sp
- X.fm HN12
- X\fMFont HN12 is Helvetica, Normal, 12 point, ASCII\fP
- X.sp
- X.fm HI12
- X\fMFont HI12 is Helvetica, Italic, 12 point, ASCII\fP
- X.sp
- X.fm HB10
- X\fMFont HB10 is Helvetica, Bold, 10 point, ASCII\fP
- X.sp
- X.fm PEN7L
- X\fMFont PEN7L is Prestige Elite, Normal, 7 point, Legal\fP
- X.sp
- X.fm LGN12H
- X\fMFont LGN12H is Letter Gothic, Normal, 12 point, ASCII, Prints sideways\fP
- X.sp
- X.fm pen10h
- X\fMFont pen10h is Prestige Elite, Normal, 10 point, ASCII, Prints sideways\fP
- X.sp
- X.fm PB14
- X\fMFont PB14 is Presentation, Bold, 14 points, ASCII, Prints sideways\fP
- X.sp
- X.fm PEN7H
- X\fMFont PEN7H is Prestige Elite, Normal, 7 point, ASCII, Prints sideways\fP
- X.sp
- X.fm lgn14
- X\fMFont lgn14 is Letter Gothic, Normal, 14 point, Print sideways\fP
- X.sp
- X.fm pcln14.l
- XFont pcln14.l is PC Line, Normal, 14 point, PC Line, Prints sideways \fMabcdefg\fP
- X.sp
- X.fm pdp4.812.l
- X\fMFont pdp4.812.l is PDP AFS, 4.8 point, 12 lpi, LICS, Prints sideways\fP
- X.sp
- X.fm pdp4.816.l
- X\fMFont pdp4.816.l is PDP AFS, 4.8 point, 16 lpi, LICS, Prints sideways\fP
- X.sp
- X.fm HN6H
- X\fMFont HN6H is Helvetica, Normal, 6 point, ASCII, Prints sideways\fP
- X.sp
- X.fm TRN10H
- X\fMFont TRN10H is Times Roman, Normal, 10 point, ASCII, Prints sideways\fP
- X.sp
- X.fm PEN7LH
- X\fMFont PEN7LH is Prestige Elite, Normal, 7 point, Legal, Prints sideways\fP
- X.sp
- X.fm LGN9.5H
- X\fMFont LGN9.5H is LtrGothic Nm 9.5 point, ASCII, Prints sideways\fP
- X.sp
- X.fm Line8.5H
- X\fMFont Line8.5H is LinePrinter 8.5 point, ASCII, Prints sideways\fP
- X.sp
- X.fm HB12H
- X\fMFont HB12H is Helvetica, Bold, 12 point, ASCII, Prints sideways\fP
- X.sp
- X.fm HB10H
- X\fMFont HB10H is Helvetica, Bold, 10 point, ASCII, Prints sideways\fP
- X.sp
- X.fm HN8H
- X\fMFont HN8H is Helvetica, Normal, 8 point, ASCII, Prints sideways\fP
- END_OF_FILE
- if test 4919 -ne `wc -c <'TestData/sampler'`; then
- echo shar: \"'TestData/sampler'\" unpacked with wrong size!
- fi
- # end of 'TestData/sampler'
- fi
- if test -f 'source/command.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'source/command.c'\"
- else
- echo shar: Extracting \"'source/command.c'\" \(13945 characters\)
- sed "s/^X//" >'source/command.c' <<'END_OF_FILE'
- X#include <stdio.h>
- X#include <ctype.h>
- X
- X#include "defs.h"
- X#include "externs.c"
- X
- Xextern FILE *fopen();
- Xextern struct machead *findmac();
- Xextern struct traphead *findtrap();
- X
- X/* this file contains the command processor */
- X
- X
- Xcommand(s,ifile,ofile)
- Xchar s[];
- XFILE *ifile,*ofile;
- X{
- X char cmd[MAXCMD][SHORTSTR];
- X int i,j,k,l;
- X int cmdnbr;
- X int atype,value;
- X char tempcmd[SHORTSTR], stopcmd[SHORTSTR];
- X char templine[MAXSTR];
- X char restofline[MAXSTR];
- X char temp1line[MAXSTR];
- X char temp2line[MAXSTR];
- X char tempfont[MAXSTR];
- X int quitadding;
- X int cnt;
- X int wordlength, chcnt;
- X FILE *tempfile,*fontfile;
- X
- X /* we have a command line. It may still have white
- X space at the front. It has a null at the end.
- X It has had nothing else done to it */
- X
- X /* first we parse the command line into its parts */
- X /* it may have a command name, and several arguments */
- X
- X /* first eat off any white space */
- X j = 0;
- X while (s[j] != '\0' && isspace(s[j]) ) j++;
- X
- X /* now skip the command character */
- X j++;
- X
- X /* clean off the command strings -- all of them ! */
- X for (cmdnbr = 0; cmdnbr < MAXCMD; cmdnbr++)
- X cmd[cmdnbr][0] = '\0';
- X
- X /* now copy into the cmd strings */
- X cmdnbr = 0;
- X
- X /* restofline contains all but the command */
- X k = j;
- X while (s[k] != '\0' && isspace(s[k]) ) k++;
- X while (s[k] != '\0' && !isspace(s[k]) ) k++;
- X while (s[k] != '\0' && isspace(s[k]) ) k++;
- X l = 0;
- X while (s[k] != '\0') {
- X restofline[l] = s[k];
- X k++;
- X l++;
- X }
- X restofline[l] = '\0';
- X
- X while ( s[j] != '\0') {
- X
- X /* first eat off any white space */
- X while (s[j] != '\0' && isspace(s[j]) ) j++;
- X
- X /* now copy into the command */
- X i = 0;
- X while ( s[j] != '\0' && !isspace(s[j]) ) {
- X cmd[cmdnbr][i] = s[j];
- X j++;
- X i++;
- X }
- X cmd[cmdnbr] [i] = '\0';
- X cmdnbr++;
- X }
- X /* now cmd[0] is the command name, and the rest are the arguments */
- X
- X /* we must now select the command, and take some action */
- X /* a finite state machine would be too cumbersome to
- X modify, so we just slug it out the hard way */
- X
- X atype = argtype(cmd[1]);
- X expndreg(templine,cmd[1]); /* expand any registers in cmd[1] */
- X value = argval(templine);
- X
- X if (streq(cmd[0],"bd") ) { /* boldface next n lines */
- X setparm(&BOLDCNT,atype,value,DEFCOUNT,0,HUGE);
- X }
- X else if (streq(cmd[0],"bp") ) { /* break page, number next n */
- X brek(ifile,ofile);
- X brpage(ifile,ofile);
- X setparm(&NEXTPAGE,atype,value,CURRPAGE + 1,1,HUGE);
- X }
- X else if (streq(cmd[0],"br") ) { /* break */
- X brek(ifile,ofile);
- X }
- X else if (streq(cmd[0],"cc") ) { /* change command character */
- X CMDCHAR = cmd[1][0];
- X }
- X else if (streq(cmd[0],"ce") ) { /* center next n lines */
- X brek(ifile,ofile);
- X setparm(&CNTRCNT,atype,value,DEFCOUNT,0,HUGE);
- X }
- X else if (streq(cmd[0],"dc") ) { /* title delimiter */
- X TDLIM = cmd[1][0];
- X }
- X else if (streq(cmd[0],"de") ) { /* define macro */
- X /* cmd[1] is the macro name */
- X defmac(cmd[1],¯olist);
- X /* now get lines from the file and add them to
- X this macro -- since the macro list is a stack,
- X the macrolist pointer points to the macro that
- X needs the lines added to it */
- X /* first build a string that can be used to stop
- X fetching lines */
- X sprintf(stopcmd,"%cen",CMDCHAR);
- X quitadding = FALSE;
- X while (! quitadding ) {
- X /* get a line */
- X getline(templine,ifile);
- X /* strip off the leading white space */
- X i = 0;
- X while (templine[i] != '\0' && isspace(templine[i]) ) i++;
- X /* copy into tempcmd */
- X j = 0;
- X while (templine[i] != '\0' && !isspace(templine[i])) {
- X tempcmd[j] = templine[i];
- X i++;
- X j++;
- X }
- X tempcmd[j] = '\0';
- X if (streq(tempcmd,stopcmd) ) {
- X quitadding = TRUE;
- X }
- X else {
- X macaddline(macrolist,templine);
- X }
- X
- X }
- X
- X }
- X else if (streq(cmd[0],"di") ) { /* start diversion */
- X defmac(cmd[1],¯olist);
- X InDiversion = TRUE;
- X DivStart = CURRY;
- X }
- X else if (streq(cmd[0],"ed") ) { /* end diversion */
- X REG('D') = CURRY - DivStart;
- X CURRY = DivStart;
- X InDiversion = FALSE;
- X }
- X else if (streq(cmd[0],"en") ) { /* end macro */
- X /* this should never be encountered */
- X fprintf(stderr,"end of macro encountered without a .de\n");
- X exit(1);
- X }
- X else if (streq(cmd[0],"et") ) { /* end transparent mode */
- X brek(ifile,ofile);
- X outselect = 'f';
- X }
- X else if (streq(cmd[0],"ex") ) {
- X brek(ifile,ofile);
- X brpage(ifile,ofile);
- X exit(0);
- X }
- X else if (streq(cmd[0],"fi") ) { /* start fill */
- X brek(ifile,ofile);
- X FILLMODE = TRUE;
- X }
- X else if (streq(cmd[0],"fm") ) { /* mount a font */
- X /* font name is in cmd[1] */
- X strcpy(tempfont,FONTSDIR);
- X strcat(tempfont,"/%s");
- X
- X sprintf(tempcmd,tempfont,cmd[1]);
- X fontfile = fopen(tempcmd,"r");
- X if (fontfile == NULL) {
- X fprintf(stderr,"font %s not found\n",tempcmd);
- X exit(1);
- X }
- X fscanf(fontfile,"%s",Pres);
- X /* note: the string Pres contains the letter E in several
- X places, which must be replaced with the ESC character */
- X i = 0;
- X while (Pres[i] != '\0') {
- X if (Pres[i] == 'E')
- X Pres[i] = ESC;
- X i++;
- X }
- X
- X
- X
- X for (i = 32; i <= 126; i++)
- X fscanf(fontfile,"%d",&P18bl[i]);
- X
- X fclose(fontfile);
- X
- X }
- X else if (streq(cmd[0],"fo") ) { /* define footer */
- X strcpy(footer,restofline);
- X }
- X else if (streq(cmd[0],"gx") ) { /* go to X */
- X expndreg(templine,cmd[1]);
- X gotoX(ifile,ofile,templine);
- X }
- X else if (streq(cmd[0],"gy") ) { /* goto y */
- X expndreg(templine,cmd[1]);
- X gotoY(ifile,ofile,templine);
- X }
- X else if (streq(cmd[0],"he") ) { /* define header */
- X strcpy(header,restofline);
- X }
- X else if (streq(cmd[0],"hr") ) { /* horizontal rule */
- X fprintf(stderr,"horizontal rule not yet implemented\n");
- X exit(1);
- X }
- X else if (streq(cmd[0],"if") ) { /* if test */
- X /* we have two expressions, and an operator, or maybe
- X only one expression, which is either 0 (TRUE)
- X or non-zero (FALSE) --- we need to parse this
- X mess to find out what it is */
- X /* everything is in restofline */
- X /* first extract the condition */
- X i = 0;
- X while (restofline[i] != '\0' && restofline[i] != '(') i++;
- X i++; /* to skip the '(' */
- X j = 0;
- X while (restofline[i] != ')' ) {
- X templine[j] = restofline[i];
- X i++;
- X j++;
- X }
- X templine[j] = '\0';
- X /* i is at the ')' in restofline */
- X /* templine contains the condition */
- X i++;
- X j = 0;
- X while (restofline[i] != '\0') {
- X temp1line[j] = restofline[i];
- X i++;
- X j++;
- X }
- X temp1line[j] = '\0';
- X /* now temp1line contains the macro to be executed if
- X the condition is true */
- X if (Beval(templine))
- X procmacro (temp1line,ifile,ofile);
- X
- X }
- X else if (streq(cmd[0],"in") ) { /* left margin */
- X brek(ifile,ofile);
- X setparm(&LMARGIN,atype,DOTSCHAR*value,DEFLMARGIN,0,HUGE);
- X }
- X else if (streq(cmd[0],"it") ) { /* italicize */
- X setparm(&ITALCNT,atype,value,DEFCOUNT,0,HUGE);
- X }
- X else if (streq(cmd[0],"ju") ) { /* right justify */
- X brek(ifile,ofile);
- X RJUSTIFY = TRUE;
- X }
- X else if (streq(cmd[0],"lp") ) { /* label paragraph */
- X brek(ifile,ofile);
- X /* the label is in cmd[1] */
- X i = 0;
- X getword(templine,cmd[1],&i);
- X parseword(temp1line,templine,&wordlength,&chcnt,ifile,ofile);
- X i = 0;
- X j = 0;
- X while (temp1line[i] != '\0') {
- X if (temp1line[i] != SHIFTOUT) {
- X temp1line[j] = temp1line[i];
- X j++;
- X }
- X i++;
- X }
- X temp1line[j] = '\0';
- X if ( ShouldPrint ) {
- X if (FONTCHANGE) {
- X sprintf(temp2line,"%c*p%dX%s",ESC, TEMPINDENT + LMARGIN - IPARA,temp1line);
- X addbuf(temp2line);
- X sprintf(temp2line,"%c*p%dX",ESC, TEMPINDENT + LMARGIN );
- X addbuf(temp2line);
- X shadd = FALSE;
- X }
- X else {
- X sprintf(temp2line,"%s ",temp1line);
- X addbuf(temp2line);
- X shadd = FALSE;
- X }
- X }
- X }
- X else if (streq(cmd[0],"ls") ) { /* line spacing */
- X brek(ifile,ofile);
- X setparm (&LSPACE,atype,value,DEFLSPACE,0,HUGE);
- X }
- X else if (streq(cmd[0],"m2") ) { /* margin after header */
- X setparm(&MTWO,atype,value,48,0,HUGE);
- X }
- X else if (streq(cmd[0],"m3") ) { /* margin before footer */
- X setparm(&MTHREE,atype,value,24,0,HUGE);
- X }
- X else if (streq(cmd[0],"ne") ) { /* need valuen lines */
- X if (CURRY + MTHREE + value * VSPACE * LSPACE > (PAGELENGTH - BOTTOMMARGIN)) {
- X brek(ifile,ofile);
- X brpage(ifile,ofile);
- X }
- X }
- X else if (streq(cmd[0],"nf") ) { /* no fill mode */
- X brek(ifile,ofile);
- X FILLMODE = FALSE;
- X }
- X else if (streq(cmd[0],"nj") ) { /* do not justify right margin */
- X brek(ifile,ofile);
- X RJUSTIFY = FALSE;
- X }
- X else if (streq(cmd[0],"pc") ) { /* page character to c */
- X PAGECHAR = cmd[1][0];
- X }
- X else if (streq(cmd[0],"pl") ) { /* page length */
- X setparm(&PAGELENGTH,atype,value,DEFPAGELENGTH,0,HUGE);
- X }
- X else if (streq(cmd[0],"pm") ) { /* set paragraph label margin */
- X brek(ifile,ofile);
- X setparm(&IPARA,atype,value * DOTSCHAR,10*DOTSCHAR,0,HUGE);
- X }
- X else if (streq(cmd[0],"rj") ) {/* right margin justified, left ragged */
- X fprintf(stderr,"right margin justified, left ragged not yet implemented\n");
- X exit(1);
- X brek(ifile,ofile);
- X }
- X else if (streq(cmd[0],"rm") ) { /* set right margin */
- X brek(ifile,ofile);
- X setparm(&RMARGIN,atype,DOTSCHAR*value,DEFRMARGIN,0,HUGE);
- X }
- X else if (streq(cmd[0],"rt") ) { /* reset traps */
- X cleantraps();
- X }
- X else if (streq(cmd[0],"so") ) { /* source a file */
- X tempfile = fopen(cmd[1],"r");
- X if (tempfile == NULL) {
- X fprintf(stderr,"error in 'so' command: file %s not found\n",cmd[1]);
- X exit(1);
- X }
- X else {
- X procfile(tempfile,ofile);
- X fclose(tempfile);
- X }
- X }
- X else if (streq(cmd[0],"sp") ) { /* space value lines */
- X brek(ifile,ofile);
- X if (CLEANPAGE)
- X puthead(ifile,ofile);
- X if (value == 0)
- X value = 1;
- X for (i = 1; i <= value; i++)
- X finishline(ifile,ofile);
- X }
- X else if (streq(cmd[0],"ti") ) { /* temporary indent */
- X brek(ifile,ofile);
- X setparm(&TEMPINDENT,atype,DOTSCHAR*value,0,-HUGE,HUGE);
- X }
- X else if (streq(cmd[0],"tl") ) { /* define title string */
- X expand(temp1line,restofline);
- X title(templine,temp1line,LMARGIN,RMARGIN,TDLIM,&cnt,tfor,ifile,ofile);
- X /* just interpolate it in for now */
- X append(templine,cnt);
- X }
- X else if (streq(cmd[0],"tf") ) { /* redefine title string */
- X for (l = 0; l < FNUMBER; l++)
- X tfor[l] = 'x';
- X if (cmd[1][0] == '\0') { /* return to default */
- X strcpy(tfor,"lcr");
- X }
- X else { /* get it from the arguments */
- X l = 1;
- X while (cmd[l][0] != '\0') {
- X tfor[l - 1] = cmd[l][0];
- X l++;
- X }
- X tfor[l - 1] = '\0';
- X
- X }
- X }
- X else if (streq(cmd[0],"tm") ) { /* transparent mode */
- X brek(ifile,ofile);
- X outselect = 't';
- X/* transparent mode */
- X{
- X char xch;
- X int xquit;
- X
- X xquit = FALSE;
- X
- X while ( (xch = getc(ifile)) != EOF && !xquit) {
- X if (xch == '\n') { /* we have a newline, so must check what comes next */
- X xch = getc(ifile);
- X /* it could be EOF !*/
- X if (xch == EOF) { /* the file ended with a newline */
- X fprintf(ofile,"\n");
- X xquit = TRUE;
- X }
- X else if (xch == CMDCHAR ){ /* if we have a CMDCHAR we may be in business */
- X xch = getc(ifile);
- X /* be sure it isn't an EOF */
- X if (xch == EOF) { /* file ended with "\nCMDCHAR" */
- X fprintf(ofile,"\n%c",CMDCHAR);
- X xquit = TRUE;
- X }
- X else { /* we now have "\nCMDCHAR" followed by something real */
- X if (xch == 'e') { /* wow --- getting close */
- X xch = getc(ifile);
- X /* is it? is it? a "t" ?*/
- X if (xch == EOF) { /* nuts */
- X fprintf(ofile,"\n%ce",CMDCHAR);
- X xquit = TRUE;
- X }
- X else if (xch == 't') { /* GOT IT! Yea! */
- X
- X xquit = TRUE;
- X }
- X else { /* gloom! */
- X fprintf(ofile,"\n%ce%c",CMDCHAR,xch);
- X }
- X }
- X else { /* broken heart */
- X fprintf(ofile,"\n%c%c",CMDCHAR,xch);
- X }
- X }
- X
- X }
- X else { /* not a CMDCHAR -- just copy \n and the char to the output */
- X fprintf(ofile,"\n%c",xch);
- X }
- X }
- X else { /* just copy the character to output */
- X putc(xch,ofile);
- X }
- X
- X } /* of while loop */
- X
- X /* at end of the loop output a newline */
- X putc('\n',ofile);
- X
- X
- X
- X}
- X /* end of transparent mode */
- X outselect = 'f';
- X }
- X else if (streq(cmd[0],"vr") ) { /* vertical rule */
- X fprintf(stderr,"vertical rule not yet implemented\n");
- X exit(1);
- X }
- X else if (streq(cmd[0],"vs") ) { /* set vertical spacing */
- X brek(ifile,ofile);
- X setparm(&VSPACE,atype,value,10,0,HUGE);
- X if (FONTCHANGE) {
- X sprintf(temp2line,"%c&l%dC",ESC,VSPACE);
- X putout(ofile,temp2line);
- X }
- X }
- X else if (streq(cmd[0],"ul") ) { /* underline n lines */
- X setparm(&ULCOUNT,atype,value,DEFCOUNT,0,HUGE);
- X }
- X else if (streq(cmd[0],"wh") ) { /* set trap */
- X /* cmd[1] has the location, and
- X cmd[2] has the name of the macro to invoke at
- X that location */
- X /* compute the locations as measured in 'dots' */
- X /* so that ".wh 48 NP" sets a trap (NP) 48 dots (1 inch)
- X from the top */
- X atype = argtype(cmd[1]);
- X expndreg(templine,cmd[1]);
- X value = argval(templine);
- X if (atype == -1)
- X value = PAGELENGTH - BOTTOMMARGIN - value;
- X else
- X value = TOPMARGIN + value;
- X deftrap(cmd[2], value, &traplist);
- X }
- X else if (streq(cmd[0],".") ) { /* a comment */
- X }
- X else { /* maybe it's a macro */
- X procmacro(s,ifile,ofile);
- X }
- X
- X
- X
- X
- X
- X} /* of command processor */
- X
- X
- X/* this function determines the type of an argument in a command line */
- X/* if the argument represents a relative change, it returns
- X 1 or -1. If the argument is absolute, it returns 0.
- X If the argument is null, it returns -2. */
- X
- Xint argtype (s)
- Xchar s[];
- X{
- X if (s[0] == '+')
- X return 1;
- X else if (s[0] == '-')
- X return -1;
- X else if (s[0] == '\0')
- X return -2; /* argument not present */
- X else
- X return 0;
- X}
- X
- X/* function to get the absolute value of the numeric value of an argument */
- Xint argval(s)
- X{
- X int v;
- X v = atoi(s);
- X if (v < 0)
- X v = -v;
- X return v;
- X}
- X
- X/* function to set parameters */
- Xint setparm(sparm,satype,svalue,sdflt,smin,smax)
- Xint *sparm,satype,svalue,sdflt,smin,smax;
- X{
- X if (satype == 1)
- X *sparm = *sparm + svalue;
- X else if (satype == -1)
- X *sparm = *sparm - svalue;
- X else if (satype == -2) /* not present */
- X *sparm = sdflt;
- X else if (satype == 0 )
- X *sparm = svalue;
- X *sparm = (*sparm > smax ? smax : *sparm);
- X *sparm = (*sparm < smin ? smin : *sparm);
- X
- X}
- END_OF_FILE
- if test 13945 -ne `wc -c <'source/command.c'`; then
- echo shar: \"'source/command.c'\" unpacked with wrong size!
- fi
- # end of 'source/command.c'
- fi
- if test -f 'source/init.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'source/init.c'\"
- else
- echo shar: Extracting \"'source/init.c'\" \(5910 characters\)
- sed "s/^X//" >'source/init.c' <<'END_OF_FILE'
- X/* this file contains all initializations */
- X
- X#include <stdio.h>
- X
- X#include <ctype.h>
- X
- X#include "defs.h"
- X#include "externs.c"
- XFILE *tempfile,*fopen();
- X
- XVOID init()
- X{
- X
- X int i;
- X char filename[50];
- X char dummy[50];
- X
- X FONTCHANGE = TRUE; /* do emit all font changes */
- X FIRSTPAGE = 1; /* first page to print */
- X LASTPAGE = HUGE; /* last page to print */
- X FORMFEED = TRUE; /* use formfeeds to go to next page */
- X SCANONLY = FALSE; /* do not just scan the text for errors */
- X TABSTOPS = 8; /* tabs every 8 spaces */
- X outbuf[0] = '\0'; /* initialize the buffer */
- X obufpos = 0;
- X macline[0] = '\0';
- X expstr[0] = '\0';
- X
- X /* registers */
- X REG('#') = 1; /* start at page 1 */
- X REG('A') = 2; /* the next page */
- X REG('B') = 24; /* bottom margin of 24 dots */
- X REG('C') = 0; /* center this many lines */
- X REG('D') = 0; /* vertical length of last diversion */
- X REG('E') = 0; /* italicize next n lines */
- X REG('F') = 0; /* current font */
- X REG('G') = 0; /* boldface next n lines */
- X REG('H') = TRUE; /* justify lines */
- X REG('I') = TRUE; /* start in FILLMODE = TRUE */
- X REG('J') = '/'; /* a SLASH mark */
- X REG('L') = 300; /* left margin of 300 dots - 1 inch */
- X REG('M') = 0; /* temporary indent */
- X REG('O') = '#'; /* page character */
- X REG('P') = 480; /* page length */
- X REG('Q') = 0; /* number of printable characters in outbuf */
- X REG('R') = 2100; /* right margin of 2100 dots - 7 inches */
- X REG('S') = 1; /* line spacing */
- X REG('T') = 0; /* top margin of 0 dots */
- X REG('U') = 30; /* width of a space character in dots */
- X REG('V') = 10; /* current vertical spacing */
- X REG('W') = 10 * DOTSCHAR; /* indented paragraph start in characters */
- X REG('X') = 0; /* current horizontal position */
- X REG('Y') = REG('T'); /* current vertical position */
- X REG('Z') = FALSE; /* underline state */
- X REG('!') = 8; /* tabstops every 8 characters */
- X REG('_') = 24; /* margin before footer */
- X REG('^') = 48; /* margin after header */
- X
- X /* initialize the macro list */
- X macrolist = NULL;
- X
- X
- X
- X /* define headers and footers */
- X /* default title formats */
- X for (i = 0; i < FNUMBER; i++)
- X tfor[i] = 'x';
- X tfor[0] = 'l';
- X tfor[1] = 'c';
- X tfor[2] = 'r';
- X strcpy(header," ");
- X strcpy(footer,"/page #/");
- X
- X
- X outselect = 'f'; /* select forprint as the output function */
- X
- X/* fonts */
- X
- X/* printer initialization to Times Roman Normal 12 point */
- Xstrcpy(filename,FONTSDIR);
- X#ifdef UNIX
- Xstrcat(filename,"/trn12");
- X#else
- Xstrcat(filename,"\\trn12");
- X#endif
- X
- Xtempfile = fopen(filename,"r");
- Xfscanf(tempfile,"%s",prinit);
- X/* note, each font initialization string contains several
- X letters 'E', which must be replaced by ESC characters */
- Xi = 0;
- Xwhile (prinit[i] != '\0') {
- X if (prinit[i] == 'E')
- X prinit[i] = ESC;
- X i++;
- X}
- X
- Xstrcpy(cfont,prinit);
- Xfor (i = 32; i <= 126; i++)
- X fscanf(tempfile,"%d",&H12nl[i]);
- Xfclose(tempfile);
- X
- X
- X/* Times Roman 12 point bold character length array */
- Xstrcpy(filename,FONTSDIR);
- X#ifdef UNIX
- Xstrcat(filename,"/trb12");
- X#else
- Xstrcat(filename,"\\trb12");
- X#endif
- X
- Xtempfile = fopen(filename,"r");
- Xfscanf(tempfile,"%s",dummy);
- Xfor (i = 32; i <= 126; i++)
- X fscanf(tempfile,"%d",&H12bl[i]);
- Xfclose(tempfile);
- X
- X
- X
- X/* character length array for Times Roman 12 point italics */
- Xstrcpy(filename,FONTSDIR);
- X#ifdef UNIX
- Xstrcat(filename,"/tri12");
- X#else
- Xstrcat(filename,"\\tri12");
- X#endif
- Xtempfile = fopen(filename,"r");
- Xfscanf(tempfile,"%s",dummy);
- Xfor (i = 32; i <= 126; i++)
- X fscanf(tempfile,"%d",&H12il[i]);
- Xfclose(tempfile);
- X
- X
- X /* fixed Courier 12 point */
- Xfor (i = 32; i <= 126; i++)
- X C12nl[i] = 30;
- X
- X
- X/* Presentation 18 point */
- Xfor (i = 32; i <= 126; i++)
- X P18bl[i] = 46;
- X
- Xsprintf(Pres,"%c&10O%c(0U%c(sp6.5h18vs1b11T",ESC,ESC,ESC);
- X
- X/* Helv Nm 6 point */
- X
- XH6nl[32] = 6; /* ' ' */
- XH6nl[33] = 11; /* '!' */
- XH6nl[34] = 9; /* '"' */
- XH6nl[35] = 16; /* '#' */
- XH6nl[36] = 15; /* '$' */
- XH6nl[37] = 23; /* % */
- XH6nl[38] = 18; /* & */
- XH6nl[39] = 6; /* single quote */
- XH6nl[40] = 7; /* ( */
- XH6nl[41] = 7; /* ) */
- XH6nl[42] = 10; /* * */
- XH6nl[43] = 15; /* + */
- XH6nl[44] = 8; /* , */
- XH6nl[45] = 15; /* - */
- XH6nl[46] = 8; /* . */
- XH6nl[47] = 11; /* / */
- XH6nl[48] = 15; /* 0 */
- XH6nl[49] = 15; /* 1 */
- XH6nl[50] = 15; /* 2 */
- XH6nl[51] = 15; /* 3 */
- XH6nl[52] = 15; /* 4 */
- XH6nl[53] = 15; /* 5 */
- XH6nl[54] = 15; /* 6 */
- XH6nl[55] = 15; /* 7 */
- XH6nl[56] = 15; /* 8 */
- XH6nl[57] = 15; /* 9 */
- XH6nl[58] = 8; /* : */
- XH6nl[59] = 8; /* ; */
- XH6nl[60] = 15; /* < */
- XH6nl[61] = 15; /* = */
- XH6nl[62] = 15; /* > */
- XH6nl[63] = 16; /* ? */
- XH6nl[64] = 24; /* @ */
- XH6nl[65] = 18; /* A */
- XH6nl[66] = 21; /* B */
- XH6nl[67] = 20; /* C */
- XH6nl[68] = 22; /* D */
- XH6nl[69] = 19; /* E */
- XH6nl[70] = 17; /* F */
- XH6nl[71] = 21; /* G */
- XH6nl[72] = 22; /* H */
- XH6nl[73] = 8; /* I */
- XH6nl[74] = 16; /* J */
- XH6nl[75] = 17; /* K */
- XH6nl[76] = 17; /* L */
- XH6nl[77] = 25; /* M */
- XH6nl[78] = 20; /* N */
- XH6nl[79] = 20; /* O */
- XH6nl[80] = 17; /* P */
- XH6nl[81] = 20; /* Q */
- XH6nl[82] = 20; /* R */
- XH6nl[83] = 18; /* S */
- XH6nl[84] = 16; /* T */
- XH6nl[85] = 20; /* U */
- XH6nl[86] = 18; /* V */
- XH6nl[87] = 26; /* W */
- XH6nl[88] = 17; /* X */
- XH6nl[89] = 16; /* Y */
- XH6nl[90] = 18; /* Z */
- XH6nl[91] = 8; /* [ */
- XH6nl[92] = 11; /* \ */
- XH6nl[93] = 8; /* ] */
- XH6nl[94] = 14; /* ^ */
- XH6nl[95] = 14; /* _ */
- XH6nl[96] = 6; /* ` */
- XH6nl[97] = 14; /* a */
- XH6nl[98] = 17; /* b */
- XH6nl[99] = 14; /* c */
- XH6nl[100] =17; /* d */
- XH6nl[101] = 15; /* e */
- XH6nl[102] = 11; /* f */
- XH6nl[103] = 15; /* g */
- XH6nl[104] = 18; /* h */
- XH6nl[105] = 7; /* i */
- XH6nl[106] = 8; /* j */
- XH6nl[107] = 15; /* k */
- XH6nl[108] = 7; /* l */
- XH6nl[109] = 22; /* m */
- XH6nl[110] = 15; /* n */
- XH6nl[111] = 16; /* o */
- XH6nl[112] = 16; /* p */
- XH6nl[113] = 17; /* q */
- XH6nl[114] = 10; /* r */
- XH6nl[115] = 14; /* s */
- XH6nl[116] = 10; /* t */
- XH6nl[117] = 15; /* u */
- XH6nl[118] = 14; /* v */
- XH6nl[119] = 22; /* w */
- XH6nl[120] = 14; /* x */
- XH6nl[121] = 15; /* y */
- XH6nl[122] = 13; /* z */
- XH6nl[123] = 15; /* { */
- XH6nl[124] = 0; /* | */
- XH6nl[125] = 15; /* } */
- XH6nl[126] = 0; /* ~ */
- X
- X
- Xdefl = &H12nl[0];
- Xclen = defl;
- X
- X}
- X
- X
- END_OF_FILE
- if test 5910 -ne `wc -c <'source/init.c'`; then
- echo shar: \"'source/init.c'\" unpacked with wrong size!
- fi
- # end of 'source/init.c'
- fi
- if test -f 'source/io.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'source/io.c'\"
- else
- echo shar: Extracting \"'source/io.c'\" \(7600 characters\)
- sed "s/^X//" >'source/io.c' <<'END_OF_FILE'
- X/* this file contains the output function */
- X
- X#include <stdio.h>
- X#include <ctype.h>
- X#include "defs.h"
- X#include "externs.c"
- X
- Xchar temp3line[MAXSTR];
- X
- X
- X
- X
- X
- X/* transparent print function */
- XVOID tprint(ifile,ofile,diff)
- XFILE *ifile,*ofile;
- Xint diff;
- X{
- X int i;
- X char temp2line[MAXSTR];
- X
- X
- X if (ShouldPrint && FONTCHANGE && ((TEMPINDENT + LMARGIN) > 0) ) {
- X sprintf(temp2line,"%c*p+%dX",ESC,TEMPINDENT+LMARGIN);
- X putout(ofile,temp2line);
- X }
- X TEMPINDENT = 0;
- X
- X i = 0;
- X while (ShouldPrint && outbuf[i] != '\0') {
- X if (outbuf[i] != SHIFTOUT)
- X putit(outbuf[i],ofile);
- X i++;
- X }
- X finishline(ifile,ofile);
- X}
- X
- X
- X
- X/* function to get a whole line from the input file */
- XVOID getline(s,f)
- Xchar s[];
- XFILE *f;
- X{
- X int count;
- X char c;
- X char temp[MAXSTR];
- X int i,j;
- X int where;
- X
- X count = 0;
- X while ( ((c = getc(f)) != '\n') && c != EOF) {
- X s[count] = c;
- X count++;
- X }
- X s[count] = '\0';
- X strcpy(temp,s);
- X
- X /* remove any tabs if we should */
- X if ( TABSTOPS > 0 ) {
- X i = 0;
- X j = 0;
- X where = 0;
- X while (s[i] != '\0') {
- X if (s[i] == 0x09) {
- X if (where % TABSTOPS == 0 ) {
- X temp[j] = ' ';
- X j++;
- X where++;
- X }
- X while (where % TABSTOPS != 0) {
- X temp[j] = ' ';
- X j++;
- X where++;
- X }
- X }
- X else {
- X temp[j] = s[i];
- X j++;
- X where++;
- X }
- X i++;
- X }
- X temp[j] = '\0';
- X }
- X strcpy(s,temp);
- X
- X if (c == EOF)
- X return EOF;
- X else
- X return count;
- X}
- X
- X
- X/* function to end a line */
- XVOID endln()
- X{
- X int i;
- X
- X /* eat any white space off the right hand end of outbuf */
- X i = obufpos - 1;
- X while (i > 0 && ( isspace(outbuf[i]) || outbuf[i] == SHIFTOUT) ) {
- X if (outbuf[i] != SHIFTOUT) {
- X CURRX = CURRX - length(outbuf[i]);
- X CHARCNT = CHARCNT - 1;
- X }
- X obufpos--;
- X i--;
- X }
- X
- X outbuf[obufpos] = '\0'; /* be sure to end the buffer properly */
- X}
- X
- X
- X/* print the output buffer, spreading it out by diff */
- XVOID forprint(ifile,f,diff)
- XFILE *ifile,*f;
- Xint diff;
- X{
- X int perchar,more,extra, thismany;
- X int i;
- X char temp2line[MAXSTR];
- X
- X
- X i = 0;
- X
- X /* the line length we desire is diff */
- X
- X /* number of extra dots that need to be placed with each character */
- X extra = diff - CURRX; /* we need this many extra dots */
- X more = 0;
- X if (CHARCNT > 1) {
- X perchar = extra/(CHARCNT - 1);
- X more = extra - (extra/(CHARCNT -1)) * (CHARCNT -1); /* the left over few */
- X }
- X else
- X perchar = 0;
- X
- X if ((FILLMODE == FALSE) || (RJUSTIFY == FALSE) ) {
- X more = 0;
- X perchar = 0;
- X }
- X
- X
- X /* first output the left margin and the temporary indent, if any */
- X if (ShouldPrint && FONTCHANGE && ( (TEMPINDENT + LMARGIN) > 0) ) {
- X sprintf(temp2line,"%c*p%dX",ESC,TEMPINDENT+LMARGIN);
- X putout(f,temp2line);
- X }
- X TEMPINDENT = 0;
- X if (perchar < 0 )
- X perchar = 0;
- X i = 0;
- X while (ShouldPrint && outbuf[i] != '\0') {
- X
- X if (outbuf[i] == SHIFTOUT) {
- X /* this many extra */
- X thismany = perchar;
- X if (more > 0 ) {
- X /* one more dot */
- X thismany++;
- X more--;
- X }
- X if (FONTCHANGE && thismany > 0) {
- X sprintf(temp2line,"%c*p+%dX",ESC,thismany);
- X putout(f,temp2line);
- X }
- X }
- X else
- X if (outbuf[i] != ANCHOR) putit(outbuf[i],f);
- X i++;
- X }
- X
- X if (outbuf[0] != '\0' ) finishline(ifile,f);
- X CURRX = 0;
- X diff = 0;
- X}
- X
- X/* turn up a new page */
- XVOID brpage(ifile,f)
- XFILE *ifile,*f;
- X{
- X /* check for traps between here and end of page */
- X checktraps(PAGELENGTH - BOTTOMMARGIN,ifile,f);
- X putfoot(ifile,f);
- X if ( FORMFEED)
- X if (ShouldPrint) putit(FF,f);
- X else {
- X if (ShouldPrint) {
- X while (CURRY <= PAGELENGTH ) {
- X putit('\n',f);
- X CURRY = CURRY + VSPACE;
- X }
- X CURRY = 0;
- X while (CURRY < TOPMARGIN) {
- X putit('\n',f);
- X CURRY = CURRY + VSPACE;
- X }
- X }
- X }
- X cleantraps();
- X CURRY = TOPMARGIN;
- X CURRPAGE = CURRPAGE + 1;
- X if (CURRPAGE > LASTPAGE) exit(0);
- X CLEANPAGE = TRUE;
- X if (CURRPAGE >= FIRSTPAGE) ShouldPrint = TRUE;
- X NEXTPAGE = CURRPAGE + 1;
- X}
- X
- X
- XVOID nullprint(ifile,ofile,diff)
- XFILE *ifile,*ofile;
- Xint diff;
- X{
- X /* do nothing */
- X}
- X
- X
- XgotoXY(ifile,ofile,x,y)
- XFILE *ifile,*ofile;
- Xint x,y;
- X{
- X /* x is measured in dots, 300 per inch, horizontally,
- X y is measured in dots, 48 per vertical inch */
- X /* measured from absolute top left margin */
- X
- X char str[MAXSTR];
- X int j;
- X
- X str[0] = '\0';
- X
- X if (FONTCHANGE)
- X sprintf(str,"%c&a%dV%c*p%dX",ESC,y*15,ESC,x);
- X j = 0;
- X while (str[j] != '\0') {
- X outbuf[obufpos] = str[j];
- X j++;
- X obufpos++;
- X }
- X
- X CURRY = y;
- X CURRX = x;
- X}
- X
- X
- X
- X
- XgotoX(ifile,ofile,s)
- XFILE *ifile,*ofile;
- Xchar s[];
- X{
- X /* x is measured in dots, 300 per inch, horizontally */
- X
- X
- X char str[MAXSTR];
- X int j;
- X
- X j = abs(atoi(s));
- X str[0] = '\0';
- X
- X if (s[0] == '-')
- X sprintf(str,"%c*p-%dX",ESC,j);
- X else if (s[0] == '+')
- X sprintf(str,"%c*p+%dX",ESC,j);
- X else
- X sprintf(str,"%c*p%dX",ESC,j);
- X j = 0;
- X if (!FONTCHANGE)
- X str[0] = '\0';
- X while (str[j] != '\0') {
- X outbuf[obufpos] = str[j];
- X j++;
- X obufpos++;
- X }
- X
- X}
- X
- X
- X
- X
- X
- X
- XgotoY(ifile,ofile,s)
- XFILE *ifile,*ofile;
- Xchar s[];
- X{
- X /* y is measured in dots, 48 per inch, vertically */
- X
- X
- X char str[MAXSTR];
- X int j;
- X
- X j = abs(atoi(s)) * 15;
- X str[0] = '\0';
- X
- X if (s[0] == '-')
- X sprintf(str,"%c&a-%dV",ESC,j); /* the command is in decipoints */
- X else if (s[0] == '+')
- X sprintf(str,"%c&a+%dV",ESC,j);
- X else
- X sprintf(str,"%c&a%dV",ESC,j);
- X j = 0;
- X if (!FONTCHANGE)
- X str[0] = '\0';
- X while (str[j] != '\0') {
- X outbuf[obufpos] = str[j];
- X j++;
- X obufpos++;
- X }
- X
- X}
- X
- X
- X
- X/* put the footer on the page */
- Xputfoot(ifile,ofile)
- XFILE *ifile,*ofile;
- X{
- X char temp[MAXSTR], temp1[MAXSTR];
- X int tcnt;
- X tcnt = 0;
- X temp1[0] = '\0';
- X if (footer[0] != '\0') {
- X brek(ifile,ofile);
- X gotoXY(ifile,ofile,LMARGIN,PAGELENGTH - BOTTOMMARGIN );
- X expand(temp,footer);
- X title(temp1,temp,LMARGIN,RMARGIN,TDLIM,&tcnt,"l c r",ifile,ofile);
- X append(temp1,tcnt);
- X outbuf[obufpos] = '\0';
- X CURRY = 0;
- X output(ifile,ofile,0);
- X }
- X}
- X
- X
- X/* put the header on the page */
- X
- Xputhead(ifile,ofile)
- XFILE *ifile, *ofile;
- X{
- X char temp[MAXSTR],temp1[MAXSTR];
- X int tcnt;
- X
- X CLEANPAGE = FALSE;
- X temp1[0] = '\0';
- X tcnt = 0;
- X CURRY = TOPMARGIN;
- X if (header[0] != '\0' && ShouldPrint && FONTCHANGE) {
- X sprintf(temp1,"%c*p%dX",ESC,LMARGIN);
- X rawout(ofile,temp1);
- X sprintf(temp1,"%c&a%dV",ESC,15 * TOPMARGIN);
- X rawout(ofile,temp1);
- X expand(temp,header);
- X title(temp1,temp,LMARGIN,RMARGIN,TDLIM,&tcnt,"l c r",ifile,ofile);
- X rawout(ofile,temp1);
- X sprintf(temp1,"\n");
- X rawout(ofile,temp1);
- X CURRY = CURRY + VSPACE;
- X }
- X if (MTWO != 0 && ShouldPrint && FONTCHANGE) {
- X sprintf(temp1,"%c*p%dX",ESC,LMARGIN);
- X rawout(ofile,temp1);
- X CURRY = CURRY + MTWO ;
- X }
- X if (ShouldPrint && FONTCHANGE) {
- X sprintf(temp1,"%c&a%dV",ESC,15 * CURRY);
- X rawout(ofile,temp1);
- X }
- X}
- X
- XVOID output(ifile,ofile,n)
- XFILE *ifile,*ofile;
- Xint n;
- X{
- X if (CLEANPAGE) {
- X CLEANPAGE = FALSE;
- X puthead(ifile,ofile);
- X }
- X
- X if (outselect == 'f') { /* formatted print */
- X forprint(ifile,ofile,n);
- X }
- X else if (outselect == 't') { /* transparent print */
- X tprint(ifile,ofile,n);
- X }
- X else if (outselect == 'n' ) { /* null print */
- X nullprint(ifile,ofile,n);
- X }
- X else if (outselect == 'd') { /* diversion */
- X }
- X else { /* default is formatted print */
- X forprint(ifile,ofile,n);
- X }
- X
- X}
- X
- X
- XVOID putout(f,s)
- XFILE *f;
- Xchar s[];
- X{
- X int i;
- X i = 0;
- X while (s[i] != '\0') {
- X putit(s[i],f);
- X i++;
- X }
- X
- X}
- X
- XVOID putit(c,f)
- Xchar c;
- XFILE *f;
- X{
- X
- X if (InDiversion) {
- X temp3line[tplace] = c;
- X tplace++;
- X if (c == '\n') {
- X tplace--;
- X temp3line[tplace] = '\0';
- X macaddline(macrolist,temp3line);
- X tplace = 0;
- X }
- X }
- X else
- X putc(c,f);
- X}
- X
- X
- XVOID rawout(f,s)
- XFILE *f;
- Xchar s[];
- X{
- X int i;
- X i = 0;
- X while (s[i] != '\0') {
- X if (s[i] != SHIFTOUT)
- X putc(s[i],f);
- X i++;
- X }
- X s[0] = '\0';
- X}
- X
- END_OF_FILE
- if test 7600 -ne `wc -c <'source/io.c'`; then
- echo shar: \"'source/io.c'\" unpacked with wrong size!
- fi
- # end of 'source/io.c'
- fi
- if test -f 'source/util.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'source/util.c'\"
- else
- echo shar: Extracting \"'source/util.c'\" \(4912 characters\)
- sed "s/^X//" >'source/util.c' <<'END_OF_FILE'
- X/* this file is all of the utility stuff */
- X
- X#include <stdio.h>
- X#include <ctype.h>
- X#include "defs.h"
- X#include "externs.c"
- X
- X
- X/* function to return the first printable character in a string */
- Xchar First(s)
- Xchar s[];
- X{
- X int i;
- X i = 0;
- X while ( (s[i] != '\0') && isspace(s[i] ) )
- X i++;
- X return s[i];
- X}
- X
- X
- X
- X/* compares two strings and returns TRUE if equal, FALSE if not */
- Xint streq(s,t)
- Xchar s[],t[];
- X{
- X return (strcmp(s,t) == 0);
- X}
- X
- X
- X
- X/* function to print error messages */
- XVOID error(s)
- Xchar s[];
- X{
- X fprintf(stderr,"ERROR: %s\n",s);
- X}
- X
- X
- X/* function to return whether or not a string is blank */
- Xint isblank(s)
- Xchar s[];
- X{
- X int i;
- X i = 0;
- X while (s[i] != '\0' && isspace(s[i]) && s[i] != EOF) {
- X i++;
- X }
- X return (s[i] == '\0' || s[i] == EOF);
- X
- X}
- X
- X
- X/* add the string sf to the front of a string, and the string sb to the
- X back of a string */
- XVOID addstr(s,sf,sb)
- Xchar s[],sf[],sb[];
- X{
- X char tempstr[MAXSTR];
- X tempstr[0] = '\0';
- X strcat(tempstr,sf);
- X strcat(tempstr,s);
- X strcat(tempstr,sb);
- X strcpy(s,tempstr);
- X}
- X
- X
- X/* this function takes a string, searches for the TDELIM, determines
- X how many fields there are in the string, and then forms a new
- X string within the given left and right margins. This new
- X string will have the left field left-justified, the right
- X field right-justified, and the center fields centered in
- X their respective spaces. May be a bear. */
- XVOID title(ostr,istr,lmargin,rmargin,delim,tcnt,fstr,ifile,f)
- Xchar ostr[],istr[];
- Xint lmargin,rmargin;
- Xchar delim;
- Xint *tcnt;
- XFILE *ifile, *f;
- Xchar fstr[]; /* the format string */
- X{
- X int i,j,k,l; /* for indexes */
- X int nbrfields, fnbr;
- X int width, extra;
- X int wlen, cnt;
- X int x;
- X char tstring[MAXSTR]; /* a temporary string */
- X char t2str[MAXSTR]; /* another temporary string */
- X char word[SHORTSTR], word1[SHORTSTR];
- X char tform[FNUMBER];
- X
- X ostr[0] = '\0';
- X *tcnt = 0;
- X for (l = 0; l < FNUMBER; l++)
- X tform[l] = 'x';
- X if (fstr[0] == '\0') { /* return to default */
- X tform[0] = 'l';
- X tform[1] = 'c';
- X tform[2] = 'r';
- X }
- X else { /* get it from fstr */
- X l = 0;
- X k = 0;
- X while (fstr[l] != '\0') {
- X while (isspace(fstr[l]) ) l++;
- X tform[k] = fstr[l];
- X k++;
- X l++;
- X }
- X
- X }
- X
- X /* find out how many fields there are by looking in tform */
- X nbrfields = 0;
- X i = 0;
- X while ( tform[i] != 'x' ) {
- X nbrfields++;
- X i++;
- X }
- X
- X width = (rmargin - lmargin) / nbrfields; /* width of each field */
- X extra = (rmargin - lmargin) - width * nbrfields; /* extra dots left over*/
- X
- X /* for each field, compute its length, do what I should with it,
- X and cat it to the ostr */
- X i = 0;
- X fnbr = 1;
- X while (istr[i] != '\0') {
- X
- X j = 0;
- X while (istr[i] != '\0' && istr[i] != delim) {
- X tstring[j] = istr[i];
- X i++;
- X j++;
- X }
- X tstring[j] = '\0';
- X x = width;
- X t2str[0] = '\0';
- X
- X j = 0;
- X while (tstring[j] != '\0') {
- X getword(word,tstring,&j);
- X parseword(word1,word,&wlen,&cnt,ifile,f);
- X *tcnt = *tcnt + cnt + 1;
- X x = x - wlen - length(' ');
- X strcat(t2str,word1);
- X strcat(t2str," ");
- X }
- X
- X
- X switch(tform[fnbr - 1]) {
- X case 'l': /* left justify */
- X sprintf(tstring,"%c*p+%dX",ESC,x);
- X strcat(ostr,t2str);
- X if (FONTCHANGE)
- X strcat(ostr,tstring);
- X break;
- X
- X case 'r': /* right justify */
- X sprintf(tstring,"%c*p+%dX",ESC,x);
- X if (FONTCHANGE)
- X strcat(ostr,tstring);
- X strcat(ostr,t2str);
- X break;
- X
- X case 'c':
- X default: /* center */
- X sprintf(tstring,"%c*p+%dX",ESC,x/2);
- X if (!FONTCHANGE)
- X tstring[0] = '\0';
- X strcat(ostr,tstring);
- X strcat(ostr,t2str);
- X strcat(ostr,tstring);
- X break;
- X
- X } /* of switch */
- X
- X if (istr[i] == delim) {
- X fnbr++;
- X i++; /* to skip the delimiter */
- X }
- X }
- X
- X
- X
- X} /* of title */
- X
- X
- X/* this function expands a line to take into account
- X the page character */
- XVOID expand(tempstr,s)
- Xchar tempstr[];
- Xchar s[];
- X{
- X char str[SHORTSTR];
- X int i,j,k;
- X
- X i = 0;
- X j = 0;
- X while (s[i] != '\0') {
- X if (s[i] == PAGECHAR) {
- X sprintf(str,"%d",CURRPAGE);
- X k = 0;
- X while (str[k] != '\0') {
- X tempstr[j] = str[k];
- X k++;
- X j++;
- X }
- X j--;
- X
- X }
- X else
- X tempstr[j] = s[i];
- X i++;
- X j++;
- X }
- X tempstr[j] = '\0';
- X}
- X
- X
- X
- X/* this function expands any registers in a string */
- Xexpndreg(cmd1,cmd2)
- Xchar cmd1[],cmd2[];
- X{
- X int i, j, k;
- X char hold[SHORTSTR];
- X i = 0;
- X j = 0;
- X while (cmd2[i] != '\0') {
- X if (cmd2[i] == '\\' && cmd2[i+1] == '(') {
- X i++;
- X if (cmd2[i] != '\0' && cmd2[i] == '(') { /* its a register */
- X i++;
- X while (cmd2[i] != '\0' && isspace(cmd2[i])) i++;
- X sprintf(hold,"%d",REG(cmd2[i]));
- X k = 0;
- X while (hold[k] != '\0') {
- X cmd1[j] = hold[k];
- X k++;
- X j++;
- X }
- X
- X }
- X else { /* who knows -- just copy it ! */
- X cmd1[j] = cmd2[i];
- X i++;
- X j++;
- X }
- X }
- X else {
- X cmd1[j] = cmd2[i];
- X i++;
- X j++;
- X }
- X }
- X cmd1[j] = '\0';
- X}
- X
- X
- Xaddbuf(s)
- Xchar s[];
- X{
- X int i;
- X i = 0;
- X while (s[i] != '\0') {
- X outbuf[obufpos] = s[i];
- X obufpos++;
- X i++;
- X }
- X}
- X
- END_OF_FILE
- if test 4912 -ne `wc -c <'source/util.c'`; then
- echo shar: \"'source/util.c'\" unpacked with wrong size!
- fi
- # end of 'source/util.c'
- fi
- echo shar: End of archive 2 \(of 5\).
- cp /dev/null ark2isdone
- MISSING=""
- for I in 1 2 3 4 5 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 5 archives.
- rm -f ark[1-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
- --
- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
- Sterling Software, IMD UUCP: uunet!sparky!kent
- Phone: (402) 291-8300 FAX: (402) 291-4362
- Please send comp.sources.misc-related mail to kent@uunet.uu.net.
-