aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/troff/ni.c
blob: e12a3a08cc127f5bb287bfdbef9f5102b8ce7f21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
#include <stdio.h>
#include "tdef.h"
#include "fns.h"
#include "ext.h"

char	termtab[NS];	/* term type added in ptinit() */
char	fontdir[NS];	/* added in casefp; not used by nroff */
char	devname[20];	/* default output device */

Numtab numtab[NN] = {
	{ PAIR('%', 0) },
	{ PAIR('n', 'l') },
	{ PAIR('y', 'r') },
	{ PAIR('h', 'p') },
	{ PAIR('c', 't') },
	{ PAIR('d', 'n') },
	{ PAIR('m', 'o') },
	{ PAIR('d', 'y') },
	{ PAIR('d', 'w') },
	{ PAIR('l', 'n') },
	{ PAIR('d', 'l') },
	{ PAIR('s', 't') },
	{ PAIR('s', 'b') },
	{ PAIR('c', '.') },
	{ PAIR('$', '$') }
};


int	alphabet	= 256;	/* latin-1 */
int	pto	= 10000;
int	pfrom	= 1;
int	print	= 1;
char	nextf[NS]	= TMACDIR;
char	mfiles[NMF][NS];
int	nmfi	= 0;
int	oldbits	= -1;
int	init	= 1;
int	fc	= IMP;	/* field character */
int	eschar	= '\\';
int	pl;
int	po;
FILE	*ptid;

int	dfact	= 1;
int	dfactd	= 1;
int	res	= 1;
int	smnt	= 0;	/* beginning of special fonts */
int	ascii	= 0;	/* ascii normally off for troff, on for nroff;  -a turns on */
int	lg;
int	pnlist[NPN] = { -1 };


int	*pnp	= pnlist;
int	npn	= 1;
int	npnflg	=  1;
int	dpn	=  -1;
int	totout	=  1;
int	ulfont	=  ULFONT;
int	tabch	=  TAB;
int	ldrch	=  LEADER;


Contab contab[NM] = {
	C(PAIR('d', 's'), caseds),
	C(PAIR('a', 's'), caseas),
	C(PAIR('s', 'p'), casesp),
	C(PAIR('f', 't'), caseft),
	C(PAIR('p', 's'), caseps),
	C(PAIR('v', 's'), casevs),
	C(PAIR('n', 'r'), casenr),
	C(PAIR('i', 'f'), caseif),
	C(PAIR('i', 'e'), caseie),
	C(PAIR('e', 'l'), caseel),
	C(PAIR('p', 'o'), casepo),
	C(PAIR('t', 'l'), casetl),
	C(PAIR('t', 'm'), casetm),
	C(PAIR('f', 'm'), casefm),
	C(PAIR('b', 'p'), casebp),
	C(PAIR('c', 'h'), casech),
	C(PAIR('p', 'n'), casepn),
	C(PAIR('b', 'r'), tbreak),
	C(PAIR('t', 'i'), caseti),
	C(PAIR('n', 'e'), casene),
	C(PAIR('n', 'f'), casenf),
	C(PAIR('c', 'e'), casece),
	C(PAIR('f', 'i'), casefi),
	C(PAIR('i', 'n'), casein),
	C(PAIR('l', 'l'), casell),
	C(PAIR('n', 's'), casens),
	C(PAIR('m', 'k'), casemk),
	C(PAIR('r', 't'), casert),
	C(PAIR('a', 'm'), caseam),
	C(PAIR('d', 'e'), casede),
	C(PAIR('d', 'i'), casedi),
	C(PAIR('d', 'a'), caseda),
	C(PAIR('w', 'h'), casewh),
	C(PAIR('d', 't'), casedt),
	C(PAIR('i', 't'), caseit),
	C(PAIR('r', 'm'), caserm),
	C(PAIR('r', 'r'), caserr),
	C(PAIR('r', 'n'), casern),
	C(PAIR('a', 'd'), casead),
	C(PAIR('r', 's'), casers),
	C(PAIR('n', 'a'), casena),
	C(PAIR('p', 'l'), casepl),
	C(PAIR('t', 'a'), caseta),
	C(PAIR('t', 'r'), casetr),
	C(PAIR('u', 'l'), caseul),
	C(PAIR('c', 'u'), casecu),
	C(PAIR('l', 't'), caselt),
	C(PAIR('n', 'x'), casenx),
	C(PAIR('s', 'o'), caseso),
	C(PAIR('i', 'g'), caseig),
	C(PAIR('t', 'c'), casetc),
	C(PAIR('f', 'c'), casefc),
	C(PAIR('e', 'c'), caseec),
	C(PAIR('e', 'o'), caseeo),
	C(PAIR('l', 'c'), caselc),
	C(PAIR('e', 'v'), caseev),
	C(PAIR('r', 'd'), caserd),
	C(PAIR('a', 'b'), caseab),
	C(PAIR('f', 'l'), casefl),
	C(PAIR('e', 'x'), caseex),
	C(PAIR('s', 's'), casess),
	C(PAIR('f', 'p'), casefp),
	C(PAIR('c', 's'), casecs),
	C(PAIR('b', 'd'), casebd),
	C(PAIR('l', 'g'), caselg),
	C(PAIR('h', 'c'), casehc),
	C(PAIR('h', 'y'), casehy),
	C(PAIR('n', 'h'), casenh),
	C(PAIR('n', 'm'), casenm),
	C(PAIR('n', 'n'), casenn),
	C(PAIR('s', 'v'), casesv),
	C(PAIR('o', 's'), caseos),
	C(PAIR('l', 's'), casels),
	C(PAIR('c', 'c'), casecc),
	C(PAIR('c', '2'), casec2),
	C(PAIR('e', 'm'), caseem),
	C(PAIR('a', 'f'), caseaf),
	C(PAIR('h', 'a'), caseha),
	C(PAIR('h', 'w'), casehw),
	C(PAIR('m', 'c'), casemc),
	C(PAIR('p', 'm'), casepm),
	C(PAIR('p', 'i'), casepi),
	C(PAIR('u', 'f'), caseuf),
	C(PAIR('p', 'c'), casepc),
	C(PAIR('h', 't'), caseht),
	C(PAIR('c', 'f'), casecf),
	C(PAIR('s', 'y'), casesy),
	C(PAIR('l', 'f'), caself),
	C(PAIR('p', 't'), casept),
	C(PAIR('g', 'd'), casegd)
};


Tbuf _oline;

/*
 * troff environment block
 */

Env env[NEV] = { {	/* this sets up env[0] */
/* int	ics	 */	0,	/* insertion character space, set by .mc */
/* int	sps	 */	0,
/* int	spacesz	 */	0,
/* int	lss	 */	0,
/* int	lss1	 */	0,
/* int	ll	 */	0,
/* int	ll1	 */	0,
/* int	lt	 */	0,
/* int	lt1	 */	0,
/* Tchar ic	 */	0,	/* insertion character (= margin character) */
/* int	icf	 */	0,	/* insertion character flag */
/* Tchar chbits	 */	0,	/* size+font bits for current character */
/* Tchar spbits	 */	0,
/* Tchar nmbits	 */	0,	/* size+font bits for number from .nm */
/* int	apts	 */	PS,	/* actual point size -- as requested by user */
/* int	apts1	 */	PS,	/* need not match an existent size */
/* int	pts	 */	PS,	/* hence, this is the size that really exists */
/* int	pts1	 */	PS,
/* int	font	 */	FT,
/* int	font1	 */	FT,
/* int	ls	 */	1,
/* int	ls1	 */	1,
/* int	ad	 */	1,
/* int	nms	 */	1,	/* .nm multiplier */
/* int	ndf	 */	1,	/* .nm separator */
/* int	nmwid	 */	3,	/* max width of .nm numbers */
/* int	fi	 */	1,
/* int	cc	 */	'.',
/* int	c2	 */	'\'',
/* int	ohc	 */	OHC,
/* int	tdelim	 */	IMP,
/* int	hyf	 */	1,
/* int	hyoff	 */	0,
/* int	hyphalg  */	HYPHALG,
/* int	un1	 */	-1,
/* int	tabc	 */	0,
/* int	dotc	 */	'.',
/* int	adsp	 */	0,	/* add this much space to each padding point */
/* int	adrem	 */	0,	/* excess space to add until it runs out */
/* int	lastl	 */	0,	/* last text on current output line */
/* int	nel	 */	0,	/* how much space left on current output line */
/* int	admod	 */	0,	/* adjust mode */
/* Tchar *wordp	 */	0,
/* int	spflg	 */	0,	/* probably to indicate space after punctuation needed */
/* Tchar *linep	 */	0,
/* Tchar *wdend	 */	0,
/* Tchar *wdstart */	0,
/* int	wne	 */	0,
/* int	ne	 */	0,	/* how much space taken on current output line */
/* int	nc	 */	0,	/* #characters (incl blank) on output line */
/* int	nb	 */	0,
/* int	lnmod	 */	0,	/* line number mode, set by .nm */
/* int	nwd	 */	0,	/* number of words on current output line */
/* int	nn	 */	0,	/* from .nn command */
/* int	ni	 */	0,	/* indent of .nm numbers, probably */
/* int	ul	 */	0,
/* int	cu	 */	0,
/* int	ce	 */	0,
/* int	in	 */	0,	/* indent and previous value */
/* int	in1	 */	0,
/* int	un	 */	0,	/* unindent of left margin in some way */
/* int	wch	 */	0,
/* int	pendt	 */	0,
/* Tchar *pendw	 */	(Tchar *)0,
/* int	pendnf	 */	0,
/* int	spread	 */	0,
/* int	it	 */	0,	/* input trap count */
/* int	itmac	 */	0
} };

Env	*envp	= env;	/* start off in env 0 */

Numerr	numerr;

Stack	*frame, *stk, *ejl;
Stack	*nxf;

int	pipeflg;
int	hflg;	/* used in nroff only */
int	eqflg;	/* used in nroff only */

int	xpts;
int	ppts;
int	pfont;
int	mpts;
int	mfont;
int	cs;
int	ccs;
int	bd;

int	stdi;
int	quiet;
int	stop;
char	ibuf[IBUFSZ];
char	xbuf[IBUFSZ];
char	*ibufp;
char	*xbufp;
char	*eibuf;
char	*xeibuf;
Tchar	pbbuf[NC];		/* pushback buffer for arguments, \n, etc. */
Tchar	*pbp = pbbuf;		/* next free slot in pbbuf */
Tchar	*lastpbp = pbbuf;	/* pbp in previous stack frame */
int	nx;
int	mflg;
Tchar	ch = 0;
int	ibf;
int	ifi;
int	iflg;
int	rargc;
char	**argp;
Ushort	trtab[NTRTAB];
int	lgf;
int	copyf;
Offset	ip;
int	nlflg;
int	donef;
int	nflush;
int	nfo;
int	padc;
int	raw;
int	flss;
int	nonumb;
int	trap;
int	tflg;
int	ejf;
int	dilev;
Offset	offset;
int	em;
int	ds;
Offset	woff;
int	app;
int	ndone;
int	lead;
int	ralss;
Offset	nextb;
Tchar	nrbits;
int	nform;
int	oldmn;
int	newmn;
int	macerr;
Offset	apptr;
int	diflg;
int	evi;
int	vflag;
int	noscale;
int	po1;
int	nlist[NTRAP];
int	mlist[NTRAP];
int	evlist[EVLSZ];
int	ev;
int	tty;
int	sfont	= FT;	/* appears to be "standard" font; used by .ul */
int	sv;
int	esc;
int	widthp;
int	xfont;
int	setwdf;
int	over;
int	nhyp;
Tchar	**hyp;
Tchar	*olinep;
int	dotT;
char	*unlkp;
Wcache	widcache[NWIDCACHE];
Diver	d[NDI];
Diver	*dip;

int	c_hyphen;
int	c_emdash;
int	c_rule;
int	c_minus;
int	c_fi;
int	c_fl;
int	c_ff;
int	c_ffi;
int	c_ffl;
int	c_acute;
int	c_grave;
int	c_under;
int	c_rooten;
int	c_boxrule;
int	c_lefthand;
int	c_dagger;
int	c_isalnum;

Spnames	spnames[] =
{
	&c_hyphen,	"hy",
	&c_emdash,	"em",
	&c_rule,	"ru",
	&c_minus,	"\\-",
	&c_fi,		"fi",
	&c_fl,		"fl",
	&c_ff,		"ff",
	&c_ffi,		"Fi",
	&c_ffl,		"Fl",
	&c_acute,	"aa",
	&c_grave,	"ga",
	&c_under,	"ul",
	&c_rooten,	"rn",
	&c_boxrule,	"br",
	&c_lefthand,	"lh",
	&c_dagger,	"dg",	/* not in nroff?? */
	&c_isalnum,	"__",
	0, 0
};


Tchar	(*hmot)(void);
Tchar	(*makem)(int i);
Tchar	(*setabs)(void);
Tchar	(*setch)(int c);
Tchar	(*sethl)(int k);
Tchar	(*setht)(void);
Tchar	(*setslant)(void);
Tchar	(*vmot)(void);
Tchar	(*xlss)(void);
int	(*findft)(int i);
int	(*width)(Tchar j);
void	(*mchbits)(void);
void	(*ptlead)(void);
void	(*ptout)(Tchar i);
void	(*ptpause)(void);
void	(*setfont)(int a);
void	(*setps)(void);
void	(*setwd)(void);