1*7067Srrh #ifndef lint 2*7067Srrh static char sccsid[] = "@(#)n3.c 4.1 06/07/82"; 3*7067Srrh #endif lint 4*7067Srrh 5*7067Srrh #include "tdef.h" 6*7067Srrh extern 7*7067Srrh #include "d.h" 8*7067Srrh extern 9*7067Srrh #include "v.h" 10*7067Srrh #ifdef NROFF 11*7067Srrh extern 12*7067Srrh #include "tw.h" 13*7067Srrh #endif 14*7067Srrh #include "sdef.h" 15*7067Srrh 16*7067Srrh /* 17*7067Srrh troff3.c 18*7067Srrh 19*7067Srrh macro and string routines, storage allocation 20*7067Srrh */ 21*7067Srrh 22*7067Srrh unsigned blist[NBLIST]; 23*7067Srrh extern struct s *frame, *stk, *nxf; 24*7067Srrh extern filep ip; 25*7067Srrh extern filep offset; 26*7067Srrh extern filep nextb; 27*7067Srrh extern char *enda; 28*7067Srrh 29*7067Srrh extern int ch; 30*7067Srrh extern int ibf; 31*7067Srrh extern int lgf; 32*7067Srrh extern int copyf; 33*7067Srrh extern int ch0; 34*7067Srrh extern int app; 35*7067Srrh extern int ds; 36*7067Srrh extern int nlflg; 37*7067Srrh extern int *argtop; 38*7067Srrh extern int *ap; 39*7067Srrh extern int nchar; 40*7067Srrh extern int pendt; 41*7067Srrh extern int rchar; 42*7067Srrh extern int dilev; 43*7067Srrh extern int nonumb; 44*7067Srrh extern int lt; 45*7067Srrh extern int nrbits; 46*7067Srrh extern int nform; 47*7067Srrh extern int fmt[]; 48*7067Srrh extern int oldmn; 49*7067Srrh extern int newmn; 50*7067Srrh extern int macerr; 51*7067Srrh extern filep apptr; 52*7067Srrh extern int diflg; 53*7067Srrh extern filep woff; 54*7067Srrh extern filep roff; 55*7067Srrh extern int wbfi; 56*7067Srrh extern int po; 57*7067Srrh extern int *cp; 58*7067Srrh extern int xxx; 59*7067Srrh int pagech = '%'; 60*7067Srrh int strflg; 61*7067Srrh extern struct contab { 62*7067Srrh int rq; 63*7067Srrh union { 64*7067Srrh int (*f)(); 65*7067Srrh unsigned mx; 66*7067Srrh }x; 67*7067Srrh }contab[NM]; 68*7067Srrh #ifndef VMUNIX 69*7067Srrh int wbuf[BLK]; 70*7067Srrh int rbuf[BLK]; 71*7067Srrh #else 72*7067Srrh int *wbuf; 73*7067Srrh int *rbuf; 74*7067Srrh int Buf[NBLIST*BLK + NEV*EVS]; 75*7067Srrh #endif 76*7067Srrh 77*7067Srrh caseig(){ 78*7067Srrh register i; 79*7067Srrh 80*7067Srrh offset = 0; 81*7067Srrh if((i = copyb()) != '.')control(i,1); 82*7067Srrh } 83*7067Srrh casern(){ 84*7067Srrh register i,j; 85*7067Srrh 86*7067Srrh lgf++; 87*7067Srrh skip(); 88*7067Srrh if(((i=getrq())==0) || ((oldmn=findmn(i)) < 0))return; 89*7067Srrh skip(); 90*7067Srrh clrmn(findmn(j=getrq())); 91*7067Srrh if(j)contab[oldmn].rq = (contab[oldmn].rq & MMASK) | j; 92*7067Srrh } 93*7067Srrh caserm(){ 94*7067Srrh lgf++; 95*7067Srrh while(!skip()){ 96*7067Srrh clrmn(findmn(getrq())); 97*7067Srrh } 98*7067Srrh } 99*7067Srrh caseas(){ 100*7067Srrh app++; 101*7067Srrh caseds(); 102*7067Srrh } 103*7067Srrh caseds(){ 104*7067Srrh ds++; 105*7067Srrh casede(); 106*7067Srrh } 107*7067Srrh caseam(){ 108*7067Srrh app++; 109*7067Srrh casede(); 110*7067Srrh } 111*7067Srrh casede(){ 112*7067Srrh register i, req; 113*7067Srrh register filep savoff; 114*7067Srrh extern filep finds(); 115*7067Srrh 116*7067Srrh if(dip != d)wbfl(); 117*7067Srrh req = '.'; 118*7067Srrh lgf++; 119*7067Srrh skip(); 120*7067Srrh if((i=getrq())==0)goto de1; 121*7067Srrh if((offset=finds(i)) == 0)goto de1; 122*7067Srrh if(ds)copys(); 123*7067Srrh else req = copyb(); 124*7067Srrh wbfl(); 125*7067Srrh clrmn(oldmn); 126*7067Srrh if(newmn)contab[newmn].rq = i | MMASK; 127*7067Srrh if(apptr){ 128*7067Srrh savoff = offset; 129*7067Srrh offset = apptr; 130*7067Srrh wbt(IMP); 131*7067Srrh offset = savoff; 132*7067Srrh } 133*7067Srrh offset = dip->op; 134*7067Srrh if(req != '.')control(req,1); 135*7067Srrh de1: 136*7067Srrh ds = app = 0; 137*7067Srrh return; 138*7067Srrh } 139*7067Srrh findmn(i) 140*7067Srrh int i; 141*7067Srrh { 142*7067Srrh register j; 143*7067Srrh 144*7067Srrh for(j=0;j<NM;j++){ 145*7067Srrh if(i == (contab[j].rq & ~MMASK))break; 146*7067Srrh } 147*7067Srrh if(j==NM)j = -1; 148*7067Srrh return(j); 149*7067Srrh } 150*7067Srrh clrmn(i) 151*7067Srrh int i; 152*7067Srrh { 153*7067Srrh extern filep boff(); 154*7067Srrh if(i >= 0){ 155*7067Srrh if(contab[i].rq & MMASK)ffree(((filep)contab[i].x.mx)<<BLKBITS); 156*7067Srrh contab[i].rq = 0; 157*7067Srrh contab[i].x.mx = 0; 158*7067Srrh } 159*7067Srrh } 160*7067Srrh filep finds(mn) 161*7067Srrh int mn; 162*7067Srrh { 163*7067Srrh register i; 164*7067Srrh extern filep boff(); 165*7067Srrh register filep savip; 166*7067Srrh extern filep alloc(); 167*7067Srrh extern filep incoff(); 168*7067Srrh 169*7067Srrh oldmn = findmn(mn); 170*7067Srrh newmn = 0; 171*7067Srrh apptr = (filep)0; 172*7067Srrh if(app && (oldmn >= 0) && (contab[oldmn].rq & MMASK)){ 173*7067Srrh savip = ip; 174*7067Srrh ip = (((filep)contab[oldmn].x.mx)<<BLKBITS); 175*7067Srrh oldmn = -1; 176*7067Srrh while((i=rbf()) != 0); 177*7067Srrh apptr = ip; 178*7067Srrh if(!diflg)ip = incoff(ip); 179*7067Srrh nextb = ip; 180*7067Srrh ip = savip; 181*7067Srrh }else{ 182*7067Srrh for(i=0;i<NM;i++){ 183*7067Srrh if(contab[i].rq == 0)break; 184*7067Srrh } 185*7067Srrh if((i==NM) || 186*7067Srrh (nextb = alloc()) == 0){ 187*7067Srrh app = 0; 188*7067Srrh if(macerr++ > 1)done2(02); 189*7067Srrh prstr("Too many string/macro names.\n"); 190*7067Srrh edone(04); 191*7067Srrh return(offset = 0); 192*7067Srrh } 193*7067Srrh contab[i].x.mx = (unsigned)(nextb>>BLKBITS); 194*7067Srrh if(!diflg){ 195*7067Srrh newmn = i; 196*7067Srrh if(oldmn == -1)contab[i].rq = -1; 197*7067Srrh }else{ 198*7067Srrh contab[i].rq = mn | MMASK; 199*7067Srrh } 200*7067Srrh } 201*7067Srrh 202*7067Srrh app = 0; 203*7067Srrh return(offset = nextb); 204*7067Srrh } 205*7067Srrh skip(){ 206*7067Srrh register i; 207*7067Srrh 208*7067Srrh while(((i=getch()) & CMASK) == ' '); 209*7067Srrh ch=i; 210*7067Srrh return(nlflg); 211*7067Srrh } 212*7067Srrh copyb() 213*7067Srrh { 214*7067Srrh register i, j, k; 215*7067Srrh int ii, req, state; 216*7067Srrh filep savoff; 217*7067Srrh 218*7067Srrh if(skip() || !(j=getrq()))j = '.'; 219*7067Srrh req = j; 220*7067Srrh k = j>>BYTE; 221*7067Srrh j &= BMASK; 222*7067Srrh copyf++; 223*7067Srrh flushi(); 224*7067Srrh nlflg = 0; 225*7067Srrh state = 1; 226*7067Srrh while(1){ 227*7067Srrh i = (ii = getch()) & CMASK; 228*7067Srrh if(state == 3){ 229*7067Srrh if(i == k)break; 230*7067Srrh if(!k){ 231*7067Srrh ch = ii; 232*7067Srrh i = getach(); 233*7067Srrh ch = ii; 234*7067Srrh if(!i)break; 235*7067Srrh } 236*7067Srrh state = 0; 237*7067Srrh goto c0; 238*7067Srrh } 239*7067Srrh if(i == '\n'){ 240*7067Srrh state = 1; 241*7067Srrh nlflg = 0; 242*7067Srrh goto c0; 243*7067Srrh } 244*7067Srrh if((state == 1) && (i == '.')){ 245*7067Srrh state++; 246*7067Srrh savoff = offset; 247*7067Srrh goto c0; 248*7067Srrh } 249*7067Srrh if((state == 2) && (i == j)){ 250*7067Srrh state++; 251*7067Srrh goto c0; 252*7067Srrh } 253*7067Srrh state = 0; 254*7067Srrh c0: 255*7067Srrh if(offset)wbf(ii); 256*7067Srrh } 257*7067Srrh if(offset){ 258*7067Srrh wbfl(); 259*7067Srrh offset = savoff; 260*7067Srrh wbt(0); 261*7067Srrh } 262*7067Srrh copyf--; 263*7067Srrh return(req); 264*7067Srrh } 265*7067Srrh copys() 266*7067Srrh { 267*7067Srrh register i; 268*7067Srrh 269*7067Srrh copyf++; 270*7067Srrh if(skip())goto c0; 271*7067Srrh if(((i=getch()) & CMASK) != '"')wbf(i); 272*7067Srrh while(((i=getch()) & CMASK) != '\n')wbf(i); 273*7067Srrh c0: 274*7067Srrh wbt(0); 275*7067Srrh copyf--; 276*7067Srrh } 277*7067Srrh filep alloc() 278*7067Srrh { 279*7067Srrh register i; 280*7067Srrh extern filep boff(); 281*7067Srrh filep j; 282*7067Srrh 283*7067Srrh for(i=0;i<NBLIST;i++){ 284*7067Srrh if(blist[i] == 0)break; 285*7067Srrh } 286*7067Srrh if(i==NBLIST){ 287*7067Srrh j = 0; 288*7067Srrh }else{ 289*7067Srrh blist[i] = -1; 290*7067Srrh if((j = boff(i)) < NEV*EVS)j = 0; 291*7067Srrh } 292*7067Srrh return(nextb = j); 293*7067Srrh } 294*7067Srrh ffree(i) 295*7067Srrh filep i; 296*7067Srrh { 297*7067Srrh register j; 298*7067Srrh 299*7067Srrh while((blist[j = blisti(i)]) != -1){ 300*7067Srrh i = ((filep)blist[j])<<BLKBITS; 301*7067Srrh blist[j] = 0; 302*7067Srrh } 303*7067Srrh blist[j] = 0; 304*7067Srrh } 305*7067Srrh filep boff(i) 306*7067Srrh int i; 307*7067Srrh { 308*7067Srrh return(((filep)i)*BLK + NEV*EVS); 309*7067Srrh } 310*7067Srrh wbt(i) 311*7067Srrh int i; 312*7067Srrh { 313*7067Srrh wbf(i); 314*7067Srrh wbfl(); 315*7067Srrh } 316*7067Srrh wbf(i) 317*7067Srrh int i; 318*7067Srrh { 319*7067Srrh register j; 320*7067Srrh 321*7067Srrh if(!offset)return; 322*7067Srrh if(!woff){ 323*7067Srrh woff = offset; 324*7067Srrh #ifdef VMUNIX 325*7067Srrh wbuf = &Buf[woff]; 326*7067Srrh #endif 327*7067Srrh wbfi = 0; 328*7067Srrh } 329*7067Srrh wbuf[wbfi++] = i; 330*7067Srrh if(!((++offset) & (BLK-1))){ 331*7067Srrh wbfl(); 332*7067Srrh if(blist[j = blisti(--offset)] == -1){ 333*7067Srrh if(alloc() == 0){ 334*7067Srrh prstr("Out of temp file space.\n"); 335*7067Srrh done2(01); 336*7067Srrh } 337*7067Srrh blist[j] = (unsigned)(nextb>>BLKBITS); 338*7067Srrh } 339*7067Srrh offset = ((filep)blist[j])<<BLKBITS; 340*7067Srrh } 341*7067Srrh if(wbfi >= BLK)wbfl(); 342*7067Srrh } 343*7067Srrh wbfl(){ 344*7067Srrh if(woff == 0)return; 345*7067Srrh #ifndef VMUNIX 346*7067Srrh lseek(ibf, ((long)woff) * sizeof(int), 0); 347*7067Srrh write(ibf, (char *)wbuf, wbfi * sizeof(int)); 348*7067Srrh #endif 349*7067Srrh if((woff & (~(BLK-1))) == (roff & (~(BLK-1))))roff = -1; 350*7067Srrh woff = 0; 351*7067Srrh } 352*7067Srrh blisti(i) 353*7067Srrh filep i; 354*7067Srrh { 355*7067Srrh return((i-NEV*EVS)/(BLK)); 356*7067Srrh } 357*7067Srrh rbf(){ 358*7067Srrh register i; 359*7067Srrh extern filep incoff(); 360*7067Srrh 361*7067Srrh if((i=rbf0(ip)) == 0){ 362*7067Srrh if(!app)i = popi(); 363*7067Srrh }else{ 364*7067Srrh ip = incoff(ip); 365*7067Srrh } 366*7067Srrh return(i); 367*7067Srrh } 368*7067Srrh rbf0(p) 369*7067Srrh filep p; 370*7067Srrh { 371*7067Srrh register filep i; 372*7067Srrh 373*7067Srrh if((i = (p & (~(BLK-1)))) != roff){ 374*7067Srrh roff = i; 375*7067Srrh #ifndef VMUNIX 376*7067Srrh lseek(ibf, ((long)roff) * sizeof(int), 0); 377*7067Srrh if(read(ibf, (char *)rbuf, BLK * sizeof(int)) == 0)return(0); 378*7067Srrh #else 379*7067Srrh rbuf = &Buf[roff]; 380*7067Srrh #endif 381*7067Srrh } 382*7067Srrh return(rbuf[p & (BLK-1)]); 383*7067Srrh } 384*7067Srrh filep incoff(p) 385*7067Srrh filep p; 386*7067Srrh { 387*7067Srrh register i; 388*7067Srrh register filep j; 389*7067Srrh if(!((j = (++p)) & (BLK-1))){ 390*7067Srrh if((i = blist[blisti(--p)]) == -1){ 391*7067Srrh prstr("Bad storage allocation.\n"); 392*7067Srrh done2(-5); 393*7067Srrh } 394*7067Srrh j = ((filep)i)<<BLKBITS; 395*7067Srrh } 396*7067Srrh return(j); 397*7067Srrh } 398*7067Srrh popi(){ 399*7067Srrh register struct s *p; 400*7067Srrh 401*7067Srrh if(frame == stk)return(0); 402*7067Srrh if(strflg)strflg--; 403*7067Srrh p = nxf = frame; 404*7067Srrh p->nargs = 0; 405*7067Srrh frame = p->pframe; 406*7067Srrh ip = p->pip; 407*7067Srrh nchar = p->pnchar; 408*7067Srrh rchar = p->prchar; 409*7067Srrh pendt = p->ppendt; 410*7067Srrh ap = p->pap; 411*7067Srrh cp = p->pcp; 412*7067Srrh ch0 = p->pch0; 413*7067Srrh return(p->pch); 414*7067Srrh } 415*7067Srrh pushi(newip) 416*7067Srrh filep newip; 417*7067Srrh { 418*7067Srrh register struct s *p; 419*7067Srrh extern char *setbrk(); 420*7067Srrh 421*7067Srrh if((enda - sizeof(struct s)) < (char *)nxf)setbrk(DELTA); 422*7067Srrh p = nxf; 423*7067Srrh p->pframe = frame; 424*7067Srrh p->pip = ip; 425*7067Srrh p->pnchar = nchar; 426*7067Srrh p->prchar = rchar; 427*7067Srrh p->ppendt = pendt; 428*7067Srrh p->pap = ap; 429*7067Srrh p->pcp = cp; 430*7067Srrh p->pch0 = ch0; 431*7067Srrh p->pch = ch; 432*7067Srrh cp = ap = 0; 433*7067Srrh nchar = rchar = pendt = ch0 = ch = 0; 434*7067Srrh frame = nxf; 435*7067Srrh if(nxf->nargs == 0) nxf += 1; 436*7067Srrh else nxf = (struct s *)argtop; 437*7067Srrh return(ip = newip); 438*7067Srrh } 439*7067Srrh char *setbrk(x) 440*7067Srrh int x; 441*7067Srrh { 442*7067Srrh register char *i; 443*7067Srrh char *sbrk(); 444*7067Srrh 445*7067Srrh if((i = sbrk(x)) == MAXPTR){ 446*7067Srrh prstrfl("Core limit reached.\n"); 447*7067Srrh edone(0100); 448*7067Srrh }else{ 449*7067Srrh enda = i + x; 450*7067Srrh } 451*7067Srrh return(i); 452*7067Srrh } 453*7067Srrh getsn(){ 454*7067Srrh register i; 455*7067Srrh 456*7067Srrh if((i=getach()) == 0)return(0); 457*7067Srrh if(i == '(')return(getrq()); 458*7067Srrh else return(i); 459*7067Srrh } 460*7067Srrh setstr(){ 461*7067Srrh register i; 462*7067Srrh 463*7067Srrh lgf++; 464*7067Srrh if(((i=getsn()) == 0) || 465*7067Srrh ((i=findmn(i)) == -1) || 466*7067Srrh !(contab[i].rq & MMASK)){ 467*7067Srrh lgf--; 468*7067Srrh return(0); 469*7067Srrh }else{ 470*7067Srrh if((enda-2) < (char *)nxf)setbrk(DELTA); 471*7067Srrh nxf->nargs = 0; 472*7067Srrh strflg++; 473*7067Srrh lgf--; 474*7067Srrh return(pushi(((filep)contab[i].x.mx)<<BLKBITS)); 475*7067Srrh } 476*7067Srrh } 477*7067Srrh collect() 478*7067Srrh { 479*7067Srrh register i; 480*7067Srrh register int *strp; 481*7067Srrh int *lim; 482*7067Srrh int **argpp, **argppend; 483*7067Srrh int quote; 484*7067Srrh struct s *savnxf; 485*7067Srrh 486*7067Srrh copyf++; 487*7067Srrh nxf->nargs = 0; 488*7067Srrh savnxf = nxf; 489*7067Srrh if(skip())goto rtn; 490*7067Srrh lim = (int *)(nxf = savnxf + sizeof(struct s)/sizeof(savnxf)); 491*7067Srrh strflg = 0; 492*7067Srrh if((argppend = 493*7067Srrh (argpp = (int **)savnxf+(sizeof(struct s)/sizeof(int **))) + 9) 494*7067Srrh > (int **)enda)setbrk(DELTA); 495*7067Srrh strp = (int *)argppend; 496*7067Srrh for(i=8; i>=0; i--)argpp[i] = 0; 497*7067Srrh while((argpp != argppend) && (!skip())){ 498*7067Srrh *argpp++ = strp; 499*7067Srrh quote = 0; 500*7067Srrh if(((i = getch()) & CMASK) == '"')quote++; 501*7067Srrh else ch = i; 502*7067Srrh while(1){ 503*7067Srrh i = getch(); 504*7067Srrh if( nlflg || 505*7067Srrh ((!quote) && ((i & CMASK) == ' ')))break; 506*7067Srrh if(quote && ((i & CMASK) == '"') && 507*7067Srrh (((i=getch()) & CMASK) != '"')){ 508*7067Srrh ch = i; 509*7067Srrh break; 510*7067Srrh } 511*7067Srrh *strp++ = i; 512*7067Srrh if(strflg && (strp >= lim)){ 513*7067Srrh prstrfl("Macro argument too long.\n"); 514*7067Srrh copyf--; 515*7067Srrh edone(004); 516*7067Srrh } 517*7067Srrh if((enda-4) <= (char *)strp)setbrk(DELTA); 518*7067Srrh } 519*7067Srrh *strp++ = 0; 520*7067Srrh } 521*7067Srrh nxf = savnxf; 522*7067Srrh nxf->nargs = argpp -(int **)(nxf + 1); 523*7067Srrh argtop = strp; 524*7067Srrh rtn: 525*7067Srrh copyf--; 526*7067Srrh } 527*7067Srrh seta() 528*7067Srrh { 529*7067Srrh register i; 530*7067Srrh 531*7067Srrh if(((i = (getch() & CMASK) - '0') > 0) && 532*7067Srrh (i <= 9) && (i <= frame->nargs))ap = *((int **)frame + i-1 + (sizeof(struct s)/sizeof(int **))); 533*7067Srrh } 534*7067Srrh caseda(){ 535*7067Srrh app++; 536*7067Srrh casedi(); 537*7067Srrh } 538*7067Srrh casedi(){ 539*7067Srrh register i, j; 540*7067Srrh register *k; 541*7067Srrh 542*7067Srrh lgf++; 543*7067Srrh if(skip() || ((i=getrq()) == 0)){ 544*7067Srrh if(dip != d)wbt(0); 545*7067Srrh if(dilev > 0){ 546*7067Srrh v.dn = dip->dnl; 547*7067Srrh v.dl = dip->maxl; 548*7067Srrh dip = &d[--dilev]; 549*7067Srrh offset = dip->op; 550*7067Srrh } 551*7067Srrh goto rtn; 552*7067Srrh } 553*7067Srrh if(++dilev == NDI){ 554*7067Srrh --dilev; 555*7067Srrh prstr("Cannot divert.\n"); 556*7067Srrh edone(02); 557*7067Srrh } 558*7067Srrh if(dip != d)wbt(0); 559*7067Srrh diflg++; 560*7067Srrh dip = &d[dilev]; 561*7067Srrh dip->op = finds(i); 562*7067Srrh dip->curd = i; 563*7067Srrh clrmn(oldmn); 564*7067Srrh k = (int *)&dip->dnl; 565*7067Srrh for(j=0; j<10; j++)k[j] = 0; /*not op and curd*/ 566*7067Srrh rtn: 567*7067Srrh app = 0; 568*7067Srrh diflg = 0; 569*7067Srrh } 570*7067Srrh casedt(){ 571*7067Srrh lgf++; 572*7067Srrh dip->dimac = dip->ditrap = dip->ditf = 0; 573*7067Srrh skip(); 574*7067Srrh dip->ditrap = vnumb((int *)0); 575*7067Srrh if(nonumb)return; 576*7067Srrh skip(); 577*7067Srrh dip->dimac = getrq(); 578*7067Srrh } 579*7067Srrh casetl(){ 580*7067Srrh register i, j; 581*7067Srrh int w1, w2, w3, delim; 582*7067Srrh filep begin; 583*7067Srrh extern width(), pchar(); 584*7067Srrh 585*7067Srrh dip->nls = 0; 586*7067Srrh skip(); 587*7067Srrh if(dip != d)wbfl(); 588*7067Srrh if((offset = begin = alloc()) == 0)return; 589*7067Srrh if((delim = getch()) & MOT){ 590*7067Srrh ch = delim; 591*7067Srrh delim = '\''; 592*7067Srrh }else delim &= CMASK; 593*7067Srrh if(!nlflg) 594*7067Srrh while(((i = getch()) & CMASK) != '\n'){ 595*7067Srrh if((i & CMASK) == delim)i = IMP; 596*7067Srrh wbf(i); 597*7067Srrh } 598*7067Srrh wbf(IMP);wbf(IMP);wbt(0); 599*7067Srrh 600*7067Srrh w1 = hseg(width,begin); 601*7067Srrh w2 = hseg(width,(filep)0); 602*7067Srrh w3 = hseg(width,(filep)0); 603*7067Srrh offset = dip->op; 604*7067Srrh #ifdef NROFF 605*7067Srrh if(!offset)horiz(po); 606*7067Srrh #endif 607*7067Srrh hseg(pchar,begin); 608*7067Srrh if(w2 || w3)horiz(j=quant((lt - w2)/2-w1,HOR)); 609*7067Srrh hseg(pchar,(filep)0); 610*7067Srrh if(w3){ 611*7067Srrh horiz(lt-w1-w2-w3-j); 612*7067Srrh hseg(pchar,(filep)0); 613*7067Srrh } 614*7067Srrh newline(0); 615*7067Srrh if(dip != d){if(dip->dnl > dip->hnl)dip->hnl = dip->dnl;} 616*7067Srrh else{if(v.nl > dip->hnl)dip->hnl = v.nl;} 617*7067Srrh ffree(begin); 618*7067Srrh } 619*7067Srrh casepc(){ 620*7067Srrh pagech = chget(IMP); 621*7067Srrh } 622*7067Srrh hseg(f,p) 623*7067Srrh int (*f)(); 624*7067Srrh filep p; 625*7067Srrh { 626*7067Srrh register acc, i; 627*7067Srrh static filep q; 628*7067Srrh 629*7067Srrh acc = 0; 630*7067Srrh if(p)q = p; 631*7067Srrh while(1){ 632*7067Srrh i = rbf0(q); 633*7067Srrh q = incoff(q); 634*7067Srrh if(!i || (i == IMP))return(acc); 635*7067Srrh if((i & CMASK) == pagech){ 636*7067Srrh nrbits = i & ~CMASK; 637*7067Srrh nform = fmt[findr('%')]; 638*7067Srrh acc += fnumb(v.pn,f); 639*7067Srrh }else acc += (*f)(i); 640*7067Srrh } 641*7067Srrh } 642*7067Srrh casepm(){ 643*7067Srrh register i, k; 644*7067Srrh register char *p; 645*7067Srrh int xx, cnt, kk, tot; 646*7067Srrh filep j; 647*7067Srrh char *kvt(); 648*7067Srrh char pmline[10]; 649*7067Srrh 650*7067Srrh kk = cnt = 0; 651*7067Srrh tot = !skip(); 652*7067Srrh for(i = 0; i<NM; i++){ 653*7067Srrh if(!((xx = contab[i].rq) & MMASK))continue; 654*7067Srrh p = pmline; 655*7067Srrh j = (((filep)contab[i].x.mx)<<BLKBITS); 656*7067Srrh k = 1; 657*7067Srrh while((j = blist[blisti(j)]) != -1){k++; j <<= BLKBITS;} 658*7067Srrh cnt++; 659*7067Srrh kk += k; 660*7067Srrh if(!tot){ 661*7067Srrh *p++ = xx & 0177; 662*7067Srrh if(!(*p++ = (xx >> BYTE) & 0177))*(p-1) = ' '; 663*7067Srrh *p++ = ' '; 664*7067Srrh kvt(k,p); 665*7067Srrh prstr(pmline); 666*7067Srrh } 667*7067Srrh } 668*7067Srrh if(tot || (cnt > 1)){ 669*7067Srrh kvt(kk,pmline); 670*7067Srrh prstr(pmline); 671*7067Srrh } 672*7067Srrh } 673*7067Srrh char *kvt(k,p) 674*7067Srrh int k; 675*7067Srrh char *p; 676*7067Srrh { 677*7067Srrh if(k>=100)*p++ = k/100 + '0'; 678*7067Srrh if(k>=10)*p++ = (k%100)/10 + '0'; 679*7067Srrh *p++ = k%10 + '0'; 680*7067Srrh *p++ = '\n'; 681*7067Srrh *p = 0; 682*7067Srrh return(p); 683*7067Srrh } 684*7067Srrh dummy(){} 685