[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c /ext/standard/tests/array array_multisort_variation11.phpt

2009-05-15 Thread Christopher Jones
sixdFri May 15 16:46:23 2009 UTC

  Added files: (Branch: PHP_5_3)
/php-src/ext/standard/tests/array   array_multisort_variation11.phpt 

  Modified files:  
/php-src/ext/standard   array.c 
  Log:
  MFH: New array_multisort() test and code comment fix (Simon Westcott)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.54r2=1.308.2.21.2.37.2.55diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.54 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.55
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.54   Sun May 10 16:45:21 2009
+++ php-src/ext/standard/array.cFri May 15 16:46:22 2009
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.54 2009/05/10 16:45:21 colder Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.55 2009/05/15 16:46:22 sixd Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -3789,7 +3789,7 @@
}
}
 
-   /* If all arrays are empty or have only one entry, we don't need to do 
anything. */
+   /* If all arrays are empty we don't need to do anything. */
if (array_size  1) {
for (k = 0; k  MULTISORT_LAST; k++) {
efree(ARRAYG(multisort_flags)[k]);

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_multisort_variation11.phpt?view=markuprev=1.1
Index: php-src/ext/standard/tests/array/array_multisort_variation11.phpt
+++ php-src/ext/standard/tests/array/array_multisort_variation11.phpt
--TEST--
Test array_multisort() function : usage variation - testing with empty array
--FILE--
?php
/* Prototype  : bool array_multisort(array ar1 [, SORT_ASC|SORT_DESC [, 
SORT_REGULAR|SORT_NUMERIC|SORT_STRING]] [, array ar2 [, SORT_ASC|SORT_DESC [, 
SORT_REGULAR|SORT_NUMERIC|SORT_STRING]], ...])
 * Description: Sort multiple arrays at once similar to how ORDER BY clause 
works in SQL
 * Source code: ext/standard/array.c
 * Alias to functions:
 */

echo *** Testing array_multisort() : Testing with empty array ***\n;

var_dump(array_multisort(array()));

?
===DONE===
?php exit(0); ?
--EXPECTF--
*** Testing array_multisort() : Testing with empty array ***
bool(true)
===DONE===



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2009-05-15 Thread Moriyoshi Koizumi
moriyoshi   Fri May 15 17:03:03 2009 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  * MFH: Roll it back.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.55r2=1.308.2.21.2.37.2.56diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.55 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.56
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.55   Fri May 15 16:46:22 2009
+++ php-src/ext/standard/array.cFri May 15 17:03:03 2009
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.55 2009/05/15 16:46:22 sixd Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.56 2009/05/15 17:03:03 moriyoshi Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -2697,7 +2697,7 @@
};
struct bucketindex *arTmp, *cmpdata, *lastkept;
unsigned int i;
-   long sort_type = PHP_SORT_REGULAR;
+   long sort_type = PHP_SORT_STRING;
 
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, a|l, array, 
sort_type) == FAILURE) {
return;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2009-05-10 Thread Etienne Kneuss
colder  Sun May 10 16:45:21 2009 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  MFB: Fix #48224 (Remove incorrect shuffle)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.53r2=1.308.2.21.2.37.2.54diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.53 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.54
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.53   Fri Feb 13 22:34:15 2009
+++ php-src/ext/standard/array.cSun May 10 16:45:21 2009
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.53 2009/02/13 22:34:15 andrei Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.54 2009/05/10 16:45:21 colder Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -3920,10 +3920,6 @@
num_avail--;
zend_hash_move_forward_ex(Z_ARRVAL_P(input), pos);
}
-
-   if (num_req == num_avail) {
-   php_array_data_shuffle(return_value TSRMLS_CC);
-   }
 }
 /* }}} */
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2009-05-10 Thread Johannes Schlüter
On Sun, 2009-05-10 at 16:45 +, Etienne Kneuss wrote:
 colderSun May 10 16:45:21 2009 UTC
 
   Modified files:  (Branch: PHP_5_3)
 /php-src/ext/standard array.c 
   Log:
   MFB: Fix #48224 (Remove incorrect shuffle)

Any chance to cover this in a test? - I know it involves randomness.

Maybe multiple calls to array_rand() and check if it's always in right
order or something?

johannes



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2009-05-10 Thread Etienne Kneuss
2009/5/10 Johannes Schlüter johan...@php.net:
 On Sun, 2009-05-10 at 16:45 +, Etienne Kneuss wrote:
 colder                Sun May 10 16:45:21 2009 UTC

   Modified files:              (Branch: PHP_5_3)
     /php-src/ext/standard     array.c
   Log:
   MFB: Fix #48224 (Remove incorrect shuffle)

 Any chance to cover this in a test? - I know it involves randomness.

 Maybe multiple calls to array_rand() and check if it's always in right
 order or something?

Yeah, I added a === check which should have a low probability of
passing with shuffles


 johannes






-- 
Etienne Kneuss
http://www.colder.ch

Men never do evil so completely and cheerfully as
when they do it from a religious conviction.
-- Pascal

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2009-02-13 Thread Andrei Zmievski
andrei  Fri Feb 13 22:34:15 2009 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  Revert bogus fix for #47370.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.52r2=1.308.2.21.2.37.2.53diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.52 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.53
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.52   Thu Feb 12 18:57:55 2009
+++ php-src/ext/standard/array.cFri Feb 13 22:34:15 2009
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.52 2009/02/12 18:57:55 moriyoshi Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.53 2009/02/13 22:34:15 andrei Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -2697,7 +2697,7 @@
};
struct bucketindex *arTmp, *cmpdata, *lastkept;
unsigned int i;
-   long sort_type = PHP_SORT_STRING;
+   long sort_type = PHP_SORT_REGULAR;
 
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, a|l, array, 
sort_type) == FAILURE) {
return;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2009-02-12 Thread Moriyoshi Koizumi
moriyoshi   Thu Feb 12 18:57:55 2009 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  * MFH: Fix bug #47370 (BC breakage of array_unique())
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.51r2=1.308.2.21.2.37.2.52diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.51 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.52
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.51   Mon Feb  9 10:47:09 2009
+++ php-src/ext/standard/array.cThu Feb 12 18:57:55 2009
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.51 2009/02/09 10:47:09 dmitry Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.52 2009/02/12 18:57:55 moriyoshi Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -2697,7 +2697,7 @@
};
struct bucketindex *arTmp, *cmpdata, *lastkept;
unsigned int i;
-   long sort_type = PHP_SORT_REGULAR;
+   long sort_type = PHP_SORT_STRING;
 
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, a|l, array, 
sort_type) == FAILURE) {
return;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c /ext/standard/tests/array bug46873.phpt

2008-12-26 Thread Arnaud Le Blanc
lbarnaudSat Dec 27 03:06:57 2008 UTC

  Added files: (Branch: PHP_5_3)
/php-src/ext/standard/tests/array   bug46873.phpt 

  Modified files:  
/php-src/ext/standard   array.c 
  Log:
  MFH: Fixed bug #46873 (extract($foo) crashes if $foo['foo'] exists)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.48r2=1.308.2.21.2.37.2.49diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.48 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.49
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.48   Fri Dec 12 19:20:49 2008
+++ php-src/ext/standard/array.cSat Dec 27 03:06:57 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.48 2008/12/12 19:20:49 andrei Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.49 2008/12/27 03:06:57 lbarnaud Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -1283,6 +1283,13 @@
zend_rebuild_symbol_table(TSRMLS_C);
}
 
+   /* var_array is passed by ref for the needs of EXTR_REFS (needs to
+* work on the original array to create refs to its members)
+* simulate pass_by_value if EXTR_REFS is not used */
+   if (!extract_refs) {
+   SEPARATE_ARG_IF_REF(var_array);
+   }
+
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(var_array), pos);
while (zend_hash_get_current_data_ex(Z_ARRVAL_P(var_array), (void 
**)entry, pos) == SUCCESS) {
zval final_name;
@@ -1382,6 +1389,10 @@
zend_hash_move_forward_ex(Z_ARRVAL_P(var_array), pos);
}
 
+   if (!extract_refs) {
+   zval_ptr_dtor(var_array);
+   }
+
RETURN_LONG(count);
 }
 /* }}} */

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/bug46873.phpt?view=markuprev=1.1
Index: php-src/ext/standard/tests/array/bug46873.phpt
+++ php-src/ext/standard/tests/array/bug46873.phpt
--TEST--
Bug #46873 (extract($foo) crashes if $foo['foo'] exists)
--FILE--
?php
$foo = array('foo' = 1, 'bar' = 2, 'test' = 3);
extract($foo);
var_dump($foo, $bar, $test);
?
--EXPECT--
int(1)
int(2)
int(3)



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2008-12-12 Thread Andrei Zmievski
andrei  Fri Dec 12 19:20:49 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  MFH
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.47r2=1.308.2.21.2.37.2.48diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.47 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.48
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.47   Wed Nov 26 00:59:41 2008
+++ php-src/ext/standard/array.cFri Dec 12 19:20:49 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.47 2008/11/26 00:59:41 lbarnaud Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.48 2008/12/12 19:20:49 andrei Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -2668,7 +2668,7 @@
 }
 /* }}} */
 
-/* {{{ proto array array_unique(array input)
+/* {{{ proto array array_unique(array input [, int sort_flags])
Removes duplicate values from array */
 PHP_FUNCTION(array_unique)
 {
@@ -2680,11 +2680,14 @@
};
struct bucketindex *arTmp, *cmpdata, *lastkept;
unsigned int i;
+   long sort_type = PHP_SORT_REGULAR;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, a, array) == 
FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, a|l, array, 
sort_type) == FAILURE) {
return;
}
 
+   php_set_compare_func(sort_type TSRMLS_CC);
+
array_init_size(return_value, 
zend_hash_num_elements(Z_ARRVAL_P(array)));
zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_P(array), 
(copy_ctor_func_t) zval_add_ref, (void *)tmp, sizeof(zval*));
 
@@ -2703,7 +2706,6 @@
arTmp[i].i = i;
}
arTmp[i].b = NULL;
-   php_set_compare_func(PHP_SORT_STRING TSRMLS_CC);
zend_qsort((void *) arTmp, i, sizeof(struct bucketindex), 
php_array_data_compare TSRMLS_CC);
 
/* go through the sorted array and delete duplicates from the copy */



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2008-12-12 Thread Hannes Magnusson
Could you maybe fix the at-least-four-tests that broke, and maybe add
a new test for this feature? :)
And NEWS entry, [DOC], update the wiki...

-Hannes

On Fri, Dec 12, 2008 at 20:20, Andrei Zmievski and...@php.net wrote:
 andrei  Fri Dec 12 19:20:49 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c
  Log:
  MFH


 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.47r2=1.308.2.21.2.37.2.48diff_format=u
 Index: php-src/ext/standard/array.c
 diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.47 
 php-src/ext/standard/array.c:1.308.2.21.2.37.2.48
 --- php-src/ext/standard/array.c:1.308.2.21.2.37.2.47   Wed Nov 26 00:59:41 
 2008
 +++ php-src/ext/standard/array.cFri Dec 12 19:20:49 2008
 @@ -21,7 +21,7 @@
+--+
  */

 -/* $Id: array.c,v 1.308.2.21.2.37.2.47 2008/11/26 00:59:41 lbarnaud Exp $ */
 +/* $Id: array.c,v 1.308.2.21.2.37.2.48 2008/12/12 19:20:49 andrei Exp $ */

  #include php.h
  #include php_ini.h
 @@ -2668,7 +2668,7 @@
  }
  /* }}} */

 -/* {{{ proto array array_unique(array input)
 +/* {{{ proto array array_unique(array input [, int sort_flags])
Removes duplicate values from array */
  PHP_FUNCTION(array_unique)
  {
 @@ -2680,11 +2680,14 @@
};
struct bucketindex *arTmp, *cmpdata, *lastkept;
unsigned int i;
 +   long sort_type = PHP_SORT_REGULAR;

 -   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, a, array) == 
 FAILURE) {
 +   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, a|l, array, 
 sort_type) == FAILURE) {
return;
}

 +   php_set_compare_func(sort_type TSRMLS_CC);
 +
array_init_size(return_value, 
 zend_hash_num_elements(Z_ARRVAL_P(array)));
zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_P(array), 
 (copy_ctor_func_t) zval_add_ref, (void *)tmp, sizeof(zval*));

 @@ -2703,7 +2706,6 @@
arTmp[i].i = i;
}
arTmp[i].b = NULL;
 -   php_set_compare_func(PHP_SORT_STRING TSRMLS_CC);
