summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>2000-06-27 18:44:30 +0000
committerZeev Suraski <zeev@php.net>2000-06-27 18:44:30 +0000
commitc860633741a1931d9f9e5298b21a8dc8efbc0fad (patch)
tree7d5d33a0f8a1b7196b3897e82f02de95e9e9c35e
parent130b9e7ef248be3beffa72b2ee7183af16d3b86d (diff)
downloadphp-git-c860633741a1931d9f9e5298b21a8dc8efbc0fad.tar.gz
Fixed a bug in opendir(), which prevented readdir() from working properly if
the $dir argument wasn't explicitly specified
-rw-r--r--NEWS10
-rw-r--r--ext/standard/dir.c34
2 files changed, 31 insertions, 13 deletions
diff --git a/NEWS b/NEWS
index 8242d52931..d9f922e920 100644
--- a/NEWS
+++ b/NEWS
@@ -2,7 +2,9 @@ PHP 4.0 NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
28 Jun 2000, Version 4.0.1
-- Make --enable-discard-path work again. (Andi)
+- Fixed a bug in opendir(), which prevented readdir() from working properly if
+ the $dir argument wasn't explicitly specified (Zeev)
+- Made --enable-discard-path work again. (Andi)
- Removed 8KB limit on line length of the file() function (Zeev)
- Disabled dl() when PHP is being used as a module inside a multithreaded web
server - it didn't work before, and caused weird results (Zeev)
@@ -96,8 +98,8 @@ PHP 4.0 NEWS
- Clean up constants in flock() function and add optional 3rd arg which
is set to true on EWOULDBLOCK (Rasmus)
- Added functions pg_loimport(), pg_loexport(). (Jouni)
-- Add SWF support to getimagesize() function (Derick Rethans)
-- Add support for both indexed and non-indexed arrays of file uploads
+- Added SWF support to getimagesize() function (Derick Rethans)
+- Added support for both indexed and non-indexed arrays of file uploads
eg. name="file[]" type="file" (Rasmus)
- Added create_function(), which gives the ability to create functions
on-the-fly (Zeev, Zend Engine)
@@ -151,7 +153,7 @@ PHP 4.0 NEWS
jpeg images it generates. (Rasmus)
- Fixed basename() bug where "file.ext///" would not return the same
as "/path/file.ext///" (Rasmus)
-- Add the swf_ortho function. (Sterling)
+- Added the swf_ortho function. (Sterling)
- Moved to virtual current working directory support. This highly improves the
functionality and stability of multi-threaded versions of PHP (Andi, Sascha)
diff --git a/ext/standard/dir.c b/ext/standard/dir.c
index 73f9cb8f9a..c2e9a98822 100644
--- a/ext/standard/dir.c
+++ b/ext/standard/dir.c
@@ -45,12 +45,20 @@ typedef struct {
} php_dir_globals;
#ifdef ZTS
-#define DIR(v) (dir_globals->v)
+#define DIRG(v) (dir_globals->v)
#define DIRLS_FETCH() php_dir_globals *dir_globals = ts_resource(dir_globals_id)
+#define DIRLS_D php_dir_globals *dir_globals
+#define DIRLS_DC , DIRLS_D
+#define DIRLS_C dir_globals
+#define DIRLS_CC , DIRLS_C
int dir_globals_id;
#else
-#define DIR(v) (dir_globals.v)
+#define DIRG(v) (dir_globals.v)
#define DIRLS_FETCH()
+#define DIRLS_D
+#define DIRLS_DC
+#define DIRLS_C
+#define DIRLS_CC
php_dir_globals dir_globals;
#endif
@@ -73,7 +81,7 @@ static zend_class_entry *dir_class_entry_ptr;
} \
ZEND_FETCH_RESOURCE(dirp,php_dir *,tmp,-1, "Directory", le_dirp); \
} else { \
- ZEND_FETCH_RESOURCE(dirp,php_dir *,0,DIR(default_dir), "Directory", le_dirp); \
+ ZEND_FETCH_RESOURCE(dirp,php_dir *,0,DIRG(default_dir), "Directory", le_dirp); \
} \
} else if ((ZEND_NUM_ARGS() != 1) || zend_get_parameters_ex(1, &id) == FAILURE) { \
WRONG_PARAM_COUNT; \
@@ -89,18 +97,26 @@ static zend_function_entry php_dir_class_functions[] = {
};
+static void php_set_default_dir(int id DIRLS_DC)
+{
+ if (DIRG(default_dir)!=-1) {
+ zend_list_delete(DIRG(default_dir));
+ }
+ DIRG(default_dir) = id;
+ zend_list_addref(id);
+}
+
+
static void _dir_dtor(php_dir *dirp)
{
closedir(dirp->dir);
efree(dirp);
}
-#ifdef ZTS
-static void php_dir_init_globals(php_dir_globals *dir_globals)
+static void php_dir_init_globals(DIRLS_D)
{
- DIR(default_dir) = 0;
+ DIRG(default_dir) = -1;
}
-#endif
PHP_MINIT_FUNCTION(dir)
{
@@ -114,7 +130,7 @@ PHP_MINIT_FUNCTION(dir)
#ifdef ZTS
dir_globals_id = ts_allocate_id(sizeof(php_dir_globals), (ts_allocate_ctor) php_dir_init_globals, NULL);
#else
- DIR(default_dir) = 0;
+ php_dir_init_globals(DIRLS_C);
#endif
return SUCCESS;
@@ -150,7 +166,7 @@ static void _php_do_opendir(INTERNAL_FUNCTION_PARAMETERS, int createobject)
dirp->id = zend_list_insert(dirp,le_dirp);
- DIR(default_dir) = dirp->id;
+ php_set_default_dir(dirp->id DIRLS_CC);
if (createobject) {
object_init_ex(return_value, dir_class_entry_ptr);