cvs: php-src /ext/spl spl_directory.c
| From: | Marcus Boerger | Date: | Wed, 17 Jan 2007 22:43:54 +0000 |
| Subject: | cvs: php-src /ext/spl spl_directory.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-42762@lists.php.net to get a copy of this message | ||
helly Wed Jan 17 22:43:54 2007 UTC
Modified files:
/php-src/ext/spl spl_directory.c
Log:
- Ensure string-type is always set correctly
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.111&r2=1.112&diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.111 php-src/ext/spl/spl_directory.c:1.112
--- php-src/ext/spl/spl_directory.c:1.111 Wed Jan 17 21:29:38 2007
+++ php-src/ext/spl/spl_directory.c Wed Jan 17 22:43:53 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_directory.c,v 1.111 2007/01/17 21:29:38 helly Exp $ */
+/* $Id: spl_directory.c,v 1.112 2007/01/17 22:43:53 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -165,9 +165,9 @@
break;
case SPL_FS_DIR:
if (intern->path_type == IS_UNICODE) {
- intern->file_name_len = spprintf(&intern->file_name.s, 0, "%s%c%s",
intern->path, DEFAULT_SLASH, intern->u.dir.entry.d_name);
- } else {
intern->file_name_len = uspprintf(&intern->file_name.s, 0, "%r%c%s",
intern->path, DEFAULT_SLASH, intern->u.dir.entry.d_name);
+ } else {
+ intern->file_name_len = spprintf(&intern->file_name.s, 0, "%s%c%s",
intern->path, DEFAULT_SLASH, intern->u.dir.entry.d_name);
}
intern->file_name_type = intern->path_type;
break;
@@ -266,8 +266,10 @@
switch (source->type) {
case SPL_FS_INFO:
+ intern->path_type = source->path_type;
intern->path_len = source->path_len;
intern->path = ezstrndup(source->path_type, source->path, source->path_len);
+ intern->file_name_type = source->file_name_type;
intern->file_name_len = source->file_name_len;
intern->file_name = ezstrndup(source->file_name_type, source->file_name,
intern->file_name_len);
break;
@@ -299,6 +301,7 @@
{
zstr p1, p2;
+ intern->file_name_type = type;
intern->file_name = use_copy ? ezstrndup(type, path, len) : path;
intern->file_name_len = len;
@@ -325,6 +328,7 @@
} else {
intern->path_len = 0;
}
+ intern->path_type = type;
intern->path = ezstrndup(type, path, intern->path_len);
} /* }}} */
@@ -395,10 +399,12 @@
zend_call_method_with_1_params(&return_value, ce, &ce->constructor,
"__construct", NULL, arg1);
zval_ptr_dtor(&arg1);
} else {
- intern->file_name = ezstrndup(source->file_name_type, source->file_name,
source->file_name_len);
- intern->file_name_len = source->file_name_len;
- intern->path = ezstrndup(source->path_type, source->path, source->path_len);
+ intern->path_type = source->path_type;
intern->path_len = source->path_len;
+ intern->path = ezstrndup(source->path_type, source->path, source->path_len);
+ intern->file_name_type = source->file_name_type;
+ intern->file_name_len = source->file_name_len;
+ intern->file_name = ezstrndup(source->file_name_type, source->file_name,
source->file_name_len);
}
break;
case SPL_FS_FILE:
@@ -417,10 +423,12 @@
zval_ptr_dtor(&arg1);
zval_ptr_dtor(&arg2);
} else {
- intern->file_name = source->file_name;
- intern->file_name_len = source->file_name_len;
- intern->path = ezstrndup(source->path_type, source->path, source->path_len);
+ intern->path_type = source->path_type;
intern->path_len = source->path_len;
+ intern->path = ezstrndup(source->path_type, source->path, source->path_len);
+ intern->file_name_type = source->file_name_type;
+ intern->file_name_len = source->file_name_len;
+ intern->file_name = source->file_name;
intern->u.file.open_mode = "r";
intern->u.file.open_mode_len = 1;
@@ -573,7 +581,7 @@
} else {
ret.s = intern->file_name.s + intern->path_len + 1;
}
- RETURN_ZSTRL(intern->file_name_type, ret, intern->file_name_len - (intern->path_len +
1), 1);
+ RETURN_ZSTRL(intern->file_name_type, ret, intern->file_name_len - (intern->path_len +
1), ZSTR_DUPLICATE);
} else {
RETURN_ZSTRL(intern->file_name_type, intern->file_name, intern->file_name_len,
ZSTR_DUPLICATE);
}
@@ -1647,6 +1655,7 @@
} else {
intern->path_len = 0;
}
+ intern->path_type = intern->file_name_type;
intern->path = ezstrndup(intern->file_name_type, intern->file_name,
intern->path_len);
}