diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-05-12 08:41:17 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-05-12 08:41:17 +0000 |
commit | 2e08684b6f7079837888e14e0a2129df281b31e8 (patch) | |
tree | 1114a34b670fa4462fe646d8deae3992e3d3eb70 | |
parent | 1caded1c8245d6b49a1f14453cd477f5c5920a15 (diff) | |
download | mandoc-2e08684b6f7079837888e14e0a2129df281b31e8.tar.gz |
mdoc_atosec -> mdoc_str2sec (consistent with str2 being different from a2).
Changed ordering of sections (EXIT STATUS moved around), argued for by Ulrich Sporlein.
Fixed mdoc_str2sec not to use weird structure.
-rw-r--r-- | libmdoc.h | 2 | ||||
-rw-r--r-- | man.7 | 20 | ||||
-rw-r--r-- | mdoc.7 | 26 | ||||
-rw-r--r-- | mdoc.h | 5 | ||||
-rw-r--r-- | mdoc.template | 4 | ||||
-rw-r--r-- | mdoc_action.c | 2 | ||||
-rw-r--r-- | mdoc_strings.c | 62 | ||||
-rw-r--r-- | mdoc_validate.c | 11 |
8 files changed, 64 insertions, 68 deletions
@@ -162,7 +162,7 @@ enum mdoct mdoc_hash_find(const char *); int mdoc_iscdelim(char); int mdoc_isdelim(const char *); size_t mdoc_isescape(const char *); -enum mdoc_sec mdoc_atosec(const char *); +enum mdoc_sec mdoc_str2sec(const char *); time_t mdoc_atotime(const char *); size_t mdoc_macro2len(enum mdoct); const char *mdoc_a2att(const char *); @@ -232,13 +232,13 @@ are generally structured as follows: The \efBfoo\efR utility processes files... \&. \&.\e\*q .SH IMPLEMENTATION NOTES -\&.\e\*q The next is for sections 1 & 8 only. -\&.\e\*q .SH EXIT STATUS \&.\e\*q The next is for sections 2, 3, & 9 only. \&.\e\*q .SH RETURN VALUES \&.\e\*q The next is for sections 1, 6, 7, & 8 only. \&.\e\*q .SH ENVIRONMENT \&.\e\*q .SH FILES +\&.\e\*q The next is for sections 1 & 8 only. +\&.\e\*q .SH EXIT STATUS \&.\e\*q .SH EXAMPLES \&.\e\*q The next is for sections 1, 4, 6, 7, & 8 only. \&.\e\*q .SH DIAGNOSTICS @@ -298,14 +298,6 @@ command). Implementation-specific notes should be kept here. This is useful when implementing standard functions that may have side effects or notable algorithmic implications. -.It Em EXIT STATUS -Command exit status for section 1, 6, and 8 manuals. This section is -the dual of -.Em RETURN VALUES , -which is used for functions. Historically, this information was -described in -.Em DIAGNOSTICS , -a practise that is now discouraged. .It Em RETURN VALUES This section is the dual of .Em EXIT STATUS , @@ -317,6 +309,14 @@ Documents any usages of environment variables, e.g., .It Em FILES Documents files used. It's helpful to document both the file and a short description of how the file is used (created, modified, etc.). +.It Em EXIT STATUS +Command exit status for section 1, 6, and 8 manuals. This section is +the dual of +.Em RETURN VALUES , +which is used for functions. Historically, this information was +described in +.Em DIAGNOSTICS , +a practise that is now discouraged. .It Em EXAMPLES Example usages. This often contains snippets of well-formed, well-tested invocations. Make doubly sure that your examples work @@ -334,13 +334,13 @@ The \&.Nm utility processes files ... \&.\e\*q .Sh IMPLEMENTATION NOTES -\&.\e\*q The next is for sections 1 & 8 only. -\&.\e\*q .Sh EXIT STATUS \&.\e\*q The next is for sections 2, 3, & 9 only. \&.\e\*q .Sh RETURN VALUES \&.\e\*q The next is for sections 1, 6, 7, & 8 only. \&.\e\*q .Sh ENVIRONMENT \&.\e\*q .Sh FILES +\&.\e\*q The next is for sections 1 & 8 only. +\&.\e\*q .Sh EXIT STATUS \&.\e\*q .Sh EXAMPLES \&.\e\*q The next is for sections 1, 4, 6, 7, & 8 only. \&.\e\*q .Sh DIAGNOSTICS @@ -452,17 +452,6 @@ Manuals not documenting a command won't include the above fragment. Implementation-specific notes should be kept here. This is useful when implementing standard functions that may have side effects or notable algorithmic implications. -.It Em EXIT STATUS -Command exit status for section 1, 6, and 8 manuals. This section is -the dual of -.Em RETURN VALUES , -which is used for functions. Historically, this information was -described in -.Em DIAGNOSTICS , -a practise that is now discouraged. -.Pp -See -.Sx \&Ex . .It Em RETURN VALUES This section is the dual of .Em EXIT STATUS , @@ -483,6 +472,17 @@ short description of how the file is used (created, modified, etc.). .Pp See .Sx \&Pa . +.It Em EXIT STATUS +Command exit status for section 1, 6, and 8 manuals. This section is +the dual of +.Em RETURN VALUES , +which is used for functions. Historically, this information was +described in +.Em DIAGNOSTICS , +a practise that is now discouraged. +.Pp +See +.Sx \&Ex . .It Em EXAMPLES Example usages. This often contains snippets of well-formed, well-tested invocations. Make doubly sure that your examples work @@ -202,10 +202,10 @@ enum mdoc_sec { SEC_SYNOPSIS, SEC_DESCRIPTION, SEC_IMPLEMENTATION, - SEC_EXIT_STATUS, SEC_RETURN_VALUES, SEC_ENVIRONMENT, SEC_FILES, + SEC_EXIT_STATUS, SEC_EXAMPLES, SEC_DIAGNOSTICS, SEC_COMPATIBILITY, @@ -217,7 +217,8 @@ enum mdoc_sec { SEC_CAVEATS, SEC_BUGS, SEC_SECURITY, - SEC_CUSTOM /* User-defined. */ + SEC_CUSTOM, /* User-defined. */ + SEC__MAX }; /* Information from prologue. */ diff --git a/mdoc.template b/mdoc.template index 5122f882..f26a83e6 100644 --- a/mdoc.template +++ b/mdoc.template @@ -19,13 +19,13 @@ .Sh SYNOPSIS .Sh DESCRIPTION .\" .Sh IMPLEMENTATION NOTES -.\" The next is for sections 1 & 8 only. -.\" .Sh EXIT STATUS .\" The next is for sections 2, 3, & 9 only. .\" .Sh RETURN VALUES .\" The next is for sections 1, 6, 7 & 8 only. .\" .Sh ENVIRONMENT .\" .Sh FILES +.\" The next is for sections 1 & 8 only. +.\" .Sh EXIT STATUS .\" .Sh EXAMPLES .\" The next is for sections 1, 4, 6, 7, & 8 only .\" .Sh DIAGNOSTICS diff --git a/mdoc_action.c b/mdoc_action.c index 63e25cd8..0883f7f1 100644 --- a/mdoc_action.c +++ b/mdoc_action.c @@ -419,7 +419,7 @@ post_sh(POST_ARGS) if ( ! concat(m, buf, n->child, BUFSIZ)) return(0); - sec = mdoc_atosec(buf); + sec = mdoc_str2sec(buf); /* * The first section should always make us move into a non-new * state. diff --git a/mdoc_strings.c b/mdoc_strings.c index b895cbe9..a852394b 100644 --- a/mdoc_strings.c +++ b/mdoc_strings.c @@ -28,39 +28,31 @@ #include "libmdoc.h" -/* FIXME: this file is poorly named. */ - -struct mdoc_secname { - const char *name; /* Name of section. */ - enum mdoc_sec sec; /* Corresponding section. */ -}; - -#define SECNAME_MAX (20) - -static const struct mdoc_secname secnames[SECNAME_MAX] = { - { "NAME", SEC_NAME }, - { "LIBRARY", SEC_LIBRARY }, - { "SYNOPSIS", SEC_SYNOPSIS }, - { "DESCRIPTION", SEC_DESCRIPTION }, - { "IMPLEMENTATION NOTES", SEC_IMPLEMENTATION }, - { "EXIT STATUS", SEC_EXIT_STATUS }, - { "RETURN VALUES", SEC_RETURN_VALUES }, - { "ENVIRONMENT", SEC_ENVIRONMENT }, - { "FILES", SEC_FILES }, - { "EXAMPLES", SEC_EXAMPLES }, - { "DIAGNOSTICS", SEC_DIAGNOSTICS }, - { "COMPATIBILITY", SEC_COMPATIBILITY }, - { "ERRORS", SEC_ERRORS }, - { "SEE ALSO", SEC_SEE_ALSO }, - { "STANDARDS", SEC_STANDARDS }, - { "HISTORY", SEC_HISTORY }, - { "AUTHORS", SEC_AUTHORS }, - { "CAVEATS", SEC_CAVEATS }, - { "BUGS", SEC_BUGS }, - { "SECURITY CONSIDERATIONS", SEC_SECURITY } +static const char * const secnames[SEC__MAX] = { + NULL, + "NAME", + "LIBRARY", + "SYNOPSIS", + "DESCRIPTION", + "IMPLEMENTATION NOTES", + "RETURN VALUES", + "ENVIRONMENT", + "FILES", + "EXIT STATUS", + "EXAMPLES", + "DIAGNOSTICS", + "COMPATIBILITY", + "ERRORS", + "SEE ALSO", + "STANDARDS", + "HISTORY", + "AUTHORS", + "CAVEATS", + "BUGS", + "SECURITY CONSIDERATIONS", + NULL }; - /* * FIXME: this is repeated in print_text() (html.c) and term_word() * (term.c). @@ -119,13 +111,13 @@ mdoc_isdelim(const char *p) enum mdoc_sec -mdoc_atosec(const char *p) +mdoc_str2sec(const char *p) { int i; - for (i = 0; i < SECNAME_MAX; i++) - if (0 == strcmp(p, secnames[i].name)) - return(secnames[i].sec); + for (i = 0; i < (int)SEC__MAX; i++) + if (secnames[i] && 0 == strcmp(p, secnames[i])) + return((enum mdoc_sec)i); return(SEC_CUSTOM); } diff --git a/mdoc_validate.c b/mdoc_validate.c index 5390158d..41207cab 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -1286,21 +1286,24 @@ post_sh_head(POST_ARGS) return(mdoc_nerr(mdoc, n, ETOOLONG)); } - sec = mdoc_atosec(buf); + sec = mdoc_str2sec(buf); /* * Check: NAME should always be first, CUSTOM has no roles, * non-CUSTOM has a conventional order to be followed. */ - if (SEC_NAME != sec && SEC_NONE == mdoc->lastnamed && - ! mdoc_nwarn(mdoc, mdoc->last, ESECNAME)) - return(0); + if (SEC_NAME != sec && SEC_NONE == mdoc->lastnamed) + if ( ! mdoc_nwarn(mdoc, mdoc->last, ESECNAME)) + return(0); + if (SEC_CUSTOM == sec) return(1); + if (sec == mdoc->lastnamed) if ( ! mdoc_nwarn(mdoc, mdoc->last, ESECREP)) return(0); + if (sec < mdoc->lastnamed) if ( ! mdoc_nwarn(mdoc, mdoc->last, ESECOOO)) return(0); |