=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/Attic/mdoc_strings.c,v retrieving revision 1.5 retrieving revision 1.6 diff -c -r1.5 -r1.6 *** src/usr.bin/mandoc/Attic/mdoc_strings.c 2009/06/18 01:19:02 1.5 --- src/usr.bin/mandoc/Attic/mdoc_strings.c 2009/06/19 07:20:19 1.6 *************** *** 1,4 **** ! /* $Id: mdoc_strings.c,v 1.5 2009/06/18 01:19:02 schwarze Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * --- 1,4 ---- ! /* $Id: mdoc_strings.c,v 1.6 2009/06/19 07:20:19 schwarze Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * *************** *** 24,64 **** #include "libmdoc.h" ! /* ! * Various string-literal operations: converting scalars to and from ! * strings, etc. ! */ struct mdoc_secname { ! const char *name; ! int flag; ! #define MSECNAME_META (1 << 0) }; ! /* Section names corresponding to mdoc_sec. */ ! static const struct mdoc_secname secnames[] = { ! { "PROLOGUE", MSECNAME_META }, ! { "BODY", MSECNAME_META }, ! { "NAME", 0 }, ! { "LIBRARY", 0 }, ! { "SYNOPSIS", 0 }, ! { "DESCRIPTION", 0 }, ! { "IMPLEMENTATION NOTES", 0 }, ! { "RETURN VALUES", 0 }, ! { "ENVIRONMENT", 0 }, ! { "FILES", 0 }, ! { "EXAMPLES", 0 }, ! { "DIAGNOSTICS", 0 }, ! { "COMPATIBILITY", 0 }, ! { "ERRORS", 0 }, ! { "SEE ALSO", 0 }, ! { "STANDARDS", 0 }, ! { "HISTORY", 0 }, ! { "AUTHORS", 0 }, ! { "CAVEATS", 0 }, ! { "BUGS", 0 }, ! { NULL, 0 } }; --- 24,57 ---- #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 (18) ! static const struct mdoc_secname secnames[SECNAME_MAX] = { ! { "NAME", SEC_NAME }, ! { "LIBRARY", SEC_LIBRARY }, ! { "SYNOPSIS", SEC_SYNOPSIS }, ! { "DESCRIPTION", SEC_DESCRIPTION }, ! { "IMPLEMENTATION NOTES", SEC_IMPLEMENTATION }, ! { "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 }, }; *************** *** 192,204 **** enum mdoc_sec mdoc_atosec(const char *p) { ! const struct mdoc_secname *n; ! int i; ! for (i = 0, n = secnames; n->name; n++, i++) ! if ( ! (n->flag & MSECNAME_META)) ! if (0 == strcmp(p, n->name)) ! return((enum mdoc_sec)i); return(SEC_CUSTOM); } --- 185,195 ---- enum mdoc_sec mdoc_atosec(const char *p) { ! int i; ! for (i = 0; i < SECNAME_MAX; i++) ! if (0 == strcmp(p, secnames[i].name)) ! return(secnames[i].sec); return(SEC_CUSTOM); }