zend_qsort((void *) arTmp, i, sizeof(struct bucketindex), 
 php_array_data_compare TSRMLS_CC);

/* go through the sorted array and delete duplicates from the copy */



 --
 PHP CVS Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2008-12-12 Thread Andrei Zmievski
Easy, there. I realized that there were 4 tests that broke after committing it. The issue 
is that I made SORT_REGULAR to be the default, which is not what the tests were expecting. 
 The easiest way to fix the tests is to make them pass SORT_STRING to array_unique(), I 
guess.


The rest is coming.

-Andrei

Hannes Magnusson wrote:

Could you maybe fix the at-least-four-tests that broke, and maybe add
a new test for this feature? :)
And NEWS entry, [DOC], update the wiki...



--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c basic_functions.c

2008-11-25 Thread Antony Dovgal
On 24.11.2008 21:12, Stanislav Malyshev wrote:
 stas  Mon Nov 24 18:12:17 2008 UTC
 
   Modified files:  (Branch: PHP_5_3)
 /php-src/ext/standard array.c basic_functions.c 
   Log:
   restore BC for arrays
   [DOC] natsort, natcasesort, usort, uasort, uksort, array_flip, array_unique 
   still won't work with objects

All these tests fail after your patch:

/local/qa/5_3.zts/ext/standard/tests/array/array_key_exists.phpt
/local/qa/5_3.zts/ext/standard/tests/array/array_key_exists_object1.phpt
/local/qa/5_3.zts/ext/standard/tests/array/array_key_exists_object2.phpt
/local/qa/5_3.zts/ext/standard/tests/array/array_key_exists_variation2.phpt
/local/qa/5_3.zts/ext/standard/tests/array/array_walk_object1.phpt
/local/qa/5_3.zts/ext/standard/tests/array/array_walk_objects.phpt
/local/qa/5_3.zts/ext/standard/tests/array/array_walk_rec_objects.phpt
/local/qa/5_3.zts/ext/standard/tests/array/array_walk_recursive_object1.phpt
/local/qa/5_3.zts/ext/standard/tests/array/current_variation1.phpt
/local/qa/5_3.zts/ext/standard/tests/array/end_variation1.phpt
/local/qa/5_3.zts/ext/standard/tests/array/key_variation1.phpt
/local/qa/5_3.zts/ext/standard/tests/array/next_variation1.phpt
/local/qa/5_3.zts/ext/standard/tests/array/prev_variation1.phpt
/local/qa/5_3.zts/ext/standard/tests/array/reset_variation1.phpt

-- 
Wbr, 
Antony Dovgal

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c basic_functions.c

2008-11-25 Thread Stanislav Malyshev

Hi!


All these tests fail after your patch:

/local/qa/5_3.zts/ext/standard/tests/array/array_key_exists.phpt
/local/qa/5_3.zts/ext/standard/tests/array/array_key_exists_object1.phpt
/local/qa/5_3.zts/ext/standard/tests/array/array_key_exists_object2.phpt
/local/qa/5_3.zts/ext/standard/tests/array/array_key_exists_variation2.phpt
/local/qa/5_3.zts/ext/standard/tests/array/array_walk_object1.phpt
/local/qa/5_3.zts/ext/standard/tests/array/array_walk_objects.phpt
/local/qa/5_3.zts/ext/standard/tests/array/array_walk_rec_objects.phpt
/local/qa/5_3.zts/ext/standard/tests/array/array_walk_recursive_object1.phpt
/local/qa/5_3.zts/ext/standard/tests/array/current_variation1.phpt
/local/qa/5_3.zts/ext/standard/tests/array/end_variation1.phpt
/local/qa/5_3.zts/ext/standard/tests/array/key_variation1.phpt
/local/qa/5_3.zts/ext/standard/tests/array/next_variation1.phpt
/local/qa/5_3.zts/ext/standard/tests/array/prev_variation1.phpt
/local/qa/5_3.zts/ext/standard/tests/array/reset_variation1.phpt


These tests expect BC breakage, which this patch fixes. So they need to 
be fixed, I guess.

--
Stanislav Malyshev, Zend Software Architect
[EMAIL PROTECTED]   http://www.zend.com/
(408)253-8829   MSN: [EMAIL PROTECTED]

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c basic_functions.c

2008-11-25 Thread Antony Dovgal
On 25.11.2008 12:15, Stanislav Malyshev wrote:
 Hi!
 
 All these tests fail after your patch:
...
 These tests expect BC breakage, which this patch fixes. So they need to 
 be fixed, I guess.

Does this mean you didn't run the tests before applying the patch?
Or does this mean you've just ignored them?

In either case, please fix the tests, if you're sure they need fixing.

-- 
Wbr, 
Antony Dovgal

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c /ext/standard/tests/array extract_variation10.phpt extract_variation11.phpt

2008-11-25 Thread Arnaud Le Blanc
lbarnaudWed Nov 26 00:59:41 2008 UTC

  Added files: (Branch: PHP_5_3)
/php-src/ext/standard/tests/array   extract_variation10.phpt 
extract_variation11.phpt 

  Modified files:  
/php-src/ext/standard   array.c 
  Log:
  MFH: Fixed bugs #44181  #44182 (extract() and references)
  (robin_fernandes at uk dot ibm dot com)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.46r2=1.308.2.21.2.37.2.47diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.46 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.47
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.46   Mon Nov 24 18:12:16 2008
+++ php-src/ext/standard/array.cWed Nov 26 00:59:41 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.46 2008/11/24 18:12:16 stas Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.47 2008/11/26 00:59:41 lbarnaud Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -1359,18 +1359,13 @@
if (extract_refs) {
zval **orig_var;
 
+   SEPARATE_ZVAL_TO_MAKE_IS_REF(entry);
+   zval_add_ref(entry);
+
if (zend_hash_find(EG(active_symbol_table), 
Z_STRVAL(final_name), Z_STRLEN(final_name) + 1, (void **) orig_var) == 
SUCCESS) {
-   SEPARATE_ZVAL_TO_MAKE_IS_REF(entry);
-   zval_add_ref(entry);
zval_ptr_dtor(orig_var);
*orig_var = *entry;
} else {
-   if (Z_REFCOUNT_P(var_array)  1 || 
*entry == EG(uninitialized_zval_ptr)) {
-   
SEPARATE_ZVAL_TO_MAKE_IS_REF(entry);
-   } else {
-   Z_SET_ISREF_PP(entry);
-   }
-   zval_add_ref(entry);

zend_hash_update(EG(active_symbol_table), Z_STRVAL(final_name), 
Z_STRLEN(final_name) + 1, (void **) entry, sizeof(zval *), NULL);
}
} else {

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/extract_variation10.phpt?view=markuprev=1.1
Index: php-src/ext/standard/tests/array/extract_variation10.phpt
+++ php-src/ext/standard/tests/array/extract_variation10.phpt
--TEST--
Test extract() function - ensure EXTR_REFS doesn't mess with isRef flag on COW 
references to array elements.  
--FILE--
?php
$a = array('foo' = 'original.foo');
$nonref = $a['foo'];
$ref = $a;
extract($a, EXTR_REFS);
$a['foo'] = 'changed.foo';
var_dump($nonref);
?
--EXPECTF--
%unicode|string%(12) original.foo

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/extract_variation11.phpt?view=markuprev=1.1
Index: php-src/ext/standard/tests/array/extract_variation11.phpt
+++ php-src/ext/standard/tests/array/extract_variation11.phpt
--TEST--
Test extract() function - ensure EXTR_REFS works when array is referenced and 
keys clash with variables in current scope. 
--FILE--
?php
$a = array('foo' = 'original.foo');
$ref = $a;
$foo = 'test';
extract($a, EXTR_OVERWRITE|EXTR_REFS);
$foo = 'changed.foo';
var_dump($a['foo']);
?
--EXPECTF--
%unicode|string%(11) changed.foo



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c basic_functions.c

2008-11-24 Thread Stanislav Malyshev
stasMon Nov 24 18:12:17 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c basic_functions.c 
  Log:
  restore BC for arrays
  [DOC] natsort, natcasesort, usort, uasort, uksort, array_flip, array_unique 
  still won't work with objects
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.45r2=1.308.2.21.2.37.2.46diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.45 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.46
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.45   Tue Oct 21 22:08:36 2008
+++ php-src/ext/standard/array.cMon Nov 24 18:12:16 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.45 2008/10/21 22:08:36 lbarnaud Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.46 2008/11/24 18:12:16 stas Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -751,16 +751,17 @@
Advances array argument's internal pointer to the last element and return 
it */
 PHP_FUNCTION(end)
 {
-   zval *array, **entry;
+   HashTable *array;
+   zval **entry;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, a, array) == 
FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, H, array) == 
FAILURE) {
return;
}
 
-   zend_hash_internal_pointer_end(Z_ARRVAL_P(array));
+   zend_hash_internal_pointer_end(array);
 
if (return_value_used) {
-   if (zend_hash_get_current_data(Z_ARRVAL_P(array), (void **) 
entry) == FAILURE) {
+   if (zend_hash_get_current_data(array, (void **) entry) == 
FAILURE) {
RETURN_FALSE;
}
 
@@ -773,16 +774,17 @@
Move array argument's internal pointer to the previous element and return 
it */
 PHP_FUNCTION(prev)
 {
-   zval *array, **entry;
+   HashTable *array;
+   zval **entry;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, a, array) == 
FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, H, array) == 
FAILURE) {
return;
}
 
-   zend_hash_move_backwards(Z_ARRVAL_P(array));
+   zend_hash_move_backwards(array);
 
if (return_value_used) {
-   if (zend_hash_get_current_data(Z_ARRVAL_P(array), (void **) 
entry) == FAILURE) {
+   if (zend_hash_get_current_data(array, (void **) entry) == 
FAILURE) {
RETURN_FALSE;
}
 
@@ -795,16 +797,17 @@
Move array argument's internal pointer to the next element and return it */
 PHP_FUNCTION(next)
 {
-   zval *array, **entry;
+   HashTable *array;
+   zval **entry;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, a, array) == 
FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, H, array) == 
FAILURE) {
return;
}
 
-   zend_hash_move_forward(Z_ARRVAL_P(array));
+   zend_hash_move_forward(array);
 
if (return_value_used) {
-   if (zend_hash_get_current_data(Z_ARRVAL_P(array), (void **) 
entry) == FAILURE) {
+   if (zend_hash_get_current_data(array, (void **) entry) == 
FAILURE) {
RETURN_FALSE;
}
 
@@ -817,16 +820,17 @@
Set array argument's internal pointer to the first element and return it */
 PHP_FUNCTION(reset)
 {
-   zval *array, **entry;
+   HashTable *array;
+   zval **entry;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, a, array) == 
FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, H, array) == 
FAILURE) {
return;
}
 
-   zend_hash_internal_pointer_reset(Z_ARRVAL_P(array));
+   zend_hash_internal_pointer_reset(array);
 
if (return_value_used) {
-   if (zend_hash_get_current_data(Z_ARRVAL_P(array), (void **) 
entry) == FAILURE) {
+   if (zend_hash_get_current_data(array, (void **) entry) == 
FAILURE) {
RETURN_FALSE;
}
 
@@ -839,13 +843,14 @@
Return the element currently pointed to by the internal array pointer */
 PHP_FUNCTION(current)
 {
-   zval *array, **entry;
+   HashTable *array;
+   zval **entry;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, a, array) == 
FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, H, array) == 
FAILURE) {
return;
}
 
