summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mdoc.c1
-rw-r--r--mdoc.h1
-rw-r--r--mdoc_html.c10
-rw-r--r--mdoc_macro.c5
-rw-r--r--mdoc_term.c2
-rw-r--r--tree.c6
6 files changed, 16 insertions, 9 deletions
diff --git a/mdoc.c b/mdoc.c
index 3df0fa4d..14eadb65 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -434,6 +434,7 @@ node_alloc(struct mdoc *mdoc, int line, int pos,
p->sec = mdoc->lastsec;
p->line = line;
p->pos = pos;
+ p->lastline = line;
p->tok = tok;
p->type = type;
diff --git a/mdoc.h b/mdoc.h
index f2c80231..7bc8819e 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -351,6 +351,7 @@ struct mdoc_node {
int nchild; /* number children */
int line; /* parse line */
int pos; /* parse column */
+ int lastline; /* the node ends on this line */
enum mdoct tok; /* tok or MDOC__MAX if none */
int flags;
#define MDOC_VALID (1 << 0) /* has been validated */
diff --git a/mdoc_html.c b/mdoc_html.c
index a5f3841d..c25b009c 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -459,15 +459,11 @@ print_mdoc_node(MDOC_ARGS)
break;
}
- if (HTML_KEEP & h->flags) {
- if (n->prev && n->prev->line != n->line) {
+ if (HTML_KEEP & h->flags || MDOC_SYNPRETTY & n->flags) {
+ if (n->prev ? (n->prev->lastline != n->line) :
+ (n->parent && n->parent->line != n->line)) {
h->flags &= ~HTML_KEEP;
h->flags |= HTML_PREKEEP;
- } else if (NULL == n->prev) {
- if (n->parent && n->parent->line != n->line) {
- h->flags &= ~HTML_KEEP;
- h->flags |= HTML_PREKEEP;
- }
}
}
diff --git a/mdoc_macro.c b/mdoc_macro.c
index 61ca534a..fd3f8764 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -561,6 +561,9 @@ rew_sub(enum mdoc_type t, struct mdoc *mdoc,
case (REWIND_NONE):
return(1);
case (REWIND_THIS):
+ n->lastline = line -
+ (MDOC_NEWLINE & mdoc->flags &&
+ ! (MDOC_EXPLICIT & mdoc_macros[tok].flags));
break;
case (REWIND_FORCE):
mandoc_vmsg(MANDOCERR_SCOPEBROKEN, mdoc->parse,
@@ -569,6 +572,8 @@ rew_sub(enum mdoc_type t, struct mdoc *mdoc,
mdoc_macronames[n->tok]);
/* FALLTHROUGH */
case (REWIND_MORE):
+ n->lastline = line -
+ (MDOC_NEWLINE & mdoc->flags ? 1 : 0);
n = n->parent;
continue;
case (REWIND_LATER):
diff --git a/mdoc_term.c b/mdoc_term.c
index 244be965..1eaa47db 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -313,7 +313,7 @@ print_mdoc_node(DECL_ARGS)
*/
if (TERMP_KEEP & p->flags || MDOC_SYNPRETTY & n->flags) {
- if (n->prev ? (n->prev->line != n->line) :
+ if (n->prev ? (n->prev->lastline != n->line) :
(n->parent && n->parent->line != n->line)) {
p->flags &= ~TERMP_KEEP;
p->flags |= TERMP_PREKEEP;
diff --git a/tree.c b/tree.c
index ee7e25dd..c5be4b5d 100644
--- a/tree.c
+++ b/tree.c
@@ -1,6 +1,7 @@
/* $Id$ */
/*
* Copyright (c) 2008, 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2013 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -163,7 +164,10 @@ print_mdoc(const struct mdoc_node *n, int indent)
putchar(' ');
if (MDOC_LINE & n->flags)
putchar('*');
- printf("%d:%d\n", n->line, n->pos);
+ printf("%d:%d", n->line, n->pos);
+ if (n->lastline != n->line)
+ printf("-%d", n->lastline);
+ putchar('\n');
}
if (n->child)