COMMON: Filter non-ASCII values in ctype.h-style isFOO functions
This commit is contained in:
parent
4f8665fc83
commit
02ebd55214
1 changed files with 10 additions and 5 deletions
|
@ -415,32 +415,37 @@ void updateGameGUIOptions(const String &options, const String &langOption) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
#define ENSURE_ASCII_CHAR(c) \
|
||||||
// TODO: Instead of a blind cast, we might want to verify
|
if (c < 0 || c > 127) \
|
||||||
// if c equals EOS; and/or is in the range -255..+255;
|
return false
|
||||||
// and return false if it isn't.
|
|
||||||
//
|
|
||||||
bool isAlnum(int c) {
|
bool isAlnum(int c) {
|
||||||
|
ENSURE_ASCII_CHAR(c);
|
||||||
return isalnum((byte)c);
|
return isalnum((byte)c);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAlpha(int c) {
|
bool isAlpha(int c) {
|
||||||
|
ENSURE_ASCII_CHAR(c);
|
||||||
return isalpha((byte)c);
|
return isalpha((byte)c);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isDigit(int c) {
|
bool isDigit(int c) {
|
||||||
|
ENSURE_ASCII_CHAR(c);
|
||||||
return isdigit((byte)c);
|
return isdigit((byte)c);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isLower(int c) {
|
bool isLower(int c) {
|
||||||
|
ENSURE_ASCII_CHAR(c);
|
||||||
return islower((byte)c);
|
return islower((byte)c);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isSpace(int c) {
|
bool isSpace(int c) {
|
||||||
|
ENSURE_ASCII_CHAR(c);
|
||||||
return isspace((byte)c);
|
return isspace((byte)c);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isUpper(int c) {
|
bool isUpper(int c) {
|
||||||
|
ENSURE_ASCII_CHAR(c);
|
||||||
return isupper((byte)c);
|
return isupper((byte)c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue