iliaa           Sun May 24 16:01:48 2009 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/ext/standard       file.c 
    /php-src/ext/standard/tests/file    fgetcsv_variation14.phpt 
                                        fgetcsv_variation21.phpt 
  Log:
  
  MFB: Improve fix for bug #48313
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.409.2.6.2.28.2.34&r2=1.409.2.6.2.28.2.35&diff_format=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.409.2.6.2.28.2.34 
php-src/ext/standard/file.c:1.409.2.6.2.28.2.35
--- php-src/ext/standard/file.c:1.409.2.6.2.28.2.34     Thu May 21 02:15:03 2009
+++ php-src/ext/standard/file.c Sun May 24 16:01:47 2009
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: file.c,v 1.409.2.6.2.28.2.34 2009/05/21 02:15:03 jani Exp $ */
+/* $Id: file.c,v 1.409.2.6.2.28.2.35 2009/05/24 16:01:47 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -2108,6 +2108,7 @@
        char *temp, *tptr, *bptr, *line_end, *limit;
        size_t temp_len, line_end_len;
        int inc_len;
+       zend_bool first_field = 1;
 
        /* initialize internal state */
        php_mblen(NULL, 0);
@@ -2159,6 +2160,11 @@
                }
 
        quit_loop_1:
+               if (first_field && bptr == line_end) {
+                       add_next_index_null(return_value);
+                       break;
+               }
+               first_field = 0;
                /* 2. Read field, leaving bptr pointing at start of next field 
*/
                if (inc_len != 0 && *bptr == enclosure) {
                        int state = 0;
@@ -2355,12 +2361,8 @@
                }
 
                /* 3. Now pass our field back to php */
-               if (comp_end - temp) {
-                       *comp_end = '\0';
-                       add_next_index_stringl(return_value, temp, comp_end - 
temp, 1);
-               } else {
-                       add_next_index_null(return_value);
-               }
+               *comp_end = '\0';
+               add_next_index_stringl(return_value, temp, comp_end - temp, 1);
        } while (inc_len > 0);
 
 out:
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fgetcsv_variation14.phpt?r1=1.1.2.2&r2=1.1.2.2.2.1&diff_format=u
Index: php-src/ext/standard/tests/file/fgetcsv_variation14.phpt
diff -u php-src/ext/standard/tests/file/fgetcsv_variation14.phpt:1.1.2.2 
php-src/ext/standard/tests/file/fgetcsv_variation14.phpt:1.1.2.2.2.1
--- php-src/ext/standard/tests/file/fgetcsv_variation14.phpt:1.1.2.2    Tue Aug 
14 14:07:46 2007
+++ php-src/ext/standard/tests/file/fgetcsv_variation14.phpt    Sun May 24 
16:01:48 2009
@@ -75,7 +75,7 @@
 -- Testing fgetcsv() with file opened using r mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -86,7 +86,7 @@
 -- Testing fgetcsv() with file opened using rb mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -97,7 +97,7 @@
 -- Testing fgetcsv() with file opened using rt mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -108,7 +108,7 @@
 -- Testing fgetcsv() with file opened using r+ mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -119,7 +119,7 @@
 -- Testing fgetcsv() with file opened using r+b mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -130,7 +130,7 @@
 -- Testing fgetcsv() with file opened using r+t mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -141,7 +141,7 @@
 -- Testing fgetcsv() with file opened using a+ mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -152,7 +152,7 @@
 -- Testing fgetcsv() with file opened using a+b mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -163,7 +163,7 @@
 -- Testing fgetcsv() with file opened using a+t mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -174,7 +174,7 @@
 -- Testing fgetcsv() with file opened using w+ mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -185,7 +185,7 @@
 -- Testing fgetcsv() with file opened using w+b mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -196,7 +196,7 @@
 -- Testing fgetcsv() with file opened using w+t mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -207,7 +207,7 @@
 -- Testing fgetcsv() with file opened using x+ mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -218,7 +218,7 @@
 -- Testing fgetcsv() with file opened using x+b mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -229,7 +229,7 @@
 -- Testing fgetcsv() with file opened using x+t mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fgetcsv_variation21.phpt?r1=1.1.2.1&r2=1.1.2.1.2.1&diff_format=u
Index: php-src/ext/standard/tests/file/fgetcsv_variation21.phpt
diff -u php-src/ext/standard/tests/file/fgetcsv_variation21.phpt:1.1.2.1 
php-src/ext/standard/tests/file/fgetcsv_variation21.phpt:1.1.2.1.2.1
--- php-src/ext/standard/tests/file/fgetcsv_variation21.phpt:1.1.2.1    Wed Aug 
 8 13:13:18 2007
+++ php-src/ext/standard/tests/file/fgetcsv_variation21.phpt    Sun May 24 
16:01:48 2009
@@ -72,7 +72,7 @@
 -- Testing fgetcsv() with file opened using r mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -80,7 +80,7 @@
 -- Testing fgetcsv() with file opened using rb mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -88,7 +88,7 @@
 -- Testing fgetcsv() with file opened using rt mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -96,7 +96,7 @@
 -- Testing fgetcsv() with file opened using r+ mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -104,7 +104,7 @@
 -- Testing fgetcsv() with file opened using r+b mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -112,7 +112,7 @@
 -- Testing fgetcsv() with file opened using r+t mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -120,7 +120,7 @@
 -- Testing fgetcsv() with file opened using a+ mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -128,7 +128,7 @@
 -- Testing fgetcsv() with file opened using a+b mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -136,7 +136,7 @@
 -- Testing fgetcsv() with file opened using a+t mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -144,7 +144,7 @@
 -- Testing fgetcsv() with file opened using w+ mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -152,7 +152,7 @@
 -- Testing fgetcsv() with file opened using w+b mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -160,7 +160,7 @@
 -- Testing fgetcsv() with file opened using w+t mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -168,7 +168,7 @@
 -- Testing fgetcsv() with file opened using x+ mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -176,7 +176,7 @@
 -- Testing fgetcsv() with file opened using x+b mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)
@@ -184,7 +184,7 @@
 -- Testing fgetcsv() with file opened using x+t mode --
 array(1) {
   [0]=>
-  string(0) ""
+  NULL
 }
 int(1)
 bool(false)



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

Reply via email to