summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2008-04-15 15:48:20 +0000
committerIlia Alshanetsky <iliaa@php.net>2008-04-15 15:48:20 +0000
commit753529325ec332e762bbfe4bbc1d2b2b88351e9c (patch)
tree7380f5caee6eb984a33dad46e83f16b45f758e71 /ext
parent7f03b0550f443c2a047bda7981498655c62a5bbb (diff)
downloadphp-git-753529325ec332e762bbfe4bbc1d2b2b88351e9c.tar.gz
MFB: Fixed bug #44034 (FILE_IGNORE_NEW_LINES in file() does not work as
expected when lines end in \r\n)
Diffstat (limited to 'ext')
-rw-r--r--ext/standard/file.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/ext/standard/file.c b/ext/standard/file.c
index 38d2a1e34f..5a782d6da6 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -775,16 +775,20 @@ parse_eol:
} while ((p = memchr(p, eol_marker, (e-p))));
} else {
do {
- if (skip_blank_lines && !(p-s)) {
+ int windows_eol = 0;
+ if (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))));