=================================================================== RCS file: /cvs/mandoc/chars.c,v retrieving revision 1.9 retrieving revision 1.13 diff -u -p -r1.9 -r1.13 --- mandoc/chars.c 2009/09/23 11:02:21 1.9 +++ mandoc/chars.c 2009/11/05 07:21:01 1.13 @@ -1,4 +1,4 @@ -/* $Id: chars.c,v 1.9 2009/09/23 11:02:21 kristaps Exp $ */ +/* $Id: chars.c,v 1.13 2009/11/05 07:21:01 kristaps Exp $ */ /* * Copyright (c) 2009 Kristaps Dzonsons * @@ -15,7 +15,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include -#include +#include #include #include @@ -35,7 +35,7 @@ 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 @@ -47,9 +47,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; @@ -89,13 +90,17 @@ chars_init(enum chars type) * (they're in-line re-ordered during lookup). */ - if (NULL == (tab = malloc(sizeof(struct tbl)))) - err(1, "malloc"); - tab->type = type; + tab = malloc(sizeof(struct tbl)); + if (NULL == tab) { + perror(NULL); + exit(EXIT_FAILURE); + } htab = calloc(PRINT_HI - PRINT_LO + 1, sizeof(struct ln **)); - if (NULL == htab) - err(1, "malloc"); + if (NULL == htab) { + perror(NULL); + exit(EXIT_FAILURE); + } for (i = 0; i < LINES_MAX; i++) { hash = (int)lines[i].code[0] - PRINT_LO; @@ -111,6 +116,7 @@ chars_init(enum chars type) } tab->htab = htab; + tab->type = type; return(tab); }