File tree Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Original file line number Diff line number Diff line change 338
338
dnl
339
339
dnl Check for available functions
340
340
dnl
341
- AC_CHECK_FUNCS ( getcwd getwd asinh acosh atanh log1p hypot glob strfmon nice fpclass isinf isnan mempcpy strpncpy )
341
+ AC_CHECK_FUNCS ( getcwd getwd asinh acosh atanh log1p log2 hypot glob strfmon nice fpclass isinf isnan mempcpy strpncpy )
342
342
AC_FUNC_FNMATCH
343
343
344
344
dnl
Original file line number Diff line number Diff line change @@ -661,22 +661,35 @@ PHP_FUNCTION(log1p)
661
661
PHP_FUNCTION (log )
662
662
{
663
663
double num , base = 0 ;
664
-
664
+
665
665
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "d|d" , & num , & base ) == FAILURE ) {
666
666
return ;
667
667
}
668
+
668
669
if (ZEND_NUM_ARGS () == 1 ) {
669
670
RETURN_DOUBLE (log (num ));
670
671
}
671
- if (base <= 0.0 ) {
672
- php_error_docref (NULL TSRMLS_CC , E_WARNING , "base must be greater than 0" );
673
- RETURN_FALSE ;
672
+
673
+ #ifdef HAVE_LOG2
674
+ if (base == 2.0 ) {
675
+ RETURN_DOUBLE (log2 (num ));
676
+ }
677
+ #endif
678
+
679
+ if (base == 10.0 ) {
680
+ RETURN_DOUBLE (log10 (num ));
674
681
}
675
- if (base == 1 ) {
682
+
683
+ if (base == 1.0 ) {
676
684
RETURN_DOUBLE (php_get_nan ());
677
- } else {
678
- RETURN_DOUBLE (log (num ) / log (base ));
679
685
}
686
+
687
+ if (base <= 0.0 ) {
688
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "base must be greater than 0" );
689
+ RETURN_FALSE ;
690
+ }
691
+
692
+ RETURN_DOUBLE (log (num ) / log (base ));
680
693
}
681
694
/* }}} */
682
695
You can’t perform that action at this time.
0 commit comments