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 2004 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 char *xxxvers = "@(#)roff:n1.c 2.13"; 437c478bd9Sstevel@tonic-gate /* 447c478bd9Sstevel@tonic-gate * n1.c 457c478bd9Sstevel@tonic-gate * 467c478bd9Sstevel@tonic-gate * consume options, initialization, main loop, 477c478bd9Sstevel@tonic-gate * input routines, escape function calling 487c478bd9Sstevel@tonic-gate */ 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate #include <ctype.h> 517c478bd9Sstevel@tonic-gate #include <signal.h> 527c478bd9Sstevel@tonic-gate #include <sys/types.h> 537c478bd9Sstevel@tonic-gate #include <sys/stat.h> 547c478bd9Sstevel@tonic-gate #include <setjmp.h> 557c478bd9Sstevel@tonic-gate #include <time.h> 567c478bd9Sstevel@tonic-gate #include <stdarg.h> 577c478bd9Sstevel@tonic-gate #include <locale.h> 587c478bd9Sstevel@tonic-gate #include <fcntl.h> 597c478bd9Sstevel@tonic-gate #include <stdlib.h> 607c478bd9Sstevel@tonic-gate #include <string.h> 617c478bd9Sstevel@tonic-gate #ifdef EUC 627c478bd9Sstevel@tonic-gate #ifdef NROFF 637c478bd9Sstevel@tonic-gate #include <stddef.h> 647c478bd9Sstevel@tonic-gate #include <limits.h> 657c478bd9Sstevel@tonic-gate #endif /* NROFF */ 667c478bd9Sstevel@tonic-gate #endif /* EUC */ 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate #include "tdef.h" 697c478bd9Sstevel@tonic-gate #include "ext.h" 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate #ifdef NROFF 727c478bd9Sstevel@tonic-gate #include "tw.h" 737c478bd9Sstevel@tonic-gate #endif 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate #define MAX_RECURSION_DEPTH 512 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate jmp_buf sjbuf; 787c478bd9Sstevel@tonic-gate extern void fdprintf(int, char *, ...); 797c478bd9Sstevel@tonic-gate extern char *roff_sprintf(char *, char *, ...); 807c478bd9Sstevel@tonic-gate filep ipl[NSO]; 817c478bd9Sstevel@tonic-gate long offl[NSO]; 827c478bd9Sstevel@tonic-gate long ioff; 837c478bd9Sstevel@tonic-gate char *ttyp; 847c478bd9Sstevel@tonic-gate char cfname[NSO+1][NS]; /*file name stack*/ 857c478bd9Sstevel@tonic-gate int cfline[NSO]; /*input line count stack*/ 867c478bd9Sstevel@tonic-gate char *progname; /* program name (troff) */ 877c478bd9Sstevel@tonic-gate #ifdef EUC 887c478bd9Sstevel@tonic-gate #ifdef NROFF 897c478bd9Sstevel@tonic-gate char mbbuf1[MB_LEN_MAX + 1]; 907c478bd9Sstevel@tonic-gate char *mbbuf1p = mbbuf1; 917c478bd9Sstevel@tonic-gate wchar_t twc = 0; 927c478bd9Sstevel@tonic-gate #endif /* NROFF */ 937c478bd9Sstevel@tonic-gate #endif /* EUC */ 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate #ifdef DEBUG 967c478bd9Sstevel@tonic-gate int debug = 0; /*debug flag*/ 97*e5190c10Smuffin #endif /* DEBUG */ 98*e5190c10Smuffin 99*e5190c10Smuffin static char *sprintn(char *, long, int); 100*e5190c10Smuffin static int printn(long, int); 1017c478bd9Sstevel@tonic-gate 102*e5190c10Smuffin int 103*e5190c10Smuffin main(int argc, char **argv) 1047c478bd9Sstevel@tonic-gate { 105*e5190c10Smuffin char *p, *q; 106*e5190c10Smuffin int j; 107*e5190c10Smuffin tchar i; 1087c478bd9Sstevel@tonic-gate int eileenct; /*count to test for "Eileen's loop"*/ 1097c478bd9Sstevel@tonic-gate extern void catch(), kcatch(); 1107c478bd9Sstevel@tonic-gate char **oargv, *getenv(); 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate (void)setlocale(LC_ALL, ""); 1137c478bd9Sstevel@tonic-gate #if !defined(TEXT_DOMAIN) 1147c478bd9Sstevel@tonic-gate #define TEXT_DOMAIN "SYS_TEST" 1157c478bd9Sstevel@tonic-gate #endif 1167c478bd9Sstevel@tonic-gate (void)textdomain(TEXT_DOMAIN); 1177c478bd9Sstevel@tonic-gate progname = argv[0]; 1187c478bd9Sstevel@tonic-gate if (signal(SIGHUP, SIG_IGN) != SIG_IGN) 1197c478bd9Sstevel@tonic-gate signal(SIGHUP, catch); 1207c478bd9Sstevel@tonic-gate if (signal(SIGINT, catch) == SIG_IGN) { 1217c478bd9Sstevel@tonic-gate signal(SIGHUP, SIG_IGN); 1227c478bd9Sstevel@tonic-gate signal(SIGINT, SIG_IGN); 1237c478bd9Sstevel@tonic-gate signal(SIGQUIT, SIG_IGN); 1247c478bd9Sstevel@tonic-gate } 1257c478bd9Sstevel@tonic-gate signal(SIGPIPE, catch); 1267c478bd9Sstevel@tonic-gate signal(SIGTERM, kcatch); 1277c478bd9Sstevel@tonic-gate oargv = argv; 1287c478bd9Sstevel@tonic-gate strcpy(cfname[0], "<standard input>"); 1297c478bd9Sstevel@tonic-gate mrehash(); 1307c478bd9Sstevel@tonic-gate nrehash(); 1317c478bd9Sstevel@tonic-gate init0(); 1327c478bd9Sstevel@tonic-gate #ifdef EUC 1337c478bd9Sstevel@tonic-gate #ifdef NROFF 1347c478bd9Sstevel@tonic-gate (void)localize(); 1357c478bd9Sstevel@tonic-gate #endif /* NROFF */ 1367c478bd9Sstevel@tonic-gate #endif /* EUC */ 1377c478bd9Sstevel@tonic-gate if ((p = getenv("TYPESETTER")) != 0) 1387c478bd9Sstevel@tonic-gate strcpy(devname, p); 1397c478bd9Sstevel@tonic-gate while (--argc > 0 && (++argv)[0][0] == '-') 1407c478bd9Sstevel@tonic-gate switch (argv[0][1]) { 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate case 'F': /* switch font tables from default */ 1437c478bd9Sstevel@tonic-gate if (argv[0][2] != '\0') { 1447c478bd9Sstevel@tonic-gate strcpy(termtab, &argv[0][2]); 1457c478bd9Sstevel@tonic-gate strcpy(fontfile, &argv[0][2]); 1467c478bd9Sstevel@tonic-gate } else { 1477c478bd9Sstevel@tonic-gate argv++; argc--; 1487c478bd9Sstevel@tonic-gate if (argv[0] != '\0') { 1497c478bd9Sstevel@tonic-gate strcpy(termtab, argv[0]); 1507c478bd9Sstevel@tonic-gate strcpy(fontfile, argv[0]); 1517c478bd9Sstevel@tonic-gate } else 1527c478bd9Sstevel@tonic-gate errprint(gettext("missing the font directory")); 1537c478bd9Sstevel@tonic-gate } 1547c478bd9Sstevel@tonic-gate continue; 1557c478bd9Sstevel@tonic-gate case 0: 1567c478bd9Sstevel@tonic-gate goto start; 1577c478bd9Sstevel@tonic-gate case 'i': 1587c478bd9Sstevel@tonic-gate stdi++; 1597c478bd9Sstevel@tonic-gate continue; 1607c478bd9Sstevel@tonic-gate case 'q': 1617c478bd9Sstevel@tonic-gate #ifdef NROFF 1627c478bd9Sstevel@tonic-gate quiet++; 1637c478bd9Sstevel@tonic-gate save_tty(); 1647c478bd9Sstevel@tonic-gate #else 1657c478bd9Sstevel@tonic-gate errprint(gettext("-q option ignored in troff")); 166*e5190c10Smuffin #endif /* NROFF */ 1677c478bd9Sstevel@tonic-gate continue; 1687c478bd9Sstevel@tonic-gate case 'n': 1697c478bd9Sstevel@tonic-gate npn = ctoi(&argv[0][2]); 1707c478bd9Sstevel@tonic-gate continue; 1717c478bd9Sstevel@tonic-gate case 'u': /* set emboldening amount */ 1727c478bd9Sstevel@tonic-gate bdtab[3] = ctoi(&argv[0][2]); 1737c478bd9Sstevel@tonic-gate if (bdtab[3] < 0 || bdtab[3] > 50) 1747c478bd9Sstevel@tonic-gate bdtab[3] = 0; 1757c478bd9Sstevel@tonic-gate continue; 1767c478bd9Sstevel@tonic-gate case 's': 1777c478bd9Sstevel@tonic-gate if (!(stop = ctoi(&argv[0][2]))) 1787c478bd9Sstevel@tonic-gate stop++; 1797c478bd9Sstevel@tonic-gate continue; 1807c478bd9Sstevel@tonic-gate case 't': 1817c478bd9Sstevel@tonic-gate ptid = 1; 1827c478bd9Sstevel@tonic-gate continue; 1837c478bd9Sstevel@tonic-gate case 'r': 1847c478bd9Sstevel@tonic-gate if (&argv[0][2] != '\0' && strlen(&argv[0][2]) >= 2 && &argv[0][3] != '\0') 1857c478bd9Sstevel@tonic-gate eibuf = roff_sprintf(ibuf+strlen(ibuf), ".nr %c %s\n", 1867c478bd9Sstevel@tonic-gate argv[0][2], &argv[0][3]); 1877c478bd9Sstevel@tonic-gate else 1887c478bd9Sstevel@tonic-gate errprint(gettext("wrong options")); 1897c478bd9Sstevel@tonic-gate continue; 1907c478bd9Sstevel@tonic-gate case 'c': 1917c478bd9Sstevel@tonic-gate case 'm': 1927c478bd9Sstevel@tonic-gate if (mflg++ >= NMF) { 1937c478bd9Sstevel@tonic-gate errprint(gettext("Too many macro packages: %s"), 1947c478bd9Sstevel@tonic-gate argv[0]); 1957c478bd9Sstevel@tonic-gate continue; 1967c478bd9Sstevel@tonic-gate } 1977c478bd9Sstevel@tonic-gate if (argv[0][2] == '\0') { 1987c478bd9Sstevel@tonic-gate errprint(gettext("No library provided with -m")); 1997c478bd9Sstevel@tonic-gate done(02); 2007c478bd9Sstevel@tonic-gate } 2017c478bd9Sstevel@tonic-gate if (getenv("TROFFMACS") != '\0') { 2027c478bd9Sstevel@tonic-gate if (tryfile(getenv("TROFFMACS"), &argv[0][2], nmfi)) 2037c478bd9Sstevel@tonic-gate nmfi++; 2047c478bd9Sstevel@tonic-gate } else 2057c478bd9Sstevel@tonic-gate if (tryfile("/usr/share/lib/tmac/", &argv[0][2], nmfi) 2067c478bd9Sstevel@tonic-gate || tryfile("/usr/share/lib/tmac/tmac.", &argv[0][2], nmfi)) 2077c478bd9Sstevel@tonic-gate nmfi++; 2087c478bd9Sstevel@tonic-gate else { 2097c478bd9Sstevel@tonic-gate errprint(gettext("Cannot find library %s\n"), 2107c478bd9Sstevel@tonic-gate argv[0]); 2117c478bd9Sstevel@tonic-gate done(02); 2127c478bd9Sstevel@tonic-gate } 2137c478bd9Sstevel@tonic-gate continue; 2147c478bd9Sstevel@tonic-gate case 'o': 2157c478bd9Sstevel@tonic-gate getpn(&argv[0][2]); 2167c478bd9Sstevel@tonic-gate continue; 2177c478bd9Sstevel@tonic-gate case 'T': 2187c478bd9Sstevel@tonic-gate strcpy(devname, &argv[0][2]); 2197c478bd9Sstevel@tonic-gate dotT++; 2207c478bd9Sstevel@tonic-gate continue; 2217c478bd9Sstevel@tonic-gate #ifdef NROFF 2227c478bd9Sstevel@tonic-gate case 'h': 2237c478bd9Sstevel@tonic-gate hflg++; 2247c478bd9Sstevel@tonic-gate continue; 2257c478bd9Sstevel@tonic-gate case 'z': 2267c478bd9Sstevel@tonic-gate no_out++; 2277c478bd9Sstevel@tonic-gate continue; 2287c478bd9Sstevel@tonic-gate case 'e': 2297c478bd9Sstevel@tonic-gate eqflg++; 2307c478bd9Sstevel@tonic-gate continue; 2317c478bd9Sstevel@tonic-gate #endif 2327c478bd9Sstevel@tonic-gate #ifndef NROFF 2337c478bd9Sstevel@tonic-gate case 'z': 2347c478bd9Sstevel@tonic-gate no_out++; 2357c478bd9Sstevel@tonic-gate case 'a': 2367c478bd9Sstevel@tonic-gate ascii = 1; 2377c478bd9Sstevel@tonic-gate nofeed++; 2387c478bd9Sstevel@tonic-gate continue; 2397c478bd9Sstevel@tonic-gate case 'f': 2407c478bd9Sstevel@tonic-gate nofeed++; 2417c478bd9Sstevel@tonic-gate continue; 2427c478bd9Sstevel@tonic-gate #endif 2437c478bd9Sstevel@tonic-gate case '#': 2447c478bd9Sstevel@tonic-gate #ifdef DEBUG 2457c478bd9Sstevel@tonic-gate debug = ctoi(&argv[0][2]); 2467c478bd9Sstevel@tonic-gate #else 2477c478bd9Sstevel@tonic-gate errprint("DEBUG not enabled"); 248*e5190c10Smuffin #endif /* DEBUG */ 2497c478bd9Sstevel@tonic-gate continue; 2507c478bd9Sstevel@tonic-gate default: 2517c478bd9Sstevel@tonic-gate errprint(gettext("unknown option %s"), argv[0]); 2527c478bd9Sstevel@tonic-gate done(02); 2537c478bd9Sstevel@tonic-gate } 2547c478bd9Sstevel@tonic-gate 2557c478bd9Sstevel@tonic-gate start: 2567c478bd9Sstevel@tonic-gate init1(oargv[0][0]); 2577c478bd9Sstevel@tonic-gate argp = argv; 2587c478bd9Sstevel@tonic-gate rargc = argc; 2597c478bd9Sstevel@tonic-gate nmfi = 0; 2607c478bd9Sstevel@tonic-gate init2(); 2617c478bd9Sstevel@tonic-gate setjmp(sjbuf); 2627c478bd9Sstevel@tonic-gate eileenct = 0; /*reset count for "Eileen's loop"*/ 2637c478bd9Sstevel@tonic-gate loop: 2647c478bd9Sstevel@tonic-gate copyf = lgf = nb = nflush = nlflg = 0; 2657c478bd9Sstevel@tonic-gate if (ip && rbf0(ip) == 0 && ejf && frame->pframe <= ejl) { 2667c478bd9Sstevel@tonic-gate nflush++; 2677c478bd9Sstevel@tonic-gate trap = 0; 2687c478bd9Sstevel@tonic-gate eject((struct s *)0); 2697c478bd9Sstevel@tonic-gate #ifdef DEBUG 2707c478bd9Sstevel@tonic-gate if (debug & DB_LOOP) 2717c478bd9Sstevel@tonic-gate fdprintf(stderr, "loop: NL=%d, ejf=%d, lss=%d, eileenct=%d\n", 2727c478bd9Sstevel@tonic-gate numtab[NL].val, ejf, lss, eileenct); 273*e5190c10Smuffin #endif /* DEBUG */ 2747c478bd9Sstevel@tonic-gate if (eileenct > 20) { 2757c478bd9Sstevel@tonic-gate errprint(gettext("job looping; check abuse of macros")); 2767c478bd9Sstevel@tonic-gate ejf = 0; /*try to break Eileen's loop*/ 2777c478bd9Sstevel@tonic-gate eileenct = 0; 2787c478bd9Sstevel@tonic-gate } else 2797c478bd9Sstevel@tonic-gate eileenct++; 2807c478bd9Sstevel@tonic-gate goto loop; 2817c478bd9Sstevel@tonic-gate } 2827c478bd9Sstevel@tonic-gate eileenct = 0; /*reset count for "Eileen's loop"*/ 2837c478bd9Sstevel@tonic-gate i = getch(); 2847c478bd9Sstevel@tonic-gate if (pendt) 2857c478bd9Sstevel@tonic-gate goto Lt; 2867c478bd9Sstevel@tonic-gate if ((j = cbits(i)) == XPAR) { 2877c478bd9Sstevel@tonic-gate copyf++; 2887c478bd9Sstevel@tonic-gate tflg++; 2897c478bd9Sstevel@tonic-gate while (cbits(i) != '\n') 2907c478bd9Sstevel@tonic-gate pchar(i = getch()); 2917c478bd9Sstevel@tonic-gate tflg = 0; 2927c478bd9Sstevel@tonic-gate copyf--; 2937c478bd9Sstevel@tonic-gate goto loop; 2947c478bd9Sstevel@tonic-gate } 2957c478bd9Sstevel@tonic-gate if (j == cc || j == c2) { 2967c478bd9Sstevel@tonic-gate if (j == c2) 2977c478bd9Sstevel@tonic-gate nb++; 2987c478bd9Sstevel@tonic-gate copyf++; 2997c478bd9Sstevel@tonic-gate while ((j = cbits(i = getch())) == ' ' || j == '\t') 3007c478bd9Sstevel@tonic-gate ; 3017c478bd9Sstevel@tonic-gate ch = i; 3027c478bd9Sstevel@tonic-gate copyf--; 3037c478bd9Sstevel@tonic-gate control(getrq(), 1); 3047c478bd9Sstevel@tonic-gate flushi(); 3057c478bd9Sstevel@tonic-gate goto loop; 3067c478bd9Sstevel@tonic-gate } 3077c478bd9Sstevel@tonic-gate Lt: 3087c478bd9Sstevel@tonic-gate ch = i; 3097c478bd9Sstevel@tonic-gate text(); 3107c478bd9Sstevel@tonic-gate if (nlflg) 3117c478bd9Sstevel@tonic-gate numtab[HP].val = 0; 3127c478bd9Sstevel@tonic-gate goto loop; 3137c478bd9Sstevel@tonic-gate } 3147c478bd9Sstevel@tonic-gate 3157c478bd9Sstevel@tonic-gate 316*e5190c10Smuffin int 3177c478bd9Sstevel@tonic-gate tryfile(pat, fn, idx) 318*e5190c10Smuffin char *pat, *fn; 3197c478bd9Sstevel@tonic-gate int idx; 3207c478bd9Sstevel@tonic-gate { 3217c478bd9Sstevel@tonic-gate strcpy(mfiles[idx], pat); 3227c478bd9Sstevel@tonic-gate strcat(mfiles[idx], fn); 3237c478bd9Sstevel@tonic-gate if (access(mfiles[idx], 4) == -1) 3247c478bd9Sstevel@tonic-gate return(0); 3257c478bd9Sstevel@tonic-gate else return(1); 3267c478bd9Sstevel@tonic-gate } 3277c478bd9Sstevel@tonic-gate 3287c478bd9Sstevel@tonic-gate void catch() 3297c478bd9Sstevel@tonic-gate { 3307c478bd9Sstevel@tonic-gate done3(01); 3317c478bd9Sstevel@tonic-gate } 3327c478bd9Sstevel@tonic-gate 3337c478bd9Sstevel@tonic-gate 3347c478bd9Sstevel@tonic-gate void kcatch() 3357c478bd9Sstevel@tonic-gate { 3367c478bd9Sstevel@tonic-gate signal(SIGTERM, SIG_IGN); 3377c478bd9Sstevel@tonic-gate done3(01); 3387c478bd9Sstevel@tonic-gate } 3397c478bd9Sstevel@tonic-gate 340*e5190c10Smuffin int 3417c478bd9Sstevel@tonic-gate init0() 3427c478bd9Sstevel@tonic-gate { 3437c478bd9Sstevel@tonic-gate eibuf = ibufp = ibuf; 3447c478bd9Sstevel@tonic-gate ibuf[0] = 0; 3457c478bd9Sstevel@tonic-gate numtab[NL].val = -1; 346*e5190c10Smuffin return (0); 3477c478bd9Sstevel@tonic-gate } 3487c478bd9Sstevel@tonic-gate 3497c478bd9Sstevel@tonic-gate 350*e5190c10Smuffin int 3517c478bd9Sstevel@tonic-gate init1(a) 3527c478bd9Sstevel@tonic-gate char a; 3537c478bd9Sstevel@tonic-gate { 354*e5190c10Smuffin char *p; 355*e5190c10Smuffin int i; 3567c478bd9Sstevel@tonic-gate 3577c478bd9Sstevel@tonic-gate p = tmp_name; 3587c478bd9Sstevel@tonic-gate if (a == 'a') 3597c478bd9Sstevel@tonic-gate p = &p[9]; 3607c478bd9Sstevel@tonic-gate if ((ibf = mkstemp(p)) == -1) { 3617c478bd9Sstevel@tonic-gate errprint(gettext("cannot create temp file.")); 3627c478bd9Sstevel@tonic-gate exit(-1); 3637c478bd9Sstevel@tonic-gate } 3647c478bd9Sstevel@tonic-gate unlkp = p; 3657c478bd9Sstevel@tonic-gate for (i = NTRTAB; --i; ) 3667c478bd9Sstevel@tonic-gate trtab[i] = i; 3677c478bd9Sstevel@tonic-gate trtab[UNPAD] = ' '; 368*e5190c10Smuffin return (0); 3697c478bd9Sstevel@tonic-gate } 3707c478bd9Sstevel@tonic-gate 3717c478bd9Sstevel@tonic-gate 372*e5190c10Smuffin int 3737c478bd9Sstevel@tonic-gate init2() 3747c478bd9Sstevel@tonic-gate { 375*e5190c10Smuffin int i, j; 3767c478bd9Sstevel@tonic-gate extern char *setbrk(); 3777c478bd9Sstevel@tonic-gate extern char *ttyname(); 3787c478bd9Sstevel@tonic-gate 3797c478bd9Sstevel@tonic-gate ttyod = 2; 3807c478bd9Sstevel@tonic-gate if ((ttyp=ttyname(j=0)) != 0 || (ttyp=ttyname(j=1)) != 0 || (ttyp=ttyname(j=2)) != 0) 3817c478bd9Sstevel@tonic-gate ; 3827c478bd9Sstevel@tonic-gate else 3837c478bd9Sstevel@tonic-gate ttyp = "notty"; 3847c478bd9Sstevel@tonic-gate iflg = j; 3857c478bd9Sstevel@tonic-gate if (ascii) 3867c478bd9Sstevel@tonic-gate mesg(0); 3877c478bd9Sstevel@tonic-gate obufp = obuf; 3887c478bd9Sstevel@tonic-gate ptinit(); 3897c478bd9Sstevel@tonic-gate mchbits(); 3907c478bd9Sstevel@tonic-gate cvtime(); 3917c478bd9Sstevel@tonic-gate numtab[PID].val = getpid(); 3927c478bd9Sstevel@tonic-gate olinep = oline; 3937c478bd9Sstevel@tonic-gate ioff = 0; 3947c478bd9Sstevel@tonic-gate numtab[HP].val = init = 0; 3957c478bd9Sstevel@tonic-gate numtab[NL].val = -1; 3967c478bd9Sstevel@tonic-gate nfo = 0; 3977c478bd9Sstevel@tonic-gate ifile = 0; 3987c478bd9Sstevel@tonic-gate copyf = raw = 0; 3997c478bd9Sstevel@tonic-gate eibuf = roff_sprintf(ibuf+strlen(ibuf), ".ds .T %s\n", devname); 4007c478bd9Sstevel@tonic-gate numtab[CD].val = -1; /* compensation */ 4017c478bd9Sstevel@tonic-gate cpushback(ibuf); 4027c478bd9Sstevel@tonic-gate ibufp = ibuf; 4037c478bd9Sstevel@tonic-gate nx = mflg; 4047c478bd9Sstevel@tonic-gate frame = stk = (struct s *)setbrk(DELTA); 4057c478bd9Sstevel@tonic-gate dip = &d[0]; 4067c478bd9Sstevel@tonic-gate nxf = frame + 1; 4077c478bd9Sstevel@tonic-gate #ifdef INCORE 4087c478bd9Sstevel@tonic-gate for (i = 0; i < NEV; i++) { 4097c478bd9Sstevel@tonic-gate extern tchar corebuf[]; 4107c478bd9Sstevel@tonic-gate *(struct env *)&corebuf[i * sizeof(env)/sizeof(tchar)] = env; 4117c478bd9Sstevel@tonic-gate } 4127c478bd9Sstevel@tonic-gate #else 4137c478bd9Sstevel@tonic-gate for (i = NEV; i--; ) 4147c478bd9Sstevel@tonic-gate write(ibf, (char *) & env, sizeof(env)); 4157c478bd9Sstevel@tonic-gate #endif 416*e5190c10Smuffin return (0); 4177c478bd9Sstevel@tonic-gate } 4187c478bd9Sstevel@tonic-gate 419*e5190c10Smuffin int 4207c478bd9Sstevel@tonic-gate cvtime() 4217c478bd9Sstevel@tonic-gate { 4227c478bd9Sstevel@tonic-gate time_t tt; 423*e5190c10Smuffin struct tm *tm; 4247c478bd9Sstevel@tonic-gate 4257c478bd9Sstevel@tonic-gate tt = time((time_t *) 0); 4267c478bd9Sstevel@tonic-gate tm = localtime(&tt); 4277c478bd9Sstevel@tonic-gate numtab[DY].val = tm->tm_mday; 4287c478bd9Sstevel@tonic-gate numtab[DW].val = tm->tm_wday + 1; 4297c478bd9Sstevel@tonic-gate numtab[YR].val = tm->tm_year; 4307c478bd9Sstevel@tonic-gate numtab[MO].val = tm->tm_mon + 1; 4317c478bd9Sstevel@tonic-gate 432*e5190c10Smuffin return (0); 4337c478bd9Sstevel@tonic-gate } 4347c478bd9Sstevel@tonic-gate 4357c478bd9Sstevel@tonic-gate 436*e5190c10Smuffin int 4377c478bd9Sstevel@tonic-gate ctoi(s) 438*e5190c10Smuffin char *s; 4397c478bd9Sstevel@tonic-gate { 440*e5190c10Smuffin int n; 4417c478bd9Sstevel@tonic-gate 4427c478bd9Sstevel@tonic-gate while (*s == ' ') 4437c478bd9Sstevel@tonic-gate s++; 4447c478bd9Sstevel@tonic-gate n = 0; 4457c478bd9Sstevel@tonic-gate while (isdigit((unsigned char)*s)) 4467c478bd9Sstevel@tonic-gate n = 10 * n + *s++ - '0'; 4477c478bd9Sstevel@tonic-gate return n; 4487c478bd9Sstevel@tonic-gate } 4497c478bd9Sstevel@tonic-gate 4507c478bd9Sstevel@tonic-gate 451*e5190c10Smuffin int 4527c478bd9Sstevel@tonic-gate mesg(f) 4537c478bd9Sstevel@tonic-gate int f; 4547c478bd9Sstevel@tonic-gate { 4557c478bd9Sstevel@tonic-gate static int mode; 4567c478bd9Sstevel@tonic-gate struct stat stbuf; 4577c478bd9Sstevel@tonic-gate 4587c478bd9Sstevel@tonic-gate if (!f) { 4597c478bd9Sstevel@tonic-gate stat(ttyp, &stbuf); 4607c478bd9Sstevel@tonic-gate mode = stbuf.st_mode; 4617c478bd9Sstevel@tonic-gate chmod(ttyp, mode & ~0122); /* turn off writing for others */ 4627c478bd9Sstevel@tonic-gate } else { 4637c478bd9Sstevel@tonic-gate if (ttyp && *ttyp && mode) 4647c478bd9Sstevel@tonic-gate chmod(ttyp, mode); 4657c478bd9Sstevel@tonic-gate } 466*e5190c10Smuffin 467*e5190c10Smuffin return (0); 4687c478bd9Sstevel@tonic-gate } 4697c478bd9Sstevel@tonic-gate 470*e5190c10Smuffin int 4717c478bd9Sstevel@tonic-gate errprint(s, s1, s2, s3, s4, s5) /* error message printer */ 4727c478bd9Sstevel@tonic-gate char *s, *s1, *s2, *s3, *s4, *s5; 4737c478bd9Sstevel@tonic-gate { 4747c478bd9Sstevel@tonic-gate fdprintf(stderr, "%s: ", progname); 4757c478bd9Sstevel@tonic-gate fdprintf(stderr, s, s1, s2, s3, s4, s5); 4767c478bd9Sstevel@tonic-gate if (numtab[CD].val > 0) 4777c478bd9Sstevel@tonic-gate fdprintf(stderr, gettext("; line %d, file %s"), numtab[CD].val, 4787c478bd9Sstevel@tonic-gate cfname[ifi]); 4797c478bd9Sstevel@tonic-gate fdprintf(stderr, "\n"); 4807c478bd9Sstevel@tonic-gate stackdump(); 4817c478bd9Sstevel@tonic-gate #ifdef DEBUG 4827c478bd9Sstevel@tonic-gate if (debug) 4837c478bd9Sstevel@tonic-gate abort(); 484*e5190c10Smuffin #endif /* DEBUG */ 485*e5190c10Smuffin return (0); 4867c478bd9Sstevel@tonic-gate } 4877c478bd9Sstevel@tonic-gate 4887c478bd9Sstevel@tonic-gate 4897c478bd9Sstevel@tonic-gate /* 4907c478bd9Sstevel@tonic-gate * Scaled down version of C Library printf. 4917c478bd9Sstevel@tonic-gate * Only %s %u %d (==%u) %o %c %x %D are recognized. 4927c478bd9Sstevel@tonic-gate */ 4937c478bd9Sstevel@tonic-gate #undef putchar 4947c478bd9Sstevel@tonic-gate #define putchar(n) (*pfbp++ = (n)) /* NO CHECKING! */ 4957c478bd9Sstevel@tonic-gate 4967c478bd9Sstevel@tonic-gate static char pfbuf[NTM]; 4977c478bd9Sstevel@tonic-gate static char *pfbp = pfbuf; 4987c478bd9Sstevel@tonic-gate int stderr = 2; /* NOT stdio value */ 4997c478bd9Sstevel@tonic-gate 5007c478bd9Sstevel@tonic-gate void 5017c478bd9Sstevel@tonic-gate fdprintf(int fd, char *fmt, ...) 5027c478bd9Sstevel@tonic-gate { 503*e5190c10Smuffin int c; 5047c478bd9Sstevel@tonic-gate char *s; 505*e5190c10Smuffin int i; 5067c478bd9Sstevel@tonic-gate va_list ap; 5077c478bd9Sstevel@tonic-gate 5087c478bd9Sstevel@tonic-gate pfbp = pfbuf; 5097c478bd9Sstevel@tonic-gate va_start(ap, fmt); 5107c478bd9Sstevel@tonic-gate loop: 5117c478bd9Sstevel@tonic-gate while ((c = *fmt++) != '%') { 5127c478bd9Sstevel@tonic-gate if (c == '\0') { 5137c478bd9Sstevel@tonic-gate if (fd == stderr) 5147c478bd9Sstevel@tonic-gate write(stderr, pfbuf, pfbp - pfbuf); 5157c478bd9Sstevel@tonic-gate else { 5167c478bd9Sstevel@tonic-gate *pfbp = 0; 5177c478bd9Sstevel@tonic-gate pfbp = pfbuf; 5187c478bd9Sstevel@tonic-gate while (*pfbp) { 5197c478bd9Sstevel@tonic-gate *obufp++ = *pfbp++; 5207c478bd9Sstevel@tonic-gate if (obufp >= &obuf[OBUFSZ]) 5217c478bd9Sstevel@tonic-gate flusho(); 5227c478bd9Sstevel@tonic-gate } 5237c478bd9Sstevel@tonic-gate } 5247c478bd9Sstevel@tonic-gate va_end(ap); 5257c478bd9Sstevel@tonic-gate return; 5267c478bd9Sstevel@tonic-gate } 5277c478bd9Sstevel@tonic-gate putchar(c); 5287c478bd9Sstevel@tonic-gate } 5297c478bd9Sstevel@tonic-gate c = *fmt++; 5307c478bd9Sstevel@tonic-gate if (c == 'd') { 5317c478bd9Sstevel@tonic-gate i = va_arg(ap, int); 5327c478bd9Sstevel@tonic-gate if (i < 0) { 5337c478bd9Sstevel@tonic-gate putchar('-'); 5347c478bd9Sstevel@tonic-gate i = -i; 5357c478bd9Sstevel@tonic-gate } 5367c478bd9Sstevel@tonic-gate printn((long)i, 10); 5377c478bd9Sstevel@tonic-gate } else if (c == 'u' || c == 'o' || c == 'x') 5387c478bd9Sstevel@tonic-gate printn(va_arg(ap, long), c == 'o' ? 8 : (c == 'x' ? 16 : 10)); 5397c478bd9Sstevel@tonic-gate else if (c == 'c') { 5407c478bd9Sstevel@tonic-gate if (c > 0177 || c < 040) 5417c478bd9Sstevel@tonic-gate putchar('\\'); 5427c478bd9Sstevel@tonic-gate putchar(va_arg(ap, int) & 0177); 5437c478bd9Sstevel@tonic-gate } else if (c == 's') { 5447c478bd9Sstevel@tonic-gate s = va_arg(ap, char *); 5457c478bd9Sstevel@tonic-gate while (c = *s++) 5467c478bd9Sstevel@tonic-gate putchar(c); 5477c478bd9Sstevel@tonic-gate } else if (c == 'D') { 5487c478bd9Sstevel@tonic-gate printn(va_arg(ap, long), 10); 5497c478bd9Sstevel@tonic-gate } else if (c == 'O') { 5507c478bd9Sstevel@tonic-gate printn(va_arg(ap, long), 8); 5517c478bd9Sstevel@tonic-gate } 5527c478bd9Sstevel@tonic-gate goto loop; 5537c478bd9Sstevel@tonic-gate } 5547c478bd9Sstevel@tonic-gate 5557c478bd9Sstevel@tonic-gate 5567c478bd9Sstevel@tonic-gate /* 5577c478bd9Sstevel@tonic-gate * Print an unsigned integer in base b. 5587c478bd9Sstevel@tonic-gate */ 559*e5190c10Smuffin static int 560*e5190c10Smuffin printn(n, b) 561*e5190c10Smuffin long n; 562*e5190c10Smuffin int b; 5637c478bd9Sstevel@tonic-gate { 564*e5190c10Smuffin long a; 5657c478bd9Sstevel@tonic-gate 5667c478bd9Sstevel@tonic-gate if (n < 0) { /* shouldn't happen */ 5677c478bd9Sstevel@tonic-gate putchar('-'); 5687c478bd9Sstevel@tonic-gate n = -n; 5697c478bd9Sstevel@tonic-gate } 5707c478bd9Sstevel@tonic-gate if (a = n / b) 5717c478bd9Sstevel@tonic-gate printn(a, b); 5727c478bd9Sstevel@tonic-gate putchar("0123456789ABCDEF"[(int)(n%b)]); 573*e5190c10Smuffin 574*e5190c10Smuffin return (0); 5757c478bd9Sstevel@tonic-gate } 5767c478bd9Sstevel@tonic-gate 5777c478bd9Sstevel@tonic-gate /* scaled down version of library roff_sprintf */ 5787c478bd9Sstevel@tonic-gate /* same limits as fdprintf */ 5797c478bd9Sstevel@tonic-gate /* returns pointer to \0 that ends the string */ 5807c478bd9Sstevel@tonic-gate 5817c478bd9Sstevel@tonic-gate /* VARARGS2 */ 5827c478bd9Sstevel@tonic-gate char *roff_sprintf(char *str, char *fmt, ...) 5837c478bd9Sstevel@tonic-gate { 584*e5190c10Smuffin int c; 5857c478bd9Sstevel@tonic-gate char *s; 586*e5190c10Smuffin int i; 5877c478bd9Sstevel@tonic-gate va_list ap; 5887c478bd9Sstevel@tonic-gate 5897c478bd9Sstevel@tonic-gate va_start(ap, fmt); 5907c478bd9Sstevel@tonic-gate loop: 5917c478bd9Sstevel@tonic-gate while ((c = *fmt++) != '%') { 5927c478bd9Sstevel@tonic-gate if (c == '\0') { 5937c478bd9Sstevel@tonic-gate *str = 0; 5947c478bd9Sstevel@tonic-gate va_end(ap); 5957c478bd9Sstevel@tonic-gate return str; 5967c478bd9Sstevel@tonic-gate } 5977c478bd9Sstevel@tonic-gate *str++ = c; 5987c478bd9Sstevel@tonic-gate } 5997c478bd9Sstevel@tonic-gate c = *fmt++; 6007c478bd9Sstevel@tonic-gate if (c == 'd') { 6017c478bd9Sstevel@tonic-gate i = va_arg(ap, int); 6027c478bd9Sstevel@tonic-gate if (i < 0) { 6037c478bd9Sstevel@tonic-gate *str++ = '-'; 6047c478bd9Sstevel@tonic-gate i = -i; 6057c478bd9Sstevel@tonic-gate } 6067c478bd9Sstevel@tonic-gate str = sprintn(str, (long)i, 10); 6077c478bd9Sstevel@tonic-gate } else if (c == 'u' || c == 'o' || c == 'x') 6087c478bd9Sstevel@tonic-gate str = sprintn(str, va_arg(ap, long), c == 'o' ? 8 : (c == 'x' ? 16 : 10)); 6097c478bd9Sstevel@tonic-gate else if (c == 'c') { 6107c478bd9Sstevel@tonic-gate if (c > 0177 || c < 040) 6117c478bd9Sstevel@tonic-gate *str++ = '\\'; 6127c478bd9Sstevel@tonic-gate *str++ = va_arg(ap, int) & 0177; 6137c478bd9Sstevel@tonic-gate } else if (c == 's') { 6147c478bd9Sstevel@tonic-gate s = va_arg(ap, char *); 6157c478bd9Sstevel@tonic-gate while (c = *s++) 6167c478bd9Sstevel@tonic-gate *str++ = c; 6177c478bd9Sstevel@tonic-gate } else if (c == 'D') { 6187c478bd9Sstevel@tonic-gate str = sprintn(str, va_arg(ap, long), 10); 6197c478bd9Sstevel@tonic-gate } else if (c == 'O') { 6207c478bd9Sstevel@tonic-gate str = sprintn(str, va_arg(ap, unsigned) , 8); 6217c478bd9Sstevel@tonic-gate } 6227c478bd9Sstevel@tonic-gate goto loop; 6237c478bd9Sstevel@tonic-gate } 6247c478bd9Sstevel@tonic-gate 6257c478bd9Sstevel@tonic-gate /* 6267c478bd9Sstevel@tonic-gate * Print an unsigned integer in base b. 6277c478bd9Sstevel@tonic-gate */ 6287c478bd9Sstevel@tonic-gate static char *sprintn(s, n, b) 629*e5190c10Smuffin char *s; 630*e5190c10Smuffin long n; 631*e5190c10Smuffin int b; 6327c478bd9Sstevel@tonic-gate { 633*e5190c10Smuffin long a; 6347c478bd9Sstevel@tonic-gate 6357c478bd9Sstevel@tonic-gate if (n < 0) { /* shouldn't happen */ 6367c478bd9Sstevel@tonic-gate *s++ = '-'; 6377c478bd9Sstevel@tonic-gate n = -n; 6387c478bd9Sstevel@tonic-gate } 6397c478bd9Sstevel@tonic-gate if (a = n / b) 6407c478bd9Sstevel@tonic-gate s = sprintn(s, a, b); 6417c478bd9Sstevel@tonic-gate *s++ = "0123456789ABCDEF"[(int)(n%b)]; 6427c478bd9Sstevel@tonic-gate return s; 6437c478bd9Sstevel@tonic-gate } 6447c478bd9Sstevel@tonic-gate 6457c478bd9Sstevel@tonic-gate 646*e5190c10Smuffin int 6477c478bd9Sstevel@tonic-gate control(a, b) 648*e5190c10Smuffin int a, b; 6497c478bd9Sstevel@tonic-gate { 650*e5190c10Smuffin int j; 6517c478bd9Sstevel@tonic-gate 6527c478bd9Sstevel@tonic-gate if (a == 0 || (j = findmn(a)) == -1) 6537c478bd9Sstevel@tonic-gate return(0); 6547c478bd9Sstevel@tonic-gate 6557c478bd9Sstevel@tonic-gate /* 6567c478bd9Sstevel@tonic-gate * Attempt to find endless recursion at runtime. Arbitrary 6577c478bd9Sstevel@tonic-gate * recursion limit of MAX_RECURSION_DEPTH was chosen as 6587c478bd9Sstevel@tonic-gate * it is extremely unlikely that a correct nroff/troff 6597c478bd9Sstevel@tonic-gate * invocation would exceed this value. 6607c478bd9Sstevel@tonic-gate */ 6617c478bd9Sstevel@tonic-gate 6627c478bd9Sstevel@tonic-gate if (frame != stk) { 6637c478bd9Sstevel@tonic-gate int frame_cnt = 0; 6647c478bd9Sstevel@tonic-gate struct s *p; 6657c478bd9Sstevel@tonic-gate 6667c478bd9Sstevel@tonic-gate for (p = frame; p != stk; p = p->pframe) 6677c478bd9Sstevel@tonic-gate frame_cnt++; 6687c478bd9Sstevel@tonic-gate if (frame_cnt > MAX_RECURSION_DEPTH) { 6697c478bd9Sstevel@tonic-gate errprint( 6707c478bd9Sstevel@tonic-gate gettext("Exceeded maximum stack size (%d) when " 6717c478bd9Sstevel@tonic-gate "executing macro %c%c. Stack dump follows"), 6727c478bd9Sstevel@tonic-gate MAX_RECURSION_DEPTH, 6737c478bd9Sstevel@tonic-gate frame->mname & 0177, (frame->mname >> BYTE) & 0177); 6747c478bd9Sstevel@tonic-gate edone(02); 6757c478bd9Sstevel@tonic-gate } 6767c478bd9Sstevel@tonic-gate } 6777c478bd9Sstevel@tonic-gate 6787c478bd9Sstevel@tonic-gate #ifdef DEBUG 6797c478bd9Sstevel@tonic-gate if (debug & DB_MAC) 6807c478bd9Sstevel@tonic-gate fdprintf(stderr, "control: macro %c%c, contab[%d]\n", 6817c478bd9Sstevel@tonic-gate a&0177, (a>>BYTE)&0177 ? (a>>BYTE)&0177 : ' ', j); 682*e5190c10Smuffin #endif /* DEBUG */ 6837c478bd9Sstevel@tonic-gate if (contab[j].f == 0) { 6847c478bd9Sstevel@tonic-gate nxf->nargs = 0; 6857c478bd9Sstevel@tonic-gate if (b) 6867c478bd9Sstevel@tonic-gate collect(); 6877c478bd9Sstevel@tonic-gate flushi(); 6887c478bd9Sstevel@tonic-gate return pushi((filep)contab[j].mx, a); 6897c478bd9Sstevel@tonic-gate } else if (b) 6907c478bd9Sstevel@tonic-gate return((*contab[j].f)(0)); 6917c478bd9Sstevel@tonic-gate else 6927c478bd9Sstevel@tonic-gate return(0); 6937c478bd9Sstevel@tonic-gate } 6947c478bd9Sstevel@tonic-gate 695*e5190c10Smuffin int 6967c478bd9Sstevel@tonic-gate getrq() 6977c478bd9Sstevel@tonic-gate { 698*e5190c10Smuffin int i, j; 6997c478bd9Sstevel@tonic-gate 7007c478bd9Sstevel@tonic-gate if (((i = getach()) == 0) || ((j = getach()) == 0)) 7017c478bd9Sstevel@tonic-gate goto rtn; 7027c478bd9Sstevel@tonic-gate i = PAIR(i, j); 7037c478bd9Sstevel@tonic-gate rtn: 7047c478bd9Sstevel@tonic-gate return(i); 7057c478bd9Sstevel@tonic-gate } 7067c478bd9Sstevel@tonic-gate 7077c478bd9Sstevel@tonic-gate /* 7087c478bd9Sstevel@tonic-gate * table encodes some special characters, to speed up tests 7097c478bd9Sstevel@tonic-gate * in getchar, viz FLSS, RPT, f, \b, \n, fc, tabch, ldrch 7107c478bd9Sstevel@tonic-gate */ 7117c478bd9Sstevel@tonic-gate 7127c478bd9Sstevel@tonic-gate char 7137c478bd9Sstevel@tonic-gate gchtab[] = { 7147c478bd9Sstevel@tonic-gate 000,004,000,000,010,000,000,000, /* fc, ldr */ 7157c478bd9Sstevel@tonic-gate 001,002,001,000,001,000,000,000, /* \b, tab, nl, RPT */ 7167c478bd9Sstevel@tonic-gate 000,000,000,000,000,000,000,000, 7177c478bd9Sstevel@tonic-gate 000,001,000,000,000,000,000,000, /* FLSS */ 7187c478bd9Sstevel@tonic-gate 000,000,000,000,000,000,000,000, 7197c478bd9Sstevel@tonic-gate 000,000,000,000,000,000,000,000, 7207c478bd9Sstevel@tonic-gate 000,000,000,000,000,000,000,000, 7217c478bd9Sstevel@tonic-gate 000,000,000,000,000,000,000,000, 7227c478bd9Sstevel@tonic-gate 000,000,000,000,000,000,000,000, 7237c478bd9Sstevel@tonic-gate 000,000,000,000,000,000,000,000, 7247c478bd9Sstevel@tonic-gate 000,000,000,000,000,000,000,000, 7257c478bd9Sstevel@tonic-gate 000,000,000,000,000,000,000,000, 7267c478bd9Sstevel@tonic-gate 000,000,000,000,000,000,001,000, /* f */ 7277c478bd9Sstevel@tonic-gate 000,000,000,000,000,000,000,000, 7287c478bd9Sstevel@tonic-gate 000,000,000,000,000,000,000,000, 7297c478bd9Sstevel@tonic-gate 000,000,000,000,000,000,000,000, 7307c478bd9Sstevel@tonic-gate }; 7317c478bd9Sstevel@tonic-gate 7327c478bd9Sstevel@tonic-gate tchar 7337c478bd9Sstevel@tonic-gate getch() 7347c478bd9Sstevel@tonic-gate { 735*e5190c10Smuffin int k; 736*e5190c10Smuffin tchar i, j; 7377c478bd9Sstevel@tonic-gate tchar setht(), setslant(); 7387c478bd9Sstevel@tonic-gate 7397c478bd9Sstevel@tonic-gate g0: 7407c478bd9Sstevel@tonic-gate if (i = ch) { 7417c478bd9Sstevel@tonic-gate #ifdef DEBUG 7427c478bd9Sstevel@tonic-gate if (debug & DB_GETC) 7437c478bd9Sstevel@tonic-gate fdprintf(stderr, "getch: ch is %x (%c)\n", 7447c478bd9Sstevel@tonic-gate ch, (ch&0177) < 040 ? 0177 : ch&0177); 745*e5190c10Smuffin #endif /* DEBUG */ 7467c478bd9Sstevel@tonic-gate if (cbits(i) == '\n') 7477c478bd9Sstevel@tonic-gate nlflg++; 7487c478bd9Sstevel@tonic-gate ch = 0; 7497c478bd9Sstevel@tonic-gate return(i); 7507c478bd9Sstevel@tonic-gate } 7517c478bd9Sstevel@tonic-gate 7527c478bd9Sstevel@tonic-gate #ifdef DEBUG 7537c478bd9Sstevel@tonic-gate if (nlflg) 7547c478bd9Sstevel@tonic-gate if (debug & DB_GETC) 7557c478bd9Sstevel@tonic-gate fdprintf(stderr,"getch: nlflg is %x\n", nlflg); 756*e5190c10Smuffin #endif /* DEBUG */ 7577c478bd9Sstevel@tonic-gate if (nlflg) 7587c478bd9Sstevel@tonic-gate return('\n'); 7597c478bd9Sstevel@tonic-gate i = getch0(); 7607c478bd9Sstevel@tonic-gate #ifdef DEBUG 7617c478bd9Sstevel@tonic-gate if (debug & DB_GETC) 7627c478bd9Sstevel@tonic-gate fdprintf(stderr, "getch: getch0 returns %x (%c)\n", 7637c478bd9Sstevel@tonic-gate i, (i&0177) < 040 ? 0177 : i&0177); 764*e5190c10Smuffin #endif /* DEBUG */ 7657c478bd9Sstevel@tonic-gate if (ismot(i)) 7667c478bd9Sstevel@tonic-gate return(i); 7677c478bd9Sstevel@tonic-gate k = cbits(i); 7687c478bd9Sstevel@tonic-gate if (k != ESC) { 7697c478bd9Sstevel@tonic-gate /* 7707c478bd9Sstevel@tonic-gate * gchtab[] has only 128 entries 7717c478bd9Sstevel@tonic-gate * if k is out of the range, it should be 7727c478bd9Sstevel@tonic-gate * handled as gchtab[k] == 0 7737c478bd9Sstevel@tonic-gate */ 7747c478bd9Sstevel@tonic-gate if (!isascii(k) || gchtab[k]==0) 7757c478bd9Sstevel@tonic-gate return(i); 7767c478bd9Sstevel@tonic-gate if (k == '\n') { 7777c478bd9Sstevel@tonic-gate if (cbits(i) == '\n') { 7787c478bd9Sstevel@tonic-gate nlflg++; 7797c478bd9Sstevel@tonic-gate if (ip == 0) 7807c478bd9Sstevel@tonic-gate numtab[CD].val++; /* line number */ 7817c478bd9Sstevel@tonic-gate } 7827c478bd9Sstevel@tonic-gate return(k); 7837c478bd9Sstevel@tonic-gate } 7847c478bd9Sstevel@tonic-gate if (k == FLSS) { 7857c478bd9Sstevel@tonic-gate copyf++; 7867c478bd9Sstevel@tonic-gate raw++; 7877c478bd9Sstevel@tonic-gate i = getch0(); 7887c478bd9Sstevel@tonic-gate if (!fi) 7897c478bd9Sstevel@tonic-gate flss = i; 7907c478bd9Sstevel@tonic-gate copyf--; 7917c478bd9Sstevel@tonic-gate raw--; 7927c478bd9Sstevel@tonic-gate goto g0; 7937c478bd9Sstevel@tonic-gate } 7947c478bd9Sstevel@tonic-gate if (k == RPT) { 7957c478bd9Sstevel@tonic-gate setrpt(); 7967c478bd9Sstevel@tonic-gate goto g0; 7977c478bd9Sstevel@tonic-gate } 7987c478bd9Sstevel@tonic-gate if (!copyf) { 7997c478bd9Sstevel@tonic-gate if (k == 'f' && lg && !lgf) { 8007c478bd9Sstevel@tonic-gate i = getlg(i); 8017c478bd9Sstevel@tonic-gate return(i); 8027c478bd9Sstevel@tonic-gate } 8037c478bd9Sstevel@tonic-gate if (k == fc || k == tabch || k == ldrch) { 8047c478bd9Sstevel@tonic-gate if ((i = setfield(k)) == 0) 8057c478bd9Sstevel@tonic-gate goto g0; 8067c478bd9Sstevel@tonic-gate else 8077c478bd9Sstevel@tonic-gate return(i); 8087c478bd9Sstevel@tonic-gate } 8097c478bd9Sstevel@tonic-gate if (k == '\b') { 8107c478bd9Sstevel@tonic-gate i = makem(-width(' ' | chbits)); 8117c478bd9Sstevel@tonic-gate return(i); 8127c478bd9Sstevel@tonic-gate } 8137c478bd9Sstevel@tonic-gate } 8147c478bd9Sstevel@tonic-gate return(i); 8157c478bd9Sstevel@tonic-gate } 8167c478bd9Sstevel@tonic-gate k = cbits(j = getch0()); 8177c478bd9Sstevel@tonic-gate if (ismot(j)) 8187c478bd9Sstevel@tonic-gate return(j); 8197c478bd9Sstevel@tonic-gate switch (k) { 8207c478bd9Sstevel@tonic-gate 8217c478bd9Sstevel@tonic-gate case 'X': /* \X'...' for copy through */ 8227c478bd9Sstevel@tonic-gate setxon(); 8237c478bd9Sstevel@tonic-gate goto g0; 8247c478bd9Sstevel@tonic-gate case '\n': /* concealed newline */ 8257c478bd9Sstevel@tonic-gate goto g0; 8267c478bd9Sstevel@tonic-gate case 'n': /* number register */ 8277c478bd9Sstevel@tonic-gate setn(); 8287c478bd9Sstevel@tonic-gate goto g0; 8297c478bd9Sstevel@tonic-gate case '*': /* string indicator */ 8307c478bd9Sstevel@tonic-gate setstr(); 8317c478bd9Sstevel@tonic-gate goto g0; 8327c478bd9Sstevel@tonic-gate case '$': /* argument indicator */ 8337c478bd9Sstevel@tonic-gate seta(); 8347c478bd9Sstevel@tonic-gate goto g0; 8357c478bd9Sstevel@tonic-gate case '{': /* LEFT */ 8367c478bd9Sstevel@tonic-gate i = LEFT; 8377c478bd9Sstevel@tonic-gate goto gx; 8387c478bd9Sstevel@tonic-gate case '}': /* RIGHT */ 8397c478bd9Sstevel@tonic-gate i = RIGHT; 8407c478bd9Sstevel@tonic-gate goto gx; 8417c478bd9Sstevel@tonic-gate case '"': /* comment */ 8427c478bd9Sstevel@tonic-gate while (cbits(i = getch0()) != '\n') 8437c478bd9Sstevel@tonic-gate ; 8447c478bd9Sstevel@tonic-gate nlflg++; 8457c478bd9Sstevel@tonic-gate if (ip == 0) 8467c478bd9Sstevel@tonic-gate numtab[CD].val++; 8477c478bd9Sstevel@tonic-gate return(i); 8487c478bd9Sstevel@tonic-gate case ESC: /* double backslash */ 8497c478bd9Sstevel@tonic-gate i = eschar; 8507c478bd9Sstevel@tonic-gate goto gx; 8517c478bd9Sstevel@tonic-gate case 'e': /* printable version of current eschar */ 8527c478bd9Sstevel@tonic-gate i = PRESC; 8537c478bd9Sstevel@tonic-gate goto gx; 8547c478bd9Sstevel@tonic-gate case ' ': /* unpaddable space */ 8557c478bd9Sstevel@tonic-gate i = UNPAD; 8567c478bd9Sstevel@tonic-gate goto gx; 8577c478bd9Sstevel@tonic-gate case '\'': /* \(aa */ 8587c478bd9Sstevel@tonic-gate i = ACUTE; 8597c478bd9Sstevel@tonic-gate goto gx; 8607c478bd9Sstevel@tonic-gate case '`': /* \(ga */ 8617c478bd9Sstevel@tonic-gate i = GRAVE; 8627c478bd9Sstevel@tonic-gate goto gx; 8637c478bd9Sstevel@tonic-gate case '_': /* \(ul */ 8647c478bd9Sstevel@tonic-gate i = UNDERLINE; 8657c478bd9Sstevel@tonic-gate goto gx; 8667c478bd9Sstevel@tonic-gate case '-': /* current font minus */ 8677c478bd9Sstevel@tonic-gate i = MINUS; 8687c478bd9Sstevel@tonic-gate goto gx; 8697c478bd9Sstevel@tonic-gate case '&': /* filler */ 8707c478bd9Sstevel@tonic-gate i = FILLER; 8717c478bd9Sstevel@tonic-gate goto gx; 8727c478bd9Sstevel@tonic-gate case 'c': /* to be continued */ 8737c478bd9Sstevel@tonic-gate i = CONT; 8747c478bd9Sstevel@tonic-gate goto gx; 8757c478bd9Sstevel@tonic-gate case '!': /* transparent indicator */ 8767c478bd9Sstevel@tonic-gate i = XPAR; 8777c478bd9Sstevel@tonic-gate goto gx; 8787c478bd9Sstevel@tonic-gate case 't': /* tab */ 8797c478bd9Sstevel@tonic-gate i = '\t'; 8807c478bd9Sstevel@tonic-gate return(i); 8817c478bd9Sstevel@tonic-gate case 'a': /* leader (SOH) */ 8827c478bd9Sstevel@tonic-gate i = LEADER; 8837c478bd9Sstevel@tonic-gate return(i); 8847c478bd9Sstevel@tonic-gate case '%': /* ohc */ 8857c478bd9Sstevel@tonic-gate i = OHC; 8867c478bd9Sstevel@tonic-gate return(i); 8877c478bd9Sstevel@tonic-gate case 'g': /* return format of a number register */ 8887c478bd9Sstevel@tonic-gate setaf(); 8897c478bd9Sstevel@tonic-gate goto g0; 8907c478bd9Sstevel@tonic-gate case 'N': /* absolute character number */ 8917c478bd9Sstevel@tonic-gate i = setabs(); 8927c478bd9Sstevel@tonic-gate goto gx; 8937c478bd9Sstevel@tonic-gate case '.': /* . */ 8947c478bd9Sstevel@tonic-gate i = '.'; 8957c478bd9Sstevel@tonic-gate gx: 8967c478bd9Sstevel@tonic-gate setsfbits(i, sfbits(j)); 8977c478bd9Sstevel@tonic-gate return(i); 8987c478bd9Sstevel@tonic-gate } 8997c478bd9Sstevel@tonic-gate if (copyf) { 9007c478bd9Sstevel@tonic-gate *pbp++ = j; 9017c478bd9Sstevel@tonic-gate return(eschar); 9027c478bd9Sstevel@tonic-gate } 9037c478bd9Sstevel@tonic-gate switch (k) { 9047c478bd9Sstevel@tonic-gate 9057c478bd9Sstevel@tonic-gate case 'p': /* spread */ 9067c478bd9Sstevel@tonic-gate spread++; 9077c478bd9Sstevel@tonic-gate goto g0; 9087c478bd9Sstevel@tonic-gate case '(': /* special char name */ 9097c478bd9Sstevel@tonic-gate if ((i = setch()) == 0) 9107c478bd9Sstevel@tonic-gate goto g0; 9117c478bd9Sstevel@tonic-gate return(i); 9127c478bd9Sstevel@tonic-gate case 's': /* size indicator */ 9137c478bd9Sstevel@tonic-gate setps(); 9147c478bd9Sstevel@tonic-gate goto g0; 9157c478bd9Sstevel@tonic-gate case 'H': /* character height */ 9167c478bd9Sstevel@tonic-gate return(setht()); 9177c478bd9Sstevel@tonic-gate case 'S': /* slant */ 9187c478bd9Sstevel@tonic-gate return(setslant()); 9197c478bd9Sstevel@tonic-gate case 'f': /* font indicator */ 9207c478bd9Sstevel@tonic-gate setfont(0); 9217c478bd9Sstevel@tonic-gate goto g0; 9227c478bd9Sstevel@tonic-gate case 'w': /* width function */ 9237c478bd9Sstevel@tonic-gate setwd(); 9247c478bd9Sstevel@tonic-gate goto g0; 9257c478bd9Sstevel@tonic-gate case 'v': /* vert mot */ 9267c478bd9Sstevel@tonic-gate if (i = vmot()) 9277c478bd9Sstevel@tonic-gate return(i); 9287c478bd9Sstevel@tonic-gate goto g0; 9297c478bd9Sstevel@tonic-gate case 'h': /* horiz mot */ 9307c478bd9Sstevel@tonic-gate if (i = hmot()) 9317c478bd9Sstevel@tonic-gate return(i); 9327c478bd9Sstevel@tonic-gate goto g0; 9337c478bd9Sstevel@tonic-gate case 'z': /* zero with char */ 9347c478bd9Sstevel@tonic-gate return(setz()); 9357c478bd9Sstevel@tonic-gate case 'l': /* hor line */ 9367c478bd9Sstevel@tonic-gate setline(); 9377c478bd9Sstevel@tonic-gate goto g0; 9387c478bd9Sstevel@tonic-gate case 'L': /* vert line */ 9397c478bd9Sstevel@tonic-gate setvline(); 9407c478bd9Sstevel@tonic-gate goto g0; 9417c478bd9Sstevel@tonic-gate case 'D': /* drawing function */ 9427c478bd9Sstevel@tonic-gate setdraw(); 9437c478bd9Sstevel@tonic-gate goto g0; 9447c478bd9Sstevel@tonic-gate case 'b': /* bracket */ 9457c478bd9Sstevel@tonic-gate setbra(); 9467c478bd9Sstevel@tonic-gate goto g0; 9477c478bd9Sstevel@tonic-gate case 'o': /* overstrike */ 9487c478bd9Sstevel@tonic-gate setov(); 9497c478bd9Sstevel@tonic-gate goto g0; 9507c478bd9Sstevel@tonic-gate case 'k': /* mark hor place */ 9517c478bd9Sstevel@tonic-gate if ((k = findr(getsn())) != -1) { 9527c478bd9Sstevel@tonic-gate numtab[k].val = numtab[HP].val; 9537c478bd9Sstevel@tonic-gate } 9547c478bd9Sstevel@tonic-gate goto g0; 9557c478bd9Sstevel@tonic-gate case '0': /* number space */ 9567c478bd9Sstevel@tonic-gate return(makem(width('0' | chbits))); 9577c478bd9Sstevel@tonic-gate #ifdef NROFF 9587c478bd9Sstevel@tonic-gate case '|': 9597c478bd9Sstevel@tonic-gate case '^': 9607c478bd9Sstevel@tonic-gate goto g0; 9617c478bd9Sstevel@tonic-gate #else 9627c478bd9Sstevel@tonic-gate case '|': /* narrow space */ 9637c478bd9Sstevel@tonic-gate return(makem((int)(EM)/6)); 9647c478bd9Sstevel@tonic-gate case '^': /* half narrow space */ 9657c478bd9Sstevel@tonic-gate return(makem((int)(EM)/12)); 9667c478bd9Sstevel@tonic-gate #endif 9677c478bd9Sstevel@tonic-gate case 'x': /* extra line space */ 9687c478bd9Sstevel@tonic-gate if (i = xlss()) 9697c478bd9Sstevel@tonic-gate return(i); 9707c478bd9Sstevel@tonic-gate goto g0; 9717c478bd9Sstevel@tonic-gate case 'u': /* half em up */ 9727c478bd9Sstevel@tonic-gate case 'r': /* full em up */ 9737c478bd9Sstevel@tonic-gate case 'd': /* half em down */ 9747c478bd9Sstevel@tonic-gate return(sethl(k)); 9757c478bd9Sstevel@tonic-gate default: 9767c478bd9Sstevel@tonic-gate return(j); 9777c478bd9Sstevel@tonic-gate } 9787c478bd9Sstevel@tonic-gate /* NOTREACHED */ 9797c478bd9Sstevel@tonic-gate } 9807c478bd9Sstevel@tonic-gate 981*e5190c10Smuffin int 9827c478bd9Sstevel@tonic-gate setxon() /* \X'...' for copy through */ 9837c478bd9Sstevel@tonic-gate { 9847c478bd9Sstevel@tonic-gate tchar xbuf[NC]; 985*e5190c10Smuffin tchar *i; 9867c478bd9Sstevel@tonic-gate tchar c; 9877c478bd9Sstevel@tonic-gate int delim, k; 9887c478bd9Sstevel@tonic-gate 9897c478bd9Sstevel@tonic-gate if (ismot(c = getch())) 990*e5190c10Smuffin return (0); 9917c478bd9Sstevel@tonic-gate delim = cbits(c); 9927c478bd9Sstevel@tonic-gate i = xbuf; 9937c478bd9Sstevel@tonic-gate *i++ = XON; 9947c478bd9Sstevel@tonic-gate while ((k = cbits(c = getch())) != delim && k != '\n' && i < xbuf+NC-1) { 9957c478bd9Sstevel@tonic-gate if (k == ' ') 9967c478bd9Sstevel@tonic-gate setcbits(c, UNPAD); 9977c478bd9Sstevel@tonic-gate *i++ = c | ZBIT; 9987c478bd9Sstevel@tonic-gate } 9997c478bd9Sstevel@tonic-gate *i++ = XOFF; 10007c478bd9Sstevel@tonic-gate *i = 0; 10017c478bd9Sstevel@tonic-gate pushback(xbuf); 1002*e5190c10Smuffin 1003*e5190c10Smuffin return (0); 10047c478bd9Sstevel@tonic-gate } 10057c478bd9Sstevel@tonic-gate 10067c478bd9Sstevel@tonic-gate 10077c478bd9Sstevel@tonic-gate char ifilt[32] = { 10087c478bd9Sstevel@tonic-gate 0, 001, 002, 003, 0, 005, 006, 007, 010, 011, 012}; 10097c478bd9Sstevel@tonic-gate 10107c478bd9Sstevel@tonic-gate tchar getch0() 10117c478bd9Sstevel@tonic-gate { 1012*e5190c10Smuffin int j; 1013*e5190c10Smuffin tchar i; 10147c478bd9Sstevel@tonic-gate #ifdef EUC 10157c478bd9Sstevel@tonic-gate #ifdef NROFF 1016*e5190c10Smuffin int n; 10177c478bd9Sstevel@tonic-gate int col_index; 10187c478bd9Sstevel@tonic-gate #endif /* NROFF */ 10197c478bd9Sstevel@tonic-gate #endif /* EUC */ 10207c478bd9Sstevel@tonic-gate 10217c478bd9Sstevel@tonic-gate again: 10227c478bd9Sstevel@tonic-gate if (pbp > lastpbp) 10237c478bd9Sstevel@tonic-gate i = *--pbp; 10247c478bd9Sstevel@tonic-gate else if (ip) { 10257c478bd9Sstevel@tonic-gate #ifdef INCORE 10267c478bd9Sstevel@tonic-gate extern tchar corebuf[]; 10277c478bd9Sstevel@tonic-gate i = corebuf[ip]; 10287c478bd9Sstevel@tonic-gate if (i == 0) 10297c478bd9Sstevel@tonic-gate i = rbf(); 10307c478bd9Sstevel@tonic-gate else { 10317c478bd9Sstevel@tonic-gate if ((++ip & (BLK - 1)) == 0) { 10327c478bd9Sstevel@tonic-gate --ip; 10337c478bd9Sstevel@tonic-gate (void)rbf(); 10347c478bd9Sstevel@tonic-gate } 10357c478bd9Sstevel@tonic-gate } 10367c478bd9Sstevel@tonic-gate #else 10377c478bd9Sstevel@tonic-gate i = rbf(); 10387c478bd9Sstevel@tonic-gate #endif 10397c478bd9Sstevel@tonic-gate } else { 10407c478bd9Sstevel@tonic-gate if (donef || ndone) 10417c478bd9Sstevel@tonic-gate done(0); 10427c478bd9Sstevel@tonic-gate if (nx || ibufp >= eibuf) { 10437c478bd9Sstevel@tonic-gate if (nfo==0) { 10447c478bd9Sstevel@tonic-gate g0: 10457c478bd9Sstevel@tonic-gate if (nextfile()) { 10467c478bd9Sstevel@tonic-gate if (ip) 10477c478bd9Sstevel@tonic-gate goto again; 10487c478bd9Sstevel@tonic-gate if (ibufp < eibuf) 10497c478bd9Sstevel@tonic-gate goto g2; 10507c478bd9Sstevel@tonic-gate } 10517c478bd9Sstevel@tonic-gate } 10527c478bd9Sstevel@tonic-gate nx = 0; 10537c478bd9Sstevel@tonic-gate if ((j = read(ifile, ibuf, IBUFSZ)) <= 0) 10547c478bd9Sstevel@tonic-gate goto g0; 10557c478bd9Sstevel@tonic-gate ibufp = ibuf; 10567c478bd9Sstevel@tonic-gate eibuf = ibuf + j; 10577c478bd9Sstevel@tonic-gate if (ip) 10587c478bd9Sstevel@tonic-gate goto again; 10597c478bd9Sstevel@tonic-gate } 10607c478bd9Sstevel@tonic-gate g2: 10617c478bd9Sstevel@tonic-gate #ifndef EUC 10627c478bd9Sstevel@tonic-gate i = *ibufp++ & 0177; 10637c478bd9Sstevel@tonic-gate ioff++; 10647c478bd9Sstevel@tonic-gate if (i >= 040 && i < 0177) 10657c478bd9Sstevel@tonic-gate #else 10667c478bd9Sstevel@tonic-gate #ifndef NROFF 10677c478bd9Sstevel@tonic-gate i = *ibufp++ & 0177; 10687c478bd9Sstevel@tonic-gate ioff++; 10697c478bd9Sstevel@tonic-gate if (i >= 040 && i < 0177) 10707c478bd9Sstevel@tonic-gate #else 10717c478bd9Sstevel@tonic-gate i = *ibufp++ & 0377; 10727c478bd9Sstevel@tonic-gate *mbbuf1p++ = i; 10737c478bd9Sstevel@tonic-gate *mbbuf1p = 0; 10747c478bd9Sstevel@tonic-gate if (!multi_locale) { 10757c478bd9Sstevel@tonic-gate twc = 0; 10767c478bd9Sstevel@tonic-gate mbbuf1p = mbbuf1; 10777c478bd9Sstevel@tonic-gate } else if ((n = mbtowc(&twc, mbbuf1, MB_CUR_MAX)) <= 0) { 10787c478bd9Sstevel@tonic-gate if (mbbuf1p >= mbbuf1 + MB_CUR_MAX) { 10797c478bd9Sstevel@tonic-gate i &= ~(MBMASK | CSMASK); 10807c478bd9Sstevel@tonic-gate twc = 0; 10817c478bd9Sstevel@tonic-gate mbbuf1p = mbbuf1; 10827c478bd9Sstevel@tonic-gate *mbbuf1p = 0; 10837c478bd9Sstevel@tonic-gate } else { 10847c478bd9Sstevel@tonic-gate i |= (MIDDLEOFMB); 10857c478bd9Sstevel@tonic-gate } 10867c478bd9Sstevel@tonic-gate } else { 10877c478bd9Sstevel@tonic-gate if (n > 1) 10887c478bd9Sstevel@tonic-gate i |= (LASTOFMB); 10897c478bd9Sstevel@tonic-gate else 10907c478bd9Sstevel@tonic-gate i |= (BYTE_CHR); 10917c478bd9Sstevel@tonic-gate if (isascii(twc)) { 10927c478bd9Sstevel@tonic-gate col_index = 0; 10937c478bd9Sstevel@tonic-gate } else { 10947c478bd9Sstevel@tonic-gate if ((col_index = wcwidth(twc)) < 0) 10957c478bd9Sstevel@tonic-gate col_index = 0; 10967c478bd9Sstevel@tonic-gate } 10977c478bd9Sstevel@tonic-gate setcsbits(i, col_index); 10987c478bd9Sstevel@tonic-gate twc = 0; 10997c478bd9Sstevel@tonic-gate mbbuf1p = mbbuf1; 11007c478bd9Sstevel@tonic-gate } 11017c478bd9Sstevel@tonic-gate ioff++; 11027c478bd9Sstevel@tonic-gate if (i >= 040 && i != 0177) 11037c478bd9Sstevel@tonic-gate #endif /* NROFF */ 11047c478bd9Sstevel@tonic-gate #endif /* EUC */ 11057c478bd9Sstevel@tonic-gate goto g4; 11067c478bd9Sstevel@tonic-gate if (i != 0177) 11077c478bd9Sstevel@tonic-gate i = ifilt[i]; 11087c478bd9Sstevel@tonic-gate } 11097c478bd9Sstevel@tonic-gate if (cbits(i) == IMP && !raw) 11107c478bd9Sstevel@tonic-gate goto again; 11117c478bd9Sstevel@tonic-gate if ((i == 0 || i == 0177) && !init && !raw) { 11127c478bd9Sstevel@tonic-gate goto again; 11137c478bd9Sstevel@tonic-gate } 11147c478bd9Sstevel@tonic-gate g4: 11157c478bd9Sstevel@tonic-gate #ifndef EUC 11167c478bd9Sstevel@tonic-gate if (copyf == 0 && (i & ~BYTEMASK) == 0) 11177c478bd9Sstevel@tonic-gate #else 11187c478bd9Sstevel@tonic-gate #ifndef NROFF 11197c478bd9Sstevel@tonic-gate if (copyf == 0 && (i & ~BYTEMASK) == 0) 11207c478bd9Sstevel@tonic-gate #else 11217c478bd9Sstevel@tonic-gate if (copyf == 0 && (i & ~CHMASK) == 0) 11227c478bd9Sstevel@tonic-gate #endif /* NROFF */ 11237c478bd9Sstevel@tonic-gate #endif /* EUC */ 11247c478bd9Sstevel@tonic-gate i |= chbits; 11257c478bd9Sstevel@tonic-gate #ifdef EUC 11267c478bd9Sstevel@tonic-gate #ifdef NROFF 11277c478bd9Sstevel@tonic-gate if (multi_locale) 11287c478bd9Sstevel@tonic-gate if (i & MBMASK1) 11297c478bd9Sstevel@tonic-gate i |= ZBIT; 11307c478bd9Sstevel@tonic-gate #endif /* NROFF */ 11317c478bd9Sstevel@tonic-gate #endif /* EUC */ 11327c478bd9Sstevel@tonic-gate if (cbits(i) == eschar && !raw) 11337c478bd9Sstevel@tonic-gate setcbits(i, ESC); 11347c478bd9Sstevel@tonic-gate return(i); 11357c478bd9Sstevel@tonic-gate } 11367c478bd9Sstevel@tonic-gate 1137*e5190c10Smuffin int 11387c478bd9Sstevel@tonic-gate pushback(b) 1139*e5190c10Smuffin tchar *b; 11407c478bd9Sstevel@tonic-gate { 1141*e5190c10Smuffin tchar *ob = b; 11427c478bd9Sstevel@tonic-gate 11437c478bd9Sstevel@tonic-gate while (*b++) 11447c478bd9Sstevel@tonic-gate ; 11457c478bd9Sstevel@tonic-gate b--; 11467c478bd9Sstevel@tonic-gate while (b > ob && pbp < &pbbuf[NC-3]) 11477c478bd9Sstevel@tonic-gate *pbp++ = *--b; 11487c478bd9Sstevel@tonic-gate if (pbp >= &pbbuf[NC-3]) { 11497c478bd9Sstevel@tonic-gate errprint(gettext("pushback overflow")); 11507c478bd9Sstevel@tonic-gate done(2); 11517c478bd9Sstevel@tonic-gate } 1152*e5190c10Smuffin 1153*e5190c10Smuffin return (0); 11547c478bd9Sstevel@tonic-gate } 11557c478bd9Sstevel@tonic-gate 1156*e5190c10Smuffin int 11577c478bd9Sstevel@tonic-gate cpushback(b) 1158*e5190c10Smuffin char *b; 11597c478bd9Sstevel@tonic-gate { 1160*e5190c10Smuffin char *ob = b; 11617c478bd9Sstevel@tonic-gate 11627c478bd9Sstevel@tonic-gate while (*b++) 11637c478bd9Sstevel@tonic-gate ; 11647c478bd9Sstevel@tonic-gate b--; 11657c478bd9Sstevel@tonic-gate while (b > ob && pbp < &pbbuf[NC-3]) 11667c478bd9Sstevel@tonic-gate *pbp++ = *--b; 11677c478bd9Sstevel@tonic-gate if (pbp >= &pbbuf[NC-3]) { 11687c478bd9Sstevel@tonic-gate errprint(gettext("cpushback overflow")); 11697c478bd9Sstevel@tonic-gate done(2); 11707c478bd9Sstevel@tonic-gate } 1171*e5190c10Smuffin 1172*e5190c10Smuffin return (0); 11737c478bd9Sstevel@tonic-gate } 11747c478bd9Sstevel@tonic-gate 1175*e5190c10Smuffin int 11767c478bd9Sstevel@tonic-gate nextfile() 11777c478bd9Sstevel@tonic-gate { 1178*e5190c10Smuffin char *p; 11797c478bd9Sstevel@tonic-gate 11807c478bd9Sstevel@tonic-gate n0: 11817c478bd9Sstevel@tonic-gate if (ifile) 11827c478bd9Sstevel@tonic-gate close(ifile); 11837c478bd9Sstevel@tonic-gate if (nx || nmfi < mflg) { 11847c478bd9Sstevel@tonic-gate p = mfiles[nmfi++]; 11857c478bd9Sstevel@tonic-gate if (*p != 0) 11867c478bd9Sstevel@tonic-gate goto n1; 11877c478bd9Sstevel@tonic-gate } 11887c478bd9Sstevel@tonic-gate if (ifi > 0) { 11897c478bd9Sstevel@tonic-gate if (popf()) 11907c478bd9Sstevel@tonic-gate goto n0; /* popf error */ 11917c478bd9Sstevel@tonic-gate return(1); /* popf ok */ 11927c478bd9Sstevel@tonic-gate } 11937c478bd9Sstevel@tonic-gate if (rargc-- <= 0) { 11947c478bd9Sstevel@tonic-gate if ((nfo -= mflg) && !stdi) 11957c478bd9Sstevel@tonic-gate done(0); 11967c478bd9Sstevel@tonic-gate nfo++; 11977c478bd9Sstevel@tonic-gate numtab[CD].val = ifile = stdi = mflg = 0; 11987c478bd9Sstevel@tonic-gate strcpy(cfname[ifi], "<standard input>"); 11997c478bd9Sstevel@tonic-gate ioff = 0; 12007c478bd9Sstevel@tonic-gate return(0); 12017c478bd9Sstevel@tonic-gate } 12027c478bd9Sstevel@tonic-gate p = (argp++)[0]; 12037c478bd9Sstevel@tonic-gate n1: 12047c478bd9Sstevel@tonic-gate numtab[CD].val = 0; 12057c478bd9Sstevel@tonic-gate if (p[0] == '-' && p[1] == 0) { 12067c478bd9Sstevel@tonic-gate ifile = 0; 12077c478bd9Sstevel@tonic-gate strcpy(cfname[ifi], "<standard input>"); 12087c478bd9Sstevel@tonic-gate } else if ((ifile = open(p, 0)) < 0) { 12097c478bd9Sstevel@tonic-gate errprint(gettext("cannot open file %s"), p); 12107c478bd9Sstevel@tonic-gate nfo -= mflg; 12117c478bd9Sstevel@tonic-gate done(02); 12127c478bd9Sstevel@tonic-gate } else 12137c478bd9Sstevel@tonic-gate strcpy(cfname[ifi],p); 12147c478bd9Sstevel@tonic-gate nfo++; 12157c478bd9Sstevel@tonic-gate ioff = 0; 12167c478bd9Sstevel@tonic-gate return(0); 12177c478bd9Sstevel@tonic-gate } 12187c478bd9Sstevel@tonic-gate 12197c478bd9Sstevel@tonic-gate 1220*e5190c10Smuffin int 12217c478bd9Sstevel@tonic-gate popf() 12227c478bd9Sstevel@tonic-gate { 1223*e5190c10Smuffin int i; 1224*e5190c10Smuffin char *p, *q; 12257c478bd9Sstevel@tonic-gate extern char *ttyname(); 12267c478bd9Sstevel@tonic-gate 12277c478bd9Sstevel@tonic-gate ioff = offl[--ifi]; 12287c478bd9Sstevel@tonic-gate numtab[CD].val = cfline[ifi]; /*restore line counter*/ 12297c478bd9Sstevel@tonic-gate ip = ipl[ifi]; 12307c478bd9Sstevel@tonic-gate if ((ifile = ifl[ifi]) == 0) { 12317c478bd9Sstevel@tonic-gate p = xbuf; 12327c478bd9Sstevel@tonic-gate q = ibuf; 12337c478bd9Sstevel@tonic-gate ibufp = xbufp; 12347c478bd9Sstevel@tonic-gate eibuf = xeibuf; 12357c478bd9Sstevel@tonic-gate while (q < eibuf) 12367c478bd9Sstevel@tonic-gate *q++ = *p++; 12377c478bd9Sstevel@tonic-gate return(0); 12387c478bd9Sstevel@tonic-gate } 12397c478bd9Sstevel@tonic-gate if (lseek(ifile, (long)(ioff & ~(IBUFSZ-1)), 0) == (long) -1 12407c478bd9Sstevel@tonic-gate || (i = read(ifile, ibuf, IBUFSZ)) < 0) 12417c478bd9Sstevel@tonic-gate return(1); 12427c478bd9Sstevel@tonic-gate eibuf = ibuf + i; 12437c478bd9Sstevel@tonic-gate ibufp = ibuf; 12447c478bd9Sstevel@tonic-gate if (ttyname(ifile) == 0) 12457c478bd9Sstevel@tonic-gate /* was >= ... */ 12467c478bd9Sstevel@tonic-gate if ((ibufp = ibuf + (int)(ioff & (IBUFSZ - 1))) > eibuf) 12477c478bd9Sstevel@tonic-gate return(1); 12487c478bd9Sstevel@tonic-gate return(0); 12497c478bd9Sstevel@tonic-gate } 12507c478bd9Sstevel@tonic-gate 12517c478bd9Sstevel@tonic-gate 1252*e5190c10Smuffin int 12537c478bd9Sstevel@tonic-gate flushi() 12547c478bd9Sstevel@tonic-gate { 12557c478bd9Sstevel@tonic-gate if (nflush) 1256*e5190c10Smuffin return (0); 12577c478bd9Sstevel@tonic-gate ch = 0; 12587c478bd9Sstevel@tonic-gate copyf++; 12597c478bd9Sstevel@tonic-gate while (!nlflg) { 12607c478bd9Sstevel@tonic-gate if (donef && (frame == stk)) 12617c478bd9Sstevel@tonic-gate break; 12627c478bd9Sstevel@tonic-gate getch(); 12637c478bd9Sstevel@tonic-gate } 12647c478bd9Sstevel@tonic-gate copyf--; 1265*e5190c10Smuffin 1266*e5190c10Smuffin return (0); 12677c478bd9Sstevel@tonic-gate } 12687c478bd9Sstevel@tonic-gate 12697c478bd9Sstevel@tonic-gate 1270*e5190c10Smuffin int 12717c478bd9Sstevel@tonic-gate getach() 12727c478bd9Sstevel@tonic-gate { 1273*e5190c10Smuffin tchar i; 1274*e5190c10Smuffin int j; 12757c478bd9Sstevel@tonic-gate 12767c478bd9Sstevel@tonic-gate lgf++; 12777c478bd9Sstevel@tonic-gate j = cbits(i = getch()); 12787c478bd9Sstevel@tonic-gate #ifndef EUC 12797c478bd9Sstevel@tonic-gate if (ismot(i) || j == ' ' || j == '\n' || j & 0200) { 12807c478bd9Sstevel@tonic-gate #else 12817c478bd9Sstevel@tonic-gate #ifndef NROFF 12827c478bd9Sstevel@tonic-gate if (ismot(i) || j == ' ' || j == '\n' || j & 0200) { 12837c478bd9Sstevel@tonic-gate #else 12847c478bd9Sstevel@tonic-gate if (ismot(i) || j == ' ' || j == '\n' || j > 0200) { 12857c478bd9Sstevel@tonic-gate #endif /* NROFF */ 12867c478bd9Sstevel@tonic-gate #endif /* EUC */ 12877c478bd9Sstevel@tonic-gate 12887c478bd9Sstevel@tonic-gate ch = i; 12897c478bd9Sstevel@tonic-gate j = 0; 12907c478bd9Sstevel@tonic-gate } 12917c478bd9Sstevel@tonic-gate lgf--; 12927c478bd9Sstevel@tonic-gate return(j & 0177); 12937c478bd9Sstevel@tonic-gate } 12947c478bd9Sstevel@tonic-gate 12957c478bd9Sstevel@tonic-gate 1296*e5190c10Smuffin int 12977c478bd9Sstevel@tonic-gate casenx() 12987c478bd9Sstevel@tonic-gate { 12997c478bd9Sstevel@tonic-gate lgf++; 13007c478bd9Sstevel@tonic-gate skip(); 13017c478bd9Sstevel@tonic-gate getname(); 13027c478bd9Sstevel@tonic-gate nx++; 13037c478bd9Sstevel@tonic-gate if (nmfi > 0) 13047c478bd9Sstevel@tonic-gate nmfi--; 13057c478bd9Sstevel@tonic-gate strcpy(mfiles[nmfi], nextf); 13067c478bd9Sstevel@tonic-gate nextfile(); 13077c478bd9Sstevel@tonic-gate nlflg++; 13087c478bd9Sstevel@tonic-gate ip = 0; 13097c478bd9Sstevel@tonic-gate pendt = 0; 13107c478bd9Sstevel@tonic-gate frame = stk; 13117c478bd9Sstevel@tonic-gate nxf = frame + 1; 1312*e5190c10Smuffin 1313*e5190c10Smuffin return (0); 13147c478bd9Sstevel@tonic-gate } 13157c478bd9Sstevel@tonic-gate 13167c478bd9Sstevel@tonic-gate 1317*e5190c10Smuffin int 13187c478bd9Sstevel@tonic-gate getname() 13197c478bd9Sstevel@tonic-gate { 1320*e5190c10Smuffin int j, k; 13217c478bd9Sstevel@tonic-gate tchar i; 13227c478bd9Sstevel@tonic-gate 13237c478bd9Sstevel@tonic-gate lgf++; 13247c478bd9Sstevel@tonic-gate for (k = 0; k < (NS - 1); k++) { 13257c478bd9Sstevel@tonic-gate #ifndef EUC 13267c478bd9Sstevel@tonic-gate if (((j = cbits(i = getch())) <= ' ') || (j > 0176)) 13277c478bd9Sstevel@tonic-gate #else 13287c478bd9Sstevel@tonic-gate #ifndef NROFF 13297c478bd9Sstevel@tonic-gate if (((j = cbits(i = getch())) <= ' ') || (j > 0176)) 13307c478bd9Sstevel@tonic-gate #else 13317c478bd9Sstevel@tonic-gate if (((j = cbits(i = getch())) <= ' ') || (j == 0177)) 13327c478bd9Sstevel@tonic-gate #endif /* NROFF */ 13337c478bd9Sstevel@tonic-gate #endif /* EUC */ 13347c478bd9Sstevel@tonic-gate break; 13357c478bd9Sstevel@tonic-gate nextf[k] = j & BYTEMASK; 13367c478bd9Sstevel@tonic-gate } 13377c478bd9Sstevel@tonic-gate nextf[k] = 0; 13387c478bd9Sstevel@tonic-gate ch = i; 13397c478bd9Sstevel@tonic-gate lgf--; 1340*e5190c10Smuffin return((int)nextf[0]); 13417c478bd9Sstevel@tonic-gate } 13427c478bd9Sstevel@tonic-gate 13437c478bd9Sstevel@tonic-gate 1344*e5190c10Smuffin int 13457c478bd9Sstevel@tonic-gate caseso() 13467c478bd9Sstevel@tonic-gate { 1347*e5190c10Smuffin int i; 1348*e5190c10Smuffin char *p, *q; 13497c478bd9Sstevel@tonic-gate 13507c478bd9Sstevel@tonic-gate lgf++; 13517c478bd9Sstevel@tonic-gate nextf[0] = 0; 13527c478bd9Sstevel@tonic-gate if (skip() || !getname() || ((i = open(nextf, 0)) < 0) || (ifi >= NSO)) { 13537c478bd9Sstevel@tonic-gate errprint(gettext("can't open file %s"), nextf); 13547c478bd9Sstevel@tonic-gate done(02); 13557c478bd9Sstevel@tonic-gate } 13567c478bd9Sstevel@tonic-gate strcpy(cfname[ifi+1], nextf); 13577c478bd9Sstevel@tonic-gate cfline[ifi] = numtab[CD].val; /*hold line counter*/ 13587c478bd9Sstevel@tonic-gate numtab[CD].val = 0; 13597c478bd9Sstevel@tonic-gate flushi(); 13607c478bd9Sstevel@tonic-gate ifl[ifi] = ifile; 13617c478bd9Sstevel@tonic-gate ifile = i; 13627c478bd9Sstevel@tonic-gate offl[ifi] = ioff; 13637c478bd9Sstevel@tonic-gate ioff = 0; 13647c478bd9Sstevel@tonic-gate ipl[ifi] = ip; 13657c478bd9Sstevel@tonic-gate ip = 0; 13667c478bd9Sstevel@tonic-gate nx++; 13677c478bd9Sstevel@tonic-gate nflush++; 13687c478bd9Sstevel@tonic-gate if (!ifl[ifi++]) { 13697c478bd9Sstevel@tonic-gate p = ibuf; 13707c478bd9Sstevel@tonic-gate q = xbuf; 13717c478bd9Sstevel@tonic-gate xbufp = ibufp; 13727c478bd9Sstevel@tonic-gate xeibuf = eibuf; 13737c478bd9Sstevel@tonic-gate while (p < eibuf) 13747c478bd9Sstevel@tonic-gate *q++ = *p++; 13757c478bd9Sstevel@tonic-gate } 1376*e5190c10Smuffin 1377*e5190c10Smuffin return (0); 13787c478bd9Sstevel@tonic-gate } 13797c478bd9Sstevel@tonic-gate 1380*e5190c10Smuffin int 13817c478bd9Sstevel@tonic-gate caself() /* set line number and file */ 13827c478bd9Sstevel@tonic-gate { 13837c478bd9Sstevel@tonic-gate int n; 13847c478bd9Sstevel@tonic-gate 13857c478bd9Sstevel@tonic-gate if (skip()) 1386*e5190c10Smuffin return (0); 13877c478bd9Sstevel@tonic-gate n = atoi(); 13887c478bd9Sstevel@tonic-gate cfline[ifi] = numtab[CD].val = n - 2; 13897c478bd9Sstevel@tonic-gate if (skip()) 1390*e5190c10Smuffin return (0); 13917c478bd9Sstevel@tonic-gate if (getname()) 13927c478bd9Sstevel@tonic-gate strcpy(cfname[ifi], nextf); 1393*e5190c10Smuffin 1394*e5190c10Smuffin return (0); 13957c478bd9Sstevel@tonic-gate } 13967c478bd9Sstevel@tonic-gate 13977c478bd9Sstevel@tonic-gate 1398*e5190c10Smuffin int 13997c478bd9Sstevel@tonic-gate casecf() 14007c478bd9Sstevel@tonic-gate { /* copy file without change */ 14017c478bd9Sstevel@tonic-gate #ifndef NROFF 14027c478bd9Sstevel@tonic-gate int fd, n; 14037c478bd9Sstevel@tonic-gate char buf[512]; 14047c478bd9Sstevel@tonic-gate extern int hpos, esc, po; 14057c478bd9Sstevel@tonic-gate nextf[0] = 0; 14067c478bd9Sstevel@tonic-gate if (skip() || !getname() || (fd = open(nextf, 0)) < 0) { 14077c478bd9Sstevel@tonic-gate errprint(gettext("can't open file %s"), nextf); 14087c478bd9Sstevel@tonic-gate done(02); 14097c478bd9Sstevel@tonic-gate } 14107c478bd9Sstevel@tonic-gate tbreak(); 14117c478bd9Sstevel@tonic-gate /* make it into a clean state, be sure that everything is out */ 14127c478bd9Sstevel@tonic-gate hpos = po; 14137c478bd9Sstevel@tonic-gate esc = un; 14147c478bd9Sstevel@tonic-gate ptesc(); 14157c478bd9Sstevel@tonic-gate ptlead(); 14167c478bd9Sstevel@tonic-gate ptps(); 14177c478bd9Sstevel@tonic-gate ptfont(); 14187c478bd9Sstevel@tonic-gate flusho(); 14197c478bd9Sstevel@tonic-gate while ((n = read(fd, buf, sizeof buf)) > 0) 14207c478bd9Sstevel@tonic-gate write(ptid, buf, n); 14217c478bd9Sstevel@tonic-gate close(fd); 14227c478bd9Sstevel@tonic-gate #endif 1423*e5190c10Smuffin return (0); 14247c478bd9Sstevel@tonic-gate } 14257c478bd9Sstevel@tonic-gate 14267c478bd9Sstevel@tonic-gate 1427*e5190c10Smuffin int 14287c478bd9Sstevel@tonic-gate casesy() /* call system */ 14297c478bd9Sstevel@tonic-gate { 14307c478bd9Sstevel@tonic-gate char sybuf[NTM]; 14317c478bd9Sstevel@tonic-gate int i; 14327c478bd9Sstevel@tonic-gate 14337c478bd9Sstevel@tonic-gate lgf++; 14347c478bd9Sstevel@tonic-gate copyf++; 14357c478bd9Sstevel@tonic-gate skip(); 14367c478bd9Sstevel@tonic-gate for (i = 0; i < NTM - 2; i++) 14377c478bd9Sstevel@tonic-gate if ((sybuf[i] = getch()) == '\n') 14387c478bd9Sstevel@tonic-gate break; 14397c478bd9Sstevel@tonic-gate sybuf[i] = 0; 14407c478bd9Sstevel@tonic-gate system(sybuf); 14417c478bd9Sstevel@tonic-gate copyf--; 14427c478bd9Sstevel@tonic-gate lgf--; 1443*e5190c10Smuffin 1444*e5190c10Smuffin return (0); 14457c478bd9Sstevel@tonic-gate } 14467c478bd9Sstevel@tonic-gate 14477c478bd9Sstevel@tonic-gate 1448*e5190c10Smuffin int 14497c478bd9Sstevel@tonic-gate getpn(a) 1450*e5190c10Smuffin char *a; 14517c478bd9Sstevel@tonic-gate { 1452*e5190c10Smuffin int n, neg; 14537c478bd9Sstevel@tonic-gate 14547c478bd9Sstevel@tonic-gate if (*a == 0) 1455*e5190c10Smuffin return (0); 14567c478bd9Sstevel@tonic-gate neg = 0; 14577c478bd9Sstevel@tonic-gate for ( ; *a; a++) 14587c478bd9Sstevel@tonic-gate switch (*a) { 14597c478bd9Sstevel@tonic-gate case '+': 14607c478bd9Sstevel@tonic-gate case ',': 14617c478bd9Sstevel@tonic-gate continue; 14627c478bd9Sstevel@tonic-gate case '-': 14637c478bd9Sstevel@tonic-gate neg = 1; 14647c478bd9Sstevel@tonic-gate continue; 14657c478bd9Sstevel@tonic-gate default: 14667c478bd9Sstevel@tonic-gate n = 0; 14677c478bd9Sstevel@tonic-gate if (isdigit((unsigned char)*a)) { 14687c478bd9Sstevel@tonic-gate do 14697c478bd9Sstevel@tonic-gate n = 10 * n + *a++ - '0'; 14707c478bd9Sstevel@tonic-gate while (isdigit((unsigned char)*a)); 14717c478bd9Sstevel@tonic-gate a--; 14727c478bd9Sstevel@tonic-gate } else 14737c478bd9Sstevel@tonic-gate n = 9999; 14747c478bd9Sstevel@tonic-gate *pnp++ = neg ? -n : n; 14757c478bd9Sstevel@tonic-gate neg = 0; 14767c478bd9Sstevel@tonic-gate if (pnp >= &pnlist[NPN-2]) { 14777c478bd9Sstevel@tonic-gate errprint(gettext("too many page numbers")); 14787c478bd9Sstevel@tonic-gate done3(-3); 14797c478bd9Sstevel@tonic-gate } 14807c478bd9Sstevel@tonic-gate } 14817c478bd9Sstevel@tonic-gate if (neg) 14827c478bd9Sstevel@tonic-gate *pnp++ = -9999; 14837c478bd9Sstevel@tonic-gate *pnp = -32767; 14847c478bd9Sstevel@tonic-gate print = 0; 14857c478bd9Sstevel@tonic-gate pnp = pnlist; 14867c478bd9Sstevel@tonic-gate if (*pnp != -32767) 14877c478bd9Sstevel@tonic-gate chkpn(); 1488*e5190c10Smuffin 1489*e5190c10Smuffin return (0); 14907c478bd9Sstevel@tonic-gate } 14917c478bd9Sstevel@tonic-gate 14927c478bd9Sstevel@tonic-gate 1493*e5190c10Smuffin int 14947c478bd9Sstevel@tonic-gate setrpt() 14957c478bd9Sstevel@tonic-gate { 14967c478bd9Sstevel@tonic-gate tchar i, j; 14977c478bd9Sstevel@tonic-gate 14987c478bd9Sstevel@tonic-gate copyf++; 14997c478bd9Sstevel@tonic-gate raw++; 15007c478bd9Sstevel@tonic-gate i = getch0(); 15017c478bd9Sstevel@tonic-gate copyf--; 15027c478bd9Sstevel@tonic-gate raw--; 15037c478bd9Sstevel@tonic-gate if (i < 0 || cbits(j = getch0()) == RPT) 1504*e5190c10Smuffin return (0); 15057c478bd9Sstevel@tonic-gate i &= BYTEMASK; 15067c478bd9Sstevel@tonic-gate while (i>0 && pbp < &pbbuf[NC-3]) { 15077c478bd9Sstevel@tonic-gate i--; 15087c478bd9Sstevel@tonic-gate *pbp++ = j; 15097c478bd9Sstevel@tonic-gate } 1510*e5190c10Smuffin 1511*e5190c10Smuffin return (0); 15127c478bd9Sstevel@tonic-gate } 15137c478bd9Sstevel@tonic-gate 15147c478bd9Sstevel@tonic-gate 1515*e5190c10Smuffin int 15167c478bd9Sstevel@tonic-gate casedb() 15177c478bd9Sstevel@tonic-gate { 15187c478bd9Sstevel@tonic-gate #ifdef DEBUG 15197c478bd9Sstevel@tonic-gate debug = 0; 15207c478bd9Sstevel@tonic-gate if (skip()) 1521*e5190c10Smuffin return (0); 15227c478bd9Sstevel@tonic-gate noscale++; 15237c478bd9Sstevel@tonic-gate debug = max(atoi(), 0); 15247c478bd9Sstevel@tonic-gate noscale = 0; 1525*e5190c10Smuffin #endif /* DEBUG */ 1526*e5190c10Smuffin 1527*e5190c10Smuffin return (0); 15287c478bd9Sstevel@tonic-gate } 1529