X-Git-Url: https://git.cameronkatri.com/mandoc.git/blobdiff_plain/dead96d50530a782ee738938c2c911a44e97bede..26b89148b8de14db6d703f964e9dee45f469b8f6:/chars.c diff --git a/chars.c b/chars.c index 31d75a6e..fe0b17de 100644 --- a/chars.c +++ b/chars.c @@ -1,4 +1,4 @@ -/* $Id: chars.c,v 1.61 2014/10/26 18:07:28 schwarze Exp $ */ +/* $Id: chars.c,v 1.65 2014/10/29 00:17:43 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2011, 2014 Ingo Schwarze @@ -104,18 +104,16 @@ mchars_spec2cp(const struct mchars *arg, const char *p, size_t sz) const struct ln *ln; ln = find(arg, p, sz); - return(ln != NULL ? ln->unicode : sz == 1 ? *p : -1); + return(ln != NULL ? ln->unicode : sz == 1 ? (unsigned char)*p : -1); } -char +int mchars_num2char(const char *p, size_t sz) { int i; - if ((i = mandoc_strntoi(p, sz, 10)) < 0) - return('\0'); - - return(i > 0 && i < 256 && isprint(i) ? i : '\0'); + i = mandoc_strntoi(p, sz, 10); + return(i >= 0 && i < 256 ? i : -1); } int @@ -123,14 +121,9 @@ mchars_num2uc(const char *p, size_t sz) { int i; - if ((i = mandoc_strntoi(p, sz, 16)) < 0) - return(0xFFFD); - - /* - * XXX Code is missing here to exclude bogus ranges. - */ - - return(i <= 0x10FFFF ? i : 0xFFFD); + i = mandoc_strntoi(p, sz, 16); + assert(i >= 0 && i <= 0x10FFFF); + return(i); } const char *