isspace() does not recognize the NBSPACE, making our own test.

This commit is contained in:
Enno Rehling 2009-07-14 21:45:49 +00:00
parent 53d1ea0f93
commit 3271f4caf6
10 changed files with 24 additions and 21 deletions

View File

@ -275,6 +275,9 @@ extern char * strdup(const char *s);
# define INLINE_FUNCTION
#endif
#define iswxspace(c) (c==160 || iswspace(c))
#define isxspace(c) (c==160 || isspace(c))
#define TOLUA_CAST (char*)
#endif

View File

@ -86,7 +86,7 @@ static char * strskp(char * s)
{
char * skip = s;
if (s==NULL) return NULL ;
while (isspace((int)*skip) && *skip) skip++;
while (isxspace((int)*skip) && *skip) skip++;
return skip ;
}
@ -117,7 +117,7 @@ static char * strcrop(char * s)
strcpy(l, s);
last = l + strlen(l);
while (last > l) {
if (!isspace((int)*(last-1)))
if (!isxspace((int)*(last-1)))
break ;
last -- ;
}

View File

@ -3530,11 +3530,11 @@ simplename(region * r)
const char * cp = rname(r, NULL);
for (i=0;*cp && i!=16;++i, ++cp) {
int c = *(unsigned char *)cp;
while (c && !isalpha(c) && !isspace(c)) {
while (c && !isalpha(c) && !isxspace(c)) {
++cp;
c = *(unsigned char*)cp;
}
if (isspace(c)) name[i] = '_';
if (isxspace(c)) name[i] = '_';
else name[i] = *cp;
if (c==0) break;
}

View File

@ -1645,7 +1645,7 @@ estring_i(char *ibuf)
char *p = ibuf;
while (*p) {
if (isspace(*(unsigned*)p) == ' ') {
if (isxspace(*(unsigned*)p) == ' ') {
*p = '~';
}
++p;

View File

@ -353,7 +353,7 @@ parse_order(const char * s, const struct locale * lang)
sptr = s;
kwd = findkeyword(parse_token(&sptr), lang);
if (kwd!=NOKEYWORD) {
while (isspace(*(unsigned char*)sptr)) ++sptr;
while (isxspace(*(unsigned char*)sptr)) ++sptr;
s = sptr;
}
return create_order_i(kwd, s, persistent, lang);

View File

@ -137,7 +137,7 @@ freadstr(FILE * F, int encoding, char * start, size_t size)
for (;;) {
int c = fgetc(F);
if (isspace(c)) {
if (isxspace(c)) {
if (str==start) {
continue;
}

View File

@ -108,8 +108,8 @@ xml_cleanup_string(xmlChar * str)
while (*read) {
/* eat leading whitespace */
if (*read && isspace(*read)) {
while (*read && isspace(*read)) {
if (*read && isxspace(*read)) {
while (*read && isxspace(*read)) {
++read;
}
*write++ = ' ';

View File

@ -35,7 +35,7 @@ atoi36(const char * str)
assert(s);
if(!(*s)) return 0;
while(isspace(*(unsigned char*)s)) ++s;
while(isxspace(*(unsigned char*)s)) ++s;
if (*s == '-') {
sign = -1;
++s;

View File

@ -33,7 +33,7 @@ eatwhite(const char * ptr, size_t * total_size)
size_t size = 0;
ret = unicode_utf8_to_ucs4(&ucs, ptr, &size);
if (ret!=0) break;
if (!iswspace((wint_t)ucs)) break;
if (!iswxspace((wint_t)ucs)) break;
*total_size += size;
ptr += size;
}
@ -54,7 +54,7 @@ getbuf_latin1(FILE * F)
const char * bp = fgets(lbuf, MAXLINE, F);
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);
@ -108,14 +108,14 @@ getbuf_latin1(FILE * F)
if (iscntrl(c)) {
if (!comment && cp<fbuf+MAXLINE) {
*cp++ = isspace(c)?' ':'?';
*cp++ = isxspace(c)?' ':'?';
}
++bp;
continue;
} else if (isspace(c)) {
} else if (isxspace(c)) {
if (!quote) {
++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++) = ' ';
}
else if (!comment && cp+1<=fbuf+MAXLINE) {
@ -126,7 +126,7 @@ getbuf_latin1(FILE * F)
continue;
} else if (c==CONTINUE_CHAR) {
const char * end = ++bp;
while (*end && isspace(*(unsigned char*)end)) ++end; /* eatwhite */
while (*end && isxspace(*(unsigned char*)end)) ++end; /* eatwhite */
if (*end == '\0') {
bp = end;
cont = true;
@ -250,7 +250,7 @@ getbuf_utf8(FILE * F)
break;
}
if (iswspace((wint_t)ucs)) {
if (iswxspace((wint_t)ucs)) {
if (!quote) {
bp += size;
ret = eatwhite(bp, &size);

View File

@ -31,7 +31,7 @@ eatwhitespace_c(const char ** str_p)
for (;;) {
unsigned char utf8_character = (unsigned char)*str;
if (~utf8_character & 0x80) {
if (!iswspace(utf8_character)) break;
if (!iswxspace(utf8_character)) break;
++str;
} else {
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));
break;
}
if (!iswspace((wint_t)ucs)) break;
if (!iswxspace((wint_t)ucs)) break;
str+=len;
}
}
@ -106,7 +106,7 @@ skip_token(void)
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;
} else {
switch(utf8_character) {
@ -154,7 +154,7 @@ parse_token(const char ** str)
if (escape) {
copy = true;
escape = false;
} else if (iswspace((wint_t)ucs)) {
} else if (iswxspace((wint_t)ucs)) {
if (quotechar==0) break;
copy = true;
} else if (utf8_character=='"' || utf8_character=='\'') {