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 /mdoc_strings.c | |
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.
Diffstat (limited to 'mdoc_strings.c')
-rw-r--r-- | mdoc_strings.c | 62 |
1 files changed, 27 insertions, 35 deletions
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); } |