helly           Sun Aug  6 13:47:51 2006 UTC

  Modified files:              (Branch: PHP_5_2)
    /php-src/ext/spl    spl_directory.c 
  Log:
  - MFH Fix cvs access through SplFileObject
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.45.2.27.2.4&r2=1.45.2.27.2.5&diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.45.2.27.2.4 
php-src/ext/spl/spl_directory.c:1.45.2.27.2.5
--- php-src/ext/spl/spl_directory.c:1.45.2.27.2.4       Sat Jul 15 15:08:41 2006
+++ php-src/ext/spl/spl_directory.c     Sun Aug  6 13:47:51 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_directory.c,v 1.45.2.27.2.4 2006/07/15 15:08:41 helly Exp $ */
+/* $Id: spl_directory.c,v 1.45.2.27.2.5 2006/08/06 13:47:51 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -1456,11 +1456,19 @@
                size_t buf_len = intern->u.file.current_line_len;
                char *buf = estrndup(intern->u.file.current_line, buf_len);
 
-               if (Z_TYPE_P(return_value) != IS_NULL) {
-                       zval_dtor(return_value);
-                       ZVAL_NULL(return_value);
+               if (intern->u.file.current_zval) {
+                       zval_ptr_dtor(&intern->u.file.current_zval);
+               }
+               ALLOC_INIT_ZVAL(intern->u.file.current_zval);
+
+               php_fgetcsv(intern->u.file.stream, delimiter, enclosure, 
buf_len, buf, intern->u.file.current_zval TSRMLS_CC);
+               if (return_value) {
+                       if (Z_TYPE_P(return_value) != IS_NULL) {
+                               zval_dtor(return_value);
+                               ZVAL_NULL(return_value);
+                       }
+                       ZVAL_ZVAL(return_value, intern->u.file.current_zval, 1, 
0);
                }
-               php_fgetcsv(intern->u.file.stream, delimiter, enclosure, 
buf_len, buf, return_value TSRMLS_CC);
        }
        return ret;
 }
@@ -1479,8 +1487,7 @@
                        return FAILURE;
                }
                if (intern->flags & SPL_FILE_OBJECT_READ_CSV) {
-                       MAKE_STD_ZVAL(retval);
-                       return spl_filesystem_file_read_csv(intern, 
intern->u.file.delimiter, intern->u.file.enclosure, retval TSRMLS_CC);
+                       return spl_filesystem_file_read_csv(intern, 
intern->u.file.delimiter, intern->u.file.enclosure, NULL TSRMLS_CC);
                } else {
                        zend_call_method_with_0_params(&this_ptr, 
Z_OBJCE_P(getThis()), &intern->u.file.func_getCurr, "getCurrentLine", &retval);
                }
@@ -1696,7 +1703,7 @@
        if (!intern->u.file.current_line && !intern->u.file.current_zval) {
                spl_filesystem_file_read_line(getThis(), intern, 1 TSRMLS_CC);
        }
-       if (intern->u.file.current_line) {
+       if (intern->u.file.current_line && (!(intern->flags & 
SPL_FILE_OBJECT_READ_CSV) || !intern->u.file.current_zval)) {
                RETURN_STRINGL(intern->u.file.current_line, 
intern->u.file.current_line_len, 1);
        } else if (intern->u.file.current_zval) {
                RETURN_ZVAL(intern->u.file.current_zval, 1, 0);

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

Reply via email to