summaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_strings.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-05-12 08:41:17 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-05-12 08:41:17 +0000
commit9f11efb0307eb4c4dbb4a8fff243321100e27573 (patch)
tree1eec3760c1790106496b536cde695f4912d0278e /mdoc_strings.c
parentbc0b057e87136f91e81cd2c0f344327dabd21c7f (diff)
downloadmandoc-9f11efb0307eb4c4dbb4a8fff243321100e27573.tar.gz
mandoc-9f11efb0307eb4c4dbb4a8fff243321100e27573.tar.zst
mandoc-9f11efb0307eb4c4dbb4a8fff243321100e27573.zip
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.c64
1 files changed, 28 insertions, 36 deletions
diff --git a/mdoc_strings.c b/mdoc_strings.c
index 33f5da15..ff8eba1f 100644
--- a/mdoc_strings.c
+++ b/mdoc_strings.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_strings.c,v 1.18 2010/05/09 21:06:50 kristaps Exp $ */
+/* $Id: mdoc_strings.c,v 1.19 2010/05/12 08:41:17 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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);
}