From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]); by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id ca9ab832; for ; Thu, 22 Oct 2015 16:54:53 -0500 (EST) Date: Thu, 22 Oct 2015 16:54:53 -0500 (EST) Message-Id: <17009230780586895908.enqueue@fantadrom.bsd.lv> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: move man(7) validation into the dedicated validation phase, too X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- move man(7) validation into the dedicated validation phase, too Modified Files: -------------- mdocml: libman.h main.c man.c man.h man_macro.c man_validate.c roff.c roff_int.h Revision Data ------------- Index: man_macro.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/man_macro.c,v retrieving revision 1.112 retrieving revision 1.113 diff -Lman_macro.c -Lman_macro.c -u -p -r1.112 -r1.113 --- man_macro.c +++ man_macro.c @@ -130,7 +130,7 @@ man_unscope(struct roff_man *man, const man->last = n; n = n->parent; - man_valid_post(man); + man->last->flags |= MAN_VALID; } /* @@ -379,28 +379,13 @@ in_line_eoln(MACRO_PROT_ARGS) assert(man->last->type != ROFFT_ROOT); man->next = ROFF_NEXT_SIBLING; - /* - * Rewind our element scope. Note that when TH is pruned, we'll - * be back at the root, so make sure that we don't clobber as - * its sibling. - */ + /* Rewind our element scope. */ for ( ; man->last; man->last = man->last->parent) { + man_state(man, man->last); if (man->last == n) break; - if (man->last->type == ROFFT_ROOT) - break; - man_valid_post(man); } - - assert(man->last); - - /* - * Same here regarding whether we're back at the root. - */ - - if (man->last->type != ROFFT_ROOT) - man_valid_post(man); } void @@ -408,6 +393,7 @@ man_endparse(struct roff_man *man) { man_unscope(man, man->first); + man->flags &= ~MAN_LITERAL; } static int Index: main.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/main.c,v retrieving revision 1.252 retrieving revision 1.253 diff -Lmain.c -Lmain.c -u -p -r1.252 -r1.253 --- main.c +++ main.c @@ -721,6 +721,7 @@ parse(struct curparse *curp, int fd, con } } if (man->macroset == MACROSET_MAN) { + man_validate(man); switch (curp->outtype) { case OUTT_HTML: html_man(curp->outdata, man); Index: roff.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/roff.c,v retrieving revision 1.282 retrieving revision 1.283 diff -Lroff.c -Lroff.c -u -p -r1.282 -r1.283 --- roff.c +++ roff.c @@ -1063,7 +1063,7 @@ roff_word_alloc(struct roff_man *man, in if (man->macroset == MACROSET_MDOC) n->flags |= MDOC_VALID | MDOC_ENDED; else - man_valid_post(man); + n->flags |= MAN_VALID; man->next = ROFF_NEXT_SIBLING; } @@ -1151,7 +1151,7 @@ roff_addtbl(struct roff_man *man, const if (man->macroset == MACROSET_MDOC) n->flags |= MDOC_VALID | MDOC_ENDED; else - man_valid_post(man); + n->flags |= MAN_VALID; man->next = ROFF_NEXT_SIBLING; } Index: roff_int.h =================================================================== RCS file: /home/cvs/mdocml/mdocml/roff_int.h,v retrieving revision 1.5 retrieving revision 1.6 diff -Lroff_int.h -Lroff_int.h -u -p -r1.5 -r1.6 --- roff_int.h +++ roff_int.h @@ -40,7 +40,6 @@ void roff_node_delete(struct roff_man */ void man_breakscope(struct roff_man *, int); -void man_valid_post(struct roff_man *); void mdoc_argv_free(struct mdoc_arg *); __END_DECLS Index: man.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/man.c,v retrieving revision 1.165 retrieving revision 1.166 diff -Lman.c -Lman.c -u -p -r1.165 -r1.166 --- man.c +++ man.c @@ -332,3 +332,38 @@ man_mparse(const struct roff_man *man) assert(man && man->parse); return man->parse; } + +void +man_state(struct roff_man *man, struct roff_node *n) +{ + + switch(n->tok) { + case MAN_nf: + case MAN_EX: + if (man->flags & MAN_LITERAL && ! (n->flags & MAN_VALID)) + mandoc_msg(MANDOCERR_NF_SKIP, man->parse, + n->line, n->pos, "nf"); + man->flags |= MAN_LITERAL; + break; + case MAN_fi: + case MAN_EE: + if ( ! (man->flags & MAN_LITERAL) && + ! (n->flags & MAN_VALID)) + mandoc_msg(MANDOCERR_FI_SKIP, man->parse, + n->line, n->pos, "fi"); + man->flags &= ~MAN_LITERAL; + break; + default: + break; + } + man->last->flags |= MAN_VALID; +} + +void +man_validate(struct roff_man *man) +{ + + man->last = man->first; + man_node_validate(man); + man->flags &= ~MAN_LITERAL; +} Index: man_validate.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/man_validate.c,v retrieving revision 1.120 retrieving revision 1.121 diff -Lman_validate.c -Lman_validate.c -u -p -r1.120 -r1.121 --- man_validate.c +++ man_validate.c @@ -48,9 +48,7 @@ static void check_text(CHKARGS); static void post_AT(CHKARGS); static void post_IP(CHKARGS); static void post_vs(CHKARGS); -static void post_fi(CHKARGS); static void post_ft(CHKARGS); -static void post_nf(CHKARGS); static void post_OP(CHKARGS); static void post_TH(CHKARGS); static void post_UC(CHKARGS); @@ -79,8 +77,8 @@ static v_check man_valids[MAN_MAX] = { NULL, /* IR */ NULL, /* RI */ post_vs, /* sp */ - post_nf, /* nf */ - post_fi, /* fi */ + NULL, /* nf */ + NULL, /* fi */ NULL, /* RE */ check_part, /* RS */ NULL, /* DT */ @@ -90,8 +88,8 @@ static v_check man_valids[MAN_MAX] = { NULL, /* in */ post_ft, /* ft */ post_OP, /* OP */ - post_nf, /* EX */ - post_fi, /* EE */ + NULL, /* EX */ + NULL, /* EE */ post_UR, /* UR */ NULL, /* UE */ NULL, /* ll */ @@ -99,16 +97,23 @@ static v_check man_valids[MAN_MAX] = { void -man_valid_post(struct roff_man *man) +man_node_validate(struct roff_man *man) { struct roff_node *n; v_check *cp; n = man->last; - if (n->flags & MAN_VALID) - return; - n->flags |= MAN_VALID; + man->last = man->last->child; + while (man->last != NULL) { + man_node_validate(man); + if (man->last == n) + man->last = man->last->child; + else + man->last = man->last->next; + } + man->last = n; + man->next = ROFF_NEXT_SIBLING; switch (n->type) { case ROFFT_TEXT: check_text(man, n); @@ -123,6 +128,8 @@ man_valid_post(struct roff_man *man) cp = man_valids + n->tok; if (*cp) (*cp)(man, n); + if (man->last == n) + man_state(man, n); break; } } @@ -383,28 +390,6 @@ post_TH(CHKARGS) * meta-data. */ roff_node_delete(man, man->last); -} - -static void -post_nf(CHKARGS) -{ - - if (man->flags & MAN_LITERAL) - mandoc_msg(MANDOCERR_NF_SKIP, man->parse, - n->line, n->pos, "nf"); - - man->flags |= MAN_LITERAL; -} - -static void -post_fi(CHKARGS) -{ - - if ( ! (MAN_LITERAL & man->flags)) - mandoc_msg(MANDOCERR_FI_SKIP, man->parse, - n->line, n->pos, "fi"); - - man->flags &= ~MAN_LITERAL; } static void Index: man.h =================================================================== RCS file: /home/cvs/mdocml/mdocml/man.h,v retrieving revision 1.75 retrieving revision 1.76 diff -Lman.h -Lman.h -u -p -r1.75 -r1.76 --- man.h +++ man.h @@ -63,6 +63,7 @@ __BEGIN_DECLS struct roff_man; -const struct mparse *man_mparse(const struct roff_man *); +const struct mparse *man_mparse(const struct roff_man *); +void man_validate(struct roff_man *); __END_DECLS Index: libman.h =================================================================== RCS file: /home/cvs/mdocml/mdocml/libman.h,v retrieving revision 1.77 retrieving revision 1.78 diff -Llibman.h -Llibman.h -u -p -r1.77 -r1.78 --- libman.h +++ libman.h @@ -37,7 +37,8 @@ extern const struct man_macro *const man __BEGIN_DECLS int man_hash_find(const char *); -void man_valid_post(struct roff_man *); +void man_node_validate(struct roff_man *); +void man_state(struct roff_man *, struct roff_node *); void man_unscope(struct roff_man *, const struct roff_node *); __END_DECLS -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv