Skip to content

Commit

Permalink
Merge branch 'PHP-8.0' into PHP-8.1
Browse files Browse the repository at this point in the history
* PHP-8.0:
  Revert "Fix GH-8563  Different results for seek() on SplFileObject and SplTempFileObject"
  • Loading branch information
Girgias committed Jul 5, 2022
2 parents 35ca407 + 79a2832 commit e67336f
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 139 deletions.
23 changes: 12 additions & 11 deletions ext/spl/spl_directory.c
Expand Up @@ -1891,21 +1891,22 @@ static zend_result spl_filesystem_file_read_ex(spl_filesystem_object *intern, bo
}

if (!buf) {
return FAILURE;
}

if (SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_DROP_NEW_LINE)) {
if (line_len > 0 && buf[line_len - 1] == '\n') {
line_len--;
if (line_len > 0 && buf[line_len - 1] == '\r') {
intern->u.file.current_line = estrdup("");
intern->u.file.current_line_len = 0;
} else {
if (SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_DROP_NEW_LINE)) {
if (line_len > 0 && buf[line_len - 1] == '\n') {
line_len--;
if (line_len > 0 && buf[line_len - 1] == '\r') {
line_len--;
}
buf[line_len] = '\0';
}
buf[line_len] = '\0';
}
}

intern->u.file.current_line = buf;
intern->u.file.current_line_len = line_len;
intern->u.file.current_line = buf;
intern->u.file.current_line_len = line_len;
}
intern->u.file.current_line_num += line_add;

return SUCCESS;
Expand Down
38 changes: 0 additions & 38 deletions ext/spl/tests/SplFileObject/fgetcsv_file_empty_lines.phpt

This file was deleted.

37 changes: 0 additions & 37 deletions ext/spl/tests/SplFileObject/foreach_file_empty_lines.phpt

This file was deleted.

48 changes: 0 additions & 48 deletions ext/spl/tests/SplFileObject/gh8563.phpt

This file was deleted.

Expand Up @@ -13,7 +13,6 @@ fclose($fp);

$fo = new SplFileObject('SplFileObject__fgetcsv1.csv');
var_dump($fo->fgetcsv());
var_dump($fo->fgetcsv());
?>
--CLEAN--
<?php
Expand All @@ -30,4 +29,3 @@ array(4) {
[3]=>
string(1) "5"
}
bool(false)
Expand Up @@ -18,5 +18,5 @@ var_dump($s->key());
var_dump($s->valid());
?>
--EXPECT--
int(12)
int(14)
bool(false)
Expand Up @@ -18,5 +18,5 @@ var_dump($s->key());
var_dump($s->valid());
?>
--EXPECT--
int(12)
int(13)
bool(false)
1 change: 1 addition & 0 deletions ext/spl/tests/bug81477.phpt
Expand Up @@ -21,6 +21,7 @@ string(8) "baz,bat
"
string(10) "more,data
"
string(0) ""
--CLEAN--
<?php
@unlink(__DIR__ . '/bug81477.csv');
Expand Down
2 changes: 1 addition & 1 deletion ext/spl/tests/fileobject_001.phpt
Expand Up @@ -70,7 +70,7 @@ string(1) "4"
int(5)
string(1) "5"
int(6)
bool(false)
string(0) ""
===B===
int(0)
string(1) "0"
Expand Down

0 comments on commit e67336f

Please sign in to comment.