X-Git-Url: https://git.cameronkatri.com/mandoc.git/blobdiff_plain/3ee412a268eff0c9e52bb141dc3289eda00a6d53..a1eb7bc59e737e8ac3bfb9641b3a576fe375ccac:/chars.c diff --git a/chars.c b/chars.c index 369aac2f..ce03347b 100644 --- a/chars.c +++ b/chars.c @@ -1,6 +1,6 @@ -/* $Id: chars.c,v 1.48 2011/07/21 15:21:13 kristaps Exp $ */ +/* $Id: chars.c,v 1.52 2011/11/08 00:15:23 kristaps Exp $ */ /* - * Copyright (c) 2009, 2010 Kristaps Dzonsons + * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2011 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any @@ -37,7 +37,7 @@ struct ln { int unicode; }; -#define LINES_MAX 325 +#define LINES_MAX 328 #define CHAR(in, ch, code) \ { NULL, (in), (ch), (code) }, @@ -51,7 +51,8 @@ struct mchars { struct ln **htab; }; -static const struct ln *find(struct mchars *, const char *, size_t); +static const struct ln *find(const struct mchars *, + const char *, size_t); void mchars_free(struct mchars *arg) @@ -96,7 +97,7 @@ mchars_alloc(void) } int -mchars_spec2cp(struct mchars *arg, const char *p, size_t sz) +mchars_spec2cp(const struct mchars *arg, const char *p, size_t sz) { const struct ln *ln; @@ -113,7 +114,8 @@ mchars_num2char(const char *p, size_t sz) if ((i = mandoc_strntoi(p, sz, 10)) < 0) return('\0'); - return(isprint(i) ? i : '\0'); + return(i > 0 && i < 256 && isprint(i) ? + /* LINTED */ i : '\0'); } int @@ -128,22 +130,25 @@ mchars_num2uc(const char *p, size_t sz) } const char * -mchars_spec2str(struct mchars *arg, const char *p, size_t sz, size_t *rsz) +mchars_spec2str(const struct mchars *arg, + const char *p, size_t sz, size_t *rsz) { const struct ln *ln; ln = find(arg, p, sz); - if (NULL == ln) + if (NULL == ln) { + *rsz = 1; return(NULL); + } *rsz = strlen(ln->ascii); return(ln->ascii); } static const struct ln * -find(struct mchars *tab, const char *p, size_t sz) +find(const struct mchars *tab, const char *p, size_t sz) { - struct ln *pp; + const struct ln *pp; int hash; assert(p);