diff options
-rw-r--r-- | libman.h | 19 | ||||
-rw-r--r-- | man.c | 186 | ||||
-rw-r--r-- | man.h | 1 | ||||
-rw-r--r-- | man_macro.c | 139 | ||||
-rw-r--r-- | man_validate.c | 115 | ||||
-rw-r--r-- | tree.c | 5 |
6 files changed, 181 insertions, 284 deletions
@@ -46,7 +46,7 @@ struct man { char *buf struct man_macro { - int (*fp)(MACRO_PROT_ARGS); + void (*fp)(MACRO_PROT_ARGS); int flags; #define MAN_SCOPED (1 << 0) #define MAN_EXPLICIT (1 << 1) /* See blk_imp(). */ @@ -61,19 +61,18 @@ extern const struct man_macro *const man_macros; __BEGIN_DECLS -int man_word_alloc(struct man *, int, int, const char *); +void man_word_alloc(struct man *, int, int, const char *); void man_word_append(struct man *, const char *); -int man_block_alloc(struct man *, int, int, enum mant); -int man_head_alloc(struct man *, int, int, enum mant); -int man_tail_alloc(struct man *, int, int, enum mant); -int man_body_alloc(struct man *, int, int, enum mant); -int man_elem_alloc(struct man *, int, int, enum mant); +void man_block_alloc(struct man *, int, int, enum mant); +void man_head_alloc(struct man *, int, int, enum mant); +void man_body_alloc(struct man *, int, int, enum mant); +void man_elem_alloc(struct man *, int, int, enum mant); void man_node_delete(struct man *, struct man_node *); void man_hash_init(void); enum mant man_hash_find(const char *); -int man_macroend(struct man *); -int man_valid_post(struct man *); -int man_unscope(struct man *, const struct man_node *); +void man_macroend(struct man *); +void man_valid_post(struct man *); +void man_unscope(struct man *, const struct man_node *); __END_DECLS @@ -50,8 +50,7 @@ const char * const *man_macronames = __man_macronames; static struct man_node *man_node_alloc(struct man *, int, int, enum man_type, enum mant); -static int man_node_append(struct man *, - struct man_node *); +static void man_node_append(struct man *, struct man_node *); static void man_node_free(struct man_node *); static void man_node_unlink(struct man *, struct man_node *); @@ -59,7 +58,7 @@ static int man_ptext(struct man *, int, char *, int); static int man_pmacro(struct man *, int, char *, int); static void man_free1(struct man *); static void man_alloc1(struct man *); -static int man_descope(struct man *, int, int); +static void man_descope(struct man *, int, int); const struct man_node * @@ -112,7 +111,8 @@ int man_endparse(struct man *man) { - return(man_macroend(man)); + man_macroend(man); + return(1); } int @@ -133,16 +133,11 @@ man_free1(struct man *man) if (man->first) man_node_delete(man, man->first); - if (man->meta.title) - free(man->meta.title); - if (man->meta.source) - free(man->meta.source); - if (man->meta.date) - free(man->meta.date); - if (man->meta.vol) - free(man->meta.vol); - if (man->meta.msec) - free(man->meta.msec); + free(man->meta.title); + free(man->meta.source); + free(man->meta.date); + free(man->meta.vol); + free(man->meta.msec); } static void @@ -159,13 +154,13 @@ man_alloc1(struct man *man) } -static int +static void man_node_append(struct man *man, struct man_node *p) { assert(man->last); assert(man->first); - assert(MAN_ROOT != p->type); + assert(p->type != MAN_ROOT); switch (man->next) { case MAN_NEXT_SIBLING: @@ -191,15 +186,11 @@ man_node_append(struct man *man, struct man_node *p) man->flags &= ~MAN_LITERAL; break; case MAN_HEAD: - assert(MAN_BLOCK == p->parent->type); + assert(p->parent->type == MAN_BLOCK); p->parent->head = p; break; - case MAN_TAIL: - assert(MAN_BLOCK == p->parent->type); - p->parent->tail = p; - break; case MAN_BODY: - assert(MAN_BLOCK == p->parent->type); + assert(p->parent->type == MAN_BLOCK); p->parent->body = p; break; default: @@ -212,14 +203,11 @@ man_node_append(struct man *man, struct man_node *p) case MAN_TBL: /* FALLTHROUGH */ case MAN_TEXT: - if ( ! man_valid_post(man)) - return(0); + man_valid_post(man); break; default: break; } - - return(1); } static struct man_node * @@ -234,85 +222,61 @@ man_node_alloc(struct man *man, int line, int pos, p->type = type; p->tok = tok; - if (MAN_NEWLINE & man->flags) + if (man->flags & MAN_NEWLINE) p->flags |= MAN_LINE; man->flags &= ~MAN_NEWLINE; return(p); } -int +void man_elem_alloc(struct man *man, int line, int pos, enum mant tok) { struct man_node *p; p = man_node_alloc(man, line, pos, MAN_ELEM, tok); - if ( ! man_node_append(man, p)) - return(0); - man->next = MAN_NEXT_CHILD; - return(1); -} - -int -man_tail_alloc(struct man *man, int line, int pos, enum mant tok) -{ - struct man_node *p; - - p = man_node_alloc(man, line, pos, MAN_TAIL, tok); - if ( ! man_node_append(man, p)) - return(0); + man_node_append(man, p); man->next = MAN_NEXT_CHILD; - return(1); } -int +void man_head_alloc(struct man *man, int line, int pos, enum mant tok) { struct man_node *p; p = man_node_alloc(man, line, pos, MAN_HEAD, tok); - if ( ! man_node_append(man, p)) - return(0); + man_node_append(man, p); man->next = MAN_NEXT_CHILD; - return(1); } -int +void man_body_alloc(struct man *man, int line, int pos, enum mant tok) { struct man_node *p; p = man_node_alloc(man, line, pos, MAN_BODY, tok); - if ( ! man_node_append(man, p)) - return(0); + man_node_append(man, p); man->next = MAN_NEXT_CHILD; - return(1); } -int +void man_block_alloc(struct man *man, int line, int pos, enum mant tok) { struct man_node *p; p = man_node_alloc(man, line, pos, MAN_BLOCK, tok); - if ( ! man_node_append(man, p)) - return(0); + man_node_append(man, p); man->next = MAN_NEXT_CHILD; - return(1); } -int +void man_word_alloc(struct man *man, int line, int pos, const char *word) { struct man_node *n; n = man_node_alloc(man, line, pos, MAN_TEXT, MAN_MAX); n->string = roff_strdup(man->roff, word); - - if ( ! man_node_append(man, n)) - return(0); - + man_node_append(man, n); man->next = MAN_NEXT_SIBLING; - return(1); } void @@ -338,8 +302,7 @@ static void man_node_free(struct man_node *p) { - if (p->string) - free(p->string); + free(p->string); free(p); } @@ -363,12 +326,10 @@ man_addeqn(struct man *man, const struct eqn *ep) n->eqn = ep; if (ep->ln > man->last->line) n->flags |= MAN_LINE; - - if ( ! man_node_append(man, n)) - return(0); - + man_node_append(man, n); man->next = MAN_NEXT_SIBLING; - return(man_descope(man, ep->ln, ep->pos)); + man_descope(man, ep->ln, ep->pos); + return(1); } int @@ -378,15 +339,13 @@ man_addspan(struct man *man, const struct tbl_span *sp) n = man_node_alloc(man, sp->line, 0, MAN_TBL, MAN_MAX); n->span = sp; - - if ( ! man_node_append(man, n)) - return(0); - + man_node_append(man, n); man->next = MAN_NEXT_SIBLING; - return(man_descope(man, sp->line, 0)); + man_descope(man, sp->line, 0); + return(1); } -static int +static void man_descope(struct man *man, int line, int offs) { /* @@ -395,19 +354,15 @@ man_descope(struct man *man, int line, int offs) * out the block scope (also if applicable). */ - if (MAN_ELINE & man->flags) { + if (man->flags & MAN_ELINE) { man->flags &= ~MAN_ELINE; - if ( ! man_unscope(man, man->last->parent)) - return(0); + man_unscope(man, man->last->parent); } - - if ( ! (MAN_BLINE & man->flags)) - return(1); + if ( ! (man->flags & MAN_BLINE)) + return; man->flags &= ~MAN_BLINE; - - if ( ! man_unscope(man, man->last->parent)) - return(0); - return(man_body_alloc(man, line, offs, man->last->tok)); + man_unscope(man, man->last->parent); + man_body_alloc(man, line, offs, man->last->tok); } static int @@ -417,13 +372,13 @@ man_ptext(struct man *man, int line, char *buf, int offs) /* Literal free-form text whitespace is preserved. */ - if (MAN_LITERAL & man->flags) { - if ( ! man_word_alloc(man, line, offs, buf + offs)) - return(0); - return(man_descope(man, line, offs)); + if (man->flags & MAN_LITERAL) { + man_word_alloc(man, line, offs, buf + offs); + man_descope(man, line, offs); + return(1); } - for (i = offs; ' ' == buf[i]; i++) + for (i = offs; buf[i] == ' '; i++) /* Skip leading whitespace. */ ; /* @@ -431,12 +386,11 @@ man_ptext(struct man *man, int line, char *buf, int offs) * but add a single vertical space elsewhere. */ - if ('\0' == buf[i]) { + if (buf[i] == '\0') { /* Allocate a blank entry. */ - if (MAN_SH != man->last->tok && - MAN_SS != man->last->tok) { - if ( ! man_elem_alloc(man, line, offs, MAN_sp)) - return(0); + if (man->last->tok != MAN_SH && + man->last->tok != MAN_SS) { + man_elem_alloc(man, line, offs, MAN_sp); man->next = MAN_NEXT_SIBLING; } return(1); @@ -463,9 +417,7 @@ man_ptext(struct man *man, int line, char *buf, int offs) buf[i] = '\0'; } - - if ( ! man_word_alloc(man, line, offs, buf + offs)) - return(0); + man_word_alloc(man, line, offs, buf + offs); /* * End-of-sentence check. If the last character is an unescaped @@ -477,7 +429,8 @@ man_ptext(struct man *man, int line, char *buf, int offs) if (mandoc_eos(buf, (size_t)i)) man->last->flags |= MAN_EOS; - return(man_descope(man, line, offs)); + man_descope(man, line, offs); + return(1); } static int @@ -528,7 +481,7 @@ man_pmacro(struct man *man, int ln, char *buf, int offs) /* Jump to the next non-whitespace word. */ - while (buf[offs] && ' ' == buf[offs]) + while (buf[offs] && buf[offs] == ' ') offs++; /* @@ -536,7 +489,7 @@ man_pmacro(struct man *man, int ln, char *buf, int offs) * into the parser as "text", so we only warn about spaces here. */ - if ('\0' == buf[offs] && ' ' == buf[offs - 1]) + if (buf[offs] == '\0' && buf[offs - 1] == ' ') mandoc_msg(MANDOCERR_SPACE_EOL, man->parse, ln, offs - 1, NULL); @@ -546,14 +499,14 @@ man_pmacro(struct man *man, int ln, char *buf, int offs) * macros---they don't print text---so we let those slip by. */ - if ( ! (MAN_NSCOPED & man_macros[tok].flags) && + if ( ! (man_macros[tok].flags & MAN_NSCOPED) && man->flags & MAN_ELINE) { n = man->last; assert(MAN_TEXT != n->type); /* Remove repeated NSCOPED macros causing ELINE. */ - if (MAN_NSCOPED & man_macros[n->tok].flags) + if (man_macros[n->tok].flags & MAN_NSCOPED) n = n->parent; mandoc_vmsg(MANDOCERR_BLK_LINE, man->parse, n->line, @@ -568,24 +521,24 @@ man_pmacro(struct man *man, int ln, char *buf, int offs) * Remove prior BLINE macro that is being clobbered. */ if ((man->flags & MAN_BLINE) && - (MAN_BSCOPE & man_macros[tok].flags)) { + (man_macros[tok].flags & MAN_BSCOPE)) { n = man->last; /* Might be a text node like 8 in * .TP 8 * .SH foo */ - if (MAN_TEXT == n->type) + if (n->type == MAN_TEXT) n = n->parent; /* Remove element that didn't end BLINE, if any. */ - if ( ! (MAN_BSCOPE & man_macros[n->tok].flags)) + if ( ! (man_macros[n->tok].flags & MAN_BSCOPE)) n = n->parent; - assert(MAN_HEAD == n->type); + assert(n->type == MAN_HEAD); n = n->parent; - assert(MAN_BLOCK == n->type); - assert(MAN_SCOPED & man_macros[n->tok].flags); + assert(n->type == MAN_BLOCK); + assert(man_macros[n->tok].flags & MAN_SCOPED); mandoc_vmsg(MANDOCERR_BLK_LINE, man->parse, n->line, n->pos, "%s breaks %s", man_macronames[tok], @@ -602,14 +555,13 @@ man_pmacro(struct man *man, int ln, char *buf, int offs) /* Call to handler... */ assert(man_macros[tok].fp); - if ( ! (*man_macros[tok].fp)(man, tok, ln, ppos, &offs, buf)) - return(0); + (*man_macros[tok].fp)(man, tok, ln, ppos, &offs, buf); /* In quick mode (for mandocdb), abort after the NAME section. */ - if (man->quick && MAN_SH == tok) { + if (man->quick && tok == MAN_SH) { n = man->last; - if (MAN_BODY == n->type && + if (n->type == MAN_BODY && strcmp(n->prev->child->string, "NAME")) return(2); } @@ -624,12 +576,12 @@ man_pmacro(struct man *man, int ln, char *buf, int offs) man_macros[tok].flags & MAN_NSCOPED) return(1); - assert(MAN_BLINE & man->flags); + assert(man->flags & MAN_BLINE); man->flags &= ~MAN_BLINE; - if ( ! man_unscope(man, man->last->parent)) - return(0); - return(man_body_alloc(man, ln, ppos, man->last->tok)); + man_unscope(man, man->last->parent); + man_body_alloc(man, ln, ppos, man->last->tok); + return(1); } /* @@ -687,7 +639,7 @@ man_deroff(char **dest, const struct man_node *n) char *cp; size_t sz; - if (MAN_TEXT != n->type) { + if (n->type != MAN_TEXT) { for (n = n->child; n; n = n->next) man_deroff(dest, n); return; @@ -68,7 +68,6 @@ enum man_type { MAN_BLOCK, MAN_HEAD, MAN_BODY, - MAN_TAIL, MAN_TBL, MAN_EQN }; diff --git a/man_macro.c b/man_macro.c index e576c8ac..403b010b 100644 --- a/man_macro.c +++ b/man_macro.c @@ -36,14 +36,14 @@ enum rew { REW_HALT }; -static int blk_close(MACRO_PROT_ARGS); -static int blk_exp(MACRO_PROT_ARGS); -static int blk_imp(MACRO_PROT_ARGS); -static int in_line_eoln(MACRO_PROT_ARGS); +static void blk_close(MACRO_PROT_ARGS); +static void blk_exp(MACRO_PROT_ARGS); +static void blk_imp(MACRO_PROT_ARGS); +static void in_line_eoln(MACRO_PROT_ARGS); static int man_args(struct man *, int, int *, char *, char **); -static int rew_scope(enum man_type, +static void rew_scope(enum man_type, struct man *, enum mant); static enum rew rew_dohalt(enum mant, enum man_type, const struct man_node *); @@ -95,7 +95,7 @@ const struct man_macro __man_macros[MAN_MAX] = { const struct man_macro * const man_macros = __man_macros; -int +void man_unscope(struct man *man, const struct man_node *to) { struct man_node *n; @@ -141,8 +141,7 @@ man_unscope(struct man *man, const struct man_node *to) man->last = n; n = n->parent; - if ( ! man_valid_post(man)) - return(0); + man_valid_post(man); } /* @@ -154,16 +153,14 @@ man_unscope(struct man *man, const struct man_node *to) man->next = (man->last == to) ? MAN_NEXT_CHILD : MAN_NEXT_SIBLING; - - return(1); } static enum rew rew_block(enum mant ntok, enum man_type type, const struct man_node *n) { - if (MAN_BLOCK == type && ntok == n->parent->tok && - MAN_BODY == n->parent->type) + if (type == MAN_BLOCK && ntok == n->parent->tok && + n->parent->type == MAN_BODY) return(REW_REWIND); return(ntok == n->tok ? REW_HALT : REW_NOHALT); } @@ -246,7 +243,7 @@ rew_dohalt(enum mant tok, enum man_type type, const struct man_node *n) * for example, the `SH' macro will close out any intervening `SS' * scopes. When a scope is closed, it must be validated and actioned. */ -static int +static void rew_scope(enum man_type type, struct man *man, enum mant tok) { struct man_node *n; @@ -260,7 +257,7 @@ rew_scope(enum man_type type, struct man *man, enum mant tok) */ c = rew_dohalt(tok, type, n); if (REW_HALT == c) - return(1); + return; if (REW_REWIND == c) break; } @@ -269,16 +266,15 @@ rew_scope(enum man_type type, struct man *man, enum mant tok) * Rewind until the current point. Warn if we're a roff * instruction that's mowing over explicit scopes. */ - assert(n); - return(man_unscope(man, n)); + man_unscope(man, n); } /* * Close out a generic explicit macro. */ -int +void blk_close(MACRO_PROT_ARGS) { enum mant ntok; @@ -297,57 +293,46 @@ blk_close(MACRO_PROT_ARGS) } for (nn = man->last->parent; nn; nn = nn->parent) - if (ntok == nn->tok && MAN_BLOCK == nn->type) + if (nn->tok == ntok && nn->type == MAN_BLOCK) break; - if (NULL == nn) { + if (nn == NULL) { mandoc_msg(MANDOCERR_BLK_NOTOPEN, man->parse, line, ppos, man_macronames[tok]); - if ( ! rew_scope(MAN_BLOCK, man, MAN_PP)) - return(0); + rew_scope(MAN_BLOCK, man, MAN_PP); } else man_unscope(man, nn); - - return(1); } -int +void blk_exp(MACRO_PROT_ARGS) { struct man_node *n; int la; char *p; - /* Close out prior implicit scopes. */ - - if ( ! rew_scope(MAN_BLOCK, man, tok)) - return(0); - - if ( ! man_block_alloc(man, line, ppos, tok)) - return(0); - if ( ! man_head_alloc(man, line, ppos, tok)) - return(0); + rew_scope(MAN_BLOCK, man, tok); + man_block_alloc(man, line, ppos, tok); + man_head_alloc(man, line, ppos, tok); for (;;) { la = *pos; if ( ! man_args(man, line, pos, buf, &p)) break; - if ( ! man_word_alloc(man, line, la, p)) - return(0); + man_word_alloc(man, line, la, p); } assert(man); assert(tok != MAN_MAX); - for (n = man->last; n; n = n->parent) { - if (n->tok != tok) - continue; - assert(MAN_HEAD == n->type); - man_unscope(man, n); - break; - } + for (n = man->last; n; n = n->parent) + if (n->tok == tok) { + assert(n->type == MAN_HEAD); + man_unscope(man, n); + break; + } - return(man_body_alloc(man, line, ppos, tok)); + man_body_alloc(man, line, ppos, tok); } /* @@ -356,27 +341,17 @@ blk_exp(MACRO_PROT_ARGS) * scopes, such as `SH' closing out an `SS', are defined in the rew * routines. */ -int +void blk_imp(MACRO_PROT_ARGS) { int la; char *p; struct man_node *n; - /* Close out prior scopes. */ - - if ( ! rew_scope(MAN_BODY, man, tok)) - return(0); - if ( ! rew_scope(MAN_BLOCK, man, tok)) - return(0); - - /* Allocate new block & head scope. */ - - if ( ! man_block_alloc(man, line, ppos, tok)) - return(0); - if ( ! man_head_alloc(man, line, ppos, tok)) - return(0); - + rew_scope(MAN_BODY, man, tok); + rew_scope(MAN_BLOCK, man, tok); + man_block_alloc(man, line, ppos, tok); + man_head_alloc(man, line, ppos, tok); n = man->last; /* Add line arguments. */ @@ -385,38 +360,33 @@ blk_imp(MACRO_PROT_ARGS) la = *pos; if ( ! man_args(man, line, pos, buf, &p)) break; - if ( ! man_word_alloc(man, line, la, p)) - return(0); + man_word_alloc(man, line, la, p); } /* Close out head and open body (unless MAN_SCOPE). */ - if (MAN_SCOPED & man_macros[tok].flags) { + if (man_macros[tok].flags & MAN_SCOPED) { /* If we're forcing scope (`TP'), keep it open. */ - if (MAN_FSCOPED & man_macros[tok].flags) { + if (man_macros[tok].flags & MAN_FSCOPED) { man->flags |= MAN_BLINE; - return(1); + return; } else if (n == man->last) { man->flags |= MAN_BLINE; - return(1); + return; } } - - if ( ! rew_scope(MAN_HEAD, man, tok)) - return(0); - return(man_body_alloc(man, line, ppos, tok)); + rew_scope(MAN_HEAD, man, tok); + man_body_alloc(man, line, ppos, tok); } -int +void in_line_eoln(MACRO_PROT_ARGS) { int la; char *p; struct man_node *n; - if ( ! man_elem_alloc(man, line, ppos, tok)) - return(0); - + man_elem_alloc(man, line, ppos, tok); n = man->last; for (;;) { @@ -426,8 +396,8 @@ in_line_eoln(MACRO_PROT_ARGS) if (man_macros[tok].flags & MAN_JOIN && man->last->type == MAN_TEXT) man_word_append(man, p); - else if ( ! man_word_alloc(man, line, la, p)) - return(0); + else + man_word_alloc(man, line, la, p); } /* @@ -445,13 +415,13 @@ in_line_eoln(MACRO_PROT_ARGS) * waiting for terms to load into our context. */ - if (n == man->last && MAN_SCOPED & man_macros[tok].flags) { - assert( ! (MAN_NSCOPED & man_macros[tok].flags)); + if (n == man->last && man_macros[tok].flags & MAN_SCOPED) { + assert( ! (man_macros[tok].flags & MAN_NSCOPED)); man->flags |= MAN_ELINE; - return(1); + return; } - assert(MAN_ROOT != man->last->type); + assert(man->last->type != MAN_ROOT); man->next = MAN_NEXT_SIBLING; /* @@ -465,8 +435,7 @@ in_line_eoln(MACRO_PROT_ARGS) break; if (man->last->type == MAN_ROOT) break; - if ( ! man_valid_post(man)) - return(0); + man_valid_post(man); } assert(man->last); @@ -475,18 +444,16 @@ in_line_eoln(MACRO_PROT_ARGS) * Same here regarding whether we're back at the root. */ - if (man->last->type != MAN_ROOT && ! man_valid_post(man)) - return(0); - - return(1); + if (man->last->type != MAN_ROOT) + man_valid_post(man); } -int +void man_macroend(struct man *man) { - return(man_unscope(man, man->first)); + man_unscope(man, man->first); } static int diff --git a/man_validate.c b/man_validate.c index 78c10af0..5688bb54 100644 --- a/man_validate.c +++ b/man_validate.c @@ -1,4 +1,4 @@ -/* $Id$ */ +/* $OpenBSD$ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -36,26 +36,26 @@ #define CHKARGS struct man *man, struct man_node *n -typedef int (*v_check)(CHKARGS); - -static int check_eq0(CHKARGS); -static int check_eq2(CHKARGS); -static int check_le1(CHKARGS); -static int check_le5(CHKARGS); -static int check_par(CHKARGS); -static int check_part(CHKARGS); -static int check_root(CHKARGS); -static int check_text(CHKARGS); - -static int post_AT(CHKARGS); -static int post_IP(CHKARGS); -static int post_vs(CHKARGS); -static int post_fi(CHKARGS); -static int post_ft(CHKARGS); -static int post_nf(CHKARGS); -static int post_TH(CHKARGS); -static int post_UC(CHKARGS); -static int post_UR(CHKARGS); +typedef void (*v_check)(CHKARGS); + +static void check_eq0(CHKARGS); +static void check_eq2(CHKARGS); +static void check_le1(CHKARGS); +static void check_le5(CHKARGS); +static void check_par(CHKARGS); +static void check_part(CHKARGS); +static void check_root(CHKARGS); +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_TH(CHKARGS); +static void post_UC(CHKARGS); +static void post_UR(CHKARGS); static v_check man_valids[MAN_MAX] = { post_vs, /* br */ @@ -100,7 +100,7 @@ static v_check man_valids[MAN_MAX] = { }; -int +void man_valid_post(struct man *man) { struct man_node *n; @@ -108,25 +108,29 @@ man_valid_post(struct man *man) n = man->last; if (n->flags & MAN_VALID) - return(1); + return; n->flags |= MAN_VALID; switch (n->type) { case MAN_TEXT: - return(check_text(man, n)); + check_text(man, n); + break; case MAN_ROOT: - return(check_root(man, n)); + check_root(man, n); + break; case MAN_EQN: /* FALLTHROUGH */ case MAN_TBL: - return(1); + break; default: cp = man_valids + n->tok; - return(*cp ? (*cp)(man, n) : 1); + if (*cp) + (*cp)(man, n); + break; } } -static int +static void check_root(CHKARGS) { @@ -152,35 +156,31 @@ check_root(CHKARGS) man->meta.date = man->quick ? mandoc_strdup("") : mandoc_normdate(man->parse, NULL, n->line, n->pos); } - - return(1); } -static int +static void check_text(CHKARGS) { char *cp, *p; if (MAN_LITERAL & man->flags) - return(1); + return; cp = n->string; for (p = cp; NULL != (p = strchr(p, '\t')); p++) mandoc_msg(MANDOCERR_FI_TAB, man->parse, n->line, n->pos + (p - cp), NULL); - return(1); } #define INEQ_DEFINE(x, ineq, name) \ -static int \ +static void \ check_##name(CHKARGS) \ { \ if (n->nchild ineq (x)) \ - return(1); \ + return; \ mandoc_vmsg(MANDOCERR_ARGCOUNT, man->parse, n->line, n->pos, \ "line arguments %s %d (have %d)", \ #ineq, (x), n->nchild); \ - return(1); \ } INEQ_DEFINE(0, ==, eq0) @@ -188,25 +188,24 @@ INEQ_DEFINE(2, ==, eq2) INEQ_DEFINE(1, <=, le1) INEQ_DEFINE(5, <=, le5) -static int +static void post_UR(CHKARGS) { if (MAN_HEAD == n->type && 1 != n->nchild) mandoc_vmsg(MANDOCERR_ARGCOUNT, man->parse, n->line, n->pos, "line arguments eq 1 (have %d)", n->nchild); - - return(check_part(man, n)); + check_part(man, n); } -static int +static void post_ft(CHKARGS) { char *cp; int ok; if (0 == n->nchild) - return(1); + return; ok = 0; cp = n->child->string; @@ -248,22 +247,18 @@ post_ft(CHKARGS) if (1 < n->nchild) mandoc_vmsg(MANDOCERR_ARGCOUNT, man->parse, n->line, n->pos, "want one child (have %d)", n->nchild); - - return(1); } -static int +static void check_part(CHKARGS) { if (MAN_BODY == n->type && 0 == n->nchild) mandoc_msg(MANDOCERR_ARGCWARN, man->parse, n->line, n->pos, "want children (have none)"); - - return(1); } -static int +static void check_par(CHKARGS) { @@ -289,11 +284,9 @@ check_par(CHKARGS) default: break; } - - return(1); } -static int +static void post_IP(CHKARGS) { @@ -311,10 +304,9 @@ post_IP(CHKARGS) default: break; } - return(1); } -static int +static void post_TH(CHKARGS) { struct man_node *nb; @@ -402,10 +394,9 @@ post_TH(CHKARGS) * meta-data. */ man_node_delete(man, man->last); - return(1); } -static int +static void post_nf(CHKARGS) { @@ -416,10 +407,9 @@ post_nf(CHKARGS) n->line, n->pos, "nf"); man->flags |= MAN_LITERAL; - return(1); } -static int +static void post_fi(CHKARGS) { @@ -430,10 +420,9 @@ post_fi(CHKARGS) n->line, n->pos, "fi"); man->flags &= ~MAN_LITERAL; - return(1); } -static int +static void post_UC(CHKARGS) { static const char * const bsd_versions[] = { @@ -468,10 +457,9 @@ post_UC(CHKARGS) free(man->meta.source); man->meta.source = mandoc_strdup(p); - return(1); } -static int +static void post_AT(CHKARGS) { static const char * const unix_versions[] = { @@ -506,10 +494,9 @@ post_AT(CHKARGS) free(man->meta.source); man->meta.source = mandoc_strdup(p); - return(1); } -static int +static void post_vs(CHKARGS) { @@ -519,7 +506,7 @@ post_vs(CHKARGS) check_le1(man, n); if (NULL != n->prev) - return(1); + return; switch (n->parent->tok) { case MAN_SH: @@ -539,6 +526,4 @@ post_vs(CHKARGS) default: break; } - - return(1); } @@ -200,9 +200,6 @@ print_man(const struct man_node *n, int indent) case MAN_BODY: t = "block-body"; break; - case MAN_TAIL: - t = "block-tail"; - break; case MAN_TBL: break; case MAN_EQN: @@ -223,8 +220,6 @@ print_man(const struct man_node *n, int indent) /* FALLTHROUGH */ case MAN_HEAD: /* FALLTHROUGH */ - case MAN_TAIL: - /* FALLTHROUGH */ case MAN_BODY: p = man_macronames[n->tok]; break; |