X-Git-Url: https://git.cameronkatri.com/mandoc.git/blobdiff_plain/6743cd2838c98a6c8127771ac05c6695131f26f5..9f11efb0307eb4c4dbb4a8fff243321100e27573:/chars.c diff --git a/chars.c b/chars.c index 34b1e9cd..461ac067 100644 --- a/chars.c +++ b/chars.c @@ -1,4 +1,4 @@ -/* $Id: chars.c,v 1.10 2009/10/30 18:43:24 kristaps Exp $ */ +/* $Id: chars.c,v 1.17 2010/03/23 13:25:01 kristaps Exp $ */ /* * Copyright (c) 2009 Kristaps Dzonsons * @@ -14,6 +14,10 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -35,10 +39,10 @@ struct ln { int type; #define CHARS_CHAR (1 << 0) #define CHARS_STRING (1 << 1) -#define CHARS_BOTH (0x03) +#define CHARS_BOTH (CHARS_CHAR | CHARS_STRING) }; -#define LINES_MAX 351 +#define LINES_MAX 369 #define CHAR(w, x, y, z, a, b) \ { NULL, (w), (y), (a), (x), (z), (b), CHARS_CHAR }, @@ -47,9 +51,10 @@ struct ln { #define BOTH(w, x, y, z, a, b) \ { NULL, (w), (y), (a), (x), (z), (b), CHARS_BOTH }, -static struct ln lines[LINES_MAX] = { +#define CHAR_TBL_START static struct ln lines[LINES_MAX] = { +#define CHAR_TBL_END }; + #include "chars.in" -}; struct tbl { enum chars type; @@ -91,13 +96,13 @@ chars_init(enum chars type) tab = malloc(sizeof(struct tbl)); if (NULL == tab) { - fprintf(stderr, "memory exhausted\n"); + perror(NULL); exit(EXIT_FAILURE); } htab = calloc(PRINT_HI - PRINT_LO + 1, sizeof(struct ln **)); if (NULL == htab) { - fprintf(stderr, "memory exhausted\n"); + perror(NULL); exit(EXIT_FAILURE); } @@ -161,18 +166,6 @@ find(struct tbl *tab, const char *p, size_t sz, size_t *rsz, int type) if (NULL == (pp = htab[hash])) return(NULL); - if (NULL == pp->next) { - if ( ! match(pp, p, sz, type)) - return(NULL); - - if (CHARS_HTML == tab->type) { - *rsz = pp->htmlsz; - return(pp->html); - } - *rsz = pp->asciisz; - return(pp->ascii); - } - for (prev = NULL; pp; pp = pp->next) { if ( ! match(pp, p, sz, type)) { prev = pp;