-   if (zend_hash_get_current_data(Z_ARRVAL_P(array), (void **) entry) == 
FAILURE) {
+   if (zend_hash_get_current_data(array, (void **) entry) == FAILURE) {
RETURN_FALSE;
}
RETURN_ZVAL(*entry, 1, 0);
@@ -856,16 +861,16 @@
Return the key of the element currently pointed to by the internal array 
pointer */
 PHP_FUNCTION(key)
 {
-   zval *array;
+   HashTable 

Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c assert.c basic_functions.c browscap.c crypt.c file.c filestat.c head.c html.c http.c info.c mail.c math.c proc_open.c rand.c streamsfuncs.c st

2008-10-22 Thread Nuno Lopes

Hey, hey, what are you doing?
I assume you're reading the 
http://gcov.php.net/viewer.php?version=PHP_5_3func=params page. That script 
is very dumb and unfortunately shows many false positives. I did a cursory 
review of your commits and most of the changes you did aren't necessary (in 
fact they can degrade the performance).
This year I was hoping to get a student from the GSoC project to improve 
this analyzer, but I didn't. Let's hope next year we can get one :P (if 
someone is interested please contact me!)


In the mean time, please don't assume that script is 100% right. Please 
always look to the code first to check if the initialization is really 
needed.


Thanks,
Nuno

- Original Message - 
From: Arnaud Le Blanc [EMAIL PROTECTED]

To: php-cvs@lists.php.net
Sent: Tuesday, October 21, 2008 11:08 PM
Subject: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c assert.c 
basic_functions.c browscap.c crypt.c file.c filestat.c head.c html.c http.c 
info.c mail.c math.c proc_open.c rand.c streamsfuncs.c string.c type.c 
versioning.c




lbarnaud Tue Oct 21 22:08:39 2008 UTC

 Modified files:  (Branch: PHP_5_3)
   /php-src/ext/standard array.c assert.c basic_functions.c browscap.c
crypt.c file.c filestat.c head.c html.c
http.c info.c mail.c math.c proc_open.c
rand.c streamsfuncs.c string.c type.c
versioning.c
 Log:
 MFH: initialize optional vars 



--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c assert.c basic_functions.c browscap.c crypt.c file.c filestat.c head.c html.c http.c info.c mail.c math.c proc_open.c rand.c streamsfuncs.c string

2008-10-21 Thread Arnaud Le Blanc
lbarnaudTue Oct 21 22:08:39 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c assert.c basic_functions.c browscap.c 
crypt.c file.c filestat.c head.c html.c 
http.c info.c mail.c math.c proc_open.c 
rand.c streamsfuncs.c string.c type.c 
versioning.c 
  Log:
  MFH: initialize optional vars
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.44r2=1.308.2.21.2.37.2.45diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.44 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.45
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.44   Tue Sep 23 15:18:26 2008
+++ php-src/ext/standard/array.cTue Oct 21 22:08:36 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.44 2008/09/23 15:18:26 nlopess Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.45 2008/10/21 22:08:36 lbarnaud Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -1981,14 +1981,14 @@
 PHP_FUNCTION(array_splice)
 {
zval *array,/* Input array */
-*repl_array,   /* Replacement array */
+*repl_array = NULL,/* Replacement array */
 ***repl = NULL;/* Replacement elements */
HashTable *new_hash = NULL, /* Output array's hash */
 **rem_hash = NULL; /* Removed elements' hash */
Bucket *p;  /* Bucket used for 
traversing hash */
longi,
offset,
-   length,
+   length = 0,
repl_num = 0;   /* Number of replacement 
elements */
int num_in; /* Number of elements 
in the input array */
 
@@ -2061,7 +2061,7 @@
 PHP_FUNCTION(array_slice)
 {
zval *input,/* Input array */
-   **z_length, /* How many elements to get */ 
+   **z_length = NULL, /* How many elements to get */ 
**entry;/* An array entry */
long offset,/* Offset to get elements from */
 length = 0;
@@ -4004,7 +4004,7 @@
zval *retval;
zend_fcall_info fci;
zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
-   zval *initial;
+   zval *initial = NULL;
HashPosition pos;
HashTable *htbl;
 
@@ -4073,7 +4073,7 @@
zval *retval = NULL;
zend_bool have_callback = 0;
char *string_key;
-   zend_fcall_info fci;
+   zend_fcall_info fci = empty_fcall_info;
zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
uint string_key_len;
ulong num_key;
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/assert.c?r1=1.60.2.3.2.6.2.3r2=1.60.2.3.2.6.2.4diff_format=u
Index: php-src/ext/standard/assert.c
diff -u php-src/ext/standard/assert.c:1.60.2.3.2.6.2.3 
php-src/ext/standard/assert.c:1.60.2.3.2.6.2.4
--- php-src/ext/standard/assert.c:1.60.2.3.2.6.2.3  Wed Jul 23 19:34:35 2008
+++ php-src/ext/standard/assert.c   Tue Oct 21 22:08:36 2008
@@ -16,7 +16,7 @@
+--+
 */
 
-/* $Id: assert.c,v 1.60.2.3.2.6.2.3 2008/07/23 19:34:35 felipe Exp $ */
+/* $Id: assert.c,v 1.60.2.3.2.6.2.4 2008/10/21 22:08:36 lbarnaud Exp $ */
 
 /* {{{ includes */
 #include php.h
@@ -239,7 +239,7 @@
Set/get the various assert flags */
 PHP_FUNCTION(assert_options)
 {
-   zval **value;
+   zval **value = NULL;
long what;
int oldint;
int ac = ZEND_NUM_ARGS();
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.c?r1=1.725.2.31.2.64.2.64r2=1.725.2.31.2.64.2.65diff_format=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.725.2.31.2.64.2.64 
php-src/ext/standard/basic_functions.c:1.725.2.31.2.64.2.65
--- php-src/ext/standard/basic_functions.c:1.725.2.31.2.64.2.64 Thu Oct 16 
23:19:13 2008
+++ php-src/ext/standard/basic_functions.c  Tue Oct 21 22:08:36 2008
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.725.2.31.2.64.2.64 2008/10/16 23:19:13 kalle Exp 
$ */
+/* $Id: basic_functions.c,v 1.725.2.31.2.64.2.65 2008/10/21 22:08:36 lbarnaud 
Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -5066,9 +5066,9 @@
 PHP_FUNCTION(error_log)
 {
char *message, *opt = NULL, *headers = NULL;
-   int message_len, opt_len, headers_len;
+   int message_len, opt_len = 0, headers_len = 0;
int opt_err = 0, argc = 

[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c /ext/standard/tests/array max.phpt max_error.phpt min.phpt min_error.phpt

2008-08-10 Thread Felipe Pena
felipe  Sun Aug 10 17:50:45 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
/php-src/ext/standard/tests/array   max.phpt max_error.phpt min.phpt 
min_error.phpt 
  Log:
  - MFH: New parameter parsing API (for min() and max())
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.39r2=1.308.2.21.2.37.2.40diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.39 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.40
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.39   Sat Aug  2 04:46:06 2008
+++ php-src/ext/standard/array.cSun Aug 10 17:50:44 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.39 2008/08/02 04:46:06 felipe Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.40 2008/08/10 17:50:44 felipe Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -923,47 +923,48 @@
Return the lowest value in an array or a series of arguments */
 PHP_FUNCTION(min)
 {
-   int argc=ZEND_NUM_ARGS();
-   zval **result;
+   int argc;
+   zval ***args = NULL;
 
-   if (argc=0) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, At least one value 
should be passed);
-   RETURN_NULL();
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, +, args, argc) 
== FAILURE) {
+   return;
}
+   
php_set_compare_func(PHP_SORT_REGULAR TSRMLS_CC);
+   
+   /* mixed min ( array $values ) */
if (argc == 1) {
-   zval **arr;
-
-   if (zend_get_parameters_ex(1, arr) == FAILURE || 
Z_TYPE_PP(arr) != IS_ARRAY) {
-   WRONG_PARAM_COUNT;
-   }
-   if (zend_hash_minmax(Z_ARRVAL_PP(arr), php_array_data_compare, 
0, (void **) result TSRMLS_CC) == SUCCESS) {
-   RETVAL_ZVAL(*result, 1, 0);
+   zval **result;
+   
+   if (Z_TYPE_PP(args[0]) != IS_ARRAY) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, When only 
one parameter is given, it must be an array);
+   RETVAL_NULL();
} else {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Array must 
contain at least one element);
-   RETURN_FALSE;
+   if (zend_hash_minmax(Z_ARRVAL_PP(args[0]), 
php_array_data_compare, 0, (void **) result TSRMLS_CC) == SUCCESS) {
+   RETVAL_ZVAL(*result, 1, 0);
+   } else {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
Array must contain at least one element);
+   RETVAL_FALSE;
+   }
}
} else {
-   zval ***args = (zval ***) safe_emalloc(sizeof(zval **), 
ZEND_NUM_ARGS(), 0);
+   /* mixed min ( mixed $value1 , mixed $value2 [, mixed 
$value3... ] ) */
zval **min, result;
int i;
 
-   if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), 
args)==FAILURE) {
-   efree(args);
-   WRONG_PARAM_COUNT;
-   }
-
min = args[0];
 
-   for (i=1; iZEND_NUM_ARGS(); i++) {
+   for (i = 1; i  argc; i++) {
is_smaller_function(result, *args[i], *min TSRMLS_CC);
if (Z_LVAL(result) == 1) {
min = args[i];
}
}
 
-   RETVAL_ZVAL(*min, 1, 0);
+   RETVAL_ZVAL(*min, 1, 0);
+   }
 
+   if (args) {
efree(args);
}
 }
@@ -973,39 +974,38 @@
Return the highest value in an array or a series of arguments */
 PHP_FUNCTION(max)
 {
-   int argc=ZEND_NUM_ARGS();
-   zval **result;
-
-   if (argc=0) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, At least one value 
should be passed);
-   RETURN_NULL();
+   zval ***args = NULL;
+   int argc;
+   
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, +, args, argc) 
== FAILURE) {
+   return;
}
+
php_set_compare_func(PHP_SORT_REGULAR TSRMLS_CC);
+   
+   /* mixed max ( array $values ) */
if (argc == 1) {
-   zval **arr;
+   zval **result;
 
-   if (zend_get_parameters_ex(1, arr) == FAILURE || 
Z_TYPE_PP(arr) != IS_ARRAY) {
-   WRONG_PARAM_COUNT;
-   }
-   if (zend_hash_minmax(Z_ARRVAL_PP(arr), php_array_data_compare, 
1, (void **) result TSRMLS_CC) == SUCCESS) {
-   RETVAL_ZVAL(*result, 1, 0);
+   if (Z_TYPE_PP(args[0]) != IS_ARRAY) {
+   

[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c basic_functions.c php_array.h /ext/standard/tests array_replace.phpt

2008-07-31 Thread Johannes Schlüter
johannesThu Jul 31 20:18:17 2008 UTC

  Added files: (Branch: PHP_5_3)
/php-src/ext/standard/tests array_replace.phpt 

  Modified files:  
/php-src/ext/standard   array.c basic_functions.c php_array.h 
  Log:
  MFH (DOC] Add array_replace/array_replace_recursive (Mett Wilmas)
  http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.37r2=1.308.2.21.2.37.2.38diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.37 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.38
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.37   Thu Jul 24 03:07:22 2008
+++ php-src/ext/standard/array.cThu Jul 31 20:18:17 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.37 2008/07/24 03:07:22 felipe Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.38 2008/07/31 20:18:17 johannes Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -2300,10 +2300,69 @@
 }
 /* }}} */
 
-static void php_array_merge_wrapper(INTERNAL_FUNCTION_PARAMETERS, int 
recursive) /* {{{ */
+PHPAPI int php_array_replace_recursive(HashTable *dest, HashTable *src 
TSRMLS_DC) /* {{{ */
+{
+   zval **src_entry, **dest_entry;
+   char *string_key;
+   uint string_key_len;
+   ulong num_key;
+   HashPosition pos;
+
+   for (zend_hash_internal_pointer_reset_ex(src, pos);
+zend_hash_get_current_data_ex(src, (void **)src_entry, pos) == 
SUCCESS;
+zend_hash_move_forward_ex(src, pos)) {
+   switch (zend_hash_get_current_key_ex(src, string_key, 
string_key_len, num_key, 0, pos)) {
+   case HASH_KEY_IS_STRING:
+   if (Z_TYPE_PP(src_entry) != IS_ARRAY ||
+   zend_hash_find(dest, string_key, 
string_key_len, (void **)dest_entry) == FAILURE ||
+   Z_TYPE_PP(dest_entry) != IS_ARRAY) {
+
+   Z_ADDREF_PP(src_entry);
+   zend_hash_update(dest, string_key, 
string_key_len, src_entry, sizeof(zval *), NULL);
+
+   continue;
+   }
+   break;
+
+   case HASH_KEY_IS_LONG:
+   if (Z_TYPE_PP(src_entry) != IS_ARRAY ||
+   zend_hash_index_find(dest, num_key, 
(void **)dest_entry) == FAILURE ||
+   Z_TYPE_PP(dest_entry) != IS_ARRAY) {
+
+   Z_ADDREF_PP(src_entry);
+   zend_hash_index_update(dest, num_key, 
src_entry, sizeof(zval *), NULL);
+
+   continue;
+   }
+   break;
+   }
+
+   if (Z_ARRVAL_PP(dest_entry)-nApplyCount  1 || 
Z_ARRVAL_PP(src_entry)-nApplyCount  1 || (*src_entry == *dest_entry  
Z_ISREF_PP(dest_entry)  (Z_REFCOUNT_PP(dest_entry) % 2))) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, recursion 
detected);
+   return 0;
+   }
+   SEPARATE_ZVAL(dest_entry);
+   Z_ARRVAL_PP(dest_entry)-nApplyCount++;
+   Z_ARRVAL_PP(src_entry)-nApplyCount++;
+   
+
+   if (!php_array_replace_recursive(Z_ARRVAL_PP(dest_entry), 
Z_ARRVAL_PP(src_entry) TSRMLS_CC)) {
+   Z_ARRVAL_PP(dest_entry)-nApplyCount--;
+   Z_ARRVAL_PP(src_entry)-nApplyCount--;
+   return 0;
+   }
+   Z_ARRVAL_PP(dest_entry)-nApplyCount--;
+   Z_ARRVAL_PP(src_entry)-nApplyCount--;
+   }
+
+   return 1;
+}
+/* }}} */
+
+static void php_array_merge_or_replace_wrapper(INTERNAL_FUNCTION_PARAMETERS, 
int recursive, int replace) /* {{{ */
 {
zval ***args = NULL;
-   int argc, i, params_ok = 1;
+   int argc, i, params_ok = 1, init_size = 0;
 
/* Get the argument count and check it */
argc = ZEND_NUM_ARGS();
@@ -2322,6 +2381,12 @@
if (Z_TYPE_PP(args[i]) != IS_ARRAY) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, Argument 
#%d is not an array, i + 1);
params_ok = 0;
+   } else {
+   int num = zend_hash_num_elements(Z_ARRVAL_PP(args[i]));
+
+   if (num  init_size) {
+   init_size = num;
+   }
}
}
if (params_ok == 0) {
@@ -2329,12 +2394,16 @@
return;
}
 
