Skip to content

Commit

Permalink
BASE: Fix build, and error handling in DO_OPTION_INT.
Browse files Browse the repository at this point in the history
This fixes the logic of 979fc29 (I hope) and includes some missing
headers.
  • Loading branch information
fuzzie committed Jun 23, 2011
1 parent e972c6c commit 92f4b7c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion base/commandLine.cpp
Expand Up @@ -25,6 +25,9 @@

#define FORBIDDEN_SYMBOL_EXCEPTION_exit

#include <errno.h>
#include <limits.h>

#include "engines/metaengine.h"
#include "base/commandLine.h"
#include "base/plugins.h"
Expand Down Expand Up @@ -267,8 +270,9 @@ void registerDefaults() {
#define DO_OPTION_INT(shortCmd, longCmd) \
DO_OPTION(shortCmd, longCmd) \
char *endptr = 0; \
errno = 0; \
long int retval = strtol(option, &endptr, 0); \
if (endptr == NULL || *endptr != 0 || retval == 0 || retval == LONG_MAX || retval == LONG_MIN || errno == ERANGE) \
if (endptr == NULL || *endptr != 0 || (errno != 0 && retval == 0) || (errno == ERANGE && (retval == LONG_MAX || retval == LONG_MIN))) \
usage("--%s: Invalid number '%s'", longCmd, option);

// Use this for boolean options; this distinguishes between "-x" and "-X",
Expand Down

0 comments on commit 92f4b7c

Please sign in to comment.