From 3271f4caf69f517eb803625fabfa29116042a572 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 14 Jul 2009 21:45:49 +0000 Subject: [PATCH] isspace() does not recognize the NBSPACE, making our own test. --- src/common/config.h | 3 +++ src/common/iniparser/iniparser.c | 4 ++-- src/common/kernel/battle.c | 4 ++-- src/common/kernel/eressea.c | 2 +- src/common/kernel/order.c | 2 +- src/common/kernel/save.c | 2 +- src/common/kernel/xmlreader.c | 4 ++-- src/common/util/base36.c | 2 +- src/common/util/filereader.c | 14 +++++++------- src/common/util/parser.c | 8 ++++---- 10 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/common/config.h b/src/common/config.h index 62195dcbc..a80d3313b 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -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 diff --git a/src/common/iniparser/iniparser.c b/src/common/iniparser/iniparser.c index 775c48a38..28d8f73bf 100644 --- a/src/common/iniparser/iniparser.c +++ b/src/common/iniparser/iniparser.c @@ -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 -- ; } diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c index dd6c8634b..f196968b6 100644 --- a/src/common/kernel/battle.c +++ b/src/common/kernel/battle.c @@ -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; } diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index 6a426bd16..5383e9714 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -1645,7 +1645,7 @@ estring_i(char *ibuf) char *p = ibuf; while (*p) { - if (isspace(*(unsigned*)p) == ' ') { + if (isxspace(*(unsigned*)p) == ' ') { *p = '~'; } ++p; diff --git a/src/common/kernel/order.c b/src/common/kernel/order.c index 2afad4695..a3c72be7d 100644 --- a/src/common/kernel/order.c +++ b/src/common/kernel/order.c @@ -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); diff --git a/src/common/kernel/save.c b/src/common/kernel/save.c index f983bd2c6..07062b142 100644 --- a/src/common/kernel/save.c +++ b/src/common/kernel/save.c @@ -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; } diff --git a/src/common/kernel/xmlreader.c b/src/common/kernel/xmlreader.c index 4fe5ee473..fae566daf 100644 --- a/src/common/kernel/xmlreader.c +++ b/src/common/kernel/xmlreader.c @@ -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++ = ' '; diff --git a/src/common/util/base36.c b/src/common/util/base36.c index 6123de48a..3b3f7a2b8 100644 --- a/src/common/util/base36.c +++ b/src/common/util/base36.c @@ -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; diff --git a/src/common/util/filereader.c b/src/common/util/filereader.c index a46e6e445..b4a24d9ba 100644 --- a/src/common/util/filereader.c +++ b/src/common/util/filereader.c @@ -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 && cpcurrent_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=='\'') {