helly Sun Mar 4 12:18:02 2007 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/spl spl_directory.c spl_iterators.c
/php-src/ext/spl/internal parentiterator.inc
Log:
- MFH simplify, synch docu/implementation
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.45.2.27.2.17&r2=1.45.2.27.2.18&diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.45.2.27.2.17
php-src/ext/spl/spl_directory.c:1.45.2.27.2.18
--- php-src/ext/spl/spl_directory.c:1.45.2.27.2.17 Sat Mar 3 15:08:59 2007
+++ php-src/ext/spl/spl_directory.c Sun Mar 4 12:18:02 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_directory.c,v 1.45.2.27.2.17 2007/03/03 15:08:59 helly Exp $ */
+/* $Id: spl_directory.c,v 1.45.2.27.2.18 2007/03/04 12:18:02 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -448,6 +448,18 @@
return NULL;
} /* }}} */
+static inline int spl_filesystem_is_dot(const char * d_name) /* {{{ */
+{
+ return !strcmp(d_name, ".") || !strcmp(d_name, "..");
+}
+/* }}} */
+
+static int spl_filesystem_is_invalid_or_dot(const char * d_name) /* {{{ */
+{
+ return d_name[0] == '\0' || spl_filesystem_is_dot(d_name);
+}
+/* }}} */
+
/* {{{ proto void DirectoryIterator::__construct(string path)
Cronstructs a new dir iterator from a path. */
SPL_METHOD(DirectoryIterator, __construct)
@@ -681,7 +693,7 @@
{
spl_filesystem_object *intern =
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
- RETURN_BOOL(!strcmp(intern->u.dir.entry.d_name, ".") ||
!strcmp(intern->u.dir.entry.d_name, ".."));
+ RETURN_BOOL(spl_filesystem_is_dot(intern->u.dir.entry.d_name));
}
/* }}} */
@@ -972,7 +984,7 @@
if (!intern->u.dir.dirp ||
!php_stream_readdir(intern->u.dir.dirp, &intern->u.dir.entry)) {
intern->u.dir.entry.d_name[0] = '\0';
}
- } while (!strcmp(intern->u.dir.entry.d_name, ".") ||
!strcmp(intern->u.dir.entry.d_name, ".."));
+ } while (spl_filesystem_is_dot(intern->u.dir.entry.d_name));
}
/* }}} */
@@ -987,7 +999,7 @@
if (!intern->u.dir.dirp ||
!php_stream_readdir(intern->u.dir.dirp, &intern->u.dir.entry)) {
intern->u.dir.entry.d_name[0] = '\0';
}
- } while (!strcmp(intern->u.dir.entry.d_name, ".") ||
!strcmp(intern->u.dir.entry.d_name, ".."));
+ } while (spl_filesystem_is_dot(intern->u.dir.entry.d_name));
if (intern->file_name) {
efree(intern->file_name);
intern->file_name = NULL;
@@ -1002,7 +1014,7 @@
zend_bool allow_links = 0;
spl_filesystem_object *intern =
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
- if (!strcmp(intern->u.dir.entry.d_name, ".") ||
!strcmp(intern->u.dir.entry.d_name, "..")) {
+ if (spl_filesystem_is_invalid_or_dot(intern->u.dir.entry.d_name)) {
RETURN_BOOL(0);
} else {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b",
&allow_links) == FAILURE) {
@@ -1274,7 +1286,7 @@
if (!object->u.dir.dirp ||
!php_stream_readdir(object->u.dir.dirp, &object->u.dir.entry)) {
object->u.dir.entry.d_name[0] = '\0';
}
- } while (!strcmp(object->u.dir.entry.d_name, ".") ||
!strcmp(object->u.dir.entry.d_name, ".."));
+ } while (spl_filesystem_is_dot(intern->u.dir.entry.d_name));
if (object->file_name) {
efree(object->file_name);
object->file_name = NULL;
@@ -1300,7 +1312,7 @@
if (!object->u.dir.dirp ||
!php_stream_readdir(object->u.dir.dirp, &object->u.dir.entry)) {
object->u.dir.entry.d_name[0] = '\0';
}
- } while (!strcmp(object->u.dir.entry.d_name, ".") ||
!strcmp(object->u.dir.entry.d_name, ".."));
+ } while (spl_filesystem_is_dot(intern->u.dir.entry.d_name));
if (iterator->current) {
zval_ptr_dtor(&iterator->current);
iterator->current = NULL;
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_iterators.c?r1=1.73.2.30.2.25&r2=1.73.2.30.2.26&diff_format=u
Index: php-src/ext/spl/spl_iterators.c
diff -u php-src/ext/spl/spl_iterators.c:1.73.2.30.2.25
php-src/ext/spl/spl_iterators.c:1.73.2.30.2.26
--- php-src/ext/spl/spl_iterators.c:1.73.2.30.2.25 Tue Feb 27 03:28:16 2007
+++ php-src/ext/spl/spl_iterators.c Sun Mar 4 12:18:02 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_iterators.c,v 1.73.2.30.2.25 2007/02/27 03:28:16 iliaa Exp $ */
+/* $Id: spl_iterators.c,v 1.73.2.30.2.26 2007/03/04 12:18:02 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -1336,41 +1336,6 @@
spl_dual_it_construct(INTERNAL_FUNCTION_PARAM_PASSTHRU,
spl_ce_ParentIterator, spl_ce_RecursiveIterator, DIT_ParentIterator);
} /* }}} */
-/* {{{ proto bool ParentIterator::hasChildren()
- Check whether the inner iterator's current element has children */
-SPL_METHOD(ParentIterator, hasChildren)
-{
- spl_dual_it_object *intern;
- zval *retval;
-
- intern = (spl_dual_it_object*)zend_object_store_get_object(getThis()
TSRMLS_CC);
-
- zend_call_method_with_0_params(&intern->inner.zobject,
intern->inner.ce, NULL, "haschildren", &retval);
- if (retval) {
- RETURN_ZVAL(retval, 0, 1);
- } else {
- RETURN_FALSE;
- }
-} /* }}} */
-
-/* {{{ proto ParentIterator ParentIterator::getChildren()
- Return the inner iterator's children contained in a ParentIterator */
-SPL_METHOD(ParentIterator, getChildren)
-{
- spl_dual_it_object *intern;
- zval *retval;
-
- intern = (spl_dual_it_object*)zend_object_store_get_object(getThis()
TSRMLS_CC);
-
- zend_call_method_with_0_params(&intern->inner.zobject,
intern->inner.ce, NULL, "getchildren", &retval);
- if (!EG(exception) && retval) {
- spl_instantiate_arg_ex1(Z_OBJCE_P(getThis()), &return_value, 0,
retval TSRMLS_CC);
- }
- if (retval) {
- zval_ptr_dtor(&retval);
- }
-} /* }}} */
-
#if HAVE_PCRE || HAVE_BUNDLED_PCRE
/* {{{ proto void RegexIterator::__construct(Iterator it, string regex [, int
mode [, int flags [, int preg_flags]]])
Create an RegexIterator from another iterator and a regular expression */
@@ -1665,7 +1630,6 @@
static zend_function_entry spl_funcs_RecursiveFilterIterator[] = {
SPL_ME(RecursiveFilterIterator, __construct,
arginfo_parent_it___construct, ZEND_ACC_PUBLIC)
- SPL_MA(ParentIterator, accept, RecursiveFilterIterator, hasChildren,
NULL, ZEND_ACC_PUBLIC)
SPL_ME(RecursiveFilterIterator, hasChildren, NULL,
ZEND_ACC_PUBLIC)
SPL_ME(RecursiveFilterIterator, getChildren, NULL,
ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
@@ -1673,10 +1637,7 @@
static zend_function_entry spl_funcs_ParentIterator[] = {
SPL_ME(ParentIterator, __construct,
arginfo_parent_it___construct, ZEND_ACC_PUBLIC)
- SPL_MA(ParentIterator, accept, ParentIterator, hasChildren,
NULL, ZEND_ACC_PUBLIC)
- SPL_ME(ParentIterator, hasChildren, NULL, ZEND_ACC_PUBLIC)
- SPL_ME(ParentIterator, getChildren, NULL, ZEND_ACC_PUBLIC)
- SPL_ME(dual_it, getInnerIterator, NULL, ZEND_ACC_PUBLIC)
+ SPL_MA(ParentIterator, accept, RecursiveFilterIterator,
hasChildren, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/internal/parentiterator.inc?r1=1.5.2.1&r2=1.5.2.1.2.1&diff_format=u
Index: php-src/ext/spl/internal/parentiterator.inc
diff -u php-src/ext/spl/internal/parentiterator.inc:1.5.2.1
php-src/ext/spl/internal/parentiterator.inc:1.5.2.1.2.1
--- php-src/ext/spl/internal/parentiterator.inc:1.5.2.1 Thu Sep 15 03:54:42 2005
+++ php-src/ext/spl/internal/parentiterator.inc Sun Mar 4 12:18:02 2007
@@ -4,7 +4,7 @@
* @ingroup SPL
* @brief class FilterIterator
* @author Marcus Boerger
- * @date 2003 - 2005
+ * @date 2003 - 2006
*
* SPL - Standard PHP Library
*/
@@ -21,26 +21,12 @@
*/
class ParentIterator extends RecursiveFilterIterator
{
- /** @param $it the RecursiveIterator to filter
- */
- function __construct(RecursiveIterator $it)
- {
- parent::__construct($it);
- }
-
/** @return whetehr the current element has children
*/
function accept()
{
return $this->it->hasChildren();
}
-
- /** @return the ParentIterator for the current elements children
- */
- function getChildren()
- {
- return new ParentIterator($this->it->getChildren());
- }
}
?>
\ No newline at end of file
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php