pajoye Wed Nov 22 12:56:26 2006 UTC
Added files:
/php-src/ext/standard/tests/file bug39538.phpt
Modified files:
/php-src/ext/standard file.c
Log:
- #39538, fgetcsv can't handle starting newlines and trailing odd
number of backslashes (David Soria Parra, Pierre)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.468&r2=1.469&diff_format=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.468 php-src/ext/standard/file.c:1.469
--- php-src/ext/standard/file.c:1.468 Mon Nov 20 11:12:35 2006
+++ php-src/ext/standard/file.c Wed Nov 22 12:56:26 2006
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.c,v 1.468 2006/11/20 11:12:35 tony2001 Exp $ */
+/* $Id: file.c,v 1.469 2006/11/22 12:56:26 pajoye Exp $ */
/* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
@@ -2249,6 +2249,11 @@
memcpy(tptr,
hunk_begin, bptr - hunk_begin);
tptr += (bptr -
hunk_begin);
hunk_begin =
bptr;
+ if (hunk_begin
!= line_end) {
+
memcpy(tptr, hunk_begin, bptr - hunk_begin);
+ tptr +=
(bptr - hunk_begin);
+
hunk_begin = bptr;
+ }
/* add the
embedded line end to the field */
memcpy(tptr,
line_end, line_end_len);
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/bug39538.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/file/bug39538.phpt
+++ php-src/ext/standard/tests/file/bug39538.phpt
--TEST--
bug 39538
--FILE--
<?php
$content = array("\"\nthis is an test\", \"next data\",
\"p\narsed\"","\"\r\nthis is an test\", \"next data\",
\"p\r\narsed\"","\"\n\rthis is an test\", \"next data\", \"p\n\rarsed\"");
$file = dirname(__FILE__) . "/bug39538.csv";
@unlink($file);
foreach ($content as $v) {
file_put_contents($file, $v);
print_r (fgetcsv(fopen($file, "r"), filesize($file)));
}
@unlink($file);
--EXPECT--
Array
(
[0] =>
this is an test
[1] => next data
[2] => p
arsed
)
Array
(
[0] =>
this is an test
[1] => next data
[2] => p
arsed
)
Array
(
[0] =>
this is an test
[1] => next data
[2] => p
arsed
)
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php