forked from github/server
look for iswgraph, instead of not iswspace
This commit is contained in:
parent
2f05f12e10
commit
6fc62eb35c
|
@ -35,7 +35,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 (!iswspace(uc)) break;
|
if (iswgraph(uc)) break;
|
||||||
++str;
|
++str;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -45,7 +45,6 @@ static int ltrim(const char **str_p)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (iswgraph(wc)) break;
|
if (iswgraph(wc)) break;
|
||||||
if (iswalnum(wc)) break;
|
|
||||||
str += len;
|
str += len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,8 +92,14 @@ static void test_parse_token_limit_utf8(CuTest *tc) {
|
||||||
char lbuf[8];
|
char lbuf[8];
|
||||||
const char *tok;
|
const char *tok;
|
||||||
const char *orig = "a\xc3\xa4\xc3\xb6\xc3\xbc\xc3\x9f"; /* auml ouml uuml szlig, 8 bytes long */
|
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));
|
tok = parse_token(&str, lbuf, sizeof(lbuf));
|
||||||
CuAssertPtrEquals(tc, (void *)(orig + strlen(orig)), (void *)str);
|
CuAssertPtrEquals(tc, (void *)(orig + strlen(orig)), (void *)str);
|
||||||
CuAssertStrEquals(tc, tok, "\xc3\xa4\xc3\xb6\xc3\xbc"); /* just three letters fit, 6 bytes long */
|
CuAssertStrEquals(tc, tok, "\xc3\xa4\xc3\xb6\xc3\xbc"); /* just three letters fit, 6 bytes long */
|
||||||
|
|
Loading…
Reference in New Issue