17071Srrh #ifndef lint 2*32270Sbostic static char sccsid[] = "@(#)n7.c 4.2 09/28/87"; 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; 426*32270Sbostic 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++; 4417071Srrh pfrom = -1; 4427071Srrh }else if(opn == pto){ 4437071Srrh print = 0; 4447071Srrh opn = -1; 4457071Srrh chkpn(); 4467071Srrh goto nlpn; 4477071Srrh } 4487071Srrh if(stop && print){ 4497071Srrh dpn++; 4507071Srrh if(dpn >= stop){ 4517071Srrh dpn = 0; 4527071Srrh dostop(); 4537071Srrh } 4547071Srrh } 4557071Srrh nl2: 4567071Srrh trap = 0; 4577071Srrh if(v.nl == 0){ 4587071Srrh if((j = findn(0)) != NTRAP) 4597071Srrh trap = control(mlist[j],0); 4607071Srrh } else if((i = findt(v.nl-nlss)) <= nlss){ 4617071Srrh if((j = findn1(v.nl-nlss+i)) == NTRAP){ 4627071Srrh prstrfl("Trap botch.\n"); 4637071Srrh done2(-5); 4647071Srrh } 4657071Srrh trap = control(mlist[j],0); 4667071Srrh } 4677071Srrh } 4687071Srrh findn1(a) 4697071Srrh int a; 4707071Srrh { 4717071Srrh register i, j; 4727071Srrh 4737071Srrh for(i=0; i<NTRAP; i++){ 4747071Srrh if(mlist[i]){ 4757071Srrh if((j = nlist[i]) < 0)j += pl; 4767071Srrh if(j == a)break; 4777071Srrh } 4787071Srrh } 4797071Srrh return(i); 4807071Srrh } 4817071Srrh chkpn(){ 4827071Srrh pto = *(pnp++); 4837071Srrh pfrom = pto & ~MOT; 4847071Srrh if(pto == -1){ 4857071Srrh flusho(); 4867071Srrh done1(0); 4877071Srrh } 4887071Srrh if(pto & MOT){ 4897071Srrh pto &= ~MOT; 4907071Srrh print++; 4917071Srrh pfrom = 0; 4927071Srrh } 4937071Srrh } 4947071Srrh findt(a) 4957071Srrh int a; 4967071Srrh { 4977071Srrh register i, j, k; 4987071Srrh 4997071Srrh k = 32767; 5007071Srrh if(dip != d){ 5017071Srrh if(dip->dimac && ((i = dip->ditrap -a) > 0))k = i; 5027071Srrh return(k); 5037071Srrh } 5047071Srrh for(i=0; i<NTRAP; i++){ 5057071Srrh if(mlist[i]){ 5067071Srrh if((j = nlist[i]) < 0)j += pl; 5077071Srrh if((j -= a) <= 0)continue; 5087071Srrh if(j < k)k = j; 5097071Srrh } 5107071Srrh } 5117071Srrh i = pl - a; 5127071Srrh if(k > i)k = i; 5137071Srrh return(k); 5147071Srrh } 5157071Srrh findt1(){ 5167071Srrh register i; 5177071Srrh 5187071Srrh if(dip != d)i = dip->dnl; 5197071Srrh else i = v.nl; 5207071Srrh return(findt(i)); 5217071Srrh } 5227071Srrh eject(a) 5237071Srrh struct s *a; 5247071Srrh { 5257071Srrh register savlss; 5267071Srrh 5277071Srrh if(dip != d)return; 5287071Srrh ejf++; 5297071Srrh if(a)ejl = a; 5307071Srrh else ejl = frame; 5317071Srrh if(trap)return; 5327071Srrh e1: 5337071Srrh savlss = lss; 5347071Srrh lss = findt(v.nl); 5357071Srrh newline(0); 5367071Srrh lss = savlss; 5377071Srrh if(v.nl && !trap)goto e1; 5387071Srrh } 5397071Srrh movword(){ 5407071Srrh register i, w, *wp; 5417071Srrh int savwch, hys; 5427071Srrh 5437071Srrh over = 0; 5447071Srrh wp = wordp; 5457071Srrh if(!nwd){ 5467071Srrh while(((i = *wp++) & CMASK) == ' '){ 5477071Srrh wch--; 5487071Srrh wne -= width(i); 5497071Srrh } 5507071Srrh wp--; 5517071Srrh } 5527071Srrh if((wne > nel) && 5537071Srrh !hyoff && hyf && 5547071Srrh (!nwd || (nel > 3*sps)) && 5557071Srrh (!(hyf & 02) || (findt1() > lss)) 5567071Srrh )hyphen(wp); 5577071Srrh savwch = wch; 5587071Srrh hyp = hyptr; 5597071Srrh nhyp = 0; 5607071Srrh while(*hyp && (*hyp <= wp))hyp++; 5617071Srrh while(wch){ 5627071Srrh if((hyoff != 1) && (*hyp == wp)){ 5637071Srrh hyp++; 5647071Srrh if(!wdstart || 5657071Srrh ((wp > (wdstart+1)) && 5667071Srrh (wp < wdend) && 5677071Srrh (!(hyf & 04) || (wp < (wdend-1))) && 5687071Srrh (!(hyf & 010) || (wp > (wdstart+2))) 5697071Srrh ) 5707071Srrh ){ 5717071Srrh nhyp++; 5727071Srrh storeline(IMP,0); 5737071Srrh } 5747071Srrh } 5757071Srrh i = *wp++; 5767071Srrh w = width(i); 5777071Srrh wne -= w; 5787071Srrh wch--; 5797071Srrh storeline(i,w); 5807071Srrh } 5817071Srrh if(nel >= 0){ 5827071Srrh nwd++; 5837071Srrh return(0); 5847071Srrh } 5857071Srrh xbitf = 1; 5867071Srrh hys = width(0200); /*hyphen*/ 5877071Srrh m1: 5887071Srrh if(!nhyp){ 5897071Srrh if(!nwd)goto m3; 5907071Srrh if(wch == savwch)goto m4; 5917071Srrh } 5927071Srrh if(*--linep != IMP)goto m5; 5937071Srrh if(!(--nhyp)) 5947071Srrh if(!nwd)goto m2; 5957071Srrh if(nel < hys){ 5967071Srrh nc--; 5977071Srrh goto m1; 5987071Srrh } 5997071Srrh m2: 6007071Srrh if(((i = *(linep-1) & CMASK) != '-') && 6017071Srrh (i != 0203) 6027071Srrh ){ 6037071Srrh *linep = (*(linep-1) & ~CMASK) | 0200; 6047071Srrh w = width(*linep); 6057071Srrh nel -= w; 6067071Srrh ne += w; 6077071Srrh linep++; 6087071Srrh /* 6097071Srrh hsend(); 6107071Srrh */ 6117071Srrh } 6127071Srrh m3: 6137071Srrh nwd++; 6147071Srrh m4: 6157071Srrh wordp = wp; 6167071Srrh return(1); 6177071Srrh m5: 6187071Srrh nc--; 6197071Srrh w = width(*linep); 6207071Srrh ne -= w; 6217071Srrh nel += w; 6227071Srrh wne += w; 6237071Srrh wch++; 6247071Srrh wp--; 6257071Srrh goto m1; 6267071Srrh } 6277071Srrh horiz(i) 6287071Srrh int i; 6297071Srrh { 6307071Srrh vflag = 0; 6317071Srrh if(i)pchar(makem(i)); 6327071Srrh } 6337071Srrh setnel(){ 6347071Srrh if(!nc){ 6357071Srrh linep = line; 6367071Srrh if(un1 >= 0){ 6377071Srrh un = un1; 6387071Srrh un1 = -1; 6397071Srrh } 6407071Srrh nel = ll - un; 6417071Srrh ne = adsp = adrem = 0; 6427071Srrh } 6437071Srrh } 6447071Srrh getword(x) 6457071Srrh int x; 6467071Srrh { 6477071Srrh register i, j, swp; 6487071Srrh int noword; 6497071Srrh 6507071Srrh noword = 0; 6517071Srrh if(x)if(pendw){ 6527071Srrh *pendw = 0; 6537071Srrh goto rtn; 6547071Srrh } 6557071Srrh if(wordp = pendw)goto g1; 6567071Srrh hyp = hyptr; 6577071Srrh wordp = word; 6587071Srrh over = wne = wch = 0; 6597071Srrh hyoff = 0; 6607071Srrh while(1){ 6617071Srrh j = (i = GETCH()) & CMASK; 6627071Srrh if(j == '\n'){ 6637071Srrh wne = wch = 0; 6647071Srrh noword = 1; 6657071Srrh goto rtn; 6667071Srrh } 6677071Srrh if(j == ohc){ 6687071Srrh hyoff = 1; 6697071Srrh continue; 6707071Srrh } 6717071Srrh if(j == ' '){ 6727071Srrh storeword(i,width(i)); /* XXX */ 6737071Srrh continue; 6747071Srrh } 6757071Srrh break; 6767071Srrh } 6777071Srrh swp = widthp; 6787071Srrh storeword(' ' | chbits, -1); 6797071Srrh if(spflg){ 6807071Srrh storeword(' ' | chbits, -1); 6817071Srrh spflg = 0; 6827071Srrh } 6837071Srrh widthp = swp; 6847071Srrh g0: 6857071Srrh if(j == CONT){ 6867071Srrh pendw = wordp; 6877071Srrh nflush = 0; 6887071Srrh flushi(); 6897071Srrh return(1); 6907071Srrh } 6917071Srrh if(hyoff != 1){ 6927071Srrh if(j == ohc){ 6937071Srrh hyoff = 2; 6947071Srrh *hyp++ = wordp; 6957071Srrh if(hyp > (hyptr+NHYP-1))hyp = hyptr+NHYP-1; 6967071Srrh goto g1; 6977071Srrh } 6987071Srrh if((j == '-') || 6997071Srrh (j == 0203) /*3/4 Em dash*/ 7007071Srrh )if(wordp > word+1){ 7017071Srrh hyoff = 2; 7027071Srrh *hyp++ = wordp + 1; 7037071Srrh if(hyp > (hyptr+NHYP-1))hyp = hyptr+NHYP-1; 7047071Srrh } 7057071Srrh } 7067071Srrh storeword(i,width(i)); /* XXX */ 7077071Srrh g1: 7087071Srrh j = (i = GETCH()) & CMASK; 7097071Srrh if(j != ' '){ 7107071Srrh if(j != '\n')goto g0; 7117071Srrh j = *(wordp-1) & CMASK; 7127071Srrh if((j == '.') || 7137071Srrh (j == '!') || 7147071Srrh (j == '?'))spflg++; 7157071Srrh } 7167071Srrh *wordp = 0; 7177071Srrh rtn: 7187071Srrh wdstart = 0; 7197071Srrh wordp = word; 7207071Srrh pendw = 0; 7217071Srrh *hyp++ = 0; 7227071Srrh setnel(); 7237071Srrh return(noword); 7247071Srrh } 7257071Srrh storeword(c,w) 7267071Srrh int c, w; 7277071Srrh { 7287071Srrh 7297071Srrh if(wordp >= &word[WDSIZE - 1]){ 7307071Srrh if(!over){ 7317071Srrh prstrfl("Word overflow.\n"); 7327071Srrh over++; 7337071Srrh c = 0343; 7347071Srrh w = -1; 7357071Srrh goto s1; 7367071Srrh } 7377071Srrh return; 7387071Srrh } 7397071Srrh s1: 7407071Srrh if(w == -1)w = width(c); 7417071Srrh wne += w; 7427071Srrh *wordp++ = c; 7437071Srrh wch++; 7447071Srrh } 7457071Srrh #ifdef NROFF 7467071Srrh extern char trtab[]; 7477071Srrh gettch(){ 7487071Srrh register int i, j; 7497071Srrh 7507071Srrh if(!((i = getch()) & MOT) && (i & ulbit)){ 7517071Srrh j = i&CMASK; 7527071Srrh if(cu && (trtab[j] == ' ')) 7537071Srrh i = ((i & ~ulbit)& ~CMASK) | '_'; 7547071Srrh if(!cu && (j>32) && (j<0370) && !(*t.codetab[j-32] & 0200)) 7557071Srrh i &= ~ulbit; 7567071Srrh } 7577071Srrh return(i); 7587071Srrh } 7597071Srrh #endif 760