look for iswgraph, instead of not iswspace
This commit is contained in:
Enno Rehling 2021-06-01 18:35:14 +02:00
parent 2f05f12e10
commit 6fc62eb35c
2 changed files with 8 additions and 3 deletions

View File

@ -35,7 +35,7 @@ static int ltrim(const char **str_p)
while (*str) {
unsigned char uc = *(unsigned char *)str;
if (~uc & 0x80) {
if (!iswspace(uc)) break;
if (iswgraph(uc)) break;
++str;
}
else {
@ -45,7 +45,6 @@ static int ltrim(const char **str_p)
break;
}
if (iswgraph(wc)) break;
if (iswalnum(wc)) break;
str += len;
}
}

View File

@ -92,8 +92,14 @@ static void test_parse_token_limit_utf8(CuTest *tc) {
char lbuf[8];
const char *tok;
const char *orig = "a\xc3\xa4\xc3\xb6\xc3\xbc\xc3\x9f"; /* auml ouml uuml szlig, 8 bytes long */
const char *str = orig+1;
const char *str;
const char *wspace = " \x07\xc2\xa0\t.okay";
str = wspace;
tok = parse_token(&str, lbuf, sizeof(lbuf));
CuAssertStrEquals(tc, tok, ".okay");
str = orig + 1;
tok = parse_token(&str, lbuf, sizeof(lbuf));
CuAssertPtrEquals(tc, (void *)(orig + strlen(orig)), (void *)str);
CuAssertStrEquals(tc, tok, "\xc3\xa4\xc3\xb6\xc3\xbc"); /* just three letters fit, 6 bytes long */