[Scummvm-cvs-logs] SF.net SVN: scummvm:[39370] scummvm/trunk/engines/sci/engine/kstring.cpp

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Fri Mar 13 11:36:57 CET 2009


Revision: 39370
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39370&view=rev
Author:   thebluegr
Date:     2009-03-13 10:36:57 +0000 (Fri, 13 Mar 2009)

Log Message:
-----------
Changed the parameter passed to isprint() to be unsigned, according to MSDN (thanks wjp)

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kstring.cpp

Modified: scummvm/trunk/engines/sci/engine/kstring.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kstring.cpp	2009-03-13 07:56:06 UTC (rev 39369)
+++ scummvm/trunk/engines/sci/engine/kstring.cpp	2009-03-13 10:36:57 UTC (rev 39370)
@@ -414,11 +414,12 @@
 	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++;
 	}
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list