helly Mon Jan 26 17:30:26 2004 EDT
Added files:
/php-src/ext/spl/tests limititerator.phpt
Modified files:
/php-src NEWS
/php-src/ext/spl spl_iterators.c
Log:
Fixed bug #27042 (SPL: SeekableIterator seek() broken).
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1589&r2=1.1590&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.1589 php-src/NEWS:1.1590
--- php-src/NEWS:1.1589 Sun Jan 25 09:00:59 2004
+++ php-src/NEWS Mon Jan 26 17:30:23 2004
@@ -11,6 +11,7 @@
(Derick)
- Fixed problems with longlong values in mysqli. (Georg)
- Fixed class name case preserving of user defined classes. (Marcus)
+- Fixed bug #27042 (SPL: SeekableIterator seek() broken). (Marcus)
- Fixed bug #27008 (Every class method can be called as static). (Marcus)
- Fixed bug #26938 (exec() has problems reading long lines).
(Ilia, runekl[at]opoint[dot]com
http://cvs.php.net/diff.php/php-src/ext/spl/spl_iterators.c?r1=1.15&r2=1.16&ty=u
Index: php-src/ext/spl/spl_iterators.c
diff -u php-src/ext/spl/spl_iterators.c:1.15 php-src/ext/spl/spl_iterators.c:1.16
--- php-src/ext/spl/spl_iterators.c:1.15 Tue Jan 20 15:59:45 2004
+++ php-src/ext/spl/spl_iterators.c Mon Jan 26 17:30:24 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_iterators.c,v 1.15 2004/01/20 20:59:45 helly Exp $ */
+/* $Id: spl_iterators.c,v 1.16 2004/01/26 22:30:24 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -880,6 +880,9 @@
INIT_PZVAL(&zpos);
ZVAL_LONG(&zpos, pos);
zend_call_method_with_1_params(&intern->inner.zobject,
intern->inner.ce, NULL, "seek", NULL, &zpos);
+ spl_dual_it_free(intern TSRMLS_CC);
+ zend_user_it_free_current(intern->inner.iterator TSRMLS_CC);
+ spl_dual_it_fetch(intern, 1 TSRMLS_CC);
intern->current.pos = pos;
} else {
/* emulate the forward seek, by next() calls */
http://cvs.php.net/co.php/php-src/ext/spl/tests/limititerator.phpt?r=1.1&p=1
Index: php-src/ext/spl/tests/limititerator.phpt
+++ php-src/ext/spl/tests/limititerator.phpt
--TEST--
SPL: SeekableIterator
--SKIPIF--
<?php if (!extension_loaded("spl")) print "skip"; ?>
--FILE--
<?php
class NumericArrayIterator implements Iterator
{
protected $a;
protected $i;
public function __construct($a)
{
echo __METHOD__ . "\n";
$this->a = $a;
}
public function rewind()
{
echo __METHOD__ . "\n";
$this->i = 0;
}
public function hasMore()
{
echo __METHOD__ . "\n";
return $this->i < count($this->a);
}
public function key()
{
echo __METHOD__ . "\n";
return $this->i;
}
public function current()
{
echo __METHOD__ . "\n";
return $this->a[$this->i];
}
public function next()
{
echo __METHOD__ . "\n";
$this->i++;
}
}
class SeekableNumericArrayIterator extends NumericArrayIterator implements
SeekableIterator
{
public function seek($index)
{
if ($index < count($this->a)) {
$this->i = $index;
}
echo __METHOD__ . '(' . $index . ")\n";
}
}
$a = array(1, 2, 3, 4, 5);
foreach (new LimitIterator(new NumericArrayIterator($a)) as $v)
{
print "$v\n";
}
echo "===SEEKABLE===\n";
$a = array(1, 2, 3, 4, 5);
foreach(new LimitIterator(new SeekableNumericArrayIterator($a)) as $v)
{
print "$v\n";
}
echo "===SEEKING===\n";
$a = array(1, 2, 3, 4, 5);
$l = new LimitIterator(new SeekableNumericArrayIterator($a));
for($i = 0; $i < 5; $i++)
{
$l->seek($i);
print $l->current() . "\n";
}
?>
===DONE===
<?php exit(0); ?>
--EXPECT--
NumericArrayIterator::__construct
NumericArrayIterator::rewind
NumericArrayIterator::hasMore
NumericArrayIterator::hasMore
NumericArrayIterator::current
NumericArrayIterator::key
1
NumericArrayIterator::next
NumericArrayIterator::hasMore
NumericArrayIterator::current
NumericArrayIterator::key
2
NumericArrayIterator::next
NumericArrayIterator::hasMore
NumericArrayIterator::current
NumericArrayIterator::key
3
NumericArrayIterator::next
NumericArrayIterator::hasMore
NumericArrayIterator::current
NumericArrayIterator::key
4
NumericArrayIterator::next
NumericArrayIterator::hasMore
NumericArrayIterator::current
NumericArrayIterator::key
5
NumericArrayIterator::next
NumericArrayIterator::hasMore
===SEEKABLE===
NumericArrayIterator::__construct
NumericArrayIterator::rewind
SeekableNumericArrayIterator::seek(0)
NumericArrayIterator::hasMore
NumericArrayIterator::current
NumericArrayIterator::key
1
NumericArrayIterator::next
NumericArrayIterator::hasMore
NumericArrayIterator::current
NumericArrayIterator::key
2
NumericArrayIterator::next
NumericArrayIterator::hasMore
NumericArrayIterator::current
NumericArrayIterator::key
3
NumericArrayIterator::next
NumericArrayIterator::hasMore
NumericArrayIterator::current
NumericArrayIterator::key
4
NumericArrayIterator::next
NumericArrayIterator::hasMore
NumericArrayIterator::current
NumericArrayIterator::key
5
NumericArrayIterator::next
NumericArrayIterator::hasMore
===SEEKING===
NumericArrayIterator::__construct
SeekableNumericArrayIterator::seek(0)
NumericArrayIterator::hasMore
NumericArrayIterator::current
NumericArrayIterator::key
1
SeekableNumericArrayIterator::seek(1)
NumericArrayIterator::hasMore
NumericArrayIterator::current
NumericArrayIterator::key
2
SeekableNumericArrayIterator::seek(2)
NumericArrayIterator::hasMore
NumericArrayIterator::current
NumericArrayIterator::key
3
SeekableNumericArrayIterator::seek(3)
NumericArrayIterator::hasMore
NumericArrayIterator::current
NumericArrayIterator::key
4
SeekableNumericArrayIterator::seek(4)
NumericArrayIterator::hasMore
NumericArrayIterator::current
NumericArrayIterator::key
5
===DONE===
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php