source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Prepare the terminal driver for filling multiple columns in
@ 2017-06-07 20:01 schwarze
  0 siblings, 0 replies; 2+ messages in thread
From: schwarze @ 2017-06-07 20:01 UTC (permalink / raw)
  To: source

Log Message:
-----------
Prepare the terminal driver for filling multiple columns in parallel,
second step: make the per-column byte pointer persistent across
term_flushln() calls, such that a subsequent call can continue at
the point where the previous call left.  If more than one column 
is in use, return from term_flushln() when the column is full, 
rather than breaking the output line.

No functional change, because nothing sets up multiple columns yet.

Modified Files:
--------------
    mdocml:
        term.c
        term.h

Revision Data
-------------
Index: term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/term.c,v
retrieving revision 1.266
retrieving revision 1.267
diff -Lterm.c -Lterm.c -u -p -r1.266 -r1.267
--- term.c
+++ term.c
@@ -95,7 +95,6 @@ term_end(struct termp *p)
 void
 term_flushln(struct termp *p)
 {
-	size_t		 i;     /* current input position in p->tcol->buf */
 	size_t		 vis;   /* current visual position on output */
 	size_t		 vbl;   /* number of blanks to prepend to output */
 	size_t		 vend;	/* end of word visual position on output */
@@ -116,20 +115,24 @@ term_flushln(struct termp *p)
 	    p->maxrmargin > p->viscol + vbl ?
 	    p->maxrmargin - p->viscol - vbl : 0;
 	vis = vend = 0;
-	i = 0;
 
-	while (i < p->lastcol) {
+	if (p->lasttcol == 0)
+		p->tcol->col = 0;
+	while (p->tcol->col < p->lastcol) {
+
 		/*
 		 * Handle literal tab characters: collapse all
 		 * subsequent tabs into a single huge set of spaces.
 		 */
+
 		ntab = 0;
-		while (i < p->lastcol && p->tcol->buf[i] == '\t') {
+		while (p->tcol->col < p->lastcol &&
+		    p->tcol->buf[p->tcol->col] == '\t') {
 			vend = term_tab_next(vis);
 			vbl += vend - vis;
 			vis = vend;
 			ntab++;
-			i++;
+			p->tcol->col++;
 		}
 
 		/*
@@ -139,7 +142,8 @@ term_flushln(struct termp *p)
 		 * space is printed according to regular spacing rules).
 		 */
 
-		for (j = i, jhy = 0; j < p->lastcol; j++) {
+		jhy = 0;
+		for (j = p->tcol->col; j < p->lastcol; j++) {
 			if (p->tcol->buf[j] == ' ' || p->tcol->buf[j] == '\t')
 				break;
 
@@ -171,10 +175,14 @@ term_flushln(struct termp *p)
 		 * Find out whether we would exceed the right margin.
 		 * If so, break to the next line.
 		 */
-		if (vend > bp && 0 == jhy && vis > 0 &&
+
+		if (vend > bp && jhy == 0 && vis > 0 &&
 		    (p->flags & TERMP_BRNEVER) == 0) {
-			vend -= vis;
+			if (p->lasttcol)
+				return;
+
 			endline(p);
+			vend -= vis;
 
 			/* Use pending tabs on the new line. */
 
@@ -194,27 +202,30 @@ term_flushln(struct termp *p)
 			    p->maxrmargin > vbl ?  p->maxrmargin - vbl : 0;
 		}
 
-		/* Write out the [remaining] word. */
-		for ( ; i < p->lastcol; i++) {
-			if (vend > bp && jhy > 0 && i > jhy)
+		/*
+		 * Write out the rest of the word.
+		 */
+
+		for ( ; p->tcol->col < p->lastcol; p->tcol->col++) {
+			if (vend > bp && jhy > 0 && p->tcol->col > jhy)
 				break;
-			if (p->tcol->buf[i] == '\t')
+			if (p->tcol->buf[p->tcol->col] == '\t')
 				break;
-			if (p->tcol->buf[i] == ' ') {
-				j = i;
-				while (i < p->lastcol &&
-				    p->tcol->buf[i] == ' ')
-					i++;
-				dv = (i - j) * (*p->width)(p, ' ');
+			if (p->tcol->buf[p->tcol->col] == ' ') {
+				j = p->tcol->col;
+				while (p->tcol->col < p->lastcol &&
+				    p->tcol->buf[p->tcol->col] == ' ')
+					p->tcol->col++;
+				dv = (p->tcol->col - j) * (*p->width)(p, ' ');
 				vbl += dv;
 				vend += dv;
 				break;
 			}
-			if (p->tcol->buf[i] == ASCII_NBRSP) {
+			if (p->tcol->buf[p->tcol->col] == ASCII_NBRSP) {
 				vbl += (*p->width)(p, ' ');
 				continue;
 			}
-			if (p->tcol->buf[i] == ASCII_BREAK)
+			if (p->tcol->buf[p->tcol->col] == ASCII_BREAK)
 				continue;
 
 			/*
@@ -228,11 +239,13 @@ term_flushln(struct termp *p)
 				vbl = 0;
 			}
 
-			(*p->letter)(p, p->tcol->buf[i]);
-			if (p->tcol->buf[i] == '\b')
-				p->viscol -= (*p->width)(p, p->tcol->buf[i-1]);
+			(*p->letter)(p, p->tcol->buf[p->tcol->col]);
+			if (p->tcol->buf[p->tcol->col] == '\b')
+				p->viscol -= (*p->width)(p,
+				    p->tcol->buf[p->tcol->col - 1]);
 			else
-				p->viscol += (*p->width)(p, p->tcol->buf[i]);
+				p->viscol += (*p->width)(p,
+				    p->tcol->buf[p->tcol->col]);
 		}
 		vis = vend;
 	}
@@ -241,6 +254,7 @@ term_flushln(struct termp *p)
 	 * If there was trailing white space, it was not printed;
 	 * so reset the cursor position accordingly.
 	 */
+
 	if (vis > vbl)
 		vis -= vbl;
 	else
@@ -251,6 +265,7 @@ term_flushln(struct termp *p)
 	p->flags &= ~(TERMP_BACKAFTER | TERMP_BACKBEFORE | TERMP_NOPAD);
 
 	/* Trailing whitespace is significant in some columns. */
+
 	if (vis && vbl && (TERMP_BRTRSP & p->flags))
 		vis += vbl;
 
Index: term.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/term.h,v
retrieving revision 1.125
retrieving revision 1.126
diff -Lterm.h -Lterm.h -u -p -r1.125 -r1.126
--- term.h
+++ term.h
@@ -52,6 +52,7 @@ struct	termp_tbl {
 struct	termp_col {
 	int		 *buf;		/* Output buffer. */
 	size_t		  maxcols;	/* Allocated bytes in buf. */
+	size_t		  col;		/* Byte in buf to be written. */
 	size_t		  rmargin;	/* Current right margin. */
 	size_t		  offset;	/* Current left margin. */
 };
@@ -61,6 +62,7 @@ struct	termp {
 	struct termp_col *tcols;	/* Array of table columns. */
 	struct termp_col *tcol;		/* Current table column. */
 	size_t		  maxtcol;	/* Allocated table columns. */
+	size_t		  lasttcol;	/* Last column currently used. */
 	size_t		  line;		/* Current output line number. */
 	size_t		  defindent;	/* Default indent for text. */
 	size_t		  defrmargin;	/* Right margin of the device. */
@@ -69,7 +71,7 @@ struct	termp {
 	size_t		  col;		/* Byte position in buf. */
 	size_t		  lastcol;	/* Bytes in buf. */
 	size_t		  viscol;	/* Chars on current line. */
-	size_t		  trailspace;	/* See termp_flushln(). */
+	size_t		  trailspace;	/* See term_flushln(). */
 	size_t		  minbl;	/* Minimum blanks before next field. */
 	int		  synopsisonly; /* Print the synopsis only. */
 	int		  mdocstyle;	/* Imitate mdoc(7) output. */
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] 2+ messages in thread

* mdocml: Prepare the terminal driver for filling multiple columns in
@ 2017-06-07 17:38 schwarze
  0 siblings, 0 replies; 2+ messages in thread
From: schwarze @ 2017-06-07 17:38 UTC (permalink / raw)
  To: source

Log Message:
-----------
Prepare the terminal driver for filling multiple columns in parallel, 
first step: split column data out of the terminal state struct into
a new column state struct and use an array of such column state 
structs.  No functional change.

Modified Files:
--------------
    mdocml:
        man_term.c
        mdoc_term.c
        roff_term.c
        tbl_term.c
        term.c
        term.h
        term_ascii.c
        term_ps.c

Revision Data
-------------
Index: mdoc_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_term.c,v
retrieving revision 1.361
retrieving revision 1.362
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.361 -r1.362
--- mdoc_term.c
+++ mdoc_term.c
@@ -259,7 +259,7 @@ terminal_mdoc(void *arg, const struct ro
 	size_t			 save_defindent;
 
 	p = (struct termp *)arg;
-	p->rmargin = p->maxrmargin = p->defrmargin;
+	p->tcol->rmargin = p->maxrmargin = p->defrmargin;
 	term_tab_set(p, NULL);
 	term_tab_set(p, "T");
 	term_tab_set(p, ".5i");
@@ -316,8 +316,8 @@ print_mdoc_node(DECL_ARGS)
 		return;
 
 	chld = 1;
-	offset = p->offset;
-	rmargin = p->rmargin;
+	offset = p->tcol->offset;
+	rmargin = p->tcol->rmargin;
 	n->flags &= ~NODE_ENDED;
 	n->prev_font = p->fonti;
 
@@ -407,8 +407,8 @@ print_mdoc_node(DECL_ARGS)
 		p->flags |= TERMP_SENTENCE;
 
 	if (n->type != ROFFT_TEXT)
-		p->offset = offset;
-	p->rmargin = rmargin;
+		p->tcol->offset = offset;
+	p->tcol->rmargin = rmargin;
 }
 
 static void
@@ -428,9 +428,9 @@ print_mdoc_foot(struct termp *p, const s
 
 	term_vspace(p);
 
-	p->offset = 0;
+	p->tcol->offset = 0;
 	sz = term_strlen(p, meta->date);
-	p->rmargin = p->maxrmargin > sz ?
+	p->tcol->rmargin = p->maxrmargin > sz ?
 	    (p->maxrmargin + term_len(p, 1) - sz) / 2 : 0;
 	p->trailspace = 1;
 	p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
@@ -438,16 +438,16 @@ print_mdoc_foot(struct termp *p, const s
 	term_word(p, meta->os);
 	term_flushln(p);
 
-	p->offset = p->rmargin;
+	p->tcol->offset = p->tcol->rmargin;
 	sz = term_strlen(p, meta->os);
-	p->rmargin = p->maxrmargin > sz ? p->maxrmargin - sz : 0;
+	p->tcol->rmargin = p->maxrmargin > sz ? p->maxrmargin - sz : 0;
 	p->flags |= TERMP_NOSPACE;
 
 	term_word(p, meta->date);
 	term_flushln(p);
 
-	p->offset = p->rmargin;
-	p->rmargin = p->maxrmargin;
+	p->tcol->offset = p->tcol->rmargin;
+	p->tcol->rmargin = p->maxrmargin;
 	p->trailspace = 0;
 	p->flags &= ~TERMP_NOBREAK;
 	p->flags |= TERMP_NOSPACE;
@@ -455,8 +455,8 @@ print_mdoc_foot(struct termp *p, const s
 	term_word(p, meta->os);
 	term_flushln(p);
 
-	p->offset = 0;
-	p->rmargin = p->maxrmargin;
+	p->tcol->offset = 0;
+	p->tcol->rmargin = p->maxrmargin;
 	p->flags = 0;
 }
 
@@ -496,8 +496,8 @@ print_mdoc_head(struct termp *p, const s
 
 	p->flags |= TERMP_NOBREAK | TERMP_NOSPACE;
 	p->trailspace = 1;
-	p->offset = 0;
-	p->rmargin = 2 * (titlen+1) + vollen < p->maxrmargin ?
+	p->tcol->offset = 0;
+	p->tcol->rmargin = 2 * (titlen+1) + vollen < p->maxrmargin ?
 	    (p->maxrmargin - vollen + term_len(p, 1)) / 2 :
 	    vollen < p->maxrmargin ?  p->maxrmargin - vollen : 0;
 
@@ -505,26 +505,26 @@ print_mdoc_head(struct termp *p, const s
 	term_flushln(p);
 
 	p->flags |= TERMP_NOSPACE;
-	p->offset = p->rmargin;
-	p->rmargin = p->offset + vollen + titlen < p->maxrmargin ?
-	    p->maxrmargin - titlen : p->maxrmargin;
+	p->tcol->offset = p->tcol->rmargin;
+	p->tcol->rmargin = p->tcol->offset + vollen + titlen <
+	    p->maxrmargin ? p->maxrmargin - titlen : p->maxrmargin;
 
 	term_word(p, volume);
 	term_flushln(p);
 
 	p->flags &= ~TERMP_NOBREAK;
 	p->trailspace = 0;
-	if (p->rmargin + titlen <= p->maxrmargin) {
+	if (p->tcol->rmargin + titlen <= p->maxrmargin) {
 		p->flags |= TERMP_NOSPACE;
-		p->offset = p->rmargin;
-		p->rmargin = p->maxrmargin;
+		p->tcol->offset = p->tcol->rmargin;
+		p->tcol->rmargin = p->maxrmargin;
 		term_word(p, title);
 		term_flushln(p);
 	}
 
 	p->flags &= ~TERMP_NOSPACE;
-	p->offset = 0;
-	p->rmargin = p->maxrmargin;
+	p->tcol->offset = 0;
+	p->tcol->rmargin = p->maxrmargin;
 	free(title);
 	free(volume);
 }
@@ -649,8 +649,8 @@ termp_it_pre(DECL_ARGS)
 
 	if (bl->norm->Bl.offs != NULL) {
 		offset = a2width(p, bl->norm->Bl.offs);
-		if (offset < 0 && (size_t)(-offset) > p->offset)
-			offset = -p->offset;
+		if (offset < 0 && (size_t)(-offset) > p->tcol->offset)
+			offset = -p->tcol->offset;
 		else if (offset > SHRT_MAX)
 			offset = 0;
 	}
@@ -714,8 +714,8 @@ termp_it_pre(DECL_ARGS)
 		 * handling for column for how this changes.
 		 */
 		width = a2width(p, bl->norm->Bl.width) + term_len(p, 2);
-		if (width < 0 && (size_t)(-width) > p->offset)
-			width = -p->offset;
+		if (width < 0 && (size_t)(-width) > p->tcol->offset)
+			width = -p->tcol->offset;
 		else if (width > SHRT_MAX)
 			width = 0;
 		break;
@@ -815,7 +815,7 @@ termp_it_pre(DECL_ARGS)
 	 * necessarily lengthened.  Everybody gets the offset.
 	 */
 
-	p->offset += offset;
+	p->tcol->offset += offset;
 
 	switch (type) {
 	case LIST_bullet:
@@ -825,21 +825,21 @@ termp_it_pre(DECL_ARGS)
 	case LIST_hang:
 	case LIST_tag:
 		if (n->type == ROFFT_HEAD)
-			p->rmargin = p->offset + width;
+			p->tcol->rmargin = p->tcol->offset + width;
 		else
-			p->offset += width;
+			p->tcol->offset += width;
 		break;
 	case LIST_column:
 		assert(width);
-		p->rmargin = p->offset + width;
+		p->tcol->rmargin = p->tcol->offset + width;
 		/*
 		 * XXX - this behaviour is not documented: the
 		 * right-most column is filled to the right margin.
 		 */
 		if (n->type == ROFFT_HEAD)
 			break;
-		if (NULL == n->next && p->rmargin < p->maxrmargin)
-			p->rmargin = p->maxrmargin;
+		if (n->next == NULL && p->tcol->rmargin < p->maxrmargin)
+			p->tcol->rmargin = p->maxrmargin;
 		break;
 	default:
 		break;
@@ -945,7 +945,7 @@ termp_nm_pre(DECL_ARGS)
 	}
 
 	if (n->type == ROFFT_BODY) {
-		if (NULL == n->child)
+		if (n->child == NULL)
 			return 0;
 		p->flags |= TERMP_NOSPACE;
 		cp = NULL;
@@ -954,9 +954,10 @@ termp_nm_pre(DECL_ARGS)
 		if (cp == NULL)
 			cp = meta->name;
 		if (cp == NULL)
-			p->offset += term_len(p, 6);
+			p->tcol->offset += term_len(p, 6);
 		else
-			p->offset += term_len(p, 1) + term_strlen(p, cp);
+			p->tcol->offset += term_len(p, 1) +
+			    term_strlen(p, cp);
 		return 1;
 	}
 
@@ -967,18 +968,18 @@ termp_nm_pre(DECL_ARGS)
 		synopsis_pre(p, n->parent);
 
 	if (n->type == ROFFT_HEAD &&
-	    NULL != n->next && NULL != n->next->child) {
+	    n->next != NULL && n->next->child != NULL) {
 		p->flags |= TERMP_NOSPACE | TERMP_NOBREAK | TERMP_BRIND;
 		p->trailspace = 1;
-		p->rmargin = p->offset + term_len(p, 1);
-		if (NULL == n->child) {
-			p->rmargin += term_strlen(p, meta->name);
-		} else if (n->child->type == ROFFT_TEXT) {
-			p->rmargin += term_strlen(p, n->child->string);
-			if (n->child->next)
+		p->tcol->rmargin = p->tcol->offset + term_len(p, 1);
+		if (n->child == NULL)
+			p->tcol->rmargin += term_strlen(p, meta->name);
+		else if (n->child->type == ROFFT_TEXT) {
+			p->tcol->rmargin += term_strlen(p, n->child->string);
+			if (n->child->next != NULL)
 				p->flags |= TERMP_HANG;
 		} else {
-			p->rmargin += term_len(p, 5);
+			p->tcol->rmargin += term_len(p, 5);
 			p->flags |= TERMP_HANG;
 		}
 	}
@@ -1250,7 +1251,7 @@ termp_sh_pre(DECL_ARGS)
 		term_fontpush(p, TERMFONT_BOLD);
 		break;
 	case ROFFT_BODY:
-		p->offset = term_len(p, p->defindent);
+		p->tcol->offset = term_len(p, p->defindent);
 		term_tab_set(p, NULL);
 		term_tab_set(p, "T");
 		term_tab_set(p, ".5i");
@@ -1281,7 +1282,7 @@ termp_sh_post(DECL_ARGS)
 		break;
 	case ROFFT_BODY:
 		term_newln(p);
-		p->offset = 0;
+		p->tcol->offset = 0;
 		break;
 	default:
 		break;
@@ -1303,7 +1304,7 @@ termp_d1_pre(DECL_ARGS)
 	if (n->type != ROFFT_BLOCK)
 		return 1;
 	term_newln(p);
-	p->offset += term_len(p, p->defindent + 1);
+	p->tcol->offset += term_len(p, p->defindent + 1);
 	term_tab_set(p, NULL);
 	term_tab_set(p, "T");
 	term_tab_set(p, ".5i");
@@ -1334,8 +1335,8 @@ termp_fn_pre(DECL_ARGS)
 		return 0;
 
 	if (pretty) {
-		rmargin = p->rmargin;
-		p->rmargin = p->offset + term_len(p, 4);
+		rmargin = p->tcol->rmargin;
+		p->tcol->rmargin = p->tcol->offset + term_len(p, 4);
 		p->flags |= TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG;
 	}
 
@@ -1351,8 +1352,8 @@ termp_fn_pre(DECL_ARGS)
 		term_flushln(p);
 		p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG);
 		p->flags |= TERMP_NOPAD;
-		p->offset = p->rmargin;
-		p->rmargin = rmargin;
+		p->tcol->offset = p->tcol->rmargin;
+		p->tcol->rmargin = rmargin;
 	}
 
 	p->flags |= TERMP_NOSPACE;
@@ -1429,15 +1430,15 @@ termp_bd_pre(DECL_ARGS)
 	    ! strcmp(n->norm->Bd.offs, "left"))
 		/* nothing */;
 	else if ( ! strcmp(n->norm->Bd.offs, "indent"))
-		p->offset += term_len(p, p->defindent + 1);
+		p->tcol->offset += term_len(p, p->defindent + 1);
 	else if ( ! strcmp(n->norm->Bd.offs, "indent-two"))
-		p->offset += term_len(p, (p->defindent + 1) * 2);
+		p->tcol->offset += term_len(p, (p->defindent + 1) * 2);
 	else {
 		offset = a2width(p, n->norm->Bd.offs);
-		if (offset < 0 && (size_t)(-offset) > p->offset)
-			p->offset = 0;
+		if (offset < 0 && (size_t)(-offset) > p->tcol->offset)
+			p->tcol->offset = 0;
 		else if (offset < SHRT_MAX)
-			p->offset += offset;
+			p->tcol->offset += offset;
 	}
 
 	/*
@@ -1448,9 +1449,9 @@ termp_bd_pre(DECL_ARGS)
 	 * lines are allowed.
 	 */
 
-	if (DISP_literal != n->norm->Bd.type &&
-	    DISP_unfilled != n->norm->Bd.type &&
-	    DISP_centered != n->norm->Bd.type)
+	if (n->norm->Bd.type != DISP_literal &&
+	    n->norm->Bd.type != DISP_unfilled &&
+	    n->norm->Bd.type != DISP_centered)
 		return 1;
 
 	if (n->norm->Bd.type == DISP_literal) {
@@ -1459,17 +1460,18 @@ termp_bd_pre(DECL_ARGS)
 		term_tab_set(p, "8n");
 	}
 
-	lm = p->offset;
+	lm = p->tcol->offset;
 	p->flags |= TERMP_BRNEVER;
-	for (nn = n->child; nn; nn = nn->next) {
-		if (DISP_centered == n->norm->Bd.type) {
+	for (nn = n->child; nn != NULL; nn = nn->next) {
+		if (n->norm->Bd.type == DISP_centered) {
 			if (nn->type == ROFFT_TEXT) {
 				len = term_strlen(p, nn->string);
-				p->offset = len >= p->rmargin ? 0 :
-				    lm + len >= p->rmargin ? p->rmargin - len :
-				    (lm + p->rmargin - len) / 2;
+				p->tcol->offset = len >= p->tcol->rmargin ?
+				    0 : lm + len >= p->tcol->rmargin ?
+				    p->tcol->rmargin - len :
+				    (lm + p->tcol->rmargin - len) / 2;
 			} else
-				p->offset = lm;
+				p->tcol->offset = lm;
 		}
 		print_mdoc_node(p, pair, meta, nn);
 		/*
@@ -1553,10 +1555,10 @@ termp_ss_pre(DECL_ARGS)
 		break;
 	case ROFFT_HEAD:
 		term_fontpush(p, TERMFONT_BOLD);
-		p->offset = term_len(p, (p->defindent+1)/2);
+		p->tcol->offset = term_len(p, (p->defindent+1)/2);
 		break;
 	case ROFFT_BODY:
-		p->offset = term_len(p, p->defindent);
+		p->tcol->offset = term_len(p, p->defindent);
 		term_tab_set(p, NULL);
 		term_tab_set(p, "T");
 		term_tab_set(p, ".5i");
@@ -1803,8 +1805,8 @@ termp_fo_pre(DECL_ARGS)
 		return 1;
 	} else if (n->type == ROFFT_BODY) {
 		if (pretty) {
-			rmargin = p->rmargin;
-			p->rmargin = p->offset + term_len(p, 4);
+			rmargin = p->tcol->rmargin;
+			p->tcol->rmargin = p->tcol->offset + term_len(p, 4);
 			p->flags |= TERMP_NOBREAK | TERMP_BRIND |
 					TERMP_HANG;
 		}
@@ -1816,8 +1818,8 @@ termp_fo_pre(DECL_ARGS)
 			p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND |
 					TERMP_HANG);
 			p->flags |= TERMP_NOPAD;
-			p->offset = p->rmargin;
-			p->rmargin = rmargin;
+			p->tcol->offset = p->tcol->rmargin;
+			p->tcol->rmargin = rmargin;
 		}
 		return 1;
 	}
@@ -1965,7 +1967,7 @@ termp_lk_pre(DECL_ARGS)
 	display = term_strlen(p, link->string) >= 26;
 	if (display) {
 		term_newln(p);
-		p->offset += term_len(p, p->defindent + 1);
+		p->tcol->offset += term_len(p, p->defindent + 1);
 	}
 	term_fontpush(p, TERMFONT_BOLD);
 	term_word(p, link->string);
Index: term_ps.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/term_ps.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -Lterm_ps.c -Lterm_ps.c -u -p -r1.84 -r1.85
--- term_ps.c
+++ term_ps.c
@@ -538,12 +538,15 @@ pspdf_alloc(const struct manoutput *outo
 	size_t		 marginx, marginy, lineheight;
 	const char	*pp;
 
-	p = mandoc_calloc(1, sizeof(struct termp));
+	p = mandoc_calloc(1, sizeof(*p));
+	p->tcol = p->tcols = mandoc_calloc(1, sizeof(*p->tcol));
+	p->maxtcol = 1;
+
 	p->enc = TERMENC_ASCII;
 	p->fontq = mandoc_reallocarray(NULL,
-	    (p->fontsz = 8), sizeof(enum termfont));
+	    (p->fontsz = 8), sizeof(*p->fontq));
 	p->fontq[0] = p->fontl = TERMFONT_NONE;
-	p->ps = mandoc_calloc(1, sizeof(struct termp_ps));
+	p->ps = mandoc_calloc(1, sizeof(*p->ps));
 
 	p->advance = ps_advance;
 	p->begin = ps_begin;
@@ -1220,7 +1223,7 @@ ps_endline(struct termp *p)
 
 	ps_closepage(p);
 
-	p->offset -= p->ti;
+	p->tcol->offset -= p->ti;
 	p->ti = 0;
 }
 
Index: tbl_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/tbl_term.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -Ltbl_term.c -Ltbl_term.c -u -p -r1.44 -r1.45
--- tbl_term.c
+++ tbl_term.c
@@ -80,21 +80,21 @@ term_tbl(struct termp *tp, const struct 
 		tp->tbl.slen = term_tbl_strlen;
 		tp->tbl.arg = tp;
 
-		tblcalc(&tp->tbl, sp, tp->rmargin - tp->offset);
+		tblcalc(&tp->tbl, sp, tp->tcol->rmargin - tp->tcol->offset);
 
 		/* Center the table as a whole. */
 
-		offset = tp->offset;
+		offset = tp->tcol->offset;
 		if (sp->opts->opts & TBL_OPT_CENTRE) {
 			tsz = sp->opts->opts & (TBL_OPT_BOX | TBL_OPT_DBOX)
 			    ? 2 : !!sp->opts->lvert + !!sp->opts->rvert;
 			for (ic = 0; ic < sp->opts->cols; ic++)
 				tsz += tp->tbl.cols[ic].width + 3;
 			tsz -= 3;
-			if (offset + tsz > tp->rmargin)
+			if (offset + tsz > tp->tcol->rmargin)
 				tsz -= 1;
-			tp->offset = (offset + tp->rmargin > tsz) ?
-			    (offset + tp->rmargin - tsz) / 2 : 0;
+			tp->tcol->offset = offset + tp->tcol->rmargin > tsz ?
+			    (offset + tp->tcol->rmargin - tsz) / 2 : 0;
 		}
 
 		/* Horizontal frame at the start of boxed tables. */
@@ -193,7 +193,7 @@ term_tbl(struct termp *tp, const struct 
 		assert(tp->tbl.cols);
 		free(tp->tbl.cols);
 		tp->tbl.cols = NULL;
-		tp->offset = offset;
+		tp->tcol->offset = offset;
 	}
 	tp->flags &= ~(TERMP_NONOSPACE | TERMP_BRNEVER);
 }
Index: term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/term.c,v
retrieving revision 1.265
retrieving revision 1.266
diff -Lterm.c -Lterm.c -u -p -r1.265 -r1.266
--- term.c
+++ term.c
@@ -32,7 +32,7 @@
 #include "main.h"
 
 static	size_t		 cond_width(const struct termp *, int, int *);
-static	void		 adjbuf(struct termp *p, size_t);
+static	void		 adjbuf(struct termp_col *, size_t);
 static	void		 bufferc(struct termp *, char);
 static	void		 encode(struct termp *, const char *, size_t);
 static	void		 encode1(struct termp *, int);
@@ -42,8 +42,9 @@ static	void		 endline(struct termp *);
 void
 term_free(struct termp *p)
 {
-
-	free(p->buf);
+	for (p->tcol = p->tcols; p->tcol < p->tcols + p->maxtcol; p->tcol++)
+		free(p->tcol->buf);
+	free(p->tcols);
 	free(p->fontq);
 	free(p);
 }
@@ -94,23 +95,23 @@ term_end(struct termp *p)
 void
 term_flushln(struct termp *p)
 {
-	size_t		 i;     /* current input position in p->buf */
-	int		 ntab;	/* number of tabs to prepend */
+	size_t		 i;     /* current input position in p->tcol->buf */
 	size_t		 vis;   /* current visual position on output */
 	size_t		 vbl;   /* number of blanks to prepend to output */
 	size_t		 vend;	/* end of word visual position on output */
 	size_t		 bp;    /* visual right border position */
 	size_t		 dv;    /* temporary for visual pos calculations */
-	size_t		 j;     /* temporary loop index for p->buf */
+	size_t		 j;     /* temporary loop index for p->tcol->buf */
 	size_t		 jhy;	/* last hyph before overflow w/r/t j */
 	size_t		 maxvis; /* output position of visible boundary */
+	int		 ntab;	/* number of tabs to prepend */
 
-	vbl = (p->flags & TERMP_NOPAD) || p->offset < p->viscol ? 0 :
-	    p->offset - p->viscol;
+	vbl = (p->flags & TERMP_NOPAD) || p->tcol->offset < p->viscol ?
+	    0 : p->tcol->offset - p->viscol;
 	if (p->minbl && vbl < p->minbl)
 		vbl = p->minbl;
-	maxvis = p->rmargin > p->viscol + vbl ?
-	    p->rmargin - p->viscol - vbl : 0;
+	maxvis = p->tcol->rmargin > p->viscol + vbl ?
+	    p->tcol->rmargin - p->viscol - vbl : 0;
 	bp = !(p->flags & TERMP_NOBREAK) ? maxvis :
 	    p->maxrmargin > p->viscol + vbl ?
 	    p->maxrmargin - p->viscol - vbl : 0;
@@ -123,7 +124,7 @@ term_flushln(struct termp *p)
 		 * subsequent tabs into a single huge set of spaces.
 		 */
 		ntab = 0;
-		while (i < p->lastcol && p->buf[i] == '\t') {
+		while (i < p->lastcol && p->tcol->buf[i] == '\t') {
 			vend = term_tab_next(vis);
 			vbl += vend - vis;
 			vis = vend;
@@ -139,31 +140,31 @@ term_flushln(struct termp *p)
 		 */
 
 		for (j = i, jhy = 0; j < p->lastcol; j++) {
-			if (' ' == p->buf[j] || '\t' == p->buf[j])
+			if (p->tcol->buf[j] == ' ' || p->tcol->buf[j] == '\t')
 				break;
 
 			/* Back over the last printed character. */
-			if (8 == p->buf[j]) {
+			if (p->tcol->buf[j] == '\b') {
 				assert(j);
-				vend -= (*p->width)(p, p->buf[j - 1]);
+				vend -= (*p->width)(p, p->tcol->buf[j - 1]);
 				continue;
 			}
 
 			/* Regular word. */
 			/* Break at the hyphen point if we overrun. */
 			if (vend > vis && vend < bp &&
-			    (ASCII_HYPH == p->buf[j] ||
-			     ASCII_BREAK == p->buf[j]))
+			    (p->tcol->buf[j] == ASCII_HYPH||
+			     p->tcol->buf[j] == ASCII_BREAK))
 				jhy = j;
 
 			/*
 			 * Hyphenation now decided, put back a real
 			 * hyphen such that we get the correct width.
 			 */
-			if (ASCII_HYPH == p->buf[j])
-				p->buf[j] = '-';
+			if (p->tcol->buf[j] == ASCII_HYPH)
+				p->tcol->buf[j] = '-';
 
-			vend += (*p->width)(p, p->buf[j]);
+			vend += (*p->width)(p, p->tcol->buf[j]);
 		}
 
 		/*
@@ -184,10 +185,11 @@ term_flushln(struct termp *p)
 			/* Re-establish indentation. */
 
 			if (p->flags & TERMP_BRIND)
-				vbl += p->rmargin;
+				vbl += p->tcol->rmargin;
 			else
-				vbl += p->offset;
-			maxvis = p->rmargin > vbl ? p->rmargin - vbl : 0;
+				vbl += p->tcol->offset;
+			maxvis = p->tcol->rmargin > vbl ?
+			    p->tcol->rmargin - vbl : 0;
 			bp = !(p->flags & TERMP_NOBREAK) ? maxvis :
 			    p->maxrmargin > vbl ?  p->maxrmargin - vbl : 0;
 		}
@@ -196,22 +198,23 @@ term_flushln(struct termp *p)
 		for ( ; i < p->lastcol; i++) {
 			if (vend > bp && jhy > 0 && i > jhy)
 				break;
-			if ('\t' == p->buf[i])
+			if (p->tcol->buf[i] == '\t')
 				break;
-			if (' ' == p->buf[i]) {
+			if (p->tcol->buf[i] == ' ') {
 				j = i;
-				while (i < p->lastcol && ' ' == p->buf[i])
+				while (i < p->lastcol &&
+				    p->tcol->buf[i] == ' ')
 					i++;
 				dv = (i - j) * (*p->width)(p, ' ');
 				vbl += dv;
 				vend += dv;
 				break;
 			}
-			if (ASCII_NBRSP == p->buf[i]) {
+			if (p->tcol->buf[i] == ASCII_NBRSP) {
 				vbl += (*p->width)(p, ' ');
 				continue;
 			}
-			if (ASCII_BREAK == p->buf[i])
+			if (p->tcol->buf[i] == ASCII_BREAK)
 				continue;
 
 			/*
@@ -225,11 +228,11 @@ term_flushln(struct termp *p)
 				vbl = 0;
 			}
 
-			(*p->letter)(p, p->buf[i]);
-			if (8 == p->buf[i])
-				p->viscol -= (*p->width)(p, p->buf[i-1]);
+			(*p->letter)(p, p->tcol->buf[i]);
+			if (p->tcol->buf[i] == '\b')
+				p->viscol -= (*p->width)(p, p->tcol->buf[i-1]);
 			else
-				p->viscol += (*p->width)(p, p->buf[i]);
+				p->viscol += (*p->width)(p, p->tcol->buf[i]);
 		}
 		vis = vend;
 	}
@@ -472,12 +475,12 @@ term_word(struct termp *p, const char *w
 			else {
 				uc += p->col;
 				p->col = 0;
-				if (p->offset > (size_t)(-uc)) {
+				if (p->tcol->offset > (size_t)(-uc)) {
 					p->ti += uc;
-					p->offset += uc;
+					p->tcol->offset += uc;
 				} else {
-					p->ti -= p->offset;
-					p->offset = 0;
+					p->ti -= p->tcol->offset;
+					p->tcol->offset = 0;
 				}
 			}
 			continue;
@@ -486,9 +489,9 @@ term_word(struct termp *p, const char *w
 				continue;
 			uc = term_hspan(p, &su) / 24;
 			if (uc <= 0) {
-				if (p->rmargin <= p->offset)
+				if (p->tcol->rmargin <= p->tcol->offset)
 					continue;
-				lsz = p->rmargin - p->offset;
+				lsz = p->tcol->rmargin - p->tcol->offset;
 			} else
 				lsz = uc;
 			while (sz &&
@@ -557,8 +560,8 @@ term_word(struct termp *p, const char *w
 			}
 			/* Trim trailing backspace/blank pair. */
 			if (p->lastcol > 2 &&
-			    (p->buf[p->lastcol - 1] == ' ' ||
-			     p->buf[p->lastcol - 1] == '\t'))
+			    (p->tcol->buf[p->lastcol - 1] == ' ' ||
+			     p->tcol->buf[p->lastcol - 1] == '\t'))
 				p->lastcol -= 2;
 			if (p->col > p->lastcol)
 				p->col = p->lastcol;
@@ -586,15 +589,13 @@ term_word(struct termp *p, const char *w
 }
 
 static void
-adjbuf(struct termp *p, size_t sz)
+adjbuf(struct termp_col *c, size_t sz)
 {
-
-	if (0 == p->maxcols)
-		p->maxcols = 1024;
-	while (sz >= p->maxcols)
-		p->maxcols <<= 2;
-
-	p->buf = mandoc_reallocarray(p->buf, p->maxcols, sizeof(int));
+	if (c->maxcols == 0)
+		c->maxcols = 1024;
+	while (c->maxcols <= sz)
+		c->maxcols <<= 2;
+	c->buf = mandoc_reallocarray(c->buf, c->maxcols, sizeof(*c->buf));
 }
 
 static void
@@ -604,10 +605,10 @@ bufferc(struct termp *p, char c)
 		(*p->letter)(p, c);
 		return;
 	}
-	if (p->col + 1 >= p->maxcols)
-		adjbuf(p, p->col + 1);
+	if (p->col + 1 >= p->tcol->maxcols)
+		adjbuf(p->tcol, p->col + 1);
 	if (p->lastcol <= p->col || (c != ' ' && c != ASCII_NBRSP))
-		p->buf[p->col] = c;
+		p->tcol->buf[p->col] = c;
 	if (p->lastcol < ++p->col)
 		p->lastcol = p->col;
 }
@@ -627,32 +628,33 @@ encode1(struct termp *p, int c)
 		return;
 	}
 
-	if (p->col + 7 >= p->maxcols)
-		adjbuf(p, p->col + 7);
+	if (p->col + 7 >= p->tcol->maxcols)
+		adjbuf(p->tcol, p->col + 7);
 
 	f = (c == ASCII_HYPH || c > 127 || isgraph(c)) ?
 	    p->fontq[p->fonti] : TERMFONT_NONE;
 
 	if (p->flags & TERMP_BACKBEFORE) {
-		if (p->buf[p->col - 1] == ' ' || p->buf[p->col - 1] == '\t')
+		if (p->tcol->buf[p->col - 1] == ' ' ||
+		    p->tcol->buf[p->col - 1] == '\t')
 			p->col--;
 		else
-			p->buf[p->col++] = 8;
+			p->tcol->buf[p->col++] = '\b';
 		p->flags &= ~TERMP_BACKBEFORE;
 	}
-	if (TERMFONT_UNDER == f || TERMFONT_BI == f) {
-		p->buf[p->col++] = '_';
-		p->buf[p->col++] = 8;
-	}
-	if (TERMFONT_BOLD == f || TERMFONT_BI == f) {
-		if (ASCII_HYPH == c)
-			p->buf[p->col++] = '-';
+	if (f == TERMFONT_UNDER || f == TERMFONT_BI) {
+		p->tcol->buf[p->col++] = '_';
+		p->tcol->buf[p->col++] = '\b';
+	}
+	if (f == TERMFONT_BOLD || f == TERMFONT_BI) {
+		if (c == ASCII_HYPH)
+			p->tcol->buf[p->col++] = '-';
 		else
-			p->buf[p->col++] = c;
-		p->buf[p->col++] = 8;
+			p->tcol->buf[p->col++] = c;
+		p->tcol->buf[p->col++] = '\b';
 	}
 	if (p->lastcol <= p->col || (c != ' ' && c != ASCII_NBRSP))
-		p->buf[p->col] = c;
+		p->tcol->buf[p->col] = c;
 	if (p->lastcol < ++p->col)
 		p->lastcol = p->col;
 	if (p->flags & TERMP_BACKAFTER) {
@@ -672,8 +674,8 @@ encode(struct termp *p, const char *word
 		return;
 	}
 
-	if (p->col + 2 + (sz * 5) >= p->maxcols)
-		adjbuf(p, p->col + 2 + (sz * 5));
+	if (p->col + 2 + (sz * 5) >= p->tcol->maxcols)
+		adjbuf(p->tcol, p->col + 2 + (sz * 5));
 
 	for (i = 0; i < sz; i++) {
 		if (ASCII_HYPH == word[i] ||
@@ -682,7 +684,7 @@ encode(struct termp *p, const char *word
 		else {
 			if (p->lastcol <= p->col ||
 			    (word[i] != ' ' && word[i] != ASCII_NBRSP))
-				p->buf[p->col] = word[i];
+				p->tcol->buf[p->col] = word[i];
 			p->col++;
 
 			/*
Index: term.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/term.h,v
retrieving revision 1.124
retrieving revision 1.125
diff -Lterm.h -Lterm.h -u -p -r1.124 -r1.125
--- term.h
+++ term.h
@@ -49,24 +49,30 @@ struct	termp_tbl {
 	int		  decimal;	/* decimal point position */
 };
 
+struct	termp_col {
+	int		 *buf;		/* Output buffer. */
+	size_t		  maxcols;	/* Allocated bytes in buf. */
+	size_t		  rmargin;	/* Current right margin. */
+	size_t		  offset;	/* Current left margin. */
+};
+
 struct	termp {
-	enum termtype	  type;
-	struct rofftbl	  tbl;		/* table configuration */
-	int		  synopsisonly; /* print the synopsis only */
-	int		  mdocstyle;	/* imitate mdoc(7) output */
+	struct rofftbl	  tbl;		/* Table configuration. */
+	struct termp_col *tcols;	/* Array of table columns. */
+	struct termp_col *tcol;		/* Current table column. */
+	size_t		  maxtcol;	/* Allocated table columns. */
 	size_t		  line;		/* Current output line number. */
 	size_t		  defindent;	/* Default indent for text. */
 	size_t		  defrmargin;	/* Right margin of the device. */
 	size_t		  lastrmargin;	/* Right margin before the last ll. */
-	size_t		  rmargin;	/* Current right margin. */
 	size_t		  maxrmargin;	/* Max right margin. */
-	size_t		  maxcols;	/* Max size of buf. */
-	size_t		  offset;	/* Margin offest. */
 	size_t		  col;		/* Byte position in buf. */
 	size_t		  lastcol;	/* Bytes in buf. */
 	size_t		  viscol;	/* Chars on current line. */
 	size_t		  trailspace;	/* See termp_flushln(). */
 	size_t		  minbl;	/* Minimum blanks before next field. */
+	int		  synopsisonly; /* Print the synopsis only. */
+	int		  mdocstyle;	/* Imitate mdoc(7) output. */
 	int		  ti;		/* Temporary indent for one line. */
 	int		  skipvsp;	/* Vertical space to skip. */
 	int		  flags;
@@ -90,7 +96,7 @@ struct	termp {
 #define	TERMP_NOBUF	 (1 << 17)	/* Bypass output buffer. */
 #define	TERMP_NEWMC	 (1 << 18)	/* No .mc printed yet. */
 #define	TERMP_ENDMC	 (1 << 19)	/* Next break ends .mc mode. */
-	int		 *buf;		/* Output buffer. */
+	enum termtype	  type;		/* Terminal, PS, or PDF. */
 	enum termenc	  enc;		/* Type of encoding. */
 	enum termfont	  fontl;	/* Last font set. */
 	enum termfont	 *fontq;	/* Symmetric fonts. */
Index: term_ascii.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/term_ascii.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -Lterm_ascii.c -Lterm_ascii.c -u -p -r1.56 -r1.57
--- term_ascii.c
+++ term_ascii.c
@@ -65,12 +65,14 @@ ascii_init(enum termenc enc, const struc
 #endif
 	struct termp	*p;
 
-	p = mandoc_calloc(1, sizeof(struct termp));
+	p = mandoc_calloc(1, sizeof(*p));
+	p->tcol = p->tcols = mandoc_calloc(1, sizeof(*p->tcol));
+	p->maxtcol = 1;
 
 	p->line = 1;
 	p->defrmargin = p->lastrmargin = 78;
 	p->fontq = mandoc_reallocarray(NULL,
-	     (p->fontsz = 8), sizeof(enum termfont));
+	     (p->fontsz = 8), sizeof(*p->fontq));
 	p->fontq[0] = p->fontl = TERMFONT_NONE;
 
 	p->begin = ascii_begin;
@@ -148,7 +150,7 @@ ascii_setwidth(struct termp *p, int iop,
 {
 
 	width /= 24;
-	p->rmargin = p->defrmargin;
+	p->tcol->rmargin = p->defrmargin;
 	if (iop > 0)
 		p->defrmargin += width;
 	else if (iop == 0)
@@ -157,8 +159,8 @@ ascii_setwidth(struct termp *p, int iop,
 		p->defrmargin -= width;
 	else
 		p->defrmargin = 0;
-	p->lastrmargin = p->rmargin;
-	p->rmargin = p->maxrmargin = p->defrmargin;
+	p->lastrmargin = p->tcol->rmargin;
+	p->tcol->rmargin = p->maxrmargin = p->defrmargin;
 }
 
 void
@@ -215,7 +217,7 @@ ascii_endline(struct termp *p)
 {
 
 	p->line++;
-	p->offset -= p->ti;
+	p->tcol->offset -= p->ti;
 	p->ti = 0;
 	putchar('\n');
 }
@@ -371,7 +373,7 @@ locale_endline(struct termp *p)
 {
 
 	p->line++;
-	p->offset -= p->ti;
+	p->tcol->offset -= p->ti;
 	p->ti = 0;
 	putwchar(L'\n');
 }
Index: man_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man_term.c,v
retrieving revision 1.202
retrieving revision 1.203
diff -Lman_term.c -Lman_term.c -u -p -r1.202 -r1.203
--- man_term.c
+++ man_term.c
@@ -141,7 +141,7 @@ terminal_man(void *arg, const struct rof
 	size_t			 save_defindent;
 
 	p = (struct termp *)arg;
-	p->rmargin = p->maxrmargin = p->defrmargin;
+	p->tcol->rmargin = p->maxrmargin = p->defrmargin;
 	term_tab_set(p, NULL);
 	term_tab_set(p, "T");
 	term_tab_set(p, ".5i");
@@ -228,7 +228,7 @@ pre_literal(DECL_ARGS)
 
 	term_newln(p);
 
-	if (MAN_nf == n->tok || MAN_EX == n->tok)
+	if (n->tok == MAN_nf || n->tok == MAN_EX)
 		mt->fl |= MANT_LITERAL;
 	else
 		mt->fl &= ~MANT_LITERAL;
@@ -238,9 +238,9 @@ pre_literal(DECL_ARGS)
 	 * So in case a second call to term_flushln() is needed,
 	 * indentation has to be set up explicitly.
 	 */
-	if (MAN_HP == n->parent->tok && p->rmargin < p->maxrmargin) {
-		p->offset = p->rmargin;
-		p->rmargin = p->maxrmargin;
+	if (n->parent->tok == MAN_HP && p->tcol->rmargin < p->maxrmargin) {
+		p->tcol->offset = p->tcol->rmargin;
+		p->tcol->rmargin = p->maxrmargin;
 		p->trailspace = 0;
 		p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
 		p->flags |= TERMP_NOSPACE;
@@ -359,8 +359,8 @@ pre_in(DECL_ARGS)
 
 	term_newln(p);
 
-	if (NULL == n->child) {
-		p->offset = mt->offset;
+	if (n->child == NULL) {
+		p->tcol->offset = mt->offset;
 		return 0;
 	}
 
@@ -380,13 +380,13 @@ pre_in(DECL_ARGS)
 	v = (term_hspan(p, &su) + 11) / 24;
 
 	if (less < 0)
-		p->offset -= p->offset > v ? v : p->offset;
+		p->tcol->offset -= p->tcol->offset > v ? v : p->tcol->offset;
 	else if (less > 0)
-		p->offset += v;
+		p->tcol->offset += v;
 	else
-		p->offset = v;
-	if (p->offset > SHRT_MAX)
-		p->offset = term_len(p, p->defindent);
+		p->tcol->offset = v;
+	if (p->tcol->offset > SHRT_MAX)
+		p->tcol->offset = term_len(p, p->defindent);
 
 	return 0;
 }
@@ -435,8 +435,8 @@ pre_HP(DECL_ARGS)
 	} else
 		len = mt->lmargin[mt->lmargincur];
 
-	p->offset = mt->offset;
-	p->rmargin = mt->offset + len;
+	p->tcol->offset = mt->offset;
+	p->tcol->rmargin = mt->offset + len;
 	return 1;
 }
 
@@ -460,8 +460,8 @@ post_HP(DECL_ARGS)
 
 		p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
 		p->trailspace = 0;
-		p->offset = mt->offset;
-		p->rmargin = p->maxrmargin;
+		p->tcol->offset = mt->offset;
+		p->tcol->rmargin = p->maxrmargin;
 		break;
 	default:
 		break;
@@ -478,7 +478,7 @@ pre_PP(DECL_ARGS)
 		print_bvspace(p, n, mt->pardist);
 		break;
 	default:
-		p->offset = mt->offset;
+		p->tcol->offset = mt->offset;
 		break;
 	}
 
@@ -522,8 +522,8 @@ pre_IP(DECL_ARGS)
 
 	switch (n->type) {
 	case ROFFT_HEAD:
-		p->offset = mt->offset;
-		p->rmargin = mt->offset + len;
+		p->tcol->offset = mt->offset;
+		p->tcol->rmargin = mt->offset + len;
 
 		savelit = MANT_LITERAL & mt->fl;
 		mt->fl &= ~MANT_LITERAL;
@@ -536,8 +536,8 @@ pre_IP(DECL_ARGS)
 
 		return 0;
 	case ROFFT_BODY:
-		p->offset = mt->offset + len;
-		p->rmargin = p->maxrmargin;
+		p->tcol->offset = mt->offset + len;
+		p->tcol->rmargin = p->maxrmargin;
 		break;
 	default:
 		break;
@@ -555,11 +555,11 @@ post_IP(DECL_ARGS)
 		term_flushln(p);
 		p->flags &= ~TERMP_NOBREAK;
 		p->trailspace = 0;
-		p->rmargin = p->maxrmargin;
+		p->tcol->rmargin = p->maxrmargin;
 		break;
 	case ROFFT_BODY:
 		term_newln(p);
-		p->offset = mt->offset;
+		p->tcol->offset = mt->offset;
 		break;
 	default:
 		break;
@@ -604,8 +604,8 @@ pre_TP(DECL_ARGS)
 
 	switch (n->type) {
 	case ROFFT_HEAD:
-		p->offset = mt->offset;
-		p->rmargin = mt->offset + len;
+		p->tcol->offset = mt->offset;
+		p->tcol->rmargin = mt->offset + len;
 
 		savelit = MANT_LITERAL & mt->fl;
 		mt->fl &= ~MANT_LITERAL;
@@ -624,8 +624,8 @@ pre_TP(DECL_ARGS)
 			mt->fl |= MANT_LITERAL;
 		return 0;
 	case ROFFT_BODY:
-		p->offset = mt->offset + len;
-		p->rmargin = p->maxrmargin;
+		p->tcol->offset = mt->offset + len;
+		p->tcol->rmargin = p->maxrmargin;
 		p->trailspace = 0;
 		p->flags &= ~(TERMP_NOBREAK | TERMP_BRTRSP);
 		break;
@@ -646,7 +646,7 @@ post_TP(DECL_ARGS)
 		break;
 	case ROFFT_BODY:
 		term_newln(p);
-		p->offset = mt->offset;
+		p->tcol->offset = mt->offset;
 		break;
 	default:
 		break;
@@ -681,14 +681,14 @@ pre_SS(DECL_ARGS)
 		break;
 	case ROFFT_HEAD:
 		term_fontrepl(p, TERMFONT_BOLD);
-		p->offset = term_len(p, 3);
-		p->rmargin = mt->offset;
+		p->tcol->offset = term_len(p, 3);
+		p->tcol->rmargin = mt->offset;
 		p->trailspace = mt->offset;
 		p->flags |= TERMP_NOBREAK | TERMP_BRIND;
 		break;
 	case ROFFT_BODY:
-		p->offset = mt->offset;
-		p->rmargin = p->maxrmargin;
+		p->tcol->offset = mt->offset;
+		p->tcol->rmargin = p->maxrmargin;
 		p->trailspace = 0;
 		p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
 		break;
@@ -743,14 +743,14 @@ pre_SH(DECL_ARGS)
 		break;
 	case ROFFT_HEAD:
 		term_fontrepl(p, TERMFONT_BOLD);
-		p->offset = 0;
-		p->rmargin = mt->offset;
+		p->tcol->offset = 0;
+		p->tcol->rmargin = mt->offset;
 		p->trailspace = mt->offset;
 		p->flags |= TERMP_NOBREAK | TERMP_BRIND;
 		break;
 	case ROFFT_BODY:
-		p->offset = mt->offset;
-		p->rmargin = p->maxrmargin;
+		p->tcol->offset = mt->offset;
+		p->tcol->rmargin = p->maxrmargin;
 		p->trailspace = 0;
 		p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
 		break;
@@ -804,8 +804,8 @@ pre_RS(DECL_ARGS)
 		n->aux = term_len(p, p->defindent);
 
 	mt->offset += n->aux;
-	p->offset = mt->offset;
-	p->rmargin = p->maxrmargin;
+	p->tcol->offset = mt->offset;
+	p->tcol->rmargin = p->maxrmargin;
 
 	if (++mt->lmarginsz < MAXMARGINS)
 		mt->lmargincur = mt->lmarginsz;
@@ -829,7 +829,7 @@ post_RS(DECL_ARGS)
 	}
 
 	mt->offset -= n->parent->head->aux;
-	p->offset = mt->offset;
+	p->tcol->offset = mt->offset;
 
 	if (--mt->lmarginsz < MAXMARGINS)
 		mt->lmargincur = mt->lmarginsz;
@@ -935,9 +935,10 @@ out:
 		else
 			term_newln(p);
 		p->flags &= ~TERMP_BRNEVER;
-		if (p->rmargin < p->maxrmargin && n->parent->tok == MAN_HP) {
-			p->offset = p->rmargin;
-			p->rmargin = p->maxrmargin;
+		if (p->tcol->rmargin < p->maxrmargin &&
+		    n->parent->tok == MAN_HP) {
+			p->tcol->offset = p->tcol->rmargin;
+			p->tcol->rmargin = p->maxrmargin;
 		}
 	}
 	if (NODE_EOS & n->flags)
@@ -994,8 +995,8 @@ print_man_foot(struct termp *p, const st
 
 	p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
 	p->trailspace = 1;
-	p->offset = 0;
-	p->rmargin = p->maxrmargin > datelen ?
+	p->tcol->offset = 0;
+	p->tcol->rmargin = p->maxrmargin > datelen ?
 	    (p->maxrmargin + term_len(p, 1) - datelen) / 2 : 0;
 
 	if (meta->os)
@@ -1004,9 +1005,10 @@ print_man_foot(struct termp *p, const st
 
 	/* At the bottom in the middle: manual date. */
 
-	p->offset = p->rmargin;
+	p->tcol->offset = p->tcol->rmargin;
 	titlen = term_strlen(p, title);
-	p->rmargin = p->maxrmargin > titlen ? p->maxrmargin - titlen : 0;
+	p->tcol->rmargin = p->maxrmargin > titlen ?
+	    p->maxrmargin - titlen : 0;
 	p->flags |= TERMP_NOSPACE;
 
 	term_word(p, meta->date);
@@ -1017,8 +1019,8 @@ print_man_foot(struct termp *p, const st
 	p->flags &= ~TERMP_NOBREAK;
 	p->flags |= TERMP_NOSPACE;
 	p->trailspace = 0;
-	p->offset = p->rmargin;
-	p->rmargin = p->maxrmargin;
+	p->tcol->offset = p->tcol->rmargin;
+	p->tcol->rmargin = p->maxrmargin;
 
 	term_word(p, title);
 	term_flushln(p);
@@ -1045,8 +1047,8 @@ print_man_head(struct termp *p, const st
 
 	p->flags |= TERMP_NOBREAK | TERMP_NOSPACE;
 	p->trailspace = 1;
-	p->offset = 0;
-	p->rmargin = 2 * (titlen+1) + vollen < p->maxrmargin ?
+	p->tcol->offset = 0;
+	p->tcol->rmargin = 2 * (titlen+1) + vollen < p->maxrmargin ?
 	    (p->maxrmargin - vollen + term_len(p, 1)) / 2 :
 	    vollen < p->maxrmargin ? p->maxrmargin - vollen : 0;
 
@@ -1056,9 +1058,9 @@ print_man_head(struct termp *p, const st
 	/* At the top in the middle: manual volume. */
 
 	p->flags |= TERMP_NOSPACE;
-	p->offset = p->rmargin;
-	p->rmargin = p->offset + vollen + titlen < p->maxrmargin ?
-	    p->maxrmargin - titlen : p->maxrmargin;
+	p->tcol->offset = p->tcol->rmargin;
+	p->tcol->rmargin = p->tcol->offset + vollen + titlen <
+	    p->maxrmargin ?  p->maxrmargin - titlen : p->maxrmargin;
 
 	term_word(p, volume);
 	term_flushln(p);
@@ -1067,17 +1069,17 @@ print_man_head(struct termp *p, const st
 
 	p->flags &= ~TERMP_NOBREAK;
 	p->trailspace = 0;
-	if (p->rmargin + titlen <= p->maxrmargin) {
+	if (p->tcol->rmargin + titlen <= p->maxrmargin) {
 		p->flags |= TERMP_NOSPACE;
-		p->offset = p->rmargin;
-		p->rmargin = p->maxrmargin;
+		p->tcol->offset = p->tcol->rmargin;
+		p->tcol->rmargin = p->maxrmargin;
 		term_word(p, title);
 		term_flushln(p);
 	}
 
 	p->flags &= ~TERMP_NOSPACE;
-	p->offset = 0;
-	p->rmargin = p->maxrmargin;
+	p->tcol->offset = 0;
+	p->tcol->rmargin = p->maxrmargin;
 
 	/*
 	 * Groff prints three blank lines before the content.
Index: roff_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/roff_term.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -Lroff_term.c -Lroff_term.c -u -p -r1.8 -r1.9
--- roff_term.c
+++ roff_term.c
@@ -60,8 +60,8 @@ roff_term_pre_br(ROFF_TERM_ARGS)
 {
 	term_newln(p);
 	if (p->flags & TERMP_BRIND) {
-		p->offset = p->rmargin;
-		p->rmargin = p->maxrmargin;
+		p->tcol->offset = p->tcol->rmargin;
+		p->tcol->rmargin = p->maxrmargin;
 		p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
 	}
 }
@@ -73,7 +73,7 @@ roff_term_pre_ce(ROFF_TERM_ARGS)
 	size_t			 len, lm;
 
 	roff_term_pre_br(p, n);
-	lm = p->offset;
+	lm = p->tcol->offset;
 	n = n->child->next;
 	while (n != NULL) {
 		nch = n;
@@ -87,9 +87,9 @@ roff_term_pre_ce(ROFF_TERM_ARGS)
 			nch = nch->next;
 		} while (nch != NULL && (n->type != ROFFT_TEXT ||
 		    (n->flags & NODE_LINE) == 0));
-		p->offset = len >= p->rmargin ? 0 :
-		    lm + len >= p->rmargin ? p->rmargin - len :
-		    (lm + p->rmargin - len) / 2;
+		p->tcol->offset = len >= p->tcol->rmargin ? 0 :
+		    lm + len >= p->tcol->rmargin ? p->tcol->rmargin - len :
+		    (lm + p->tcol->rmargin - len) / 2;
 		while (n != nch) {
 			if (n->type == ROFFT_TEXT)
 				term_word(p, n->string);
@@ -100,7 +100,7 @@ roff_term_pre_ce(ROFF_TERM_ARGS)
 		p->flags |= TERMP_NOSPACE;
 		term_flushln(p);
 	}
-	p->offset = lm;
+	p->tcol->offset = lm;
 }
 
 static void
@@ -206,16 +206,16 @@ roff_term_pre_ti(ROFF_TERM_ARGS)
 	len = term_hspan(p, &su) / 24;
 
 	if (sign == 0) {
-		p->ti = len - p->offset;
-		p->offset = len;
+		p->ti = len - p->tcol->offset;
+		p->tcol->offset = len;
 	} else if (sign == 1) {
 		p->ti = len;
-		p->offset += len;
-	} else if ((size_t)len < p->offset) {
+		p->tcol->offset += len;
+	} else if ((size_t)len < p->tcol->offset) {
 		p->ti = -len;
-		p->offset -= len;
+		p->tcol->offset -= len;
 	} else {
-		p->ti = -p->offset;
-		p->offset = 0;
+		p->ti = -p->tcol->offset;
+		p->tcol->offset = 0;
 	}
 }
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-07 20:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-07 20:01 mdocml: Prepare the terminal driver for filling multiple columns in schwarze
  -- strict thread matches above, loose matches on Subject: below --
2017-06-07 17:38 schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).