26 if (dip
== d
&& numtabp
[NL
].val
== -1) {
37 } else if (pendw
&& !brflg
) {
41 *linep
= dip
->nls
= 0;
42 if (NROFF
&& dip
== d
)
50 if ((lastl
= ll
- un
) < ne
)
53 if (admod
&& ad
&& (brflg
!= 2)) {
57 un
+= quant(nel
/ 2, HOR
);
63 if (lastl
+ un
> dip
->maxl
)
64 dip
->maxl
= lastl
+ un
;
74 lastl
= ne
+ (nwd
-1) * adsp
+ adrem
;
75 for (i
= line
; nc
> 0; ) {
76 if ((cbits(j
= *i
++)) == ' ') {
81 } while ((cbits(j
= *i
++)) == ' ');
89 } else if ((totout
& 01) || adrem
/ resol
>= nwd
) {
94 pchar((Tchar
) WORDSP
);
102 if ((k
= ll
- un0
- lastl
+ ics
) > 0)
115 if (dip
->dnl
> dip
->hnl
)
118 if (numtabp
[NL
].val
> dip
->hnl
)
119 dip
->hnl
= numtabp
[NL
].val
;
121 for (k
= ls
- 1; k
> 0 && !trap
; k
--)
129 int lnv
= numtabp
[LN
].val
;
132 nw
= width('1' | nrbits
);
140 un
+= nw
* (nmwid
+ nms
+ ni
);
144 do { /* count digits in numtabp[LN].val */
146 } while ((lnv
/= 10) > 0);
147 horiz(nw
* (ni
+ max(nmwid
-i
, 0)));
149 fnumb(numtabp
[LN
].val
, pchar
);
162 if ((dip
== d
) && (numtabp
[NL
].val
== -1)) {
181 while ((cbits(i
= GETCH())) == ' ') {
183 numtabp
[HP
].val
+= sps
;
188 nflush
= pendt
= ch
= spcnt
= 0;
223 adsp
= nel
/ (nwd
- 1);
224 adsp
= (adsp
/ HOR
) * HOR
;
225 adrem
= nel
- adsp
*(nwd
-1);
260 while ((j
= (cbits(i
= GETCH()))) != '\n') {
272 numtabp
[HP
].val
+= j
;
277 if ((i
= quant(nel
/ 2, HOR
)) > 0)
281 storeline((Tchar
)FILLER
, 0);
305 if (ul
&& (--ul
== 0)) {
310 if (it
&& --it
== 0 && itmac
)
315 void storeline(Tchar c
, int w
)
319 if (linep
>= line
+ lnsize
- 2) {
322 if (( line
= (Tchar
*)realloc((char *)line
, lnsize
* sizeof(Tchar
))) != NULL
) {
330 ERROR
"Line overflow." WARN
;
363 dip
->blss
= flss
= 0;
366 pchar1((Tchar
)dip
->alss
);
368 dip
->dnl
+= dip
->alss
;
371 if (dip
->ditrap
&& !dip
->ditf
&& dip
->dnl
>= dip
->ditrap
&& dip
->dimac
)
372 if (control(dip
->dimac
, 0)) {
381 nlss
= dip
->alss
+ dip
->blss
+ lss
;
382 numtabp
[NL
].val
+= nlss
;
383 if (TROFF
&& ascii
) {
384 dip
->alss
= dip
->blss
= 0;
389 if (numtabp
[NL
].val
< pl
)
392 ejf
= dip
->hnl
= numtabp
[NL
].val
= 0;
395 if ((!nc
&& !wch
) || ndone
)
402 opn
= numtabp
[PN
].val
;
405 numtabp
[PN
].val
= npn
;
409 if (numtabp
[PN
].val
== pfrom
) {
412 } else if (opn
== pto
) {
419 ptpage(numtabp
[PN
].val
); /* supposedly in a clean state so can pause */
429 if (numtabp
[NL
].val
== 0) {
430 if ((j
= findn(0)) != NTRAP
)
431 trap
= control(mlist
[j
], 0);
432 } else if ((i
= findt(numtabp
[NL
].val
- nlss
)) <= nlss
) {
433 if ((j
= findn1(numtabp
[NL
].val
- nlss
+ i
)) == NTRAP
) {
435 ERROR
"Trap botch." WARN
;
438 trap
= control(mlist
[j
], 0);
447 for (i
= 0; i
< NTRAP
; i
++) {
449 if ((j
= nlist
[i
]) < 0)
462 pfrom
= pto
>=0 ? pto
: -pto
;
463 if (pto
== -INT_MAX
) {
481 if (dip
->dimac
&& (i
= dip
->ditrap
- a
) > 0)
485 for (i
= 0; i
< NTRAP
; i
++) {
487 if ((j
= nlist
[i
]) < 0)
529 lss
= findt(numtabp
[NL
].val
);
532 if (numtabp
[NL
].val
&& !trap
)
546 while (cbits(*wp
++) == ' ') {
552 if (wne
> nel
&& !hyoff
&& hyf
&& (!nwd
|| nel
> 3 * sps
) &&
553 (!(hyf
& 02) || (findt1() > lss
)))
558 while (*hyp
&& *hyp
<= wp
)
561 if (hyoff
!= 1 && *hyp
== wp
) {
563 if (!wdstart
|| (wp
> wdstart
+ 1 && wp
< wdend
&&
564 (!(hyf
& 04) || wp
< wdend
- 1) && /* 04 => last 2 */
565 (!(hyf
& 010) || wp
> wdstart
+ 2))) { /* 010 => 1st 2 */
567 storeline((Tchar
)IMP
, 0);
578 return 0; /* line didn't fill up */
581 xbits((Tchar
)HYPHEN
, 1);
582 hys
= width((Tchar
)HYPHEN
);
600 if ((i
= cbits(*(linep
- 1))) != '-' && i
!= EMDASH
) {
601 *linep
= (*(linep
- 1) & SFMASK
) | HYPHEN
;
611 return(1); /* line filled up */
641 ne
= adsp
= adrem
= 0;
663 over
= wne
= wch
= 0;
666 while (1) { /* picks up 1st char of word */
667 j
= cbits(i
= GETCH());
674 hyoff
= 1; /* 1 => don't hyphenate */
678 numtabp
[HP
].val
+= sps
;
685 storeword(' ' | obits
, sps
);
687 storeword(' ' | obits
, sps
);
701 if (hyp
> hyptr
+ NHYP
- 1)
702 hyp
= hyptr
+ NHYP
- 1;
705 if (((j
== '-' || j
== EMDASH
)) && !(i
& ZBIT
)) /* zbit avoids \X */
706 if (wordp
> word
+ 1) {
709 if (hyp
> hyptr
+ NHYP
- 1)
710 hyp
= hyptr
+ NHYP
- 1;
714 numtabp
[HP
].val
+= j
;
717 j
= cbits(i
= GETCH());
719 static char *sentchar
= ".?!"; /* sentence terminators */
722 wp
= wordp
-1; /* handle extra space at end of sentence */
725 if (j
=='"' || j
=='\'' || j
==')' || j
==']' || j
=='*' || j
==DAGGER
)
727 for (k
= 0; sentchar
[k
]; k
++)
728 if (j
== sentchar
[k
]) {
736 numtabp
[HP
].val
+= sps
;
738 for (wp
= word
; *wp
; wp
++) {
740 break; /* drechsler */
744 if (!(isascii(j
) && isdigit(j
)) && j
!= '-')
747 if (*wp
== 0) /* all numbers, so don't hyphenate */
758 void storeword(Tchar c
, int w
)
763 if (wordp
>= word
+ wdsize
- 2) {
766 if (( word
= (Tchar
*)realloc((char *)word
, wdsize
* sizeof(Tchar
))) != NULL
) {
768 wordp
= word
+ (wordp
- savp
);
770 pendw
= word
+ (pendw
- savp
);
772 wdstart
= word
+ (wdstart
- savp
);
774 wdend
= word
+ (wdend
- savp
);
775 for (i
= 0; i
< NHYP
; i
++)
777 hyptr
[i
] = word
+ (hyptr
[i
] - savp
);
783 ERROR
"Word overflow." WARN
;
799 extern int c_isalnum
;
808 if (ismot(i
) || fbits(i
) != ulfont
)
811 if (trtab
[j
] == ' ') {
813 setfbits(i
, FT
); /* default */
817 /* should test here for characters that ought to be underlined */
818 /* in the old nroff, that was the 200 bit on the width! */
819 /* for now, just do letters, digits and certain special chars */