diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-01-05 17:57:07 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-01-05 17:57:07 +0000 |
commit | 0a1a67c2c7759505f69bf1127a57b5232a7f84bd (patch) | |
tree | 98aeb84543ec76ae485fe13e0b24c57eb062964c | |
parent | e653c8089f13da940f3273f95fca6e7098852332 (diff) | |
download | mandoc-0a1a67c2c7759505f69bf1127a57b5232a7f84bd.tar.gz |
*** empty log message ***
-rw-r--r-- | argv.c | 21 | ||||
-rw-r--r-- | hash.c | 2 | ||||
-rw-r--r-- | macro.c | 19 | ||||
-rw-r--r-- | mdoc.c | 6 | ||||
-rw-r--r-- | mdoc.h | 3 | ||||
-rw-r--r-- | mdocml.c | 5 | ||||
-rw-r--r-- | prologue.c | 4 |
7 files changed, 34 insertions, 26 deletions
@@ -133,15 +133,6 @@ lookup(int tok, const char *argv) { switch (tok) { - case (MDOC_Bf): - if (xstrcmp(argv, "emphasis")) - return(MDOC_Emphasis); - else if (xstrcmp(argv, "literal")) - return(MDOC_Literal); - else if (xstrcmp(argv, "symbolic")) - return(MDOC_Symbolic); - break; - case (MDOC_An): if (xstrcmp(argv, "split")) return(MDOC_Split); @@ -162,6 +153,15 @@ lookup(int tok, const char *argv) return(MDOC_Offset); break; + case (MDOC_Bf): + if (xstrcmp(argv, "emphasis")) + return(MDOC_Emphasis); + else if (xstrcmp(argv, "literal")) + return(MDOC_Literal); + else if (xstrcmp(argv, "symbolic")) + return(MDOC_Symbolic); + break; + case (MDOC_Bk): if (xstrcmp(argv, "words")) return(MDOC_Words); @@ -283,8 +283,7 @@ lookup(int tok, const char *argv) break; default: - abort(); - /* NOTREACHED */ + break; } return(MDOC_ARG_MAX); @@ -112,6 +112,8 @@ mdoc_tokhash_find(const void *arg, const char *tmp) minor = tmp[1] - 97; ind = (major * 27) + minor; + if (ind < 0 || ind >= (27 * 26)) + return(MDOC_MAX); if (NULL == htab[ind]) return(MDOC_MAX); @@ -107,6 +107,7 @@ static int rewind_expblock(struct mdoc *mdoc, int ppos, int tok, int tt) { struct mdoc_node *n; + int t; assert(mdoc->last); @@ -114,9 +115,9 @@ rewind_expblock(struct mdoc *mdoc, int ppos, int tok, int tt) for (n = mdoc->last->parent; n; n = n->parent) { if (MDOC_BLOCK != n->type) continue; - if (tt == n->data.block.tok) + if (tt == (t = n->data.block.tok)) break; - if (MDOC_NESTED & mdoc_macros[n->data.block.tok].flags) + if (MDOC_NESTED & mdoc_macros[t].flags) continue; return(mdoc_err(mdoc, tok, ppos, ERR_SCOPE_BREAK)); } @@ -147,11 +148,16 @@ rewind_impblock(struct mdoc *mdoc, int ppos, int tok) break; if ( ! (MDOC_EXPLICIT & mdoc_macros[t].flags)) continue; + if (MDOC_NESTED & mdoc_macros[tok].flags) + return(1); return(mdoc_err(mdoc, tok, ppos, ERR_SCOPE_BREAK)); } - mdoc->last = n ? n : mdoc->last; + if (NULL == n) + return(1); + mdoc->next = MDOC_NEXT_SIBLING; + mdoc->last = n; if ( ! mdoc_valid_post(mdoc, tok, ppos)) return(0); return(mdoc_action(mdoc, tok, ppos)); @@ -215,8 +221,8 @@ macro_close_explicit(MACRO_PROT_ARGS) case (MDOC_El): tt = MDOC_Bl; break; - case (MDOC_Fo): - tt = MDOC_Fc; + case (MDOC_Fc): + tt = MDOC_Fo; break; case (MDOC_Oc): tt = MDOC_Oo; @@ -425,8 +431,7 @@ macro_scoped(MACRO_PROT_ARGS) assert ( ! (MDOC_CALLABLE & mdoc_macros[tok].flags)); - if ( ! (MDOC_EXPLICIT & mdoc_macros[tok].flags) && - ! (MDOC_NESTED & mdoc_macros[tok].flags)) + if ( ! (MDOC_EXPLICIT & mdoc_macros[tok].flags)) if ( ! rewind_impblock(mdoc, ppos, tok)) return(0); @@ -107,7 +107,7 @@ const struct mdoc_macro __mdoc_macros[MDOC_MAX] = { { macro_text, MDOC_CALLABLE }, /* Er */ { macro_text, MDOC_CALLABLE }, /* Ev */ { macro_constant, 0 }, /* Ex */ - { macro_text, MDOC_CALLABLE }, /* Fa */ + { macro_text, MDOC_CALLABLE | MDOC_QUOTABLE }, /* Fa */ { macro_constant, 0 }, /* Fd */ { macro_text, MDOC_CALLABLE }, /* Fl */ { macro_text, MDOC_CALLABLE | MDOC_QUOTABLE }, /* Fn */ @@ -168,7 +168,7 @@ const struct mdoc_macro __mdoc_macros[MDOC_MAX] = { { macro_scoped_line, MDOC_CALLABLE }, /* Ql */ { macro_constant_scoped, MDOC_CALLABLE }, /* Qo */ { macro_scoped_line, MDOC_CALLABLE }, /* Qq */ - { macro_scoped, MDOC_EXPLICIT }, /* Re */ + { macro_close_explicit, 0 }, /* Re */ { macro_scoped, MDOC_EXPLICIT }, /* Rs */ { macro_close_explicit, MDOC_CALLABLE }, /* Sc */ { macro_constant_scoped, MDOC_CALLABLE }, /* So */ @@ -252,6 +252,8 @@ mdoc_parseln(struct mdoc *mdoc, char *buf) char tmp[5]; if ('.' != *buf) { + if (SEC_PROLOGUE == mdoc->sec_lastn) + return(mdoc_err(mdoc, -1, 0, ERR_SYNTAX_NOTEXT)); mdoc_word_alloc(mdoc, 0, buf); mdoc->next = MDOC_NEXT_SIBLING; return(1); @@ -221,7 +221,8 @@ enum mdoc_err { ERR_SYNTAX_CHILDHEAD, ERR_SYNTAX_CHILDBODY, ERR_SYNTAX_EMPTYBODY, - ERR_SYNTAX_EMPTYHEAD + ERR_SYNTAX_EMPTYHEAD, + ERR_SYNTAX_NOTEXT }; enum mdoc_att { @@ -328,6 +328,9 @@ msg_err(void *arg, int tok, int col, enum mdoc_err type) fmt = lit = NULL; switch (type) { + case (ERR_SYNTAX_NOTEXT): + lit = "syntax: context-free text disallowed"; + break; case (ERR_SYNTAX_QUOTE): lit = "syntax: disallowed argument quotation"; break; @@ -357,7 +360,7 @@ msg_err(void *arg, int tok, int col, enum mdoc_err type) fmt = "scope: macro `%s' may not be nested in the current context"; break; case (ERR_MACRO_NOTSUP): - fmt = "macro `%s' not supported"; + lit = "macro not supported"; break; case (ERR_MACRO_NOTCALL): fmt = "macro `%s' not callable"; @@ -67,10 +67,6 @@ again: break; } - if (MDOC_MAX != mdoc_find(mdoc, args[j]) && ! mdoc_warn - (mdoc, tok, lastarg, WARN_SYNTAX_MACLIKE)) - return(0); - if (0 == j) { if (xstrlcpy(mdoc->meta.title, args[0], META_TITLE_SZ)) goto again; |