diff options
-rw-r--r-- | libmdoc.h | 1 | ||||
-rw-r--r-- | mdoc_strings.c | 38 | ||||
-rw-r--r-- | mdoc_validate.c | 39 |
3 files changed, 38 insertions, 40 deletions
@@ -108,7 +108,6 @@ void mdoc_node_delete(struct mdoc *, struct mdoc_node *); void mdoc_hash_init(void); enum mdoct mdoc_hash_find(const char *); size_t mdoc_isescape(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 *); diff --git a/mdoc_strings.c b/mdoc_strings.c index 8f2dddbc..6745e36a 100644 --- a/mdoc_strings.c +++ b/mdoc_strings.c @@ -29,44 +29,6 @@ #include "mandoc.h" #include "libmdoc.h" -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 -}; - -enum mdoc_sec -mdoc_str2sec(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); -} - - /* FIXME: move this into an editable .in file. */ size_t mdoc_macro2len(enum mdoct macro) 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); +} + |