mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
Use some early returns in spl_directory
This commit is contained in:
parent
a3abcc063e
commit
1a81251dbb
1 changed files with 51 additions and 52 deletions
|
@ -1900,13 +1900,13 @@ static int spl_filesystem_file_read(spl_filesystem_object *intern, int silent) /
|
||||||
|
|
||||||
static int spl_filesystem_file_read_csv(spl_filesystem_object *intern, char delimiter, char enclosure, int escape, zval *return_value) /* {{{ */
|
static int spl_filesystem_file_read_csv(spl_filesystem_object *intern, char delimiter, char enclosure, int escape, zval *return_value) /* {{{ */
|
||||||
{
|
{
|
||||||
int ret = SUCCESS;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
ret = spl_filesystem_file_read(intern, 1);
|
int ret = spl_filesystem_file_read(intern, 1);
|
||||||
} while (ret == SUCCESS && !intern->u.file.current_line_len && SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_SKIP_EMPTY));
|
if (ret != SUCCESS) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
} while (!intern->u.file.current_line_len && SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_SKIP_EMPTY));
|
||||||
|
|
||||||
if (ret == SUCCESS) {
|
|
||||||
size_t buf_len = intern->u.file.current_line_len;
|
size_t buf_len = intern->u.file.current_line_len;
|
||||||
char *buf = estrndup(intern->u.file.current_line, buf_len);
|
char *buf = estrndup(intern->u.file.current_line, buf_len);
|
||||||
|
|
||||||
|
@ -1919,8 +1919,7 @@ static int spl_filesystem_file_read_csv(spl_filesystem_object *intern, char deli
|
||||||
if (return_value) {
|
if (return_value) {
|
||||||
ZVAL_COPY(return_value, &intern->u.file.current_zval);
|
ZVAL_COPY(return_value, &intern->u.file.current_zval);
|
||||||
}
|
}
|
||||||
}
|
return SUCCESS;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -2300,12 +2299,13 @@ PHP_METHOD(SplFileObject, fgetcsv)
|
||||||
char *delim = NULL, *enclo = NULL, *esc = NULL;
|
char *delim = NULL, *enclo = NULL, *esc = NULL;
|
||||||
size_t d_len = 0, e_len = 0, esc_len = 0;
|
size_t d_len = 0, e_len = 0, esc_len = 0;
|
||||||
|
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|sss", &delim, &d_len, &enclo, &e_len, &esc, &esc_len) == SUCCESS) {
|
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|sss", &delim, &d_len, &enclo, &e_len, &esc, &esc_len) == FAILURE) {
|
||||||
|
RETURN_THROWS();
|
||||||
|
}
|
||||||
|
|
||||||
CHECK_SPL_FILE_OBJECT_IS_INITIALIZED(intern);
|
CHECK_SPL_FILE_OBJECT_IS_INITIALIZED(intern);
|
||||||
|
|
||||||
switch(ZEND_NUM_ARGS())
|
switch (ZEND_NUM_ARGS()) {
|
||||||
{
|
|
||||||
case 3:
|
case 3:
|
||||||
if (esc_len > 1) {
|
if (esc_len > 1) {
|
||||||
zend_argument_value_error(3, "must be empty or a single character");
|
zend_argument_value_error(3, "must be empty or a single character");
|
||||||
|
@ -2335,7 +2335,6 @@ PHP_METHOD(SplFileObject, fgetcsv)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
spl_filesystem_file_read_csv(intern, delimiter, enclosure, escape, return_value);
|
spl_filesystem_file_read_csv(intern, delimiter, enclosure, escape, return_value);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue