1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 32*7c478bd9Sstevel@tonic-gate 33*7c478bd9Sstevel@tonic-gate /* 34*7c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 35*7c478bd9Sstevel@tonic-gate * The Regents of the University of California 36*7c478bd9Sstevel@tonic-gate * All Rights Reserved 37*7c478bd9Sstevel@tonic-gate * 38*7c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 39*7c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 40*7c478bd9Sstevel@tonic-gate * contributors. 41*7c478bd9Sstevel@tonic-gate */ 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate #ifdef EUC 44*7c478bd9Sstevel@tonic-gate #ifdef NROFF 45*7c478bd9Sstevel@tonic-gate #include <stddef.h> 46*7c478bd9Sstevel@tonic-gate #include <stdlib.h> 47*7c478bd9Sstevel@tonic-gate #include <widec.h> 48*7c478bd9Sstevel@tonic-gate #endif /* NROFF */ 49*7c478bd9Sstevel@tonic-gate #endif /* EUC */ 50*7c478bd9Sstevel@tonic-gate #include <string.h> 51*7c478bd9Sstevel@tonic-gate #include "tdef.h" 52*7c478bd9Sstevel@tonic-gate #include "ext.h" 53*7c478bd9Sstevel@tonic-gate 54*7c478bd9Sstevel@tonic-gate /* 55*7c478bd9Sstevel@tonic-gate * troff5.c 56*7c478bd9Sstevel@tonic-gate * 57*7c478bd9Sstevel@tonic-gate * misc processing requests 58*7c478bd9Sstevel@tonic-gate */ 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate int iflist[NIF]; 61*7c478bd9Sstevel@tonic-gate int ifx; 62*7c478bd9Sstevel@tonic-gate 63*7c478bd9Sstevel@tonic-gate casead() 64*7c478bd9Sstevel@tonic-gate { 65*7c478bd9Sstevel@tonic-gate register i; 66*7c478bd9Sstevel@tonic-gate 67*7c478bd9Sstevel@tonic-gate ad = 1; 68*7c478bd9Sstevel@tonic-gate /*leave admod alone*/ 69*7c478bd9Sstevel@tonic-gate if (skip()) 70*7c478bd9Sstevel@tonic-gate return; 71*7c478bd9Sstevel@tonic-gate switch (i = cbits(getch())) { 72*7c478bd9Sstevel@tonic-gate case 'r': /*right adj, left ragged*/ 73*7c478bd9Sstevel@tonic-gate admod = 2; 74*7c478bd9Sstevel@tonic-gate break; 75*7c478bd9Sstevel@tonic-gate case 'l': /*left adj, right ragged*/ 76*7c478bd9Sstevel@tonic-gate admod = ad = 0; /*same as casena*/ 77*7c478bd9Sstevel@tonic-gate break; 78*7c478bd9Sstevel@tonic-gate case 'c': /*centered adj*/ 79*7c478bd9Sstevel@tonic-gate admod = 1; 80*7c478bd9Sstevel@tonic-gate break; 81*7c478bd9Sstevel@tonic-gate case 'b': 82*7c478bd9Sstevel@tonic-gate case 'n': 83*7c478bd9Sstevel@tonic-gate admod = 0; 84*7c478bd9Sstevel@tonic-gate break; 85*7c478bd9Sstevel@tonic-gate case '0': 86*7c478bd9Sstevel@tonic-gate case '2': 87*7c478bd9Sstevel@tonic-gate case '4': 88*7c478bd9Sstevel@tonic-gate ad = 0; 89*7c478bd9Sstevel@tonic-gate case '1': 90*7c478bd9Sstevel@tonic-gate case '3': 91*7c478bd9Sstevel@tonic-gate case '5': 92*7c478bd9Sstevel@tonic-gate admod = (i - '0') / 2; 93*7c478bd9Sstevel@tonic-gate } 94*7c478bd9Sstevel@tonic-gate } 95*7c478bd9Sstevel@tonic-gate 96*7c478bd9Sstevel@tonic-gate 97*7c478bd9Sstevel@tonic-gate casena() 98*7c478bd9Sstevel@tonic-gate { 99*7c478bd9Sstevel@tonic-gate ad = 0; 100*7c478bd9Sstevel@tonic-gate } 101*7c478bd9Sstevel@tonic-gate 102*7c478bd9Sstevel@tonic-gate 103*7c478bd9Sstevel@tonic-gate casefi() 104*7c478bd9Sstevel@tonic-gate { 105*7c478bd9Sstevel@tonic-gate tbreak(); 106*7c478bd9Sstevel@tonic-gate fi++; 107*7c478bd9Sstevel@tonic-gate pendnf = 0; 108*7c478bd9Sstevel@tonic-gate lnsize = LNSIZE; 109*7c478bd9Sstevel@tonic-gate } 110*7c478bd9Sstevel@tonic-gate 111*7c478bd9Sstevel@tonic-gate 112*7c478bd9Sstevel@tonic-gate casenf() 113*7c478bd9Sstevel@tonic-gate { 114*7c478bd9Sstevel@tonic-gate tbreak(); 115*7c478bd9Sstevel@tonic-gate fi = 0; 116*7c478bd9Sstevel@tonic-gate } 117*7c478bd9Sstevel@tonic-gate 118*7c478bd9Sstevel@tonic-gate 119*7c478bd9Sstevel@tonic-gate casers() 120*7c478bd9Sstevel@tonic-gate { 121*7c478bd9Sstevel@tonic-gate dip->nls = 0; 122*7c478bd9Sstevel@tonic-gate } 123*7c478bd9Sstevel@tonic-gate 124*7c478bd9Sstevel@tonic-gate 125*7c478bd9Sstevel@tonic-gate casens() 126*7c478bd9Sstevel@tonic-gate { 127*7c478bd9Sstevel@tonic-gate dip->nls++; 128*7c478bd9Sstevel@tonic-gate } 129*7c478bd9Sstevel@tonic-gate 130*7c478bd9Sstevel@tonic-gate 131*7c478bd9Sstevel@tonic-gate chget(c) 132*7c478bd9Sstevel@tonic-gate int c; 133*7c478bd9Sstevel@tonic-gate { 134*7c478bd9Sstevel@tonic-gate tchar i; 135*7c478bd9Sstevel@tonic-gate 136*7c478bd9Sstevel@tonic-gate if (skip() || ismot(i = getch()) || cbits(i) == ' ' || cbits(i) == '\n') { 137*7c478bd9Sstevel@tonic-gate ch = i; 138*7c478bd9Sstevel@tonic-gate return(c); 139*7c478bd9Sstevel@tonic-gate } else 140*7c478bd9Sstevel@tonic-gate return(i & BYTEMASK); 141*7c478bd9Sstevel@tonic-gate } 142*7c478bd9Sstevel@tonic-gate 143*7c478bd9Sstevel@tonic-gate 144*7c478bd9Sstevel@tonic-gate casecc() 145*7c478bd9Sstevel@tonic-gate { 146*7c478bd9Sstevel@tonic-gate cc = chget('.'); 147*7c478bd9Sstevel@tonic-gate } 148*7c478bd9Sstevel@tonic-gate 149*7c478bd9Sstevel@tonic-gate 150*7c478bd9Sstevel@tonic-gate casec2() 151*7c478bd9Sstevel@tonic-gate { 152*7c478bd9Sstevel@tonic-gate c2 = chget('\''); 153*7c478bd9Sstevel@tonic-gate } 154*7c478bd9Sstevel@tonic-gate 155*7c478bd9Sstevel@tonic-gate 156*7c478bd9Sstevel@tonic-gate casehc() 157*7c478bd9Sstevel@tonic-gate { 158*7c478bd9Sstevel@tonic-gate ohc = chget(OHC); 159*7c478bd9Sstevel@tonic-gate } 160*7c478bd9Sstevel@tonic-gate 161*7c478bd9Sstevel@tonic-gate 162*7c478bd9Sstevel@tonic-gate casetc() 163*7c478bd9Sstevel@tonic-gate { 164*7c478bd9Sstevel@tonic-gate tabc = chget(0); 165*7c478bd9Sstevel@tonic-gate } 166*7c478bd9Sstevel@tonic-gate 167*7c478bd9Sstevel@tonic-gate 168*7c478bd9Sstevel@tonic-gate caselc() 169*7c478bd9Sstevel@tonic-gate { 170*7c478bd9Sstevel@tonic-gate dotc = chget(0); 171*7c478bd9Sstevel@tonic-gate } 172*7c478bd9Sstevel@tonic-gate 173*7c478bd9Sstevel@tonic-gate 174*7c478bd9Sstevel@tonic-gate casehy() 175*7c478bd9Sstevel@tonic-gate { 176*7c478bd9Sstevel@tonic-gate register i; 177*7c478bd9Sstevel@tonic-gate 178*7c478bd9Sstevel@tonic-gate hyf = 1; 179*7c478bd9Sstevel@tonic-gate if (skip()) 180*7c478bd9Sstevel@tonic-gate return; 181*7c478bd9Sstevel@tonic-gate noscale++; 182*7c478bd9Sstevel@tonic-gate i = atoi(); 183*7c478bd9Sstevel@tonic-gate noscale = 0; 184*7c478bd9Sstevel@tonic-gate if (nonumb) 185*7c478bd9Sstevel@tonic-gate return; 186*7c478bd9Sstevel@tonic-gate hyf = max(i, 0); 187*7c478bd9Sstevel@tonic-gate } 188*7c478bd9Sstevel@tonic-gate 189*7c478bd9Sstevel@tonic-gate 190*7c478bd9Sstevel@tonic-gate casenh() 191*7c478bd9Sstevel@tonic-gate { 192*7c478bd9Sstevel@tonic-gate hyf = 0; 193*7c478bd9Sstevel@tonic-gate } 194*7c478bd9Sstevel@tonic-gate 195*7c478bd9Sstevel@tonic-gate 196*7c478bd9Sstevel@tonic-gate max(aa, bb) 197*7c478bd9Sstevel@tonic-gate int aa, bb; 198*7c478bd9Sstevel@tonic-gate { 199*7c478bd9Sstevel@tonic-gate if (aa > bb) 200*7c478bd9Sstevel@tonic-gate return(aa); 201*7c478bd9Sstevel@tonic-gate else 202*7c478bd9Sstevel@tonic-gate return(bb); 203*7c478bd9Sstevel@tonic-gate } 204*7c478bd9Sstevel@tonic-gate 205*7c478bd9Sstevel@tonic-gate 206*7c478bd9Sstevel@tonic-gate casece() 207*7c478bd9Sstevel@tonic-gate { 208*7c478bd9Sstevel@tonic-gate register i; 209*7c478bd9Sstevel@tonic-gate 210*7c478bd9Sstevel@tonic-gate noscale++; 211*7c478bd9Sstevel@tonic-gate skip(); 212*7c478bd9Sstevel@tonic-gate i = max(atoi(), 0); 213*7c478bd9Sstevel@tonic-gate if (nonumb) 214*7c478bd9Sstevel@tonic-gate i = 1; 215*7c478bd9Sstevel@tonic-gate tbreak(); 216*7c478bd9Sstevel@tonic-gate ce = i; 217*7c478bd9Sstevel@tonic-gate noscale = 0; 218*7c478bd9Sstevel@tonic-gate } 219*7c478bd9Sstevel@tonic-gate 220*7c478bd9Sstevel@tonic-gate 221*7c478bd9Sstevel@tonic-gate casein() 222*7c478bd9Sstevel@tonic-gate { 223*7c478bd9Sstevel@tonic-gate register i; 224*7c478bd9Sstevel@tonic-gate 225*7c478bd9Sstevel@tonic-gate if (skip()) 226*7c478bd9Sstevel@tonic-gate i = in1; 227*7c478bd9Sstevel@tonic-gate else 228*7c478bd9Sstevel@tonic-gate i = max(hnumb(&in), 0); 229*7c478bd9Sstevel@tonic-gate tbreak(); 230*7c478bd9Sstevel@tonic-gate in1 = in; 231*7c478bd9Sstevel@tonic-gate in = i; 232*7c478bd9Sstevel@tonic-gate if (!nc) { 233*7c478bd9Sstevel@tonic-gate un = in; 234*7c478bd9Sstevel@tonic-gate setnel(); 235*7c478bd9Sstevel@tonic-gate } 236*7c478bd9Sstevel@tonic-gate } 237*7c478bd9Sstevel@tonic-gate 238*7c478bd9Sstevel@tonic-gate 239*7c478bd9Sstevel@tonic-gate casell() 240*7c478bd9Sstevel@tonic-gate { 241*7c478bd9Sstevel@tonic-gate register i; 242*7c478bd9Sstevel@tonic-gate 243*7c478bd9Sstevel@tonic-gate if (skip()) 244*7c478bd9Sstevel@tonic-gate i = ll1; 245*7c478bd9Sstevel@tonic-gate else 246*7c478bd9Sstevel@tonic-gate i = max(hnumb(&ll), INCH / 10); 247*7c478bd9Sstevel@tonic-gate ll1 = ll; 248*7c478bd9Sstevel@tonic-gate ll = i; 249*7c478bd9Sstevel@tonic-gate setnel(); 250*7c478bd9Sstevel@tonic-gate } 251*7c478bd9Sstevel@tonic-gate 252*7c478bd9Sstevel@tonic-gate 253*7c478bd9Sstevel@tonic-gate caselt() 254*7c478bd9Sstevel@tonic-gate { 255*7c478bd9Sstevel@tonic-gate register i; 256*7c478bd9Sstevel@tonic-gate 257*7c478bd9Sstevel@tonic-gate if (skip()) 258*7c478bd9Sstevel@tonic-gate i = lt1; 259*7c478bd9Sstevel@tonic-gate else 260*7c478bd9Sstevel@tonic-gate i = max(hnumb(<), 0); 261*7c478bd9Sstevel@tonic-gate lt1 = lt; 262*7c478bd9Sstevel@tonic-gate lt = i; 263*7c478bd9Sstevel@tonic-gate } 264*7c478bd9Sstevel@tonic-gate 265*7c478bd9Sstevel@tonic-gate 266*7c478bd9Sstevel@tonic-gate caseti() 267*7c478bd9Sstevel@tonic-gate { 268*7c478bd9Sstevel@tonic-gate register i; 269*7c478bd9Sstevel@tonic-gate 270*7c478bd9Sstevel@tonic-gate if (skip()) 271*7c478bd9Sstevel@tonic-gate return; 272*7c478bd9Sstevel@tonic-gate i = max(hnumb(&in), 0); 273*7c478bd9Sstevel@tonic-gate tbreak(); 274*7c478bd9Sstevel@tonic-gate un1 = i; 275*7c478bd9Sstevel@tonic-gate setnel(); 276*7c478bd9Sstevel@tonic-gate } 277*7c478bd9Sstevel@tonic-gate 278*7c478bd9Sstevel@tonic-gate 279*7c478bd9Sstevel@tonic-gate casels() 280*7c478bd9Sstevel@tonic-gate { 281*7c478bd9Sstevel@tonic-gate register i; 282*7c478bd9Sstevel@tonic-gate 283*7c478bd9Sstevel@tonic-gate noscale++; 284*7c478bd9Sstevel@tonic-gate if (skip()) 285*7c478bd9Sstevel@tonic-gate i = ls1; 286*7c478bd9Sstevel@tonic-gate else 287*7c478bd9Sstevel@tonic-gate i = max(inumb(&ls), 1); 288*7c478bd9Sstevel@tonic-gate ls1 = ls; 289*7c478bd9Sstevel@tonic-gate ls = i; 290*7c478bd9Sstevel@tonic-gate noscale = 0; 291*7c478bd9Sstevel@tonic-gate } 292*7c478bd9Sstevel@tonic-gate 293*7c478bd9Sstevel@tonic-gate 294*7c478bd9Sstevel@tonic-gate casepo() 295*7c478bd9Sstevel@tonic-gate { 296*7c478bd9Sstevel@tonic-gate register i; 297*7c478bd9Sstevel@tonic-gate 298*7c478bd9Sstevel@tonic-gate if (skip()) 299*7c478bd9Sstevel@tonic-gate i = po1; 300*7c478bd9Sstevel@tonic-gate else 301*7c478bd9Sstevel@tonic-gate i = max(hnumb(&po), 0); 302*7c478bd9Sstevel@tonic-gate po1 = po; 303*7c478bd9Sstevel@tonic-gate po = i; 304*7c478bd9Sstevel@tonic-gate #ifndef NROFF 305*7c478bd9Sstevel@tonic-gate if (!ascii) 306*7c478bd9Sstevel@tonic-gate esc += po - po1; 307*7c478bd9Sstevel@tonic-gate #endif 308*7c478bd9Sstevel@tonic-gate } 309*7c478bd9Sstevel@tonic-gate 310*7c478bd9Sstevel@tonic-gate 311*7c478bd9Sstevel@tonic-gate casepl() 312*7c478bd9Sstevel@tonic-gate { 313*7c478bd9Sstevel@tonic-gate register i; 314*7c478bd9Sstevel@tonic-gate 315*7c478bd9Sstevel@tonic-gate skip(); 316*7c478bd9Sstevel@tonic-gate if ((i = vnumb(&pl)) == 0) 317*7c478bd9Sstevel@tonic-gate pl = 11 * INCH; /*11in*/ 318*7c478bd9Sstevel@tonic-gate else 319*7c478bd9Sstevel@tonic-gate pl = i; 320*7c478bd9Sstevel@tonic-gate if (numtab[NL].val > pl) 321*7c478bd9Sstevel@tonic-gate numtab[NL].val = pl; 322*7c478bd9Sstevel@tonic-gate } 323*7c478bd9Sstevel@tonic-gate 324*7c478bd9Sstevel@tonic-gate 325*7c478bd9Sstevel@tonic-gate casewh() 326*7c478bd9Sstevel@tonic-gate { 327*7c478bd9Sstevel@tonic-gate register i, j, k; 328*7c478bd9Sstevel@tonic-gate 329*7c478bd9Sstevel@tonic-gate lgf++; 330*7c478bd9Sstevel@tonic-gate skip(); 331*7c478bd9Sstevel@tonic-gate i = vnumb((int *)0); 332*7c478bd9Sstevel@tonic-gate if (nonumb) 333*7c478bd9Sstevel@tonic-gate return; 334*7c478bd9Sstevel@tonic-gate skip(); 335*7c478bd9Sstevel@tonic-gate j = getrq(); 336*7c478bd9Sstevel@tonic-gate if ((k = findn(i)) != NTRAP) { 337*7c478bd9Sstevel@tonic-gate mlist[k] = j; 338*7c478bd9Sstevel@tonic-gate return; 339*7c478bd9Sstevel@tonic-gate } 340*7c478bd9Sstevel@tonic-gate for (k = 0; k < NTRAP; k++) 341*7c478bd9Sstevel@tonic-gate if (mlist[k] == 0) 342*7c478bd9Sstevel@tonic-gate break; 343*7c478bd9Sstevel@tonic-gate if (k == NTRAP) { 344*7c478bd9Sstevel@tonic-gate flusho(); 345*7c478bd9Sstevel@tonic-gate errprint(gettext("cannot plant trap.")); 346*7c478bd9Sstevel@tonic-gate return; 347*7c478bd9Sstevel@tonic-gate } 348*7c478bd9Sstevel@tonic-gate mlist[k] = j; 349*7c478bd9Sstevel@tonic-gate nlist[k] = i; 350*7c478bd9Sstevel@tonic-gate } 351*7c478bd9Sstevel@tonic-gate 352*7c478bd9Sstevel@tonic-gate 353*7c478bd9Sstevel@tonic-gate casech() 354*7c478bd9Sstevel@tonic-gate { 355*7c478bd9Sstevel@tonic-gate register i, j, k; 356*7c478bd9Sstevel@tonic-gate 357*7c478bd9Sstevel@tonic-gate lgf++; 358*7c478bd9Sstevel@tonic-gate skip(); 359*7c478bd9Sstevel@tonic-gate if (!(j = getrq())) 360*7c478bd9Sstevel@tonic-gate return; 361*7c478bd9Sstevel@tonic-gate else 362*7c478bd9Sstevel@tonic-gate for (k = 0; k < NTRAP; k++) 363*7c478bd9Sstevel@tonic-gate if (mlist[k] == j) 364*7c478bd9Sstevel@tonic-gate break; 365*7c478bd9Sstevel@tonic-gate if (k == NTRAP) 366*7c478bd9Sstevel@tonic-gate return; 367*7c478bd9Sstevel@tonic-gate skip(); 368*7c478bd9Sstevel@tonic-gate i = vnumb((int *)0); 369*7c478bd9Sstevel@tonic-gate if (nonumb) 370*7c478bd9Sstevel@tonic-gate mlist[k] = 0; 371*7c478bd9Sstevel@tonic-gate nlist[k] = i; 372*7c478bd9Sstevel@tonic-gate } 373*7c478bd9Sstevel@tonic-gate 374*7c478bd9Sstevel@tonic-gate 375*7c478bd9Sstevel@tonic-gate findn(i) 376*7c478bd9Sstevel@tonic-gate int i; 377*7c478bd9Sstevel@tonic-gate { 378*7c478bd9Sstevel@tonic-gate register k; 379*7c478bd9Sstevel@tonic-gate 380*7c478bd9Sstevel@tonic-gate for (k = 0; k < NTRAP; k++) 381*7c478bd9Sstevel@tonic-gate if ((nlist[k] == i) && (mlist[k] != 0)) 382*7c478bd9Sstevel@tonic-gate break; 383*7c478bd9Sstevel@tonic-gate return(k); 384*7c478bd9Sstevel@tonic-gate } 385*7c478bd9Sstevel@tonic-gate 386*7c478bd9Sstevel@tonic-gate 387*7c478bd9Sstevel@tonic-gate casepn() 388*7c478bd9Sstevel@tonic-gate { 389*7c478bd9Sstevel@tonic-gate register i; 390*7c478bd9Sstevel@tonic-gate 391*7c478bd9Sstevel@tonic-gate skip(); 392*7c478bd9Sstevel@tonic-gate noscale++; 393*7c478bd9Sstevel@tonic-gate i = max(inumb(&numtab[PN].val), 0); 394*7c478bd9Sstevel@tonic-gate noscale = 0; 395*7c478bd9Sstevel@tonic-gate if (!nonumb) { 396*7c478bd9Sstevel@tonic-gate npn = i; 397*7c478bd9Sstevel@tonic-gate npnflg++; 398*7c478bd9Sstevel@tonic-gate } 399*7c478bd9Sstevel@tonic-gate } 400*7c478bd9Sstevel@tonic-gate 401*7c478bd9Sstevel@tonic-gate 402*7c478bd9Sstevel@tonic-gate casebp() 403*7c478bd9Sstevel@tonic-gate { 404*7c478bd9Sstevel@tonic-gate register i; 405*7c478bd9Sstevel@tonic-gate register struct s *savframe; 406*7c478bd9Sstevel@tonic-gate 407*7c478bd9Sstevel@tonic-gate if (dip != d) 408*7c478bd9Sstevel@tonic-gate return; 409*7c478bd9Sstevel@tonic-gate savframe = frame; 410*7c478bd9Sstevel@tonic-gate skip(); 411*7c478bd9Sstevel@tonic-gate if ((i = inumb(&numtab[PN].val)) < 0) 412*7c478bd9Sstevel@tonic-gate i = 0; 413*7c478bd9Sstevel@tonic-gate tbreak(); 414*7c478bd9Sstevel@tonic-gate if (!nonumb) { 415*7c478bd9Sstevel@tonic-gate npn = i; 416*7c478bd9Sstevel@tonic-gate npnflg++; 417*7c478bd9Sstevel@tonic-gate } else if (dip->nls) 418*7c478bd9Sstevel@tonic-gate return; 419*7c478bd9Sstevel@tonic-gate eject(savframe); 420*7c478bd9Sstevel@tonic-gate } 421*7c478bd9Sstevel@tonic-gate 422*7c478bd9Sstevel@tonic-gate 423*7c478bd9Sstevel@tonic-gate casetm(ab) 424*7c478bd9Sstevel@tonic-gate int ab; 425*7c478bd9Sstevel@tonic-gate { 426*7c478bd9Sstevel@tonic-gate register i; 427*7c478bd9Sstevel@tonic-gate char tmbuf[NTM]; 428*7c478bd9Sstevel@tonic-gate 429*7c478bd9Sstevel@tonic-gate lgf++; 430*7c478bd9Sstevel@tonic-gate copyf++; 431*7c478bd9Sstevel@tonic-gate if (skip() && ab) 432*7c478bd9Sstevel@tonic-gate errprint(gettext("User Abort")); 433*7c478bd9Sstevel@tonic-gate for (i = 0; i < NTM - 2; ) 434*7c478bd9Sstevel@tonic-gate if ((tmbuf[i++] = getch()) == '\n') 435*7c478bd9Sstevel@tonic-gate break; 436*7c478bd9Sstevel@tonic-gate if (i == NTM - 2) 437*7c478bd9Sstevel@tonic-gate tmbuf[i++] = '\n'; 438*7c478bd9Sstevel@tonic-gate tmbuf[i] = 0; 439*7c478bd9Sstevel@tonic-gate if (ab) /* truncate output */ 440*7c478bd9Sstevel@tonic-gate obufp = obuf; /* should be a function in n2.c */ 441*7c478bd9Sstevel@tonic-gate flusho(); 442*7c478bd9Sstevel@tonic-gate fdprintf(stderr, "%s", tmbuf); 443*7c478bd9Sstevel@tonic-gate copyf--; 444*7c478bd9Sstevel@tonic-gate lgf--; 445*7c478bd9Sstevel@tonic-gate } 446*7c478bd9Sstevel@tonic-gate 447*7c478bd9Sstevel@tonic-gate 448*7c478bd9Sstevel@tonic-gate casesp(a) 449*7c478bd9Sstevel@tonic-gate int a; 450*7c478bd9Sstevel@tonic-gate { 451*7c478bd9Sstevel@tonic-gate register i, j, savlss; 452*7c478bd9Sstevel@tonic-gate 453*7c478bd9Sstevel@tonic-gate tbreak(); 454*7c478bd9Sstevel@tonic-gate if (dip->nls || trap) 455*7c478bd9Sstevel@tonic-gate return; 456*7c478bd9Sstevel@tonic-gate i = findt1(); 457*7c478bd9Sstevel@tonic-gate if (!a) { 458*7c478bd9Sstevel@tonic-gate skip(); 459*7c478bd9Sstevel@tonic-gate j = vnumb((int *)0); 460*7c478bd9Sstevel@tonic-gate if (nonumb) 461*7c478bd9Sstevel@tonic-gate j = lss; 462*7c478bd9Sstevel@tonic-gate } else 463*7c478bd9Sstevel@tonic-gate j = a; 464*7c478bd9Sstevel@tonic-gate if (j == 0) 465*7c478bd9Sstevel@tonic-gate return; 466*7c478bd9Sstevel@tonic-gate if (i < j) 467*7c478bd9Sstevel@tonic-gate j = i; 468*7c478bd9Sstevel@tonic-gate savlss = lss; 469*7c478bd9Sstevel@tonic-gate if (dip != d) 470*7c478bd9Sstevel@tonic-gate i = dip->dnl; 471*7c478bd9Sstevel@tonic-gate else 472*7c478bd9Sstevel@tonic-gate i = numtab[NL].val; 473*7c478bd9Sstevel@tonic-gate if ((i + j) < 0) 474*7c478bd9Sstevel@tonic-gate j = -i; 475*7c478bd9Sstevel@tonic-gate lss = j; 476*7c478bd9Sstevel@tonic-gate newline(0); 477*7c478bd9Sstevel@tonic-gate lss = savlss; 478*7c478bd9Sstevel@tonic-gate } 479*7c478bd9Sstevel@tonic-gate 480*7c478bd9Sstevel@tonic-gate 481*7c478bd9Sstevel@tonic-gate casert() 482*7c478bd9Sstevel@tonic-gate { 483*7c478bd9Sstevel@tonic-gate register a, *p; 484*7c478bd9Sstevel@tonic-gate 485*7c478bd9Sstevel@tonic-gate skip(); 486*7c478bd9Sstevel@tonic-gate if (dip != d) 487*7c478bd9Sstevel@tonic-gate p = &dip->dnl; 488*7c478bd9Sstevel@tonic-gate else 489*7c478bd9Sstevel@tonic-gate p = &numtab[NL].val; 490*7c478bd9Sstevel@tonic-gate a = vnumb(p); 491*7c478bd9Sstevel@tonic-gate if (nonumb) 492*7c478bd9Sstevel@tonic-gate a = dip->mkline; 493*7c478bd9Sstevel@tonic-gate if ((a < 0) || (a >= *p)) 494*7c478bd9Sstevel@tonic-gate return; 495*7c478bd9Sstevel@tonic-gate nb++; 496*7c478bd9Sstevel@tonic-gate casesp(a - *p); 497*7c478bd9Sstevel@tonic-gate } 498*7c478bd9Sstevel@tonic-gate 499*7c478bd9Sstevel@tonic-gate 500*7c478bd9Sstevel@tonic-gate caseem() 501*7c478bd9Sstevel@tonic-gate { 502*7c478bd9Sstevel@tonic-gate lgf++; 503*7c478bd9Sstevel@tonic-gate skip(); 504*7c478bd9Sstevel@tonic-gate em = getrq(); 505*7c478bd9Sstevel@tonic-gate } 506*7c478bd9Sstevel@tonic-gate 507*7c478bd9Sstevel@tonic-gate 508*7c478bd9Sstevel@tonic-gate casefl() 509*7c478bd9Sstevel@tonic-gate { 510*7c478bd9Sstevel@tonic-gate tbreak(); 511*7c478bd9Sstevel@tonic-gate flusho(); 512*7c478bd9Sstevel@tonic-gate } 513*7c478bd9Sstevel@tonic-gate 514*7c478bd9Sstevel@tonic-gate 515*7c478bd9Sstevel@tonic-gate caseev() 516*7c478bd9Sstevel@tonic-gate { 517*7c478bd9Sstevel@tonic-gate register nxev; 518*7c478bd9Sstevel@tonic-gate 519*7c478bd9Sstevel@tonic-gate if (skip()) { 520*7c478bd9Sstevel@tonic-gate e0: 521*7c478bd9Sstevel@tonic-gate if (evi == 0) 522*7c478bd9Sstevel@tonic-gate return; 523*7c478bd9Sstevel@tonic-gate nxev = evlist[--evi]; 524*7c478bd9Sstevel@tonic-gate goto e1; 525*7c478bd9Sstevel@tonic-gate } 526*7c478bd9Sstevel@tonic-gate noscale++; 527*7c478bd9Sstevel@tonic-gate nxev = atoi(); 528*7c478bd9Sstevel@tonic-gate noscale = 0; 529*7c478bd9Sstevel@tonic-gate if (nonumb) 530*7c478bd9Sstevel@tonic-gate goto e0; 531*7c478bd9Sstevel@tonic-gate flushi(); 532*7c478bd9Sstevel@tonic-gate if ((nxev >= NEV) || (nxev < 0) || (evi >= EVLSZ)) { 533*7c478bd9Sstevel@tonic-gate flusho(); 534*7c478bd9Sstevel@tonic-gate errprint(gettext("cannot do ev.")); 535*7c478bd9Sstevel@tonic-gate if (error) 536*7c478bd9Sstevel@tonic-gate done2(040); 537*7c478bd9Sstevel@tonic-gate else 538*7c478bd9Sstevel@tonic-gate edone(040); 539*7c478bd9Sstevel@tonic-gate return; 540*7c478bd9Sstevel@tonic-gate } 541*7c478bd9Sstevel@tonic-gate evlist[evi++] = ev; 542*7c478bd9Sstevel@tonic-gate e1: 543*7c478bd9Sstevel@tonic-gate if (ev == nxev) 544*7c478bd9Sstevel@tonic-gate return; 545*7c478bd9Sstevel@tonic-gate #ifdef INCORE 546*7c478bd9Sstevel@tonic-gate { 547*7c478bd9Sstevel@tonic-gate extern tchar corebuf[]; 548*7c478bd9Sstevel@tonic-gate *(struct env *)&corebuf[ev * sizeof(env)/sizeof(tchar)] = env; 549*7c478bd9Sstevel@tonic-gate env = *(struct env *)&corebuf[nxev * sizeof(env)/sizeof(tchar)]; 550*7c478bd9Sstevel@tonic-gate } 551*7c478bd9Sstevel@tonic-gate #else 552*7c478bd9Sstevel@tonic-gate lseek(ibf, ev * (long)sizeof(env), 0); 553*7c478bd9Sstevel@tonic-gate write(ibf, (char *) & env, sizeof(env)); 554*7c478bd9Sstevel@tonic-gate lseek(ibf, nxev * (long)sizeof(env), 0); 555*7c478bd9Sstevel@tonic-gate read(ibf, (char *) & env, sizeof(env)); 556*7c478bd9Sstevel@tonic-gate #endif 557*7c478bd9Sstevel@tonic-gate ev = nxev; 558*7c478bd9Sstevel@tonic-gate } 559*7c478bd9Sstevel@tonic-gate 560*7c478bd9Sstevel@tonic-gate caseel() 561*7c478bd9Sstevel@tonic-gate { 562*7c478bd9Sstevel@tonic-gate if (--ifx < 0) { 563*7c478bd9Sstevel@tonic-gate ifx = 0; 564*7c478bd9Sstevel@tonic-gate iflist[0] = 0; 565*7c478bd9Sstevel@tonic-gate } 566*7c478bd9Sstevel@tonic-gate caseif(2); 567*7c478bd9Sstevel@tonic-gate } 568*7c478bd9Sstevel@tonic-gate 569*7c478bd9Sstevel@tonic-gate 570*7c478bd9Sstevel@tonic-gate caseie() 571*7c478bd9Sstevel@tonic-gate { 572*7c478bd9Sstevel@tonic-gate if (ifx >= NIF) { 573*7c478bd9Sstevel@tonic-gate errprint(gettext("if-else overflow.")); 574*7c478bd9Sstevel@tonic-gate ifx = 0; 575*7c478bd9Sstevel@tonic-gate edone(040); 576*7c478bd9Sstevel@tonic-gate } 577*7c478bd9Sstevel@tonic-gate caseif(1); 578*7c478bd9Sstevel@tonic-gate ifx++; 579*7c478bd9Sstevel@tonic-gate } 580*7c478bd9Sstevel@tonic-gate 581*7c478bd9Sstevel@tonic-gate 582*7c478bd9Sstevel@tonic-gate caseif(x) 583*7c478bd9Sstevel@tonic-gate int x; 584*7c478bd9Sstevel@tonic-gate { 585*7c478bd9Sstevel@tonic-gate extern int falsef; 586*7c478bd9Sstevel@tonic-gate register notflag, true; 587*7c478bd9Sstevel@tonic-gate tchar i; 588*7c478bd9Sstevel@tonic-gate 589*7c478bd9Sstevel@tonic-gate if (x == 2) { 590*7c478bd9Sstevel@tonic-gate notflag = 0; 591*7c478bd9Sstevel@tonic-gate true = iflist[ifx]; 592*7c478bd9Sstevel@tonic-gate goto i1; 593*7c478bd9Sstevel@tonic-gate } 594*7c478bd9Sstevel@tonic-gate true = 0; 595*7c478bd9Sstevel@tonic-gate skip(); 596*7c478bd9Sstevel@tonic-gate if ((cbits(i = getch())) == '!') { 597*7c478bd9Sstevel@tonic-gate notflag = 1; 598*7c478bd9Sstevel@tonic-gate } else { 599*7c478bd9Sstevel@tonic-gate notflag = 0; 600*7c478bd9Sstevel@tonic-gate ch = i; 601*7c478bd9Sstevel@tonic-gate } 602*7c478bd9Sstevel@tonic-gate i = atoi(); 603*7c478bd9Sstevel@tonic-gate if (!nonumb) { 604*7c478bd9Sstevel@tonic-gate if (i > 0) 605*7c478bd9Sstevel@tonic-gate true++; 606*7c478bd9Sstevel@tonic-gate goto i1; 607*7c478bd9Sstevel@tonic-gate } 608*7c478bd9Sstevel@tonic-gate i = getch(); 609*7c478bd9Sstevel@tonic-gate switch (cbits(i)) { 610*7c478bd9Sstevel@tonic-gate case 'e': 611*7c478bd9Sstevel@tonic-gate if (!(numtab[PN].val & 01)) 612*7c478bd9Sstevel@tonic-gate true++; 613*7c478bd9Sstevel@tonic-gate break; 614*7c478bd9Sstevel@tonic-gate case 'o': 615*7c478bd9Sstevel@tonic-gate if (numtab[PN].val & 01) 616*7c478bd9Sstevel@tonic-gate true++; 617*7c478bd9Sstevel@tonic-gate break; 618*7c478bd9Sstevel@tonic-gate #ifdef NROFF 619*7c478bd9Sstevel@tonic-gate case 'n': 620*7c478bd9Sstevel@tonic-gate true++; 621*7c478bd9Sstevel@tonic-gate case 't': 622*7c478bd9Sstevel@tonic-gate #endif 623*7c478bd9Sstevel@tonic-gate #ifndef NROFF 624*7c478bd9Sstevel@tonic-gate case 't': 625*7c478bd9Sstevel@tonic-gate true++; 626*7c478bd9Sstevel@tonic-gate case 'n': 627*7c478bd9Sstevel@tonic-gate #endif 628*7c478bd9Sstevel@tonic-gate case ' ': 629*7c478bd9Sstevel@tonic-gate break; 630*7c478bd9Sstevel@tonic-gate default: 631*7c478bd9Sstevel@tonic-gate true = cmpstr(i); 632*7c478bd9Sstevel@tonic-gate } 633*7c478bd9Sstevel@tonic-gate i1: 634*7c478bd9Sstevel@tonic-gate true ^= notflag; 635*7c478bd9Sstevel@tonic-gate if (x == 1) 636*7c478bd9Sstevel@tonic-gate iflist[ifx] = !true; 637*7c478bd9Sstevel@tonic-gate if (true) { 638*7c478bd9Sstevel@tonic-gate i2: 639*7c478bd9Sstevel@tonic-gate while ((cbits(i = getch())) == ' ') 640*7c478bd9Sstevel@tonic-gate ; 641*7c478bd9Sstevel@tonic-gate if (cbits(i) == LEFT) 642*7c478bd9Sstevel@tonic-gate goto i2; 643*7c478bd9Sstevel@tonic-gate ch = i; 644*7c478bd9Sstevel@tonic-gate nflush++; 645*7c478bd9Sstevel@tonic-gate } else { 646*7c478bd9Sstevel@tonic-gate copyf++; 647*7c478bd9Sstevel@tonic-gate falsef++; 648*7c478bd9Sstevel@tonic-gate eatblk(0); 649*7c478bd9Sstevel@tonic-gate copyf--; 650*7c478bd9Sstevel@tonic-gate falsef--; 651*7c478bd9Sstevel@tonic-gate } 652*7c478bd9Sstevel@tonic-gate } 653*7c478bd9Sstevel@tonic-gate 654*7c478bd9Sstevel@tonic-gate eatblk(inblk) 655*7c478bd9Sstevel@tonic-gate int inblk; 656*7c478bd9Sstevel@tonic-gate { register int cnt, i; 657*7c478bd9Sstevel@tonic-gate 658*7c478bd9Sstevel@tonic-gate cnt = 0; 659*7c478bd9Sstevel@tonic-gate do { 660*7c478bd9Sstevel@tonic-gate if (ch) { 661*7c478bd9Sstevel@tonic-gate i = cbits(ch); 662*7c478bd9Sstevel@tonic-gate ch = 0; 663*7c478bd9Sstevel@tonic-gate } else 664*7c478bd9Sstevel@tonic-gate i = cbits(getch0()); 665*7c478bd9Sstevel@tonic-gate if (i == ESC) 666*7c478bd9Sstevel@tonic-gate cnt++; 667*7c478bd9Sstevel@tonic-gate else { 668*7c478bd9Sstevel@tonic-gate if (cnt == 1) 669*7c478bd9Sstevel@tonic-gate switch (i) { 670*7c478bd9Sstevel@tonic-gate case '{': i = LEFT; break; 671*7c478bd9Sstevel@tonic-gate case '}': i = RIGHT; break; 672*7c478bd9Sstevel@tonic-gate case '\n': i = 'x'; break; 673*7c478bd9Sstevel@tonic-gate } 674*7c478bd9Sstevel@tonic-gate cnt = 0; 675*7c478bd9Sstevel@tonic-gate } 676*7c478bd9Sstevel@tonic-gate if (i == LEFT) eatblk(1); 677*7c478bd9Sstevel@tonic-gate } while ((!inblk && (i != '\n')) || (inblk && (i != RIGHT))); 678*7c478bd9Sstevel@tonic-gate if (i == '\n') 679*7c478bd9Sstevel@tonic-gate nlflg++; 680*7c478bd9Sstevel@tonic-gate } 681*7c478bd9Sstevel@tonic-gate 682*7c478bd9Sstevel@tonic-gate 683*7c478bd9Sstevel@tonic-gate cmpstr(c) 684*7c478bd9Sstevel@tonic-gate tchar c; 685*7c478bd9Sstevel@tonic-gate { 686*7c478bd9Sstevel@tonic-gate register j, delim; 687*7c478bd9Sstevel@tonic-gate register tchar i; 688*7c478bd9Sstevel@tonic-gate register val; 689*7c478bd9Sstevel@tonic-gate int savapts, savapts1, savfont, savfont1, savpts, savpts1; 690*7c478bd9Sstevel@tonic-gate tchar string[1280]; 691*7c478bd9Sstevel@tonic-gate register tchar *sp; 692*7c478bd9Sstevel@tonic-gate 693*7c478bd9Sstevel@tonic-gate if (ismot(c)) 694*7c478bd9Sstevel@tonic-gate return(0); 695*7c478bd9Sstevel@tonic-gate delim = cbits(c); 696*7c478bd9Sstevel@tonic-gate savapts = apts; 697*7c478bd9Sstevel@tonic-gate savapts1 = apts1; 698*7c478bd9Sstevel@tonic-gate savfont = font; 699*7c478bd9Sstevel@tonic-gate savfont1 = font1; 700*7c478bd9Sstevel@tonic-gate savpts = pts; 701*7c478bd9Sstevel@tonic-gate savpts1 = pts1; 702*7c478bd9Sstevel@tonic-gate sp = string; 703*7c478bd9Sstevel@tonic-gate while ((j = cbits(i = getch()))!=delim && j!='\n' && sp<&string[1280-1]) 704*7c478bd9Sstevel@tonic-gate *sp++ = i; 705*7c478bd9Sstevel@tonic-gate if (sp >= string + 1280) { 706*7c478bd9Sstevel@tonic-gate errprint(gettext("too-long string compare.")); 707*7c478bd9Sstevel@tonic-gate edone(0100); 708*7c478bd9Sstevel@tonic-gate } 709*7c478bd9Sstevel@tonic-gate if (nlflg) { 710*7c478bd9Sstevel@tonic-gate val = sp==string; 711*7c478bd9Sstevel@tonic-gate goto rtn; 712*7c478bd9Sstevel@tonic-gate } 713*7c478bd9Sstevel@tonic-gate *sp++ = 0; 714*7c478bd9Sstevel@tonic-gate apts = savapts; 715*7c478bd9Sstevel@tonic-gate apts1 = savapts1; 716*7c478bd9Sstevel@tonic-gate font = savfont; 717*7c478bd9Sstevel@tonic-gate font1 = savfont1; 718*7c478bd9Sstevel@tonic-gate pts = savpts; 719*7c478bd9Sstevel@tonic-gate pts1 = savpts1; 720*7c478bd9Sstevel@tonic-gate mchbits(); 721*7c478bd9Sstevel@tonic-gate val = 1; 722*7c478bd9Sstevel@tonic-gate sp = string; 723*7c478bd9Sstevel@tonic-gate while ((j = cbits(i = getch())) != delim && j != '\n') { 724*7c478bd9Sstevel@tonic-gate if (*sp != i) { 725*7c478bd9Sstevel@tonic-gate eat(delim); 726*7c478bd9Sstevel@tonic-gate val = 0; 727*7c478bd9Sstevel@tonic-gate goto rtn; 728*7c478bd9Sstevel@tonic-gate } 729*7c478bd9Sstevel@tonic-gate sp++; 730*7c478bd9Sstevel@tonic-gate } 731*7c478bd9Sstevel@tonic-gate if (*sp) 732*7c478bd9Sstevel@tonic-gate val = 0; 733*7c478bd9Sstevel@tonic-gate rtn: 734*7c478bd9Sstevel@tonic-gate apts = savapts; 735*7c478bd9Sstevel@tonic-gate apts1 = savapts1; 736*7c478bd9Sstevel@tonic-gate font = savfont; 737*7c478bd9Sstevel@tonic-gate font1 = savfont1; 738*7c478bd9Sstevel@tonic-gate pts = savpts; 739*7c478bd9Sstevel@tonic-gate pts1 = savpts1; 740*7c478bd9Sstevel@tonic-gate mchbits(); 741*7c478bd9Sstevel@tonic-gate return(val); 742*7c478bd9Sstevel@tonic-gate } 743*7c478bd9Sstevel@tonic-gate 744*7c478bd9Sstevel@tonic-gate 745*7c478bd9Sstevel@tonic-gate caserd() 746*7c478bd9Sstevel@tonic-gate { 747*7c478bd9Sstevel@tonic-gate 748*7c478bd9Sstevel@tonic-gate lgf++; 749*7c478bd9Sstevel@tonic-gate skip(); 750*7c478bd9Sstevel@tonic-gate getname(); 751*7c478bd9Sstevel@tonic-gate if (!iflg) { 752*7c478bd9Sstevel@tonic-gate if (quiet) { 753*7c478bd9Sstevel@tonic-gate #ifdef NROFF 754*7c478bd9Sstevel@tonic-gate echo_off(); 755*7c478bd9Sstevel@tonic-gate flusho(); 756*7c478bd9Sstevel@tonic-gate #endif NROFF 757*7c478bd9Sstevel@tonic-gate fdprintf(stderr, "\007"); /*bell*/ 758*7c478bd9Sstevel@tonic-gate } else { 759*7c478bd9Sstevel@tonic-gate if (nextf[0]) { 760*7c478bd9Sstevel@tonic-gate fdprintf(stderr, "%s:", nextf); 761*7c478bd9Sstevel@tonic-gate } else { 762*7c478bd9Sstevel@tonic-gate fdprintf(stderr, "\007"); /*bell*/ 763*7c478bd9Sstevel@tonic-gate } 764*7c478bd9Sstevel@tonic-gate } 765*7c478bd9Sstevel@tonic-gate } 766*7c478bd9Sstevel@tonic-gate collect(); 767*7c478bd9Sstevel@tonic-gate tty++; 768*7c478bd9Sstevel@tonic-gate pushi(NBLIST*BLK, PAIR('r','d')); 769*7c478bd9Sstevel@tonic-gate } 770*7c478bd9Sstevel@tonic-gate 771*7c478bd9Sstevel@tonic-gate 772*7c478bd9Sstevel@tonic-gate rdtty() 773*7c478bd9Sstevel@tonic-gate { 774*7c478bd9Sstevel@tonic-gate char onechar; 775*7c478bd9Sstevel@tonic-gate #ifdef EUC 776*7c478bd9Sstevel@tonic-gate #ifdef NROFF 777*7c478bd9Sstevel@tonic-gate int i, n, col_index; 778*7c478bd9Sstevel@tonic-gate #endif /* NROFF */ 779*7c478bd9Sstevel@tonic-gate #endif /* EUC */ 780*7c478bd9Sstevel@tonic-gate 781*7c478bd9Sstevel@tonic-gate onechar = 0; 782*7c478bd9Sstevel@tonic-gate if (read(0, &onechar, 1) == 1) { 783*7c478bd9Sstevel@tonic-gate if (onechar == '\n') 784*7c478bd9Sstevel@tonic-gate tty++; 785*7c478bd9Sstevel@tonic-gate else 786*7c478bd9Sstevel@tonic-gate tty = 1; 787*7c478bd9Sstevel@tonic-gate #ifndef EUC 788*7c478bd9Sstevel@tonic-gate if (tty != 3) 789*7c478bd9Sstevel@tonic-gate return(onechar); 790*7c478bd9Sstevel@tonic-gate #else 791*7c478bd9Sstevel@tonic-gate #ifndef NROFF 792*7c478bd9Sstevel@tonic-gate if (tty != 3) 793*7c478bd9Sstevel@tonic-gate return(onechar); 794*7c478bd9Sstevel@tonic-gate #else 795*7c478bd9Sstevel@tonic-gate if (tty != 3) { 796*7c478bd9Sstevel@tonic-gate if (!multi_locale) 797*7c478bd9Sstevel@tonic-gate return(onechar); 798*7c478bd9Sstevel@tonic-gate i = onechar & 0377; 799*7c478bd9Sstevel@tonic-gate *mbbuf1p++ = i; 800*7c478bd9Sstevel@tonic-gate *mbbuf1p = 0; 801*7c478bd9Sstevel@tonic-gate if ((n = mbtowc(&twc, mbbuf1, MB_CUR_MAX)) <= 0) { 802*7c478bd9Sstevel@tonic-gate if (mbbuf1p >= mbbuf1 + MB_CUR_MAX) { 803*7c478bd9Sstevel@tonic-gate i &= ~(MBMASK | CSMASK); 804*7c478bd9Sstevel@tonic-gate twc = 0; 805*7c478bd9Sstevel@tonic-gate mbbuf1p = mbbuf1; 806*7c478bd9Sstevel@tonic-gate *mbbuf1p = 0; 807*7c478bd9Sstevel@tonic-gate } else { 808*7c478bd9Sstevel@tonic-gate i |= (MIDDLEOFMB); 809*7c478bd9Sstevel@tonic-gate } 810*7c478bd9Sstevel@tonic-gate } else { 811*7c478bd9Sstevel@tonic-gate if (n > 1) 812*7c478bd9Sstevel@tonic-gate i |= (LASTOFMB); 813*7c478bd9Sstevel@tonic-gate else 814*7c478bd9Sstevel@tonic-gate i |= (BYTE_CHR); 815*7c478bd9Sstevel@tonic-gate if (isascii(twc)) { 816*7c478bd9Sstevel@tonic-gate col_index = 0; 817*7c478bd9Sstevel@tonic-gate } else { 818*7c478bd9Sstevel@tonic-gate if ((col_index = wcwidth(twc)) < 0) 819*7c478bd9Sstevel@tonic-gate col_index = 0; 820*7c478bd9Sstevel@tonic-gate } 821*7c478bd9Sstevel@tonic-gate setcsbits(i, col_index); 822*7c478bd9Sstevel@tonic-gate twc = 0; 823*7c478bd9Sstevel@tonic-gate mbbuf1p = mbbuf1; 824*7c478bd9Sstevel@tonic-gate } 825*7c478bd9Sstevel@tonic-gate return(i); 826*7c478bd9Sstevel@tonic-gate } 827*7c478bd9Sstevel@tonic-gate #endif /* NROFF */ 828*7c478bd9Sstevel@tonic-gate #endif /* EUC */ 829*7c478bd9Sstevel@tonic-gate } 830*7c478bd9Sstevel@tonic-gate popi(); 831*7c478bd9Sstevel@tonic-gate tty = 0; 832*7c478bd9Sstevel@tonic-gate #ifdef NROFF 833*7c478bd9Sstevel@tonic-gate if (quiet) 834*7c478bd9Sstevel@tonic-gate echo_on(); 835*7c478bd9Sstevel@tonic-gate #endif NROFF 836*7c478bd9Sstevel@tonic-gate return(0); 837*7c478bd9Sstevel@tonic-gate } 838*7c478bd9Sstevel@tonic-gate 839*7c478bd9Sstevel@tonic-gate 840*7c478bd9Sstevel@tonic-gate caseec() 841*7c478bd9Sstevel@tonic-gate { 842*7c478bd9Sstevel@tonic-gate eschar = chget('\\'); 843*7c478bd9Sstevel@tonic-gate } 844*7c478bd9Sstevel@tonic-gate 845*7c478bd9Sstevel@tonic-gate 846*7c478bd9Sstevel@tonic-gate caseeo() 847*7c478bd9Sstevel@tonic-gate { 848*7c478bd9Sstevel@tonic-gate eschar = 0; 849*7c478bd9Sstevel@tonic-gate } 850*7c478bd9Sstevel@tonic-gate 851*7c478bd9Sstevel@tonic-gate 852*7c478bd9Sstevel@tonic-gate caseta() 853*7c478bd9Sstevel@tonic-gate { 854*7c478bd9Sstevel@tonic-gate register i; 855*7c478bd9Sstevel@tonic-gate 856*7c478bd9Sstevel@tonic-gate tabtab[0] = nonumb = 0; 857*7c478bd9Sstevel@tonic-gate for (i = 0; ((i < (NTAB - 1)) && !nonumb); i++) { 858*7c478bd9Sstevel@tonic-gate if (skip()) 859*7c478bd9Sstevel@tonic-gate break; 860*7c478bd9Sstevel@tonic-gate tabtab[i] = max(hnumb(&tabtab[max(i-1,0)]), 0) & TABMASK; 861*7c478bd9Sstevel@tonic-gate if (!nonumb) 862*7c478bd9Sstevel@tonic-gate switch (cbits(ch)) { 863*7c478bd9Sstevel@tonic-gate case 'C': 864*7c478bd9Sstevel@tonic-gate tabtab[i] |= CTAB; 865*7c478bd9Sstevel@tonic-gate break; 866*7c478bd9Sstevel@tonic-gate case 'R': 867*7c478bd9Sstevel@tonic-gate tabtab[i] |= RTAB; 868*7c478bd9Sstevel@tonic-gate break; 869*7c478bd9Sstevel@tonic-gate default: /*includes L*/ 870*7c478bd9Sstevel@tonic-gate break; 871*7c478bd9Sstevel@tonic-gate } 872*7c478bd9Sstevel@tonic-gate nonumb = ch = 0; 873*7c478bd9Sstevel@tonic-gate } 874*7c478bd9Sstevel@tonic-gate tabtab[i] = 0; 875*7c478bd9Sstevel@tonic-gate } 876*7c478bd9Sstevel@tonic-gate 877*7c478bd9Sstevel@tonic-gate 878*7c478bd9Sstevel@tonic-gate casene() 879*7c478bd9Sstevel@tonic-gate { 880*7c478bd9Sstevel@tonic-gate register i, j; 881*7c478bd9Sstevel@tonic-gate 882*7c478bd9Sstevel@tonic-gate skip(); 883*7c478bd9Sstevel@tonic-gate i = vnumb((int *)0); 884*7c478bd9Sstevel@tonic-gate if (nonumb) 885*7c478bd9Sstevel@tonic-gate i = lss; 886*7c478bd9Sstevel@tonic-gate if (i > (j = findt1())) { 887*7c478bd9Sstevel@tonic-gate i = lss; 888*7c478bd9Sstevel@tonic-gate lss = j; 889*7c478bd9Sstevel@tonic-gate dip->nls = 0; 890*7c478bd9Sstevel@tonic-gate newline(0); 891*7c478bd9Sstevel@tonic-gate lss = i; 892*7c478bd9Sstevel@tonic-gate } 893*7c478bd9Sstevel@tonic-gate } 894*7c478bd9Sstevel@tonic-gate 895*7c478bd9Sstevel@tonic-gate 896*7c478bd9Sstevel@tonic-gate casetr() 897*7c478bd9Sstevel@tonic-gate { 898*7c478bd9Sstevel@tonic-gate register i, j; 899*7c478bd9Sstevel@tonic-gate tchar k; 900*7c478bd9Sstevel@tonic-gate 901*7c478bd9Sstevel@tonic-gate lgf++; 902*7c478bd9Sstevel@tonic-gate skip(); 903*7c478bd9Sstevel@tonic-gate while ((i = cbits(k=getch())) != '\n') { 904*7c478bd9Sstevel@tonic-gate if (ismot(k)) 905*7c478bd9Sstevel@tonic-gate return; 906*7c478bd9Sstevel@tonic-gate if (ismot(k = getch())) 907*7c478bd9Sstevel@tonic-gate return; 908*7c478bd9Sstevel@tonic-gate if ((j = cbits(k)) == '\n') 909*7c478bd9Sstevel@tonic-gate j = ' '; 910*7c478bd9Sstevel@tonic-gate trtab[i] = j; 911*7c478bd9Sstevel@tonic-gate } 912*7c478bd9Sstevel@tonic-gate } 913*7c478bd9Sstevel@tonic-gate 914*7c478bd9Sstevel@tonic-gate 915*7c478bd9Sstevel@tonic-gate casecu() 916*7c478bd9Sstevel@tonic-gate { 917*7c478bd9Sstevel@tonic-gate cu++; 918*7c478bd9Sstevel@tonic-gate caseul(); 919*7c478bd9Sstevel@tonic-gate } 920*7c478bd9Sstevel@tonic-gate 921*7c478bd9Sstevel@tonic-gate 922*7c478bd9Sstevel@tonic-gate caseul() 923*7c478bd9Sstevel@tonic-gate { 924*7c478bd9Sstevel@tonic-gate register i; 925*7c478bd9Sstevel@tonic-gate 926*7c478bd9Sstevel@tonic-gate noscale++; 927*7c478bd9Sstevel@tonic-gate if (skip()) 928*7c478bd9Sstevel@tonic-gate i = 1; 929*7c478bd9Sstevel@tonic-gate else 930*7c478bd9Sstevel@tonic-gate i = atoi(); 931*7c478bd9Sstevel@tonic-gate if (ul && (i == 0)) { 932*7c478bd9Sstevel@tonic-gate font = sfont; 933*7c478bd9Sstevel@tonic-gate ul = cu = 0; 934*7c478bd9Sstevel@tonic-gate } 935*7c478bd9Sstevel@tonic-gate if (i) { 936*7c478bd9Sstevel@tonic-gate if (!ul) { 937*7c478bd9Sstevel@tonic-gate sfont = font; 938*7c478bd9Sstevel@tonic-gate font = ulfont; 939*7c478bd9Sstevel@tonic-gate } 940*7c478bd9Sstevel@tonic-gate ul = i; 941*7c478bd9Sstevel@tonic-gate } 942*7c478bd9Sstevel@tonic-gate noscale = 0; 943*7c478bd9Sstevel@tonic-gate mchbits(); 944*7c478bd9Sstevel@tonic-gate } 945*7c478bd9Sstevel@tonic-gate 946*7c478bd9Sstevel@tonic-gate 947*7c478bd9Sstevel@tonic-gate caseuf() 948*7c478bd9Sstevel@tonic-gate { 949*7c478bd9Sstevel@tonic-gate register i, j; 950*7c478bd9Sstevel@tonic-gate 951*7c478bd9Sstevel@tonic-gate if (skip() || !(i = getrq()) || i == 'S' || (j = findft(i)) == -1) 952*7c478bd9Sstevel@tonic-gate ulfont = ULFONT; /*default underline position*/ 953*7c478bd9Sstevel@tonic-gate else 954*7c478bd9Sstevel@tonic-gate ulfont = j; 955*7c478bd9Sstevel@tonic-gate #ifdef NROFF 956*7c478bd9Sstevel@tonic-gate if (ulfont == FT) 957*7c478bd9Sstevel@tonic-gate ulfont = ULFONT; 958*7c478bd9Sstevel@tonic-gate #endif 959*7c478bd9Sstevel@tonic-gate } 960*7c478bd9Sstevel@tonic-gate 961*7c478bd9Sstevel@tonic-gate 962*7c478bd9Sstevel@tonic-gate caseit() 963*7c478bd9Sstevel@tonic-gate { 964*7c478bd9Sstevel@tonic-gate register i; 965*7c478bd9Sstevel@tonic-gate 966*7c478bd9Sstevel@tonic-gate lgf++; 967*7c478bd9Sstevel@tonic-gate it = itmac = 0; 968*7c478bd9Sstevel@tonic-gate noscale++; 969*7c478bd9Sstevel@tonic-gate skip(); 970*7c478bd9Sstevel@tonic-gate i = atoi(); 971*7c478bd9Sstevel@tonic-gate skip(); 972*7c478bd9Sstevel@tonic-gate if (!nonumb && (itmac = getrq())) 973*7c478bd9Sstevel@tonic-gate it = i; 974*7c478bd9Sstevel@tonic-gate noscale = 0; 975*7c478bd9Sstevel@tonic-gate } 976*7c478bd9Sstevel@tonic-gate 977*7c478bd9Sstevel@tonic-gate 978*7c478bd9Sstevel@tonic-gate casemc() 979*7c478bd9Sstevel@tonic-gate { 980*7c478bd9Sstevel@tonic-gate register i; 981*7c478bd9Sstevel@tonic-gate 982*7c478bd9Sstevel@tonic-gate if (icf > 1) 983*7c478bd9Sstevel@tonic-gate ic = 0; 984*7c478bd9Sstevel@tonic-gate icf = 0; 985*7c478bd9Sstevel@tonic-gate if (skip()) 986*7c478bd9Sstevel@tonic-gate return; 987*7c478bd9Sstevel@tonic-gate ic = getch(); 988*7c478bd9Sstevel@tonic-gate icf = 1; 989*7c478bd9Sstevel@tonic-gate skip(); 990*7c478bd9Sstevel@tonic-gate i = max(hnumb((int *)0), 0); 991*7c478bd9Sstevel@tonic-gate if (!nonumb) 992*7c478bd9Sstevel@tonic-gate ics = i; 993*7c478bd9Sstevel@tonic-gate } 994*7c478bd9Sstevel@tonic-gate 995*7c478bd9Sstevel@tonic-gate 996*7c478bd9Sstevel@tonic-gate casemk() 997*7c478bd9Sstevel@tonic-gate { 998*7c478bd9Sstevel@tonic-gate register i, j; 999*7c478bd9Sstevel@tonic-gate 1000*7c478bd9Sstevel@tonic-gate if (dip != d) 1001*7c478bd9Sstevel@tonic-gate j = dip->dnl; 1002*7c478bd9Sstevel@tonic-gate else 1003*7c478bd9Sstevel@tonic-gate j = numtab[NL].val; 1004*7c478bd9Sstevel@tonic-gate if (skip()) { 1005*7c478bd9Sstevel@tonic-gate dip->mkline = j; 1006*7c478bd9Sstevel@tonic-gate return; 1007*7c478bd9Sstevel@tonic-gate } 1008*7c478bd9Sstevel@tonic-gate if ((i = getrq()) == 0) 1009*7c478bd9Sstevel@tonic-gate return; 1010*7c478bd9Sstevel@tonic-gate numtab[findr(i)].val = j; 1011*7c478bd9Sstevel@tonic-gate } 1012*7c478bd9Sstevel@tonic-gate 1013*7c478bd9Sstevel@tonic-gate 1014*7c478bd9Sstevel@tonic-gate casesv() 1015*7c478bd9Sstevel@tonic-gate { 1016*7c478bd9Sstevel@tonic-gate register i; 1017*7c478bd9Sstevel@tonic-gate 1018*7c478bd9Sstevel@tonic-gate skip(); 1019*7c478bd9Sstevel@tonic-gate if ((i = vnumb((int *)0)) < 0) 1020*7c478bd9Sstevel@tonic-gate return; 1021*7c478bd9Sstevel@tonic-gate if (nonumb) 1022*7c478bd9Sstevel@tonic-gate i = 1; 1023*7c478bd9Sstevel@tonic-gate sv += i; 1024*7c478bd9Sstevel@tonic-gate caseos(); 1025*7c478bd9Sstevel@tonic-gate } 1026*7c478bd9Sstevel@tonic-gate 1027*7c478bd9Sstevel@tonic-gate 1028*7c478bd9Sstevel@tonic-gate caseos() 1029*7c478bd9Sstevel@tonic-gate { 1030*7c478bd9Sstevel@tonic-gate register savlss; 1031*7c478bd9Sstevel@tonic-gate 1032*7c478bd9Sstevel@tonic-gate if (sv <= findt1()) { 1033*7c478bd9Sstevel@tonic-gate savlss = lss; 1034*7c478bd9Sstevel@tonic-gate lss = sv; 1035*7c478bd9Sstevel@tonic-gate newline(0); 1036*7c478bd9Sstevel@tonic-gate lss = savlss; 1037*7c478bd9Sstevel@tonic-gate sv = 0; 1038*7c478bd9Sstevel@tonic-gate } 1039*7c478bd9Sstevel@tonic-gate } 1040*7c478bd9Sstevel@tonic-gate 1041*7c478bd9Sstevel@tonic-gate 1042*7c478bd9Sstevel@tonic-gate casenm() 1043*7c478bd9Sstevel@tonic-gate { 1044*7c478bd9Sstevel@tonic-gate register i; 1045*7c478bd9Sstevel@tonic-gate 1046*7c478bd9Sstevel@tonic-gate lnmod = nn = 0; 1047*7c478bd9Sstevel@tonic-gate if (skip()) 1048*7c478bd9Sstevel@tonic-gate return; 1049*7c478bd9Sstevel@tonic-gate lnmod++; 1050*7c478bd9Sstevel@tonic-gate noscale++; 1051*7c478bd9Sstevel@tonic-gate i = inumb(&numtab[LN].val); 1052*7c478bd9Sstevel@tonic-gate if (!nonumb) 1053*7c478bd9Sstevel@tonic-gate numtab[LN].val = max(i, 0); 1054*7c478bd9Sstevel@tonic-gate getnm(&ndf, 1); 1055*7c478bd9Sstevel@tonic-gate getnm(&nms, 0); 1056*7c478bd9Sstevel@tonic-gate getnm(&ni, 0); 1057*7c478bd9Sstevel@tonic-gate noscale = 0; 1058*7c478bd9Sstevel@tonic-gate nmbits = chbits; 1059*7c478bd9Sstevel@tonic-gate } 1060*7c478bd9Sstevel@tonic-gate 1061*7c478bd9Sstevel@tonic-gate 1062*7c478bd9Sstevel@tonic-gate getnm(p, min) 1063*7c478bd9Sstevel@tonic-gate int *p, min; 1064*7c478bd9Sstevel@tonic-gate { 1065*7c478bd9Sstevel@tonic-gate register i; 1066*7c478bd9Sstevel@tonic-gate 1067*7c478bd9Sstevel@tonic-gate eat(' '); 1068*7c478bd9Sstevel@tonic-gate if (skip()) 1069*7c478bd9Sstevel@tonic-gate return; 1070*7c478bd9Sstevel@tonic-gate i = atoi(); 1071*7c478bd9Sstevel@tonic-gate if (nonumb) 1072*7c478bd9Sstevel@tonic-gate return; 1073*7c478bd9Sstevel@tonic-gate *p = max(i, min); 1074*7c478bd9Sstevel@tonic-gate } 1075*7c478bd9Sstevel@tonic-gate 1076*7c478bd9Sstevel@tonic-gate 1077*7c478bd9Sstevel@tonic-gate casenn() 1078*7c478bd9Sstevel@tonic-gate { 1079*7c478bd9Sstevel@tonic-gate noscale++; 1080*7c478bd9Sstevel@tonic-gate skip(); 1081*7c478bd9Sstevel@tonic-gate nn = max(atoi(), 1); 1082*7c478bd9Sstevel@tonic-gate noscale = 0; 1083*7c478bd9Sstevel@tonic-gate } 1084*7c478bd9Sstevel@tonic-gate 1085*7c478bd9Sstevel@tonic-gate 1086*7c478bd9Sstevel@tonic-gate caseab() 1087*7c478bd9Sstevel@tonic-gate { 1088*7c478bd9Sstevel@tonic-gate casetm(1); 1089*7c478bd9Sstevel@tonic-gate done3(0); 1090*7c478bd9Sstevel@tonic-gate } 1091*7c478bd9Sstevel@tonic-gate 1092*7c478bd9Sstevel@tonic-gate 1093*7c478bd9Sstevel@tonic-gate #ifdef NROFF 1094*7c478bd9Sstevel@tonic-gate /* 1095*7c478bd9Sstevel@tonic-gate * The following routines are concerned with setting terminal options. 1096*7c478bd9Sstevel@tonic-gate * The manner of doing this differs between research/Berkeley systems 1097*7c478bd9Sstevel@tonic-gate * and UNIX System V systems (i.e. DOCUMENTER'S WORKBENCH) 1098*7c478bd9Sstevel@tonic-gate * The distinction is controlled by the #define'd variable USG, 1099*7c478bd9Sstevel@tonic-gate * which must be set by System V users. 1100*7c478bd9Sstevel@tonic-gate */ 1101*7c478bd9Sstevel@tonic-gate 1102*7c478bd9Sstevel@tonic-gate 1103*7c478bd9Sstevel@tonic-gate #ifdef USG 1104*7c478bd9Sstevel@tonic-gate #include <termio.h> 1105*7c478bd9Sstevel@tonic-gate #define ECHO_USG (ECHO | ECHOE | ECHOK | ECHONL) 1106*7c478bd9Sstevel@tonic-gate struct termio ttys; 1107*7c478bd9Sstevel@tonic-gate #else 1108*7c478bd9Sstevel@tonic-gate #include <sgtty.h> 1109*7c478bd9Sstevel@tonic-gate struct sgttyb ttys[2]; 1110*7c478bd9Sstevel@tonic-gate #endif USG 1111*7c478bd9Sstevel@tonic-gate 1112*7c478bd9Sstevel@tonic-gate int ttysave[2] = {-1, -1}; 1113*7c478bd9Sstevel@tonic-gate 1114*7c478bd9Sstevel@tonic-gate save_tty() /*save any tty settings that may be changed*/ 1115*7c478bd9Sstevel@tonic-gate { 1116*7c478bd9Sstevel@tonic-gate 1117*7c478bd9Sstevel@tonic-gate #ifdef USG 1118*7c478bd9Sstevel@tonic-gate if (ioctl(0, TCGETA, &ttys) >= 0) 1119*7c478bd9Sstevel@tonic-gate ttysave[0] = ttys.c_lflag; 1120*7c478bd9Sstevel@tonic-gate #else 1121*7c478bd9Sstevel@tonic-gate if (gtty(0, &ttys[0]) >= 0) 1122*7c478bd9Sstevel@tonic-gate ttysave[0] = ttys[0].sg_flags; 1123*7c478bd9Sstevel@tonic-gate if (gtty(1, &ttys[1]) >= 0) 1124*7c478bd9Sstevel@tonic-gate ttysave[1] = ttys[1].sg_flags; 1125*7c478bd9Sstevel@tonic-gate #endif USG 1126*7c478bd9Sstevel@tonic-gate 1127*7c478bd9Sstevel@tonic-gate } 1128*7c478bd9Sstevel@tonic-gate 1129*7c478bd9Sstevel@tonic-gate 1130*7c478bd9Sstevel@tonic-gate restore_tty() /*restore tty settings from beginning*/ 1131*7c478bd9Sstevel@tonic-gate { 1132*7c478bd9Sstevel@tonic-gate 1133*7c478bd9Sstevel@tonic-gate if (ttysave[0] != -1) { 1134*7c478bd9Sstevel@tonic-gate #ifdef USG 1135*7c478bd9Sstevel@tonic-gate ttys.c_lflag = ttysave[0]; 1136*7c478bd9Sstevel@tonic-gate ioctl(0, TCSETAW, &ttys); 1137*7c478bd9Sstevel@tonic-gate #else 1138*7c478bd9Sstevel@tonic-gate ttys[0].sg_flags = ttysave[0]; 1139*7c478bd9Sstevel@tonic-gate stty(0, &ttys[0]); 1140*7c478bd9Sstevel@tonic-gate } 1141*7c478bd9Sstevel@tonic-gate if (ttysave[1] != -1) { 1142*7c478bd9Sstevel@tonic-gate ttys[1].sg_flags = ttysave[1]; 1143*7c478bd9Sstevel@tonic-gate stty(1, &ttys[1]); 1144*7c478bd9Sstevel@tonic-gate #endif USG 1145*7c478bd9Sstevel@tonic-gate } 1146*7c478bd9Sstevel@tonic-gate } 1147*7c478bd9Sstevel@tonic-gate 1148*7c478bd9Sstevel@tonic-gate 1149*7c478bd9Sstevel@tonic-gate set_tty() /*this replaces the use of bset and breset*/ 1150*7c478bd9Sstevel@tonic-gate { 1151*7c478bd9Sstevel@tonic-gate 1152*7c478bd9Sstevel@tonic-gate #ifndef USG /*for research/BSD only, reset CRMOD*/ 1153*7c478bd9Sstevel@tonic-gate if (ttysave[1] == -1) 1154*7c478bd9Sstevel@tonic-gate save_tty(); 1155*7c478bd9Sstevel@tonic-gate if (ttysave[1] != -1) { 1156*7c478bd9Sstevel@tonic-gate ttys[1].sg_flags &= ~CRMOD; 1157*7c478bd9Sstevel@tonic-gate stty(1, &ttys[1]); 1158*7c478bd9Sstevel@tonic-gate } 1159*7c478bd9Sstevel@tonic-gate #endif USG 1160*7c478bd9Sstevel@tonic-gate 1161*7c478bd9Sstevel@tonic-gate } 1162*7c478bd9Sstevel@tonic-gate 1163*7c478bd9Sstevel@tonic-gate 1164*7c478bd9Sstevel@tonic-gate echo_off() /*turn off ECHO for .rd in "-q" mode*/ 1165*7c478bd9Sstevel@tonic-gate { 1166*7c478bd9Sstevel@tonic-gate if (ttysave[0] == -1) 1167*7c478bd9Sstevel@tonic-gate return; 1168*7c478bd9Sstevel@tonic-gate 1169*7c478bd9Sstevel@tonic-gate #ifdef USG 1170*7c478bd9Sstevel@tonic-gate ttys.c_lflag &= ~ECHO_USG; 1171*7c478bd9Sstevel@tonic-gate ioctl(0, TCSETAW, &ttys); 1172*7c478bd9Sstevel@tonic-gate #else 1173*7c478bd9Sstevel@tonic-gate ttys[0].sg_flags &= ~ECHO; 1174*7c478bd9Sstevel@tonic-gate stty(0, &ttys[0]); 1175*7c478bd9Sstevel@tonic-gate #endif USG 1176*7c478bd9Sstevel@tonic-gate 1177*7c478bd9Sstevel@tonic-gate } 1178*7c478bd9Sstevel@tonic-gate 1179*7c478bd9Sstevel@tonic-gate 1180*7c478bd9Sstevel@tonic-gate echo_on() /*restore ECHO after .rd in "-q" mode*/ 1181*7c478bd9Sstevel@tonic-gate { 1182*7c478bd9Sstevel@tonic-gate if (ttysave[0] == -1) 1183*7c478bd9Sstevel@tonic-gate return; 1184*7c478bd9Sstevel@tonic-gate 1185*7c478bd9Sstevel@tonic-gate #ifdef USG 1186*7c478bd9Sstevel@tonic-gate ttys.c_lflag |= ECHO_USG; 1187*7c478bd9Sstevel@tonic-gate ioctl(0, TCSETAW, &ttys); 1188*7c478bd9Sstevel@tonic-gate #else 1189*7c478bd9Sstevel@tonic-gate ttys[0].sg_flags |= ECHO; 1190*7c478bd9Sstevel@tonic-gate stty(0, &ttys[0]); 1191*7c478bd9Sstevel@tonic-gate #endif USG 1192*7c478bd9Sstevel@tonic-gate 1193*7c478bd9Sstevel@tonic-gate } 1194*7c478bd9Sstevel@tonic-gate #endif NROFF 1195