helly Thu Jul 20 22:54:22 2006 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/spl doxygen.cfg spl_functions.c spl_functions.h
spl_iterators.c spl_iterators.h
/php-src/ext/spl/internal regexiterator.inc
/php-src/ext/spl/tests iterator_050.phpt iterator_051.phpt
iterator_052.phpt iterator_053.phpt
iterator_054.phpt iterator_055.phpt
Log:
- Synch RegexIterator with HEAD
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/doxygen.cfg?r1=1.4.2.1&r2=1.4.2.1.2.1&diff_format=u
Index: php-src/ext/spl/doxygen.cfg
diff -u php-src/ext/spl/doxygen.cfg:1.4.2.1
php-src/ext/spl/doxygen.cfg:1.4.2.1.2.1
--- php-src/ext/spl/doxygen.cfg:1.4.2.1 Mon Feb 20 22:21:54 2006
+++ php-src/ext/spl/doxygen.cfg Thu Jul 20 22:54:21 2006
@@ -194,10 +194,10 @@
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = YES
HIDE_UNDOC_RELATIONS = YES
-HAVE_DOT = NO
+HAVE_DOT = YES
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
-UML_LOOK = NO
+UML_LOOK = YES
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_functions.c?r1=1.28.2.3.2.1&r2=1.28.2.3.2.2&diff_format=u
Index: php-src/ext/spl/spl_functions.c
diff -u php-src/ext/spl/spl_functions.c:1.28.2.3.2.1
php-src/ext/spl/spl_functions.c:1.28.2.3.2.2
--- php-src/ext/spl/spl_functions.c:1.28.2.3.2.1 Sun Jun 4 10:34:22 2006
+++ php-src/ext/spl/spl_functions.c Thu Jul 20 22:54:21 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_functions.c,v 1.28.2.3.2.1 2006/06/04 10:34:22 helly Exp $ */
+/* $Id: spl_functions.c,v 1.28.2.3.2.2 2006/07/20 22:54:21 helly Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -36,7 +36,7 @@
/* }}} */
/* {{{ spl_register_interface */
-void spl_register_interface(zend_class_entry ** ppce, char * class_name,
zend_function_entry *functions TSRMLS_DC)
+void spl_register_interface(zend_class_entry ** ppce, char * class_name,
zend_function_entry * functions TSRMLS_DC)
{
zend_class_entry ce;
@@ -95,14 +95,9 @@
/* }}} */
/* {{{ spl_register_property */
-void spl_register_property( zend_class_entry * class_entry, char *prop_name,
zval *prop_val, int prop_flags TSRMLS_DC)
+void spl_register_property( zend_class_entry * class_entry, char *prop_name,
int prop_name_len, int prop_flags TSRMLS_DC)
{
- if (!prop_val) {
- INIT_PZVAL(prop_val);
- prop_val->type = IS_NULL;
- }
-
- zend_declare_property(class_entry, prop_name, strlen(prop_name),
prop_val, prop_flags TSRMLS_CC);
+ zend_declare_property_null(class_entry, prop_name, prop_name_len,
prop_flags TSRMLS_CC);
}
/* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_functions.h?r1=1.19.2.3&r2=1.19.2.3.2.1&diff_format=u
Index: php-src/ext/spl/spl_functions.h
diff -u php-src/ext/spl/spl_functions.h:1.19.2.3
php-src/ext/spl/spl_functions.h:1.19.2.3.2.1
--- php-src/ext/spl/spl_functions.h:1.19.2.3 Sun Jan 1 12:50:13 2006
+++ php-src/ext/spl/spl_functions.h Thu Jul 20 22:54:21 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_functions.h,v 1.19.2.3 2006/01/01 12:50:13 sniper Exp $ */
+/* $Id: spl_functions.h,v 1.19.2.3.2.1 2006/07/20 22:54:21 helly Exp $ */
#ifndef PHP_FUNCTIONS_H
#define PHP_FUNCTIONS_H
@@ -49,8 +49,8 @@
#define REGISTER_SPL_FUNCTIONS(class_name, function_list) \
spl_register_functions(spl_ce_ ## class_name, function_list TSRMLS_CC);
-#define REGISTER_SPL_PROPERTY(class_name, prop_name) \
- spl_register_property(spl_ce_ ## class_name, prop_name, prop_val,
prop_flags TSRMLS_CC);
+#define REGISTER_SPL_PROPERTY(class_name, prop_name, prop_flags) \
+ spl_register_property(spl_ce_ ## class_name, prop_name,
sizeof(prop_name)-1, prop_flags TSRMLS_CC);
#define REGISTER_SPL_CLASS_CONST_LONG(class_name, const_name, value) \
zend_declare_class_constant_long(spl_ce_ ## class_name, const_name,
sizeof(const_name)-1, (long)value TSRMLS_CC);
@@ -64,7 +64,7 @@
void spl_register_parent_ce(zend_class_entry * class_entry, zend_class_entry *
parent_class TSRMLS_DC);
void spl_register_functions(zend_class_entry * class_entry,
zend_function_entry * function_list TSRMLS_DC);
-void spl_register_property( zend_class_entry * class_entry, char *prop_name,
zval *prop_val, int prop_flags TSRMLS_DC);
+void spl_register_property( zend_class_entry * class_entry, char *prop_name,
int prop_name_len, int prop_flags TSRMLS_DC);
/* sub: whether to allow subclasses/interfaces
allow = 0: allow all classes and interfaces
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_iterators.c?r1=1.73.2.30.2.14&r2=1.73.2.30.2.15&diff_format=u
Index: php-src/ext/spl/spl_iterators.c
diff -u php-src/ext/spl/spl_iterators.c:1.73.2.30.2.14
php-src/ext/spl/spl_iterators.c:1.73.2.30.2.15
--- php-src/ext/spl/spl_iterators.c:1.73.2.30.2.14 Tue Jul 18 22:42:28 2006
+++ php-src/ext/spl/spl_iterators.c Thu Jul 20 22:54:21 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_iterators.c,v 1.73.2.30.2.14 2006/07/18 22:42:28 iliaa Exp $ */
+/* $Id: spl_iterators.c,v 1.73.2.30.2.15 2006/07/20 22:54:21 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -994,13 +994,13 @@
case DIT_RegexIterator:
case DIT_RecursiveRegexIterator: {
char *regex;
- int len, poptions, coptions;
- pcre_extra *extra = NULL;
+ int regex_len;
long mode = REGIT_MODE_MATCH;
+ intern->u.regex.use_flags = ZEND_NUM_ARGS() >= 5;
intern->u.regex.flags = 0;
intern->u.regex.preg_flags = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"Os|lll", &zobject, ce_inner, ®ex, &len, &intern->u.regex.flags, &mode,
&intern->u.regex.preg_flags) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"Os|lll", &zobject, ce_inner, ®ex, ®ex_len, &mode,
&intern->u.regex.flags, &intern->u.regex.preg_flags) == FAILURE) {
php_set_error_handling(EH_NORMAL, NULL
TSRMLS_CC);
return NULL;
}
@@ -1010,8 +1010,8 @@
return NULL;
}
intern->u.regex.mode = mode;
- intern->u.regex.regex = estrndup(regex, len);
- intern->u.regex.pce =
pcre_get_compiled_regex_cache(regex, len, &extra, &poptions, &coptions
TSRMLS_CC);
+ intern->u.regex.regex = estrndup(regex, regex_len);
+ intern->u.regex.pce =
pcre_get_compiled_regex_cache(regex, regex_len TSRMLS_CC);
intern->u.regex.pce->refcount++;
break;;
}
@@ -1365,7 +1365,7 @@
} /* }}} */
#if HAVE_PCRE || HAVE_BUNDLED_PCRE
-/* {{{ proto void RegexIterator::__construct(Iterator it, string regex [, int
flags [, int mode [, int preg_flags]]])
+/* {{{ proto void RegexIterator::__construct(Iterator it, string regex [, int
mode [, int flags [, int preg_flags]]])
Create an RegexIterator from another iterator and a regular expression */
SPL_METHOD(RegexIterator, __construct)
{
@@ -1377,11 +1377,9 @@
SPL_METHOD(RegexIterator, accept)
{
spl_dual_it_object *intern =
(spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
- char *subject, tmp[32];
- int subject_len, use_copy, count;
- zval subject_copy, zcount;
- pcre *regex = intern->u.regex.pce->re;
- pcre_extra *extra = intern->u.regex.pce->extra;
+ char *subject, tmp[32], *result;
+ int subject_len, use_copy, count, result_len;
+ zval subject_copy, zcount, *replacement;
if (intern->u.regex.flags & REGIT_USE_KEY) {
if (intern->current.key_type == HASH_KEY_IS_LONG) {
@@ -1408,7 +1406,7 @@
{
case REGIT_MODE_MAX: /* won't happen but makes compiler happy */
case REGIT_MODE_MATCH:
- count = pcre_exec(regex, extra, subject, subject_len, 0, 0,
NULL, 0);
+ count = pcre_exec(intern->u.regex.pce->re,
intern->u.regex.pce->extra, subject, subject_len, 0, 0, NULL, 0);
RETVAL_BOOL(count >= 0);
break;
@@ -1419,9 +1417,9 @@
use_copy = 1;
}
zval_ptr_dtor(&intern->current.data);
- MAKE_STD_ZVAL(intern->current.data);
- php_pcre_match(regex, extra, subject, subject_len, &zcount,
- intern->current.data, intern->u.regex.mode ==
REGIT_MODE_ALL_MATCHES, 0, 0, 0, 0 TSRMLS_CC);
+ ALLOC_INIT_ZVAL(intern->current.data);
+ php_pcre_match_impl(intern->u.regex.pce, subject, subject_len,
&zcount,
+ intern->current.data, intern->u.regex.mode ==
REGIT_MODE_ALL_MATCHES, intern->u.regex.use_flags, intern->u.regex.preg_flags,
0 TSRMLS_CC);
count =
zend_hash_num_elements(Z_ARRVAL_P(intern->current.data));
RETVAL_BOOL(count > 0);
break;
@@ -1432,11 +1430,28 @@
use_copy = 1;
}
zval_ptr_dtor(&intern->current.data);
- MAKE_STD_ZVAL(intern->current.data);
- php_pcre_split(regex, extra, subject, subject_len,
intern->current.data, 0, -1, 0, 0, 0 TSRMLS_CC);
+ ALLOC_INIT_ZVAL(intern->current.data);
+ php_pcre_split_impl(intern->u.regex.pce, subject, subject_len,
intern->current.data, -1, intern->u.regex.preg_flags TSRMLS_CC);
count =
zend_hash_num_elements(Z_ARRVAL_P(intern->current.data));
RETVAL_BOOL(count > 1);
break;
+
+ case REGIT_MODE_REPLACE:
+ replacement = zend_read_property(intern->std.ce, getThis(),
"replacement", sizeof("replacement")-1, 1 TSRMLS_CC);
+ result = php_pcre_replace_impl(intern->u.regex.pce, subject,
subject_len, replacement, 0, &result_len, 0, NULL TSRMLS_CC);
+
+ if (intern->u.regex.flags & REGIT_USE_KEY) {
+ if (intern->current.key_type != HASH_KEY_IS_LONG) {
+ efree(intern->current.str_key);
+ }
+ intern->current.key_type = HASH_KEY_IS_STRING;
+ intern->current.str_key = result;
+ intern->current.str_key_len = result_len + 1;
+ } else {
+ zval_ptr_dtor(&intern->current.data);
+ MAKE_STD_ZVAL(intern->current.data);
+ ZVAL_STRINGL(intern->current.data, result, result_len,
0);
+ }
}
if (use_copy) {
@@ -1444,7 +1459,7 @@
}
} /* }}} */
-/* {{{ proto void RecursiveRegexIterator::__construct(RecursiveIterator it,
string regex [, int flags [, int mode [, int preg_flags]]])
+/* {{{ proto void RecursiveRegexIterator::__construct(RecursiveIterator it,
string regex [, int mode [, int flags [, int preg_flags]]])
Create an RecursiveRegexIterator from another recursive iterator and a
regular expression */
SPL_METHOD(RecursiveRegexIterator, __construct)
{
@@ -1584,8 +1599,8 @@
ZEND_BEGIN_ARG_INFO_EX(arginfo_regex_it___construct, 0, 0, 2)
ZEND_ARG_OBJ_INFO(0, iterator, Iterator, 0)
ZEND_ARG_INFO(0, regex)
- ZEND_ARG_INFO(0, flags)
ZEND_ARG_INFO(0, mode)
+ ZEND_ARG_INFO(0, flags)
ZEND_ARG_INFO(0, preg_flags)
ZEND_END_ARG_INFO();
@@ -2779,6 +2794,8 @@
REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "GET_MATCH",
REGIT_MODE_GET_MATCH);
REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "ALL_MATCHES",
REGIT_MODE_ALL_MATCHES);
REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "SPLIT",
REGIT_MODE_SPLIT);
+ REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "REPLACE",
REGIT_MODE_REPLACE);
+ REGISTER_SPL_PROPERTY(RegexIterator, "replacement", 0);
REGISTER_SPL_SUB_CLASS_EX(RecursiveRegexIterator, RegexIterator,
spl_dual_it_new, spl_funcs_RecursiveRegexIterator);
REGISTER_SPL_IMPLEMENTS(RecursiveRegexIterator, RecursiveIterator);
#else
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_iterators.h?r1=1.18.2.7.2.7&r2=1.18.2.7.2.8&diff_format=u
Index: php-src/ext/spl/spl_iterators.h
diff -u php-src/ext/spl/spl_iterators.h:1.18.2.7.2.7
php-src/ext/spl/spl_iterators.h:1.18.2.7.2.8
--- php-src/ext/spl/spl_iterators.h:1.18.2.7.2.7 Sun Jul 16 21:12:32 2006
+++ php-src/ext/spl/spl_iterators.h Thu Jul 20 22:54:21 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_iterators.h,v 1.18.2.7.2.7 2006/07/16 21:12:32 helly Exp $ */
+/* $Id: spl_iterators.h,v 1.18.2.7.2.8 2006/07/20 22:54:21 helly Exp $ */
#ifndef SPL_ITERATORS_H
#define SPL_ITERATORS_H
@@ -100,6 +100,7 @@
REGIT_MODE_GET_MATCH,
REGIT_MODE_ALL_MATCHES,
REGIT_MODE_SPLIT,
+ REGIT_MODE_REPLACE,
REGIT_MODE_MAX,
} regex_mode;
@@ -137,6 +138,7 @@
} append;
#if HAVE_PCRE || HAVE_BUNDLED_PCRE
struct {
+ int use_flags;
int flags;
regex_mode mode;
long preg_flags;
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/internal/regexiterator.inc?r1=1.2.2.3&r2=1.2.2.4&diff_format=u
Index: php-src/ext/spl/internal/regexiterator.inc
diff -u php-src/ext/spl/internal/regexiterator.inc:1.2.2.3
php-src/ext/spl/internal/regexiterator.inc:1.2.2.4
--- php-src/ext/spl/internal/regexiterator.inc:1.2.2.3 Sun Jul 16 23:46:12 2006
+++ php-src/ext/spl/internal/regexiterator.inc Thu Jul 20 22:54:21 2006
@@ -12,7 +12,7 @@
/**
* @brief Regular expression filter for iterators
* @author Marcus Boerger
- * @version 1.1
+ * @version 1.0
* @since PHP 5.1
*
* This filter iterator assumes that the inner iterator
@@ -26,6 +26,7 @@
const GET_MATCH = 1; /**< Mode: Return the first matche (if any) */
const ALL_MATCHES = 2; /**< Mode: Return all matches (if any) */
const SPLIT = 3; /**< Mode: Return the split values (if any) */
+ const REPLACE = 4; /**< Mode: Replace the input key or current */
private $regex; /**< the regular expression to match against */
private $flags; /**< special flags (self::USE_KEY) */
@@ -33,6 +34,7 @@
self::GET_MATCH, self::ALL_MATCHES,
self::SPLIT) */
private $preg_flags;/**< PREG_* flags, see preg_match(),
preg_match_all(),
preg_split() */
+ private $key; /**< the value used for key() */
private $current; /**< the value used for current() */
/**
@@ -41,13 +43,13 @@
*
* @param it inner iterator
* @param regex the regular expression to match
- * @param flags special flags (self::USE_KEY)
* @param mode operation mode (one of self::MATCH,
self::GET_MATCH,
* self::ALL_MATCHES, self::SPLIT)
+ * @param flags special flags (self::USE_KEY)
* @param preg_flags global PREG_* flags, see preg_match(),
* preg_match_all(), preg_split()
*/
- function __construct(Iterator $it, $regex, $flags = 0, $mode = 0,
$preg_flags = 0) {
+ function __construct(Iterator $it, $regex, $mode = 0, $flags = 0,
$preg_flags = 0) {
parent::__construct($it);
$this->regex = $regex;
$this->flags = $flags;
@@ -66,9 +68,10 @@
function accept()
{
$matches = array();
+ $this->key = parent::key();
$this->current = parent::current();
/* note that we use $this->current, rather than calling
parent::current() */
- $subject = ($this->flags & self::USE_KEY) ? parent::key() :
$this->current;
+ $subject = ($this->flags & self::USE_KEY) ? $this->key :
$this->current;
switch($this->mode)
{
case self::MATCH:
@@ -85,9 +88,28 @@
case self::SPLIT:
$this->current = array();
preg_split($this->regex, $subject,
$this->current, $this->preg_flags) > 1;
+
+ case self::REPLACE:
+ $this->current = array();
+ $result = preg_replace($this->regex,
$this->replacement, $subject);
+ if ($this->flags & self::USE_KEY)
+ {
+ $this->key = $result;
+ }
+ else
+ {
+ $this->current = $result;
+ }
}
}
+ /** @return the key after accept has been called
+ */
+ function key()
+ {
+ return $this->key;
+ }
+
/** @return the current value after accept has been called
*/
function current()
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/iterator_050.phpt?r1=1.1.2.2&r2=1.1.2.3&diff_format=u
Index: php-src/ext/spl/tests/iterator_050.phpt
diff -u php-src/ext/spl/tests/iterator_050.phpt:1.1.2.2
php-src/ext/spl/tests/iterator_050.phpt:1.1.2.3
--- php-src/ext/spl/tests/iterator_050.phpt:1.1.2.2 Sun Jul 16 21:12:32 2006
+++ php-src/ext/spl/tests/iterator_050.phpt Thu Jul 20 22:54:21 2006
@@ -18,10 +18,10 @@
}
$ar = new
ArrayIterator(array('1','1,2','1,2,3','',NULL,array(),'FooBar',',',',,'));
-$it = new MyRegexIterator($ar, '/(\d),(\d)/', 0, RegexIterator::GET_MATCH);
+$it = new MyRegexIterator($ar, '/(\d),(\d)/', RegexIterator::GET_MATCH);
$it->show();
-$it = new MyRegexIterator($ar, '/(\d)/', 0, RegexIterator::GET_MATCH);
+$it = new MyRegexIterator($ar, '/(\d)/', RegexIterator::GET_MATCH);
$it->show();
var_dump($ar);
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/iterator_051.phpt?r1=1.1.2.2&r2=1.1.2.3&diff_format=u
Index: php-src/ext/spl/tests/iterator_051.phpt
diff -u php-src/ext/spl/tests/iterator_051.phpt:1.1.2.2
php-src/ext/spl/tests/iterator_051.phpt:1.1.2.3
--- php-src/ext/spl/tests/iterator_051.phpt:1.1.2.2 Sun Jul 16 21:12:32 2006
+++ php-src/ext/spl/tests/iterator_051.phpt Thu Jul 20 22:54:21 2006
@@ -18,10 +18,10 @@
}
$ar = new
ArrayIterator(array('1'=>0,'1,2'=>1,'1,2,3'=>2,0=>3,'FooBar'=>4,','=>5,',,'=>6));
-$it = new MyRegexIterator($ar, '/(\d),(\d)/', RegexIterator::USE_KEY,
RegexIterator::GET_MATCH);
+$it = new MyRegexIterator($ar, '/(\d),(\d)/', RegexIterator::GET_MATCH,
RegexIterator::USE_KEY);
$it->show();
-$it = new MyRegexIterator($ar, '/(\d)/', RegexIterator::USE_KEY,
RegexIterator::GET_MATCH);
+$it = new MyRegexIterator($ar, '/(\d)/', RegexIterator::GET_MATCH,
RegexIterator::USE_KEY);
$it->show();
var_dump($ar);
@@ -93,67 +93,3 @@
int(6)
}
===DONE===
---UEXPECTF--
-unicode(3) "1,2"
-array(3) {
- [0]=>
- string(3) "1,2"
- [1]=>
- string(1) "1"
- [2]=>
- string(1) "2"
-}
-unicode(5) "1,2,3"
-array(3) {
- [0]=>
- string(3) "1,2"
- [1]=>
- string(1) "1"
- [2]=>
- string(1) "2"
-}
-int(1)
-array(2) {
- [0]=>
- string(1) "1"
- [1]=>
- string(1) "1"
-}
-unicode(3) "1,2"
-array(2) {
- [0]=>
- string(1) "1"
- [1]=>
- string(1) "1"
-}
-unicode(5) "1,2,3"
-array(2) {
- [0]=>
- string(1) "1"
- [1]=>
- string(1) "1"
-}
-int(0)
-array(2) {
- [0]=>
- string(1) "0"
- [1]=>
- string(1) "0"
-}
-object(ArrayIterator)#%d (7) {
- [1]=>
- int(0)
- [u"1,2"]=>
- int(1)
- [u"1,2,3"]=>
- int(2)
- [0]=>
- int(3)
- [u"FooBar"]=>
- int(4)
- [u","]=>
- int(5)
- [u",,"]=>
- int(6)
-}
-===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/iterator_052.phpt?r1=1.1.2.2&r2=1.1.2.3&diff_format=u
Index: php-src/ext/spl/tests/iterator_052.phpt
diff -u php-src/ext/spl/tests/iterator_052.phpt:1.1.2.2
php-src/ext/spl/tests/iterator_052.phpt:1.1.2.3
--- php-src/ext/spl/tests/iterator_052.phpt:1.1.2.2 Sun Jul 16 21:12:32 2006
+++ php-src/ext/spl/tests/iterator_052.phpt Thu Jul 20 22:54:21 2006
@@ -7,6 +7,15 @@
class MyRegexIterator extends RegexIterator
{
+ public $uk, $re;
+
+ function __construct($it, $re, $mode, $flags = 0)
+ {
+ $this->uk = $flags & self::USE_KEY;
+ $this->re = $re;
+ parent::__construct($it, $re, $mode, $flags);
+ }
+
function show()
{
foreach($this as $k => $v)
@@ -15,13 +24,21 @@
var_dump($v);
}
}
+
+ function accept()
+ {
+ @preg_match_all($this->re, (string)($this->uk ? $this->key() :
$this->current()), $sub);
+ $ret = parent::accept();
+ var_dump($sub == $this->current());
+ return $ret;
+ }
}
$ar = new
ArrayIterator(array('1','1,2','1,2,3','',NULL,array(),'FooBar',',',',,'));
-$it = new MyRegexIterator($ar, '/(\d),(\d)/', 0, RegexIterator::ALL_MATCHES);
+$it = new MyRegexIterator($ar, '/(\d),(\d)/', RegexIterator::ALL_MATCHES);
$it->show();
-$it = new MyRegexIterator($ar, '/(\d)/', 0, RegexIterator::ALL_MATCHES);
+$it = new MyRegexIterator($ar, '/(\d)/', RegexIterator::ALL_MATCHES);
$it->show();
var_dump($ar);
@@ -30,40 +47,150 @@
===DONE===
<?php exit(0); ?>
--EXPECTF--
+bool(true)
+int(0)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
int(1)
-array(1) {
+array(3) {
[0]=>
- array(3) {
+ array(1) {
[0]=>
string(3) "1,2"
- [1]=>
+ }
+ [1]=>
+ array(1) {
+ [0]=>
string(1) "1"
- [2]=>
+ }
+ [2]=>
+ array(1) {
+ [0]=>
string(1) "2"
}
}
+bool(true)
int(2)
-array(1) {
+array(3) {
[0]=>
- array(3) {
+ array(1) {
[0]=>
string(3) "1,2"
- [1]=>
+ }
+ [1]=>
+ array(1) {
+ [0]=>
string(1) "1"
- [2]=>
+ }
+ [2]=>
+ array(1) {
+ [0]=>
string(1) "2"
}
}
+bool(true)
+int(3)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(4)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(5)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(6)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(7)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(8)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
int(0)
-array(1) {
+array(2) {
[0]=>
- array(2) {
+ array(1) {
[0]=>
string(1) "1"
- [1]=>
+ }
+ [1]=>
+ array(1) {
+ [0]=>
string(1) "1"
}
}
+bool(true)
int(1)
array(2) {
[0]=>
@@ -71,40 +198,98 @@
[0]=>
string(1) "1"
[1]=>
- string(1) "1"
+ string(1) "2"
}
[1]=>
array(2) {
[0]=>
- string(1) "2"
+ string(1) "1"
[1]=>
string(1) "2"
}
}
+bool(true)
int(2)
-array(3) {
+array(2) {
[0]=>
- array(2) {
+ array(3) {
[0]=>
string(1) "1"
[1]=>
- string(1) "1"
+ string(1) "2"
+ [2]=>
+ string(1) "3"
}
[1]=>
- array(2) {
+ array(3) {
[0]=>
- string(1) "2"
+ string(1) "1"
[1]=>
string(1) "2"
- }
- [2]=>
- array(2) {
- [0]=>
- string(1) "3"
- [1]=>
+ [2]=>
string(1) "3"
}
}
+bool(true)
+int(3)
+array(2) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+}
+bool(true)
+int(4)
+array(2) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+}
+bool(true)
+int(5)
+array(2) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+}
+bool(true)
+int(6)
+array(2) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+}
+bool(true)
+int(7)
+array(2) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+}
+bool(true)
+int(8)
+array(2) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+}
object(ArrayIterator)#%d (9) {
[0]=>
%s(1) "1"
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/iterator_053.phpt?r1=1.1.2.2&r2=1.1.2.3&diff_format=u
Index: php-src/ext/spl/tests/iterator_053.phpt
diff -u php-src/ext/spl/tests/iterator_053.phpt:1.1.2.2
php-src/ext/spl/tests/iterator_053.phpt:1.1.2.3
--- php-src/ext/spl/tests/iterator_053.phpt:1.1.2.2 Sun Jul 16 21:12:32 2006
+++ php-src/ext/spl/tests/iterator_053.phpt Thu Jul 20 22:54:21 2006
@@ -1,5 +1,5 @@
--TEST--
-SPL: RegexIterator::ALL_MATCHES, USE_KEY
+SPL: RegexIterator::ALL_MATCHES
--SKIPIF--
<?php if (!extension_loaded("spl")) print "skip"; ?>
--FILE--
@@ -7,6 +7,15 @@
class MyRegexIterator extends RegexIterator
{
+ public $uk, $re;
+
+ function __construct($it, $re, $mode, $flags = 0)
+ {
+ $this->uk = $flags & self::USE_KEY;
+ $this->re = $re;
+ parent::__construct($it, $re, $mode, $flags);
+ }
+
function show()
{
foreach($this as $k => $v)
@@ -15,13 +24,21 @@
var_dump($v);
}
}
+
+ function accept()
+ {
+ @preg_match_all($this->re, (string)($this->uk ? $this->key() :
$this->current()), $sub);
+ $ret = parent::accept();
+ var_dump($sub == $this->current());
+ return $ret;
+ }
}
-$ar = new
ArrayIterator(array('1'=>0,'1,2'=>1,'1,2,3'=>2,0=>3,'FooBar'=>4,','=>5,',,'=>6));
-$it = new MyRegexIterator($ar, '/(\d),(\d)/', RegexIterator::USE_KEY,
RegexIterator::ALL_MATCHES);
+$ar = new
ArrayIterator(array('1','1,2','1,2,3','',NULL,array(),'FooBar',',',',,'));
+$it = new MyRegexIterator($ar, '/(\d),(\d)/', RegexIterator::ALL_MATCHES,
RegexIterator::USE_KEY);
$it->show();
-$it = new MyRegexIterator($ar, '/(\d)/', RegexIterator::USE_KEY,
RegexIterator::ALL_MATCHES);
+$it = new MyRegexIterator($ar, '/(\d)/', RegexIterator::ALL_MATCHES,
RegexIterator::USE_KEY);
$it->show();
var_dump($ar);
@@ -30,208 +47,268 @@
===DONE===
<?php exit(0); ?>
--EXPECTF--
-string(3) "1,2"
-array(1) {
+bool(true)
+int(0)
+array(3) {
[0]=>
- array(3) {
- [0]=>
- string(3) "1,2"
- [1]=>
- string(1) "1"
- [2]=>
- string(1) "2"
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
}
}
-string(5) "1,2,3"
-array(1) {
+bool(true)
+int(1)
+array(3) {
[0]=>
- array(3) {
- [0]=>
- string(3) "1,2"
- [1]=>
- string(1) "1"
- [2]=>
- string(1) "2"
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
}
}
-int(1)
-array(1) {
+bool(true)
+int(2)
+array(3) {
[0]=>
- array(2) {
- [0]=>
- string(1) "1"
- [1]=>
- string(1) "1"
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
}
}
-string(3) "1,2"
-array(2) {
+bool(true)
+int(3)
+array(3) {
[0]=>
- array(2) {
- [0]=>
- string(1) "1"
- [1]=>
- string(1) "1"
+ array(0) {
}
[1]=>
- array(2) {
- [0]=>
- string(1) "2"
- [1]=>
- string(1) "2"
+ array(0) {
+ }
+ [2]=>
+ array(0) {
}
}
-string(5) "1,2,3"
+bool(true)
+int(4)
array(3) {
[0]=>
- array(2) {
- [0]=>
- string(1) "1"
- [1]=>
- string(1) "1"
+ array(0) {
}
[1]=>
- array(2) {
- [0]=>
- string(1) "2"
- [1]=>
- string(1) "2"
+ array(0) {
}
[2]=>
- array(2) {
- [0]=>
- string(1) "3"
- [1]=>
- string(1) "3"
+ array(0) {
+ }
+}
+bool(true)
+int(5)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(6)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(7)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(8)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
}
}
+bool(true)
int(0)
-array(1) {
+array(2) {
[0]=>
- array(2) {
+ array(1) {
[0]=>
string(1) "0"
- [1]=>
+ }
+ [1]=>
+ array(1) {
+ [0]=>
string(1) "0"
}
}
-object(ArrayIterator)#%d (7) {
+bool(true)
+int(1)
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(1) "1"
+ }
[1]=>
- int(0)
- ["1,2"]=>
- int(1)
- ["1,2,3"]=>
- int(2)
- [0]=>
- int(3)
- ["FooBar"]=>
- int(4)
- [","]=>
- int(5)
- [",,"]=>
- int(6)
+ array(1) {
+ [0]=>
+ string(1) "1"
+ }
}
-===DONE===
---UEXPECTF--
-unicode(3) "1,2"
-array(1) {
+bool(true)
+int(2)
+array(2) {
[0]=>
- array(3) {
+ array(1) {
+ [0]=>
+ string(1) "2"
+ }
+ [1]=>
+ array(1) {
[0]=>
- string(3) "1,2"
- [1]=>
- string(1) "1"
- [2]=>
string(1) "2"
}
}
-unicode(5) "1,2,3"
-array(1) {
+bool(true)
+int(3)
+array(2) {
[0]=>
- array(3) {
+ array(1) {
[0]=>
- string(3) "1,2"
- [1]=>
- string(1) "1"
- [2]=>
- string(1) "2"
+ string(1) "3"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(1) "3"
}
}
-int(1)
-array(1) {
+bool(true)
+int(4)
+array(2) {
[0]=>
- array(2) {
+ array(1) {
[0]=>
- string(1) "1"
- [1]=>
- string(1) "1"
+ string(1) "4"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(1) "4"
}
}
-unicode(3) "1,2"
+bool(true)
+int(5)
array(2) {
[0]=>
- array(2) {
+ array(1) {
[0]=>
- string(1) "1"
- [1]=>
- string(1) "1"
+ string(1) "5"
}
[1]=>
- array(2) {
+ array(1) {
[0]=>
- string(1) "2"
- [1]=>
- string(1) "2"
+ string(1) "5"
}
}
-unicode(5) "1,2,3"
-array(3) {
+bool(true)
+int(6)
+array(2) {
[0]=>
- array(2) {
+ array(1) {
[0]=>
- string(1) "1"
- [1]=>
- string(1) "1"
+ string(1) "6"
}
[1]=>
- array(2) {
+ array(1) {
[0]=>
- string(1) "2"
- [1]=>
- string(1) "2"
+ string(1) "6"
}
- [2]=>
- array(2) {
+}
+bool(true)
+int(7)
+array(2) {
+ [0]=>
+ array(1) {
[0]=>
- string(1) "3"
- [1]=>
- string(1) "3"
+ string(1) "7"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(1) "7"
}
}
-int(0)
-array(1) {
+bool(true)
+int(8)
+array(2) {
[0]=>
- array(2) {
+ array(1) {
[0]=>
- string(1) "0"
- [1]=>
- string(1) "0"
+ string(1) "8"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(1) "8"
}
}
-object(ArrayIterator)#%d (7) {
+object(ArrayIterator)#%d (9) {
+ [0]=>
+ %s(1) "1"
[1]=>
- int(0)
- [u"1,2"]=>
- int(1)
- [u"1,2,3"]=>
- int(2)
- [0]=>
- int(3)
- [u"FooBar"]=>
- int(4)
- [u","]=>
- int(5)
- [u",,"]=>
- int(6)
+ %s(3) "1,2"
+ [2]=>
+ %s(5) "1,2,3"
+ [3]=>
+ %s(0) ""
+ [4]=>
+ NULL
+ [5]=>
+ array(0) {
+ }
+ [6]=>
+ %s(6) "FooBar"
+ [7]=>
+ %s(1) ","
+ [8]=>
+ %s(2) ",,"
}
===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/iterator_054.phpt?r1=1.1.2.2&r2=1.1.2.3&diff_format=u
Index: php-src/ext/spl/tests/iterator_054.phpt
diff -u php-src/ext/spl/tests/iterator_054.phpt:1.1.2.2
php-src/ext/spl/tests/iterator_054.phpt:1.1.2.3
--- php-src/ext/spl/tests/iterator_054.phpt:1.1.2.2 Sun Jul 16 21:12:32 2006
+++ php-src/ext/spl/tests/iterator_054.phpt Thu Jul 20 22:54:21 2006
@@ -18,7 +18,7 @@
}
$ar = new
ArrayIterator(array('1','1,2','1,2,3','',NULL,array(),'FooBar',',',',,'));
-$it = new MyRegexIterator($ar, '/,/', 0, RegexIterator::SPLIT);
+$it = new MyRegexIterator($ar, '/,/', RegexIterator::SPLIT);
$it->show();
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/iterator_055.phpt?r1=1.1.2.2&r2=1.1.2.3&diff_format=u
Index: php-src/ext/spl/tests/iterator_055.phpt
diff -u php-src/ext/spl/tests/iterator_055.phpt:1.1.2.2
php-src/ext/spl/tests/iterator_055.phpt:1.1.2.3
--- php-src/ext/spl/tests/iterator_055.phpt:1.1.2.2 Sun Jul 16 21:12:32 2006
+++ php-src/ext/spl/tests/iterator_055.phpt Thu Jul 20 22:54:21 2006
@@ -18,7 +18,7 @@
}
$ar = new
ArrayIterator(array('1'=>0,'1,2'=>1,'1,2,3'=>2,0=>3,'FooBar'=>4,','=>5,',,'=>6));
-$it = new MyRegexIterator($ar, '/(\d),(\d)/', RegexIterator::USE_KEY,
RegexIterator::SPLIT);
+$it = new MyRegexIterator($ar, '/(\d),(\d)/', RegexIterator::SPLIT,
RegexIterator::USE_KEY);
$it->show();
@@ -59,35 +59,3 @@
int(6)
}
===DONE===
---UEXPECTF--
-unicode(3) "1,2"
-array(2) {
- [0]=>
- string(0) ""
- [1]=>
- string(0) ""
-}
-unicode(5) "1,2,3"
-array(2) {
- [0]=>
- string(0) ""
- [1]=>
- string(2) ",3"
-}
-object(ArrayIterator)#%d (7) {
- [1]=>
- int(0)
- [u"1,2"]=>
- int(1)
- [u"1,2,3"]=>
- int(2)
- [0]=>
- int(3)
- [u"FooBar"]=>
- int(4)
- [u","]=>
- int(5)
- [u",,"]=>
- int(6)
-}
-===DONE===
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php