forked from github/server
isspace() does not recognize the NBSPACE, making our own test.
This commit is contained in:
parent
53d1ea0f93
commit
3271f4caf6
10 changed files with 24 additions and 21 deletions
|
@ -275,6 +275,9 @@ extern char * strdup(const char *s);
|
||||||
# define INLINE_FUNCTION
|
# define INLINE_FUNCTION
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define iswxspace(c) (c==160 || iswspace(c))
|
||||||
|
#define isxspace(c) (c==160 || isspace(c))
|
||||||
|
|
||||||
#define TOLUA_CAST (char*)
|
#define TOLUA_CAST (char*)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ static char * strskp(char * s)
|
||||||
{
|
{
|
||||||
char * skip = s;
|
char * skip = s;
|
||||||
if (s==NULL) return NULL ;
|
if (s==NULL) return NULL ;
|
||||||
while (isspace((int)*skip) && *skip) skip++;
|
while (isxspace((int)*skip) && *skip) skip++;
|
||||||
return skip ;
|
return skip ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ static char * strcrop(char * s)
|
||||||
strcpy(l, s);
|
strcpy(l, s);
|
||||||
last = l + strlen(l);
|
last = l + strlen(l);
|
||||||
while (last > l) {
|
while (last > l) {
|
||||||
if (!isspace((int)*(last-1)))
|
if (!isxspace((int)*(last-1)))
|
||||||
break ;
|
break ;
|
||||||
last -- ;
|
last -- ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3530,11 +3530,11 @@ simplename(region * r)
|
||||||
const char * cp = rname(r, NULL);
|
const char * cp = rname(r, NULL);
|
||||||
for (i=0;*cp && i!=16;++i, ++cp) {
|
for (i=0;*cp && i!=16;++i, ++cp) {
|
||||||
int c = *(unsigned char *)cp;
|
int c = *(unsigned char *)cp;
|
||||||
while (c && !isalpha(c) && !isspace(c)) {
|
while (c && !isalpha(c) && !isxspace(c)) {
|
||||||
++cp;
|
++cp;
|
||||||
c = *(unsigned char*)cp;
|
c = *(unsigned char*)cp;
|
||||||
}
|
}
|
||||||
if (isspace(c)) name[i] = '_';
|
if (isxspace(c)) name[i] = '_';
|
||||||
else name[i] = *cp;
|
else name[i] = *cp;
|
||||||
if (c==0) break;
|
if (c==0) break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1645,7 +1645,7 @@ estring_i(char *ibuf)
|
||||||
char *p = ibuf;
|
char *p = ibuf;
|
||||||
|
|
||||||
while (*p) {
|
while (*p) {
|
||||||
if (isspace(*(unsigned*)p) == ' ') {
|
if (isxspace(*(unsigned*)p) == ' ') {
|
||||||
*p = '~';
|
*p = '~';
|
||||||
}
|
}
|
||||||
++p;
|
++p;
|
||||||
|
|
|
@ -353,7 +353,7 @@ parse_order(const char * s, const struct locale * lang)
|
||||||
sptr = s;
|
sptr = s;
|
||||||
kwd = findkeyword(parse_token(&sptr), lang);
|
kwd = findkeyword(parse_token(&sptr), lang);
|
||||||
if (kwd!=NOKEYWORD) {
|
if (kwd!=NOKEYWORD) {
|
||||||
while (isspace(*(unsigned char*)sptr)) ++sptr;
|
while (isxspace(*(unsigned char*)sptr)) ++sptr;
|
||||||
s = sptr;
|
s = sptr;
|
||||||
}
|
}
|
||||||
return create_order_i(kwd, s, persistent, lang);
|
return create_order_i(kwd, s, persistent, lang);
|
||||||
|
|
|
@ -137,7 +137,7 @@ freadstr(FILE * F, int encoding, char * start, size_t size)
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int c = fgetc(F);
|
int c = fgetc(F);
|
||||||
|
|
||||||
if (isspace(c)) {
|
if (isxspace(c)) {
|
||||||
if (str==start) {
|
if (str==start) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,8 +108,8 @@ xml_cleanup_string(xmlChar * str)
|
||||||
|
|
||||||
while (*read) {
|
while (*read) {
|
||||||
/* eat leading whitespace */
|
/* eat leading whitespace */
|
||||||
if (*read && isspace(*read)) {
|
if (*read && isxspace(*read)) {
|
||||||
while (*read && isspace(*read)) {
|
while (*read && isxspace(*read)) {
|
||||||
++read;
|
++read;
|
||||||
}
|
}
|
||||||
*write++ = ' ';
|
*write++ = ' ';
|
||||||
|
|
|
@ -35,7 +35,7 @@ atoi36(const char * str)
|
||||||
assert(s);
|
assert(s);
|
||||||
if(!(*s)) return 0;
|
if(!(*s)) return 0;
|
||||||
|
|
||||||
while(isspace(*(unsigned char*)s)) ++s;
|
while(isxspace(*(unsigned char*)s)) ++s;
|
||||||
if (*s == '-') {
|
if (*s == '-') {
|
||||||
sign = -1;
|
sign = -1;
|
||||||
++s;
|
++s;
|
||||||
|
|
|
@ -33,7 +33,7 @@ eatwhite(const char * ptr, size_t * total_size)
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
ret = unicode_utf8_to_ucs4(&ucs, ptr, &size);
|
ret = unicode_utf8_to_ucs4(&ucs, ptr, &size);
|
||||||
if (ret!=0) break;
|
if (ret!=0) break;
|
||||||
if (!iswspace((wint_t)ucs)) break;
|
if (!iswxspace((wint_t)ucs)) break;
|
||||||
*total_size += size;
|
*total_size += size;
|
||||||
ptr += size;
|
ptr += size;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ getbuf_latin1(FILE * F)
|
||||||
const char * bp = fgets(lbuf, MAXLINE, F);
|
const char * bp = fgets(lbuf, MAXLINE, F);
|
||||||
|
|
||||||
if (bp==NULL) return NULL;
|
if (bp==NULL) return NULL;
|
||||||
while (*bp && isspace(*(unsigned char*)bp)) ++bp; /* eatwhite */
|
while (*bp && isxspace(*(unsigned char*)bp)) ++bp; /* eatwhite */
|
||||||
|
|
||||||
comment = (boolean)(comment && cont);
|
comment = (boolean)(comment && cont);
|
||||||
|
|
||||||
|
@ -108,14 +108,14 @@ getbuf_latin1(FILE * F)
|
||||||
|
|
||||||
if (iscntrl(c)) {
|
if (iscntrl(c)) {
|
||||||
if (!comment && cp<fbuf+MAXLINE) {
|
if (!comment && cp<fbuf+MAXLINE) {
|
||||||
*cp++ = isspace(c)?' ':'?';
|
*cp++ = isxspace(c)?' ':'?';
|
||||||
}
|
}
|
||||||
++bp;
|
++bp;
|
||||||
continue;
|
continue;
|
||||||
} else if (isspace(c)) {
|
} else if (isxspace(c)) {
|
||||||
if (!quote) {
|
if (!quote) {
|
||||||
++bp;
|
++bp;
|
||||||
while (*bp && isspace(*(unsigned char*)bp)) ++bp; /* eatwhite */
|
while (*bp && isxspace(*(unsigned char*)bp)) ++bp; /* eatwhite */
|
||||||
if (!comment && *bp && *bp!=COMMENT_CHAR && cp<fbuf+MAXLINE) *(cp++) = ' ';
|
if (!comment && *bp && *bp!=COMMENT_CHAR && cp<fbuf+MAXLINE) *(cp++) = ' ';
|
||||||
}
|
}
|
||||||
else if (!comment && cp+1<=fbuf+MAXLINE) {
|
else if (!comment && cp+1<=fbuf+MAXLINE) {
|
||||||
|
@ -126,7 +126,7 @@ getbuf_latin1(FILE * F)
|
||||||
continue;
|
continue;
|
||||||
} else if (c==CONTINUE_CHAR) {
|
} else if (c==CONTINUE_CHAR) {
|
||||||
const char * end = ++bp;
|
const char * end = ++bp;
|
||||||
while (*end && isspace(*(unsigned char*)end)) ++end; /* eatwhite */
|
while (*end && isxspace(*(unsigned char*)end)) ++end; /* eatwhite */
|
||||||
if (*end == '\0') {
|
if (*end == '\0') {
|
||||||
bp = end;
|
bp = end;
|
||||||
cont = true;
|
cont = true;
|
||||||
|
@ -250,7 +250,7 @@ getbuf_utf8(FILE * F)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iswspace((wint_t)ucs)) {
|
if (iswxspace((wint_t)ucs)) {
|
||||||
if (!quote) {
|
if (!quote) {
|
||||||
bp += size;
|
bp += size;
|
||||||
ret = eatwhite(bp, &size);
|
ret = eatwhite(bp, &size);
|
||||||
|
|
|
@ -31,7 +31,7 @@ eatwhitespace_c(const char ** str_p)
|
||||||
for (;;) {
|
for (;;) {
|
||||||
unsigned char utf8_character = (unsigned char)*str;
|
unsigned char utf8_character = (unsigned char)*str;
|
||||||
if (~utf8_character & 0x80) {
|
if (~utf8_character & 0x80) {
|
||||||
if (!iswspace(utf8_character)) break;
|
if (!iswxspace(utf8_character)) break;
|
||||||
++str;
|
++str;
|
||||||
} else {
|
} else {
|
||||||
ret = unicode_utf8_to_ucs4(&ucs, str, &len);
|
ret = unicode_utf8_to_ucs4(&ucs, str, &len);
|
||||||
|
@ -39,7 +39,7 @@ eatwhitespace_c(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 (!iswspace((wint_t)ucs)) break;
|
if (!iswxspace((wint_t)ucs)) break;
|
||||||
str+=len;
|
str+=len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ skip_token(void)
|
||||||
log_warning(("illegal character sequence in UTF8 string: %s\n", state->current_token));
|
log_warning(("illegal character sequence in UTF8 string: %s\n", state->current_token));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (iswspace((wint_t)ucs) && quotechar==0) {
|
if (iswxspace((wint_t)ucs) && quotechar==0) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
switch(utf8_character) {
|
switch(utf8_character) {
|
||||||
|
@ -154,7 +154,7 @@ parse_token(const char ** str)
|
||||||
if (escape) {
|
if (escape) {
|
||||||
copy = true;
|
copy = true;
|
||||||
escape = false;
|
escape = false;
|
||||||
} else if (iswspace((wint_t)ucs)) {
|
} else if (iswxspace((wint_t)ucs)) {
|
||||||
if (quotechar==0) break;
|
if (quotechar==0) break;
|
||||||
copy = true;
|
copy = true;
|
||||||
} else if (utf8_character=='"' || utf8_character=='\'') {
|
} else if (utf8_character=='"' || utf8_character=='\'') {
|
||||||
|
|
Loading…
Reference in a new issue