aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--main.c4
-rw-r--r--mandoc.h4
-rw-r--r--mdoc.c4
-rw-r--r--mdoc.h3
-rw-r--r--mdoc_macro.c5
-rw-r--r--mdoc_validate.c34
6 files changed, 40 insertions, 14 deletions
diff --git a/main.c b/main.c
index 89bd4ef8..79a252e9 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.122 2010/12/10 20:58:56 schwarze Exp $ */
+/* $Id: main.c,v 1.123 2010/12/15 23:39:40 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -145,7 +145,6 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
/* related to macros and nesting */
"skipping obsolete macro",
- "skipping paragraph macro",
"blocks badly nested",
"child violates parent syntax",
"nested displays are not portable",
@@ -183,6 +182,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"skipping bad character",
"skipping text before the first section header",
"skipping unknown macro",
+ "skipping paragraph macro",
"NOT IMPLEMENTED: skipping request",
"line scope broken",
"argument count wrong",
diff --git a/mandoc.h b/mandoc.h
index 14687e0b..51239794 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.33 2010/12/10 20:58:56 schwarze Exp $ */
+/* $Id: mandoc.h,v 1.34 2010/12/15 23:39:40 kristaps Exp $ */
/*
* Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -67,7 +67,6 @@ enum mandocerr {
/* related to macros and nesting */
MANDOCERR_MACROOBS, /* skipping obsolete macro */
- MANDOCERR_IGNPAR, /* skipping paragraph macro */
MANDOCERR_SCOPENEST, /* blocks badly nested */
MANDOCERR_CHILD, /* child violates parent syntax */
MANDOCERR_NESTEDDISP, /* nested displays are not portable */
@@ -105,6 +104,7 @@ enum mandocerr {
MANDOCERR_BADCHAR, /* skipping bad character */
MANDOCERR_NOTEXT, /* skipping text before the first section header */
MANDOCERR_MACRO, /* skipping unknown macro */
+ MANDOCERR_IGNPAR, /* skipping paragraph macro */
MANDOCERR_REQUEST, /* NOT IMPLEMENTED: skipping request */
MANDOCERR_LINESCOPE, /* line scope broken */
MANDOCERR_ARGCOUNT, /* argument count wrong */
diff --git a/mdoc.c b/mdoc.c
index ef1fda64..38dbd72f 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.168 2010/12/06 11:01:19 kristaps Exp $ */
+/* $Id: mdoc.c,v 1.169 2010/12/15 23:39:40 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -552,6 +552,8 @@ mdoc_node_unlink(struct mdoc *m, struct mdoc_node *n)
n->parent->nchild--;
if (n->parent->child == n)
n->parent->child = n->prev ? n->prev : n->next;
+ if (n->parent->last == n)
+ n->parent->last = n->prev ? n->prev : NULL;
}
/* Adjust parse point, if applicable. */
diff --git a/mdoc.h b/mdoc.h
index 0de8fe59..675e8dab 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -1,4 +1,4 @@
-/* $Id: mdoc.h,v 1.106 2010/12/15 14:52:16 kristaps Exp $ */
+/* $Id: mdoc.h,v 1.107 2010/12/15 23:39:40 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -371,6 +371,7 @@ union mdoc_data {
struct mdoc_node {
struct mdoc_node *parent; /* parent AST node */
struct mdoc_node *child; /* first child AST node */
+ struct mdoc_node *last; /* last child AST node */
struct mdoc_node *next; /* sibling AST node */
struct mdoc_node *prev; /* prior sibling AST node */
int nchild; /* number children */
diff --git a/mdoc_macro.c b/mdoc_macro.c
index 790437cc..1c97f88c 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_macro.c,v 1.98 2010/12/06 11:01:19 kristaps Exp $ */
+/* $Id: mdoc_macro.c,v 1.99 2010/12/15 23:39:40 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -252,6 +252,7 @@ lookup_raw(const char *p)
static int
rew_last(struct mdoc *mdoc, const struct mdoc_node *to)
{
+ struct mdoc_node *n;
assert(to);
mdoc->next = MDOC_NEXT_SIBLING;
@@ -260,8 +261,10 @@ rew_last(struct mdoc *mdoc, const struct mdoc_node *to)
while (mdoc->last != to) {
if ( ! mdoc_valid_post(mdoc))
return(0);
+ n = mdoc->last;
mdoc->last = mdoc->last->parent;
assert(mdoc->last);
+ mdoc->last->last = n;
}
return(mdoc_valid_post(mdoc));
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 6ffa50f5..ddf82b8b 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.139 2010/12/09 10:32:22 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.140 2010/12/15 23:39:40 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -107,6 +107,7 @@ static int post_it(POST_ARGS);
static int post_lb(POST_ARGS);
static int post_nm(POST_ARGS);
static int post_os(POST_ARGS);
+static int post_ignpar(POST_ARGS);
static int post_prol(POST_ARGS);
static int post_root(POST_ARGS);
static int post_rs(POST_ARGS);
@@ -150,9 +151,9 @@ static v_post posts_nm[] = { post_nm, NULL };
static v_post posts_notext[] = { ewarn_eq0, NULL };
static v_post posts_os[] = { post_os, post_prol, NULL };
static v_post posts_rs[] = { berr_ge1, herr_eq0, post_rs, NULL };
-static v_post posts_sh[] = { herr_ge1, bwarn_ge1, post_sh, NULL };
+static v_post posts_sh[] = { post_ignpar, herr_ge1, bwarn_ge1, post_sh, NULL };
static v_post posts_sp[] = { eerr_le1, NULL };
-static v_post posts_ss[] = { herr_ge1, NULL };
+static v_post posts_ss[] = { post_ignpar, herr_ge1, bwarn_ge1, NULL };
static v_post posts_st[] = { eerr_eq1, post_st, NULL };
static v_post posts_std[] = { post_std, NULL };
static v_post posts_text[] = { eerr_ge1, NULL };
@@ -894,10 +895,6 @@ pre_it(PRE_ARGS)
if (MDOC_BLOCK != n->type)
return(1);
- /*
- * FIXME: this can probably be lifted if we make the It into
- * something else on-the-fly?
- */
return(check_parent(mdoc, n, MDOC_Bl, MDOC_BODY));
}
@@ -1883,6 +1880,29 @@ post_sh_head(POST_ARGS)
}
static int
+post_ignpar(POST_ARGS)
+{
+ struct mdoc_node *np;
+
+ if (MDOC_BODY != mdoc->last->type)
+ return(1);
+
+ if (NULL != (np = mdoc->last->child))
+ if (MDOC_Pp == np->tok || MDOC_Lp == np->tok) {
+ mdoc_nmsg(mdoc, np, MANDOCERR_IGNPAR);
+ mdoc_node_delete(mdoc, np);
+ }
+
+ if (NULL != (np = mdoc->last->last))
+ if (MDOC_Pp == np->tok || MDOC_Lp == np->tok) {
+ mdoc_nmsg(mdoc, np, MANDOCERR_IGNPAR);
+ mdoc_node_delete(mdoc, np);
+ }
+
+ return(1);
+}
+
+static int
pre_par(PRE_ARGS)
{