xref: /original-bsd/old/roff/common_source/ni.c (revision cfa2a17a)
1 /*-
2  * Copyright (c) 1991 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.proprietary.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)ni.c	4.5 (Berkeley) 04/18/91";
10 #endif /* not lint */
11 
12 #include "tdef.h"
13 #include "pathnames.h"
14 char obuf[OBUFSZ];
15 char *obufp = obuf;
16 int r[NN] = {
17 	PAIR('%',0),
18 	PAIR('n','l'),
19 	PAIR('y','r'),
20 	PAIR('h','p'),
21 	PAIR('c','t'),
22 	PAIR('d','n'),
23 	PAIR('m','o'),
24 	PAIR('d','y'),
25 	PAIR('d','w'),
26 	PAIR('l','n'),
27 	PAIR('d','l'),
28 	PAIR('s','t'),
29 	PAIR('s','b'),
30 	PAIR('c','.')};
31 int pto = 10000;
32 int pfrom = 1;
33 int print = 1;
34 char nextf[NS] = _PATH_TMAC;
35 int nfi = sizeof(_PATH_TMAC) - 1;
36 #ifdef NROFF
37 char termtab[NS] = _PATH_TERM;
38 int tti = sizeof(_PATH_TERM) - 1;
39 #endif
40 #ifndef NROFF
41 int oldbits = -1;
42 #endif
43 int init = 1;
44 int fc = IMP;
45 int eschar = '\\';
46 int pl = 11*INCH;
47 int po = PO;
48 int dfact = 1;
49 int dfactd = 1;
50 int res = 1;
51 int smnt = 4;
52 int ascii = ASCII;
53 int ptid = PTID;
54 char ptname[] = "/dev/cat";
55 int lg = LG;
56 int pnlist[NPN] = {-1};
57 int *pnp = pnlist;
58 int npn = 1;
59 int npnflg = 1;
60 int xflg = 1;
61 int dpn = -1;
62 int totout = 1;
63 int ulfont = 1;
64 int ulbit = 1<<9;
65 int tabch = TAB;
66 int ldrch = LEADER;
67 int xxx;
68 extern caseds(), caseas(), casesp(), caseft(), caseps(), casevs(),
69 casenr(), caseif(), casepo(), casetl(), casetm(), casebp(), casech(),
70 casepn(), tbreak(), caseti(), casene(), casenf(), casece(), casefi(),
71 casein(), caseli(), casell(), casens(), casemk(), casert(), caseam(),
72 casede(), casedi(), caseda(), casewh(), casedt(), caseit(), caserm(),
73 casern(), casead(), casers(), casena(), casepl(), caseta(), casetr(),
74 caseul(), caselt(), casenx(), caseso(), caseig(), casetc(), casefc(),
75 caseec(), caseeo(), caselc(), caseev(), caserd(), caseab(), casefl(),
76 done(), casess(), casefp(), casecs(), casebd(), caselg(), casehc(),
77 casehy(), casenh(), casenm(), casenn(), casesv(), caseos(), casels(),
78 casecc(), casec2(), caseem(), caseaf(), casehw(), casemc(), casepm(),
79 casecu(), casepi(), caserr(), caseuf(), caseie(), caseel(), casepc(),
80 caseht();
81 #ifndef NROFF
82 extern casefz();
83 #endif
84 extern casecf();
85 struct contab {
86 	int rq;
87 /*
88 	union {
89  */
90 		int (*f)();
91 /*
92 		unsigned mx;
93 	}x;
94  */
95 }contab[NM]= {
96 	PAIR('d','s'),caseds,
97 	PAIR('a','s'),caseas,
98 	PAIR('s','p'),casesp,
99 	PAIR('f','t'),caseft,
100 	PAIR('p','s'),caseps,
101 	PAIR('v','s'),casevs,
102 	PAIR('n','r'),casenr,
103 	PAIR('i','f'),caseif,
104 	PAIR('i','e'),caseie,
105 	PAIR('e','l'),caseel,
106 	PAIR('p','o'),casepo,
107 	PAIR('t','l'),casetl,
108 	PAIR('t','m'),casetm,
109 	PAIR('b','p'),casebp,
110 	PAIR('c','h'),casech,
111 	PAIR('p','n'),casepn,
112 	PAIR('b','r'),tbreak,
113 	PAIR('t','i'),caseti,
114 	PAIR('n','e'),casene,
115 	PAIR('n','f'),casenf,
116 	PAIR('c','e'),casece,
117 	PAIR('f','i'),casefi,
118 	PAIR('i','n'),casein,
119 	PAIR('l','i'),caseli,
120 	PAIR('l','l'),casell,
121 	PAIR('n','s'),casens,
122 	PAIR('m','k'),casemk,
123 	PAIR('r','t'),casert,
124 	PAIR('a','m'),caseam,
125 	PAIR('d','e'),casede,
126 	PAIR('d','i'),casedi,
127 	PAIR('d','a'),caseda,
128 	PAIR('w','h'),casewh,
129 	PAIR('d','t'),casedt,
130 	PAIR('i','t'),caseit,
131 	PAIR('r','m'),caserm,
132 	PAIR('r','r'),caserr,
133 	PAIR('r','n'),casern,
134 	PAIR('a','d'),casead,
135 	PAIR('r','s'),casers,
136 	PAIR('n','a'),casena,
137 	PAIR('p','l'),casepl,
138 	PAIR('t','a'),caseta,
139 	PAIR('t','r'),casetr,
140 	PAIR('u','l'),caseul,
141 	PAIR('c','u'),casecu,
142 	PAIR('l','t'),caselt,
143 	PAIR('n','x'),casenx,
144 	PAIR('s','o'),caseso,
145 	PAIR('i','g'),caseig,
146 	PAIR('t','c'),casetc,
147 	PAIR('f','c'),casefc,
148 	PAIR('e','c'),caseec,
149 	PAIR('e','o'),caseeo,
150 	PAIR('l','c'),caselc,
151 	PAIR('e','v'),caseev,
152 	PAIR('r','d'),caserd,
153 	PAIR('a','b'),caseab,
154 	PAIR('f','l'),casefl,
155 	PAIR('e','x'),done,
156 	PAIR('s','s'),casess,
157 	PAIR('f','p'),casefp,
158 	PAIR('c','s'),casecs,
159 	PAIR('b','d'),casebd,
160 	PAIR('l','g'),caselg,
161 	PAIR('h','c'),casehc,
162 	PAIR('h','y'),casehy,
163 	PAIR('n','h'),casenh,
164 	PAIR('n','m'),casenm,
165 	PAIR('n','n'),casenn,
166 	PAIR('s','v'),casesv,
167 	PAIR('o','s'),caseos,
168 	PAIR('l','s'),casels,
169 	PAIR('c','c'),casecc,
170 	PAIR('c','2'),casec2,
171 	PAIR('e','m'),caseem,
172 	PAIR('a','f'),caseaf,
173 	PAIR('h','w'),casehw,
174 	PAIR('m','c'),casemc,
175 	PAIR('p','m'),casepm,
176 #ifdef NROFF
177 	PAIR('p','i'),casepi,
178 #endif
179 	PAIR('u','f'),caseuf,
180 	PAIR('p','c'),casepc,
181 	PAIR('h','t'),caseht,
182 #ifndef NROFF
183 	PAIR('f','z'),casefz,
184 #endif
185 	PAIR('c', 'f'),casecf,
186 };
187 
188 /*
189 troff environment block
190 */
191 
192 int block = 0;
193 int ics = ICS;
194 int ic = 0;
195 int icf = 0;
196 int chbits = 0;
197 int spbits = 0;
198 int nmbits = 0;
199 int apts = PS;
200 int apts1 = PS;
201 int pts = PS;
202 int pts1 = PS;
203 int font = FT;
204 int font1 = FT;
205 int sps = SPS;
206 int spacesz = SS;
207 int lss = VS;
208 int lss1 = VS;
209 int ls = 1;
210 int ls1 = 1;
211 int ll = LL;
212 int ll1 = LL;
213 int lt = LL;
214 int lt1 = LL;
215 int ad = 1;
216 int nms = 1;
217 int ndf = 1;
218 int fi = 1;
219 int cc = '.';
220 int c2 = '\'';
221 int ohc = OHC;
222 int tdelim = IMP;
223 int hyf = 1;
224 int hyoff = 0;
225 int un1 = -1;
226 int tabc = 0;
227 int dotc = '.';
228 int adsp = 0;
229 int adrem = 0;
230 int lastl = 0;
231 int nel = 0;
232 int admod = 0;
233 int *wordp = 0;
234 int spflg = 0;
235 int *linep = 0;
236 int *wdend = 0;
237 int *wdstart = 0;
238 int wne = 0;
239 int ne = 0;
240 int nc = 0;
241 int nb = 0;
242 int lnmod = 0;
243 int nwd = 0;
244 int nn = 0;
245 int ni = 0;
246 int ul = 0;
247 int cu = 0;
248 int ce = 0;
249 int in = 0;
250 int in1 = 0;
251 int un = 0;
252 int wch = 0;
253 int pendt = 0;
254 int *pendw = 0;
255 int pendnf = 0;
256 int spread = 0;
257 int it = 0;
258 int itmac = 0;
259 int lnsize = LNSIZE;
260 int *hyptr[NHYP] = {0};
261 int tabtab[NTAB] = {DTAB,DTAB*2,DTAB*3,DTAB*4,DTAB*5,DTAB*6,DTAB*7,DTAB*8,
262 	DTAB*9,DTAB*10,DTAB*11,DTAB*12,DTAB*13,DTAB*14,DTAB*15,0};
263 int line[LNSIZE] = {0};
264 int word[WDSIZE] = {0};
265 int blockxxx[EVS-68-NHYP-NTAB-WDSIZE-LNSIZE] = {0};
266 /*spare 5 words*/
267 int oline[LNSIZE+1];
268