Browse Source

sync with 5.3 branch. add test for bug #44925

experimental/first_unicode_implementation
Nuno Lopes 18 years ago
parent
commit
bdeeaa526a
  1. 7
      ext/pcre/php_pcre.c
  2. 107
      ext/pcre/tests/bug44925.phpt

7
ext/pcre/php_pcre.c

@ -1976,9 +1976,8 @@ PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval *return
/* Go through the input array */
zend_hash_internal_pointer_reset(Z_ARRVAL_P(input));
while(zend_hash_get_current_data(Z_ARRVAL_P(input), (void **)&entry) == SUCCESS) {
zval subject;
zval subject = **entry;
subject = **entry;
if (Z_TYPE_PP(entry) != IS_STRING) {
zval_copy_ctor(&subject);
convert_to_string_with_converter(&subject, UG(utf8_conv));
@ -2001,8 +2000,8 @@ PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval *return
}
/* If the entry fits our requirements */
if ((count > 0 && !invert) ||
(count == PCRE_ERROR_NOMATCH && invert)) {
if ((count > 0 && !invert) || (count == PCRE_ERROR_NOMATCH && invert)) {
Z_ADDREF_PP(entry);
/* Add to return array */

107
ext/pcre/tests/bug44925.phpt

@ -0,0 +1,107 @@
--TEST--
Bug #44925 (preg_grep() modifies input array)
--FILE--
<?php
$str1 = 'a';
$str2 = 'b';
$array=Array("1",2,3,1.1,FALSE,NULL,Array(), $str1, &$str2);
var_dump($array);
var_dump(preg_grep('/do not match/',$array));
$a = preg_grep('/./',$array);
var_dump($a);
$str1 = 'x';
$str2 = 'y';
var_dump($a); // check if array is still ok
var_dump($array);
?>
--EXPECTF--
array(9) {
[0]=>
unicode(1) "1"
[1]=>
int(2)
[2]=>
int(3)
[3]=>
float(1.1)
[4]=>
bool(false)
[5]=>
NULL
[6]=>
array(0) {
}
[7]=>
unicode(1) "a"
[8]=>
&unicode(1) "b"
}
Notice: Array to string conversion in %sbug44925.php on line 9
array(0) {
}
Notice: Array to string conversion in %sbug44925.php on line 11
array(7) {
[0]=>
unicode(1) "1"
[1]=>
int(2)
[2]=>
int(3)
[3]=>
float(1.1)
[6]=>
array(0) {
}
[7]=>
unicode(1) "a"
[8]=>
&unicode(1) "b"
}
array(7) {
[0]=>
unicode(1) "1"
[1]=>
int(2)
[2]=>
int(3)
[3]=>
float(1.1)
[6]=>
array(0) {
}
[7]=>
unicode(1) "a"
[8]=>
&unicode(1) "y"
}
array(9) {
[0]=>
unicode(1) "1"
[1]=>
int(2)
[2]=>
int(3)
[3]=>
float(1.1)
[4]=>
bool(false)
[5]=>
NULL
[6]=>
array(0) {
}
[7]=>
unicode(1) "a"
[8]=>
&unicode(1) "y"
}
Loading…
Cancel
Save