[Scummvm-cvs-logs] SF.net SVN: scummvm:[49148] scummvm/trunk/engines/sci/console.cpp
m_kiewitz at users.sourceforge.net
m_kiewitz at users.sourceforge.net
Sat May 22 23:46:40 CEST 2010
Revision: 49148
http://scummvm.svn.sourceforge.net/scummvm/?rev=49148&view=rev
Author: m_kiewitz
Date: 2010-05-22 21:46:40 +0000 (Sat, 22 May 2010)
Log Message:
-----------
SCI: adding ability to specify hexadecimal number as index for debug command vmvars - also report error if invalid index is given to us
Modified Paths:
--------------
scummvm/trunk/engines/sci/console.cpp
Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp 2010-05-22 18:00:16 UTC (rev 49147)
+++ scummvm/trunk/engines/sci/console.cpp 2010-05-22 21:46:40 UTC (rev 49148)
@@ -1762,7 +1762,7 @@
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 @@
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;
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