try being compatible with glibc and ms crt.

This commit is contained in:
Enno Rehling 2021-06-01 19:46:38 +02:00
parent 6fc62eb35c
commit c8e09083f6

View file

@ -24,6 +24,8 @@ typedef struct parse_state {
static parse_state *states; static parse_state *states;
#define TRIMMED(wc) (iswspace(wc) || iswcntrl(wc) || (wc) == 160 || (wc) == 8199 || (wc) == 8239)
static int ltrim(const char **str_p) static int ltrim(const char **str_p)
{ {
int ret = 0; int ret = 0;
@ -35,7 +37,7 @@ static int ltrim(const char **str_p)
while (*str) { while (*str) {
unsigned char uc = *(unsigned char *)str; unsigned char uc = *(unsigned char *)str;
if (~uc & 0x80) { if (~uc & 0x80) {
if (iswgraph(uc)) break; if (!TRIMMED(uc)) break;
++str; ++str;
} }
else { else {
@ -44,7 +46,7 @@ static int ltrim(const char **str_p)
log_warning("illegal character sequence in UTF8 string: %s\n", str); log_warning("illegal character sequence in UTF8 string: %s\n", str);
break; break;
} }
if (iswgraph(wc)) break; if (!TRIMMED(wc)) break;
str += len; str += len;
} }
} }