=================================================================== RCS file: /cvs/mandoc/chars.c,v retrieving revision 1.22 retrieving revision 1.29 diff -u -p -r1.22 -r1.29 --- mandoc/chars.c 2010/07/17 09:21:39 1.22 +++ mandoc/chars.c 2010/09/04 20:18:53 1.29 @@ -1,6 +1,6 @@ -/* $Id: chars.c,v 1.22 2010/07/17 09:21:39 kristaps Exp $ */ +/* $Id: chars.c,v 1.29 2010/09/04 20:18:53 kristaps Exp $ */ /* - * Copyright (c) 2009 Kristaps Dzonsons + * Copyright (c) 2009, 2010 Kristaps Dzonsons * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -33,7 +33,6 @@ struct ln { struct ln *next; const char *code; const char *ascii; - size_t asciisz; int unicode; int type; #define CHARS_CHAR (1 << 0) @@ -41,14 +40,14 @@ struct ln { #define CHARS_BOTH (CHARS_CHAR | CHARS_STRING) }; -#define LINES_MAX 370 +#define LINES_MAX 362 -#define CHAR(in, ch, chsz, code) \ - { NULL, (in), (ch), (chsz), (code), CHARS_CHAR }, -#define STRING(in, ch, chsz, code) \ - { NULL, (in), (ch), (chsz), (code), CHARS_STRING }, -#define BOTH(in, ch, chsz, code) \ - { NULL, (in), (ch), (chsz), (code), CHARS_BOTH }, +#define CHAR(in, ch, code) \ + { NULL, (in), (ch), (code), CHARS_CHAR }, +#define STRING(in, ch, code) \ + { NULL, (in), (ch), (code), CHARS_STRING }, +#define BOTH(in, ch, code) \ + { NULL, (in), (ch), (code), CHARS_BOTH }, #define CHAR_TBL_START static struct ln lines[LINES_MAX] = { #define CHAR_TBL_END }; @@ -95,13 +94,13 @@ chars_init(enum chars type) tab = malloc(sizeof(struct tbl)); if (NULL == tab) { perror(NULL); - exit(EXIT_FAILURE); + exit((int)MANDOCLEVEL_SYSERR); } htab = calloc(PRINT_HI - PRINT_LO + 1, sizeof(struct ln **)); if (NULL == htab) { perror(NULL); - exit(EXIT_FAILURE); + exit((int)MANDOCLEVEL_SYSERR); } for (i = 0; i < LINES_MAX; i++) { @@ -165,7 +164,7 @@ chars_spec2str(void *arg, const char *p, size_t sz, si if (NULL == ln) return(NULL); - *rsz = ln->asciisz; + *rsz = strlen(ln->ascii); return(ln->ascii); } @@ -182,7 +181,7 @@ chars_res2str(void *arg, const char *p, size_t sz, siz if (NULL == ln) return(NULL); - *rsz = ln->asciisz; + *rsz = strlen(ln->ascii); return(ln->ascii); } @@ -195,7 +194,8 @@ find(struct tbl *tab, const char *p, size_t sz, int ty int hash; assert(p); - assert(sz > 0); + if (0 == sz) + return(NULL); if (p[0] < PRINT_LO || p[0] > PRINT_HI) return(NULL);