aboutsummaryrefslogtreecommitdiff
path: root/engines/agi/agi.cpp
diff options
context:
space:
mode:
authorKari Salminen2008-01-17 11:16:00 +0000
committerKari Salminen2008-01-17 11:16:00 +0000
commit5a2440ce1b487dc896cd60d76871f40236d22687 (patch)
treeceacb7d2a125bd41ad37a23116f9082b4cdfa3e6 /engines/agi/agi.cpp
parent3a0f7b4ea89280c32f30dbec33d4bd6ae72f99b6 (diff)
downloadscummvm-rg350-5a2440ce1b487dc896cd60d76871f40236d22687.tar.gz
scummvm-rg350-5a2440ce1b487dc896cd60d76871f40236d22687.tar.bz2
scummvm-rg350-5a2440ce1b487dc896cd60d76871f40236d22687.zip
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 ;).
svn-id: r30531
Diffstat (limited to 'engines/agi/agi.cpp')
-rw-r--r--engines/agi/agi.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index 17359236f0..5cf82b83bd 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -222,7 +222,19 @@ void AgiEngine::processEvents() {
// 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) {