source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mandoc: In GNU, Heirloom, and Plan 9 roff, literal tab characters are
@ 2022-08-15 10:22 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2022-08-15 10:22 UTC (permalink / raw)
  To: source

Log Message:
-----------
In GNU, Heirloom, and Plan 9 roff, literal tab characters are 
non-breakable in exactly the same way as "\ ".  That is, the preceding
word, the tab character, and the following word are always kept
together on the same output line.  If filling is enabled and an
output line break is required before the end of the following word,
the break occurs before the beginning of the preceding word.

Make mandoc behave in the same way.

Of course, using literal tab characters in filled text remains a
bad idea, and the "WARNING: tab in filled text" remains unchanged.

Modified Files:
--------------
    mandoc:
        term.c

Revision Data
-------------
Index: term.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/term.c,v
retrieving revision 1.286
retrieving revision 1.287
diff -Lterm.c -Lterm.c -u -p -r1.286 -r1.287
--- term.c
+++ term.c
@@ -268,22 +268,11 @@ term_fill(struct termp *p, size_t *nbr, 
 			vis -= (*p->width)(p, p->tcol->buf[ic - 1]);
 			continue;
 
-		case '\t':  /* Normal ASCII whitespace. */
 		case ' ':
 		case ASCII_BREAK:  /* Escape \: (breakpoint). */
-			switch (p->tcol->buf[ic]) {
-			case '\t':
-				vn = term_tab_next(vis);
-				break;
-			case ' ':
-				vn = vis + (*p->width)(p, ' ');
-				break;
-			case ASCII_BREAK:
-				vn = vis;
-				break;
-			default:
-				abort();
-			}
+			vn = vis;
+			if (p->tcol->buf[ic] == ' ')
+				vn += (*p->width)(p, ' ');
 			/* Can break at the end of a word. */
 			if (breakline || vn > vtarget)
 				break;
@@ -317,12 +306,19 @@ term_fill(struct termp *p, size_t *nbr, 
 			*vbr = vis;
 			continue;
 
-		case ASCII_NBRSP:  /* Non-breakable space. */
-			p->tcol->buf[ic] = ' ';
-			/* FALLTHROUGH */
-		default:  /* Printable character. */
+		default:
+			switch (p->tcol->buf[ic]) {
+			case '\t':
+				vis = term_tab_next(vis);
+				break;
+			case ASCII_NBRSP:  /* Non-breakable space. */
+				p->tcol->buf[ic] = ' ';
+				/* FALLTHROUGH */
+			default:  /* Printable character. */
+				vis += (*p->width)(p, p->tcol->buf[ic]);
+				break;
+			}
 			graph = 1;
-			vis += (*p->width)(p, p->tcol->buf[ic]);
 			if (vis > vtarget && *nbr > 0)
 				return;
 			continue;
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-15 10:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-15 10:22 mandoc: In GNU, Heirloom, and Plan 9 roff, literal tab characters are 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).