diff options
author | Max Horn | 2012-02-20 16:15:10 +0100 |
---|---|---|
committer | Max Horn | 2012-02-20 16:20:32 +0100 |
commit | 02ebd552141173775b9462f4414083d3b8d49a80 (patch) | |
tree | 01176e1aa8b2981f3fb15f37d39dc16687afbf4b | |
parent | 4f8665fc836898ebf54fc73b1061125b748183bc (diff) | |
download | scummvm-rg350-02ebd552141173775b9462f4414083d3b8d49a80.tar.gz scummvm-rg350-02ebd552141173775b9462f4414083d3b8d49a80.tar.bz2 scummvm-rg350-02ebd552141173775b9462f4414083d3b8d49a80.zip |
COMMON: Filter non-ASCII values in ctype.h-style isFOO functions
-rw-r--r-- | common/util.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/common/util.cpp b/common/util.cpp index e605a267d5..3f97308d8e 100644 --- a/common/util.cpp +++ b/common/util.cpp @@ -415,32 +415,37 @@ void updateGameGUIOptions(const String &options, const String &langOption) { } } -// -// TODO: Instead of a blind cast, we might want to verify -// if c equals EOS; and/or is in the range -255..+255; -// and return false if it isn't. -// +#define ENSURE_ASCII_CHAR(c) \ + if (c < 0 || c > 127) \ + return false + bool isAlnum(int c) { + ENSURE_ASCII_CHAR(c); return isalnum((byte)c); } bool isAlpha(int c) { + ENSURE_ASCII_CHAR(c); return isalpha((byte)c); } bool isDigit(int c) { + ENSURE_ASCII_CHAR(c); return isdigit((byte)c); } bool isLower(int c) { + ENSURE_ASCII_CHAR(c); return islower((byte)c); } bool isSpace(int c) { + ENSURE_ASCII_CHAR(c); return isspace((byte)c); } bool isUpper(int c) { + ENSURE_ASCII_CHAR(c); return isupper((byte)c); } |