17071Srrh #ifndef lint 2*40363Smckusick static char sccsid[] = "@(#)n7.c 4.4 03/07/90"; 37071Srrh #endif lint 47071Srrh 57071Srrh #include "tdef.h" 67071Srrh extern 77071Srrh #include "d.h" 87071Srrh extern 97071Srrh #include "v.h" 107071Srrh #ifdef NROFF 117071Srrh extern 127071Srrh #include "tw.h" 137071Srrh #endif 147071Srrh #include "sdef.h" 157071Srrh #ifdef NROFF 167071Srrh #define GETCH gettch 177071Srrh #endif 187071Srrh #ifndef NROFF 197071Srrh #define GETCH getch 207071Srrh #endif 217071Srrh 227071Srrh /* 237071Srrh troff7.c 247071Srrh 257071Srrh text 267071Srrh */ 277071Srrh 287071Srrh extern struct s *frame, *stk; 297071Srrh extern struct s *ejl; 307071Srrh 317071Srrh extern int pl; 327071Srrh extern int trap; 337071Srrh extern int flss; 347071Srrh extern int npnflg; 357071Srrh extern int npn; 367071Srrh extern int stop; 377071Srrh extern int nflush; 387071Srrh extern int ejf; 397071Srrh extern int ascii; 407071Srrh extern int donef; 417071Srrh extern int nc; 427071Srrh extern int wch; 437071Srrh extern int dpn; 447071Srrh extern int ndone; 457071Srrh extern int lss; 467071Srrh extern int pto; 477071Srrh extern int pfrom; 487071Srrh extern int print; 497071Srrh extern int nlist[NTRAP]; 507071Srrh extern int mlist[NTRAP]; 517071Srrh extern int *pnp; 527071Srrh extern int nb; 537071Srrh extern int ic; 547071Srrh extern int icf; 557071Srrh extern int ics; 567071Srrh extern int ne; 577071Srrh extern int ll; 587071Srrh extern int un; 597071Srrh extern int un1; 607071Srrh extern int in; 617071Srrh extern int ls; 627071Srrh extern int spread; 637071Srrh extern int totout; 647071Srrh extern int nwd; 657071Srrh extern int *pendw; 667071Srrh extern int *linep; 677071Srrh extern int line[]; 687071Srrh extern int lastl; 697071Srrh extern int ch; 707071Srrh extern int ce; 717071Srrh extern int fi; 727071Srrh extern int nlflg; 737071Srrh extern int pendt; 747071Srrh extern int sps; 757071Srrh extern int adsp; 767071Srrh extern int pendnf; 777071Srrh extern int over; 787071Srrh extern int adrem; 797071Srrh extern int nel; 807071Srrh extern int ad; 817071Srrh extern int ohc; 827071Srrh extern int hyoff; 837071Srrh extern int nhyp; 847071Srrh extern int spflg; 857071Srrh extern int word[]; 867071Srrh extern int *wordp; 877071Srrh extern int wne; 887071Srrh extern int chbits; 897071Srrh extern int cwidth; 907071Srrh extern int widthp; 917071Srrh extern int hyf; 927071Srrh extern int xbitf; 937071Srrh extern int vflag; 947071Srrh extern int ul; 957071Srrh extern int cu; 967071Srrh extern int font; 977071Srrh extern int sfont; 987071Srrh extern int it; 997071Srrh extern int itmac; 1007071Srrh extern int *hyptr[NHYP]; 1017071Srrh extern int **hyp; 1027071Srrh extern int *wdstart, *wdend; 1037071Srrh extern int lnmod; 1047071Srrh extern int admod; 1057071Srrh extern int nn; 1067071Srrh extern int nms; 1077071Srrh extern int ndf; 1087071Srrh extern int ni; 1097071Srrh extern int nform; 1107071Srrh extern int lnsize; 1117071Srrh extern int po; 1127071Srrh extern int ulbit; 1137071Srrh extern int *vlist; 1147071Srrh extern int nrbits; 1157071Srrh extern int nmbits; 1167071Srrh extern char trtab[]; 1177071Srrh extern int xxx; 1187071Srrh int brflg; 1197071Srrh 1207071Srrh tbreak(){ 1217071Srrh register *i, j, pad; 1227071Srrh int res; 1237071Srrh 1247071Srrh trap = 0; 1257071Srrh if(nb)return; 1267071Srrh if((dip == d) && (v.nl == -1)){ 1277071Srrh newline(1); 1287071Srrh return; 1297071Srrh } 1307071Srrh if(!nc){ 1317071Srrh setnel(); 1327071Srrh if(!wch)return; 1337071Srrh if(pendw)getword(1); 1347071Srrh movword(); 1357071Srrh }else if(pendw && !brflg){ 1367071Srrh getword(1); 1377071Srrh movword(); 1387071Srrh } 1397071Srrh *linep = dip->nls = 0; 1407071Srrh #ifdef NROFF 1417071Srrh if(dip == d)horiz(po); 1427071Srrh #endif 1437071Srrh if(lnmod)donum(); 1447071Srrh lastl = ne; 1457071Srrh if(brflg != 1){ 1467071Srrh totout = 0; 1477071Srrh }else if(ad){ 1487071Srrh if((lastl = (ll - un)) < ne)lastl = ne; 1497071Srrh } 1507071Srrh if(admod && ad && (brflg != 2)){ 1517071Srrh lastl = ne; 1527071Srrh adsp = adrem = 0; 1537071Srrh #ifdef NROFF 1547071Srrh if(admod == 1)un += quant(nel/2,t.Adj); 1557071Srrh #endif 1567071Srrh #ifndef NROFF 1577071Srrh if(admod == 1)un += nel/2; 1587071Srrh #endif 1597071Srrh else if(admod ==2)un += nel; 1607071Srrh } 1617071Srrh totout++; 1627071Srrh brflg = 0; 1637071Srrh if((lastl+un) > dip->maxl)dip->maxl = (lastl+un); 1647071Srrh horiz(un); 1657071Srrh #ifdef NROFF 1667071Srrh if(adrem%t.Adj)res = t.Hor; else res = t.Adj; 1677071Srrh #endif 1687071Srrh for(i = line;nc > 0;){ 1697071Srrh if(((j = *i++) & CMASK) == ' '){ 1707071Srrh pad = 0; 1717071Srrh do{ 1727071Srrh pad += width(j); 1737071Srrh nc--; 1747071Srrh }while(((j = *i++) & CMASK) == ' '); 1757071Srrh i--; 1767071Srrh pad += adsp; 1777071Srrh --nwd; 1787071Srrh if(adrem){ 1797071Srrh if(adrem < 0){ 1807071Srrh #ifdef NROFF 1817071Srrh pad -= res; 1827071Srrh adrem += res; 1837071Srrh }else if((totout&01) || 1847071Srrh ((adrem/res)>=(nwd))){ 1857071Srrh pad += res; 1867071Srrh adrem -= res; 1877071Srrh #endif 1887071Srrh #ifndef NROFF 1897071Srrh pad--; 1907071Srrh adrem++; 1917071Srrh }else{ 1927071Srrh pad++; 1937071Srrh adrem--; 1947071Srrh #endif 1957071Srrh } 1967071Srrh } 1977071Srrh horiz(pad); 1987071Srrh }else{ 1997071Srrh pchar(j); 2007071Srrh nc--; 2017071Srrh } 2027071Srrh } 2037071Srrh if(ic){ 2047071Srrh if((j = ll - un - lastl + ics) > 0)horiz(j); 2057071Srrh pchar(ic); 2067071Srrh } 2077071Srrh if(icf)icf++; 2087071Srrh else ic = 0; 2097071Srrh ne = nwd = 0; 2107071Srrh un = in; 2117071Srrh setnel(); 2127071Srrh newline(0); 2137071Srrh if(dip != d){if(dip->dnl > dip->hnl)dip->hnl = dip->dnl;} 2147071Srrh else{if(v.nl > dip->hnl)dip->hnl = v.nl;} 2157071Srrh for(j=ls-1; (j >0) && !trap; j--)newline(0); 2167071Srrh spread = 0; 2177071Srrh } 2187071Srrh donum(){ 2197071Srrh register i, nw; 2207071Srrh extern pchar(); 2217071Srrh 2227071Srrh nrbits = nmbits; 2237071Srrh nw = width('1' | nrbits); 2247071Srrh if(nn){ 2257071Srrh nn--; 2267071Srrh goto d1; 2277071Srrh } 2287071Srrh if(v.ln%ndf){ 2297071Srrh v.ln++; 2307071Srrh d1: 2317071Srrh un += nw*(3+nms+ni); 2327071Srrh return; 2337071Srrh } 2347071Srrh i = 0; 2357071Srrh if(v.ln<100)i++; 2367071Srrh if(v.ln<10)i++; 2377071Srrh horiz(nw*(ni+i)); 2387071Srrh nform = 0; 2397071Srrh fnumb(v.ln,pchar); 2407071Srrh un += nw*nms; 2417071Srrh v.ln++; 2427071Srrh } 2437071Srrh text(){ 2447071Srrh register i; 2457071Srrh static int spcnt; 2467071Srrh 2477071Srrh nflush++; 2487071Srrh if((dip == d) && (v.nl == -1)){newline(1); return;} 2497071Srrh setnel(); 2507071Srrh if(ce || !fi){ 2517071Srrh nofill(); 2527071Srrh return; 2537071Srrh } 2547071Srrh if(pendw)goto t4; 2557071Srrh if(pendt)if(spcnt)goto t2; else goto t3; 2567071Srrh pendt++; 2577071Srrh if(spcnt)goto t2; 2587071Srrh while(((i = GETCH()) & CMASK) == ' ')spcnt++; 2597071Srrh if(nlflg){ 2607071Srrh t1: 2617071Srrh nflush = pendt = ch = spcnt = 0; 2627071Srrh callsp(); 2637071Srrh return; 2647071Srrh } 2657071Srrh ch = i; 2667071Srrh if(spcnt){ 2677071Srrh t2: 2687071Srrh tbreak(); 2697071Srrh if(nc || wch)goto rtn; 2707071Srrh un += spcnt*sps; 2717071Srrh spcnt = 0; 2727071Srrh setnel(); 2737071Srrh if(trap)goto rtn; 2747071Srrh if(nlflg)goto t1; 2757071Srrh } 2767071Srrh t3: 2777071Srrh if(spread)goto t5; 2787071Srrh if(pendw || !wch) 2797071Srrh t4: 2807071Srrh if(getword(0))goto t6; 2817071Srrh if(!movword())goto t3; 2827071Srrh t5: 2837071Srrh if(nlflg)pendt = 0; 2847071Srrh adsp = adrem = 0; 2857071Srrh if(ad){ 2867071Srrh /* jfr */ if (nwd==1) adsp=nel; else adsp=nel/(nwd-1); 2877071Srrh #ifdef NROFF 2887071Srrh adsp = (adsp/t.Adj)*t.Adj; 2897071Srrh #endif 2907071Srrh adrem = nel - adsp*(nwd-1); 2917071Srrh } 2927071Srrh brflg = 1; 2937071Srrh tbreak(); 2947071Srrh spread = 0; 2957071Srrh if(!trap)goto t3; 2967071Srrh if(!nlflg)goto rtn; 2977071Srrh t6: 2987071Srrh pendt = 0; 2997071Srrh ckul(); 3007071Srrh rtn: 3017071Srrh nflush = 0; 3027071Srrh } 3037071Srrh nofill(){ 3047071Srrh register i, j; 3057071Srrh 3067071Srrh if(!pendnf){ 3077071Srrh over = 0; 3087071Srrh tbreak(); 3097071Srrh if(trap)goto rtn; 3107071Srrh if(nlflg){ 3117071Srrh ch = nflush = 0; 3127071Srrh callsp(); 3137071Srrh return; 3147071Srrh } 3157071Srrh adsp = adrem = 0; 3167071Srrh nwd = 10000; 3177071Srrh } 3187071Srrh while((j = ((i = GETCH()) & CMASK)) != '\n'){ 3197071Srrh if(j == ohc)continue; 3207071Srrh if(j == CONT){ 3217071Srrh pendnf++; 3227071Srrh nflush = 0; 3237071Srrh flushi(); 3247071Srrh ckul(); 3257071Srrh return; 3267071Srrh } 3277071Srrh storeline(i,-1); 3287071Srrh } 3297071Srrh if(ce){ 3307071Srrh ce--; 3317071Srrh if((i=quant(nel/2,HOR)) > 0)un += i; 3327071Srrh } 3337071Srrh if(!nc)storeline(FILLER,0); 3347071Srrh brflg = 2; 3357071Srrh tbreak(); 3367071Srrh ckul(); 3377071Srrh rtn: 3387071Srrh pendnf = nflush = 0; 3397071Srrh } 3407071Srrh callsp(){ 3417071Srrh register i; 3427071Srrh 3437071Srrh if(flss)i = flss; else i = lss; 3447071Srrh flss = 0; 3457071Srrh casesp(i); 3467071Srrh } 3477071Srrh ckul(){ 3487071Srrh if(ul && (--ul == 0)){ 3497071Srrh cu = 0; 3507071Srrh font = sfont; 3517071Srrh mchbits(); 3527071Srrh } 3537071Srrh if(it && (--it == 0) && itmac)control(itmac,0); 3547071Srrh } 3557071Srrh storeline(c,w){ 3567071Srrh register i; 3577071Srrh 3587071Srrh if((c & CMASK) == JREG){ 3597071Srrh if((i=findr(c>>BYTE)) != -1)vlist[i] = ne; 3607071Srrh return; 3617071Srrh } 3627071Srrh if(linep >= (line + lnsize - 1)){ 3637071Srrh if(!over){ 3647071Srrh prstrfl("Line overflow.\n"); 3657071Srrh over++; 3667071Srrh c = 0343; 3677071Srrh w = -1; 3687071Srrh goto s1; 3697071Srrh } 3707071Srrh return; 3717071Srrh } 3727071Srrh s1: 3737071Srrh if(w == -1)w = width(c); 3747071Srrh ne += w; 3757071Srrh nel -= w; 3767071Srrh /* 3777071Srrh * if( cu && !(c & MOT) && (trtab[(c & CMASK)] == ' ')) 3787071Srrh * c = ((c & ~ulbit) & ~CMASK) | '_'; 3797071Srrh */ 3807071Srrh *linep++ = c; 3817071Srrh nc++; 3827071Srrh } 3837071Srrh newline(a) 3847071Srrh int a; 3857071Srrh { 3867071Srrh register i, j, nlss; 3877071Srrh int opn; 3887071Srrh 3897071Srrh if(a)goto nl1; 3907071Srrh if(dip != d){ 3917071Srrh j = lss; 3927071Srrh pchar1(FLSS); 3937071Srrh if(flss)lss = flss; 3947071Srrh i = lss + dip->blss; 3957071Srrh dip->dnl += i; 3967071Srrh pchar1(i); 3977071Srrh pchar1('\n'); 3987071Srrh lss = j; 3997071Srrh dip->blss = flss = 0; 4007071Srrh if(dip->alss){ 4017071Srrh pchar1(FLSS); 4027071Srrh pchar1(dip->alss); 4037071Srrh pchar1('\n'); 4047071Srrh dip->dnl += dip->alss; 4057071Srrh dip->alss = 0; 4067071Srrh } 4077071Srrh if(dip->ditrap && !dip->ditf && 4087071Srrh (dip->dnl >= dip->ditrap) && dip->dimac) 4097071Srrh if(control(dip->dimac,0)){trap++; dip->ditf++;} 4107071Srrh return; 4117071Srrh } 4127071Srrh j = lss; 4137071Srrh if(flss)lss = flss; 4147071Srrh nlss = dip->alss + dip->blss + lss; 4157071Srrh v.nl += nlss; 4167071Srrh #ifndef NROFF 4177071Srrh if(ascii){dip->alss = dip->blss = 0;} 4187071Srrh #endif 4197071Srrh pchar1('\n'); 4207071Srrh flss = 0; 4217071Srrh lss = j; 4227071Srrh if(v.nl < pl)goto nl2; 4237071Srrh nl1: 4247071Srrh ejf = dip->hnl = v.nl = 0; 4257071Srrh ejl = frame; 42632270Sbostic if(donef == 1){ 4277071Srrh if((!nc && !wch) || ndone)done1(0); 4287071Srrh ndone++; 4297071Srrh donef = 0; 4307071Srrh if(frame == stk)nflush++; 4317071Srrh } 4327071Srrh opn = v.pn; 4337071Srrh v.pn++; 4347071Srrh if(npnflg){ 4357071Srrh v.pn = npn; 4367071Srrh npn = npnflg = 0; 4377071Srrh } 4387071Srrh nlpn: 4397071Srrh if(v.pn == pfrom){ 4407071Srrh print++; 44133264Smckusick }else if(opn == pto || v.pn > pto){ 4427071Srrh print = 0; 4437071Srrh chkpn(); 4447071Srrh goto nlpn; 4457071Srrh } 4467071Srrh if(stop && print){ 4477071Srrh dpn++; 4487071Srrh if(dpn >= stop){ 4497071Srrh dpn = 0; 4507071Srrh dostop(); 4517071Srrh } 4527071Srrh } 4537071Srrh nl2: 4547071Srrh trap = 0; 4557071Srrh if(v.nl == 0){ 4567071Srrh if((j = findn(0)) != NTRAP) 4577071Srrh trap = control(mlist[j],0); 4587071Srrh } else if((i = findt(v.nl-nlss)) <= nlss){ 4597071Srrh if((j = findn1(v.nl-nlss+i)) == NTRAP){ 4607071Srrh prstrfl("Trap botch.\n"); 4617071Srrh done2(-5); 4627071Srrh } 4637071Srrh trap = control(mlist[j],0); 4647071Srrh } 4657071Srrh } 4667071Srrh findn1(a) 4677071Srrh int a; 4687071Srrh { 4697071Srrh register i, j; 4707071Srrh 4717071Srrh for(i=0; i<NTRAP; i++){ 4727071Srrh if(mlist[i]){ 4737071Srrh if((j = nlist[i]) < 0)j += pl; 4747071Srrh if(j == a)break; 4757071Srrh } 4767071Srrh } 4777071Srrh return(i); 4787071Srrh } 4797071Srrh chkpn(){ 480*40363Smckusick pfrom = pto = *(pnp++); 4817071Srrh if(pto == -1){ 4827071Srrh flusho(); 4837071Srrh done1(0); 4847071Srrh } 485*40363Smckusick if(pto == -2){ 4867071Srrh print++; 4877071Srrh pfrom = 0; 488*40363Smckusick pto = 10000; 4897071Srrh } 490*40363Smckusick else if(pto & MOT){ 491*40363Smckusick print++; 492*40363Smckusick pto &= ~MOT; 493*40363Smckusick pfrom = 0; 494*40363Smckusick } 4957071Srrh } 4967071Srrh findt(a) 4977071Srrh int a; 4987071Srrh { 4997071Srrh register i, j, k; 5007071Srrh 5017071Srrh k = 32767; 5027071Srrh if(dip != d){ 5037071Srrh if(dip->dimac && ((i = dip->ditrap -a) > 0))k = i; 5047071Srrh return(k); 5057071Srrh } 5067071Srrh for(i=0; i<NTRAP; i++){ 5077071Srrh if(mlist[i]){ 5087071Srrh if((j = nlist[i]) < 0)j += pl; 5097071Srrh if((j -= a) <= 0)continue; 5107071Srrh if(j < k)k = j; 5117071Srrh } 5127071Srrh } 5137071Srrh i = pl - a; 5147071Srrh if(k > i)k = i; 5157071Srrh return(k); 5167071Srrh } 5177071Srrh findt1(){ 5187071Srrh register i; 5197071Srrh 5207071Srrh if(dip != d)i = dip->dnl; 5217071Srrh else i = v.nl; 5227071Srrh return(findt(i)); 5237071Srrh } 5247071Srrh eject(a) 5257071Srrh struct s *a; 5267071Srrh { 5277071Srrh register savlss; 5287071Srrh 5297071Srrh if(dip != d)return; 5307071Srrh ejf++; 5317071Srrh if(a)ejl = a; 5327071Srrh else ejl = frame; 5337071Srrh if(trap)return; 5347071Srrh e1: 5357071Srrh savlss = lss; 5367071Srrh lss = findt(v.nl); 5377071Srrh newline(0); 5387071Srrh lss = savlss; 5397071Srrh if(v.nl && !trap)goto e1; 5407071Srrh } 5417071Srrh movword(){ 5427071Srrh register i, w, *wp; 5437071Srrh int savwch, hys; 5447071Srrh 5457071Srrh over = 0; 5467071Srrh wp = wordp; 5477071Srrh if(!nwd){ 5487071Srrh while(((i = *wp++) & CMASK) == ' '){ 5497071Srrh wch--; 5507071Srrh wne -= width(i); 5517071Srrh } 5527071Srrh wp--; 5537071Srrh } 5547071Srrh if((wne > nel) && 5557071Srrh !hyoff && hyf && 5567071Srrh (!nwd || (nel > 3*sps)) && 5577071Srrh (!(hyf & 02) || (findt1() > lss)) 5587071Srrh )hyphen(wp); 5597071Srrh savwch = wch; 5607071Srrh hyp = hyptr; 5617071Srrh nhyp = 0; 5627071Srrh while(*hyp && (*hyp <= wp))hyp++; 5637071Srrh while(wch){ 5647071Srrh if((hyoff != 1) && (*hyp == wp)){ 5657071Srrh hyp++; 5667071Srrh if(!wdstart || 5677071Srrh ((wp > (wdstart+1)) && 5687071Srrh (wp < wdend) && 5697071Srrh (!(hyf & 04) || (wp < (wdend-1))) && 5707071Srrh (!(hyf & 010) || (wp > (wdstart+2))) 5717071Srrh ) 5727071Srrh ){ 5737071Srrh nhyp++; 5747071Srrh storeline(IMP,0); 5757071Srrh } 5767071Srrh } 5777071Srrh i = *wp++; 5787071Srrh w = width(i); 5797071Srrh wne -= w; 5807071Srrh wch--; 5817071Srrh storeline(i,w); 5827071Srrh } 5837071Srrh if(nel >= 0){ 5847071Srrh nwd++; 5857071Srrh return(0); 5867071Srrh } 5877071Srrh xbitf = 1; 5887071Srrh hys = width(0200); /*hyphen*/ 5897071Srrh m1: 5907071Srrh if(!nhyp){ 5917071Srrh if(!nwd)goto m3; 5927071Srrh if(wch == savwch)goto m4; 5937071Srrh } 5947071Srrh if(*--linep != IMP)goto m5; 5957071Srrh if(!(--nhyp)) 5967071Srrh if(!nwd)goto m2; 5977071Srrh if(nel < hys){ 5987071Srrh nc--; 5997071Srrh goto m1; 6007071Srrh } 6017071Srrh m2: 6027071Srrh if(((i = *(linep-1) & CMASK) != '-') && 6037071Srrh (i != 0203) 6047071Srrh ){ 6057071Srrh *linep = (*(linep-1) & ~CMASK) | 0200; 6067071Srrh w = width(*linep); 6077071Srrh nel -= w; 6087071Srrh ne += w; 6097071Srrh linep++; 6107071Srrh /* 6117071Srrh hsend(); 6127071Srrh */ 6137071Srrh } 6147071Srrh m3: 6157071Srrh nwd++; 6167071Srrh m4: 6177071Srrh wordp = wp; 6187071Srrh return(1); 6197071Srrh m5: 6207071Srrh nc--; 6217071Srrh w = width(*linep); 6227071Srrh ne -= w; 6237071Srrh nel += w; 6247071Srrh wne += w; 6257071Srrh wch++; 6267071Srrh wp--; 6277071Srrh goto m1; 6287071Srrh } 6297071Srrh horiz(i) 6307071Srrh int i; 6317071Srrh { 6327071Srrh vflag = 0; 6337071Srrh if(i)pchar(makem(i)); 6347071Srrh } 6357071Srrh setnel(){ 6367071Srrh if(!nc){ 6377071Srrh linep = line; 6387071Srrh if(un1 >= 0){ 6397071Srrh un = un1; 6407071Srrh un1 = -1; 6417071Srrh } 6427071Srrh nel = ll - un; 6437071Srrh ne = adsp = adrem = 0; 6447071Srrh } 6457071Srrh } 6467071Srrh getword(x) 6477071Srrh int x; 6487071Srrh { 6497071Srrh register i, j, swp; 6507071Srrh int noword; 6517071Srrh 6527071Srrh noword = 0; 6537071Srrh if(x)if(pendw){ 6547071Srrh *pendw = 0; 6557071Srrh goto rtn; 6567071Srrh } 6577071Srrh if(wordp = pendw)goto g1; 6587071Srrh hyp = hyptr; 6597071Srrh wordp = word; 6607071Srrh over = wne = wch = 0; 6617071Srrh hyoff = 0; 6627071Srrh while(1){ 6637071Srrh j = (i = GETCH()) & CMASK; 6647071Srrh if(j == '\n'){ 6657071Srrh wne = wch = 0; 6667071Srrh noword = 1; 6677071Srrh goto rtn; 6687071Srrh } 6697071Srrh if(j == ohc){ 6707071Srrh hyoff = 1; 6717071Srrh continue; 6727071Srrh } 6737071Srrh if(j == ' '){ 6747071Srrh storeword(i,width(i)); /* XXX */ 6757071Srrh continue; 6767071Srrh } 6777071Srrh break; 6787071Srrh } 6797071Srrh swp = widthp; 6807071Srrh storeword(' ' | chbits, -1); 6817071Srrh if(spflg){ 6827071Srrh storeword(' ' | chbits, -1); 6837071Srrh spflg = 0; 6847071Srrh } 6857071Srrh widthp = swp; 6867071Srrh g0: 6877071Srrh if(j == CONT){ 6887071Srrh pendw = wordp; 6897071Srrh nflush = 0; 6907071Srrh flushi(); 6917071Srrh return(1); 6927071Srrh } 6937071Srrh if(hyoff != 1){ 6947071Srrh if(j == ohc){ 6957071Srrh hyoff = 2; 6967071Srrh *hyp++ = wordp; 6977071Srrh if(hyp > (hyptr+NHYP-1))hyp = hyptr+NHYP-1; 6987071Srrh goto g1; 6997071Srrh } 7007071Srrh if((j == '-') || 7017071Srrh (j == 0203) /*3/4 Em dash*/ 7027071Srrh )if(wordp > word+1){ 7037071Srrh hyoff = 2; 7047071Srrh *hyp++ = wordp + 1; 7057071Srrh if(hyp > (hyptr+NHYP-1))hyp = hyptr+NHYP-1; 7067071Srrh } 7077071Srrh } 7087071Srrh storeword(i,width(i)); /* XXX */ 7097071Srrh g1: 7107071Srrh j = (i = GETCH()) & CMASK; 7117071Srrh if(j != ' '){ 7127071Srrh if(j != '\n')goto g0; 7137071Srrh j = *(wordp-1) & CMASK; 7147071Srrh if((j == '.') || 7157071Srrh (j == '!') || 7167071Srrh (j == '?'))spflg++; 7177071Srrh } 7187071Srrh *wordp = 0; 7197071Srrh rtn: 7207071Srrh wdstart = 0; 7217071Srrh wordp = word; 7227071Srrh pendw = 0; 7237071Srrh *hyp++ = 0; 7247071Srrh setnel(); 7257071Srrh return(noword); 7267071Srrh } 7277071Srrh storeword(c,w) 7287071Srrh int c, w; 7297071Srrh { 7307071Srrh 7317071Srrh if(wordp >= &word[WDSIZE - 1]){ 7327071Srrh if(!over){ 7337071Srrh prstrfl("Word overflow.\n"); 7347071Srrh over++; 7357071Srrh c = 0343; 7367071Srrh w = -1; 7377071Srrh goto s1; 7387071Srrh } 7397071Srrh return; 7407071Srrh } 7417071Srrh s1: 7427071Srrh if(w == -1)w = width(c); 7437071Srrh wne += w; 7447071Srrh *wordp++ = c; 7457071Srrh wch++; 7467071Srrh } 7477071Srrh #ifdef NROFF 7487071Srrh extern char trtab[]; 7497071Srrh gettch(){ 7507071Srrh register int i, j; 7517071Srrh 7527071Srrh if(!((i = getch()) & MOT) && (i & ulbit)){ 7537071Srrh j = i&CMASK; 7547071Srrh if(cu && (trtab[j] == ' ')) 7557071Srrh i = ((i & ~ulbit)& ~CMASK) | '_'; 7567071Srrh if(!cu && (j>32) && (j<0370) && !(*t.codetab[j-32] & 0200)) 7577071Srrh i &= ~ulbit; 7587071Srrh } 7597071Srrh return(i); 7607071Srrh } 7617071Srrh #endif 762