aboutsummaryrefslogtreecommitdiffstatshomepage
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
commita689df0aa61055b688017fe251c1440d1b82ea09 (patch)
tree1f6daf38d574c1132ad5827ec38864d6490d43ba /mdoc_validate.c
parentc951da7ef21e3e87c07a7d4b730990bef506f6d4 (diff)
downloadmandoc-a689df0aa61055b688017fe251c1440d1b82ea09.tar.gz
mandoc-a689df0aa61055b688017fe251c1440d1b82ea09.tar.zst
mandoc-a689df0aa61055b688017fe251c1440d1b82ea09.zip
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.c41
1 files changed, 39 insertions, 2 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index c4e7130f..c7d932cf 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.159 2011/03/15 16:23:51 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.160 2011/03/17 09:22:39 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -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);
+}
+