/********************************************************/ /* */ /* ROFF4, Version 1.60 */ /* */ /*(C) 1983,4 by Ernest E. Bergmann */ /* Physics, Building #16 */ /* Lehigh Univerisity */ /* Bethlehem, Pa. 18015 */ /* */ /* Permission is hereby granted for all commercial and */ /* non-commercial reproduction and distribution of this */ /* material provided this notice is included. */ /* */ /********************************************************/ /*FEB 19, 1984*/ /*Jan 15, 1984*/ #include #include /*June 27, 1983 eliminate directed input*/ char _doflag; /* flag if directed /O being used */ char **_nullpos; /*???*/ char _dobuf[BUFSIZ]; /* /O buffer used for direction */ char sav_out_file[20]; /*??? added to work with dioinit and dioflush() ???*/ int debug; int unbug; int PAGESTOP; int JUSTIFY; int FFEED; int FIRSTPAGE,LASTPAGE;/*for selectively printing output*/ int SUPPRESS;/*if true,no output is passed by putchar()*/ #define STDERR stderr /* send error messages to console while in DIO */ #define STKSIZ 3 #define DEBUG ( debug != 0 ) #define UNBUG ( unbug != 0 ) #define HUGE 135 /* generally large number */ #define LSZ 255 /* line buffer size*/ #define MAXLINE 255 #define MAXTAB 30 #define MTABSZ 200 #define STABSZ 100 #define RTABSZ 10 #define COMMAND '.' /* all commands starts with this */ #define CONSOLE -5 /* one of output options */ #define PRINTER -4 /* another */ #define FLE -3 #define UNKNOWN -1 /* returned if doesn't recg. command */ #define NO_VAL -32760 /* returned when no argument w/commad */ #define WE_HAVE_A_WORD 1 /* returned by getwrd func. */ #define NO 0 #define YES 1 #define UNDERLINE '\137' #define CR 0x0D #define BACKSPACE '\b' #define NUMSIGN '#' /* for title strings */ #define NEWLINE '\n' #define TAB '\t' #define BLANK ' ' #define FORMF 0x0C /* formfeed for printer */ #define SQUOTE 0x27 /* single quote */ #define DQUOTE 0x22 /* double quote */ #define TRSIZ 2000 /*size of TRTBL*/ #define CPMEOF 0x1A #define TRANSLATE 2 /* May 23, 1983*/ #define BLACK 1 #define WHITE 0 #define CONTROL -1 #define SENTINEL -2 #define HTAB -3 #define OTHERS -4 #define XCHAR '-' #define UCHAR '_' #define FI 1 /* fill lines */ #define TI 2 /* temporary indent */ #define BP 3 /* begin page */ #define BR 4 /* causes break */ #define CE 5 /* center line(s) */ #define IN 7 /* left indent */ #define LS 8 /* line spacing */ #define NF 9 /* no fill */ #define PL 10 /* set page length */ #define RM 11 /* set right margin */ #define SP 12 /* add blank line(s) */ #define ST 13 /* stop(pause) at page start?*/ #define FO 14 /* footer title */ #define HE 15 /* header title */ #define M1 16 /* top margin */ #define M2 17 /* second top margin */ #define M3 18 /* first bottom margin */ #define M4 19 /* bottom-most margin */ #define IG 20 /* "ignore";comments,Nov 6,82*/ #define NE 21 /* "need";Nov 7,82*/ #define FF 22 /* "formfeed";Nov 10*/ #define SC 23 /* "space character";Nov13*/ #define OW 24 /* "output width";Nov 13*/ #define TS 25 /* "tabsize";Nov 13*/ #define EH 26 /* "even headers";Nov 14*/ #define OH 27 /* "odd headers"*/ #define EF 28 /* "even footers"*/ #define OF 29 /* "odd footers"*/ #define AB 30 /* "abort";Nov 15*/ #define DB 31 /* "debug"*/ #define TC 32 /* "translation flag char"*/ #define TR 33 /* "def translation string"*/ #define CF 34 /* Dec 4:control flag char*/ #define IC 35 /* insert character */ #define OU 36 /* output */ #define JU 37 /* right justify?*/ #define NJ 38 /* don't right justify*/ #define WH 39 /* whole line spacing code*/ #define FR 40 /* fractional spacing,code*/ #define DS 41 /*define string*/ #define DM 42 /*define macro*/ #define EM 43 /*end macro*/ #define RG 44 /*register variable*/ #define DI 45 /*diversion*/ #define ED 46 /*end diversion*/ #define SO 47 /*"source", include*/ #define PC 48 /*printer control definition*/ #define SA 49 /*"say" inline msg to console*/ #define BJ 50 /*break with rightjustification of current line*/ int XFILL[STKSIZ]; /*convert global value to a stack*/ #define FILL XFILL[0] /* set to YES or NO */ int XLSVAL[STKSIZ]; #define LSVAL XLSVAL[0] /*LINne spacing value -> default will be 1 */ int TIVAL; /* temporary indent -> default 0 */ int XINVAL[STKSIZ]; #define INVAL XINVAL[0] /* left indent -> default 0 */ int XRMVAL[STKSIZ]; #define RMVAL XRMVAL[0] /* right margin -> default PAGEWIDTH */ int CEVAL; /* set equal to number of lines to be centered */ int XTCVAL[STKSIZ]; #define TCVAL XTCVAL[0] /*translation flag char*/ /* default is 0 */ int SPVAL; /* blank lines to be spaced down */ int CURPAG; /* current output page number; init = 0 */ int NEWPAG; /* next output page number; init = 1 */ int VLINENO; /* virtual (intended) line advances on page, see vadv()*/ int FVLINENO; /* + line fraction */ int PLINENO; /* printer's actual line advances on page, see padv()*/ int FPLINENO; /* + line fraction */ int XPLVAL[STKSIZ]; #define PLVAL XPLVAL[0] /* page length in lines */ int XM1VAL[STKSIZ]; #define M1VAL XM1VAL[0] /* margin before& including header in lines*/ int XM2VAL[STKSIZ]; #define M2VAL XM2VAL[0] /* margin after header in lines*/ int XM3VAL[STKSIZ]; #define M3VAL XM3VAL[0] /* margin after last text line in lines*/ int XM4VAL[STKSIZ]; #define M4VAL XM4VAL[0] /* bottom margin, including footer in lines*/ int BOTTOM; /* end of text area in lines;start of M3+M4 */ int XSCVAL[STKSIZ]; #define SCVAL XSCVAL[0] /* space character*/ int XOWVAL[STKSIZ]; #define OWVAL XOWVAL[0] /* output device width*/ int XTABSIZ[STKSIZ]; #define TABSIZ XTABSIZ[0] /* spacing of tabstops*/ int SENTENCE; /* Nov 20*/ int XCFVAL[STKSIZ]; #define CFVAL XCFVAL[0] /*Dec 4:control flag character value*/ int XICVAL[STKSIZ]; #define ICVAL XICVAL[0] /*insert character*/ char LINE[ LSZ ]; /*input line buffer, Nov 26*/ char EHEAD[ LSZ ],*EH2,*EH3; /* even header title */ char OHEAD[ LSZ ],*OH2,*OH3; /* odd header title */ char EFOOT[ LSZ ],*EF2,*EF3; /* even footer title */ char OFOOT[ LSZ ],*OF2,*OF3; /* even footer title */ /* defaults for global parameters */ #define FI_DEF 1 #define LS_DEF 1 #define IN_DEF 0 #define RM_DEF 60 #define TI_DEF 0 #define CE_DEF 1 #define UL_DEF -1 #define M1_DEF 2 #define M2_DEF 2 #define M3_DEF 2 #define M4_DEF 2 #define PL_DEF 66 #define FF_DEF YES /* .ff defaults to "on" */ #define FF_INI NO /* initial setting*/ #define SC_INI BLANK #define OW_INI 60 /*initial output width*/ #define TS_DEF 8 /*standard tabsize*/ #define TC_DEF '~' /*translation flag default*/ #define CF_DEF '^' /*Dec 4*/ #define IC_DEF '\\' #define CW_DEF 12 /* 12/120" */ #define JU_INI YES /*right justification*/ #define REGDEF 1 /*default for register var.*/ /*when .rg has no numeric arg*/ int DIR; /* for "spreading" of lines */ int OUTWRDS; /* no. words in OUTBUF; init = 0 */ char OUTBUF[ LSZ ]; /*lines to be filled collected here */ int OUTW; /*current display width of OUTBUF*/ int OUTPOS; /* =strlen(OUTBUF) */ int WTOP,LTOP,OUTTOP; /*zero|negative;levels of subscripts*/ int WBOT,LBOT,OUTBOT; /*zero|positive;levels of subscripts*/ int OLDLN; /*position of previous main line*/ int OLDBOT; /*OUTBOT for previous line;reset each page*/ int FRQ,FRVAL; /* fractional line?, what fraction size*/ char *OUSTRING; char *FRSTRING; /* ^ to code for fractional spacing*/ char *WHSTRING; /* ^ to code for whole line spacing*/ char *CPTR[128-' ']; /*pointer table for print control*/ char *TPTR[128-' ']; /*pointer table for translation strings for char; initialize to null */ int CPTRNUM[128-' ']; int TPTRNUM[128-' ']; int FRNUM,WHNUM,OUNUM; char *PCHR; char TRTBL[TRSIZ]; /*holds translation strings*/ char *MTAB[MAXTAB]; char *STAB[MAXTAB]; char *RTAB[MAXTAB]; int RTABVAL[MAXTAB]; char *DTAB[MAXTAB]; char *TREND; /*^to end of above;init = TRTBL*/ int DLINK; /*^ head of diversion list*/ int *RLINK; /*^ head of register variable list*/ int *SLINK,*MLINK; /*points to head of linked string, macro lists*/ int MEND,DEND,SEND,REND; struct _buf *IOBUF; FILE *fp, *fopen(),*lfp; /*following added for buffered and formatted output: */ char OUTBUF2[LSZ]; /*for line to be output in fancy fmt*/ int BPOS,CP,PP; /*buffer,column,printer positions*/ char XBUF[LSZ]; /*strikout buffer*/ int XF,XCOL; /* " flag and column */ char UBUF[LSZ]; /*underline buffer*/ int UF,UCOL; /* " flag and column */ int FIRST; /*flag for first pass*/ char DBUF[LSZ]; /*double strike buffer*/ int DPOS; int OCNT; int MCNT; int BLKCNT; #define REVSCROLL FALSE #define CANBS FALSE #define BACKSIZE LSZ char BACKBUF[BACKSIZE]; int BINP; /*position in above;init to 0*/ #define BELL '\007' char KEYBD; /*boolean & prompt for keyboard input*/ char KLINE[MAXLINE]; /*keyboard line input buffer*/ char *KPTR; /*pointer for above*/ struct divfd {char *nm; /*name*/ int cs; /*character count*/ int ls; /*line count*/ struct _buf *bf; /*to iobuf if open, FALSE otherwise*/ }; #define FMAX 4 /* # of additional files open*/ int FPTR; FILE *FSTACK[FMAX]; int TFLAG;/*added for start(), complete()*/ int XF2,UF2,MCNT2; int PRINTIT;