version 1.41, 2011/05/14 17:54:42 |
version 1.44, 2011/05/17 11:50:20 |
|
|
#include <string.h> |
#include <string.h> |
|
|
#include "mandoc.h" |
#include "mandoc.h" |
|
#include "libmandoc.h" |
|
|
#define PRINT_HI 126 |
#define PRINT_HI 126 |
#define PRINT_LO 32 |
#define PRINT_LO 32 |
Line 137 mchars_res2cp(struct mchars *arg, const char *p, size_ |
|
Line 138 mchars_res2cp(struct mchars *arg, const char *p, size_ |
|
} |
} |
|
|
/* |
/* |
* Numbered character to literal character. |
* Numbered character string to ASCII codepoint. |
* This can only be a printable character (i.e., alnum, punct, space) so |
* This can only be a printable character (i.e., alnum, punct, space) so |
* prevent the character from ruining our state (backspace, newline, and |
* prevent the character from ruining our state (backspace, newline, and |
* so on). |
* so on). |
|
* If the character is illegal, returns '\0'. |
*/ |
*/ |
char |
char |
mchars_num2char(const char *p, size_t sz) |
mchars_num2char(const char *p, size_t sz) |
{ |
{ |
int i; |
int i; |
|
|
if (sz > 3) |
if ((i = mandoc_strntou(p, sz, 10)) < 0) |
return('\0'); |
return('\0'); |
|
|
i = atoi(p); |
|
/* LINTED */ |
|
return(isprint(i) ? i : '\0'); |
return(isprint(i) ? i : '\0'); |
|
} |
|
|
|
/* |
|
* Hex character string to Unicode codepoint. |
|
* If the character is illegal, returns '\0'. |
|
*/ |
|
int |
|
mchars_num2uc(const char *p, size_t sz) |
|
{ |
|
int i; |
|
|
|
if ((i = mandoc_strntou(p, sz, 16)) < 0) |
|
return('\0'); |
|
/* FIXME: make sure we're not in a bogus range. */ |
|
return(i > 0x80 && i <= 0x10FFFF ? i : '\0'); |
} |
} |
|
|
/* |
/* |