diff options
author | 2009-06-19 07:20:19 +0000 | |
---|---|---|
committer | 2009-06-19 07:20:19 +0000 | |
commit | 6be99f77fdb520f853bd722d3dd06b747f0952f3 (patch) | |
tree | 144ecb6429e82bcb96f5da9819e453cd7f52ac64 /usr.bin/mandoc/mdoc_validate.c | |
parent | Always report 0 as the minimal brightness level to wscons. This results in (diff) | |
download | wireguard-openbsd-6be99f77fdb520f853bd722d3dd06b747f0952f3.tar.xz wireguard-openbsd-6be99f77fdb520f853bd722d3dd06b747f0952f3.zip |
sync to 1.7.19: more elegant section handling
Diffstat (limited to 'usr.bin/mandoc/mdoc_validate.c')
-rw-r--r-- | usr.bin/mandoc/mdoc_validate.c | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index c4447ec44ab..4cf3c36b977 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.8 2009/06/19 00:07:06 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.9 2009/06/19 07:20:19 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -42,6 +42,7 @@ enum merr { ELISTTYPE, EDISPTYPE, EMULTIDISP, + ESECNAME, EMULTILIST, EARGREP, EBOOL, @@ -116,7 +117,6 @@ static int pre_fd(PRE_ARGS); static int pre_it(PRE_ARGS); static int pre_lb(PRE_ARGS); static int pre_os(PRE_ARGS); -static int pre_prologue(PRE_ARGS); static int pre_rv(PRE_ARGS); static int pre_sh(PRE_ARGS); static int pre_ss(PRE_ARGS); @@ -155,15 +155,15 @@ static v_pre pres_an[] = { pre_an, NULL }; static v_pre pres_bd[] = { pre_display, pre_bd, NULL }; static v_pre pres_bl[] = { pre_bl, NULL }; static v_pre pres_cd[] = { pre_cd, NULL }; -static v_pre pres_dd[] = { pre_prologue, pre_dd, NULL }; +static v_pre pres_dd[] = { pre_dd, NULL }; static v_pre pres_d1[] = { pre_display, NULL }; -static v_pre pres_dt[] = { pre_prologue, pre_dt, NULL }; +static v_pre pres_dt[] = { pre_dt, NULL }; static v_pre pres_er[] = { pre_er, NULL }; static v_pre pres_ex[] = { pre_ex, NULL }; static v_pre pres_fd[] = { pre_fd, NULL }; static v_pre pres_it[] = { pre_it, NULL }; static v_pre pres_lb[] = { pre_lb, NULL }; -static v_pre pres_os[] = { pre_prologue, pre_os, NULL }; +static v_pre pres_os[] = { pre_os, NULL }; static v_pre pres_rv[] = { pre_rv, NULL }; static v_pre pres_sh[] = { pre_sh, NULL }; static v_pre pres_ss[] = { pre_ss, NULL }; @@ -408,6 +408,9 @@ perr(struct mdoc *m, int line, int pos, enum merr type) case (EDISPTYPE): p = "missing display type"; break; + case (ESECNAME): + p = "the NAME section must come first"; + break; case (ELINE): p = "expected line arguments"; break; @@ -1014,14 +1017,6 @@ pre_cd(PRE_ARGS) static int -pre_prologue(PRE_ARGS) -{ - - return(check_sec(mdoc, n, SEC_PROLOGUE, SEC_CUSTOM)); -} - - -static int pre_dt(PRE_ARGS) { @@ -1308,7 +1303,7 @@ post_root(POST_ARGS) if (NULL == mdoc->first->child) return(verr(mdoc, ENODATA)); - if (SEC_PROLOGUE == mdoc->lastnamed) + if ( ! (MDOC_PBODY & mdoc->flags)) return(verr(mdoc, ENOPROLOGUE)); if (MDOC_BLOCK != mdoc->first->child->type) @@ -1389,13 +1384,12 @@ post_sh_head(POST_ARGS) * certain manual sections. */ - assert(MDOC_Sh == mdoc->last->tok); - - /* This is just concat() inlined, which is irritating. */ - buf[0] = 0; + for (n = mdoc->last->child; n; n = n->next) { + /* XXX - copied from compact(). */ assert(MDOC_TEXT == n->type); + if (strlcat(buf, n->string, 64) >= 64) return(nerr(mdoc, n, ETOOLONG)); if (NULL == n->next) @@ -1406,21 +1400,24 @@ post_sh_head(POST_ARGS) sec = mdoc_atosec(buf); - /* The NAME section should always be first. */ + /* + * Check: NAME should always be first, CUSTOM has no roles, + * non-CUSTOM has a conventional order to be followed. + */ - if (SEC_BODY == mdoc->lastnamed && SEC_NAME != sec) - return(vwarn(mdoc, WSECOOO)); + if (SEC_NAME != sec && SEC_NONE == mdoc->lastnamed) + return(verr(mdoc, ESECNAME)); if (SEC_CUSTOM == sec) return(1); - - /* Check for repeated or out-of-order sections. */ - if (sec == mdoc->lastnamed) return(vwarn(mdoc, WSECREP)); if (sec < mdoc->lastnamed) return(vwarn(mdoc, WSECOOO)); - /* Check particular section/manual section conventions. */ + /* + * Check particular section/manual conventions. LIBRARY can + * only occur in msec 2, 3 (TODO: are there more of these?). + */ switch (sec) { case (SEC_LIBRARY): |