summaryrefslogtreecommitdiffstats
path: root/mdoc_validate.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-03-17 09:22:39 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-03-17 09:22:39 +0000
commit0583916dc21aa81e3e794e0475fbcf58b45833fc (patch)
tree5410a515b6abfa173ec2bd3e585ea346fe455524 /mdoc_validate.c
parent8efc30176986c7bf8c728cecbe5daafe5657732b (diff)
downloadmandoc-0583916dc21aa81e3e794e0475fbcf58b45833fc.tar.gz
Move mdoc_str2sec() into mdoc_validate.c as a2sec(), as that's the only
place that it's being used.
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r--mdoc_validate.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 3f845317..85774a1e 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -74,6 +74,7 @@ static void check_args(struct mdoc *, struct mdoc_node *);
static int concat(struct mdoc *, char *,
const struct mdoc_node *, size_t);
+static enum mdoc_sec a2sec(const char *);
static int ebool(POST_ARGS);
static int berr_ge1(POST_ARGS);
@@ -321,6 +322,30 @@ static const enum mdoct rsord[RSORD_MAX] = {
MDOC__U
};
+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
+};
int
mdoc_valid_pre(struct mdoc *mdoc, struct mdoc_node *n)
@@ -1821,7 +1846,7 @@ post_sh_head(POST_ARGS)
if ( ! concat(mdoc, buf, mdoc->last->child, BUFSIZ))
return(0);
- sec = mdoc_str2sec(buf);
+ sec = a2sec(buf);
/* The NAME should be first. */
@@ -2255,3 +2280,15 @@ concat(struct mdoc *m, char *p, const struct mdoc_node *n, size_t sz)
return(1);
}
+static enum mdoc_sec
+a2sec(const char *p)
+{
+ int i;
+
+ for (i = 0; i < (int)SEC__MAX; i++)
+ if (secnames[i] && 0 == strcmp(p, secnames[i]))
+ return((enum mdoc_sec)i);
+
+ return(SEC_CUSTOM);
+}
+