[Scummvm-cvs-logs] SF.net SVN: scummvm: [30531] scummvm/trunk/engines/agi/agi.cpp

buddha_ at users.sourceforge.net buddha_ at users.sourceforge.net
Thu Jan 17 12:16:00 CET 2008


Revision: 30531
          http://scummvm.svn.sourceforge.net/scummvm/?rev=30531&view=rev
Author:   buddha_
Date:     2008-01-17 03:16:00 -0800 (Thu, 17 Jan 2008)

Log Message:
-----------
Fix for isalpha() assertions (Almost identical to revision 29924's fix). Added the rationale for this fix in comments so hopefully this won't happen a third time at the same point in code ;).

Revision Links:
--------------
    http://scummvm.svn.sourceforge.net/scummvm/?rev=29924&view=rev

Modified Paths:
--------------
    scummvm/trunk/engines/agi/agi.cpp

Modified: scummvm/trunk/engines/agi/agi.cpp
===================================================================
--- scummvm/trunk/engines/agi/agi.cpp	2008-01-17 11:07:11 UTC (rev 30530)
+++ scummvm/trunk/engines/agi/agi.cpp	2008-01-17 11:16:00 UTC (rev 30531)
@@ -222,7 +222,19 @@
 				// Not a special key, so get the ASCII code for it
 				key = event.kbd.ascii;
 
-				if (isalpha(key)) {			
+				// Function isalpha is defined in <ctype.h> so the following applies to it:
+				//
+				// The C Programming Language Standard states:
+				//   The header <ctype.h> declares several functions useful for classifying
+				//   and mapping characters. In all cases the argument is an int, the value
+				//   of which shall be representable as an unsigned char or shall equal the
+				//   value of the macro EOF. If the argument has any other value, the
+				//   behavior is undefined.
+				//
+				// For a concrete example (e.g. in Microsoft Visual Studio 2003):
+				//   When used with a debug CRT library, isalpha will display a CRT assert
+				//   if passed a parameter that isn't EOF or in the range of 0 through 0xFF.
+				if (key >= 0 && key <= 0xFF && isalpha(key)) {
 					// Key is A-Z. 
 					// Map Ctrl-A to 1, Ctrl-B to 2, etc.
 					if (event.kbd.flags & Common::KBD_CTRL) {


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