aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2009-03-13 10:36:57 +0000
committerFilippos Karapetis2009-03-13 10:36:57 +0000
commit7854a01f14aa76f9e95101838606354ab05d8514 (patch)
tree92830445c4fba68bd320c0dd79b0b65f0d36076c
parent091652376323a54a55327d114c0da994ec859d80 (diff)
downloadscummvm-rg350-7854a01f14aa76f9e95101838606354ab05d8514.tar.gz
scummvm-rg350-7854a01f14aa76f9e95101838606354ab05d8514.tar.bz2
scummvm-rg350-7854a01f14aa76f9e95101838606354ab05d8514.zip
Changed the parameter passed to isprint() to be unsigned, according to MSDN (thanks wjp)
svn-id: r39370
-rw-r--r--engines/sci/engine/kstring.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index 1bcde36a9c..c6cc5910a5 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -414,11 +414,12 @@ static int is_print_str(char *str) {
if (len == 0) return 1;
while (*str) {
- // We're ANDing the string with 0xFF to prevent a situation
- // where MSVC could sometimes falsely parse the character as
- // multibyte/Unicode, thereby overflowing an assertion inside
- // isprint(). This occurs after the intro of LSL5, for example.
- if (isprint((*str & 0xFF))) printable++;
+ // The parameter passed to isprint() needs to be in the range
+ // 0 to 0xFF or EOF, according to MSDN, therefore we cast it
+ // to an unsigned char. Values outside this range (in this
+ // case, negative values) yield unpredictable results. Refer to:
+ // http://msdn.microsoft.com/en-us/library/ewx8s4kw.aspx
+ if (isprint((unsigned char)*str)) printable++;
str++;
}