Skip to content

Commit adb7297

Browse files
committed
Minor cleanup in spl_direcotry
* Rename variable for clarity * Reduce section with replaced error handling * Drop comment code line
1 parent 28afaef commit adb7297

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

ext/spl/spl_directory.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ static spl_filesystem_object *spl_filesystem_object_create_info(spl_filesystem_o
470470
return intern;
471471
} /* }}} */
472472

473-
static spl_filesystem_object *spl_filesystem_object_create_type(int ht, spl_filesystem_object *source, int type, zend_class_entry *ce, zval *return_value) /* {{{ */
473+
static spl_filesystem_object *spl_filesystem_object_create_type(int num_args, spl_filesystem_object *source, int type, zend_class_entry *ce, zval *return_value) /* {{{ */
474474
{
475475
spl_filesystem_object *intern;
476476
zend_bool use_include_path = 0;
@@ -542,7 +542,7 @@ static spl_filesystem_object *spl_filesystem_object_create_type(int ht, spl_file
542542
intern->u.file.open_mode = "r";
543543
intern->u.file.open_mode_len = 1;
544544

545-
if (ht && zend_parse_parameters(ht, "|sbr",
545+
if (num_args && zend_parse_parameters(num_args, "|sbr",
546546
&intern->u.file.open_mode, &intern->u.file.open_mode_len,
547547
&use_include_path, &intern->u.file.zcontext) == FAILURE) {
548548
zend_restore_error_handling(&error_handling);
@@ -700,8 +700,6 @@ void spl_filesystem_object_construct(INTERNAL_FUNCTION_PARAMETERS, zend_long cto
700700
zend_long flags;
701701
zend_error_handling error_handling;
702702

703-
zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling);
704-
705703
if (SPL_HAS_FLAG(ctor_flags, DIT_CTOR_FLAGS)) {
706704
flags = SPL_FILE_DIR_KEY_AS_PATHNAME|SPL_FILE_DIR_CURRENT_AS_FILEINFO;
707705
parsed = zend_parse_parameters(ZEND_NUM_ARGS(), "p|l", &path, &len, &flags);
@@ -716,23 +714,23 @@ void spl_filesystem_object_construct(INTERNAL_FUNCTION_PARAMETERS, zend_long cto
716714
flags |= SPL_FILE_DIR_UNIXPATHS;
717715
}
718716
if (parsed == FAILURE) {
719-
zend_restore_error_handling(&error_handling);
720717
return;
721718
}
719+
722720
if (!len) {
723721
zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Directory name must not be empty.");
724-
zend_restore_error_handling(&error_handling);
725722
return;
726723
}
727724

728725
intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
729726
if (intern->_path) {
730727
/* object is already initialized */
731-
zend_restore_error_handling(&error_handling);
732728
php_error_docref(NULL, E_WARNING, "Directory object is already initialized");
733729
return;
734730
}
735731
intern->flags = flags;
732+
733+
zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling);
736734
#ifdef HAVE_GLOB
737735
if (SPL_HAS_FLAG(ctor_flags, DIT_CTOR_GLOB) && strstr(path, "glob://") != path) {
738736
spprintf(&path, 0, "glob://%s", path);
@@ -1101,7 +1099,6 @@ SPL_METHOD(FilesystemIterator, current)
11011099
} else {
11021100
ZVAL_OBJ(return_value, Z_OBJ_P(ZEND_THIS));
11031101
Z_ADDREF_P(return_value);
1104-
/*RETURN_STRING(intern->u.dir.entry.d_name, 1);*/
11051102
}
11061103
}
11071104
/* }}} */

0 commit comments

Comments
 (0)