php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2191 Function max does not work...
Submitted: 1999-08-30 09:22 UTC Modified: 1999-08-31 11:27 UTC
From: oliver at billix dot franken dot de Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0 Latest CVS (30/08/1999) OS: linux
Private report: No CVE-ID: None
 [1999-08-30 09:22 UTC] oliver at billix dot franken dot de
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];
                        }
                }

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-08-31 11:27 UTC] ssb at cvs dot php dot net
Your patch has been applied.  Thanks.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 15:01:56 2024 UTC