[Scummvm-cvs-logs] scummvm master -> 1b6453dff4dde1e293b62f7fb4ade02507fd31bb

fuzzie fuzzie at fuzzie.org
Fri Jun 24 19:11:42 CEST 2011


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
1b6453dff4 BASE: Mess with strtol error handling some more.


Commit: 1b6453dff4dde1e293b62f7fb4ade02507fd31bb
    https://github.com/scummvm/scummvm/commit/1b6453dff4dde1e293b62f7fb4ade02507fd31bb
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-06-24T10:07:03-07:00

Commit Message:
BASE: Mess with strtol error handling some more.

WinCE's strtol can't actually do proper error handling because it is
lacking errno, so just check the bounds instead. If you really have
some need to pass LONG_MIN/LONG_MAX as command-line parameters then
it could always be #ifdeffed, but I'm assuming no-one cares.

Changed paths:
    base/commandLine.cpp



diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index 5435116..1cd3643 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -25,7 +25,7 @@
 
 #define FORBIDDEN_SYMBOL_EXCEPTION_exit
 
-#include <errno.h>
+#include <limits.h>
 
 #include "engines/metaengine.h"
 #include "base/commandLine.h"
@@ -266,12 +266,12 @@ void registerDefaults() {
 	if (!option) usage("Option '%s' requires an argument", argv[isLongCmd ? i : i-1]);
 
 // Use this for options which have a required integer value
+// (we don't check ERANGE because WinCE doesn't support errno, so we're stuck just rejecting LONG_MAX/LONG_MIN..)
 #define DO_OPTION_INT(shortCmd, longCmd) \
 	DO_OPTION(shortCmd, longCmd) \
 	char *endptr; \
-	errno = 0; \
-	strtol(option, &endptr, 0); \
-	if (*endptr != '\0' || errno == ERANGE) \
+	long int retval = strtol(option, &endptr, 0); \
+	if (*endptr != '\0' || retval == LONG_MAX || retval == LONG_MIN) \
 		usage("--%s: Invalid number '%s'", longCmd, option);
 
 // Use this for boolean options; this distinguishes between "-x" and "-X",






More information about the Scummvm-git-logs mailing list