-   array_init(return_value);
+   array_init_size(return_value, init_size);
 
-   for (i=0; iargc; i++) {
-   SEPARATE_ZVAL(args[i]);
-   

[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2008-07-23 Thread Felipe Pena
felipe  Wed Jul 23 16:28:46 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  - MFH: Fixed bug #45605 (array_uintersect_assoc gives incorrect error message)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.35r2=1.308.2.21.2.37.2.36diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.35 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.36
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.35   Wed Jul  9 21:29:52 2008
+++ php-src/ext/standard/array.cWed Jul 23 16:28:46 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.35 2008/07/09 21:29:52 colder Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.36 2008/07/23 16:28:46 felipe Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -2837,10 +2837,14 @@
/* Get the argument count */
argc = ZEND_NUM_ARGS();
if (data_compare_type == INTERSECT_COMP_DATA_USER) {
-   if (argc  3 || zend_parse_parameters(ZEND_NUM_ARGS() 
TSRMLS_CC, +f, args, argc, BG(user_compare_fci), 
BG(user_compare_fci_cache)) == FAILURE) {
+   if (argc  3) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, at least 3 
parameters are required, %d given, ZEND_NUM_ARGS());
return;
}
+   
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, +f, 
args, argc, BG(user_compare_fci), BG(user_compare_fci_cache)) == FAILURE) {
+   return;
+   }
intersect_data_compare_func = zval_user_compare;
} else {
if (argc  2 || zend_parse_parameters(ZEND_NUM_ARGS() 
TSRMLS_CC, +, args, argc) == FAILURE) {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2008-07-23 Thread Felipe Pena
felipe  Thu Jul 24 03:07:23 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  - MFH: Improved parameter handling
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.36r2=1.308.2.21.2.37.2.37diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.36 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.37
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.36   Wed Jul 23 16:28:46 2008
+++ php-src/ext/standard/array.cThu Jul 24 03:07:22 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.36 2008/07/23 16:28:46 felipe Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.37 2008/07/24 03:07:22 felipe Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -2833,28 +2833,35 @@
int (*intersect_data_compare_func)(zval **, zval ** TSRMLS_DC) = NULL;
zend_bool ok;
zval **data;
+   int req_args;
+   char *param_spec;
 
/* Get the argument count */
argc = ZEND_NUM_ARGS();
if (data_compare_type == INTERSECT_COMP_DATA_USER) {
-   if (argc  3) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, at least 3 
parameters are required, %d given, ZEND_NUM_ARGS());
-   return;
-   }
-   
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, +f, 
args, argc, BG(user_compare_fci), BG(user_compare_fci_cache)) == FAILURE) {
-   return;
-   }
+   /* INTERSECT_COMP_DATA_USER - array_uintersect_assoc() */
+   req_args = 3;
+   param_spec = +f;
intersect_data_compare_func = zval_user_compare;
} else {
-   if (argc  2 || zend_parse_parameters(ZEND_NUM_ARGS() 
TSRMLS_CC, +, args, argc) == FAILURE) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, at least 2 
parameters are required, %d given, ZEND_NUM_ARGS());
-   return;
-   }
+   /*  INTERSECT_COMP_DATA_NONE - array_intersect_key()
+   INTERSECT_COMP_DATA_INTERNAL - array_intersect_assoc() 
*/
+   req_args = 2;
+   param_spec = +;
+   
if (data_compare_type == INTERSECT_COMP_DATA_INTERNAL) {
intersect_data_compare_func = zval_compare;
}
}
+   
+   if (argc  req_args) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, at least %d 
parameters are required, %d given, req_args, argc);
+   return;
+   }
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, param_spec, args, 
argc, BG(user_compare_fci), BG(user_compare_fci_cache)) == FAILURE) {
+   return;
+   }
 
