]> granicus.if.org Git - php/commitdiff
MFH (patch for allowing strings in pow() args, fixes #17374)
authorEdin Kadribasic <edink@php.net>
Thu, 23 May 2002 14:38:08 +0000 (14:38 +0000)
committerEdin Kadribasic <edink@php.net>
Thu, 23 May 2002 14:38:08 +0000 (14:38 +0000)
ext/standard/math.c

index ae9a5b02e2a3fa132e1a3cfbba3aa964c981d3ee..4ca710d23566bafc4b96b14588f94cf805e136fc 100644 (file)
@@ -429,14 +429,11 @@ PHP_FUNCTION(pow)
                return;
        }
 
-       /* TODO: handle numeric strings. */
-       if ((Z_TYPE_P(zbase) != IS_LONG && Z_TYPE_P(zbase) != IS_DOUBLE) ||
-               (Z_TYPE_P(zexp ) != IS_LONG && Z_TYPE_P(zexp ) != IS_DOUBLE)) {
-               php_error(E_WARNING, "Invalid argument(s) passed to %s()", get_active_function_name(TSRMLS_C));
-               RETURN_FALSE;
-       }
+       /* make sure we're dealing with numbers */
+       convert_scalar_to_number(zbase TSRMLS_CC);
+       convert_scalar_to_number(zexp TSRMLS_CC);
 
-       /* if both base and exponent were longs, try to get a long out */
+       /* if both base and exponent were longs, we'll try to get a long out */
        wantlong = Z_TYPE_P(zbase) == IS_LONG 
                && Z_TYPE_P(zexp ) == IS_LONG && Z_LVAL_P(zexp) >= 0;