helly           Wed Jul 28 18:55:26 2004 EDT

  Modified files:              (Branch: PHP_5_0)
    /php-src/ext/spl    spl_iterators.c 
    /php-src/ext/spl/examples   autoload.inc dbareader.inc 
  Log:
  MFH
  
http://cvs.php.net/diff.php/php-src/ext/spl/spl_iterators.c?r1=1.38&r2=1.38.2.1&ty=u
Index: php-src/ext/spl/spl_iterators.c
diff -u php-src/ext/spl/spl_iterators.c:1.38 php-src/ext/spl/spl_iterators.c:1.38.2.1
--- php-src/ext/spl/spl_iterators.c:1.38        Mon May 31 04:58:32 2004
+++ php-src/ext/spl/spl_iterators.c     Wed Jul 28 18:55:26 2004
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_iterators.c,v 1.38 2004/05/31 08:58:32 zeev Exp $ */
+/* $Id: spl_iterators.c,v 1.38.2.1 2004/07/28 22:55:26 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -634,8 +634,16 @@
        }
 } /* }}} */
 
+static INLINE void spl_dual_it_require(spl_dual_it_object *intern TSRMLS_DC)
+{
+       if (!intern->inner.iterator) {
+               php_error_docref(NULL TSRMLS_CC, E_ERROR, "The inner constructor 
wasn't initialized with an iterator instance");
+       }
+}
+
 static INLINE void spl_dual_it_free(spl_dual_it_object *intern TSRMLS_DC)
 {
+       spl_dual_it_require(intern TSRMLS_CC);
        if (intern->inner.iterator && 
intern->inner.iterator->funcs->invalidate_current) {
                
intern->inner.iterator->funcs->invalidate_current(intern->inner.iterator TSRMLS_CC);
        }
@@ -698,6 +706,8 @@
 {
        if (do_free) {
                spl_dual_it_free(intern TSRMLS_CC);
+       } else {
+               spl_dual_it_require(intern TSRMLS_CC);
        }
        intern->inner.iterator->funcs->move_forward(intern->inner.iterator TSRMLS_CC);
        intern->current.pos++;
http://cvs.php.net/diff.php/php-src/ext/spl/examples/autoload.inc?r1=1.5&r2=1.5.2.1&ty=u
Index: php-src/ext/spl/examples/autoload.inc
diff -u php-src/ext/spl/examples/autoload.inc:1.5 
php-src/ext/spl/examples/autoload.inc:1.5.2.1
--- php-src/ext/spl/examples/autoload.inc:1.5   Mon May 10 13:26:03 2004
+++ php-src/ext/spl/examples/autoload.inc       Wed Jul 28 18:55:26 2004
@@ -33,7 +33,10 @@
  */
 function __autoload($classname) {
        $classname = strtolower($classname);
-       foreach(split(':', ini_get('include_path')) as $dir)
+       $inc = split(':', ini_get('include_path'));
+       $inc[] = '.';
+       $inc[] = dirname($_SERVER['PATH_TRANSLATED']);
+       foreach($inc as $dir)
        {
                if (__load_class($classname, $dir))
                {
@@ -41,10 +44,7 @@
                        return;
                }
        }
-       if (!__load_class($classname, '.'))
-       if (!__load_class($classname, dirname($_SERVER['PATH_TRANSLATED'])))
        fprintf(STDERR, 'Class not found ('.$classname.")\n");
-       return;
 }
 
 ?>
http://cvs.php.net/diff.php/php-src/ext/spl/examples/dbareader.inc?r1=1.2&r2=1.2.2.1&ty=u
Index: php-src/ext/spl/examples/dbareader.inc
diff -u php-src/ext/spl/examples/dbareader.inc:1.2 
php-src/ext/spl/examples/dbareader.inc:1.2.2.1
--- php-src/ext/spl/examples/dbareader.inc:1.2  Mon May 10 13:26:03 2004
+++ php-src/ext/spl/examples/dbareader.inc      Wed Jul 28 18:55:26 2004
@@ -28,32 +28,24 @@
         * @param handler Handler to use for database access.
         */
        function __construct($file, $handler) {
-               $this->db = dba_open($file, 'r', $handler);
+               if (!$this->db = dba_open($file, 'r', $handler)) {
+                   throw new exception('Could not open file ' . $file);
+               }
        }
        
        /**
         * Close database.
         */
        function __destruct() {
-               if ($this->db) {
-                       dba_close($this->db);
-               }
+               dba_close($this->db);
        }
 
        /**
         * Rewind to first element.
         */
        function rewind() {
-               if ($this->db) {
-                       $this->key = dba_firstkey($this->db);
-               }
-       }
-
-       /**
-        * @return Current data.
-        */
-       function current() {
-               return $this->val;
+               $this->key = dba_firstkey($this->db);
+               fetch_data();
        }
 
        /**
@@ -62,12 +54,24 @@
         * @return void
         */
        function next() {
-               if ($this->db) {
-                       $this->key = dba_nextkey($this->db);
-                       if ($this->key !== false) {
-                               $this->val = dba_fetch($this->key, $this->db);
-                       }
+               $this->key = dba_nextkey($this->db);
+               fetch_data();
+       }
+
+    /**
+     * Fetches the current data if $key is valid
+     */        
+       private function fetch_data() {
+               if ($this->key !== false) {
+                       $this->val = dba_fetch($this->key, $this->db);
                }
+       }
+
+       /**
+        * @return Current data.
+        */
+       function current() {
+               return $this->val;
        }
 
        /**

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

Reply via email to