for (i = 0; i  argc; i++) {
if (Z_TYPE_PP(args[i]) != IS_ARRAY) {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2008-07-09 Thread Etienne Kneuss
colder  Wed Jul  9 21:29:53 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  MFH: Fix resolution rule of count vs. handler
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.34r2=1.308.2.21.2.37.2.35diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.34 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.35
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.34   Mon Jun  2 11:20:59 2008
+++ php-src/ext/standard/array.cWed Jul  9 21:29:52 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.34 2008/06/02 11:20:59 mattwil Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.35 2008/07/09 21:29:52 colder Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -319,9 +319,17 @@
break;
case IS_OBJECT: {
 #ifdef HAVE_SPL
-   /* it the object implements Countable we call its 
count() method */
zval *retval;
-
+#endif
+   /* first, we check if the handler is defined */
+   if (Z_OBJ_HT_P(array)-count_elements) {
+   RETVAL_LONG(1);
+   if (SUCCESS == 
Z_OBJ_HT(*array)-count_elements(array, Z_LVAL_P(return_value) TSRMLS_CC)) {
+   return;
+   }
+   }
+#ifdef HAVE_SPL
+   /* if not and the object implements Countable we call 
its count() method */
if (Z_OBJ_HT_P(array)-get_class_entry  
instanceof_function(Z_OBJCE_P(array), spl_ce_Countable TSRMLS_CC)) {
zend_call_method_with_0_params(array, NULL, 
NULL, count, retval);
if (retval) {
@@ -332,13 +340,6 @@
return;
}
 #endif
-   /* if not we return the number of properties (not 
taking visibility into account) */
-   if (Z_OBJ_HT_P(array)-count_elements) {
-   RETVAL_LONG(1);
-   if (SUCCESS == 
Z_OBJ_HT(*array)-count_elements(array, Z_LVAL_P(return_value) TSRMLS_CC)) {
-   return;
-   }
-   }
}
default:
RETURN_LONG(1);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2008-06-02 Thread Matt Wilmas
mattwil Mon Jun  2 11:20:59 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  MFH: Initialize with length instead of 0
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.33r2=1.308.2.21.2.37.2.34diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.33 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.34
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.33   Mon Jun  2 10:27:55 2008
+++ php-src/ext/standard/array.cMon Jun  2 11:20:59 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.33 2008/06/02 10:27:55 tony2001 Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.34 2008/06/02 11:20:59 mattwil Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -2111,7 +2111,7 @@
/* Don't create the array of removed elements if it's not going
 * to be used; e.g. only removing and/or replacing elements */
if (return_value_used) {
-   int size = 0;
+   int size = length;
 
/* Clamp the offset.. */
if (offset  num_in) {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c string.c var_unserializer.re ZendEngine2 zend_API.c zend_API.h zend_builtin_functions.c zend_object_handlers.c

2008-06-02 Thread Antony Dovgal

Please do not forget to run Valgrind when you commit patches like this (i.e. 
affecting the basics of the engine).
If you're a Windows user, you can either wait for gcov.php.net reports or ask 
me about it (I do valgrind runs every day anyway).

On 27.05.2008 14:29, Matt Wilmas wrote:

mattwil Tue May 27 10:29:34 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/ZendEngine2	zend_API.c zend_API.h zend_builtin_functions.c 
	zend_object_handlers.c 
/php-src/ext/standard	array.c string.c var_unserializer.re 
  Log:

  MFH: Add array_init_size() and use it where array size is known at 
initialization




--
Wbr, 
Antony Dovgal


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2008-06-02 Thread Antony Dovgal
tony2001Mon Jun  2 10:27:55 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  fix uninitialized variable
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.32r2=1.308.2.21.2.37.2.33diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.32 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.33
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.32   Fri May 30 10:55:14 2008
+++ php-src/ext/standard/array.cMon Jun  2 10:27:55 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.32 2008/05/30 10:55:14 mattwil Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.33 2008/06/02 10:27:55 tony2001 Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -2111,7 +2111,7 @@
/* Don't create the array of removed elements if it's not going
 * to be used; e.g. only removing and/or replacing elements */
if (return_value_used) {
-   int size;
+   int size = 0;
 
/* Clamp the offset.. */
if (offset  num_in) {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2008-05-30 Thread Matt Wilmas
mattwil Fri May 30 10:55:15 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  MFH: Only check args once in php_array_diff_key/intersect_key, not on each 
iteration. This also makes sure ALL args are checked (pre-5.2.5 behavior)
  - Also, use new hash_quick_del function where possible
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.31r2=1.308.2.21.2.37.2.32diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.31 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.32
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.31   Tue May 27 10:29:33 2008
+++ php-src/ext/standard/array.cFri May 30 10:55:14 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.31 2008/05/27 10:29:33 mattwil Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.32 2008/05/30 10:55:14 mattwil Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -2754,7 +2754,7 @@
if (Z_ARRVAL_P(return_value) == 
EG(symbol_table)) {
zend_delete_global_variable(p-arKey, 
p-nKeyLength - 1 TSRMLS_CC);
} else {
-   zend_hash_del(Z_ARRVAL_P(return_value), 
p-arKey, p-nKeyLength);
+   
zend_hash_quick_del(Z_ARRVAL_P(return_value), p-arKey, p-nKeyLength, p-h);
}
}
}
@@ -2851,10 +2851,12 @@
}
}
 
-   if (Z_TYPE_PP(args[0]) != IS_ARRAY) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Argument #1 is not 
an array);
-   RETVAL_NULL();
-   goto out;
+   for (i = 0; i  argc; i++) {
+   if (Z_TYPE_PP(args[i]) != IS_ARRAY) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Argument 
#%d is not an array, i + 1);
+   RETVAL_NULL();
+   goto out;
+   }
}
 
array_init(return_value);
@@ -2863,12 +2865,7 @@
if (p-nKeyLength == 0) {
ok = 1;
for (i = 1; i  argc; i++) {
-   if (Z_TYPE_PP(args[i]) != IS_ARRAY) {
-   php_error_docref(NULL TSRMLS_CC, 
E_WARNING, Argument #%d is not an array, i + 1);
-   zval_dtor(return_value);
-   RETVAL_NULL();
-   goto out;
-   } else if 
(zend_hash_index_find(Z_ARRVAL_PP(args[i]), p-h, (void**)data) == FAILURE ||
+   if (zend_hash_index_find(Z_ARRVAL_PP(args[i]), 
p-h, (void**)data) == FAILURE ||
(intersect_data_compare_func 

intersect_data_compare_func((zval**)p-pData, data TSRMLS_CC) != 0)
) {
@@ -2883,12 +2880,7 @@
} else {
ok = 1;
for (i = 1; i  argc; i++) {
-   if (Z_TYPE_PP(args[i]) != IS_ARRAY) {
-   php_error_docref(NULL TSRMLS_CC, 
E_WARNING, Argument #%d is not an array, i + 1);
-   zval_dtor(return_value);
-   RETVAL_NULL();
-   goto out;
-   } else if 
(zend_hash_quick_find(Z_ARRVAL_PP(args[i]), p-arKey, p-nKeyLength, p-h, 
(void**)data) == FAILURE ||
+   if (zend_hash_quick_find(Z_ARRVAL_PP(args[i]), 
p-arKey, p-nKeyLength, p-h, (void**)data) == FAILURE ||
(intersect_data_compare_func 

intersect_data_compare_func((zval**)p-pData, data TSRMLS_CC) != 0)
) {
@@ -3118,7 +3110,7 @@
if (p-nKeyLength == 0) {

zend_hash_index_del(Z_ARRVAL_P(return_value), p-h);
} else {
-   
zend_hash_del(Z_ARRVAL_P(return_value), p-arKey, p-nKeyLength);
+   
zend_hash_quick_del(Z_ARRVAL_P(return_value), p-arKey, p-nKeyLength, p-h);
}
}
}
@@ -3134,7 +3126,7 @@
if (p-nKeyLength == 0) {

zend_hash_index_del(Z_ARRVAL_P(return_value), p-h);
} else {
-   

[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c /ext/standard/tests/array array_slice_variation6.phpt

2008-05-18 Thread Felipe Pena
felipe  Sun May 18 15:42:09 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
/php-src/ext/standard/tests/array   array_slice_variation6.phpt 
  Log:
  - Making compatible with 64bit plataform
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.29r2=1.308.2.21.2.37.2.30diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.29 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.30
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.29   Sun May  4 11:26:50 2008
+++ php-src/ext/standard/array.cSun May 18 15:42:08 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.29 2008/05/04 11:26:50 tony2001 Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.30 2008/05/18 15:42:08 felipe Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -2163,7 +2163,7 @@
/* ..and the length */
if (length  0) {
length = num_in - offset + length;
-   } else if (((unsigned) offset + (unsigned) length)  (unsigned) num_in) 
{
+   } else if (((unsigned long) offset + (unsigned long) length)  
(unsigned) num_in) {
length = num_in - offset;
}
 
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_slice_variation6.phpt?r1=1.1.4.3r2=1.1.4.4diff_format=u
Index: php-src/ext/standard/tests/array/array_slice_variation6.phpt
diff -u php-src/ext/standard/tests/array/array_slice_variation6.phpt:1.1.4.3 
php-src/ext/standard/tests/array/array_slice_variation6.phpt:1.1.4.4
--- php-src/ext/standard/tests/array/array_slice_variation6.phpt:1.1.4.3
Mon Apr 14 23:17:30 2008
+++ php-src/ext/standard/tests/array/array_slice_variation6.phptSun May 
18 15:42:09 2008
@@ -133,10 +133,18 @@
 }
 
 -- $length is maximum integer value --
-array(0) {
+array(4) {
+  [0]=
+  string(3) two
+  [1]=
+  string(5) three
+  [2]=
+  string(4) nine
+  [ten]=
+  int(10)
 }
 
 -- $length is minimum integer value --
 array(0) {
 }
-Done
\ No newline at end of file
+Done



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2008-05-04 Thread Antony Dovgal
tony2001Sun May  4 11:26:51 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  fix compile warnings
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.28r2=1.308.2.21.2.37.2.29diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.28 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.29
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.28   Tue Apr 29 08:15:20 2008
+++ php-src/ext/standard/array.cSun May  4 11:26:50 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.28 2008/04/29 08:15:20 dmitry Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.29 2008/05/04 11:26:50 tony2001 Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -1641,7 +1641,7 @@
goto err;
}
for (; *low = *high; (*low) -= (unsigned int)lstep) {
-   add_next_index_stringl(return_value, low, 1, 1);
+   add_next_index_stringl(return_value, (const 
char *)low, 1, 1);
if (((signed int)*low - lstep)  0) {
break;
}
@@ -1652,13 +1652,13 @@
goto err;
}
for (; *low = *high; (*low) += (unsigned int)lstep) {
-   add_next_index_stringl(return_value, low, 1, 1);
+   add_next_index_stringl(return_value, (const 
char *)low, 1, 1);
if (((signed int)*low + lstep)  255) {
break;
}
}
} else {
-   add_next_index_stringl(return_value, low, 1, 1);
+   add_next_index_stringl(return_value, (const char *)low, 
1, 1);
}
 
} else if (Z_TYPE_P(zlow) == IS_DOUBLE || Z_TYPE_P(zhigh) == IS_DOUBLE 
|| is_step_double) {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c /ext/standard/tests/array bug42177.phpt

2008-03-12 Thread Felipe Pena
felipe  Wed Mar 12 19:18:42 2008 UTC

  Added files: (Branch: PHP_5_3)
/php-src/ext/standard/tests/array   bug42177.phpt 

  Modified files:  
/php-src/ext/standard   array.c 
  Log:
  MFB: Fixed bug #42177 (Warning array_merge_recursive(): recursion detected 
comes again...)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.26r2=1.308.2.21.2.37.2.27diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.26 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.27
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.26   Fri Feb 22 13:28:40 2008
+++ php-src/ext/standard/array.cWed Mar 12 19:18:42 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.26 2008/02/22 13:28:40 felipe Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.27 2008/03/12 19:18:42 felipe Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -2210,7 +2210,7 @@
if (recursive  zend_hash_find(dest, 
string_key, string_key_len, (void **)dest_entry) == SUCCESS) {
HashTable *thash = HASH_OF(*dest_entry);
 
-   if ((thash  thash-nApplyCount  1) 
|| (*src_entry == *dest_entry  (Z_REFCOUNT_PP(dest_entry) % 2))) {
+   if ((thash  thash-nApplyCount  1) 
|| (*src_entry == *dest_entry  Z_ISREF_PP(dest_entry)  
(Z_REFCOUNT_PP(dest_entry) % 2))) {
php_error_docref(NULL 
TSRMLS_CC, E_WARNING, recursion detected);
return 0;
}

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/bug42177.phpt?view=markuprev=1.1
Index: php-src/ext/standard/tests/array/bug42177.phpt
+++ php-src/ext/standard/tests/array/bug42177.phpt



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2008-02-22 Thread Felipe Pena
felipe  Fri Feb 22 13:28:40 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  Fixed Bug #44212 (array_diff_assoc not reporting missing arguments)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.25r2=1.308.2.21.2.37.2.26diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.25 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.26
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.25   Fri Feb 15 09:33:09 2008
+++ php-src/ext/standard/array.cFri Feb 22 13:28:40 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.25 2008/02/15 09:33:09 tony2001 Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.26 2008/02/22 13:28:40 felipe Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -3211,12 +3211,20 @@
/* Get the argument count */
argc = ZEND_NUM_ARGS();
if (data_compare_type == DIFF_COMP_DATA_USER) {
-   if (argc  3 || zend_parse_parameters(ZEND_NUM_ARGS() 
TSRMLS_CC, +f, args, argc, BG(user_compare_fci), 
BG(user_compare_fci_cache)) == FAILURE) {
+   if (argc  3) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, at least 3 
parameters are required, %d given, ZEND_NUM_ARGS());
+   return;
+   }
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, +f, 
args, argc, BG(user_compare_fci), BG(user_compare_fci_cache)) == FAILURE) {
return;
}
diff_data_compare_func = zval_user_compare;
} else {
-   if (argc  2 || zend_parse_parameters(ZEND_NUM_ARGS() 
TSRMLS_CC, +, args, argc) == FAILURE) {
+   if (argc  2) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, at least 2 
parameters are required, %d given, ZEND_NUM_ARGS());
+   return;
+   }
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, +, 
args, argc) == FAILURE) {
return;
}
if (data_compare_type == DIFF_COMP_DATA_INTERNAL) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2008-02-15 Thread Antony Dovgal
tony2001Fri Feb 15 09:33:09 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  MFH: recursion protection in count()
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.24r2=1.308.2.21.2.37.2.25diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.24 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.25
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.24   Thu Feb 14 14:08:22 2008
+++ php-src/ext/standard/array.cFri Feb 15 09:33:09 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.24 2008/02/14 14:08:22 felipe Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.25 2008/02/15 09:33:09 tony2001 Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -275,6 +275,11 @@
zval **element;
 
if (Z_TYPE_P(array) == IS_ARRAY) {
+   if (Z_ARRVAL_P(array)-nApplyCount  1) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, recursion 
detected);
+   return 0;
+   }
+
cnt = zend_hash_num_elements(Z_ARRVAL_P(array));
if (mode == COUNT_RECURSIVE) {
HashPosition pos;
@@ -283,7 +288,9 @@

zend_hash_get_current_data_ex(Z_ARRVAL_P(array), (void **) element, pos) == 
SUCCESS;
zend_hash_move_forward_ex(Z_ARRVAL_P(array), 
pos)
) {
+   Z_ARRVAL_P(array)-nApplyCount++;
cnt += php_count_recursive(*element, 
COUNT_RECURSIVE TSRMLS_CC);
+   Z_ARRVAL_P(array)-nApplyCount--;
}
}
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2008-02-14 Thread Dmitry Stogov
dmitry  Thu Feb 14 08:46:25 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  Fixed memory leak
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.22r2=1.308.2.21.2.37.2.23diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.22 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.23
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.22   Tue Feb 12 01:31:12 2008
+++ php-src/ext/standard/array.cThu Feb 14 08:46:25 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.22 2008/02/12 01:31:12 felipe Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.23 2008/02/14 08:46:25 dmitry Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -1911,6 +1911,7 @@
Z_ADDREF_P(new_var);
 
if (zend_hash_next_index_insert(Z_ARRVAL_P(stack), new_var, 
sizeof(zval *), NULL) == FAILURE) {
+   Z_DELREF_P(new_var);
php_error_docref(NULL TSRMLS_CC, E_WARNING, Cannot add 
element to the array as the next element is already occupied);
efree(args);
RETURN_FALSE;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2008-02-14 Thread Felipe Pena
felipe  Thu Feb 14 14:08:22 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  MFB: Fixed Bug #42838 (Wrong results in array_diff_uassoc)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.23r2=1.308.2.21.2.37.2.24diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.23 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.24
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.23   Thu Feb 14 08:46:25 2008
+++ php-src/ext/standard/array.cThu Feb 14 14:08:22 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.23 2008/02/14 08:46:25 dmitry Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.24 2008/02/14 14:08:22 felipe Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -3442,13 +3442,14 @@
}
c = 1;
for (i = 1; i  arr_argc; i++) {
+   Bucket **ptr = ptrs[i];
if (behavior == DIFF_NORMAL) {
-   while (*ptrs[i]  (0  (c = 
diff_data_compare_func(ptrs[0], ptrs[i] TSRMLS_CC {
-   ptrs[i]++;
+   while (*ptr  (0  (c = 
diff_data_compare_func(ptrs[0], ptr TSRMLS_CC {
+   ptr++;
}
} else if (behavior  DIFF_ASSOC) { /* triggered also 
when DIFF_KEY */
-   while (*ptrs[i]  (0  (c = 
diff_key_compare_func(ptrs[0], ptrs[i] TSRMLS_CC {
-   ptrs[i]++;
+   while (*ptr  (0 != (c = 
diff_key_compare_func(ptrs[0], ptr TSRMLS_CC {
+   ptr++;
}
}
if (!c) {
@@ -3460,12 +3461,12 @@
} else if (behavior == DIFF_ASSOC) {  /* only 
when DIFF_ASSOC */
/* In this branch is execute only when 
DIFF_ASSOC. If behavior == DIFF_KEY
 * data comparison is not needed - 
skipped. */
-   if (*ptrs[i]) {
+   if (*ptr) {
if (data_compare_type == 
DIFF_COMP_DATA_USER) {
BG(user_compare_fci) = 
*fci_data;

BG(user_compare_fci_cache) = *fci_data_cache;
}
-   if 
(diff_data_compare_func(ptrs[0], ptrs[i] TSRMLS_CC) != 0) {
+   if 
(diff_data_compare_func(ptrs[0], ptr TSRMLS_CC) != 0) {
/* the data is not the 
same */
c = -1;
if (key_compare_type == 
DIFF_COMP_KEY_USER) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2008-02-12 Thread Felipe Pena
Em Ter, 2008-02-12 às 18:50 +0100, Hannes Magnusson escreveu:
 On Feb 12, 2008 2:31 AM, Felipe Pena [EMAIL PROTECTED] wrote:
  felipe  Tue Feb 12 01:31:12 2008 UTC
 
Modified files:  (Branch: PHP_5_3)
  /php-src/ext/standard   array.c
Log:
array_slice() - Fixed behavior when NULL is given in third parameter (BC)
 
 This is starting to be pretty damn funny.
 AFAICS this is the 4th attempt (in 3weeks) to fix the exact same bug,
 doesn't anyone have a test case specifcally for this bug?
 I know there are bunch of array_splice_*.phpt tests, but this bug
 really deserves its own test case.
 
 -Hannes
 

Yesterday I added a test case for this bug.

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2008-02-12 Thread Hannes Magnusson
On Feb 12, 2008 2:31 AM, Felipe Pena [EMAIL PROTECTED] wrote:
 felipe  Tue Feb 12 01:31:12 2008 UTC

   Modified files:  (Branch: PHP_5_3)
 /php-src/ext/standard   array.c
   Log:
   array_slice() - Fixed behavior when NULL is given in third parameter (BC)

This is starting to be pretty damn funny.
AFAICS this is the 4th attempt (in 3weeks) to fix the exact same bug,
doesn't anyone have a test case specifcally for this bug?
I know there are bunch of array_splice_*.phpt tests, but this bug
really deserves its own test case.

-Hannes

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2008-02-11 Thread Antony Dovgal
tony2001Mon Feb 11 13:34:42 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  MFH
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.20r2=1.308.2.21.2.37.2.21diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.20 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.21
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.20   Tue Feb  5 15:58:27 2008
+++ php-src/ext/standard/array.cMon Feb 11 13:34:41 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.20 2008/02/05 15:58:27 iliaa Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.21 2008/02/11 13:34:41 tony2001 Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -2109,7 +2109,7 @@
zval *input,/* Input array */
**entry;/* An array entry */
long offset,/* Offset to get elements from */
-length = NULL; /* How many elements to get */
+length = 0;/* How many elements to get */
zend_bool preserve_keys = 0; /* Whether to preserve keys while copying 
to the new array or not */
int  num_in,/* Number of elements in the 
input array */
 pos;   /* Current position in the 
array */
@@ -2126,7 +2126,7 @@
num_in = zend_hash_num_elements(Z_ARRVAL_P(input));
 
/* We want all entries from offset to the end if length is not passed 
or is null */
-   if (length == NULL) {
+   if (length == 0) {
length = num_in;
}
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2008-02-11 Thread Felipe Pena
felipe  Tue Feb 12 01:31:12 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  array_slice() - Fixed behavior when NULL is given in third parameter (BC)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.21r2=1.308.2.21.2.37.2.22diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.21 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.22
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.21   Mon Feb 11 13:34:41 2008
+++ php-src/ext/standard/array.cTue Feb 12 01:31:12 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.21 2008/02/11 13:34:41 tony2001 Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.22 2008/02/12 01:31:12 felipe Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -2107,9 +2107,10 @@
 PHP_FUNCTION(array_slice)
 {
zval *input,/* Input array */
+   **z_length, /* How many elements to get */ 
**entry;/* An array entry */
long offset,/* Offset to get elements from */
-length = 0;/* How many elements to get */
+length = 0;
zend_bool preserve_keys = 0; /* Whether to preserve keys while copying 
to the new array or not */
int  num_in,/* Number of elements in the 
input array */
 pos;   /* Current position in the 
array */
@@ -2118,7 +2119,7 @@
ulong num_key;
HashPosition hpos;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, al|lb, input, 
offset, length, preserve_keys) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, al|Zb, input, 
offset, z_length, preserve_keys) == FAILURE) {
return;
}
 
@@ -2126,8 +2127,11 @@
num_in = zend_hash_num_elements(Z_ARRVAL_P(input));
 
/* We want all entries from offset to the end if length is not passed 
or is null */
-   if (length == 0) {
+   if (ZEND_NUM_ARGS()  3 || Z_TYPE_PP(z_length) == IS_NULL) {
length = num_in;
+   } else {
+   convert_to_long_ex(z_length);
+   length = Z_LVAL_PP(z_length);
}
 
/* Initialize returned array */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2008-01-28 Thread Antony Dovgal
tony2001Tue Jan 29 00:39:46 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  MFH: fix #43596 (array_slice(): $length arg ignored when it is 0)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.17r2=1.308.2.21.2.37.2.18diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.17 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.18
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.17   Fri Jan 25 15:52:48 2008
+++ php-src/ext/standard/array.cTue Jan 29 00:39:46 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.17 2008/01/25 15:52:48 rrichards Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.18 2008/01/29 00:39:46 tony2001 Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -2113,12 +2113,13 @@
zend_bool preserve_keys = 0; /* Whether to preserve keys while copying 
to the new array or not */
int  num_in,/* Number of elements in the 
input array */
 pos;   /* Current position in the 
array */
+   zval*z_length;
char *string_key;
uint string_key_len;
ulong num_key;
HashPosition hpos;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, al|lb, input, 
offset, length, preserve_keys) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, al|z/b, input, 
offset, z_length, preserve_keys) == FAILURE) {
return;
}
 
@@ -2126,7 +2127,10 @@
num_in = zend_hash_num_elements(Z_ARRVAL_P(input));
 
/* We want all entries from offset to the end if length is not passed 
or is null */
-   if (length == 0) {
+   if (ZEND_NUM_ARGS() = 3  Z_TYPE_P(z_length) != IS_NULL) {
+   convert_to_long(z_length);
+   length = Z_LVAL_P(z_length);
+   } else {
length = num_in;
}
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2008-01-25 Thread Antony Dovgal
tony2001Fri Jan 25 13:42:36 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  MFH: endless loop (and stack overflow) protection in compact()
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.15r2=1.308.2.21.2.37.2.16diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.15 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.16
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.15   Wed Jan 23 12:09:52 2008
+++ php-src/ext/standard/array.cFri Jan 25 13:42:36 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.15 2008/01/23 12:09:52 tony2001 Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.16 2008/01/25 13:42:36 tony2001 Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -1450,6 +1450,13 @@
else if (Z_TYPE_P(entry) == IS_ARRAY) {
HashPosition pos;
 
+   if ((Z_ARRVAL_P(entry)-nApplyCount  1)) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, recursion 
detected);
+   return;
+   }
+
+   Z_ARRVAL_P(entry)-nApplyCount++;
+
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(entry), pos);
while (zend_hash_get_current_data_ex(Z_ARRVAL_P(entry), 
(void**)value_ptr, pos) == SUCCESS) {
value = *value_ptr;
@@ -1457,6 +1464,7 @@
php_compact_var(eg_active_symbol_table, return_value, 
value);
zend_hash_move_forward_ex(Z_ARRVAL_P(entry), pos);
}
+   Z_ARRVAL_P(entry)-nApplyCount--;
}
 }
 /* }}} */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2008-01-25 Thread Rob Richards
rrichards   Fri Jan 25 15:52:48 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  MFH: fix zts build
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.16r2=1.308.2.21.2.37.2.17diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.16 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.17
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.16   Fri Jan 25 13:42:36 2008
+++ php-src/ext/standard/array.cFri Jan 25 15:52:48 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.16 2008/01/25 13:42:36 tony2001 Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.17 2008/01/25 15:52:48 rrichards Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -1432,7 +1432,7 @@
 }
 /* }}} */
 
-static void php_compact_var(HashTable *eg_active_symbol_table, zval 
*return_value, zval *entry) /* {{{ */
+static void php_compact_var(HashTable *eg_active_symbol_table, zval 
*return_value, zval *entry TSRMLS_DC) /* {{{ */
 {
zval **value_ptr, *value, *data;
 
@@ -1461,7 +1461,7 @@
while (zend_hash_get_current_data_ex(Z_ARRVAL_P(entry), 
(void**)value_ptr, pos) == SUCCESS) {
value = *value_ptr;
 
-   php_compact_var(eg_active_symbol_table, return_value, 
value);
+   php_compact_var(eg_active_symbol_table, return_value, 
value TSRMLS_CC);
zend_hash_move_forward_ex(Z_ARRVAL_P(entry), pos);
}
Z_ARRVAL_P(entry)-nApplyCount--;
@@ -1489,7 +1489,7 @@
array_init(return_value);
 
for (i=0; iZEND_NUM_ARGS(); i++) {
-   php_compact_var(EG(active_symbol_table), return_value, 
*args[i]);
+   php_compact_var(EG(active_symbol_table), return_value, *args[i] 
TSRMLS_CC);
}
 
efree(args);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c /ext/standard/tests/array bug42850.phpt

2008-01-14 Thread Brian Shire
shire   Mon Jan 14 22:09:52 2008 UTC

  Added files: (Branch: PHP_5_3)
/php-src/ext/standard/tests/array   bug42850.phpt 

  Modified files:  
/php-src/ext/standard   array.c 
  Log:
  MFH: Fix bug #42850 array_walk_recursive() leaves references, refix bug #34982
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.13r2=1.308.2.21.2.37.2.14diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.13 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.14
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.13   Mon Dec 31 07:17:14 2007
+++ php-src/ext/standard/array.cMon Jan 14 22:09:52 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.13 2007/12/31 07:17:14 sebastian Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.14 2008/01/14 22:09:52 shire Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -1038,7 +1038,7 @@
zend_fcall_info orig_array_walk_fci;
zend_fcall_info_cache orig_array_walk_fci_cache;
 
-   SEPARATE_ZVAL_TO_MAKE_IS_REF(args[0]);
+   SEPARATE_ZVAL_IF_NOT_REF(args[0]);
thash = HASH_OF(*(args[0]));
if (thash-nApplyCount  1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, 
recursion detected);

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/bug42850.phpt?view=markuprev=1.1
Index: php-src/ext/standard/tests/array/bug42850.phpt
+++ php-src/ext/standard/tests/array/bug42850.phpt
--TEST--
Bug #42850 array_walk_recursive() leaves references, #34982 
array_walk_recursive() modifies elements outside function scope 
--FILE--
?php

// Bug #42850
$data = array ('key1' = 'val1', array('key2' = 'val2'));
function apply_dumb($item, $key) {}; 
var_dump($data);
array_walk_recursive($data, 'apply_dumb');
$data2 = $data;
$data2[0] = 'altered';
var_dump($data);
var_dump($data2);

// Bug #34982
function myfunc($data) {
array_walk_recursive($data, 'apply_changed');
}
function apply_changed($input, $key) {
$input = 'changed';
}
myfunc($data);
var_dump($data);

--EXPECT--
array(2) {
  [key1]=
  string(4) val1
  [0]=
  array(1) {
[key2]=
string(4) val2
  }
}
array(2) {
  [key1]=
  string(4) val1
  [0]=
  array(1) {
[key2]=
string(4) val2
  }
}
array(2) {
  [key1]=
  string(4) val1
  [0]=
  string(7) altered
}
array(2) {
  [key1]=
  string(4) val1
  [0]=
  array(1) {
[key2]=
string(4) val2
  }
}
--UEXPECT--
array(2) {
  [ukey1]=
  unicode(4) val1
  [0]=
  array(1) {
[ukey2]=
unicode(4) val2
  }
}
array(2) {
  [ukey1]=
  unicode(4) val1
  [0]=
  array(1) {
[ukey2]=
unicode(4) val2
  }
}
array(2) {
  [ukey1]=
  unicode(4) val1
  [0]=
  unicode(7) altered
}
array(2) {
  [ukey1]=
  unicode(4) val1
  [0]=
  array(1) {
[ukey2]=
unicode(4) val2
  }
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c /ext/standard/tests/array array_slice.phpt bug43541.phpt

2007-12-11 Thread Jani Taskinen
janiTue Dec 11 09:47:21 2007 UTC

  Added files: (Branch: PHP_5_3)
/php-src/ext/standard/tests/array   bug43541.phpt 

  Modified files:  
/php-src/ext/standard   array.c 
/php-src/ext/standard/tests/array   array_slice.phpt 
  Log:
  MFH: - Fixed bug #43541
  http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.11r2=1.308.2.21.2.37.2.12diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.11 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.12
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.11   Wed Dec  5 19:55:31 2007
+++ php-src/ext/standard/array.cTue Dec 11 09:47:20 2007
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.11 2007/12/05 19:55:31 iliaa Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.12 2007/12/11 09:47:20 jani Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -2101,17 +2101,16 @@
zval *input,/* Input array */
**entry;/* An array entry */
long offset,/* Offset to get elements from */
-length;/* How many elements to get */
+length = 0;/* How many elements to get */
zend_bool preserve_keys = 0; /* Whether to preserve keys while copying 
to the new array or not */
int  num_in,/* Number of elements in the 
input array */
 pos;   /* Current position in the 
array */
-   zval*length_param;
char *string_key;
uint string_key_len;
ulong num_key;
HashPosition hpos;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, al|zb, input, 
offset, length_param, preserve_keys) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, al|lb, input, 
offset, length, preserve_keys) == FAILURE) {
return;
}
 
@@ -2119,12 +2118,10 @@
num_in = zend_hash_num_elements(Z_ARRVAL_P(input));
 
/* We want all entries from offset to the end if length is not passed 
or is null */
-   if (ZEND_NUM_ARGS() = 3  Z_TYPE_P(length_param) != IS_NULL) {
-   length = Z_LVAL_P(length_param);
-   } else {
+   if (length == 0) {
length = num_in;
}
-   
+
/* Initialize returned array */
array_init(return_value);
 
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_slice.phpt?r1=1.2.2.2r2=1.2.2.3diff_format=u
Index: php-src/ext/standard/tests/array/array_slice.phpt
diff -u php-src/ext/standard/tests/array/array_slice.phpt:1.2.2.2 
php-src/ext/standard/tests/array/array_slice.phpt:1.2.2.3
--- php-src/ext/standard/tests/array/array_slice.phpt:1.2.2.2   Fri Nov  2 
19:41:11 2007
+++ php-src/ext/standard/tests/array/array_slice.phpt   Tue Dec 11 09:47:20 2007
@@ -1,7 +1,6 @@
 --TEST--
 Testing array_slice() function
 --FILE--
-
 ?php
 
 $var_array = array(
@@ -89,27 +88,26 @@
   var_dump (array_slice($var_array[2], -3, -2, false) );
 
 ?
-
 --EXPECTF--
 *** Output for Zero Argument ***
 
-Warning: array_slice() expects at least %d parameters, %d given in %s on line 
%d
+Warning: array_slice() expects at least 2 parameters, 0 given in %s on line %d
 
 *** Output for Single array Argument ***
 
-Warning: array_slice() expects at least %d parameters, %d given in %s on line 
%d
+Warning: array_slice() expects at least 2 parameters, 1 given in %s on line %d
 
 *** Output for invalid number of Arguments ***
 
-Warning: array_slice() expects at most %d parameters, %d given in %s on line %d
+Warning: array_slice() expects at most 4 parameters, 5 given in %s on line %d
 
 *** Output for scalar Argument ***
 
-Warning: array_slice() expects parameter %d to be array, integer given in %s 
on line %d
+Warning: array_slice() expects parameter 1 to be array, integer given in %s on 
line %d
 
 *** Output for string Argument ***
 
-Warning: array_slice() expects parameter %d to be array, string given in %s on 
line %d%d
+Warning: array_slice() expects parameter 1 to be array, string given in %s on 
line %d
 
 *** Iteration 1 ***
 
@@ -218,7 +216,23 @@
   [2]=
   int(4)
 }
-array(0) {
+array(8) {
+  [0]=
+  int(2)
+  [1]=
+  int(3)
+  [2]=
+  int(4)
+  [3]=
+  int(5)
+  [4]=
+  int(6)
+  [5]=
+  int(7)
+  [6]=
+  int(8)
+  [7]=
+  int(9)
 }
 array(5) {
   [0]=
@@ -240,7 +254,25 @@
   [2]=
   int(3)
 }
-array(0) {
+array(9) {
+  [0]=
+  int(1)
+  [1]=
+  int(2)
+  [2]=
+  int(3)
+  [3]=
+  int(4)
+  [4]=
+  int(5)
+  [5]=
+  int(6)
+  [6]=
+  int(7)
+  [7]=
+  int(8)
+  [8]=
+  int(9)
 }
 array(6) {
   [0]=
@@ -262,7 +294,11 @@
   [1]=
   int(9)
 }
-array(0) {
+array(2) {
+  [0]=
+  int(8)
+  [1]=
+  int(9)
 }
 array(0) {
 }
@@ -276,7 +312,23 @@
   [3]=
   int(4)
 }
-array(0) {
+array(8) {
+  [1]=
+  

Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c /ext/standard/tests/array array_slice.phpt bug43541.phpt

2007-12-11 Thread Steph Fox

Hi Jani,

Thanks!

I split the existing array_slice.phpt into five (see bug report) because the 
output's unusable, but they'll need updating now because they were aimed at 
the 'no change' version. I'll do it later in the week.


- Steph

- Original Message - 
From: Jani Taskinen [EMAIL PROTECTED]

To: php-cvs@lists.php.net
Sent: Tuesday, December 11, 2007 9:47 AM
Subject: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c 
/ext/standard/tests/array array_slice.phpt bug43541.phpt




jani Tue Dec 11 09:47:21 2007 UTC

 Added files: (Branch: PHP_5_3)
   /php-src/ext/standard/tests/array bug43541.phpt

 Modified files:
   /php-src/ext/standard array.c
   /php-src/ext/standard/tests/array array_slice.phpt
 Log:
 MFH: - Fixed bug #43541








--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php 


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c /ext/standard/tests/array bug43495.phpt

2007-12-05 Thread Ilia Alshanetsky
iliaa   Wed Dec  5 19:55:32 2007 UTC

  Added files: (Branch: PHP_5_3)
/php-src/ext/standard/tests/array   bug43495.phpt 

  Modified files:  
/php-src/ext/standard   array.c 
  Log:
  Fixed bug #43495 (array_merge_recursive() crashes with recursive arrays)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.10r2=1.308.2.21.2.37.2.11diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.10 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.11
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.10   Mon Dec  3 14:13:27 2007
+++ php-src/ext/standard/array.cWed Dec  5 19:55:31 2007
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.10 2007/12/03 14:13:27 iliaa Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.11 2007/12/05 19:55:31 iliaa Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -2191,7 +2191,9 @@
switch (zend_hash_get_current_key_ex(src, string_key, 
string_key_len, num_key, 0, pos)) {
case HASH_KEY_IS_STRING:
if (recursive  zend_hash_find(dest, 
string_key, string_key_len, (void **)dest_entry) == SUCCESS) {
-   if (*src_entry == *dest_entry  
(Z_REFCOUNT_PP(dest_entry) % 2)) {
+   HashTable *thash = HASH_OF(*dest_entry);
+
+   if ((thash  thash-nApplyCount  1) 
|| (*src_entry == *dest_entry  (Z_REFCOUNT_PP(dest_entry) % 2))) {
php_error_docref(NULL 
TSRMLS_CC, E_WARNING, recursion detected);
return 0;
}
@@ -2200,9 +2202,18 @@
 
convert_to_array_ex(dest_entry);
convert_to_array_ex(src_entry);
+   if (thash) {
+   thash-nApplyCount++;
+   }
if 
(!php_array_merge(Z_ARRVAL_PP(dest_entry), Z_ARRVAL_PP(src_entry), recursive 
TSRMLS_CC)) {
+   if (thash) {
+   thash-nApplyCount--;
+   }
return 0;
}
+   if (thash) {
+   thash-nApplyCount--;
+   }
} else {
Z_ADDREF_PP(src_entry);
zend_hash_update(dest, string_key, 
string_key_len, src_entry, sizeof(zval *), NULL);

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/bug43495.phpt?view=markuprev=1.1
Index: php-src/ext/standard/tests/array/bug43495.phpt
+++ php-src/ext/standard/tests/array/bug43495.phpt

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2007-12-03 Thread Ilia Alshanetsky
iliaa   Mon Dec  3 14:13:27 2007 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  
  MFB:  Fixed bug #43482 (array_pad() does not warn on very small pad
  numbers).
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.9r2=1.308.2.21.2.37.2.10diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.9 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.10
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.9Sun Nov 25 15:56:07 2007
+++ php-src/ext/standard/array.cMon Dec  3 14:13:27 2007
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.9 2007/11/25 15:56:07 iliaa Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.10 2007/12/03 14:13:27 iliaa Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -2473,6 +2473,11 @@
/* Do some initial calculations */
input_size = zend_hash_num_elements(Z_ARRVAL_P(input));
pad_size_abs = abs(pad_size);
+   if (pad_size_abs  0) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, You may only pad 
up to 1048576 elements at a time);
+   zval_dtor(return_value);
+   RETURN_FALSE;
+   }
do_pad = (input_size = pad_size_abs) ? 0 : 1;
 
/* Copy the original array */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2007-11-25 Thread Ilia Alshanetsky
iliaa   Sun Nov 25 15:56:07 2007 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  Fixed bug #43386 (array_globals not reset to 0 properly on init)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.8r2=1.308.2.21.2.37.2.9diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.8 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.9
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.8Tue Nov  6 13:26:59 2007
+++ php-src/ext/standard/array.cSun Nov 25 15:56:07 2007
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.8 2007/11/06 13:26:59 jani Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.9 2007/11/25 15:56:07 iliaa Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -94,7 +94,7 @@
 */
 static void php_array_init_globals(zend_array_globals *array_globals)
 {
-   memset(array_globals, 0, sizeof(array_globals));
+   memset(array_globals, 0, sizeof(zend_array_globals));
 }
 /* }}} */
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c /ext/standard/tests/array array_intersect_assoc_error.phpt array_intersect_assoc_variation1.phpt array_intersect_assoc_variation2.phpt

2007-11-06 Thread Jani Taskinen
janiTue Nov  6 13:26:59 2007 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
/php-src/ext/standard/tests/array   array_intersect_assoc_error.phpt 
array_intersect_assoc_variation1.phpt 
array_intersect_assoc_variation2.phpt 
  Log:
  MFH: - Fixed bug #43196 (array_intersect_assoc() crashes with non-array input)
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.7r2=1.308.2.21.2.37.2.8diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.7 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.8
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.7Mon Nov  5 23:53:23 2007
+++ php-src/ext/standard/array.cTue Nov  6 13:26:59 2007
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.7 2007/11/05 23:53:23 iliaa Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.8 2007/11/06 13:26:59 jani Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -2763,13 +2763,24 @@
}
}
 
+   if (Z_TYPE_PP(args[0]) != IS_ARRAY) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Argument #1 is not 
an array);
+   RETVAL_NULL();
+   goto out;
+   }
+
array_init(return_value);
 
for (p = Z_ARRVAL_PP(args[0])-pListHead; p != NULL; p = p-pListNext) {
if (p-nKeyLength == 0) {
ok = 1;
for (i = 1; i  argc; i++) {
-   if (zend_hash_index_find(Z_ARRVAL_PP(args[i]), 
p-h, (void**)data) == FAILURE ||
+   if (Z_TYPE_PP(args[i]) != IS_ARRAY) {
+   php_error_docref(NULL TSRMLS_CC, 
E_WARNING, Argument #%d is not an array, i + 1);
+   zval_dtor(return_value);
+   RETVAL_NULL();
+   goto out;
+   } else if 
(zend_hash_index_find(Z_ARRVAL_PP(args[i]), p-h, (void**)data) == FAILURE ||
(intersect_data_compare_func 

intersect_data_compare_func((zval**)p-pData, data TSRMLS_CC) != 0)
) {
@@ -2784,7 +2795,12 @@
} else {
ok = 1;
for (i = 1; i  argc; i++) {
-   if (zend_hash_quick_find(Z_ARRVAL_PP(args[i]), 
p-arKey, p-nKeyLength, p-h, (void**)data) == FAILURE ||
+   if (Z_TYPE_PP(args[i]) != IS_ARRAY) {
+   php_error_docref(NULL TSRMLS_CC, 
E_WARNING, Argument #%d is not an array, i + 1);
+   zval_dtor(return_value);
+   RETVAL_NULL();
+   goto out;
+   } else if 
(zend_hash_quick_find(Z_ARRVAL_PP(args[i]), p-arKey, p-nKeyLength, p-h, 
(void**)data) == FAILURE ||
(intersect_data_compare_func 

intersect_data_compare_func((zval**)p-pData, data TSRMLS_CC) != 0)
) {
@@ -2798,6 +2814,7 @@
}
}
}
+out:
efree(args);
 }
 /* }}} */
@@ -3164,13 +3181,24 @@
}
}
 
+   if (Z_TYPE_PP(args[0]) != IS_ARRAY) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Argument #1 is not 
an array);
+   RETVAL_NULL();
+   goto out;
+   }
+
array_init(return_value);
 
for (p = Z_ARRVAL_PP(args[0])-pListHead; p != NULL; p = p-pListNext) {
if (p-nKeyLength == 0) {
ok = 1;
for (i = 1; i  argc; i++) {
-   if (zend_hash_index_find(Z_ARRVAL_PP(args[i]), 
p-h, (void**)data) == SUCCESS 
+   if (Z_TYPE_PP(args[i]) != IS_ARRAY) {
+   php_error_docref(NULL TSRMLS_CC, 
E_WARNING, Argument #%d is not an array, i + 1);
+   zval_dtor(return_value);
+   RETVAL_NULL();
+   goto out;
+   } else if 
(zend_hash_index_find(Z_ARRVAL_PP(args[i]), p-h, (void**)data) == SUCCESS 
(!diff_data_compare_func ||

diff_data_compare_func((zval**)p-pData, data TSRMLS_CC) == 0)
) {
@@ -3185,7 +3213,12 @@
} else {
ok = 1;
for (i = 1; i  argc; i++) 

[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2007-11-05 Thread Ilia Alshanetsky
iliaa   Mon Nov  5 23:53:23 2007 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  Fixed bug #43197 (array_intersect_assoc() does not emit warning messages for
  error inputs)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.6r2=1.308.2.21.2.37.2.7diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.6 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.7
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.6Fri Nov  2 19:40:38 2007
+++ php-src/ext/standard/array.cMon Nov  5 23:53:23 2007
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.6 2007/11/02 19:40:38 jani Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.7 2007/11/05 23:53:23 iliaa Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -2749,11 +2749,13 @@
argc = ZEND_NUM_ARGS();
if (data_compare_type == INTERSECT_COMP_DATA_USER) {
if (argc  3 || zend_parse_parameters(ZEND_NUM_ARGS() 
TSRMLS_CC, +f, args, argc, BG(user_compare_fci), 
BG(user_compare_fci_cache)) == FAILURE) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, at least 3 
parameters are required, %d given, ZEND_NUM_ARGS());
return;
}
intersect_data_compare_func = zval_user_compare;
} else {
if (argc  2 || zend_parse_parameters(ZEND_NUM_ARGS() 
TSRMLS_CC, +, args, argc) == FAILURE) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, at least 2 
parameters are required, %d given, ZEND_NUM_ARGS());
return;
}
if (data_compare_type == INTERSECT_COMP_DATA_INTERNAL) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c /ext/standard/tests/array max.phpt min.phpt /ext/standard/tests/file fgetc_basic.phpt fgetc_variation4.phpt

2007-10-31 Thread Jani Taskinen
janiWed Oct 31 13:39:26 2007 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
/php-src/ext/standard/tests/array   max.phpt min.phpt 
/php-src/ext/standard/tests/filefgetc_basic.phpt 
fgetc_variation4.phpt 
  Log:
  MFH: fix typo
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.4r2=1.308.2.21.2.37.2.5diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.4 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.5
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.4Thu Oct 18 14:33:14 2007
+++ php-src/ext/standard/array.cWed Oct 31 13:39:26 2007
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.4 2007/10/18 14:33:14 scottmac Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.5 2007/10/31 13:39:26 jani Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -964,7 +964,7 @@
zval **result;
 
if (argc=0) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Atleast one value 
should be passed);
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, At least one value 
should be passed);
RETURN_NULL();
}
set_compare_func(SORT_REGULAR TSRMLS_CC);
@@ -977,7 +977,7 @@
if (zend_hash_minmax(Z_ARRVAL_PP(arr), array_data_compare, 0, 
(void **) result TSRMLS_CC) == SUCCESS) {
RETVAL_ZVAL(*result, 1, 0);
} else {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Array must 
contain atleast one element);
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Array must 
contain at least one element);
RETURN_FALSE;
}
} else {
@@ -1014,7 +1014,7 @@
zval **result;
 
if (argc=0) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Atleast one value 
should be passed);
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, At least one value 
should be passed);
RETURN_NULL();
}
set_compare_func(SORT_REGULAR TSRMLS_CC);
@@ -1027,7 +1027,7 @@
if (zend_hash_minmax(Z_ARRVAL_PP(arr), array_data_compare, 1, 
(void **) result TSRMLS_CC) == SUCCESS) {
RETVAL_ZVAL(*result, 1, 0);
} else {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Array must 
contain atleast one element);
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Array must 
contain at least one element);
RETURN_FALSE;
}
} else {
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/max.phpt?r1=1.1.2.3r2=1.1.2.3.2.1diff_format=u
Index: php-src/ext/standard/tests/array/max.phpt
diff -u php-src/ext/standard/tests/array/max.phpt:1.1.2.3 
php-src/ext/standard/tests/array/max.phpt:1.1.2.3.2.1
--- php-src/ext/standard/tests/array/max.phpt:1.1.2.3   Mon May  7 22:30:16 2007
+++ php-src/ext/standard/tests/array/max.phpt   Wed Oct 31 13:39:26 2007
@@ -20,13 +20,13 @@
 echo Done\n;
 ?
 --EXPECTF--
-Warning: max(): Atleast one value should be passed in %s on line %d
+Warning: max(): At least one value should be passed in %s on line %d
 NULL
 
 Warning: Wrong parameter count for max() in %s on line %d
 NULL
 
-Warning: max(): Array must contain atleast one element in %s on line %d
+Warning: max(): Array must contain at least one element in %s on line %d
 bool(false)
 
 Warning: Wrong parameter count for max() in %s on line %d
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/min.phpt?r1=1.1.2.3r2=1.1.2.3.2.1diff_format=u
Index: php-src/ext/standard/tests/array/min.phpt
diff -u php-src/ext/standard/tests/array/min.phpt:1.1.2.3 
php-src/ext/standard/tests/array/min.phpt:1.1.2.3.2.1
--- php-src/ext/standard/tests/array/min.phpt:1.1.2.3   Mon May  7 22:30:16 2007
+++ php-src/ext/standard/tests/array/min.phpt   Wed Oct 31 13:39:26 2007
@@ -20,13 +20,13 @@
 echo Done\n;
 ?
 --EXPECTF--
-Warning: min(): Atleast one value should be passed in %s on line %d
+Warning: min(): At least one value should be passed in %s on line %d
 NULL
 
 Warning: Wrong parameter count for min() in %s on line %d
 NULL
 
-Warning: min(): Array must contain atleast one element in %s on line %d
+Warning: min(): Array must contain at least one element in %s on line %d
 bool(false)
 
 Warning: Wrong parameter count for min() in %s on line %d
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fgetc_basic.phpt?r1=1.1.2.1.2.1r2=1.1.2.1.2.2diff_format=u
Index: php-src/ext/standard/tests/file/fgetc_basic.phpt
diff -u php-src/ext/standard/tests/file/fgetc_basic.phpt:1.1.2.1.2.1 
php-src/ext/standard/tests/file/fgetc_basic.phpt:1.1.2.1.2.2
--- php-src/ext/standard/tests/file/fgetc_basic.phpt:1.1.2.1.2.1Thu Oct 

[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2007-10-18 Thread Scott MacVicar
scottmacThu Oct 18 14:33:14 2007 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  Fixed bug #43020 (Warning message is missing with shuffle() and more than one 
argument)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.3r2=1.308.2.21.2.37.2.4diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.3 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.4
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.3Sun Oct  7 05:22:06 2007
+++ php-src/ext/standard/array.cThu Oct 18 14:33:14 2007
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.3 2007/10/07 05:22:06 davidw Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.4 2007/10/18 14:33:14 scottmac Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -1842,7 +1842,7 @@
 {
zval *array;
 
-   if (zend_parse_parameters(1 TSRMLS_CC, a, array) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, a, array) == 
FAILURE) {
RETURN_FALSE;
}
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c

2007-10-02 Thread Antony Dovgal
tony2001Tue Oct  2 10:04:38 2007 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c 
  Log:
  MF5_2: improved recursion detection in array_walk()
  fixes #42752, though the leaks are still there
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.1r2=1.308.2.21.2.37.2.2diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.1 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.2
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.1Mon Oct  1 12:34:19 2007
+++ php-src/ext/standard/array.cTue Oct  2 10:04:38 2007
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.1 2007/10/01 12:34:19 jani Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.2 2007/10/02 10:04:38 tony2001 Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -1079,11 +1079,13 @@

SEPARATE_ZVAL_TO_MAKE_IS_REF(args[0]);
thash = HASH_OF(*(args[0]));
-   if (thash == target_hash) {
+   if (thash-nApplyCount  1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, 
recursion detected);
return 0;
}
+   thash-nApplyCount++;
php_array_walk(thash, userdata, recursive TSRMLS_CC);
+   thash-nApplyCount--;
} else {
zend_fcall_info fci;
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard array.c php_var.h

2007-10-01 Thread Jani Taskinen
janiMon Oct  1 12:34:19 2007 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   array.c php_var.h 
  Log:
  MFH: sync (adds php_prefix_varname() API function)
  http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37r2=1.308.2.21.2.37.2.1diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.1
--- php-src/ext/standard/array.c:1.308.2.21.2.37Sat Sep 22 15:38:00 2007
+++ php-src/ext/standard/array.cMon Oct  1 12:34:19 2007
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37 2007/09/22 15:38:00 iliaa Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.1 2007/10/01 12:34:19 jani Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -618,7 +618,7 @@
 /* check if comparison function is valid */
 #define PHP_ARRAY_CMP_FUNC_CHECK(func_name)\
if (!zend_is_callable(*func_name, 0, NULL)) {   \
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Invalid comparison 
function.);\
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Invalid comparison 
function); \
 BG(user_compare_fci_cache) = old_user_compare_fci_cache; \
BG(user_compare_func_name) = old_compare_func;  \
RETURN_FALSE;   \
@@ -1317,82 +1317,86 @@
 }
 /* }}} */
 
+PHPAPI int php_prefix_varname(zval *result, zval *prefix, char *var_name, int 
var_name_len, zend_bool add_underscore TSRMLS_DC) /* {{{ */
+{
+   Z_STRLEN_P(result) = Z_STRLEN_P(prefix) + (add_underscore ? 1 : 0) + 
var_name_len;
+   Z_TYPE_P(result) = IS_STRING;
+   Z_STRVAL_P(result) = emalloc(Z_STRLEN_P(result) + 1);
+   memcpy(Z_STRVAL_P(result), Z_STRVAL_P(prefix), Z_STRLEN_P(prefix));
+
+   if (add_underscore) {
+   Z_STRVAL_P(result)[Z_STRLEN_P(prefix)] = '_';
+   }
+
+   memcpy(Z_STRVAL_P(result) + Z_STRLEN_P(prefix) + (add_underscore ? 1 : 
0), var_name, var_name_len + 1);
+
+   return SUCCESS;
+}
+/* }}} */
+
 /* {{{ proto int extract(array var_array [, int extract_type [, string 
prefix]])
Imports variables into symbol table from an array */
 PHP_FUNCTION(extract)
 {
-   zval **var_array, **z_extract_type, **prefix;
+   zval *var_array, *prefix = NULL;
+   long extract_type = EXTR_OVERWRITE;
zval **entry, *data;
char *var_name;
-   smart_str final_name = {0};
ulong num_key;
uint var_name_len;
-   int var_exists, extract_type, key_type, count = 0;
+   int var_exists, key_type, count = 0;
int extract_refs = 0;
HashPosition pos;
 
-   switch (ZEND_NUM_ARGS()) {
-   case 1:
-   if (zend_get_parameters_ex(1, var_array) == FAILURE) {
-   WRONG_PARAM_COUNT;
-   }
-   extract_type = EXTR_OVERWRITE;
-   break;
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, a|lz/, 
var_array, extract_type, prefix) == FAILURE) {
+   return;
+   }
 
-   case 2:
-   if (zend_get_parameters_ex(2, var_array, 
z_extract_type) == FAILURE) {
-   WRONG_PARAM_COUNT;
-   }
-   convert_to_long_ex(z_extract_type);
-   extract_type = Z_LVAL_PP(z_extract_type);
-   extract_refs = (extract_type  EXTR_REFS);
-   extract_type = 0xff;
-   if (extract_type  EXTR_SKIP  extract_type = 
EXTR_PREFIX_IF_EXISTS) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
Prefix expected to be specified);
-   return;
-   }
-   break;
-   
-   case 3:
-   if (zend_get_parameters_ex(3, var_array, 
z_extract_type, prefix) == FAILURE) {
-   WRONG_PARAM_COUNT;
-   }
-   convert_to_long_ex(z_extract_type);
-   extract_type = Z_LVAL_PP(z_extract_type);
-   extract_refs = (extract_type  EXTR_REFS);
-   extract_type = 0xff;
-   convert_to_string_ex(prefix);
-   break;
+   extract_refs = (extract_type  EXTR_REFS);
+   extract_type = 0xff;
 
-   default:
-   WRONG_PARAM_COUNT;
-   break;
-   }
-   
if (extract_type  EXTR_OVERWRITE || extract_type  EXTR_IF_EXISTS) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Unknown extract 
type);
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Invalid extract 
type);
return;
}
-   
-   if