aboutsummaryrefslogtreecommitdiff
path: root/common/util.cpp
diff options
context:
space:
mode:
authorMax Horn2012-01-28 01:15:49 +0100
committerMax Horn2012-02-15 16:51:37 +0100
commit658080deeda79d20ea40643569fbcb072573e7cf (patch)
treed604bf668909a6db44a1ec83e7c51088a5d85592 /common/util.cpp
parent37e5b209a71af725456a42be2605dea28ffceb84 (diff)
downloadscummvm-rg350-658080deeda79d20ea40643569fbcb072573e7cf.tar.gz
scummvm-rg350-658080deeda79d20ea40643569fbcb072573e7cf.tar.bz2
scummvm-rg350-658080deeda79d20ea40643569fbcb072573e7cf.zip
ALL: Avoid using is* macros from ctype.h
On some systems, passing signed chars to macros like isspace() etc. lead to a runtime error. Hence, mark these macros as forbidden by default, and introduce otherwise equivalent alternatives for them.
Diffstat (limited to 'common/util.cpp')
-rw-r--r--common/util.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/common/util.cpp b/common/util.cpp
index 1c4df8b6cd..0a7d0f1e89 100644
--- a/common/util.cpp
+++ b/common/util.cpp
@@ -19,6 +19,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#define FORBIDDEN_SYMBOL_EXCEPTION_isalnum
+#define FORBIDDEN_SYMBOL_EXCEPTION_isalpha
+#define FORBIDDEN_SYMBOL_EXCEPTION_isdigit
+#define FORBIDDEN_SYMBOL_EXCEPTION_isnumber
+#define FORBIDDEN_SYMBOL_EXCEPTION_islower
+#define FORBIDDEN_SYMBOL_EXCEPTION_isspace
+#define FORBIDDEN_SYMBOL_EXCEPTION_isupper
+
+
#include "common/util.h"
#include "common/translation.h"
#include "common/config-manager.h"
@@ -407,3 +416,37 @@ void updateGameGUIOptions(const String &options, const String &langOption) {
}
} // End of namespace Common
+
+
+//
+// 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.
+//
+bool isAlnum(int c) {
+ return isalnum((byte)c);
+}
+
+bool isAlpha(int c) {
+ return isalpha((byte)c);
+}
+
+bool isDigit(int c) {
+ return isdigit((byte)c);
+}
+
+bool isNumber(int c) {
+ return isnumber((byte)c);
+}
+
+bool isLower(int c) {
+ return islower((byte)c);
+}
+
+bool isSpace(int c) {
+ return isspace((byte)c);
+}
+
+bool isUpper(int c) {
+ return isupper((byte)c);
+}