xref: /illumos-gate/usr/src/cmd/troff/nroff.d/n6.c (revision d7c57852)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23*d7c57852SGary Mills  * Copyright 2017 Gary Mills
247c478bd9Sstevel@tonic-gate  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
257c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
297c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate /*
327c478bd9Sstevel@tonic-gate  * University Copyright- Copyright (c) 1982, 1986, 1988
337c478bd9Sstevel@tonic-gate  * The Regents of the University of California
347c478bd9Sstevel@tonic-gate  * All Rights Reserved
357c478bd9Sstevel@tonic-gate  *
367c478bd9Sstevel@tonic-gate  * University Acknowledgment- Portions of this document are derived from
377c478bd9Sstevel@tonic-gate  * software developed by the University of California, Berkeley, and its
387c478bd9Sstevel@tonic-gate  * contributors.
397c478bd9Sstevel@tonic-gate  */
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #include "tdef.h"
427c478bd9Sstevel@tonic-gate #include "tw.h"
437c478bd9Sstevel@tonic-gate #include "ext.h"
447c478bd9Sstevel@tonic-gate #include <ctype.h>
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate /*
477c478bd9Sstevel@tonic-gate  * n6.c -- width functions, sizes and fonts
487c478bd9Sstevel@tonic-gate */
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate int	bdtab[NFONT+1] ={ 0, 0, 0, 3, 3, 0, };
517c478bd9Sstevel@tonic-gate int	sbold = 0;
527c478bd9Sstevel@tonic-gate int	fontlab[NFONT+1] = { 0, 'R', 'I', 'B', PAIR('B','I'), 'S', 0 };
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate extern	int	nchtab;
557c478bd9Sstevel@tonic-gate 
56e5190c10Smuffin int
width(j)577c478bd9Sstevel@tonic-gate width(j)
58e5190c10Smuffin tchar j;
597c478bd9Sstevel@tonic-gate {
60e5190c10Smuffin 	int	i, k;
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate 	if (j & (ZBIT|MOT)) {
637c478bd9Sstevel@tonic-gate 		if (iszbit(j))
647c478bd9Sstevel@tonic-gate 			return(0);
657c478bd9Sstevel@tonic-gate 		if (isvmot(j))
667c478bd9Sstevel@tonic-gate 			return(0);
677c478bd9Sstevel@tonic-gate 		k = absmot(j);
687c478bd9Sstevel@tonic-gate 		if (isnmot(j))
697c478bd9Sstevel@tonic-gate 			k = -k;
707c478bd9Sstevel@tonic-gate 		return(k);
717c478bd9Sstevel@tonic-gate 	}
727c478bd9Sstevel@tonic-gate 	i = cbits(j);
737c478bd9Sstevel@tonic-gate 	if (i < ' ') {
747c478bd9Sstevel@tonic-gate 		if (i == '\b')
757c478bd9Sstevel@tonic-gate 			return(-widthp);
767c478bd9Sstevel@tonic-gate 		if (i == PRESC)
777c478bd9Sstevel@tonic-gate 			i = eschar;
787c478bd9Sstevel@tonic-gate 		else if (iscontrol(i))
797c478bd9Sstevel@tonic-gate 			return(0);
807c478bd9Sstevel@tonic-gate 	}
817c478bd9Sstevel@tonic-gate 	if (i==ohc)
827c478bd9Sstevel@tonic-gate 		return(0);
837c478bd9Sstevel@tonic-gate #ifdef EUC
847c478bd9Sstevel@tonic-gate #ifdef NROFF
857c478bd9Sstevel@tonic-gate 	if (multi_locale) {
867c478bd9Sstevel@tonic-gate 		if ((j & MBMASK) || (j & CSMASK)) {
877c478bd9Sstevel@tonic-gate 			switch(j & MBMASK) {
887c478bd9Sstevel@tonic-gate 				case BYTE_CHR:
897c478bd9Sstevel@tonic-gate 				case LASTOFMB:
907c478bd9Sstevel@tonic-gate 					k = t.Char * csi_width[cs(j)];
917c478bd9Sstevel@tonic-gate 					break;
927c478bd9Sstevel@tonic-gate 				default:
937c478bd9Sstevel@tonic-gate 					k = 0;
947c478bd9Sstevel@tonic-gate 					break;
957c478bd9Sstevel@tonic-gate 			}
967c478bd9Sstevel@tonic-gate 			widthp = k;
977c478bd9Sstevel@tonic-gate 			return(k);
987c478bd9Sstevel@tonic-gate 		}
997c478bd9Sstevel@tonic-gate 	}
1007c478bd9Sstevel@tonic-gate 	i &= 0x1ff;
1017c478bd9Sstevel@tonic-gate #endif /* NROFF */
1027c478bd9Sstevel@tonic-gate #endif /* EUC */
1037c478bd9Sstevel@tonic-gate 	i = trtab[i];
1047c478bd9Sstevel@tonic-gate 	if (i < 32)
1057c478bd9Sstevel@tonic-gate 		return(0);
1067c478bd9Sstevel@tonic-gate 	k = t.width[i] * t.Char;
1077c478bd9Sstevel@tonic-gate 	widthp = k;
1087c478bd9Sstevel@tonic-gate 	return(k);
1097c478bd9Sstevel@tonic-gate }
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate 
setch()1127c478bd9Sstevel@tonic-gate tchar setch()
1137c478bd9Sstevel@tonic-gate {
114e5190c10Smuffin 	int	j;
1157c478bd9Sstevel@tonic-gate 	char	temp[10];
116e5190c10Smuffin 	char	*s;
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate 	s = temp;
1197c478bd9Sstevel@tonic-gate 	if ((*s++ = getach()) == 0 || (*s++ = getach()) == 0)
1207c478bd9Sstevel@tonic-gate 		return(0);
1217c478bd9Sstevel@tonic-gate 	*s = '\0';
1227c478bd9Sstevel@tonic-gate 	if ((j = findch(temp)) > 0)
1237c478bd9Sstevel@tonic-gate 		return j | chbits;
1247c478bd9Sstevel@tonic-gate 	else
1257c478bd9Sstevel@tonic-gate 		return 0;
1267c478bd9Sstevel@tonic-gate }
1277c478bd9Sstevel@tonic-gate 
setabs()1287c478bd9Sstevel@tonic-gate tchar setabs()		/* set absolute char from \C'...' */
1297c478bd9Sstevel@tonic-gate {			/* for now, a no-op */
1307c478bd9Sstevel@tonic-gate 	int i, n, nf;
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate 	getch();
1337c478bd9Sstevel@tonic-gate 	n = 0;
1347c478bd9Sstevel@tonic-gate 	n = inumb(&n);
1357c478bd9Sstevel@tonic-gate 	getch();
1367c478bd9Sstevel@tonic-gate 	if (nonumb)
1377c478bd9Sstevel@tonic-gate 		return 0;
1387c478bd9Sstevel@tonic-gate 	return n + nchtab + _SPECCHAR_ST;
1397c478bd9Sstevel@tonic-gate }
1407c478bd9Sstevel@tonic-gate 
141e5190c10Smuffin int
findft(i)1427c478bd9Sstevel@tonic-gate findft(i)
143e5190c10Smuffin int	i;
1447c478bd9Sstevel@tonic-gate {
145e5190c10Smuffin 	int	k;
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate 	if ((k = i - '0') >= 0 && k <= nfonts && k < smnt)
1487c478bd9Sstevel@tonic-gate 		return(k);
1497c478bd9Sstevel@tonic-gate 	for (k = 0; fontlab[k] != i; k++)
1507c478bd9Sstevel@tonic-gate 		if (k > nfonts)
1517c478bd9Sstevel@tonic-gate 			return(-1);
1527c478bd9Sstevel@tonic-gate 	return(k);
1537c478bd9Sstevel@tonic-gate }
1547c478bd9Sstevel@tonic-gate 
155e5190c10Smuffin int
caseps()1567c478bd9Sstevel@tonic-gate caseps()
1577c478bd9Sstevel@tonic-gate {
158e5190c10Smuffin 	return (0);
1597c478bd9Sstevel@tonic-gate }
1607c478bd9Sstevel@tonic-gate 
161e5190c10Smuffin int
mchbits()1627c478bd9Sstevel@tonic-gate mchbits()
1637c478bd9Sstevel@tonic-gate {
1647c478bd9Sstevel@tonic-gate 	chbits = 0;
1657c478bd9Sstevel@tonic-gate 	setfbits(chbits, font);
1667c478bd9Sstevel@tonic-gate 	sps = width(' ' | chbits);
167e5190c10Smuffin 
168e5190c10Smuffin 	return (0);
1697c478bd9Sstevel@tonic-gate }
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate 
172e5190c10Smuffin int
setps()1737c478bd9Sstevel@tonic-gate setps()
1747c478bd9Sstevel@tonic-gate {
175e5190c10Smuffin 	int	i, j;
1767c478bd9Sstevel@tonic-gate 
1777c478bd9Sstevel@tonic-gate 	i = cbits(getch());
1787c478bd9Sstevel@tonic-gate 	if (ischar(i) && isdigit(i)) {		/* \sd or \sdd */
1797c478bd9Sstevel@tonic-gate 		i -= '0';
1807c478bd9Sstevel@tonic-gate 		if (i == 0)		/* \s0 */
1817c478bd9Sstevel@tonic-gate 			;
1827c478bd9Sstevel@tonic-gate 		else if (i <= 3 && ischar(j = cbits(ch = getch())) &&
1837c478bd9Sstevel@tonic-gate 		    isdigit(j)) {	/* \sdd */
1847c478bd9Sstevel@tonic-gate 			ch = 0;
1857c478bd9Sstevel@tonic-gate 		}
1867c478bd9Sstevel@tonic-gate 	} else if (i == '(') {		/* \s(dd */
1877c478bd9Sstevel@tonic-gate 		getch();
1887c478bd9Sstevel@tonic-gate 		getch();
1897c478bd9Sstevel@tonic-gate 	} else if (i == '+' || i == '-') {	/* \s+, \s- */
1907c478bd9Sstevel@tonic-gate 		j = cbits(getch());
1917c478bd9Sstevel@tonic-gate 		if (ischar(j) && isdigit(j)) {		/* \s+d, \s-d */
1927c478bd9Sstevel@tonic-gate 			;
1937c478bd9Sstevel@tonic-gate 		} else if (j == '(') {		/* \s+(dd, \s-(dd */
1947c478bd9Sstevel@tonic-gate 			getch();
1957c478bd9Sstevel@tonic-gate 			getch();
1967c478bd9Sstevel@tonic-gate 		}
1977c478bd9Sstevel@tonic-gate 	}
198e5190c10Smuffin 
199e5190c10Smuffin 	return (0);
2007c478bd9Sstevel@tonic-gate }
2017c478bd9Sstevel@tonic-gate 
2027c478bd9Sstevel@tonic-gate 
setht()2037c478bd9Sstevel@tonic-gate tchar setht()		/* set character height from \H'...' */
2047c478bd9Sstevel@tonic-gate {
2057c478bd9Sstevel@tonic-gate 	tchar c;
2067c478bd9Sstevel@tonic-gate 
2077c478bd9Sstevel@tonic-gate 	getch();
208*d7c57852SGary Mills 	(void) inumb(&apts);
2097c478bd9Sstevel@tonic-gate 	getch();
2107c478bd9Sstevel@tonic-gate 	return(0);
2117c478bd9Sstevel@tonic-gate }
2127c478bd9Sstevel@tonic-gate 
2137c478bd9Sstevel@tonic-gate 
setslant()2147c478bd9Sstevel@tonic-gate tchar setslant()		/* set slant from \S'...' */
2157c478bd9Sstevel@tonic-gate {
2167c478bd9Sstevel@tonic-gate 	int	n;
2177c478bd9Sstevel@tonic-gate 	tchar c;
2187c478bd9Sstevel@tonic-gate 
2197c478bd9Sstevel@tonic-gate 	getch();
2207c478bd9Sstevel@tonic-gate 	n = 0;
2217c478bd9Sstevel@tonic-gate 	n = inumb(&n);
2227c478bd9Sstevel@tonic-gate 	getch();
2237c478bd9Sstevel@tonic-gate 	return(0);
2247c478bd9Sstevel@tonic-gate }
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate 
227e5190c10Smuffin int
caseft()2287c478bd9Sstevel@tonic-gate caseft()
2297c478bd9Sstevel@tonic-gate {
2307c478bd9Sstevel@tonic-gate 	skip();
2317c478bd9Sstevel@tonic-gate 	setfont(1);
232e5190c10Smuffin 
233e5190c10Smuffin 	return (0);
2347c478bd9Sstevel@tonic-gate }
2357c478bd9Sstevel@tonic-gate 
2367c478bd9Sstevel@tonic-gate 
237e5190c10Smuffin int
setfont(a)2387c478bd9Sstevel@tonic-gate setfont(a)
2397c478bd9Sstevel@tonic-gate int	a;
2407c478bd9Sstevel@tonic-gate {
241e5190c10Smuffin 	int	i, j;
2427c478bd9Sstevel@tonic-gate 
2437c478bd9Sstevel@tonic-gate 	if (a)
2447c478bd9Sstevel@tonic-gate 		i = getrq();
2452bc98732SRichard Lowe 	else
2467c478bd9Sstevel@tonic-gate 		i = getsn();
2477c478bd9Sstevel@tonic-gate 	if (!i || i == 'P') {
2487c478bd9Sstevel@tonic-gate 		j = font1;
2497c478bd9Sstevel@tonic-gate 		goto s0;
2507c478bd9Sstevel@tonic-gate 	}
2517c478bd9Sstevel@tonic-gate 	if (i == 'S' || i == '0')
252e5190c10Smuffin 		return (0);
2537c478bd9Sstevel@tonic-gate 	if ((j = findft(i, fontlab)) == -1)
254e5190c10Smuffin 		return (0);
2557c478bd9Sstevel@tonic-gate s0:
2567c478bd9Sstevel@tonic-gate 	font1 = font;
2577c478bd9Sstevel@tonic-gate 	font = j;
2587c478bd9Sstevel@tonic-gate 	mchbits();
259e5190c10Smuffin 
260e5190c10Smuffin 	return (0);
2617c478bd9Sstevel@tonic-gate }
2627c478bd9Sstevel@tonic-gate 
2637c478bd9Sstevel@tonic-gate 
264e5190c10Smuffin int
setwd()2657c478bd9Sstevel@tonic-gate setwd()
2667c478bd9Sstevel@tonic-gate {
267e5190c10Smuffin 	int	base, wid;
268e5190c10Smuffin 	tchar i;
2697c478bd9Sstevel@tonic-gate 	int	delim, emsz, k;
2707c478bd9Sstevel@tonic-gate 	int	savhp, savapts, savapts1, savfont, savfont1, savpts, savpts1;
2717c478bd9Sstevel@tonic-gate 
2722bc98732SRichard Lowe 	base = numtab[ST].val = wid = numtab[CT].val = 0;
2737c478bd9Sstevel@tonic-gate 	if (ismot(i = getch()))
274e5190c10Smuffin 		return (0);
2757c478bd9Sstevel@tonic-gate 	delim = cbits(i);
2767c478bd9Sstevel@tonic-gate 	savhp = numtab[HP].val;
2777c478bd9Sstevel@tonic-gate 	numtab[HP].val = 0;
2787c478bd9Sstevel@tonic-gate 	savapts = apts;
2797c478bd9Sstevel@tonic-gate 	savapts1 = apts1;
2807c478bd9Sstevel@tonic-gate 	savfont = font;
2817c478bd9Sstevel@tonic-gate 	savfont1 = font1;
2827c478bd9Sstevel@tonic-gate 	savpts = pts;
2837c478bd9Sstevel@tonic-gate 	savpts1 = pts1;
2847c478bd9Sstevel@tonic-gate 	setwdf++;
2857c478bd9Sstevel@tonic-gate 	while (cbits(i = getch()) != delim && !nlflg) {
2867c478bd9Sstevel@tonic-gate 		k = width(i);
2877c478bd9Sstevel@tonic-gate 		wid += k;
2887c478bd9Sstevel@tonic-gate 		numtab[HP].val += k;
2897c478bd9Sstevel@tonic-gate 		if (!ismot(i)) {
2907c478bd9Sstevel@tonic-gate 			emsz = (INCH * pts + 36) / 72;
2917c478bd9Sstevel@tonic-gate 		} else if (isvmot(i)) {
2927c478bd9Sstevel@tonic-gate 			k = absmot(i);
2937c478bd9Sstevel@tonic-gate 			if (isnmot(i))
2947c478bd9Sstevel@tonic-gate 				k = -k;
2957c478bd9Sstevel@tonic-gate 			base -= k;
2967c478bd9Sstevel@tonic-gate 			emsz = 0;
2972bc98732SRichard Lowe 		} else
2987c478bd9Sstevel@tonic-gate 			continue;
2997c478bd9Sstevel@tonic-gate 		if (base < numtab[SB].val)
3007c478bd9Sstevel@tonic-gate 			numtab[SB].val = base;
3017c478bd9Sstevel@tonic-gate 		if ((k = base + emsz) > numtab[ST].val)
3027c478bd9Sstevel@tonic-gate 			numtab[ST].val = k;
3037c478bd9Sstevel@tonic-gate 	}
3047c478bd9Sstevel@tonic-gate 	setn1(wid, 0, (tchar) 0);
3057c478bd9Sstevel@tonic-gate 	numtab[HP].val = savhp;
3067c478bd9Sstevel@tonic-gate 	apts = savapts;
3077c478bd9Sstevel@tonic-gate 	apts1 = savapts1;
3087c478bd9Sstevel@tonic-gate 	font = savfont;
3097c478bd9Sstevel@tonic-gate 	font1 = savfont1;
3107c478bd9Sstevel@tonic-gate 	pts = savpts;
3117c478bd9Sstevel@tonic-gate 	pts1 = savpts1;
3127c478bd9Sstevel@tonic-gate 	mchbits();
3137c478bd9Sstevel@tonic-gate 	setwdf = 0;
314e5190c10Smuffin 
315e5190c10Smuffin 	return (0);
3167c478bd9Sstevel@tonic-gate }
3177c478bd9Sstevel@tonic-gate 
3187c478bd9Sstevel@tonic-gate 
vmot()3197c478bd9Sstevel@tonic-gate tchar vmot()
3207c478bd9Sstevel@tonic-gate {
3217c478bd9Sstevel@tonic-gate 	dfact = lss;
3227c478bd9Sstevel@tonic-gate 	vflag++;
3237c478bd9Sstevel@tonic-gate 	return(mot());
3247c478bd9Sstevel@tonic-gate }
3257c478bd9Sstevel@tonic-gate 
3267c478bd9Sstevel@tonic-gate 
hmot()3277c478bd9Sstevel@tonic-gate tchar hmot()
3287c478bd9Sstevel@tonic-gate {
3297c478bd9Sstevel@tonic-gate 	dfact = EM;
3307c478bd9Sstevel@tonic-gate 	return(mot());
3317c478bd9Sstevel@tonic-gate }
3327c478bd9Sstevel@tonic-gate 
3337c478bd9Sstevel@tonic-gate 
mot()3347c478bd9Sstevel@tonic-gate tchar mot()
3357c478bd9Sstevel@tonic-gate {
336e5190c10Smuffin 	int j, n;
337e5190c10Smuffin 	tchar i;
3387c478bd9Sstevel@tonic-gate 
3397c478bd9Sstevel@tonic-gate 	j = HOR;
3407c478bd9Sstevel@tonic-gate 	getch(); /*eat delim*/
3417c478bd9Sstevel@tonic-gate 	if (n = atoi()) {
3427c478bd9Sstevel@tonic-gate 		if (vflag)
3437c478bd9Sstevel@tonic-gate 			j = VERT;
3447c478bd9Sstevel@tonic-gate 		i = makem(quant(n, j));
3457c478bd9Sstevel@tonic-gate 	} else
3467c478bd9Sstevel@tonic-gate 		i = 0;
3477c478bd9Sstevel@tonic-gate 	getch();
3487c478bd9Sstevel@tonic-gate 	vflag = 0;
3497c478bd9Sstevel@tonic-gate 	dfact = 1;
3507c478bd9Sstevel@tonic-gate 	return(i);
3517c478bd9Sstevel@tonic-gate }
3527c478bd9Sstevel@tonic-gate 
3537c478bd9Sstevel@tonic-gate 
sethl(k)3547c478bd9Sstevel@tonic-gate tchar sethl(k)
3557c478bd9Sstevel@tonic-gate int	k;
3567c478bd9Sstevel@tonic-gate {
357e5190c10Smuffin 	int	j;
3587c478bd9Sstevel@tonic-gate 	tchar i;
3597c478bd9Sstevel@tonic-gate 
3607c478bd9Sstevel@tonic-gate 	j = t.Halfline;
3617c478bd9Sstevel@tonic-gate 	if (k == 'u')
3627c478bd9Sstevel@tonic-gate 		j = -j;
3637c478bd9Sstevel@tonic-gate 	else if (k == 'r')
3647c478bd9Sstevel@tonic-gate 		j = -2 * j;
3657c478bd9Sstevel@tonic-gate 	vflag++;
3667c478bd9Sstevel@tonic-gate 	i = makem(j);
3677c478bd9Sstevel@tonic-gate 	vflag = 0;
3687c478bd9Sstevel@tonic-gate 	return(i);
3697c478bd9Sstevel@tonic-gate }
3707c478bd9Sstevel@tonic-gate 
3717c478bd9Sstevel@tonic-gate 
makem(i)3727c478bd9Sstevel@tonic-gate tchar makem(i)
3737c478bd9Sstevel@tonic-gate int	i;
3747c478bd9Sstevel@tonic-gate {
375e5190c10Smuffin 	tchar j;
3767c478bd9Sstevel@tonic-gate 
3777c478bd9Sstevel@tonic-gate 	if ((j = i) < 0)
3787c478bd9Sstevel@tonic-gate 		j = -j;
3797c478bd9Sstevel@tonic-gate 	j |= MOT;
3807c478bd9Sstevel@tonic-gate 	if (i < 0)
3817c478bd9Sstevel@tonic-gate 		j |= NMOT;
3827c478bd9Sstevel@tonic-gate 	if (vflag)
3837c478bd9Sstevel@tonic-gate 		j |= VMOT;
3847c478bd9Sstevel@tonic-gate 	return(j);
3857c478bd9Sstevel@tonic-gate }
3867c478bd9Sstevel@tonic-gate 
3877c478bd9Sstevel@tonic-gate 
getlg(i)3887c478bd9Sstevel@tonic-gate tchar getlg(i)
3897c478bd9Sstevel@tonic-gate tchar	i;
3907c478bd9Sstevel@tonic-gate {
3917c478bd9Sstevel@tonic-gate 	return(i);
3927c478bd9Sstevel@tonic-gate }
3937c478bd9Sstevel@tonic-gate 
3947c478bd9Sstevel@tonic-gate 
395e5190c10Smuffin int
caselg()3967c478bd9Sstevel@tonic-gate caselg()
3977c478bd9Sstevel@tonic-gate {
398e5190c10Smuffin 	return (0);
3997c478bd9Sstevel@tonic-gate }
4007c478bd9Sstevel@tonic-gate 
4017c478bd9Sstevel@tonic-gate 
402e5190c10Smuffin int
casefp()4037c478bd9Sstevel@tonic-gate casefp()
4047c478bd9Sstevel@tonic-gate {
405e5190c10Smuffin 	int	i, j;
4067c478bd9Sstevel@tonic-gate 
4077c478bd9Sstevel@tonic-gate 	skip();
4087c478bd9Sstevel@tonic-gate 	if ((i = cbits(getch()) - '0') < 0 || i > nfonts)
409e5190c10Smuffin 		return (0);
4107c478bd9Sstevel@tonic-gate 	if (skip() || !(j = getrq()))
411e5190c10Smuffin 		return (0);
4127c478bd9Sstevel@tonic-gate 	fontlab[i] = j;
413e5190c10Smuffin 
414e5190c10Smuffin 	return (0);
4157c478bd9Sstevel@tonic-gate }
4167c478bd9Sstevel@tonic-gate 
4177c478bd9Sstevel@tonic-gate 
418e5190c10Smuffin int
casecs()4197c478bd9Sstevel@tonic-gate casecs()
4207c478bd9Sstevel@tonic-gate {
421e5190c10Smuffin 	return (0);
4227c478bd9Sstevel@tonic-gate }
4237c478bd9Sstevel@tonic-gate 
4247c478bd9Sstevel@tonic-gate 
425e5190c10Smuffin int
casebd()4267c478bd9Sstevel@tonic-gate casebd()
4277c478bd9Sstevel@tonic-gate {
428e5190c10Smuffin 	int	i, j, k;
4297c478bd9Sstevel@tonic-gate 
4307c478bd9Sstevel@tonic-gate 	k = 0;
4317c478bd9Sstevel@tonic-gate bd0:
4327c478bd9Sstevel@tonic-gate 	if (skip() || !(i = getrq()) || (j = findft(i)) == -1) {
4337c478bd9Sstevel@tonic-gate 		if (k)
4347c478bd9Sstevel@tonic-gate 			goto bd1;
4352bc98732SRichard Lowe 		else
436e5190c10Smuffin 			return (0);
4377c478bd9Sstevel@tonic-gate 	}
4387c478bd9Sstevel@tonic-gate 	if (j == smnt) {
4397c478bd9Sstevel@tonic-gate 		k = smnt;
4407c478bd9Sstevel@tonic-gate 		goto bd0;
4417c478bd9Sstevel@tonic-gate 	}
4427c478bd9Sstevel@tonic-gate 	if (k) {
4437c478bd9Sstevel@tonic-gate 		sbold = j;
4447c478bd9Sstevel@tonic-gate 		j = k;
4457c478bd9Sstevel@tonic-gate 	}
4467c478bd9Sstevel@tonic-gate bd1:
4477c478bd9Sstevel@tonic-gate 	skip();
4487c478bd9Sstevel@tonic-gate 	noscale++;
4497c478bd9Sstevel@tonic-gate 	bdtab[j] = atoi();
4507c478bd9Sstevel@tonic-gate 	noscale = 0;
451e5190c10Smuffin 
452e5190c10Smuffin 	return (0);
4537c478bd9Sstevel@tonic-gate }
4547c478bd9Sstevel@tonic-gate 
4557c478bd9Sstevel@tonic-gate 
456e5190c10Smuffin int
casevs()4577c478bd9Sstevel@tonic-gate casevs()
4587c478bd9Sstevel@tonic-gate {
459e5190c10Smuffin 	int	i;
4607c478bd9Sstevel@tonic-gate 
4617c478bd9Sstevel@tonic-gate 	skip();
4627c478bd9Sstevel@tonic-gate 	vflag++;
4637c478bd9Sstevel@tonic-gate 	dfact = INCH; /*default scaling is points!*/
4647c478bd9Sstevel@tonic-gate 	dfactd = 72;
4657c478bd9Sstevel@tonic-gate 	res = VERT;
4667c478bd9Sstevel@tonic-gate 	i = inumb(&lss);
4677c478bd9Sstevel@tonic-gate 	if (nonumb)
4687c478bd9Sstevel@tonic-gate 		i = lss1;
4697c478bd9Sstevel@tonic-gate 	if (i < VERT)
4707c478bd9Sstevel@tonic-gate 		i = VERT;	/* was VERT */
4717c478bd9Sstevel@tonic-gate 	lss1 = lss;
4727c478bd9Sstevel@tonic-gate 	lss = i;
4737c478bd9Sstevel@tonic-gate 
474e5190c10Smuffin 	return (0);
475e5190c10Smuffin }
4767c478bd9Sstevel@tonic-gate 
4777c478bd9Sstevel@tonic-gate 
4787c478bd9Sstevel@tonic-gate 
479e5190c10Smuffin int
casess()4807c478bd9Sstevel@tonic-gate casess()
4817c478bd9Sstevel@tonic-gate {
482e5190c10Smuffin 	return (0);
4837c478bd9Sstevel@tonic-gate }
4847c478bd9Sstevel@tonic-gate 
4857c478bd9Sstevel@tonic-gate 
xlss()4867c478bd9Sstevel@tonic-gate tchar xlss()
4877c478bd9Sstevel@tonic-gate {
4887c478bd9Sstevel@tonic-gate 	/* stores \x'...' into
4897c478bd9Sstevel@tonic-gate 	 * two successive tchars.
4907c478bd9Sstevel@tonic-gate 	 * the first contains HX, the second the value,
4917c478bd9Sstevel@tonic-gate 	 * encoded as a vertical motion.
4927c478bd9Sstevel@tonic-gate 	 * decoding is done in n2.c by pchar().
4937c478bd9Sstevel@tonic-gate 	 */
4947c478bd9Sstevel@tonic-gate 	int	i;
4957c478bd9Sstevel@tonic-gate 
4967c478bd9Sstevel@tonic-gate 	getch();
4977c478bd9Sstevel@tonic-gate 	dfact = lss;
4987c478bd9Sstevel@tonic-gate 	i = quant(atoi(), VERT);
4997c478bd9Sstevel@tonic-gate 	dfact = 1;
5007c478bd9Sstevel@tonic-gate 	getch();
5017c478bd9Sstevel@tonic-gate 	if (i >= 0)
5027c478bd9Sstevel@tonic-gate 		*pbp++ = MOT | VMOT | i;
5037c478bd9Sstevel@tonic-gate 	else
5047c478bd9Sstevel@tonic-gate 		*pbp++ = MOT | VMOT | NMOT | -i;
5057c478bd9Sstevel@tonic-gate 	return(HX);
5067c478bd9Sstevel@tonic-gate }
507