Skip to content

Commit 1478278

Browse files
authored
SPL: Use new improved is_line_empty() function instead of the old one (#9217)
1 parent 5e518c0 commit 1478278

File tree

1 file changed

+1
-36
lines changed

1 file changed

+1
-36
lines changed

ext/spl/spl_directory.c

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,47 +2020,12 @@ static zend_result spl_filesystem_file_read_line_ex(zval * this_ptr, spl_filesys
20202020
}
20212021
} /* }}} */
20222022

2023-
static bool spl_filesystem_file_is_empty_line(spl_filesystem_object *intern) /* {{{ */
2024-
{
2025-
if (intern->u.file.current_line) {
2026-
return intern->u.file.current_line_len == 0;
2027-
} else if (!Z_ISUNDEF(intern->u.file.current_zval)) {
2028-
ZEND_ASSERT(Z_TYPE(intern->u.file.current_zval) == IS_ARRAY);
2029-
/* TODO Figure out when this branch can happen... */
2030-
if (SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_READ_CSV)
2031-
&& zend_hash_num_elements(Z_ARRVAL(intern->u.file.current_zval)) == 1) {
2032-
ZEND_ASSERT(false && "Can this happen?");
2033-
uint32_t idx = 0;
2034-
zval *first;
2035-
2036-
if (HT_IS_PACKED(Z_ARRVAL(intern->u.file.current_zval))) {
2037-
while (Z_ISUNDEF(Z_ARRVAL(intern->u.file.current_zval)->arPacked[idx])) {
2038-
idx++;
2039-
}
2040-
first = &Z_ARRVAL(intern->u.file.current_zval)->arPacked[idx];
2041-
ZEND_ASSERT(Z_TYPE_P(first) == IS_STRING);
2042-
} else {
2043-
while (Z_ISUNDEF(Z_ARRVAL(intern->u.file.current_zval)->arData[idx].val)) {
2044-
idx++;
2045-
}
2046-
first = &Z_ARRVAL(intern->u.file.current_zval)->arData[idx].val;
2047-
ZEND_ASSERT(Z_TYPE_P(first) == IS_STRING);
2048-
}
2049-
return Z_STRLEN_P(first) == 0;
2050-
}
2051-
return zend_hash_num_elements(Z_ARRVAL(intern->u.file.current_zval)) == 0;
2052-
} else {
2053-
return 1;
2054-
}
2055-
}
2056-
/* }}} */
2057-
20582023
/* Call to this function reads a line in a "silent" fashion and does not throw an exception */
20592024
static zend_result spl_filesystem_file_read_line(zval * this_ptr, spl_filesystem_object *intern) /* {{{ */
20602025
{
20612026
zend_result ret = spl_filesystem_file_read_line_ex(this_ptr, intern);
20622027

2063-
while (SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_SKIP_EMPTY) && ret == SUCCESS && spl_filesystem_file_is_empty_line(intern)) {
2028+
while (SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_SKIP_EMPTY) && ret == SUCCESS && is_line_empty(intern)) {
20642029
spl_filesystem_file_free_line(intern);
20652030
ret = spl_filesystem_file_read_line_ex(this_ptr, intern);
20662031
}

0 commit comments

Comments
 (0)