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
This commit is contained in:
Martin Kiewitz 2010-05-22 21:46:40 +00:00
parent 5f2a88e596
commit d04c7a58aa

View File

@ -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;