[PHP-DEV] PHP 4.0 Bug #2191: Function max does not work... From: oliver <email protected>
Date: 08/30/99

From: oliver <email protected>
Operating system: linux
PHP version: 4.0 Latest CVS (30/08/1999)
PHP Bug Type: Misbehaving function
Bug description: Function max does not work...

Simple script to reproduce:
---------------------------
<?php
print max(20.0,10.0,30.0);
?>

prints 20 instead of 30. (In fact, it always prints the first value)

Here is a patch which worked for me, but I'm not sure whether
it's the correct way of fixing it:

*** basic_functions.c Mon Aug 30 15:05:51 1999
--- basic_functions.c.org Sun Aug 29 13:05:46 1999
***************
*** 1388,1395 ****
                min = args[0];
  
                for (i=1; i<ARG_COUNT(ht); i++) {
! compare_function(&result, min, args[i]);
! if (result.value.lval > 0) {
                                min = args[i];
                        }
                }
--- 1388,1395 ----
                min = args[0];
  
                for (i=1; i<ARG_COUNT(ht); i++) {
! is_smaller_function(&result, args[i], min);
! if (result.value.lval == 1) {
                                min = args[i];
                        }
                }
***************
*** 1439,1446 ****
                max = args[0];
  
                for (i=1; i<ARG_COUNT(ht); i++) {
! compare_function(&result, max, args[i]);
! if (result.value.lval < 0) {
                                max = args[i];
                        }
                }
--- 1439,1446 ----
                max = args[0];
  
                for (i=1; i<ARG_COUNT(ht); i++) {
! is_smaller_or_equal_function(&result, args[i], max);
! if (result.value.lval == 0) {
                                max = args[i];
                        }
                }

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>