Merge branch 'PHP-5.4' into PHP-5.5

This commit is contained in:
Lars Strojny 2012-12-29 03:36:06 +01:00
commit f8a9a47e8c
2 changed files with 13 additions and 0 deletions

View File

@ -80,6 +80,11 @@ static int php_filter_parse_int(const char *str, unsigned int str_len, long *ret
break;
}
if (*str == '0' && str + 1 == end) {
/* Special cases: +0 and -0 */
return 1;
}
/* must start with 1..9*/
if (str < end && *str >= '1' && *str <= '9') {
ctx_value = ((sign)?-1:1) * ((*(str++)) - '0');

View File

@ -10,9 +10,13 @@ precision=14
/* Integer */
$data = "-123"; var_dump(filter_var($data, FILTER_VALIDATE_INT));
$data = "0"; var_dump(filter_var($data, FILTER_VALIDATE_INT));
$data = "-0"; var_dump(filter_var($data, FILTER_VALIDATE_INT));
$data = "+0"; var_dump(filter_var($data, FILTER_VALIDATE_INT));
$data = "123"; var_dump(filter_var($data, FILTER_VALIDATE_INT));
$data = -123; var_dump(filter_var($data, FILTER_VALIDATE_INT));
$data = 0; var_dump(filter_var($data, FILTER_VALIDATE_INT));
$data = -0; var_dump(filter_var($data, FILTER_VALIDATE_INT));
$data = +0; var_dump(filter_var($data, FILTER_VALIDATE_INT));
$data = 123; var_dump(filter_var($data, FILTER_VALIDATE_INT));
$data = ""; var_dump(filter_var($data, FILTER_VALIDATE_INT));
echo "\n";
@ -46,9 +50,13 @@ $data = ""; var_dump(filter_var($data, FILTER_VALIDATE_BOOLEAN));
--EXPECT--
int(-123)
int(0)
int(0)
int(0)
int(123)
int(-123)
int(0)
int(0)
int(0)
int(123)
bool(false)