source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Trailing whitespace is significant when determining the width of
@ 2015-09-21 13:25 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2015-09-21 13:25 UTC (permalink / raw)
  To: source

Log Message:
-----------
Trailing whitespace is significant when determining the width of a tag
in mdoc(7) .Bl -tag and man(7) .TP, but not in man(7) .IP.
Quirk reported by Jan Stary <hans at stare dot cz> on ports@.

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

Revision Data
-------------
Index: term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/term.c,v
retrieving revision 1.249
retrieving revision 1.250
diff -Lterm.c -Lterm.c -u -p -r1.249 -r1.250
--- term.c
+++ term.c
@@ -78,6 +78,8 @@ term_end(struct termp *p)
  *    the next column.  However, if less than p->trailspace blanks,
  *    which can be 0, 1, or 2, remain to the right margin, the line
  *    will be broken.
+ *  - TERMP_BRTRSP: Consider trailing whitespace significant
+ *    when deciding whether the chunk fits or not.
  *  - TERMP_BRIND: If the chunk does not fit and the output line has
  *    to be broken, start the next line at the right margin instead
  *    of at the offset.  Used together with TERMP_NOBREAK for the tags
@@ -290,6 +292,10 @@ term_flushln(struct termp *p)
 
 	} else if (TERMP_DANGLE & p->flags)
 		return;
+
+	/* Trailing whitespace is significant in some columns. */
+	if (vis && vbl && (TERMP_BRTRSP & p->flags))
+		vis += vbl;
 
 	/* If the column was overrun, break the line. */
 	if (maxvis < vis + p->trailspace * (*p->width)(p, ' ')) {
Index: term.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/term.h,v
retrieving revision 1.115
retrieving revision 1.116
diff -Lterm.h -Lterm.h -u -p -r1.115 -r1.116
--- term.h
+++ term.h
@@ -77,12 +77,13 @@ struct	termp {
 #define	TERMP_BACKAFTER	 (1 << 6)	/* Back up after next character. */
 #define	TERMP_BACKBEFORE (1 << 7)	/* Back up before next character. */
 #define	TERMP_NOBREAK	 (1 << 8)	/* See term_flushln(). */
-#define	TERMP_BRIND	 (1 << 9)	/* See term_flushln(). */
-#define	TERMP_DANGLE	 (1 << 10)	/* See term_flushln(). */
-#define	TERMP_HANG	 (1 << 11)	/* See term_flushln(). */
-#define	TERMP_NOSPLIT	 (1 << 12)	/* Do not break line before .An. */
-#define	TERMP_SPLIT	 (1 << 13)	/* Break line before .An. */
-#define	TERMP_NONEWLINE	 (1 << 14)	/* No line break in nofill mode. */
+#define	TERMP_BRTRSP	 (1 << 9)	/* See term_flushln(). */
+#define	TERMP_BRIND	 (1 << 10)	/* See term_flushln(). */
+#define	TERMP_DANGLE	 (1 << 11)	/* See term_flushln(). */
+#define	TERMP_HANG	 (1 << 12)	/* See term_flushln(). */
+#define	TERMP_NOSPLIT	 (1 << 13)	/* Do not break line before .An. */
+#define	TERMP_SPLIT	 (1 << 14)	/* Break line before .An. */
+#define	TERMP_NONEWLINE	 (1 << 15)	/* No line break in nofill mode. */
 	int		 *buf;		/* Output buffer. */
 	enum termenc	  enc;		/* Type of encoding. */
 	const struct mchars *symtab;	/* Character table. */
Index: man_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man_term.c,v
retrieving revision 1.183
retrieving revision 1.184
diff -Lman_term.c -Lman_term.c -u -p -r1.183 -r1.184
--- man_term.c
+++ man_term.c
@@ -671,7 +671,7 @@ pre_TP(DECL_ARGS)
 
 	switch (n->type) {
 	case ROFFT_HEAD:
-		p->flags |= TERMP_NOBREAK;
+		p->flags |= TERMP_NOBREAK | TERMP_BRTRSP;
 		p->trailspace = 1;
 		break;
 	case ROFFT_BODY:
@@ -723,7 +723,7 @@ pre_TP(DECL_ARGS)
 		p->offset = mt->offset + len;
 		p->rmargin = p->maxrmargin;
 		p->trailspace = 0;
-		p->flags &= ~TERMP_NOBREAK;
+		p->flags &= ~(TERMP_NOBREAK | TERMP_BRTRSP);
 		break;
 	default:
 		break;
Index: mdoc_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_term.c,v
retrieving revision 1.325
retrieving revision 1.326
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.325 -r1.326
--- mdoc_term.c
+++ mdoc_term.c
@@ -802,7 +802,7 @@ termp_it_pre(DECL_ARGS)
 		if (n->type != ROFFT_HEAD)
 			break;
 
-		p->flags |= TERMP_NOBREAK | TERMP_BRIND;
+		p->flags |= TERMP_NOBREAK | TERMP_BRTRSP | TERMP_BRIND;
 		p->trailspace = 2;
 
 		if (NULL == n->next || NULL == n->next->child)
@@ -974,7 +974,7 @@ termp_it_post(DECL_ARGS)
 	 * has munged them in the meanwhile.
 	 */
 
-	p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND |
+	p->flags &= ~(TERMP_NOBREAK | TERMP_BRTRSP | TERMP_BRIND |
 			TERMP_DANGLE | TERMP_HANG);
 	p->trailspace = 0;
 }
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

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

only message in thread, other threads:[~2015-09-21 13:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-21 13:25 mdocml: Trailing whitespace is significant when determining the width of 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).