diff options
-rw-r--r-- | main.c | 2 | ||||
-rw-r--r-- | mandoc.h | 2 | ||||
-rw-r--r-- | mdoc.c | 2 | ||||
-rw-r--r-- | mdoc.h | 1 | ||||
-rw-r--r-- | mdoc_macro.c | 3 | ||||
-rw-r--r-- | mdoc_validate.c | 32 |
6 files changed, 34 insertions, 8 deletions
@@ -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", @@ -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 */ @@ -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. */ @@ -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 34037b2c..79cededd 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -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 2e4f93f2..e2ada6d5 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -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) { |