From 44f1ef210d03519b716e4befec51fdba0427b264 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Thu, 24 Jul 2008 12:49:11 +0000 Subject: [PATCH] - MFH: New parameter parsing API --- ext/standard/dir.c | 13 +-- ext/standard/tests/dir/closedir_error.phpt | 2 +- .../tests/dir/closedir_variation1.phpt | 96 +++++++++---------- ext/standard/tests/dir/readdir_error.phpt | 2 +- .../tests/dir/readdir_variation1.phpt | 96 +++++++++---------- ext/standard/tests/dir/rewinddir_error.phpt | 2 +- .../tests/dir/rewinddir_variation1.phpt | 96 +++++++++---------- 7 files changed, 154 insertions(+), 153 deletions(-) diff --git a/ext/standard/dir.c b/ext/standard/dir.c index 63292a853d..3dcef4cd36 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -74,6 +74,9 @@ static int le_dirp; static zend_class_entry *dir_class_entry_ptr; #define FETCH_DIRP() \ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &id) == FAILURE) { \ + return; \ + } \ if (ZEND_NUM_ARGS() == 0) { \ myself = getThis(); \ if (myself) { \ @@ -85,10 +88,8 @@ static zend_class_entry *dir_class_entry_ptr; } else { \ ZEND_FETCH_RESOURCE(dirp, php_stream *, 0, DIRG(default_dir), "Directory", php_file_le_stream()); \ } \ - } else if ((ZEND_NUM_ARGS() != 1) || zend_get_parameters_ex(1, &id) == FAILURE) { \ - WRONG_PARAM_COUNT; \ } else { \ - dirp = (php_stream *) zend_fetch_resource(id TSRMLS_CC, -1, "Directory", NULL, 1, php_file_le_stream()); \ + dirp = (php_stream *) zend_fetch_resource(&id TSRMLS_CC, -1, "Directory", NULL, 1, php_file_le_stream()); \ if (!dirp) \ RETURN_FALSE; \ } @@ -256,7 +257,7 @@ PHP_FUNCTION(getdir) Close directory connection identified by the dir_handle */ PHP_FUNCTION(closedir) { - zval **id, **tmp, *myself; + zval *id = NULL, **tmp, *myself; php_stream *dirp; int rsrc_id; @@ -362,7 +363,7 @@ PHP_FUNCTION(getcwd) Rewind dir_handle back to the start */ PHP_FUNCTION(rewinddir) { - zval **id, **tmp, *myself; + zval *id = NULL, **tmp, *myself; php_stream *dirp; FETCH_DIRP(); @@ -380,7 +381,7 @@ PHP_FUNCTION(rewinddir) Read directory entry from dir_handle */ PHP_NAMED_FUNCTION(php_if_readdir) { - zval **id, **tmp, *myself; + zval *id = NULL, **tmp, *myself; php_stream *dirp; php_stream_dirent entry; diff --git a/ext/standard/tests/dir/closedir_error.phpt b/ext/standard/tests/dir/closedir_error.phpt index 1a8a043d0a..c2f7647ff9 100644 --- a/ext/standard/tests/dir/closedir_error.phpt +++ b/ext/standard/tests/dir/closedir_error.phpt @@ -40,6 +40,6 @@ rmdir($dir_path); -- Testing closedir() function with more than expected no. of arguments -- -Warning: Wrong parameter count for closedir() in %s on line %d +Warning: closedir() expects at most 1 parameter, 2 given in %s on line %d NULL ===DONE=== diff --git a/ext/standard/tests/dir/closedir_variation1.phpt b/ext/standard/tests/dir/closedir_variation1.phpt index d5c843996d..ecc4477e35 100644 --- a/ext/standard/tests/dir/closedir_variation1.phpt +++ b/ext/standard/tests/dir/closedir_variation1.phpt @@ -92,121 +92,121 @@ foreach($inputs as $input) { -- Iteration 1 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, integer given in %s on line %d +NULL -- Iteration 2 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, integer given in %s on line %d +NULL -- Iteration 3 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, integer given in %s on line %d +NULL -- Iteration 4 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, integer given in %s on line %d +NULL -- Iteration 5 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, double given in %s on line %d +NULL -- Iteration 6 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, double given in %s on line %d +NULL -- Iteration 7 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, double given in %s on line %d +NULL -- Iteration 8 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, double given in %s on line %d +NULL -- Iteration 9 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, double given in %s on line %d +NULL -- Iteration 10 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, null given in %s on line %d +NULL -- Iteration 11 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, null given in %s on line %d +NULL -- Iteration 12 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, boolean given in %s on line %d +NULL -- Iteration 13 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, boolean given in %s on line %d +NULL -- Iteration 14 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, boolean given in %s on line %d +NULL -- Iteration 15 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, boolean given in %s on line %d +NULL -- Iteration 16 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, string given in %s on line %d +NULL -- Iteration 17 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, string given in %s on line %d +NULL -- Iteration 18 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, array given in %s on line %d +NULL -- Iteration 19 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, string given in %s on line %d +NULL -- Iteration 20 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, string given in %s on line %d +NULL -- Iteration 21 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, string given in %s on line %d +NULL -- Iteration 22 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, object given in %s on line %d +NULL -- Iteration 23 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, null given in %s on line %d +NULL -- Iteration 24 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, null given in %s on line %d +NULL ===DONE=== diff --git a/ext/standard/tests/dir/readdir_error.phpt b/ext/standard/tests/dir/readdir_error.phpt index 4b4011a136..23ba3dfa63 100644 --- a/ext/standard/tests/dir/readdir_error.phpt +++ b/ext/standard/tests/dir/readdir_error.phpt @@ -38,6 +38,6 @@ rmdir($path); -- Testing readdir() function with more than expected no. of arguments -- -Warning: Wrong parameter count for readdir() in %s on line %d +Warning: readdir() expects at most 1 parameter, 2 given in %s on line %d NULL ===DONE=== diff --git a/ext/standard/tests/dir/readdir_variation1.phpt b/ext/standard/tests/dir/readdir_variation1.phpt index b9cd85b288..7fe99703ac 100644 --- a/ext/standard/tests/dir/readdir_variation1.phpt +++ b/ext/standard/tests/dir/readdir_variation1.phpt @@ -90,121 +90,121 @@ foreach($inputs as $input) { -- Iteration 1 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, integer given in %s on line %d +NULL -- Iteration 2 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, integer given in %s on line %d +NULL -- Iteration 3 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, integer given in %s on line %d +NULL -- Iteration 4 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, integer given in %s on line %d +NULL -- Iteration 5 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, double given in %s on line %d +NULL -- Iteration 6 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, double given in %s on line %d +NULL -- Iteration 7 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, double given in %s on line %d +NULL -- Iteration 8 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, double given in %s on line %d +NULL -- Iteration 9 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, double given in %s on line %d +NULL -- Iteration 10 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, null given in %s on line %d +NULL -- Iteration 11 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, null given in %s on line %d +NULL -- Iteration 12 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, boolean given in %s on line %d +NULL -- Iteration 13 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, boolean given in %s on line %d +NULL -- Iteration 14 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, boolean given in %s on line %d +NULL -- Iteration 15 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, boolean given in %s on line %d +NULL -- Iteration 16 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, string given in %s on line %d +NULL -- Iteration 17 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, string given in %s on line %d +NULL -- Iteration 18 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, array given in %s on line %d +NULL -- Iteration 19 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, string given in %s on line %d +NULL -- Iteration 20 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, string given in %s on line %d +NULL -- Iteration 21 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, string given in %s on line %d +NULL -- Iteration 22 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, object given in %s on line %d +NULL -- Iteration 23 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, null given in %s on line %d +NULL -- Iteration 24 -- -Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: readdir() expects parameter 1 to be resource, null given in %s on line %d +NULL ===DONE=== diff --git a/ext/standard/tests/dir/rewinddir_error.phpt b/ext/standard/tests/dir/rewinddir_error.phpt index d66b24b939..b3bb02bca3 100644 --- a/ext/standard/tests/dir/rewinddir_error.phpt +++ b/ext/standard/tests/dir/rewinddir_error.phpt @@ -37,6 +37,6 @@ rmdir($dir_path); -- Testing rewinddir() function with more than expected no. of arguments -- -Warning: Wrong parameter count for rewinddir() in %s on line %d +Warning: rewinddir() expects at most 1 parameter, 2 given in %s on line %d NULL ===DONE=== diff --git a/ext/standard/tests/dir/rewinddir_variation1.phpt b/ext/standard/tests/dir/rewinddir_variation1.phpt index e1fa002c14..66cd1f657a 100644 --- a/ext/standard/tests/dir/rewinddir_variation1.phpt +++ b/ext/standard/tests/dir/rewinddir_variation1.phpt @@ -91,121 +91,121 @@ foreach($inputs as $input) { -- Iteration 1 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, integer given in %s on line %d +NULL -- Iteration 2 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, integer given in %s on line %d +NULL -- Iteration 3 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, integer given in %s on line %d +NULL -- Iteration 4 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, integer given in %s on line %d +NULL -- Iteration 5 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, double given in %s on line %d +NULL -- Iteration 6 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, double given in %s on line %d +NULL -- Iteration 7 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, double given in %s on line %d +NULL -- Iteration 8 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, double given in %s on line %d +NULL -- Iteration 9 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, double given in %s on line %d +NULL -- Iteration 10 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, null given in %s on line %d +NULL -- Iteration 11 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, null given in %s on line %d +NULL -- Iteration 12 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, boolean given in %s on line %d +NULL -- Iteration 13 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, boolean given in %s on line %d +NULL -- Iteration 14 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, boolean given in %s on line %d +NULL -- Iteration 15 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, boolean given in %s on line %d +NULL -- Iteration 16 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, string given in %s on line %d +NULL -- Iteration 17 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, string given in %s on line %d +NULL -- Iteration 18 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, array given in %s on line %d +NULL -- Iteration 19 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, string given in %s on line %d +NULL -- Iteration 20 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, string given in %s on line %d +NULL -- Iteration 21 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, string given in %s on line %d +NULL -- Iteration 22 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, object given in %s on line %d +NULL -- Iteration 23 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, null given in %s on line %d +NULL -- Iteration 24 -- -Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: rewinddir() expects parameter 1 to be resource, null given in %s on line %d +NULL ===DONE=== -- 2.40.0