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 /*
237c478bd9Sstevel@tonic-gate * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
287c478bd9Sstevel@tonic-gate /* All Rights Reserved */
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gate /*
317c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988
327c478bd9Sstevel@tonic-gate * The Regents of the University of California
337c478bd9Sstevel@tonic-gate * All Rights Reserved
347c478bd9Sstevel@tonic-gate *
357c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from
367c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its
377c478bd9Sstevel@tonic-gate * contributors.
387c478bd9Sstevel@tonic-gate */
397c478bd9Sstevel@tonic-gate
40*e5190c10Smuffin #pragma ident "%Z%%M% %I% %E% SMI"
41*e5190c10Smuffin
427c478bd9Sstevel@tonic-gate /*
437c478bd9Sstevel@tonic-gate n10.c
447c478bd9Sstevel@tonic-gate
457c478bd9Sstevel@tonic-gate Device interfaces
467c478bd9Sstevel@tonic-gate */
477c478bd9Sstevel@tonic-gate
487c478bd9Sstevel@tonic-gate #include <limits.h>
497c478bd9Sstevel@tonic-gate #include <ctype.h>
507c478bd9Sstevel@tonic-gate #include <sys/types.h>
517c478bd9Sstevel@tonic-gate #include <sys/stat.h>
527c478bd9Sstevel@tonic-gate #ifdef EUC
537c478bd9Sstevel@tonic-gate #ifdef NROFF
547c478bd9Sstevel@tonic-gate #include <stdlib.h>
557c478bd9Sstevel@tonic-gate #endif /* NROFF */
567c478bd9Sstevel@tonic-gate #endif /* EUC */
577c478bd9Sstevel@tonic-gate #include "tdef.h"
587c478bd9Sstevel@tonic-gate #include "ext.h"
597c478bd9Sstevel@tonic-gate #include "tw.h"
607c478bd9Sstevel@tonic-gate
617c478bd9Sstevel@tonic-gate struct t t; /* terminal characteristics */
627c478bd9Sstevel@tonic-gate
637c478bd9Sstevel@tonic-gate int dtab;
647c478bd9Sstevel@tonic-gate int plotmode;
657c478bd9Sstevel@tonic-gate int esct;
667c478bd9Sstevel@tonic-gate
677c478bd9Sstevel@tonic-gate char xchname[4 * (NROFFCHARS-_SPECCHAR_ST)]; /* hy, em, etc. */
687c478bd9Sstevel@tonic-gate short xchtab[NROFFCHARS-_SPECCHAR_ST]; /* indexes into chname[] */
697c478bd9Sstevel@tonic-gate char *codestr;
707c478bd9Sstevel@tonic-gate char *chname = xchname;
717c478bd9Sstevel@tonic-gate short *chtab = xchtab;
727c478bd9Sstevel@tonic-gate int nchtab = 0;
737c478bd9Sstevel@tonic-gate
747c478bd9Sstevel@tonic-gate
757c478bd9Sstevel@tonic-gate int Inch;
767c478bd9Sstevel@tonic-gate int Hor;
777c478bd9Sstevel@tonic-gate int Vert;
787c478bd9Sstevel@tonic-gate int nfonts = 4; /* R, I, B, S */
797c478bd9Sstevel@tonic-gate
807c478bd9Sstevel@tonic-gate /* these characters are used as various signals or values
817c478bd9Sstevel@tonic-gate * in miscellaneous places.
827c478bd9Sstevel@tonic-gate * values are set in specnames in t10.c
837c478bd9Sstevel@tonic-gate */
847c478bd9Sstevel@tonic-gate
857c478bd9Sstevel@tonic-gate int c_hyphen;
867c478bd9Sstevel@tonic-gate int c_emdash;
877c478bd9Sstevel@tonic-gate int c_rule;
887c478bd9Sstevel@tonic-gate int c_minus;
897c478bd9Sstevel@tonic-gate int c_fi;
907c478bd9Sstevel@tonic-gate int c_fl;
917c478bd9Sstevel@tonic-gate int c_ff;
927c478bd9Sstevel@tonic-gate int c_ffi;
937c478bd9Sstevel@tonic-gate int c_ffl;
947c478bd9Sstevel@tonic-gate int c_acute;
957c478bd9Sstevel@tonic-gate int c_grave;
967c478bd9Sstevel@tonic-gate int c_under;
977c478bd9Sstevel@tonic-gate int c_rooten;
987c478bd9Sstevel@tonic-gate int c_boxrule;
997c478bd9Sstevel@tonic-gate int c_lefthand;
1007c478bd9Sstevel@tonic-gate int c_dagger;
1017c478bd9Sstevel@tonic-gate int c_isalnum;
1027c478bd9Sstevel@tonic-gate
103*e5190c10Smuffin int
ptinit()1047c478bd9Sstevel@tonic-gate ptinit()
1057c478bd9Sstevel@tonic-gate {
106*e5190c10Smuffin int i, j;
107*e5190c10Smuffin char *p, *cp, *q;
1087c478bd9Sstevel@tonic-gate int nread, fd;
1097c478bd9Sstevel@tonic-gate extern char *skipstr(), *getstr(), *getint();
1107c478bd9Sstevel@tonic-gate extern char *setbrk();
1117c478bd9Sstevel@tonic-gate struct stat stbuf;
1127c478bd9Sstevel@tonic-gate char check[50];
1137c478bd9Sstevel@tonic-gate
1147c478bd9Sstevel@tonic-gate strcat(termtab, devname);
1157c478bd9Sstevel@tonic-gate if ((fd = open(termtab, 0)) < 0) {
1167c478bd9Sstevel@tonic-gate errprint(gettext("cannot open %s"), termtab);
1177c478bd9Sstevel@tonic-gate exit(-1);
1187c478bd9Sstevel@tonic-gate }
1197c478bd9Sstevel@tonic-gate
1207c478bd9Sstevel@tonic-gate fstat(fd, &stbuf);
1217c478bd9Sstevel@tonic-gate codestr = setbrk((int) stbuf.st_size);
1227c478bd9Sstevel@tonic-gate
1237c478bd9Sstevel@tonic-gate nread = read(fd, codestr, (int) stbuf.st_size);
1247c478bd9Sstevel@tonic-gate close(fd);
1257c478bd9Sstevel@tonic-gate
1267c478bd9Sstevel@tonic-gate p = codestr;
1277c478bd9Sstevel@tonic-gate p = skipstr(p); /* skip over type, could check */
1287c478bd9Sstevel@tonic-gate p = skipstr(p); p = getint(p, &t.bset);
1297c478bd9Sstevel@tonic-gate p = skipstr(p); p = getint(p, &t.breset);
1307c478bd9Sstevel@tonic-gate p = skipstr(p); p = getint(p, &t.Hor);
1317c478bd9Sstevel@tonic-gate p = skipstr(p); p = getint(p, &t.Vert);
1327c478bd9Sstevel@tonic-gate p = skipstr(p); p = getint(p, &t.Newline);
1337c478bd9Sstevel@tonic-gate p = skipstr(p); p = getint(p, &t.Char);
1347c478bd9Sstevel@tonic-gate p = skipstr(p); p = getint(p, &t.Em);
1357c478bd9Sstevel@tonic-gate p = skipstr(p); p = getint(p, &t.Halfline);
1367c478bd9Sstevel@tonic-gate p = skipstr(p); p = getint(p, &t.Adj);
1377c478bd9Sstevel@tonic-gate p = skipstr(p); p = getstr(p, t.twinit = p);
1387c478bd9Sstevel@tonic-gate p = skipstr(p); p = getstr(p, t.twrest = p);
1397c478bd9Sstevel@tonic-gate p = skipstr(p); p = getstr(p, t.twnl = p);
1407c478bd9Sstevel@tonic-gate p = skipstr(p); p = getstr(p, t.hlr = p);
1417c478bd9Sstevel@tonic-gate p = skipstr(p); p = getstr(p, t.hlf = p);
1427c478bd9Sstevel@tonic-gate p = skipstr(p); p = getstr(p, t.flr = p);
1437c478bd9Sstevel@tonic-gate p = skipstr(p); p = getstr(p, t.bdon = p);
1447c478bd9Sstevel@tonic-gate p = skipstr(p); p = getstr(p, t.bdoff = p);
1457c478bd9Sstevel@tonic-gate p = skipstr(p); p = getstr(p, t.iton = p);
1467c478bd9Sstevel@tonic-gate p = skipstr(p); p = getstr(p, t.itoff = p);
1477c478bd9Sstevel@tonic-gate p = skipstr(p); p = getstr(p, t.ploton = p);
1487c478bd9Sstevel@tonic-gate p = skipstr(p); p = getstr(p, t.plotoff = p);
1497c478bd9Sstevel@tonic-gate p = skipstr(p); p = getstr(p, t.up = p);
1507c478bd9Sstevel@tonic-gate p = skipstr(p); p = getstr(p, t.down = p);
1517c478bd9Sstevel@tonic-gate p = skipstr(p); p = getstr(p, t.right = p);
1527c478bd9Sstevel@tonic-gate p = skipstr(p); p = getstr(p, t.left = p);
1537c478bd9Sstevel@tonic-gate
1547c478bd9Sstevel@tonic-gate getstr(p, check);
1557c478bd9Sstevel@tonic-gate if (strcmp(check, "charset") != 0) {
1567c478bd9Sstevel@tonic-gate errprint(gettext("device table apparently curdled"));
1577c478bd9Sstevel@tonic-gate exit(1);
1587c478bd9Sstevel@tonic-gate }
1597c478bd9Sstevel@tonic-gate
1607c478bd9Sstevel@tonic-gate for (i = 0; i < _SPECCHAR_ST; i++)
1617c478bd9Sstevel@tonic-gate t.width[i] = 1; /* default widths */
1627c478bd9Sstevel@tonic-gate
1637c478bd9Sstevel@tonic-gate i = 0;
1647c478bd9Sstevel@tonic-gate /* this ought to be a pointer array and in place in codestr */
1657c478bd9Sstevel@tonic-gate cp = chname + 1; /* bug if starts at 0, in setch */
1667c478bd9Sstevel@tonic-gate while (p < codestr + nread) {
1677c478bd9Sstevel@tonic-gate while (*p == ' ' || *p == '\t' || *p == '\n')
1687c478bd9Sstevel@tonic-gate p++;
1697c478bd9Sstevel@tonic-gate if (i + _SPECCHAR_ST >= NROFFCHARS) {
1707c478bd9Sstevel@tonic-gate errprint(gettext("too many names in charset for %s"),
1717c478bd9Sstevel@tonic-gate termtab);
1727c478bd9Sstevel@tonic-gate exit(1);
1737c478bd9Sstevel@tonic-gate }
1747c478bd9Sstevel@tonic-gate chtab[i] = cp - chname; /* index, not pointer */
1757c478bd9Sstevel@tonic-gate *cp++ = *p++; /* 2-char names */
1767c478bd9Sstevel@tonic-gate *cp++ = *p++;
1777c478bd9Sstevel@tonic-gate *cp++ = '\0';
1787c478bd9Sstevel@tonic-gate while (*p == ' ' || *p == '\t')
1797c478bd9Sstevel@tonic-gate p++;
1807c478bd9Sstevel@tonic-gate t.width[i+_SPECCHAR_ST] = *p++ - '0';
1817c478bd9Sstevel@tonic-gate while (*p == ' ' || *p == '\t')
1827c478bd9Sstevel@tonic-gate p++;
1837c478bd9Sstevel@tonic-gate t.codetab[i] = p;
1847c478bd9Sstevel@tonic-gate p = getstr(p, p); /* compress string */
1857c478bd9Sstevel@tonic-gate p++;
1867c478bd9Sstevel@tonic-gate i++;
1877c478bd9Sstevel@tonic-gate nchtab++;
1887c478bd9Sstevel@tonic-gate }
1897c478bd9Sstevel@tonic-gate
1907c478bd9Sstevel@tonic-gate sps = EM;
1917c478bd9Sstevel@tonic-gate ics = EM * 2;
1927c478bd9Sstevel@tonic-gate dtab = 8 * t.Em;
1937c478bd9Sstevel@tonic-gate for (i = 0; i < 16; i++)
1947c478bd9Sstevel@tonic-gate tabtab[i] = dtab * (i + 1);
1957c478bd9Sstevel@tonic-gate pl = 11 * INCH;
1967c478bd9Sstevel@tonic-gate po = PO;
1977c478bd9Sstevel@tonic-gate spacesz = SS;
1987c478bd9Sstevel@tonic-gate lss = lss1 = VS;
1997c478bd9Sstevel@tonic-gate ll = ll1 = lt = lt1 = LL;
2007c478bd9Sstevel@tonic-gate smnt = nfonts = 5; /* R I B BI S */
2017c478bd9Sstevel@tonic-gate specnames(); /* install names like "hyphen", etc. */
2027c478bd9Sstevel@tonic-gate if (eqflg)
2037c478bd9Sstevel@tonic-gate t.Adj = t.Hor;
204*e5190c10Smuffin
205*e5190c10Smuffin return (0);
2067c478bd9Sstevel@tonic-gate }
2077c478bd9Sstevel@tonic-gate
skipstr(s)2087c478bd9Sstevel@tonic-gate char *skipstr(s) /* skip over leading space plus string */
2097c478bd9Sstevel@tonic-gate char *s;
2107c478bd9Sstevel@tonic-gate {
2117c478bd9Sstevel@tonic-gate while (*s == ' ' || *s == '\t' || *s == '\n')
2127c478bd9Sstevel@tonic-gate s++;
2137c478bd9Sstevel@tonic-gate while (*s != ' ' && *s != '\t' && *s != '\n')
2147c478bd9Sstevel@tonic-gate if (*s++ == '\\')
2157c478bd9Sstevel@tonic-gate s++;
2167c478bd9Sstevel@tonic-gate return s;
2177c478bd9Sstevel@tonic-gate }
2187c478bd9Sstevel@tonic-gate
getstr(s,t)2197c478bd9Sstevel@tonic-gate char *getstr(s, t) /* find next string in s, copy to t */
2207c478bd9Sstevel@tonic-gate char *s, *t;
2217c478bd9Sstevel@tonic-gate {
2227c478bd9Sstevel@tonic-gate int quote = 0;
2237c478bd9Sstevel@tonic-gate
2247c478bd9Sstevel@tonic-gate while (*s == ' ' || *s == '\t' || *s == '\n')
2257c478bd9Sstevel@tonic-gate s++;
2267c478bd9Sstevel@tonic-gate if (*s == '"') {
2277c478bd9Sstevel@tonic-gate s++;
2287c478bd9Sstevel@tonic-gate quote = 1;
2297c478bd9Sstevel@tonic-gate }
2307c478bd9Sstevel@tonic-gate for (;;) {
2317c478bd9Sstevel@tonic-gate if (quote && *s == '"') {
2327c478bd9Sstevel@tonic-gate s++;
2337c478bd9Sstevel@tonic-gate break;
2347c478bd9Sstevel@tonic-gate }
2357c478bd9Sstevel@tonic-gate if (!quote && (*s == ' ' || *s == '\t' || *s == '\n'))
2367c478bd9Sstevel@tonic-gate break;
2377c478bd9Sstevel@tonic-gate if (*s != '\\')
2387c478bd9Sstevel@tonic-gate *t++ = *s++;
2397c478bd9Sstevel@tonic-gate else {
2407c478bd9Sstevel@tonic-gate s++; /* skip \\ */
2417c478bd9Sstevel@tonic-gate if (isdigit((unsigned char)s[0]) &&
2427c478bd9Sstevel@tonic-gate isdigit((unsigned char)s[1]) &&
2437c478bd9Sstevel@tonic-gate isdigit((unsigned char)s[2])) {
2447c478bd9Sstevel@tonic-gate *t++ = (s[0]-'0')<<6 | (s[1]-'0')<<3 | s[2]-'0';
2457c478bd9Sstevel@tonic-gate s += 2;
2467c478bd9Sstevel@tonic-gate } else if (isdigit((unsigned char)s[0])) {
2477c478bd9Sstevel@tonic-gate *t++ = *s - '0';
2487c478bd9Sstevel@tonic-gate } else if (*s == 'b') {
2497c478bd9Sstevel@tonic-gate *t++ = '\b';
2507c478bd9Sstevel@tonic-gate } else if (*s == 'n') {
2517c478bd9Sstevel@tonic-gate *t++ = '\n';
2527c478bd9Sstevel@tonic-gate } else if (*s == 'r') {
2537c478bd9Sstevel@tonic-gate *t++ = '\r';
2547c478bd9Sstevel@tonic-gate } else if (*s == 't') {
2557c478bd9Sstevel@tonic-gate *t++ = '\t';
2567c478bd9Sstevel@tonic-gate } else {
2577c478bd9Sstevel@tonic-gate *t++ = *s;
2587c478bd9Sstevel@tonic-gate }
2597c478bd9Sstevel@tonic-gate s++;
2607c478bd9Sstevel@tonic-gate }
2617c478bd9Sstevel@tonic-gate }
2627c478bd9Sstevel@tonic-gate *t = '\0';
2637c478bd9Sstevel@tonic-gate return s;
2647c478bd9Sstevel@tonic-gate }
2657c478bd9Sstevel@tonic-gate
getint(s,pn)2667c478bd9Sstevel@tonic-gate char *getint(s, pn) /* find integer at s */
2677c478bd9Sstevel@tonic-gate char *s;
2687c478bd9Sstevel@tonic-gate int *pn;
2697c478bd9Sstevel@tonic-gate {
2707c478bd9Sstevel@tonic-gate int base;
2717c478bd9Sstevel@tonic-gate
2727c478bd9Sstevel@tonic-gate while (*s == ' ' || *s == '\t' || *s == '\n')
2737c478bd9Sstevel@tonic-gate s++;
2747c478bd9Sstevel@tonic-gate base = (*s == '0') ? 8 : 10;
2757c478bd9Sstevel@tonic-gate *pn = 0;
2767c478bd9Sstevel@tonic-gate while (isdigit((unsigned char)*s))
2777c478bd9Sstevel@tonic-gate *pn = base * *pn + *s++ - '0';
2787c478bd9Sstevel@tonic-gate return s;
2797c478bd9Sstevel@tonic-gate }
2807c478bd9Sstevel@tonic-gate
281*e5190c10Smuffin int
specnames()2827c478bd9Sstevel@tonic-gate specnames()
2837c478bd9Sstevel@tonic-gate {
2847c478bd9Sstevel@tonic-gate static struct {
2857c478bd9Sstevel@tonic-gate int *n;
2867c478bd9Sstevel@tonic-gate char *v;
2877c478bd9Sstevel@tonic-gate } spnames[] = {
2887c478bd9Sstevel@tonic-gate &c_hyphen, "hy",
2897c478bd9Sstevel@tonic-gate &c_emdash, "em",
2907c478bd9Sstevel@tonic-gate &c_rule, "ru",
2917c478bd9Sstevel@tonic-gate &c_minus, "\\-",
2927c478bd9Sstevel@tonic-gate &c_fi, "fi",
2937c478bd9Sstevel@tonic-gate &c_fl, "fl",
2947c478bd9Sstevel@tonic-gate &c_ff, "ff",
2957c478bd9Sstevel@tonic-gate &c_ffi, "Fi",
2967c478bd9Sstevel@tonic-gate &c_ffl, "Fl",
2977c478bd9Sstevel@tonic-gate &c_acute, "aa",
2987c478bd9Sstevel@tonic-gate &c_grave, "ga",
2997c478bd9Sstevel@tonic-gate &c_under, "ul",
3007c478bd9Sstevel@tonic-gate &c_rooten, "rn",
3017c478bd9Sstevel@tonic-gate &c_boxrule, "br",
3027c478bd9Sstevel@tonic-gate &c_lefthand, "lh",
3037c478bd9Sstevel@tonic-gate &c_isalnum, "__",
3047c478bd9Sstevel@tonic-gate 0, 0
3057c478bd9Sstevel@tonic-gate };
3067c478bd9Sstevel@tonic-gate int i;
3077c478bd9Sstevel@tonic-gate
3087c478bd9Sstevel@tonic-gate for (i = 0; spnames[i].n; i++)
3097c478bd9Sstevel@tonic-gate *spnames[i].n = findch(spnames[i].v);
3107c478bd9Sstevel@tonic-gate if (c_isalnum == 0)
3117c478bd9Sstevel@tonic-gate c_isalnum = NROFFCHARS;
312*e5190c10Smuffin
313*e5190c10Smuffin return (0);
3147c478bd9Sstevel@tonic-gate }
3157c478bd9Sstevel@tonic-gate
3167c478bd9Sstevel@tonic-gate
317*e5190c10Smuffin int
findch(s)3187c478bd9Sstevel@tonic-gate findch(s) /* find char s in chname */
319*e5190c10Smuffin char *s;
3207c478bd9Sstevel@tonic-gate {
321*e5190c10Smuffin int i;
3227c478bd9Sstevel@tonic-gate
3237c478bd9Sstevel@tonic-gate for (i = 0; chtab[i] != 0; i++)
3247c478bd9Sstevel@tonic-gate if (strcmp(s, &chname[chtab[i]]) == 0)
3257c478bd9Sstevel@tonic-gate return(i + _SPECCHAR_ST);
3267c478bd9Sstevel@tonic-gate return(0);
3277c478bd9Sstevel@tonic-gate }
3287c478bd9Sstevel@tonic-gate
329*e5190c10Smuffin int
twdone()3307c478bd9Sstevel@tonic-gate twdone()
3317c478bd9Sstevel@tonic-gate {
3327c478bd9Sstevel@tonic-gate int waitf;
3337c478bd9Sstevel@tonic-gate
3347c478bd9Sstevel@tonic-gate obufp = obuf;
3357c478bd9Sstevel@tonic-gate if (t.twrest) /* has ptinit() been done yet? */
3367c478bd9Sstevel@tonic-gate oputs(t.twrest);
3377c478bd9Sstevel@tonic-gate flusho();
3387c478bd9Sstevel@tonic-gate if (pipeflg) {
3397c478bd9Sstevel@tonic-gate close(ptid);
3407c478bd9Sstevel@tonic-gate wait(&waitf);
3417c478bd9Sstevel@tonic-gate }
3427c478bd9Sstevel@tonic-gate restore_tty();
343*e5190c10Smuffin
344*e5190c10Smuffin return (0);
3457c478bd9Sstevel@tonic-gate }
3467c478bd9Sstevel@tonic-gate
3477c478bd9Sstevel@tonic-gate
348*e5190c10Smuffin int
ptout(i)3497c478bd9Sstevel@tonic-gate ptout(i)
3507c478bd9Sstevel@tonic-gate tchar i;
3517c478bd9Sstevel@tonic-gate {
3527c478bd9Sstevel@tonic-gate *olinep++ = i;
3537c478bd9Sstevel@tonic-gate if (olinep >= &oline[LNSIZE])
3547c478bd9Sstevel@tonic-gate olinep--;
3557c478bd9Sstevel@tonic-gate if (cbits(i) != '\n')
356*e5190c10Smuffin return (0);
3577c478bd9Sstevel@tonic-gate olinep--;
3587c478bd9Sstevel@tonic-gate lead += dip->blss + lss - t.Newline;
3597c478bd9Sstevel@tonic-gate dip->blss = 0;
3607c478bd9Sstevel@tonic-gate esct = esc = 0;
3617c478bd9Sstevel@tonic-gate if (olinep > oline) {
3627c478bd9Sstevel@tonic-gate move();
3637c478bd9Sstevel@tonic-gate ptout1();
3647c478bd9Sstevel@tonic-gate oputs(t.twnl);
3657c478bd9Sstevel@tonic-gate } else {
3667c478bd9Sstevel@tonic-gate lead += t.Newline;
3677c478bd9Sstevel@tonic-gate move();
3687c478bd9Sstevel@tonic-gate }
3697c478bd9Sstevel@tonic-gate lead += dip->alss;
3707c478bd9Sstevel@tonic-gate dip->alss = 0;
3717c478bd9Sstevel@tonic-gate olinep = oline;
372*e5190c10Smuffin
373*e5190c10Smuffin return (0);
3747c478bd9Sstevel@tonic-gate }
3757c478bd9Sstevel@tonic-gate
3767c478bd9Sstevel@tonic-gate
377*e5190c10Smuffin int
ptout1()3787c478bd9Sstevel@tonic-gate ptout1()
3797c478bd9Sstevel@tonic-gate {
380*e5190c10Smuffin int k;
381*e5190c10Smuffin char *codep;
3827c478bd9Sstevel@tonic-gate #ifdef EUC
3837c478bd9Sstevel@tonic-gate #ifdef NROFF
384*e5190c10Smuffin int cnt;
385*e5190c10Smuffin tchar *qq;
3867c478bd9Sstevel@tonic-gate #endif /* NROFF */
3877c478bd9Sstevel@tonic-gate #endif /* EUC */
3887c478bd9Sstevel@tonic-gate extern char *plot();
3897c478bd9Sstevel@tonic-gate int w, j, phyw;
3907c478bd9Sstevel@tonic-gate #ifdef EUC
3917c478bd9Sstevel@tonic-gate #ifdef NROFF
3927c478bd9Sstevel@tonic-gate int jj;
3937c478bd9Sstevel@tonic-gate #endif /* NROFF */
3947c478bd9Sstevel@tonic-gate #endif /* EUC */
3957c478bd9Sstevel@tonic-gate tchar * q, i;
3967c478bd9Sstevel@tonic-gate static int oxfont = FT; /* start off in roman */
3977c478bd9Sstevel@tonic-gate
3987c478bd9Sstevel@tonic-gate for (q = oline; q < olinep; q++) {
3997c478bd9Sstevel@tonic-gate i = *q;
4007c478bd9Sstevel@tonic-gate if (ismot(i)) {
4017c478bd9Sstevel@tonic-gate j = absmot(i);
4027c478bd9Sstevel@tonic-gate if (isnmot(i))
4037c478bd9Sstevel@tonic-gate j = -j;
4047c478bd9Sstevel@tonic-gate if (isvmot(i))
4057c478bd9Sstevel@tonic-gate lead += j;
4067c478bd9Sstevel@tonic-gate else
4077c478bd9Sstevel@tonic-gate esc += j;
4087c478bd9Sstevel@tonic-gate continue;
4097c478bd9Sstevel@tonic-gate }
4107c478bd9Sstevel@tonic-gate if ((k = cbits(i)) <= 040) {
4117c478bd9Sstevel@tonic-gate switch (k) {
4127c478bd9Sstevel@tonic-gate case ' ': /*space*/
4137c478bd9Sstevel@tonic-gate esc += t.Char;
4147c478bd9Sstevel@tonic-gate break;
4157c478bd9Sstevel@tonic-gate case '\033':
4167c478bd9Sstevel@tonic-gate case '\007':
4177c478bd9Sstevel@tonic-gate case '\016':
4187c478bd9Sstevel@tonic-gate case '\017':
4197c478bd9Sstevel@tonic-gate oput(k);
4207c478bd9Sstevel@tonic-gate break;
4217c478bd9Sstevel@tonic-gate }
4227c478bd9Sstevel@tonic-gate continue;
4237c478bd9Sstevel@tonic-gate }
4247c478bd9Sstevel@tonic-gate #ifdef EUC
4257c478bd9Sstevel@tonic-gate #ifdef NROFF
4267c478bd9Sstevel@tonic-gate if (multi_locale && ((k & MBMASK) || (k & CSMASK))) {
4277c478bd9Sstevel@tonic-gate cnt = 0;
4287c478bd9Sstevel@tonic-gate while ((*q & MBMASK1) && (cnt + 1 < (int)MB_CUR_MAX)) {
4297c478bd9Sstevel@tonic-gate cnt++;
4307c478bd9Sstevel@tonic-gate q++;
4317c478bd9Sstevel@tonic-gate }
4327c478bd9Sstevel@tonic-gate if ((cnt && !(*q & CSMASK)) || (*q & MBMASK1)) {
4337c478bd9Sstevel@tonic-gate q -= cnt;
4347c478bd9Sstevel@tonic-gate cnt = 0;
4357c478bd9Sstevel@tonic-gate *q &= ~0xfe00;
4367c478bd9Sstevel@tonic-gate }
4377c478bd9Sstevel@tonic-gate k = cbits(i = *q);
4387c478bd9Sstevel@tonic-gate phyw = w = t.Char * csi_width[cs(i)];
4397c478bd9Sstevel@tonic-gate } else {
4407c478bd9Sstevel@tonic-gate #endif /* NROFF */
4417c478bd9Sstevel@tonic-gate #endif /* EUC */
4427c478bd9Sstevel@tonic-gate phyw = w = t.Char * t.width[k];
4437c478bd9Sstevel@tonic-gate if (iszbit(i))
4447c478bd9Sstevel@tonic-gate w = 0;
4457c478bd9Sstevel@tonic-gate #ifdef EUC
4467c478bd9Sstevel@tonic-gate #ifdef NROFF
4477c478bd9Sstevel@tonic-gate }
4487c478bd9Sstevel@tonic-gate #endif /* NROFF */
4497c478bd9Sstevel@tonic-gate #endif /* EUC */
4507c478bd9Sstevel@tonic-gate if (esc || lead)
4517c478bd9Sstevel@tonic-gate move();
4527c478bd9Sstevel@tonic-gate esct += w;
4537c478bd9Sstevel@tonic-gate #ifndef EUC
4547c478bd9Sstevel@tonic-gate xfont = fbits(i);
4557c478bd9Sstevel@tonic-gate #else
4567c478bd9Sstevel@tonic-gate #ifndef NROFF
4577c478bd9Sstevel@tonic-gate xfont = fbits(i);
4587c478bd9Sstevel@tonic-gate #else
4597c478bd9Sstevel@tonic-gate #endif /* NROFF */
4607c478bd9Sstevel@tonic-gate xfont = (fbits(*q) % NFONT); /* for invalid code */
4617c478bd9Sstevel@tonic-gate #endif /* EUC */
4627c478bd9Sstevel@tonic-gate if (xfont != oxfont) {
4637c478bd9Sstevel@tonic-gate if (oxfont == ulfont || oxfont == BIFONT)
4647c478bd9Sstevel@tonic-gate oputs(t.itoff);
4657c478bd9Sstevel@tonic-gate if (bdtab[oxfont])
4667c478bd9Sstevel@tonic-gate oputs(t.bdoff);
4677c478bd9Sstevel@tonic-gate if (xfont == ulfont || xfont == BIFONT)
4687c478bd9Sstevel@tonic-gate oputs(t.iton);
4697c478bd9Sstevel@tonic-gate if (bdtab[xfont])
4707c478bd9Sstevel@tonic-gate oputs(t.bdon);
4717c478bd9Sstevel@tonic-gate oxfont = xfont;
4727c478bd9Sstevel@tonic-gate }
4737c478bd9Sstevel@tonic-gate if ((xfont == ulfont || xfont == BIFONT) && !(*t.iton & 0377)) {
4747c478bd9Sstevel@tonic-gate for (j = w / t.Char; j > 0; j--)
4757c478bd9Sstevel@tonic-gate oput('_');
4767c478bd9Sstevel@tonic-gate for (j = w / t.Char; j > 0; j--)
4777c478bd9Sstevel@tonic-gate oput('\b');
4787c478bd9Sstevel@tonic-gate }
4797c478bd9Sstevel@tonic-gate if ((j = bdtab[xfont]) && !(*t.bdon & 0377))
4807c478bd9Sstevel@tonic-gate j++;
4817c478bd9Sstevel@tonic-gate else
4827c478bd9Sstevel@tonic-gate j = 1; /* number of overstrikes for bold */
4837c478bd9Sstevel@tonic-gate if (k < 128) { /* ordinary ascii */
4847c478bd9Sstevel@tonic-gate oput(k);
4857c478bd9Sstevel@tonic-gate while (--j > 0) {
4867c478bd9Sstevel@tonic-gate oput('\b');
4877c478bd9Sstevel@tonic-gate oput(k);
4887c478bd9Sstevel@tonic-gate }
4897c478bd9Sstevel@tonic-gate #ifdef EUC
4907c478bd9Sstevel@tonic-gate #ifdef NROFF
4917c478bd9Sstevel@tonic-gate } else if (multi_locale && (k & CSMASK)) {
4927c478bd9Sstevel@tonic-gate for (qq = q - cnt; qq <= q;)
4937c478bd9Sstevel@tonic-gate oput(cbits(*qq++));
4947c478bd9Sstevel@tonic-gate while (--j > 0) {
4957c478bd9Sstevel@tonic-gate for (jj = cnt + 1; jj > 0; jj--)
4967c478bd9Sstevel@tonic-gate oput('\b');
4977c478bd9Sstevel@tonic-gate for (qq = q - cnt; qq <= q;)
4987c478bd9Sstevel@tonic-gate oput(cbits(*qq++));
4997c478bd9Sstevel@tonic-gate }
5007c478bd9Sstevel@tonic-gate } else if (k < 256) {
5017c478bd9Sstevel@tonic-gate /*
5027c478bd9Sstevel@tonic-gate * Invalid character for C locale or
5037c478bd9Sstevel@tonic-gate * non-printable 8-bit single byte
5047c478bd9Sstevel@tonic-gate * character such as <no-break-sp>
5057c478bd9Sstevel@tonic-gate * in ISO-8859-1
5067c478bd9Sstevel@tonic-gate */
5077c478bd9Sstevel@tonic-gate oput(k);
5087c478bd9Sstevel@tonic-gate while (--j > 0) {
5097c478bd9Sstevel@tonic-gate oput('\b');
5107c478bd9Sstevel@tonic-gate oput(k);
5117c478bd9Sstevel@tonic-gate }
5127c478bd9Sstevel@tonic-gate #endif /* NROFF */
5137c478bd9Sstevel@tonic-gate #endif /* EUC */
5147c478bd9Sstevel@tonic-gate } else if (k >= nchtab + _SPECCHAR_ST) {
5157c478bd9Sstevel@tonic-gate oput(k - nchtab - _SPECCHAR_ST);
5167c478bd9Sstevel@tonic-gate } else {
5177c478bd9Sstevel@tonic-gate int oj = j;
5187c478bd9Sstevel@tonic-gate codep = t.codetab[k-_SPECCHAR_ST];
5197c478bd9Sstevel@tonic-gate while (*codep != 0) {
5207c478bd9Sstevel@tonic-gate if (*codep & 0200) {
5217c478bd9Sstevel@tonic-gate codep = plot(codep);
5227c478bd9Sstevel@tonic-gate oput(' ');
5237c478bd9Sstevel@tonic-gate } else {
5247c478bd9Sstevel@tonic-gate if (*codep == '%') /* escape */
5257c478bd9Sstevel@tonic-gate codep++;
5267c478bd9Sstevel@tonic-gate oput(*codep);
5277c478bd9Sstevel@tonic-gate if (*codep == '\033')
5287c478bd9Sstevel@tonic-gate oput(*++codep);
5297c478bd9Sstevel@tonic-gate else if (*codep != '\b')
5307c478bd9Sstevel@tonic-gate for (j = oj; --j > 0; ) {
5317c478bd9Sstevel@tonic-gate oput('\b');
5327c478bd9Sstevel@tonic-gate oput(*codep);
5337c478bd9Sstevel@tonic-gate }
5347c478bd9Sstevel@tonic-gate codep++;
5357c478bd9Sstevel@tonic-gate }
5367c478bd9Sstevel@tonic-gate }
5377c478bd9Sstevel@tonic-gate }
5387c478bd9Sstevel@tonic-gate if (!w)
5397c478bd9Sstevel@tonic-gate for (j = phyw / t.Char; j > 0; j--)
5407c478bd9Sstevel@tonic-gate oput('\b');
5417c478bd9Sstevel@tonic-gate }
542*e5190c10Smuffin
543*e5190c10Smuffin return (0);
5447c478bd9Sstevel@tonic-gate }
5457c478bd9Sstevel@tonic-gate
5467c478bd9Sstevel@tonic-gate
plot(x)5477c478bd9Sstevel@tonic-gate char *plot(x)
5487c478bd9Sstevel@tonic-gate char *x;
5497c478bd9Sstevel@tonic-gate {
550*e5190c10Smuffin int i;
551*e5190c10Smuffin char *j, *k;
5527c478bd9Sstevel@tonic-gate
5537c478bd9Sstevel@tonic-gate oputs(t.ploton);
5547c478bd9Sstevel@tonic-gate k = x;
5557c478bd9Sstevel@tonic-gate if ((*k & 0377) == 0200)
5567c478bd9Sstevel@tonic-gate k++;
5577c478bd9Sstevel@tonic-gate for (; *k; k++) {
5587c478bd9Sstevel@tonic-gate if (*k == '%') { /* quote char within plot mode */
5597c478bd9Sstevel@tonic-gate oput(*++k);
5607c478bd9Sstevel@tonic-gate } else if (*k & 0200) {
5617c478bd9Sstevel@tonic-gate if (*k & 0100) {
5627c478bd9Sstevel@tonic-gate if (*k & 040)
5637c478bd9Sstevel@tonic-gate j = t.up;
5647c478bd9Sstevel@tonic-gate else
5657c478bd9Sstevel@tonic-gate j = t.down;
5667c478bd9Sstevel@tonic-gate } else {
5677c478bd9Sstevel@tonic-gate if (*k & 040)
5687c478bd9Sstevel@tonic-gate j = t.left;
5697c478bd9Sstevel@tonic-gate else
5707c478bd9Sstevel@tonic-gate j = t.right;
5717c478bd9Sstevel@tonic-gate }
5727c478bd9Sstevel@tonic-gate if ((i = *k & 037) == 0) { /* 2nd 0200 turns it off */
5737c478bd9Sstevel@tonic-gate ++k;
5747c478bd9Sstevel@tonic-gate break;
5757c478bd9Sstevel@tonic-gate }
5767c478bd9Sstevel@tonic-gate while (i--)
5777c478bd9Sstevel@tonic-gate oputs(j);
5787c478bd9Sstevel@tonic-gate } else
5797c478bd9Sstevel@tonic-gate oput(*k);
5807c478bd9Sstevel@tonic-gate }
5817c478bd9Sstevel@tonic-gate oputs(t.plotoff);
5827c478bd9Sstevel@tonic-gate return(k);
5837c478bd9Sstevel@tonic-gate }
5847c478bd9Sstevel@tonic-gate
5857c478bd9Sstevel@tonic-gate
586*e5190c10Smuffin int
move()5877c478bd9Sstevel@tonic-gate move()
5887c478bd9Sstevel@tonic-gate {
589*e5190c10Smuffin int k;
590*e5190c10Smuffin char *i, *j;
5917c478bd9Sstevel@tonic-gate char *p, *q;
5927c478bd9Sstevel@tonic-gate int iesct, dt;
5937c478bd9Sstevel@tonic-gate
5947c478bd9Sstevel@tonic-gate iesct = esct;
5957c478bd9Sstevel@tonic-gate if (esct += esc)
5967c478bd9Sstevel@tonic-gate i = "\0";
5977c478bd9Sstevel@tonic-gate else
5987c478bd9Sstevel@tonic-gate i = "\n\0";
5997c478bd9Sstevel@tonic-gate j = t.hlf;
6007c478bd9Sstevel@tonic-gate p = t.right;
6017c478bd9Sstevel@tonic-gate q = t.down;
6027c478bd9Sstevel@tonic-gate if (lead) {
6037c478bd9Sstevel@tonic-gate if (lead < 0) {
6047c478bd9Sstevel@tonic-gate lead = -lead;
6057c478bd9Sstevel@tonic-gate i = t.flr;
6067c478bd9Sstevel@tonic-gate /* if(!esct)i = t.flr; else i = "\0";*/
6077c478bd9Sstevel@tonic-gate j = t.hlr;
6087c478bd9Sstevel@tonic-gate q = t.up;
6097c478bd9Sstevel@tonic-gate }
6107c478bd9Sstevel@tonic-gate if (*i & 0377) {
6117c478bd9Sstevel@tonic-gate k = lead / t.Newline;
6127c478bd9Sstevel@tonic-gate lead = lead % t.Newline;
6137c478bd9Sstevel@tonic-gate while (k--)
6147c478bd9Sstevel@tonic-gate oputs(i);
6157c478bd9Sstevel@tonic-gate }
6167c478bd9Sstevel@tonic-gate if (*j & 0377) {
6177c478bd9Sstevel@tonic-gate k = lead / t.Halfline;
6187c478bd9Sstevel@tonic-gate lead = lead % t.Halfline;
6197c478bd9Sstevel@tonic-gate while (k--)
6207c478bd9Sstevel@tonic-gate oputs(j);
6217c478bd9Sstevel@tonic-gate } else { /* no half-line forward, not at line begining */
6227c478bd9Sstevel@tonic-gate k = lead / t.Newline;
6237c478bd9Sstevel@tonic-gate lead = lead % t.Newline;
6247c478bd9Sstevel@tonic-gate if (k > 0)
6257c478bd9Sstevel@tonic-gate esc = esct;
6267c478bd9Sstevel@tonic-gate i = "\n";
6277c478bd9Sstevel@tonic-gate while (k--)
6287c478bd9Sstevel@tonic-gate oputs(i);
6297c478bd9Sstevel@tonic-gate }
6307c478bd9Sstevel@tonic-gate }
6317c478bd9Sstevel@tonic-gate if (esc) {
6327c478bd9Sstevel@tonic-gate if (esc < 0) {
6337c478bd9Sstevel@tonic-gate esc = -esc;
6347c478bd9Sstevel@tonic-gate j = "\b";
6357c478bd9Sstevel@tonic-gate p = t.left;
6367c478bd9Sstevel@tonic-gate } else {
6377c478bd9Sstevel@tonic-gate j = " ";
6387c478bd9Sstevel@tonic-gate if (hflg)
6397c478bd9Sstevel@tonic-gate while ((dt = dtab - (iesct % dtab)) <= esc) {
6407c478bd9Sstevel@tonic-gate if (dt % t.Em)
6417c478bd9Sstevel@tonic-gate break;
6427c478bd9Sstevel@tonic-gate oput(TAB);
6437c478bd9Sstevel@tonic-gate esc -= dt;
6447c478bd9Sstevel@tonic-gate iesct += dt;
6457c478bd9Sstevel@tonic-gate }
6467c478bd9Sstevel@tonic-gate }
6477c478bd9Sstevel@tonic-gate k = esc / t.Em;
6487c478bd9Sstevel@tonic-gate esc = esc % t.Em;
6497c478bd9Sstevel@tonic-gate while (k--)
6507c478bd9Sstevel@tonic-gate oputs(j);
6517c478bd9Sstevel@tonic-gate }
6527c478bd9Sstevel@tonic-gate if ((*t.ploton & 0377) && (esc || lead)) {
6537c478bd9Sstevel@tonic-gate oputs(t.ploton);
6547c478bd9Sstevel@tonic-gate esc /= t.Hor;
6557c478bd9Sstevel@tonic-gate lead /= t.Vert;
6567c478bd9Sstevel@tonic-gate while (esc--)
6577c478bd9Sstevel@tonic-gate oputs(p);
6587c478bd9Sstevel@tonic-gate while (lead--)
6597c478bd9Sstevel@tonic-gate oputs(q);
6607c478bd9Sstevel@tonic-gate oputs(t.plotoff);
6617c478bd9Sstevel@tonic-gate }
6627c478bd9Sstevel@tonic-gate esc = lead = 0;
663*e5190c10Smuffin
664*e5190c10Smuffin return (0);
6657c478bd9Sstevel@tonic-gate }
6667c478bd9Sstevel@tonic-gate
6677c478bd9Sstevel@tonic-gate
668*e5190c10Smuffin int
ptlead()6697c478bd9Sstevel@tonic-gate ptlead()
6707c478bd9Sstevel@tonic-gate {
6717c478bd9Sstevel@tonic-gate move();
672*e5190c10Smuffin
673*e5190c10Smuffin return (0);
6747c478bd9Sstevel@tonic-gate }
6757c478bd9Sstevel@tonic-gate
6767c478bd9Sstevel@tonic-gate
677*e5190c10Smuffin int
dostop()6787c478bd9Sstevel@tonic-gate dostop()
6797c478bd9Sstevel@tonic-gate {
6807c478bd9Sstevel@tonic-gate char junk;
6817c478bd9Sstevel@tonic-gate
6827c478bd9Sstevel@tonic-gate flusho();
6837c478bd9Sstevel@tonic-gate read(2, &junk, 1);
684*e5190c10Smuffin
685*e5190c10Smuffin return (0);
686*e5190c10Smuffin }
687*e5190c10Smuffin
688*e5190c10Smuffin int
newpage()689*e5190c10Smuffin newpage()
690*e5190c10Smuffin {
691*e5190c10Smuffin return (0);
6927c478bd9Sstevel@tonic-gate }
6937c478bd9Sstevel@tonic-gate
6947c478bd9Sstevel@tonic-gate
695*e5190c10Smuffin int
pttrailer()696*e5190c10Smuffin pttrailer()
697*e5190c10Smuffin {
698*e5190c10Smuffin return (0);
699*e5190c10Smuffin }
700