Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » PHP
  • » [PHP-DEV] [PATCH] array_product() [RSS Feed]

#1 Oct. 29, 2005 08:04:03

Arpad R.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] [PATCH] array_product()


The array_product() function is completely broken. I've filed a bug athttp://bugs.php.net/bug.php?id=35014describing the problem, but to summarise
it returns 0 for all valid input and when the input is an empty array.

I've also posted a patch, which fixes everything for me. I would appreciate
any feedback, especially since this is my first patch :)

Thanks,
Arpad Ray

Index: ext/standard/array.c
===================================================================
RCS file: /repository/php-src/ext/standard/array.c,v
retrieving revision 1.308.2.10
diff -u -u -b -B -r1.308.2.10 array.c
--- ext/standard/array.c 28 Oct 2005 09:57:35 -0000 1.308.2.10
+++ ext/standard/array.c 29 Oct 2005 06:04:22 -0000
@@ -3997,7 +3997,12 @@
return;
}

- ZVAL_LONG(return_value, 0);
+ if (zend_hash_num_elements(Z_ARRVAL_PP(input)) == 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Array must
contain at least one element");
+ return;
+ }
+
+ ZVAL_LONG(return_value, 1);

for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(input), &pos);
zend_hash_get_current_data_ex(Z_ARRVAL_PP(input), (void
**)&entry, &pos) == SUCCESS;

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

  • Root
  • » PHP
  • » [PHP-DEV] [PATCH] array_product() [RSS Feed]

Board footer

Moderator control

Enjoy the 18th of November
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support