aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Kiewitz2010-05-22 21:46:40 +0000
committerMartin Kiewitz2010-05-22 21:46:40 +0000
commitd04c7a58aa5d72f62f49c5c3246d5e5c0af8920a (patch)
tree001fbc6eb3114c54e4aa0290030eecbefddb47d0
parent5f2a88e5966e64e24f6630ca3d1e84077d76998b (diff)
downloadscummvm-rg350-d04c7a58aa5d72f62f49c5c3246d5e5c0af8920a.tar.gz
scummvm-rg350-d04c7a58aa5d72f62f49c5c3246d5e5c0af8920a.tar.bz2
scummvm-rg350-d04c7a58aa5d72f62f49c5c3246d5e5c0af8920a.zip
SCI: adding ability to specify hexadecimal number as index for debug command vmvars - also report error if invalid index is given to us
svn-id: r49148
-rw-r--r--engines/sci/console.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index 16bc69115f..540b7c84d8 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -1762,7 +1762,7 @@ bool Console::cmdVMVars(int argc, const char **argv) {
const char *varabbrev = "gltp";
const char *vartype_pre = strchr(varabbrev, *argv[1]);
int vartype;
- int idx = atoi(argv[2]);
+ int idx;
if (!vartype_pre) {
DebugPrintf("Invalid variable type '%c'\n", *argv[1]);
@@ -1771,6 +1771,26 @@ bool Console::cmdVMVars(int argc, const char **argv) {
vartype = vartype_pre - varabbrev;
+ char *endPtr = 0;
+ int idxLen = strlen(argv[2]);
+ const char *lastChar = argv[2] + idxLen - (idxLen == 0 ? 0 : 1);
+
+ if ((strncmp(argv[2], "0x", 2) == 0) || (*lastChar == 'h')) {
+ // hexadecimal number
+ idx = strtol(argv[2], &endPtr, 16);
+ if ((*endPtr != 0) && (*endPtr != 'h')) {
+ DebugPrintf("Invalid hexadecimal index '%s'\n", argv[2]);
+ return true;
+ }
+ } else {
+ // decimal number
+ idx = strtol(argv[2], &endPtr, 10);
+ if (*endPtr != 0) {
+ DebugPrintf("Invalid decimal index '%s'\n", argv[2]);
+ return true;
+ }
+ }
+
if (idx < 0) {
DebugPrintf("Invalid: negative index\n");
return true;