summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-01-01 18:33:51 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-01-01 18:33:51 +0000
commit17b167d7d727a9ea9d8e35dd3bc22b3a6e7ef31a (patch)
treefadf81d928adfb6bdedd8cd5fbf031dad185fd31
parent3ec518a3f16532b7789a62e67f99cf1e752b81a8 (diff)
downloadmandoc-VERSION_1_9_15-pre2.tar.gz
mandoc-VERSION_1_9_15-pre2.tar.zst
mandoc-VERSION_1_9_15-pre2.zip
Fix of subtle, but significant, resetting of tags when in list mode. Pointed out by Ingo Schwarze.VERSION_1_9_15-pre2
-rw-r--r--mdoc_term.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/mdoc_term.c b/mdoc_term.c
index b51ce236..47429911 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.108 2010/01/01 18:01:40 kristaps Exp $ */
+/* $Id: mdoc_term.c,v 1.109 2010/01/01 18:33:51 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -37,7 +37,6 @@
struct termpair {
struct termpair *ppair;
- int flag;
int count;
};
@@ -677,10 +676,6 @@ termp_it_pre(DECL_ARGS)
bl = n->parent->parent->parent;
- /* Save parent attributes. */
-
- pair->flag = p->flags;
-
/* Get list width, offset, and list type from argument list. */
keys[0] = MDOC_Width;
@@ -822,11 +817,10 @@ termp_it_pre(DECL_ARGS)
}
/*
- * Pad and break control. This is the tricker part. Lists with
- * set right-margins for the head get TERMP_NOBREAK because, if
- * they overrun the margin, they wrap to the new margin.
- * Correspondingly, the body for these types don't left-pad, as
- * the head will pad out to to the right.
+ * Pad and break control. This is the tricky part. These flags
+ * are documented in term_flushln() in term.c. Note that we're
+ * going to unset all of these flags in termp_it_post() when we
+ * exit.
*/
switch (type) {
@@ -967,7 +961,7 @@ termp_it_pre(DECL_ARGS)
break;
case (MDOC_Enum):
(pair->ppair->ppair->count)++;
- (void)snprintf(buf, sizeof(buf), "%d.",
+ snprintf(buf, sizeof(buf), "%d.",
pair->ppair->ppair->count);
term_word(p, buf);
break;
@@ -1010,7 +1004,7 @@ termp_it_post(DECL_ARGS)
{
int type;
- if (MDOC_BODY != n->type && MDOC_HEAD != n->type)
+ if (MDOC_BLOCK == n->type)
return;
type = arg_listtype(n->parent->parent->parent);
@@ -1034,7 +1028,17 @@ termp_it_post(DECL_ARGS)
break;
}
- p->flags = pair->flag;
+ /*
+ * Now that our output is flushed, we can reset our tags. Since
+ * only `It' sets these flags, we're free to assume that nobody
+ * has munged them in the meanwhile.
+ */
+
+ p->flags &= ~TERMP_DANGLE;
+ p->flags &= ~TERMP_NOBREAK;
+ p->flags &= ~TERMP_TWOSPACE;
+ p->flags &= ~TERMP_NOLPAD;
+ p->flags &= ~TERMP_HANG;
}
@@ -2015,10 +2019,9 @@ termp_sm_pre(DECL_ARGS)
{
assert(n->child && MDOC_TEXT == n->child->type);
- if (0 == strcmp("on", n->child->string)) {
+ if (0 == strcmp("on", n->child->string))
p->flags &= ~TERMP_NONOSPACE;
- p->flags &= ~TERMP_NOSPACE;
- } else
+ else
p->flags |= TERMP_NONOSPACE;
return(0);