felipe Sun Feb 10 04:09:12 2008 UTC
Modified files:
/php-src/ext/standard file.c
Log:
Fixed Bug #42229 (fgetcsv() behaves differently for a file containing '\n'
with php5 and php6)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.509&r2=1.510&diff_format=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.509 php-src/ext/standard/file.c:1.510
--- php-src/ext/standard/file.c:1.509 Sun Feb 10 02:13:37 2008
+++ php-src/ext/standard/file.c Sun Feb 10 04:09:12 2008
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.c,v 1.509 2008/02/10 02:13:37 felipe Exp $ */
+/* $Id: file.c,v 1.510 2008/02/10 04:09:12 felipe Exp $ */
/* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
@@ -2359,6 +2359,11 @@
if (p >= e) break;
goto ready_state;
}
+
+ /* Otherwise, starting a new field without
enclosures */
+ state = PHP_FGETCSV_FIELD_NO_ENC;
+ field_start = p++;
+ field_end = NULL;
/* Is it an escape character? */
if ((PHP_FGETCSV_BIN_CHECK(p, e, escape,
escape_len) && escape != enclosure) ||
@@ -2368,15 +2373,9 @@
/* Skip escape sequence and let next
char be treated as literal
* If enclosure is the same character
as esacpe, it is considered as esacped
* if it appears twice */
- p += escape_len;
+ p += escape_len - 1;
/* FALL THROUGH */
}
-
- /* Otherwise, starting a new field without
enclosures */
- state = PHP_FGETCSV_FIELD_NO_ENC;
- field_start = p;
- field_end = NULL;
- p++;
break;
case PHP_FGETCSV_FIELD_WITH_ENC:
@@ -2568,6 +2567,11 @@
if (p >= e) break;
goto ready_state;
}
+
+ /* Otherwise, starting a new field without
enclosures */
+ state = PHP_FGETCSV_FIELD_NO_ENC;
+ field_start = p++;
+ field_end = NULL;
/* Is it an escape character? */
if ((PHP_FGETCSV_UNI_CHECK(p, e, escape,
escape_len) && escape != enclosure) ||
@@ -2575,17 +2579,11 @@
PHP_FGETCSV_UNI_CHECK(p+1, e, escape,
escape_len) && escape == enclosure)
) {
/* Skip escape sequence and let next
char be treated as literal
- * If enclosure is the same character
as esacpe, it is considered as esacped
+ * If enclosure is the same character
as escape, it is considered as escaped
* if it appears twice */
- p += escape_len;
+ p += escape_len - 1;
/* FALL THROUGH */
}
-
- /* Otherwise, starting a new field without
enclosures */
- state = PHP_FGETCSV_FIELD_NO_ENC;
- field_start = p;
- field_end = NULL;
- p++;
break;
case PHP_FGETCSV_FIELD_WITH_ENC:
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php