diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-01-21 11:35:26 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-01-21 11:35:26 +0000 |
commit | 750900b44b04f0713e1d2456b42c728b564c9c39 (patch) | |
tree | 25cdf9e2ab1b4cfcb3b0536bac7c982488c9eab2 /mdoc.c | |
parent | e2762e29b6445ab6177b83521a279938a317605f (diff) | |
download | mandoc-750900b44b04f0713e1d2456b42c728b564c9c39.tar.gz |
More validation on prologue/first NAME section.
Diffstat (limited to 'mdoc.c')
-rw-r--r-- | mdoc.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -305,8 +305,8 @@ mdoc_parseln(struct mdoc *mdoc, int line, char *buf) mdoc->linetok = 0; if ('.' != *buf) { - if ( ! (MDOC_BODYPARSE & mdoc->flags)) - return(mdoc_perr(mdoc, line, 0, "text disallowed")); + if (SEC_PROLOGUE == mdoc->lastnamed) + return(mdoc_perr(mdoc, line, 0, "text disallowed in document prologue")); if ( ! mdoc_word_alloc(mdoc, line, 0, buf)) return(0); mdoc->next = MDOC_NEXT_SIBLING; @@ -407,9 +407,12 @@ mdoc_macro(struct mdoc *mdoc, int tok, assert(mdoc_macros[tok].fp); - if ( ! (MDOC_PROLOGUE & mdoc_macros[tok].flags) && - ! (MDOC_BODYPARSE & mdoc->flags)) - return(mdoc_perr(mdoc, ln, ppos, "macro disallowed: not in document body")); + if (MDOC_PROLOGUE & mdoc_macros[tok].flags && + SEC_PROLOGUE != mdoc->lastnamed) + return(mdoc_perr(mdoc, ln, ppos, "macro disallowed in document body")); + if ( ! (MDOC_PROLOGUE & mdoc_macros[tok].flags) && + SEC_PROLOGUE == mdoc->lastnamed) + return(mdoc_perr(mdoc, ln, ppos, "macro disallowed in document prologue")); if (1 != ppos && ! (MDOC_CALLABLE & mdoc_macros[tok].flags)) return(mdoc_perr(mdoc, ln, ppos, "macro not callable")); return((*mdoc_macros[tok].fp)(mdoc, tok, ln, ppos, pos, buf)); |