From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (kristaps@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id p2H9MdCJ009952 for ; Thu, 17 Mar 2011 05:22:39 -0400 (EDT) Received: (from kristaps@localhost) by krisdoz.my.domain (8.14.3/8.14.3/Submit) id p2H9Md8O013495; Thu, 17 Mar 2011 05:22:39 -0400 (EDT) Date: Thu, 17 Mar 2011 05:22:39 -0400 (EDT) Message-Id: <201103170922.p2H9Md8O013495@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: kristaps@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: Move mdoc_str2sec() into mdoc_validate.c as a2sec(), as that's X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- Move mdoc_str2sec() into mdoc_validate.c as a2sec(), as that's the only place that it's being used. Modified Files: -------------- mdocml: libmdoc.h mdoc_strings.c mdoc_validate.c Revision Data ------------- Index: mdoc_validate.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_validate.c,v retrieving revision 1.159 retrieving revision 1.160 diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.159 -r1.160 --- mdoc_validate.c +++ mdoc_validate.c @@ -74,6 +74,7 @@ static void check_args(struct mdoc *, s 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. */ @@ -2253,5 +2278,17 @@ concat(struct mdoc *m, char *p, const st } 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); } Index: libmdoc.h =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/libmdoc.h,v retrieving revision 1.65 retrieving revision 1.66 diff -Llibmdoc.h -Llibmdoc.h -u -p -r1.65 -r1.66 --- libmdoc.h +++ libmdoc.h @@ -108,7 +108,6 @@ void mdoc_node_delete(struct mdoc *, 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 *); Index: mdoc_strings.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_strings.c,v retrieving revision 1.26 retrieving revision 1.27 diff -Lmdoc_strings.c -Lmdoc_strings.c -u -p -r1.26 -r1.27 --- mdoc_strings.c +++ 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) -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv