diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-04-30 22:24:31 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-04-30 22:24:31 +0000 |
commit | 44ecac209529bca926296c46ec9ba062147bfbe2 (patch) | |
tree | 665dc3ecbb25554e5468ee30b1d2b4a486770254 /chars.c | |
parent | 8978dc20be98c1d06b71ccbb2bb988879f8a2d1c (diff) | |
download | mandoc-44ecac209529bca926296c46ec9ba062147bfbe2.tar.gz |
Make mchars_num2char() return a char like it says.
Diffstat (limited to 'chars.c')
-rw-r--r-- | chars.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -137,23 +137,23 @@ mchars_res2cp(struct mchars *arg, const char *p, size_t sz) /* - * 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); } |