From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Trailing whitespace is significant when determining the width of
Date: Mon, 21 Sep 2015 08:25:30 -0500 (EST) [thread overview]
Message-ID: <1842925956745737989.enqueue@fantadrom.bsd.lv> (raw)
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
reply other threads:[~2015-09-21 13:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1842925956745737989.enqueue@fantadrom.bsd.lv \
--to=schwarze@mdocml.bsd.lv \
--cc=source@mdocml.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).