mirror of https://github.com/moparisthebest/curl
src/tool_paramhlp: try harder to catch negatives
strto* functions happily chomp off leading whitespace, so simply checking for str[0] can lead to false negatives. Do the full parse and check the out value instead.
This commit is contained in:
parent
d3aaa68f55
commit
f5005dd8d0
|
@ -178,9 +178,13 @@ ParameterError str2num(long *val, const char *str)
|
||||||
|
|
||||||
ParameterError str2unum(long *val, const char *str)
|
ParameterError str2unum(long *val, const char *str)
|
||||||
{
|
{
|
||||||
if(str[0]=='-')
|
ParameterError result = str2num(val, str);
|
||||||
return PARAM_NEGATIVE_NUMERIC; /* badness */
|
if(result != PARAM_OK)
|
||||||
return str2num(val, str);
|
return result;
|
||||||
|
if(*val < 0)
|
||||||
|
return PARAM_NEGATIVE_NUMERIC;
|
||||||
|
|
||||||
|
return PARAM_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue