Skip to content

Commit 2586812

Browse files
committed
Inline FileFunctionCall macro
1 parent 029fa49 commit 2586812

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

ext/spl/spl_directory.c

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,17 +1944,6 @@ static int spl_filesystem_file_call(spl_filesystem_object *intern, zend_function
19441944
return result;
19451945
} /* }}} */
19461946

1947-
#define FileFunctionCall(func_name, pass_num_args) /* {{{ */ \
1948-
{ \
1949-
zend_function *func_ptr; \
1950-
func_ptr = (zend_function *)zend_hash_str_find_ptr(EG(function_table), #func_name, sizeof(#func_name) - 1); \
1951-
if (func_ptr == NULL) { \
1952-
zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Internal error, function %s() not found. Please report", #func_name); \
1953-
return; \
1954-
} \
1955-
spl_filesystem_file_call(intern, func_ptr, pass_num_args, return_value); \
1956-
} /* }}} */
1957-
19581947
static int spl_filesystem_file_read_csv(spl_filesystem_object *intern, char delimiter, char enclosure, int escape, zval *return_value) /* {{{ */
19591948
{
19601949
int ret = SUCCESS;
@@ -2561,7 +2550,14 @@ PHP_METHOD(SplFileObject, getCsvControl)
25612550
PHP_METHOD(SplFileObject, flock)
25622551
{
25632552
spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
2564-
FileFunctionCall(flock, ZEND_NUM_ARGS());
2553+
zend_function *func_ptr;
2554+
2555+
func_ptr = (zend_function *)zend_hash_str_find_ptr(EG(function_table), "flock", sizeof("flock") - 1);
2556+
if (func_ptr == NULL) {
2557+
zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Internal error, function flock() not found. Please report");
2558+
RETURN_THROWS();
2559+
}
2560+
spl_filesystem_file_call(intern, func_ptr, ZEND_NUM_ARGS(), return_value);
25652561
}
25662562
/* }}} */
25672563

@@ -2663,6 +2659,7 @@ PHP_METHOD(SplFileObject, fpassthru)
26632659
PHP_METHOD(SplFileObject, fscanf)
26642660
{
26652661
spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
2662+
zend_function *func_ptr;
26662663

26672664
if(!intern->u.file.stream) {
26682665
zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Object not initialized");
@@ -2672,7 +2669,12 @@ PHP_METHOD(SplFileObject, fscanf)
26722669
spl_filesystem_file_free_line(intern);
26732670
intern->u.file.current_line_num++;
26742671

2675-
FileFunctionCall(fscanf, ZEND_NUM_ARGS());
2672+
func_ptr = (zend_function *)zend_hash_str_find_ptr(EG(function_table), "fscanf", sizeof("fscanf") - 1);
2673+
if (func_ptr == NULL) {
2674+
zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Internal error, function fscanf() not found. Please report");
2675+
RETURN_THROWS();
2676+
}
2677+
spl_filesystem_file_call(intern, func_ptr, ZEND_NUM_ARGS(), return_value);
26762678
}
26772679
/* }}} */
26782680

@@ -2744,7 +2746,14 @@ PHP_METHOD(SplFileObject, fread)
27442746
PHP_METHOD(SplFileObject, fstat)
27452747
{
27462748
spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
2747-
FileFunctionCall(fstat, ZEND_NUM_ARGS());
2749+
zend_function *func_ptr;
2750+
2751+
func_ptr = (zend_function *)zend_hash_str_find_ptr(EG(function_table), "fstat", sizeof("fstat") - 1);
2752+
if (func_ptr == NULL) {
2753+
zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Internal error, function fstat() not found. Please report");
2754+
RETURN_THROWS();
2755+
}
2756+
spl_filesystem_file_call(intern, func_ptr, ZEND_NUM_ARGS(), return_value);
27482757
}
27492758
/* }}} */
27502759

0 commit comments

Comments
 (0)