=================================================================== RCS file: /cvs/mandoc/chars.c,v retrieving revision 1.36 retrieving revision 1.39 diff -u -p -r1.36 -r1.39 --- mandoc/chars.c 2011/04/29 22:18:12 1.36 +++ mandoc/chars.c 2011/04/30 22:24:31 1.39 @@ -1,4 +1,4 @@ -/* $Id: chars.c,v 1.36 2011/04/29 22:18:12 kristaps Exp $ */ +/* $Id: chars.c,v 1.39 2011/04/30 22:24:31 kristaps Exp $ */ /* * Copyright (c) 2009, 2010 Kristaps Dzonsons * Copyright (c) 2011 Ingo Schwarze @@ -55,7 +55,6 @@ struct ln { #include "chars.in" struct mchars { - enum mcharst type; struct ln **htab; }; @@ -72,7 +71,7 @@ mchars_free(struct mchars *arg) } struct mchars * -mchars_init(enum mcharst type) +mchars_alloc(void) { struct mchars *tab; struct ln **htab; @@ -103,7 +102,6 @@ mchars_init(enum mcharst type) } tab->htab = htab; - tab->type = type; return(tab); } @@ -139,23 +137,23 @@ mchars_res2cp(struct mchars *arg, const char *p, size_ /* - * Numbered character to literal character, - * represented as a null-terminated string for additional safety. + * Numbered character to literal character. */ -const char * +char mchars_num2char(const char *p, size_t sz) { int i; - static char c[2]; if (sz > 3) - return(NULL); + return('\0'); + i = atoi(p); - if (i < 0 || i > 255) - return(NULL); - c[0] = (char)i; - c[1] = '\0'; - return(c); + /* + * FIXME: + * This is wrong. Anything could be written here! + * This should be carefully screened for possible characters. + */ + return(i <= 0 || i > 255 ? '\0' : (char)i); }