diff options
author | Zeev Suraski <zeev@php.net> | 2001-05-10 12:58:31 +0000 |
---|---|---|
committer | Zeev Suraski <zeev@php.net> | 2001-05-10 12:58:31 +0000 |
commit | 429667883e8382200b8d39a558b9300cd18a8c45 (patch) | |
tree | a05ce57041e5c26a7d2b751b835906a80038a2ad | |
parent | ef23bc97a347a2c338c7a6c895fcad1b3a9e03fb (diff) | |
download | php-git-429667883e8382200b8d39a558b9300cd18a8c45.tar.gz |
Treat numeric strings as numbers in the increment operator
-rw-r--r-- | Zend/zend_operators.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 713177c380..11d72f6dc4 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -1431,8 +1431,32 @@ ZEND_API int increment_function(zval *op1) op1->value.lval = 1; op1->type = IS_LONG; break; - case IS_STRING: /* Perl style string increment */ - increment_string(op1); + case IS_STRING: { + long lval; + double dval; + char *strval = op1->value.str.val; + + switch (is_numeric_string(strval, op1->value.str.len, &lval, &dval)) { + case IS_LONG: + op1->value.lval = lval+1; + op1->type = IS_LONG; + efree(strval); + break; + case IS_DOUBLE: + op1->value.dval = dval+1; + op1->type = IS_DOUBLE; + efree(strval); + break; +#if 0 + case FLAG_IS_BC: + /* Not implemented */ +#endif + default: + /* Perl style string increment */ + increment_string(op1); + break; + } + } break; default: return FAILURE; |