summaryrefslogtreecommitdiff
path: root/usr.bin/deroff/deroff.c
blob: 0bf26d2fb21e6a430612d0442eae61cce8c73a32 (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
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
/*	$OpenBSD: deroff.c,v 1.4 2002/02/28 22:12:15 danh Exp $	*/

/*-
 * Copyright (c) 1988, 1993
 *	The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by the University of
 *	California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */
/*
 * Copyright (C) Caldera International Inc.  2001-2002.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code and documentation must retain the above
 *    copyright notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed or owned by Caldera
 *	International, Inc.
 * 4. Neither the name of Caldera International, Inc. nor the names of other
 *    contributors may be used to endorse or promote products derived from
 *    this software without specific prior written permission.
 *
 * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
 * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT,
 * INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef lint
static const char copyright[] =
"@(#) Copyright (c) 1988, 1993\n\
	The Regents of the University of California.  All rights reserved.\n";
#endif /* not lint */

#ifndef lint
#if 0
static const char sccsid[] = "@(#)deroff.c	8.1 (Berkeley) 6/6/93";
#else
static const char rcsid[] = "$OpenBSD: deroff.c,v 1.4 2002/02/28 22:12:15 danh Exp $";
#endif
#endif /* not lint */

#include <err.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

/*
 *	Deroff command -- strip troff, eqn, and Tbl sequences from
 *	a file.  Has two flags argument, -w, to cause output one word per line
 *	rather than in the original format.
 *	-mm (or -ms) causes the corresponding macro's to be interpreted
 *	so that just sentences are output
 *	-ml  also gets rid of lists.
 *	Deroff follows .so and .nx commands, removes contents of macro
 *	definitions, equations (both .EQ ... .EN and $...$),
 *	Tbl command sequences, and Troff backslash constructions.
 *
 *	All input is through the Cget macro;
 *	the most recently read character is in c.
 *
 *	Modified by Robert Henry to process -me and -man macros.
 */

#define Cget ( (c=getc(infile)) == EOF ? eof() : ((c==ldelim)&&(filesp==files) ? skeqn() : c) )
#define C1get ( (c=getc(infile)) == EOF ? eof() :  c)

#ifdef DEBUG
#  define C	_C()
#  define C1	_C1()
#else /* not DEBUG */
#  define C	Cget
#  define C1	C1get
#endif /* not DEBUG */

#define SKIP while (C != '\n')
#define SKIP_TO_COM SKIP; SKIP; pc=c; while (C != '.' || pc != '\n' || C > 'Z')pc=c

#define	YES 1
#define	NO 0
#define	MS 0	/* -ms */
#define	MM 1	/* -mm */
#define	ME 2	/* -me */
#define	MA 3	/* -man */

#ifdef DEBUG
char *mactab[] = { "-ms", "-mm", "-me", "-ma" };
#endif /* DEBUG */

#define	ONE 1
#define	TWO 2

#define NOCHAR -2
#define SPECIAL 0
#define APOS 1
#define PUNCT 2
#define DIGIT 3
#define LETTER 4

#define MAXFILES 20

int	iflag;
int	wordflag;
int	msflag;		/* processing a source written using a mac package */
int	mac;		/* which package */
int	disp;
int	parag;
int	inmacro;
int	intable;
int	keepblock;	/* keep blocks of text; normally false when msflag */

char chars[128];  /* SPECIAL, PUNCT, APOS, DIGIT, or LETTER */

char line[LINE_MAX];
char *lp;

int c;
int pc;
int ldelim;
int rdelim;

char fname[PATH_MAX];
FILE *files[MAXFILES];
FILE **filesp;
FILE *infile;

int argc;
char **argv;

/*
 *	Macro processing
 *
 *	Macro table definitions
 */
typedef	int pacmac;		/* compressed macro name */
int	argconcat = 0;		/* concat arguments together (-me only) */

#define	tomac(c1, c2)		((((c1) & 0xFF) << 8) | ((c2) & 0xFF))
#define	frommac(src, c1, c2)	(((c1)=((src)>>8)&0xFF),((c2) =(src)&0xFF))

struct mactab{
	int	condition;
	pacmac	macname;
	int	(*func)();	/* XXX - args */
};

struct	mactab	troffmactab[];
struct	mactab	ppmactab[];
struct	mactab	msmactab[];
struct	mactab	mmmactab[];
struct	mactab	memactab[];
struct	mactab	manmactab[];

/*
 *	Macro table initialization
 */
#define	M(cond, c1, c2, func) {cond, tomac(c1, c2), func}

/*
 *	Flags for matching conditions other than
 *	the macro name
 */
#define	NONE		0
#define	FNEST		1		/* no nested files */
#define	NOMAC		2		/* no macro */
#define	MAC		3		/* macro */
#define	PARAG		4		/* in a paragraph */
#define	MSF		5		/* msflag is on */
#define	NBLK		6		/* set if no blocks to be kept */

/*
 *	Return codes from macro minions, determine where to jump,
 *	how to repeat/reprocess text
 */
#define	COMX		1		/* goto comx */
#define	COM		2		/* goto com */

int	 skeqn(void);
int	 eof(void);
int	 _C1(void);
int	 _C(void);
int	 EQ(void);
int	 domacro(void);
int	 PS(void);
int	 skip(void);
int	 intbl(void);
int	 outtbl(void);
int	 so(void);
int	 nx(void);
int	 skiptocom(void);
int	 PP(pacmac);
int	 AU(void);
int	 SH(pacmac);
int	 UX(void);
int	 MMHU(pacmac);
int	 mesnblock(pacmac);
int	 mssnblock(pacmac);
int	 nf(void);
int	 ce(void);
int	 meip(pacmac);
int	 mepp(pacmac);
int	 mesh(pacmac);
int	 mefont(pacmac);
int	 manfont(pacmac);
int	 manpp(pacmac);
int	 macsort(const void *, const void *);
int	 sizetab(struct mactab *);
void	 getfname(void);
void	 textline(char *, int);
void	 work(void);
void	 regline(void (*)(char *, int), int);
void	 macro(void);
void	 tbl(void);
void	 stbl(void);
void	 eqn(void);
void	 backsl(void);
void	 sce(void);
void	 refer(int);
void	 inpic(void);
void	 msputmac(char *, int);
void	 msputwords(int);
void	 meputmac(char *, int);
void	 meputwords(int);
void	 noblock(char, char);
void	 defcomline(pacmac);
void	 comline(void);
void	 buildtab(struct mactab **, int *);
FILE	*opn(char *);
struct mactab *macfill(struct mactab *, struct mactab *);
__dead void usage(void);

int
main(int ac, char **av)
{
	int	i, ch;
	int	errflg = 0;
	int	kflag = NO;

	iflag = NO;
	wordflag = NO;
	msflag = NO;
	mac = ME;
	disp = NO;
	parag = NO;
	inmacro = NO;
	intable = NO;
	ldelim	= NOCHAR;
	rdelim	= NOCHAR;
	keepblock = YES;

	while ((ch = getopt(ac, av, "ikpwm:")) != -1) {
		switch (ch) {
		case 'i':
			iflag = YES;
			break;
		case 'k':
			kflag = YES;
			break;
		case 'm':
			msflag = YES;
			keepblock = NO;
			switch (optarg[0]) {
			case 'm':
				mac = MM;
				break;
			case 's':
				mac = MS;
				break;
			case 'e':
				mac = ME;
				break;
			case 'a':
				mac = MA;
				break;
			case 'l':
				disp = YES;
				break;
			default:
				errflg++;
				break;
			}
			if (errflg == 0 && optarg[1] != '\0')
				errflg++;
			break;
		case 'p':
			parag = YES;
			break;
		case 'w':
			wordflag = YES;
			kflag = YES;
			break;
		default:
			errflg++;
		}
	}
	argc = ac - optind;
	argv = av + optind;

	if (kflag)
		keepblock = YES;
	if (errflg)
		usage();

#ifdef DEBUG
	printf("msflag = %d, mac = %s, keepblock = %d, disp = %d\n",
		msflag, mactab[mac], keepblock, disp);
#endif /* DEBUG */
	if (argc == 0) {
		infile = stdin;
	} else {
		infile = opn(argv[0]);
		--argc;
		++argv;
	}
	files[0] = infile;
	filesp = &files[0];

	for (i = 'a'; i <= 'z' ; ++i)
		chars[i] = LETTER;
	for (i = 'A'; i <= 'Z'; ++i)
		chars[i] = LETTER;
	for (i = '0'; i <= '9'; ++i)
		chars[i] = DIGIT;
	chars['\''] = APOS;
	chars['&'] = APOS;
	chars['.'] = PUNCT;
	chars[','] = PUNCT;
	chars[';'] = PUNCT;
	chars['?'] = PUNCT;
	chars[':'] = PUNCT;
	work();
	exit(0);
}

int
skeqn(void)
{

	while ((c = getc(infile)) != rdelim) {
		if (c == EOF)
			c = eof();
		else if (c == '"') {
			while ((c = getc(infile)) != '"') {
				if (c == EOF ||
				    (c == '\\' && (c = getc(infile)) == EOF))
					c = eof();
			}
		}
	}
	if (msflag)
		return((c = 'x'));
	return((c = ' '));
}

FILE *
opn(char *p)
{
	FILE *fd;

	if ((fd = fopen(p, "r")) == NULL)
		err(1, "fopen %s", p);

	return(fd);
}

int
eof(void)
{

	if (infile != stdin)
		fclose(infile);
	if (filesp > files)
		infile = *--filesp;
	else if (argc > 0) {
		infile = opn(argv[0]);
		--argc;
		++argv;
	} else
		exit(0);
	return(C);
}

void
getfname(void)
{
	char *p;
	struct chain {
		struct chain *nextp;
		char *datap;
	} *q;
	static struct chain *namechain= NULL;

	while (C == ' ')
		;	/* nothing */

	for (p = fname ; p - fname < sizeof(fname) && (*p = c) != '\n' &&
	    c != ' ' && c != '\t' && c != '\\'; ++p)
		C;
	*p = '\0';
	while (c != '\n')
		C;

	/* see if this name has already been used */
	for (q = namechain ; q; q = q->nextp)
		if (strcmp(fname, q->datap) == 0) {
			fname[0] = '\0';
			return;
		}

	q = (struct chain *) malloc(sizeof(struct chain));
	if (q == NULL)
		err(1, "malloc");
	q->nextp = namechain;
	q->datap = strdup(fname);
	if (q->datap == NULL)
		err(1, "strdup");
	namechain = q;
}

/*ARGSUSED*/
void
textline(char *str, int constant)
{

	if (wordflag) {
		msputwords(0);
		return;
	}
	puts(str);
}

void
work(void)
{

	for (;;) {
		C;
#ifdef FULLDEBUG
		printf("Starting work with `%c'\n", c);
#endif /* FULLDEBUG */
		if (c == '.' || c == '\'')
			comline();
		else
			regline(textline, TWO);
	}
}

void
regline(void (*pfunc)(char *, int), int constant)
{

	line[0] = c;
	lp = line;
	while (lp - line < sizeof(line)) {
		if (c == '\\') {
			*lp = ' ';
			backsl();
		}
		if (c == '\n')
			break;
		if (intable && c == 'T') {
			*++lp = C;
			if (c == '{' || c == '}') {
				lp[-1] = ' ';
				*lp = C;
			}
		} else {
			*++lp = C;
		}
	}
	*lp = '\0';

	if (line[0] != '\0')
		(*pfunc)(line, constant);
}

void
macro(void)
{

	if (msflag) {
		do {
			SKIP;
		} while (C!='.' || C!='.' || C=='.');	/* look for  .. */
		if (c != '\n')
			SKIP;
		return;
	}
	SKIP;
	inmacro = YES;
}

void
tbl(void)
{

	while (C != '.')
		;	/* nothing */
	SKIP;
	intable = YES;
}

void
stbl(void)
{

	while (C != '.')
		;	/* nothing */
	SKIP_TO_COM;
	if (c != 'T' || C != 'E') {
		SKIP;
		pc = c;
		while (C != '.' || pc != '\n' || C != 'T' || C != 'E')
			pc = c;
	}
}

void
eqn(void)
{
	int c1, c2;
	int dflg;
	char last;

	last=0;
	dflg = 1;
	SKIP;

	for (;;) {
		if (C1 == '.'  || c == '\'') {
			while (C1 == ' ' || c == '\t')
				;
			if (c == 'E' && C1 == 'N') {
				SKIP;
				if (msflag && dflg) {
					putchar('x');
					putchar(' ');
					if (last) {
						putchar(last);
						putchar('\n');
					}
				}
				return;
			}
		} else if (c == 'd') {
			/* look for delim */
			if (C1 == 'e' && C1 == 'l')
				if (C1 == 'i' && C1 == 'm') {
					while (C1 == ' ')
						;	/* nothing */

					if ((c1 = c) == '\n' ||
					    (c2 = C1) == '\n' ||
					    (c1 == 'o' && c2 == 'f' && C1=='f')) {
						ldelim = NOCHAR;
						rdelim = NOCHAR;
					} else {
						ldelim = c1;
						rdelim = c2;
					}
				}
			dflg = 0;
		}

		if (c != '\n')
			while (C1 != '\n') {
				if (chars[c] == PUNCT)
					last = c;
				else if (c != ' ')
					last = 0;
			}
	}
}

/* skip over a complete backslash construction */
void
backsl(void)
{
	int bdelim;

sw:
	switch (C) {
	case '"':
		SKIP;
		return;

	case 's':
		if (C == '\\')
			backsl();
		else {
			while (C >= '0' && c <= '9')
				;	/* nothing */
			ungetc(c, infile);
			c = '0';
		}
		--lp;
		return;

	case 'f':
	case 'n':
	case '*':
		if (C != '(')
			return;

	case '(':
		if (msflag) {
			if (C == 'e') {
				if (C == 'm') {
					*lp = '-';
					return;
				}
			}
			else if (c != '\n')
				C;
			return;
		}
		if (C != '\n')
			C;
		return;

	case '$':
		C;	/* discard argument number */
		return;

	case 'b':
	case 'x':
	case 'v':
	case 'h':
	case 'w':
	case 'o':
	case 'l':
	case 'L':
		if ((bdelim = C) == '\n')
			return;
		while (C != '\n' && c != bdelim)
			if (c == '\\')
				backsl();
		return;

	case '\\':
		if (inmacro)
			goto sw;

	default:
		return;
	}
}

void
sce(void)
{
	char *ap;
	int n, i;
	char a[10];

	for (ap = a; C != '\n'; ap++) {
		*ap = c;
		if (ap == &a[9]) {
			SKIP;
			ap = a;
			break;
		}
	}
	if (ap != a)
		n = atoi(a);
	else
		n = 1;
	for (i = 0; i < n;) {
		if (C == '.') {
			if (C == 'c') {
				if (C == 'e') {
					while (C == ' ')
						;	/* nothing */
					if (c == '0') {
						SKIP;
						break;
					} else
						SKIP;
				}
				else
					SKIP;
			} else if (c == 'P' || C == 'P') {
				if (c != '\n')
					SKIP;
				break;
			} else if (c != '\n')
				SKIP;
		} else {
			SKIP;
			i++;
		}
	}
}

void
refer(int c1)
{
	int c2;

	if (c1 != '\n')
		SKIP;

	for (c2 = -1;;) {
		if (C != '.')
			SKIP;
		else {
			if (C != ']')
				SKIP;
			else {
				while (C != '\n')
					c2 = c;
				if (c2 != -1 && chars[c2] == PUNCT)
					putchar(c2);
				return;
			}
		}
	}
}

void
inpic(void)
{
	int c1;
	char *p1;

	SKIP;
	p1 = line;
	c = '\n';
	for (;;) {
		c1 = c;
		if (C == '.' && c1 == '\n') {
			if (C != 'P') {
				if (c == '\n')
					continue;
				else {
					SKIP;
					c = '\n';
					continue;
				}
			}
			if (C != 'E') {
				if (c == '\n')
					continue;
				else {
					SKIP;
					c = '\n';
					continue;
				}
			}
			SKIP;
			return;
		}
		else if (c == '\"') {
			while (C != '\"') {
				if (c == '\\') {
					if (C == '\"')
						continue;
					ungetc(c, infile);
					backsl();
				} else
					*p1++ = c;
			}
			*p1++ = ' ';
		}
		else if (c == '\n' && p1 != line) {
			*p1 = '\0';
			if (wordflag)
				msputwords(NO);
			else {
				puts(line);
				putchar('\n');
			}
			p1 = line;
		}
	}
}

#ifdef DEBUG
int
_C1(void)
{

	return(C1get);
}

int
_C(void)
{

	return(Cget);
}
#endif /* DEBUG */

/*
 *	Put out a macro line, using ms and mm conventions.
 */
void
msputmac(char *s, int constant)
{
	char *t;
	int found;
	int last;

	last = 0;
	found = 0;
	if (wordflag) {
		msputwords(YES);
		return;
	}
	while (*s) {
		while (*s == ' ' || *s == '\t')
			putchar(*s++);
		for (t = s ; *t != ' ' && *t != '\t' && *t != '\0' ; ++t)
			;	/* nothing */
		if (*s == '\"')
			s++;
		if (t > s + constant && chars[(unsigned char)s[0]] == LETTER &&
		    chars[(unsigned char)s[1]] == LETTER) {
			while (s < t)
				if (*s == '\"')
					s++;
				else
					putchar(*s++);
			last = *(t-1);
			found++;
		} else if (found && chars[(unsigned char)s[0]] == PUNCT &&
		    s[1] == '\0') {
			putchar(*s++);
		} else {
			last = *(t - 1);
			s = t;
		}
	}
	putchar('\n');
	if (msflag && chars[last] == PUNCT) {
		putchar(last);
		putchar('\n');
	}
}

/*
 *	put out words (for the -w option) with ms and mm conventions
 */
void
msputwords(int macline)
{
	char *p, *p1;
	int i, nlet;

	for (p1 = line;;) {
		/*
		 *	skip initial specials ampersands and apostrophes
		 */
		while (chars[(unsigned char)*p1] < DIGIT)
			if (*p1++ == '\0')
				return;
		nlet = 0;
		for (p = p1 ; (i = chars[(unsigned char)*p]) != SPECIAL ; ++p)
			if (i == LETTER)
				++nlet;

		if (nlet > 1 && chars[(unsigned char)p1[0]] == LETTER) {
			/*
			 *	delete trailing ampersands and apostrophes
			 */
			while ((i = chars[(unsigned char)p[-1]]) == PUNCT ||
			    i == APOS )
				--p;
			while (p1 < p)
				putchar(*p1++);
			putchar('\n');
		} else {
			p1 = p;
		}
	}
}

/*
 *	put out a macro using the me conventions
 */
#define SKIPBLANK(cp)	while (*cp == ' ' || *cp == '\t') { cp++; }
#define SKIPNONBLANK(cp) while (*cp !=' ' && *cp !='\cp' && *cp !='\0') { cp++; }

void
meputmac(char *cp, int constant)
{
	char	*np;
	int	found;
	int	argno;
	int	last;
	int	inquote;

	last = 0;
	found = 0;
	if (wordflag) {
		meputwords(YES);
		return;
	}
	for (argno = 0; *cp; argno++) {
		SKIPBLANK(cp);
		inquote = (*cp == '"');
		if (inquote)
			cp++;
		for (np = cp; *np; np++) {
			switch (*np) {
			case '\n':
			case '\0':
				break;

			case '\t':
			case ' ':
				if (inquote)
					continue;
				else
					goto endarg;

			case '"':
				if (inquote && np[1] == '"') {
					memmove(np, np + 1, strlen(np));
					np++;
					continue;
				} else {
					*np = ' '; 	/* bye bye " */
					goto endarg;
				}

			default:
				continue;
			}
		}
		endarg: ;
		/*
		 *	cp points at the first char in the arg
		 *	np points one beyond the last char in the arg
		 */
		if ((argconcat == 0) || (argconcat != argno))
			putchar(' ');
#ifdef FULLDEBUG
		{
			char	*p;
			printf("[%d,%d: ", argno, np - cp);
			for (p = cp; p < np; p++) {
				putchar(*p);
			}
			printf("]");
		}
#endif /* FULLDEBUG */
		/*
		 *	Determine if the argument merits being printed
		 *
		 *	constant is the cut off point below which something
		 *	is not a word.
		 */
		if (((np - cp) > constant) &&
		    (inquote || (chars[(unsigned char)cp[0]] == LETTER))) {
			for (cp = cp; cp < np; cp++)
				putchar(*cp);
			last = np[-1];
			found++;
		} else if (found && (np - cp == 1) &&
		    chars[(unsigned char)*cp] == PUNCT) {
			putchar(*cp);
		} else {
			last = np[-1];
		}
		cp = np;
	}
	if (msflag && chars[last] == PUNCT)
		putchar(last);
	putchar('\n');
}

/*
 *	put out words (for the -w option) with ms and mm conventions
 */
void
meputwords(int macline)
{

	msputwords(macline);
}

/*
 *
 *	Skip over a nested set of macros
 *
 *	Possible arguments to noblock are:
 *
 *	fi	end of unfilled text
 *	PE	pic ending
 *	DE	display ending
 *
 *	for ms and mm only:
 *		KE	keep ending
 *
 *		NE	undocumented match to NS (for mm?)
 *		LE	mm only: matches RL or *L (for lists)
 *
 *	for me:
 *		([lqbzcdf]
 */
void
noblock(char a1, char a2)
{
	int c1,c2;
	int eqnf;
	int lct;

	lct = 0;
	eqnf = 1;
	SKIP;
	for (;;) {
		while (C != '.')
			if (c == '\n')
				continue;
			else
				SKIP;
		if ((c1 = C) == '\n')
			continue;
		if ((c2 = C) == '\n')
			continue;
		if (c1 == a1 && c2 == a2) {
			SKIP;
			if (lct != 0) {
				lct--;
				continue;
			}
			if (eqnf)
				putchar('.');
			putchar('\n');
			return;
		} else if (a1 == 'L' && c2 == 'L') {
			lct++;
			SKIP;
		}
		/*
		 *	equations (EQ) nested within a display
		 */
		else if (c1 == 'E' && c2 == 'Q') {
			if ((mac == ME && a1 == ')')
			    || (mac != ME && a1 == 'D')) {
				eqn();
				eqnf=0;
			}
		}
		/*
		 *	turning on filling is done by the paragraphing
		 *	macros
		 */
		else if (a1 == 'f') {	/* .fi */
			if  ((mac == ME && (c2 == 'h' || c2 == 'p'))
			    || (mac != ME && (c1 == 'P' || c2 == 'P'))) {
				SKIP;
				return;
			}
		} else {
			SKIP;
		}
	}
}

int
EQ(void)
{

	eqn();
	return(0);
}

int
domacro(void)
{

	macro();
	return(0);
}

int
PS(void)
{

	for (C; c == ' ' || c == '\t'; C)
		;	/* nothing */

	if (c == '<') {		/* ".PS < file" -- don't expect a .PE */
		SKIP;
		return(0);
	}
	if (!msflag)
		inpic();
	else
		noblock('P', 'E');
	return(0);
}

int
skip(void)
{

	SKIP;
	return(0);
}

int
intbl(void)
{

	if (msflag)
		stbl();
	else
		tbl();
	return(0);
}

int
outtbl(void)
{

	intable = NO;
	return(0);
}

int
so(void)
{

	if (!iflag) {
		getfname();
		if (fname[0]) {
			if (++filesp - &files[0] > MAXFILES)
				err(1, "too many nested files (max %d)",
				    MAXFILES);
			infile = *filesp = opn(fname);
		}
	}
	return(0);
}

int
nx(void)
{

	if (!iflag) {
		getfname();
		if (fname[0] == '\0')
			exit(0);
		if (infile != stdin)
			fclose(infile);
		infile = *filesp = opn(fname);
	}
	return(0);
}

int
skiptocom(void)
{

	SKIP_TO_COM;
	return(COMX);
}

int
PP(pacmac c12)
{
	int c1, c2;

	frommac(c12, c1, c2);
	printf(".%c%c", c1, c2);
	while (C != '\n')
		putchar(c);
	putchar('\n');
	return(0);
}

int
AU(void)
{

	if (mac == MM)
		return(0);
	SKIP_TO_COM;
	return(COMX);
}

int
SH(pacmac c12)
{
	int c1, c2;

	frommac(c12, c1, c2);

	if (parag) {
		printf(".%c%c", c1, c2);
		while (C != '\n')
			putchar(c);
		putchar(c);
		putchar('!');
		for (;;) {
			while (C != '\n')
				putchar(c);
			putchar('\n');
			if (C == '.')
				return(COM);
			putchar('!');
			putchar(c);
		}
		/*NOTREACHED*/
	} else {
		SKIP_TO_COM;
		return(COMX);
	}
}

int
UX(void)
{

	if (wordflag)
		printf("UNIX\n");
	else
		printf("UNIX ");
	return(0);
}

int
MMHU(pacmac c12)
{
	int c1, c2;

	frommac(c12, c1, c2);
	if (parag) {
		printf(".%c%c", c1, c2);
		while (C != '\n')
			putchar(c);
		putchar('\n');
	} else {
		SKIP;
	}
	return(0);
}

int
mesnblock(pacmac c12)
{
	int c1, c2;

	frommac(c12, c1, c2);
	noblock(')', c2);
	return(0);
}

int
mssnblock(pacmac c12)
{
	int c1, c2;

	frommac(c12, c1, c2);
	noblock(c1, 'E');
	return(0);
}

int
nf(void)
{

	noblock('f', 'i');
	return(0);
}

int
ce(void)
{

	sce();
	return(0);
}

int
meip(pacmac c12)
{

	if (parag)
		mepp(c12);
	else if (wordflag)	/* save the tag */
		regline(meputmac, ONE);
	else
		SKIP;
	return(0);
}

/*
 *	only called for -me .pp or .sh, when parag is on
 */
int
mepp(pacmac c12)
{

	PP(c12);		/* eats the line */
	return(0);
}

/*
 *	Start of a section heading; output the section name if doing words
 */
int
mesh(pacmac c12)
{

	if (parag)
		mepp(c12);
	else if (wordflag)
		defcomline(c12);
	else
		SKIP;
	return(0);
}

/*
 *	process a font setting
 */
int
mefont(pacmac c12)
{

	argconcat = 1;
	defcomline(c12);
	argconcat = 0;
	return(0);
}

int
manfont(pacmac c12)
{

	return(mefont(c12));
}

int
manpp(pacmac c12)
{

	return(mepp(c12));
}

void
defcomline(pacmac c12)
{
	int c1, c2;

	frommac(c12, c1, c2);
	if (msflag && mac == MM && c2 == 'L') {
		if (disp || c1 == 'R') {
			noblock('L', 'E');
		} else {
			SKIP;
			putchar('.');
		}
	}
	else if (c1 == '.' && c2 == '.') {
		if (msflag) {
			SKIP;
			return;
		}
		while (C == '.')
			/*VOID*/;
	}
	++inmacro;
	/*
	 *	Process the arguments to the macro
	 */
	switch (mac) {
	default:
	case MM:
	case MS:
		if (c1 <= 'Z' && msflag)
			regline(msputmac, ONE);
		else
			regline(msputmac, TWO);
		break;
	case ME:
		regline(meputmac, ONE);
		break;
	}
	--inmacro;
}

void
comline(void)
{
	int	c1;
	int	c2;
	pacmac	c12;
	int	mid;
	int	lb, ub;
	int	hit;
	static	int	tabsize = 0;
	static	struct	mactab	*mactab = (struct mactab *)0;
	struct	mactab	*mp;

	if (mactab == 0)
		 buildtab(&mactab, &tabsize);
com:
	while (C == ' ' || c == '\t')
		;
comx:
	if ((c1 = c) == '\n')
		return;
	c2 = C;
	if (c1 == '.' && c2 != '.')
		inmacro = NO;
	if (msflag && c1 == '[') {
		refer(c2);
		return;
	}
	if (parag && mac==MM && c1 == 'P' && c2 == '\n') {
		printf(".P\n");
		return;
	}
	if (c2 == '\n')
		return;
	/*
	 *	Single letter macro
	 */
	if (mac == ME && (c2 == ' ' || c2 == '\t') )
		c2 = ' ';
	c12 = tomac(c1, c2);
	/*
	 *	binary search through the table of macros
	 */
	lb = 0;
	ub = tabsize - 1;
	while (lb <= ub) {
		mid = (ub + lb) / 2;
		mp = &mactab[mid];
		if (mp->macname < c12)
			lb = mid + 1;
		else if (mp->macname > c12)
			ub = mid - 1;
		else {
			hit = 1;
#ifdef FULLDEBUG
			printf("preliminary hit macro %c%c ", c1, c2);
#endif /* FULLDEBUG */
			switch (mp->condition) {
			case NONE:
				hit = YES;
				break;
			case FNEST:
				hit = (filesp == files);
				break;
			case NOMAC:
				hit = !inmacro;
				break;
			case MAC:
				hit = inmacro;
				break;
			case PARAG:
				hit = parag;
				break;
			case NBLK:
				hit = !keepblock;
				break;
			default:
				hit = 0;
			}

			if (hit) {
#ifdef FULLDEBUG
				printf("MATCH\n");
#endif /* FULLDEBUG */
				switch ((*(mp->func))(c12)) {
				default:
					return;
				case COMX:
					goto comx;
				case COM:
					goto com;
				}
			}
#ifdef FULLDEBUG
			printf("FAIL\n");
#endif /* FULLDEBUG */
			break;
		}
	}
	defcomline(c12);
}

int
macsort(const void *p1, const void *p2)
{
	struct mactab *t1 = (struct mactab *)p1;
	struct mactab *t2 = (struct mactab *)p2;

	return(t1->macname - t2->macname);
}

int
sizetab(struct mactab *mp)
{
	int i;

	i = 0;
	if (mp) {
		for (; mp->macname; mp++, i++)
			/*VOID*/ ;
	}
	return(i);
}

struct mactab *
macfill(struct mactab *dst, struct mactab *src)
{

	if (src) {
		while (src->macname)
			*dst++ = *src++;
	}
	return(dst);
}

__dead void
usage(void)
{
	extern char *__progname;

	fprintf(stderr, "usage: %s [-ikpw ] [ -m ( a | e | m | s | l ) ] [ filename ] ... \n", __progname);
	exit(1);
}

void
buildtab(struct mactab **r_back, int *r_size)
{
	int	size;
	struct	mactab	*p, *p1, *p2;
	struct	mactab	*back;

	size = sizetab(troffmactab) + sizetab(ppmactab);
	p1 = p2 = NULL;
	if (msflag) {
		switch (mac) {
		case ME:
			p1 = memactab;
			break;
		case MM:
			p1 = msmactab;
			p2 = mmmactab;
			break;
		case MS:
			p1 = msmactab;
			break;
		case MA:
			p1 = manmactab;
			break;
		default:
			break;
		}
	}
	size += sizetab(p1);
	size += sizetab(p2);
	back = (struct mactab *)calloc(size+2, sizeof(struct mactab));
	if (back == NULL)
		err(1, "calloc");

	p = macfill(back, troffmactab);
	p = macfill(p, ppmactab);
	p = macfill(p, p1);
	p = macfill(p, p2);

	qsort(back, size, sizeof(struct mactab), macsort);
	*r_size = size;
	*r_back = back;
}

/*
 *	troff commands
 */
struct	mactab	troffmactab[] = {
	M(NONE,		'\\','"',	skip),	/* comment */
	M(NOMAC,	'd','e',	domacro),	/* define */
	M(NOMAC,	'i','g',	domacro),	/* ignore till .. */
	M(NOMAC,	'a','m',	domacro),	/* append macro */
	M(NBLK,		'n','f',	nf),	/* filled */
	M(NBLK,		'c','e',	ce),	/* centered */

	M(NONE,		's','o',	so),	/* source a file */
	M(NONE,		'n','x',	nx),	/* go to next file */

	M(NONE,		't','m',	skip),	/* print string on tty */
	M(NONE,		'h','w',	skip),	/* exception hyphen words */
	M(NONE,		0,0,		0)
};

/*
 *	Preprocessor output
 */
struct	mactab	ppmactab[] = {
	M(FNEST,	'E','Q',	EQ),	/* equation starting */
	M(FNEST,	'T','S',	intbl),	/* table starting */
	M(FNEST,	'T','C',	intbl),	/* alternative table? */
	M(FNEST,	'T','&',	intbl),	/* table reformatting */
	M(NONE,		'T','E',	outtbl),/* table ending */
	M(NONE,		'P','S',	PS),	/* picture starting */
	M(NONE,		0,0,		0)
};

/*
 *	Particular to ms and mm
 */
struct	mactab	msmactab[] = {
	M(NONE,		'T','L',	skiptocom),	/* title follows */
	M(NONE,		'F','S',	skiptocom),	/* start footnote */
	M(NONE,		'O','K',	skiptocom),	/* Other kws */

	M(NONE,		'N','R',	skip),	/* undocumented */
	M(NONE,		'N','D',	skip),	/* use supplied date */

	M(PARAG,	'P','P',	PP),	/* begin parag */
	M(PARAG,	'I','P',	PP),	/* begin indent parag, tag x */
	M(PARAG,	'L','P',	PP),	/* left blocked parag */

	M(NONE,		'A','U',	AU),	/* author */
	M(NONE,		'A','I',	AU),	/* authors institution */

	M(NONE,		'S','H',	SH),	/* section heading */
	M(NONE,		'S','N',	SH),	/* undocumented */
	M(NONE,		'U','X',	UX),	/* unix */

	M(NBLK,		'D','S',	mssnblock),	/* start display text */
	M(NBLK,		'K','S',	mssnblock),	/* start keep */
	M(NBLK,		'K','F',	mssnblock),	/* start float keep */
	M(NONE,		0,0,		0)
};

struct	mactab	mmmactab[] = {
	M(NONE,		'H',' ',	MMHU),	/* -mm ? */
	M(NONE,		'H','U',	MMHU),	/* -mm ? */
	M(PARAG,	'P',' ',	PP),	/* paragraph for -mm */
	M(NBLK,		'N','S',	mssnblock),	/* undocumented */
	M(NONE,		0,0,		0)
};

struct	mactab	memactab[] = {
	M(PARAG,	'p','p',	mepp),
	M(PARAG,	'l','p',	mepp),
	M(PARAG,	'n','p',	mepp),
	M(NONE,		'i','p',	meip),

	M(NONE,		's','h',	mesh),
	M(NONE,		'u','h',	mesh),

	M(NBLK,		'(','l',	mesnblock),
	M(NBLK,		'(','q',	mesnblock),
	M(NBLK,		'(','b',	mesnblock),
	M(NBLK,		'(','z',	mesnblock),
	M(NBLK,		'(','c',	mesnblock),

	M(NBLK,		'(','d',	mesnblock),
	M(NBLK,		'(','f',	mesnblock),
	M(NBLK,		'(','x',	mesnblock),

	M(NONE,		'r',' ',	mefont),
	M(NONE,		'i',' ',	mefont),
	M(NONE,		'b',' ',	mefont),
	M(NONE,		'u',' ',	mefont),
	M(NONE,		'q',' ',	mefont),
	M(NONE,		'r','b',	mefont),
	M(NONE,		'b','i',	mefont),
	M(NONE,		'b','x',	mefont),
	M(NONE,		0,0,		0)
};

struct	mactab	manmactab[] = {
	M(PARAG,	'B','I',	manfont),
	M(PARAG,	'B','R',	manfont),
	M(PARAG,	'I','B',	manfont),
	M(PARAG,	'I','R',	manfont),
	M(PARAG,	'R','B',	manfont),
	M(PARAG,	'R','I',	manfont),

	M(PARAG,	'P','P',	manpp),
	M(PARAG,	'L','P',	manpp),
	M(PARAG,	'H','P',	manpp),
	M(NONE,		0,0,		0)
};