[Scummvm-cvs-logs] SF.net SVN: scummvm: [21911] scummvm/trunk/base
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Sat Apr 15 06:59:01 CEST 2006
Revision: 21911
Author: fingolfin
Date: 2006-04-15 06:58:01 -0700 (Sat, 15 Apr 2006)
ViewCVS: http://svn.sourceforge.net/scummvm/?rev=21911&view=rev
Log Message:
-----------
Always use base 0 in strtol when parsing integer command line options / config file entries (this makes it possible to optionally use hex values)
Modified Paths:
--------------
scummvm/trunk/base/gameDetector.cpp
scummvm/trunk/common/config-manager.cpp
Modified: scummvm/trunk/base/gameDetector.cpp
===================================================================
--- scummvm/trunk/base/gameDetector.cpp 2006-04-15 13:51:49 UTC (rev 21910)
+++ scummvm/trunk/base/gameDetector.cpp 2006-04-15 13:58:01 UTC (rev 21911)
@@ -294,7 +294,7 @@
DO_OPTION_OPT(shortCmd, longCmd, 0) \
if (!option) usage("Option '%s' requires an argument", argv[i]); \
char *endptr = 0; \
- int intValue; intValue = (int)strtol(option, &endptr, 10); \
+ int intValue; intValue = (int)strtol(option, &endptr, 0); \
if (endptr == NULL || *endptr != 0) usage("--%s: Invalid number '%s'", longCmd, option);
// Use this for boolean options; this distinguishes between "-x" and "-X",
@@ -508,14 +508,7 @@
END_OPTION
#ifndef DISABLE_SCUMM
- DO_LONG_OPTION("tempo")
- // Use the special value '0' for the base in (int)strtol.
- // Doing that makes it possible to enter hex values
- // as "0x1234", but also decimal values ("123").
- int value = (int)strtol(option, 0, 0);
- char buf[20];
- snprintf(buf, sizeof(buf), "%d", value);
- settings["tempo"] = buf;
+ DO_LONG_OPTION_INT("tempo")
END_OPTION
DO_LONG_OPTION_BOOL("demo-mode")
Modified: scummvm/trunk/common/config-manager.cpp
===================================================================
--- scummvm/trunk/common/config-manager.cpp 2006-04-15 13:51:49 UTC (rev 21910)
+++ scummvm/trunk/common/config-manager.cpp 2006-04-15 13:58:01 UTC (rev 21911)
@@ -425,7 +425,10 @@
if (value.empty())
return 0;
- int ivalue = (int)strtol(value.c_str(), &errpos, 10);
+ // We zse the special value '0' for the base passed to strtol. Doing that
+ // makes it possible to enter hex values as "0x1234", but also decimal
+ // values ("123") are still valid.
+ int ivalue = (int)strtol(value.c_str(), &errpos, 0);
if (value.c_str() == errpos)
error("ConfigManager::getInt(%s,%s): '%s' is not a valid integer",
key.c_str(), domName.c_str(), errpos);
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