curl tool: allow negative numbers as option values
authorAlessandro Ghedini <al3xbio@gmail.com>
Sun, 12 Feb 2012 13:49:32 +0000 (14:49 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 13 Feb 2012 18:58:23 +0000 (19:58 +0100)
Fix the str2num() function to not check if the input string starts with a
digit, since strtol() supports numbers prepended with '-' (and '+') too.
This makes the --max-redirs option work as documented.

src/tool_paramhlp.c

index adb12ce..2d8e7f0 100644 (file)
@@ -151,8 +151,6 @@ void cleanarg(char *str)
  * Parse the string and write the integer in the given address. Return
  * non-zero on failure, zero on success.
  *
- * The string must start with a digit to be valid.
- *
  * Since this function gets called with the 'nextarg' pointer from within the
  * getparameter a lot, we must check it for NULL before accessing the str
  * data.
@@ -160,7 +158,7 @@ void cleanarg(char *str)
 
 int str2num(long *val, const char *str)
 {
-  if(str && ISDIGIT(*str)) {
+  if(str) {
     char *endptr;
     long num = strtol(str, &endptr, 10);
     if((endptr != str) && (endptr == str + strlen(str))) {