lbarnaud Fri May 8 09:49:27 2009 UTC
Added files: (Branch: PHP_5_2)
/php-src/ext/standard/tests/file bug44034.phpt
Modified files:
/php-src/ext/standard file.c
Log:
MFB5.3 fix for bug #44034 (FILE_IGNORE_NEW_LINES in file() does not work as
expected when lines end in \r\n) (fixes #48175)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.409.2.6.2.40&r2=1.409.2.6.2.41&diff_format=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.409.2.6.2.40
php-src/ext/standard/file.c:1.409.2.6.2.41
--- php-src/ext/standard/file.c:1.409.2.6.2.40 Sun Apr 19 17:10:52 2009
+++ php-src/ext/standard/file.c Fri May 8 09:49:27 2009
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.c,v 1.409.2.6.2.40 2009/04/19 17:10:52 lbarnaud Exp $ */
+/* $Id: file.c,v 1.409.2.6.2.41 2009/05/08 09:49:27 lbarnaud Exp $ */
/* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
@@ -788,16 +788,20 @@
} while ((p = memchr(p, eol_marker, (e-p))));
} else {
do {
- if (skip_blank_lines && !(p-s)) {
+ int windows_eol = 0;
+ if (p != target_buf && eol_marker == '\n' &&
*(p - 1) == '\r') {
+ windows_eol++;
+ }
+ if (skip_blank_lines && !(p-s-windows_eol)) {
s = ++p;
continue;
}
if (PG(magic_quotes_runtime)) {
/* s is in target_buf which is freed at
the end of the function */
- slashed = php_addslashes(s, (p-s),
&len, 0 TSRMLS_CC);
+ slashed = php_addslashes(s,
(p-s-windows_eol), &len, 0 TSRMLS_CC);
add_index_stringl(return_value, i++,
slashed, len, 0);
} else {
- add_index_stringl(return_value, i++,
estrndup(s, p-s), p-s, 0);
+ add_index_stringl(return_value, i++,
estrndup(s, p-s-windows_eol), p-s-windows_eol, 0);
}
s = ++p;
} while ((p = memchr(p, eol_marker, (e-p))));
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/bug44034.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/file/bug44034.phpt
+++ php-src/ext/standard/tests/file/bug44034.phpt
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php