[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_directory.h

2009-07-07 Thread Ilia Alshanetsky
iliaa   Wed Jul  8 03:09:59 2009 UTC

  Modified files:  
/php-src/ext/splspl_directory.c spl_directory.h 
  Log:
  
  MFB: Fixed bug #48788 (RecursiveDirectoryIterator doesn't descend into
  symlinked
  directories). 
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.185r2=1.186diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.185 
php-src/ext/spl/spl_directory.c:1.186
--- php-src/ext/spl/spl_directory.c:1.185   Sat Jul  4 20:28:15 2009
+++ php-src/ext/spl/spl_directory.c Wed Jul  8 03:09:58 2009
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.185 2009/07/04 20:28:15 felipe Exp $ */
+/* $Id: spl_directory.c,v 1.186 2009/07/08 03:09:58 iliaa Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1364,7 +1364,7 @@
return;
}
spl_filesystem_object_get_file_name(intern TSRMLS_CC);
-   if (!allow_links) {
+   if (!allow_links  !(intern-flags  
SPL_FILE_DIR_FOLLOW_SYMLINKS)) {
php_u_stat(intern-file_name_type, intern-file_name, 
intern-file_name_len, FS_IS_LINK, FG(default_context), return_value TSRMLS_CC);
if (zend_is_true(return_value)) {
RETURN_FALSE;
@@ -2787,6 +2787,7 @@
REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, CURRENT_AS_SELF,
 SPL_FILE_DIR_CURRENT_AS_SELF);
REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, KEY_MODE_MASK,  
 SPL_FILE_DIR_KEY_MODE_MASK);
REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, KEY_AS_PATHNAME,
 SPL_FILE_DIR_KEY_AS_PATHNAME);
+   REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, FOLLOW_SYMLINKS,
 SPL_FILE_DIR_FOLLOW_SYMLINKS);
REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, KEY_AS_FILENAME,
 SPL_FILE_DIR_KEY_AS_FILENAME);
REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, 
NEW_CURRENT_AND_KEY, 
SPL_FILE_DIR_KEY_AS_FILENAME|SPL_FILE_DIR_CURRENT_AS_FILEINFO);
REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, SKIP_DOTS,  
 SPL_FILE_DIR_SKIPDOTS);
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.h?r1=1.49r2=1.50diff_format=u
Index: php-src/ext/spl/spl_directory.h
diff -u php-src/ext/spl/spl_directory.h:1.49 
php-src/ext/spl/spl_directory.h:1.50
--- php-src/ext/spl/spl_directory.h:1.49Thu Jun  4 14:46:08 2009
+++ php-src/ext/spl/spl_directory.h Wed Jul  8 03:09:58 2009
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.h,v 1.49 2009/06/04 14:46:08 colder Exp $ */
+/* $Id: spl_directory.h,v 1.50 2009/07/08 03:09:58 iliaa Exp $ */
 
 #ifndef SPL_DIRECTORY_H
 #define SPL_DIRECTORY_H
@@ -131,6 +131,7 @@
 
 #define SPL_FILE_DIR_KEY_AS_PATHNAME   0x /* make 
RecursiveDirectoryTree::key() return getPathname() */
 #define SPL_FILE_DIR_KEY_AS_FILENAME   0x0100 /* make 
RecursiveDirectoryTree::key() return getFilename() */
+#define SPL_FILE_DIR_FOLLOW_SYMLINKS   0x0200 /* make 
RecursiveDirectoryTree::hasChildren() follow symlinks */
 #define SPL_FILE_DIR_KEY_MODE_MASK 0x0F00 /* mask 
RecursiveDirectoryTree::key() */
 #define SPL_FILE_DIR_KEY(intern,mode)  
((intern-flagsSPL_FILE_DIR_KEY_MODE_MASK)==mode)
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2009-06-24 Thread Dmitry Stogov
dmitry  Wed Jun 24 08:53:44 2009 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  Fixed bug #48643 (String functions memory issue)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.183r2=1.184diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.183 
php-src/ext/spl/spl_directory.c:1.184
--- php-src/ext/spl/spl_directory.c:1.183   Thu Jun  4 14:46:08 2009
+++ php-src/ext/spl/spl_directory.c Wed Jun 24 08:53:44 2009
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.183 2009/06/04 14:46:08 colder Exp $ */
+/* $Id: spl_directory.c,v 1.184 2009/06/24 08:53:44 dmitry Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1723,37 +1723,53 @@
 static int spl_filesystem_object_cast(zval *readobj, zval *writeobj, int type, 
void *extra TSRMLS_DC)
 {
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(readobj TSRMLS_CC);
+   int ret;
+   zval retval;
+   zval *retval_ptr = retval;
 
switch (intern-type) {
case SPL_FS_INFO:
case SPL_FS_FILE:
if (type == intern-file_name_type) {
-   ZVAL_ZSTRL(writeobj, intern-file_name_type, 
intern-file_name, intern-file_name_len, 1);
-   return SUCCESS;
+   ZVAL_ZSTRL(retval_ptr, intern-file_name_type, 
intern-file_name, intern-file_name_len, 1);
+   ret = SUCCESS;
+   break;
}
if (type == IS_STRING) {
-   ZVAL_ZSTRL(writeobj, intern-file_name_type, 
intern-file_name, intern-file_name_len, ZSTR_DUPLICATE);
-   zval_unicode_to_string_ex(writeobj, 
ZEND_U_CONVERTER(((UConverter *)extra)) TSRMLS_CC);
-   return SUCCESS;
+   ZVAL_ZSTRL(retval_ptr, intern-file_name_type, 
intern-file_name, intern-file_name_len, ZSTR_DUPLICATE);
+   zval_unicode_to_string_ex(retval_ptr, 
ZEND_U_CONVERTER(((UConverter *)extra)) TSRMLS_CC);
+   ret = SUCCESS;
+   break;
}
if (type == IS_UNICODE) {
-   ZVAL_ASCII_STRINGL(writeobj, intern-file_name.s, 
intern-file_name_len, 1);
-   return SUCCESS;
+   ZVAL_ASCII_STRINGL(retval_ptr, intern-file_name.s, 
intern-file_name_len, 1);
+   ret = SUCCESS;
+   break;
}
+   ZVAL_NULL(retval_ptr);
+   ret = FAILURE;
break;
case SPL_FS_DIR:
if (type == IS_STRING) {
-   ZVAL_STRING(writeobj, intern-u.dir.entry.d_name, 1);
-   return SUCCESS;
+   ZVAL_STRING(retval_ptr, intern-u.dir.entry.d_name, 1);
+   ret = SUCCESS;
+   break;
}
if (type == IS_UNICODE) {
-   ZVAL_ASCII_STRING(writeobj, intern-u.dir.entry.d_name, 
1);
-   return SUCCESS;
+   ZVAL_ASCII_STRING(retval_ptr, 
intern-u.dir.entry.d_name, 1);
+   ret = SUCCESS;
+   break;
}
-   break;
+   default:
+   ZVAL_NULL(retval_ptr);
+   ret = FAILURE;
+   break;  
+   }
+   if (readobj == writeobj) {
+   zval_dtor(readobj);
}
-   ZVAL_NULL(writeobj);
-   return FAILURE;
+   ZVAL_ZVAL(writeobj, retval_ptr, 0, 0);
+   return ret;
 }
 /* }}} */
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2009-06-24 Thread Jani Taskinen

This was reported for PHP_5_2, did you intentionally not MFH? :)

--Jani

Dmitry Stogov wrote:

dmitry  Wed Jun 24 08:53:44 2009 UTC

  Modified files:  
/php-src/ext/spl	spl_directory.c 
  Log:

  Fixed bug #48643 (String functions memory issue)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.183r2=1.184diff_format=u

Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.183 
php-src/ext/spl/spl_directory.c:1.184
--- php-src/ext/spl/spl_directory.c:1.183   Thu Jun  4 14:46:08 2009
+++ php-src/ext/spl/spl_directory.c Wed Jun 24 08:53:44 2009
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.183 2009/06/04 14:46:08 colder Exp $ */

+/* $Id: spl_directory.c,v 1.184 2009/06/24 08:53:44 dmitry Exp $ */
 
 #ifdef HAVE_CONFIG_H

 # include config.h
@@ -1723,37 +1723,53 @@
 static int spl_filesystem_object_cast(zval *readobj, zval *writeobj, int type, 
void *extra TSRMLS_DC)
 {
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(readobj TSRMLS_CC);
+   int ret;
+   zval retval;
+   zval *retval_ptr = retval;
 
 	switch (intern-type) {

case SPL_FS_INFO:
case SPL_FS_FILE:
if (type == intern-file_name_type) {
-   ZVAL_ZSTRL(writeobj, intern-file_name_type, 
intern-file_name, intern-file_name_len, 1);
-   return SUCCESS;
+   ZVAL_ZSTRL(retval_ptr, intern-file_name_type, 
intern-file_name, intern-file_name_len, 1);
+   ret = SUCCESS;
+   break;
}
if (type == IS_STRING) {
-   ZVAL_ZSTRL(writeobj, intern-file_name_type, 
intern-file_name, intern-file_name_len, ZSTR_DUPLICATE);
-   zval_unicode_to_string_ex(writeobj, 
ZEND_U_CONVERTER(((UConverter *)extra)) TSRMLS_CC);
-   return SUCCESS;
+   ZVAL_ZSTRL(retval_ptr, intern-file_name_type, 
intern-file_name, intern-file_name_len, ZSTR_DUPLICATE);
+   zval_unicode_to_string_ex(retval_ptr, 
ZEND_U_CONVERTER(((UConverter *)extra)) TSRMLS_CC);
+   ret = SUCCESS;
+   break;
}
if (type == IS_UNICODE) {
-   ZVAL_ASCII_STRINGL(writeobj, intern-file_name.s, 
intern-file_name_len, 1);
-   return SUCCESS;
+   ZVAL_ASCII_STRINGL(retval_ptr, intern-file_name.s, 
intern-file_name_len, 1);
+   ret = SUCCESS;
+   break;
}
+   ZVAL_NULL(retval_ptr);
+   ret = FAILURE;
break;
case SPL_FS_DIR:
if (type == IS_STRING) {
-   ZVAL_STRING(writeobj, intern-u.dir.entry.d_name, 1);
-   return SUCCESS;
+   ZVAL_STRING(retval_ptr, intern-u.dir.entry.d_name, 1);
+   ret = SUCCESS;
+   break;
}
if (type == IS_UNICODE) {
-   ZVAL_ASCII_STRING(writeobj, intern-u.dir.entry.d_name, 
1);
-   return SUCCESS;
+   ZVAL_ASCII_STRING(retval_ptr, 
intern-u.dir.entry.d_name, 1);
+   ret = SUCCESS;
+   break;
}
-   break;
+   default:
+   ZVAL_NULL(retval_ptr);
+   ret = FAILURE;
+   break;  
+   }
+   if (readobj == writeobj) {
+   zval_dtor(readobj);
}
-   ZVAL_NULL(writeobj);
-   return FAILURE;
+   ZVAL_ZVAL(writeobj, retval_ptr, 0, 0);
+   return ret;
 }
 /* }}} */
 







--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_directory.h

2009-06-04 Thread Etienne Kneuss
colder  Thu Jun  4 14:46:08 2009 UTC

  Modified files:  
/php-src/ext/splspl_directory.c spl_directory.h 
  Log:
  Include other flags as well
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.182r2=1.183diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.182 
php-src/ext/spl/spl_directory.c:1.183
--- php-src/ext/spl/spl_directory.c:1.182   Mon May 25 14:32:14 2009
+++ php-src/ext/spl/spl_directory.c Thu Jun  4 14:46:08 2009
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.182 2009/05/25 14:32:14 felipe Exp $ */
+/* $Id: spl_directory.c,v 1.183 2009/06/04 14:46:08 colder Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1334,7 +1334,7 @@
 {
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
-   RETURN_LONG(intern-flags  (SPL_FILE_DIR_KEY_MODE_MASK | 
SPL_FILE_DIR_CURRENT_MODE_MASK));
+   RETURN_LONG(intern-flags  (SPL_FILE_DIR_KEY_MODE_MASK | 
SPL_FILE_DIR_CURRENT_MODE_MASK | SPL_FILE_DIR_OTHERS_MASK));
 } /* }}} */
 
 /* {{{ proto void FilesystemIterator::setFlags(long $flags) U
@@ -1346,8 +1346,8 @@
 
zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, l, flags);
 
-   intern-flags = 
~(SPL_FILE_DIR_KEY_MODE_MASK|SPL_FILE_DIR_CURRENT_MODE_MASK);
-   intern-flags |= 
((SPL_FILE_DIR_KEY_MODE_MASK|SPL_FILE_DIR_CURRENT_MODE_MASK)  flags);
+   intern-flags = 
~(SPL_FILE_DIR_KEY_MODE_MASK|SPL_FILE_DIR_CURRENT_MODE_MASK|SPL_FILE_DIR_OTHERS_MASK);
+   intern-flags |= 
((SPL_FILE_DIR_KEY_MODE_MASK|SPL_FILE_DIR_CURRENT_MODE_MASK|SPL_FILE_DIR_OTHERS_MASK)
  flags);
 } /* }}} */
 
 /* {{{ proto bool RecursiveDirectoryIterator::hasChildren([bool $allow_links = 
false]) U
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.h?r1=1.48r2=1.49diff_format=u
Index: php-src/ext/spl/spl_directory.h
diff -u php-src/ext/spl/spl_directory.h:1.48 
php-src/ext/spl/spl_directory.h:1.49
--- php-src/ext/spl/spl_directory.h:1.48Tue Mar 10 23:39:38 2009
+++ php-src/ext/spl/spl_directory.h Thu Jun  4 14:46:08 2009
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.h,v 1.48 2009/03/10 23:39:38 helly Exp $ */
+/* $Id: spl_directory.h,v 1.49 2009/06/04 14:46:08 colder Exp $ */
 
 #ifndef SPL_DIRECTORY_H
 #define SPL_DIRECTORY_H
@@ -137,6 +137,7 @@
 
 #define SPL_FILE_DIR_SKIPDOTS  0x1000 /* Tells whether it 
should skip dots or not */
 #define SPL_FILE_DIR_UNIXPATHS 0x2000 /* Whether to unixify 
path separators */
+#define SPL_FILE_DIR_OTHERS_MASK   0x3000 /* mask used for 
get/setFlags */
 
 #endif /* SPL_DIRECTORY_H */
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c /ext/spl/tests bug47534.phpt

2009-05-09 Thread Etienne Kneuss
colder  Sat May  9 21:05:18 2009 UTC

  Modified files:  
/php-src/ext/spl/tests  bug47534.phpt 
/php-src/ext/splspl_directory.c 
  Log:
  Fix bug #47534 (RecursiveDirectoryIterator::getChildren ignoring 
CURRENT_AS_PATHNAME)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/bug47534.phpt?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/spl/tests/bug47534.phpt
diff -u /dev/null php-src/ext/spl/tests/bug47534.phpt:1.2
--- /dev/null   Sat May  9 21:05:18 2009
+++ php-src/ext/spl/tests/bug47534.phpt Sat May  9 21:05:18 2009
@@ -0,0 +1,14 @@
+--TEST--
+SPL: RecursiveDirectoryIterator bug 47534
+--FILE--
+?php
+$it1 = new RecursiveDirectoryIterator(dirname(__FILE__), 
FileSystemIterator::CURRENT_AS_PATHNAME);
+$it1-rewind();
+echo gettype($it1-current()).\n;
+
+$it2 = new RecursiveDirectoryIterator(dirname(__FILE__));
+$it2-rewind();
+echo gettype($it2-current()).\n;
+--EXPECT--
+unicode
+object
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.180r2=1.181diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.180 
php-src/ext/spl/spl_directory.c:1.181
--- php-src/ext/spl/spl_directory.c:1.180   Thu Mar 26 20:02:12 2009
+++ php-src/ext/spl/spl_directory.c Sat May  9 21:05:18 2009
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.180 2009/03/26 20:02:12 felipe Exp $ */
+/* $Id: spl_directory.c,v 1.181 2009/05/09 21:05:18 colder Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1386,28 +1386,32 @@

spl_filesystem_object_get_file_name(intern TSRMLS_CC);
 
-   INIT_PZVAL(zflags);
-   INIT_PZVAL(zpath);
-   ZVAL_LONG(zflags, intern-flags);
-   ZVAL_ZSTRL(zpath, intern-file_name_type, intern-file_name, 
intern-file_name_len, 1);
-
-   spl_instantiate_arg_ex2(Z_OBJCE_P(getThis()), return_value, 0, zpath, 
zflags TSRMLS_CC);
-
-   zval_dtor(zpath);
-
-   subdir = 
(spl_filesystem_object*)zend_object_store_get_object(return_value TSRMLS_CC);
-   if (subdir) {
-   if (intern-u.dir.sub_path.v  intern-u.dir.sub_path_len  1) 
{
-   subdir-u.dir.sub_path_type = 
intern-u.dir.sub_path_type;
-   subdir-u.dir.sub_path_len = 
zspprintf(intern-u.dir.sub_path_type, subdir-u.dir.sub_path, 0, %R%c%s, 
intern-u.dir.sub_path_type, intern-u.dir.sub_path, slash, 
intern-u.dir.entry.d_name);
-   } else {
-   subdir-u.dir.sub_path_len = 
strlen(intern-u.dir.entry.d_name);
-   subdir-u.dir.sub_path_type = IS_STRING;
-   subdir-u.dir.sub_path.s = 
estrndup(intern-u.dir.entry.d_name, subdir-u.dir.sub_path_len);
-   }
-   subdir-info_class = intern-info_class;
-   subdir-file_class = intern-file_class;
-   subdir-oth = intern-oth;
+   if (SPL_HAS_FLAG(intern-flags, SPL_FILE_DIR_CURRENT_AS_PATHNAME)) {
+   RETURN_ZSTRL(intern-file_name_type, intern-file_name, 
intern-file_name_len, 1);
+   } else {
+   INIT_PZVAL(zflags);
+   INIT_PZVAL(zpath);
+   ZVAL_LONG(zflags, intern-flags);
+   ZVAL_ZSTRL(zpath, intern-file_name_type, intern-file_name, 
intern-file_name_len, 1);
+
+   spl_instantiate_arg_ex2(Z_OBJCE_P(getThis()), return_value, 0, 
zpath, zflags TSRMLS_CC);
+
+   zval_dtor(zpath);
+
+   subdir = 
(spl_filesystem_object*)zend_object_store_get_object(return_value TSRMLS_CC);
+   if (subdir) {
+   if (intern-u.dir.sub_path.v  
intern-u.dir.sub_path_len  1) {
+   subdir-u.dir.sub_path_type = 
intern-u.dir.sub_path_type;
+   subdir-u.dir.sub_path_len = 
zspprintf(intern-u.dir.sub_path_type, subdir-u.dir.sub_path, 0, %R%c%s, 
intern-u.dir.sub_path_type, intern-u.dir.sub_path, slash, 
intern-u.dir.entry.d_name);
+   } else {
+   subdir-u.dir.sub_path_len = 
strlen(intern-u.dir.entry.d_name);
+   subdir-u.dir.sub_path_type = IS_STRING;
+   subdir-u.dir.sub_path.s = 
estrndup(intern-u.dir.entry.d_name, subdir-u.dir.sub_path_len);
+   }
+   subdir-info_class = intern-info_class;
+   subdir-file_class = intern-file_class;
+   subdir-oth = intern-oth;
+   }
}
 }
 /* }}} */



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2009-03-10 Thread Marcus Boerger
helly   Tue Mar 10 23:27:59 2009 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - Safer flag handling as requested by Greg
  http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.177r2=1.178diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.177 
php-src/ext/spl/spl_directory.c:1.178
--- php-src/ext/spl/spl_directory.c:1.177   Wed Dec 31 11:12:36 2008
+++ php-src/ext/spl/spl_directory.c Tue Mar 10 23:27:59 2009
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.177 2008/12/31 11:12:36 sebastian Exp $ */
+/* $Id: spl_directory.c,v 1.178 2009/03/10 23:27:59 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -44,6 +44,8 @@
 #include ext/standard/basic_functions.h
 #include ext/standard/php_filestat.h
 
+#define SPL_HAS_FLAG(flags, test_flag) ((flags  test_flag) ? 1 : 0)
+
 /* declare the class handlers */
 static zend_object_handlers spl_filesystem_object_handlers;
 
@@ -185,7 +187,7 @@
 {
zstr path;
zend_uchar path_type;
-   char slash = intern-flags  SPL_FILE_DIR_UNIXPATHS ? '/' : 
DEFAULT_SLASH;
+   char slash = SPL_HAS_FLAG(intern-flags, SPL_FILE_DIR_UNIXPATHS) ? '/' 
: DEFAULT_SLASH;
 
if (!intern-file_name.v) {
switch (intern-type) {
@@ -228,7 +230,7 @@
 static void spl_filesystem_dir_open(spl_filesystem_object* intern, zend_uchar 
type, zstr path, int path_len TSRMLS_DC)
 {
int options = REPORT_ERRORS;
-   int skip_dots = intern-flags  SPL_FILE_DIR_SKIPDOTS;
+   int skip_dots = SPL_HAS_FLAG(intern-flags, SPL_FILE_DIR_SKIPDOTS);
 
 #if HELLY_0
if (php_stream_is(intern-u.dir.dirp, php_glob_stream_ops)) {
@@ -322,7 +324,7 @@
old_object = zend_objects_get_address(zobject TSRMLS_CC);
source = (spl_filesystem_object*)old_object;
 
-   skip_dots = source-flags  SPL_FILE_DIR_SKIPDOTS;
+   skip_dots = SPL_HAS_FLAG(source-flags, SPL_FILE_DIR_SKIPDOTS);
 
new_obj_val = spl_filesystem_object_new_ex(old_object-ce, intern 
TSRMLS_CC);
new_object = intern-std;
@@ -666,7 +668,7 @@
 
 UChar u_glob[sizeof(glob://)];
 
-void spl_filesystem_object_construct(INTERNAL_FUNCTION_PARAMETERS, int 
ctor_flags) /* {{{ */
+void spl_filesystem_object_construct(INTERNAL_FUNCTION_PARAMETERS, long 
ctor_flags) /* {{{ */
 {
spl_filesystem_object *intern;
zstr path;
@@ -677,7 +679,7 @@

zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, 
error_handling TSRMLS_CC);
 
-   if (ctor_flags  DIT_CTOR_FLAGS) {
+   if (SPL_HAS_FLAG(ctor_flags, DIT_CTOR_FLAGS)) {
flags = 
SPL_FILE_DIR_KEY_AS_PATHNAME|SPL_FILE_DIR_CURRENT_AS_FILEINFO;
parsed = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, 
t|l, path, len, path_type, flags);
} else {
@@ -685,11 +687,11 @@
parsed = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t, 
path, len, path_type);
}
 
-   if (ctor_flags  SPL_FILE_DIR_SKIPDOTS) {
+   if (SPL_HAS_FLAG(ctor_flags, SPL_FILE_DIR_SKIPDOTS)) {
flags |= SPL_FILE_DIR_SKIPDOTS;
}
 
-   if (ctor_flags  SPL_FILE_DIR_UNIXPATHS) {
+   if (SPL_HAS_FLAG(ctor_flags, SPL_FILE_DIR_UNIXPATHS)) {
flags |= SPL_FILE_DIR_UNIXPATHS;
}
 
@@ -706,7 +708,7 @@
intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() 
TSRMLS_CC);
intern-flags = flags;
 
-   if ((ctor_flags  DIT_CTOR_GLOB)  (
+   if (SPL_HAS_FLAG(ctor_flags, DIT_CTOR_GLOB)  (
(path_type == IS_STRING  strstr(path.s, glob://) != path.s) 
||
(path_type == IS_UNICODE  u_strstr(path.u, u_glob) != path.u)
)) {
@@ -771,7 +773,7 @@
 SPL_METHOD(DirectoryIterator, next)
 {
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
-   int skip_dots = intern-flags  SPL_FILE_DIR_SKIPDOTS;
+   int skip_dots = SPL_HAS_FLAG(intern-flags, SPL_FILE_DIR_SKIPDOTS);
 
intern-u.dir.index++;
do {
@@ -1388,7 +1390,7 @@
zval zpath, zflags;
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
spl_filesystem_object *subdir;
-   char slash = intern-flags  SPL_FILE_DIR_UNIXPATHS ? '/' : 
DEFAULT_SLASH;
+   char slash = SPL_HAS_FLAG(intern-flags, SPL_FILE_DIR_UNIXPATHS) ? '/' 
: DEFAULT_SLASH;

spl_filesystem_object_get_file_name(intern TSRMLS_CC);
 
@@ -1439,7 +1441,7 @@
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
zstr sub_name;
int sub_len;
-   char slash = intern-flags  SPL_FILE_DIR_UNIXPATHS ? '/' : 
DEFAULT_SLASH;
+   char slash = SPL_HAS_FLAG(intern-flags, SPL_FILE_DIR_UNIXPATHS) 

[PHP-CVS] cvs: php-src /ext/spl spl_directory.c ZendEngine2 zend_closures.c zend_interfaces.c zend_interfaces.h

2008-12-22 Thread Etienne Kneuss
colder  Mon Dec 22 13:50:43 2008 UTC

  Modified files:  
/ZendEngine2zend_closures.c zend_interfaces.c zend_interfaces.h 
/php-src/ext/splspl_directory.c 
  Log:
  Fix #46646 (Implement zend functions to restrict serialization or internal 
classes)
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_closures.c?r1=1.15r2=1.16diff_format=u
Index: ZendEngine2/zend_closures.c
diff -u ZendEngine2/zend_closures.c:1.15 ZendEngine2/zend_closures.c:1.16
--- ZendEngine2/zend_closures.c:1.15Thu Nov 27 19:02:44 2008
+++ ZendEngine2/zend_closures.c Mon Dec 22 13:50:43 2008
@@ -17,11 +17,12 @@
+--+
 */
 
-/* $Id: zend_closures.c,v 1.15 2008/11/27 19:02:44 dmitry Exp $ */
+/* $Id: zend_closures.c,v 1.16 2008/12/22 13:50:43 colder Exp $ */
 
 #include zend.h
 #include zend_API.h
 #include zend_closures.h
+#include zend_interfaces.h
 #include zend_objects.h
 #include zend_objects_API.h
 #include zend_globals.h
@@ -78,20 +79,6 @@
 }
 /* }}} */
 
-static int zend_closure_serialize(zval *object, int *type, zstr *buffer, 
zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC) /* {{{ */
-{
-   zend_error(E_RECOVERABLE_ERROR, Serialization of 'Closure' is not 
allowed);
-   return FAILURE;
-}
-/* }}} */
-
-static int zend_closure_unserialize(zval **object, zend_class_entry *ce, int 
type, const zstr buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC) 
/* {{{ */
-{
-   zend_error(E_RECOVERABLE_ERROR, Unserialization of 'Closure' is not 
allowed);
-   return FAILURE;
-}
-/* }}} */
-
 static int zend_closure_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */
 {
return (Z_OBJ_HANDLE_P(o1) != Z_OBJ_HANDLE_P(o2));
@@ -247,8 +234,8 @@
zend_ce_closure = zend_register_internal_class(ce TSRMLS_CC);
zend_ce_closure-ce_flags |= ZEND_ACC_FINAL_CLASS;
zend_ce_closure-create_object = zend_closure_new;
-   zend_ce_closure-serialize = zend_closure_serialize;
-   zend_ce_closure-unserialize = zend_closure_unserialize;
+   zend_ce_closure-serialize = zend_class_serialize_deny;
+   zend_ce_closure-unserialize = zend_class_unserialize_deny;
 
memcpy(closure_handlers, zend_get_std_object_handlers(), 
sizeof(zend_object_handlers));
closure_handlers.get_constructor = zend_closure_get_constructor;
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_interfaces.c?r1=1.74r2=1.75diff_format=u
Index: ZendEngine2/zend_interfaces.c
diff -u ZendEngine2/zend_interfaces.c:1.74 ZendEngine2/zend_interfaces.c:1.75
--- ZendEngine2/zend_interfaces.c:1.74  Thu Nov 27 19:02:44 2008
+++ ZendEngine2/zend_interfaces.c   Mon Dec 22 13:50:43 2008
@@ -16,7 +16,7 @@
+--+
 */
 
-/* $Id: zend_interfaces.c,v 1.74 2008/11/27 19:02:44 dmitry Exp $ */
+/* $Id: zend_interfaces.c,v 1.75 2008/12/22 13:50:43 colder Exp $ */
 
 #include zend.h
 #include zend_API.h
@@ -471,6 +471,19 @@
 }
 /* }}} */
 
+ZEND_API int zend_class_serialize_deny(zval *object, int *type, zstr *buffer, 
zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC) /* {{{ */
+{
+   zend_class_entry *ce = Z_OBJCE_P(object);
+   zend_throw_exception_ex(NULL, 0 TSRMLS_CC, Serialization of '%s' is 
not allowed, ce-name);
+   return FAILURE;
+} /* }}} */
+
+ZEND_API int zend_class_unserialize_deny(zval **object, zend_class_entry *ce, 
int type, const zstr buf, zend_uint buf_len, zend_unserialize_data *data 
TSRMLS_DC) /* {{{ */
+{
+   zend_throw_exception_ex(NULL, 0 TSRMLS_CC, Unserialization of '%s' is 
not allowed, ce-name);
+   return FAILURE;
+} /* }}} */
+
 /* {{{ zend_implement_serializable */
 static int zend_implement_serializable(zend_class_entry *interface, 
zend_class_entry *class_type TSRMLS_DC)
 {
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_interfaces.h?r1=1.24r2=1.25diff_format=u
Index: ZendEngine2/zend_interfaces.h
diff -u ZendEngine2/zend_interfaces.h:1.24 ZendEngine2/zend_interfaces.h:1.25
--- ZendEngine2/zend_interfaces.h:1.24  Sun Aug 24 17:01:22 2008
+++ ZendEngine2/zend_interfaces.h   Mon Dec 22 13:50:43 2008
@@ -16,7 +16,7 @@
+--+
 */
 
-/* $Id: zend_interfaces.h,v 1.24 2008/08/24 17:01:22 colder Exp $ */
+/* $Id: zend_interfaces.h,v 1.25 2008/12/22 13:50:43 colder Exp $ */
 
 #ifndef ZEND_INTERFACES_H
 #define ZEND_INTERFACES_H
@@ -69,6 +69,9 @@
 ZEND_API int zend_user_serialize(zval *object, int *type, zstr *buffer, 
zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC);
 ZEND_API int zend_user_unserialize(zval **object, zend_class_entry *ce, int 
type, const zstr buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC);
 
+ZEND_API int zend_class_serialize_deny(zval *object, int *type, zstr *buffer, 
zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC);
+ZEND_API int zend_class_unserialize_deny(zval **object, 

[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2008-11-05 Thread Etienne Kneuss
colder  Thu Nov  6 01:07:05 2008 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  Fix #46421 (Take care about /)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.171r2=1.172diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.171 
php-src/ext/spl/spl_directory.c:1.172
--- php-src/ext/spl/spl_directory.c:1.171   Sun Nov  2 21:10:11 2008
+++ php-src/ext/spl/spl_directory.c Thu Nov  6 01:07:05 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.171 2008/11/02 21:10:11 felipe Exp $ */
+/* $Id: spl_directory.c,v 1.172 2008/11/06 01:07:05 colder Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -241,7 +241,7 @@
intern-_path_len = path_len;
intern-u.dir.dirp = php_stream_u_opendir(type, path, path_len, 
options, NULL);
 
-   if (intern-_path_len  IS_SLASH_AT(type, path, intern-_path_len-1)) {
+   if (intern-_path_len  1  IS_SLASH_AT(type, path, 
intern-_path_len-1)) {
intern-_path = ezstrndup(type, path, --intern-_path_len);
} else {
intern-_path = ezstrndup(type, path, intern-_path_len);
@@ -278,7 +278,7 @@
zend_list_addref(Z_RESVAL_P(intern-u.file.zcontext));
}
 
-   if (intern-file_name_len  IS_SLASH_AT(intern-file_name_type, 
intern-file_name, intern-file_name_len-1)) {
+   if (intern-file_name_len  1  IS_SLASH_AT(intern-file_name_type, 
intern-file_name, intern-file_name_len-1)) {
intern-file_name_len--;
}
 
@@ -396,7 +396,7 @@

if (type == IS_UNICODE) {
slash_pos.u = (p1.u  p2.u ? p1.u : p2.u);
-   if (IS_SLASH_AT(type, intern-file_name, 
intern-file_name_len-1)) {
+   if (IS_SLASH_AT(type, intern-file_name, 
intern-file_name_len-1)  intern-file_name_len  1) {
intern-file_name_len = slash_pos.u - 
intern-file_name.u;

intern-file_name.u[intern-file_name_len] = 0;
continue;
@@ -404,7 +404,7 @@
intern-_path_len = slash_pos.u - 
intern-file_name.u;
} else {
slash_pos.s = (p1.s  p2.s ? p1.s : p2.s);
-   if (IS_SLASH_AT(type, intern-file_name, 
intern-file_name_len-1)) {
+   if (IS_SLASH_AT(type, intern-file_name, 
intern-file_name_len-1)  intern-file_name_len  1) {
intern-file_name_len = slash_pos.s - 
intern-file_name.s;

intern-file_name.s[intern-file_name_len] = 0;
continue;
@@ -2113,7 +2113,7 @@
if (spl_filesystem_file_open(intern, use_include_path, 0 TSRMLS_CC) == 
SUCCESS) {
tmp_path_len  = strlen(intern-u.file.stream-orig_path);
 
-   if (tmp_path_len  IS_SLASH_AT(IS_STRING, 
ZSTR(intern-u.file.stream-orig_path), tmp_path_len-1)) {
+   if (tmp_path_len  1  IS_SLASH_AT(IS_STRING, 
ZSTR(intern-u.file.stream-orig_path), tmp_path_len-1)) {
tmp_path_len--;
}
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_iterators.c

2008-10-21 Thread Arnaud Le Blanc
lbarnaudTue Oct 21 22:06:07 2008 UTC

  Modified files:  
/php-src/ext/splspl_directory.c spl_iterators.c 
  Log:
  initialize optional vars
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.168r2=1.169diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.168 
php-src/ext/spl/spl_directory.c:1.169
--- php-src/ext/spl/spl_directory.c:1.168   Fri Sep 12 16:24:12 2008
+++ php-src/ext/spl/spl_directory.c Tue Oct 21 22:06:05 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.168 2008/09/12 16:24:12 felipe Exp $ */
+/* $Id: spl_directory.c,v 1.169 2008/10/21 22:06:05 lbarnaud Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -2340,8 +2340,8 @@
 {
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
char delimiter = intern-u.file.delimiter, enclosure = 
intern-u.file.enclosure, escape = intern-u.file.escape;
-   char *delim, *enclo, *esc;
-   int d_len, e_len, esc_len;
+   char *delim = NULL, *enclo = NULL, *esc = NULL;
+   int d_len = 0, e_len = 0, esc_len = 0;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |sss, delim, 
d_len, enclo, e_len, esc, esc_len) == SUCCESS) {
switch(ZEND_NUM_ARGS())
@@ -2381,8 +2381,8 @@
 {
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
char delimiter = ',', enclosure = '', escape='\\';
-   char *delim, *enclo, *esc;
-   int d_len, e_len, esc_len;
+   char *delim = NULL, *enclo = NULL, *esc = NULL;
+   int d_len = 0, e_len = 0, esc_len = 0;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |sss, delim, 
d_len, enclo, e_len, esc, esc_len) == SUCCESS) {
switch(ZEND_NUM_ARGS())
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_iterators.c?r1=1.179r2=1.180diff_format=u
Index: php-src/ext/spl/spl_iterators.c
diff -u php-src/ext/spl/spl_iterators.c:1.179 
php-src/ext/spl/spl_iterators.c:1.180
--- php-src/ext/spl/spl_iterators.c:1.179   Mon Sep 22 13:06:28 2008
+++ php-src/ext/spl/spl_iterators.c Tue Oct 21 22:06:06 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_iterators.c,v 1.179 2008/09/22 13:06:28 felipe Exp $ */
+/* $Id: spl_iterators.c,v 1.180 2008/10/21 22:06:06 lbarnaud Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1339,8 +1339,8 @@
}
case DIT_IteratorIterator: {
zend_class_entry **pce_cast;
-   char * class_name;
-   int class_name_len;
+   char * class_name = NULL;
+   int class_name_len = 0;
 
/* UTODO: class_name must be zstr */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, 
O|s, zobject, ce_inner, class_name, class_name_len) == FAILURE) {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2008-09-12 Thread Felipe Pena
felipe  Fri Sep 12 16:24:12 2008 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - Missing argument to type t
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.167r2=1.168diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.167 
php-src/ext/spl/spl_directory.c:1.168
--- php-src/ext/spl/spl_directory.c:1.167   Thu Sep 11 15:45:29 2008
+++ php-src/ext/spl/spl_directory.c Fri Sep 12 16:24:12 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.167 2008/09/11 15:45:29 lbarnaud Exp $ */
+/* $Id: spl_directory.c,v 1.168 2008/09/12 16:24:12 felipe Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -879,11 +879,11 @@
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
zstr fname, suffix, path;
int flen, slen = 0, path_len;
-   zend_uchar path_type;
+   zend_uchar path_type, stype;
 
suffix.v = 0;
if (intern-file_name_type == IS_UNICODE) { 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |t, 
suffix.u, slen) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |t, 
suffix, slen, stype) == FAILURE) {
return;
}
} else {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c /ext/spl/tests bug46053.phpt

2008-09-11 Thread Arnaud Le Blanc
lbarnaudThu Sep 11 15:31:48 2008 UTC

  Added files: 
/php-src/ext/spl/tests  bug46053.phpt 

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  Fixed #46053 (SplFileObject::seek - Endless loop)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.165r2=1.166diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.165 
php-src/ext/spl/spl_directory.c:1.166
--- php-src/ext/spl/spl_directory.c:1.165   Thu Sep 11 15:22:17 2008
+++ php-src/ext/spl/spl_directory.c Thu Sep 11 15:31:48 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.165 2008/09/11 15:22:17 lbarnaud Exp $ */
+/* $Id: spl_directory.c,v 1.166 2008/09/11 15:31:48 lbarnaud Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -2612,7 +2612,9 @@
spl_filesystem_file_rewind(getThis(), intern TSRMLS_CC);

while(intern-u.file.current_line_num  line_pos) {
-   spl_filesystem_file_read_line(getThis(), intern, 1 TSRMLS_CC);
+   if (spl_filesystem_file_read_line(getThis(), intern, 1 
TSRMLS_CC) == FAILURE) {
+   break;
+   }
}
 } /* }}} */
 

http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/bug46053.phpt?view=markuprev=1.1
Index: php-src/ext/spl/tests/bug46053.phpt
+++ php-src/ext/spl/tests/bug46053.phpt
--TEST--
Bug #46053 (SplFileObject::seek - Endless loop)
--FILE--
?php

$x = new splfileobject(__FILE__);
$x-getPathName();
$x-seek(10);
$x-seek(0);
var_dump(trim($x-fgets()));
--EXPECTF--
string(%d) ?php



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2008-09-11 Thread Arnaud Le Blanc
lbarnaudThu Sep 11 15:45:29 2008 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  Fix invalid free
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.166r2=1.167diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.166 
php-src/ext/spl/spl_directory.c:1.167
--- php-src/ext/spl/spl_directory.c:1.166   Thu Sep 11 15:31:48 2008
+++ php-src/ext/spl/spl_directory.c Thu Sep 11 15:45:29 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.166 2008/09/11 15:31:48 lbarnaud Exp $ */
+/* $Id: spl_directory.c,v 1.167 2008/09/11 15:45:29 lbarnaud Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1163,6 +1163,7 @@
UChar *path;
int filename_len, path_len;
char *filename, buff[MAXPATHLEN];
+   zend_bool free_filename = 0;
 
zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, NULL 
TSRMLS_CC);
 
@@ -1175,6 +1176,7 @@
} else {
if (intern-file_name_type == IS_UNICODE) {
php_stream_path_encode(NULL, filename, filename_len, 
intern-file_name.u, intern-file_name_len, REPORT_ERRORS, FG(default_context));
+   free_filename = filename != NULL;
} else {
filename = intern-file_name.s;
}
@@ -1199,7 +1201,7 @@
RETVAL_FALSE;
}
 
-   if (intern-file_name_type == IS_UNICODE  filename) {
+   if (free_filename) {
efree(filename);
}
 }



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_directory.h

2008-07-24 Thread Steph Fox
sfoxThu Jul 24 08:52:24 2008 UTC

  Modified files:  
/php-src/ext/splspl_directory.c spl_directory.h 
  Log:
  - Introduce SPL_FILE_DIR_UNIXPATHS.
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.161r2=1.162diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.161 
php-src/ext/spl/spl_directory.c:1.162
--- php-src/ext/spl/spl_directory.c:1.161   Wed Jul 23 06:12:44 2008
+++ php-src/ext/spl/spl_directory.c Thu Jul 24 08:52:24 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.161 2008/07/23 06:12:44 helly Exp $ */
+/* $Id: spl_directory.c,v 1.162 2008/07/24 08:52:24 sfox Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -185,6 +185,8 @@
 {
zstr path;
zend_uchar path_type;
+   char slash = intern-flags  SPL_FILE_DIR_UNIXPATHS ? '/' : 
DEFAULT_SLASH;
+
if (!intern-file_name.v) {
switch (intern-type) {
case SPL_FS_INFO:
@@ -195,7 +197,7 @@
path = spl_filesystem_object_get_path(intern, NULL, 
path_type TSRMLS_CC);
intern-file_name_len = zspprintf(path_type, 
intern-file_name, 0, %R%c%s,
  path_type, path,
- DEFAULT_SLASH, 
intern-u.dir.entry.d_name);
+ slash, 
intern-u.dir.entry.d_name);
intern-file_name_type = path_type;
break;
}
@@ -684,6 +686,10 @@
flags |= SPL_FILE_DIR_SKIPDOTS;
}
 
+   if (ctor_flags  SPL_FILE_DIR_UNIXPATHS) {
+   flags |= SPL_FILE_DIR_UNIXPATHS;
+   }
+
if (parsed == FAILURE) {
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
return;
@@ -1372,6 +1378,7 @@
zval zpath, zflags;
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
spl_filesystem_object *subdir;
+   char slash = intern-flags  SPL_FILE_DIR_UNIXPATHS ? '/' : 
DEFAULT_SLASH;

spl_filesystem_object_get_file_name(intern TSRMLS_CC);
 
@@ -1388,7 +1395,7 @@
if (subdir) {
if (intern-u.dir.sub_path.v  intern-u.dir.sub_path_len  1) 
{
subdir-u.dir.sub_path_type = 
intern-u.dir.sub_path_type;
-   subdir-u.dir.sub_path_len = 
zspprintf(intern-u.dir.sub_path_type, subdir-u.dir.sub_path, 0, %R%c%s, 
intern-u.dir.sub_path_type, intern-u.dir.sub_path, DEFAULT_SLASH, 
intern-u.dir.entry.d_name);
+   subdir-u.dir.sub_path_len = 
zspprintf(intern-u.dir.sub_path_type, subdir-u.dir.sub_path, 0, %R%c%s, 
intern-u.dir.sub_path_type, intern-u.dir.sub_path, slash, 
intern-u.dir.entry.d_name);
} else {
subdir-u.dir.sub_path_len = 
strlen(intern-u.dir.entry.d_name);
subdir-u.dir.sub_path_type = IS_STRING;
@@ -1422,9 +1429,10 @@
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
zstr sub_name;
int sub_len;
+   char slash = intern-flags  SPL_FILE_DIR_UNIXPATHS ? '/' : 
DEFAULT_SLASH;
 
if (intern-u.dir.sub_path.v) {
-   sub_len = zspprintf(intern-u.dir.sub_path_type, sub_name, 0, 
%R%c%s, intern-u.dir.sub_path_type, intern-u.dir.sub_path, DEFAULT_SLASH, 
intern-u.dir.entry.d_name);
+   sub_len = zspprintf(intern-u.dir.sub_path_type, sub_name, 0, 
%R%c%s, intern-u.dir.sub_path_type, intern-u.dir.sub_path, slash, 
intern-u.dir.entry.d_name);
RETURN_ZSTRL(intern-u.dir.sub_path_type, sub_name, sub_len, 0);
} else {
RETURN_RT_STRING(intern-u.dir.entry.d_name, ZSTR_DUPLICATE);
@@ -2770,6 +2778,7 @@
REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, KEY_AS_FILENAME,
 SPL_FILE_DIR_KEY_AS_FILENAME);
REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, 
NEW_CURRENT_AND_KEY, 
SPL_FILE_DIR_KEY_AS_FILENAME|SPL_FILE_DIR_CURRENT_AS_FILEINFO);
REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, SKIP_DOTS,  
 SPL_FILE_DIR_SKIPDOTS);
+   REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, UNIX_PATHS, 
 SPL_FILE_DIR_UNIXPATHS);
 
spl_ce_FilesystemIterator-get_iterator = 
spl_filesystem_tree_get_iterator;
 
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.h?r1=1.45r2=1.46diff_format=u
Index: php-src/ext/spl/spl_directory.h
diff -u php-src/ext/spl/spl_directory.h:1.45 
php-src/ext/spl/spl_directory.h:1.46
--- php-src/ext/spl/spl_directory.h:1.45Sat Jul 19 11:20:04 2008
+++ php-src/ext/spl/spl_directory.h Thu Jul 24 08:52:24 2008
@@ -16,7 +16,7 @@

[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2008-07-23 Thread Marcus Boerger
helly   Wed Jul 23 06:12:44 2008 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - MFH [DOC] Add FilesystemIterator::SKIP_DOTS (flag to skip '.' and '..' in 
iteration)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.160r2=1.161diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.160 
php-src/ext/spl/spl_directory.c:1.161
--- php-src/ext/spl/spl_directory.c:1.160   Sat Jul 19 11:20:04 2008
+++ php-src/ext/spl/spl_directory.c Wed Jul 23 06:12:44 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.160 2008/07/19 11:20:04 colder Exp $ */
+/* $Id: spl_directory.c,v 1.161 2008/07/23 06:12:44 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1848,7 +1848,7 @@
 static const zend_function_entry spl_FilesystemIterator_functions[] = {
SPL_ME(FilesystemIterator, __construct,   arginfo_r_dir___construct, 
ZEND_ACC_PUBLIC)
SPL_ME(FilesystemIterator, rewind,NULL, ZEND_ACC_PUBLIC)
-   SPL_ME(DirectoryIterator, next,   NULL, ZEND_ACC_PUBLIC)
+   SPL_ME(DirectoryIterator,  next,  NULL, ZEND_ACC_PUBLIC)
SPL_ME(FilesystemIterator, key,   NULL, ZEND_ACC_PUBLIC)
SPL_ME(FilesystemIterator, current,   NULL, ZEND_ACC_PUBLIC)
SPL_ME(FilesystemIterator, getFlags,  NULL, ZEND_ACC_PUBLIC)
@@ -2769,6 +2769,7 @@
REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, KEY_AS_PATHNAME,
 SPL_FILE_DIR_KEY_AS_PATHNAME);
REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, KEY_AS_FILENAME,
 SPL_FILE_DIR_KEY_AS_FILENAME);
REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, 
NEW_CURRENT_AND_KEY, 
SPL_FILE_DIR_KEY_AS_FILENAME|SPL_FILE_DIR_CURRENT_AS_FILEINFO);
+   REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, SKIP_DOTS,  
 SPL_FILE_DIR_SKIPDOTS);
 
spl_ce_FilesystemIterator-get_iterator = 
spl_filesystem_tree_get_iterator;
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2008-07-23 Thread Marcus Boerger
Hello Marcus,

   pf, I executed the commands in the wrong window/order. Now head got
   MFH :-)

Wednesday, July 23, 2008, 8:12:44 AM, you wrote:

 helly   Wed Jul 23 06:12:44 2008 UTC

   Modified files:  
 /php-src/ext/splspl_directory.c 
   Log:
   - MFH [DOC] Add FilesystemIterator::SKIP_DOTS (flag to skip '.' and '..' in 
 iteration)
   
 http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.160r2=1.161diff_format=u
 Index: php-src/ext/spl/spl_directory.c
 diff -u php-src/ext/spl/spl_directory.c:1.160
 php-src/ext/spl/spl_directory.c:1.161
 --- php-src/ext/spl/spl_directory.c:1.160   Sat Jul 19 11:20:04 2008
 +++ php-src/ext/spl/spl_directory.c Wed Jul 23 06:12:44 2008
 @@ -16,7 +16,7 @@

 +--+
   */
  
 -/* $Id: spl_directory.c,v 1.160 2008/07/19 11:20:04 colder Exp $ */
 +/* $Id: spl_directory.c,v 1.161 2008/07/23 06:12:44 helly Exp $ */
  
  #ifdef HAVE_CONFIG_H
  # include config.h
 @@ -1848,7 +1848,7 @@
  static const zend_function_entry spl_FilesystemIterator_functions[] = {
 SPL_ME(FilesystemIterator, __construct,  
 arginfo_r_dir___construct, ZEND_ACC_PUBLIC)
 SPL_ME(FilesystemIterator, rewind,NULL, ZEND_ACC_PUBLIC)
 -   SPL_ME(DirectoryIterator, next,   NULL, ZEND_ACC_PUBLIC)
 +   SPL_ME(DirectoryIterator,  next,  NULL, ZEND_ACC_PUBLIC)
 SPL_ME(FilesystemIterator, key,   NULL, ZEND_ACC_PUBLIC)
 SPL_ME(FilesystemIterator, current,   NULL, ZEND_ACC_PUBLIC)
 SPL_ME(FilesystemIterator, getFlags,  NULL, ZEND_ACC_PUBLIC)
 @@ -2769,6 +2769,7 @@
 REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator,
 KEY_AS_PATHNAME, SPL_FILE_DIR_KEY_AS_PATHNAME);
 REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator,
 KEY_AS_FILENAME, SPL_FILE_DIR_KEY_AS_FILENAME);
 REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator,
 NEW_CURRENT_AND_KEY,
 SPL_FILE_DIR_KEY_AS_FILENAME|SPL_FILE_DIR_CURRENT_AS_FILEINFO);
 +   REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, SKIP_DOTS,   
 SPL_FILE_DIR_SKIPDOTS);
  
 spl_ce_FilesystemIterator-get_iterator = 
 spl_filesystem_tree_get_iterator;
  






Best regards,
 Marcus


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2008-07-23 Thread Jani Taskinen

Bunny will be spared..this time. :)

--Jani


Marcus Boerger wrote:

Hello Marcus,

   pf, I executed the commands in the wrong window/order. Now head got
   MFH :-)

Wednesday, July 23, 2008, 8:12:44 AM, you wrote:


helly   Wed Jul 23 06:12:44 2008 UTC


  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:

  - MFH [DOC] Add FilesystemIterator::SKIP_DOTS (flag to skip '.' and '..' in 
iteration)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.160r2=1.161diff_format=u

Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.160
php-src/ext/spl/spl_directory.c:1.161
--- php-src/ext/spl/spl_directory.c:1.160   Sat Jul 19 11:20:04 2008
+++ php-src/ext/spl/spl_directory.c Wed Jul 23 06:12:44 2008
@@ -16,7 +16,7 @@
   
+--+

  */
 
-/* $Id: spl_directory.c,v 1.160 2008/07/19 11:20:04 colder Exp $ */

+/* $Id: spl_directory.c,v 1.161 2008/07/23 06:12:44 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H

 # include config.h
@@ -1848,7 +1848,7 @@
 static const zend_function_entry spl_FilesystemIterator_functions[] = {
SPL_ME(FilesystemIterator, __construct,  
arginfo_r_dir___construct, ZEND_ACC_PUBLIC)

SPL_ME(FilesystemIterator, rewind,NULL, ZEND_ACC_PUBLIC)
-   SPL_ME(DirectoryIterator, next,   NULL, ZEND_ACC_PUBLIC)
+   SPL_ME(DirectoryIterator,  next,  NULL, ZEND_ACC_PUBLIC)
SPL_ME(FilesystemIterator, key,   NULL, ZEND_ACC_PUBLIC)
SPL_ME(FilesystemIterator, current,   NULL, ZEND_ACC_PUBLIC)
SPL_ME(FilesystemIterator, getFlags,  NULL, ZEND_ACC_PUBLIC)
@@ -2769,6 +2769,7 @@
REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator,
KEY_AS_PATHNAME, SPL_FILE_DIR_KEY_AS_PATHNAME);
REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator,
KEY_AS_FILENAME, SPL_FILE_DIR_KEY_AS_FILENAME);
REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator,
NEW_CURRENT_AND_KEY,
SPL_FILE_DIR_KEY_AS_FILENAME|SPL_FILE_DIR_CURRENT_AS_FILEINFO);
+   REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, SKIP_DOTS,   
SPL_FILE_DIR_SKIPDOTS);
 
spl_ce_FilesystemIterator-get_iterator = spl_filesystem_tree_get_iterator;
 







Best regards,
 Marcus





--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_directory.h /ext/spl/tests dit_006.phpt

2008-07-19 Thread Etienne Kneuss
colder  Sat Jul 19 11:20:05 2008 UTC

  Added files: 
/php-src/ext/spl/tests  dit_006.phpt 

  Modified files:  
/php-src/ext/splspl_directory.c spl_directory.h 
  Log:
  Implement DirectoryIterator::seek
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.159r2=1.160diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.159 
php-src/ext/spl/spl_directory.c:1.160
--- php-src/ext/spl/spl_directory.c:1.159   Tue Jul  8 22:49:35 2008
+++ php-src/ext/spl/spl_directory.c Sat Jul 19 11:20:04 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.159 2008/07/08 22:49:35 colder Exp $ */
+/* $Id: spl_directory.c,v 1.160 2008/07/19 11:20:04 colder Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -776,6 +776,44 @@
 }
 /* }}} */
 
+/* {{{ proto void DirectoryIterator::seek(int position)
+   Seek to the given position */
+SPL_METHOD(DirectoryIterator, seek)
+{
+   spl_filesystem_object *intern= 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+   zval  *retval= NULL;
+   long   pos;
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, l, pos) == 
FAILURE) {
+   return;
+   }
+
+   if (intern-u.dir.index  pos) {
+   /* we first rewind */
+   zend_call_method_with_0_params(this_ptr, Z_OBJCE_P(getThis()), 
intern-u.dir.func_rewind, rewind, retval);
+   if (retval) {
+   zval_ptr_dtor(retval);
+   }
+   }
+
+   while (intern-u.dir.index  pos) {
+   int valid = 0;
+   zend_call_method_with_0_params(this_ptr, Z_OBJCE_P(getThis()), 
intern-u.dir.func_valid, valid, retval);
+   if (retval) {
+   valid = zend_is_true(retval);
+   zval_ptr_dtor(retval);
+   }
+   if (!valid) {
+   break;
+   }
+   zend_call_method_with_0_params(this_ptr, Z_OBJCE_P(getThis()), 
intern-u.dir.func_next, next, retval);
+   if (retval) {
+   zval_ptr_dtor(retval);
+   }
+   }
+} /* }}} */
+
+
 /* {{{ proto string DirectoryIterator::valid() U
Check whether dir contains more entries */
 SPL_METHOD(DirectoryIterator, valid)
@@ -1768,6 +1806,12 @@
ZEND_ARG_INFO(0, path)
 ZEND_END_ARG_INFO()
 
+static
+ZEND_BEGIN_ARG_INFO(arginfo_dir_it_seek, 0) 
+   ZEND_ARG_INFO(0, position)
+ZEND_END_ARG_INFO();
+
+
 /* the method table */
 /* each method can have its own parameters and visibility */
 static const zend_function_entry spl_DirectoryIterator_functions[] = {
@@ -1780,6 +1824,7 @@
SPL_ME(DirectoryIterator, key,   NULL, ZEND_ACC_PUBLIC)
SPL_ME(DirectoryIterator, current,   NULL, ZEND_ACC_PUBLIC)
SPL_ME(DirectoryIterator, next,  NULL, ZEND_ACC_PUBLIC)
+   SPL_ME(DirectoryIterator, seek,  arginfo_dir_it_seek, 
ZEND_ACC_PUBLIC)
SPL_MA(DirectoryIterator, __toString, DirectoryIterator, getFilename, 
NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
 };
@@ -2704,12 +2749,13 @@
 
REGISTER_SPL_STD_CLASS_EX(SplFileInfo, spl_filesystem_object_new, 
spl_SplFileInfo_functions);
memcpy(spl_filesystem_object_handlers, zend_get_std_object_handlers(), 
sizeof(zend_object_handlers));
-   spl_filesystem_object_handlers.clone_obj = spl_filesystem_object_clone;
-   spl_filesystem_object_handlers.cast_object = spl_filesystem_object_cast;
+   spl_filesystem_object_handlers.clone_obj  = 
spl_filesystem_object_clone;
+   spl_filesystem_object_handlers.cast_object= 
spl_filesystem_object_cast;
spl_filesystem_object_handlers.get_debug_info = 
spl_filesystem_object_get_debug_info;
 
REGISTER_SPL_SUB_CLASS_EX(DirectoryIterator, SplFileInfo, 
spl_filesystem_object_new, spl_DirectoryIterator_functions);
zend_class_implements(spl_ce_DirectoryIterator TSRMLS_CC, 1, 
zend_ce_iterator);
+   REGISTER_SPL_IMPLEMENTS(DirectoryIterator, SeekableIterator);
 
spl_ce_DirectoryIterator-get_iterator = 
spl_filesystem_dir_get_iterator;
 
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.h?r1=1.44r2=1.45diff_format=u
Index: php-src/ext/spl/spl_directory.h
diff -u php-src/ext/spl/spl_directory.h:1.44 
php-src/ext/spl/spl_directory.h:1.45
--- php-src/ext/spl/spl_directory.h:1.44Tue May 20 21:46:13 2008
+++ php-src/ext/spl/spl_directory.h Sat Jul 19 11:20:04 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.h,v 1.44 2008/05/20 21:46:13 colder Exp $ */
+/* $Id: spl_directory.h,v 1.45 2008/07/19 11:20:04 colder Exp $ */
 
 #ifndef SPL_DIRECTORY_H
 #define SPL_DIRECTORY_H
@@ -82,6 

Re: [PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2008-07-08 Thread Antony Dovgal

On 05.07.2008 22:58, Marcus Boerger wrote:

Hello Antony,

  I thought all functions we use here are ext/standard and always
available. Or are we referencing non windows functions as well, if so,
could we figure that out somehow and not provide these functions at all?


Yes, they are always available, but wrong hash_find() function was used and
the code failed to find them, which caused unavoidable crash.

--
Wbr, 
Antony Dovgal


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c /ext/spl/tests dit_001.phpt fileobject_003.phpt fileobject_004.phpt fileobject_getfileinfo_basic.phpt

2008-07-08 Thread Etienne Kneuss
colder  Tue Jul  8 22:40:30 2008 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
/php-src/ext/spl/tests  dit_001.phpt fileobject_003.phpt 
fileobject_004.phpt 
fileobject_getfileinfo_basic.phpt 
  Log:
  - Fix filename in debug_info
  - Fix #45345 (getPathInfo on the file instead of the dir)
  - Remove trailing / on input
  http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.157r2=1.158diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.157 
php-src/ext/spl/spl_directory.c:1.158
--- php-src/ext/spl/spl_directory.c:1.157   Wed Jul  2 10:46:52 2008
+++ php-src/ext/spl/spl_directory.c Tue Jul  8 22:40:29 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.157 2008/07/02 10:46:52 tony2001 Exp $ */
+/* $Id: spl_directory.c,v 1.158 2008/07/08 22:40:29 colder Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -374,29 +374,47 @@
intern-file_name = use_copy ? ezstrndup(type, path, len) : path;
intern-file_name_len = len;
 
-   if (type == IS_UNICODE) {
-   p1.u = u_strrchr(path.u, '/');
-   } else {
-   p1.s = strrchr(path.s, '/');
-   }
+   while (1) {
+   if (type == IS_UNICODE) {
+   p1.u = u_strrchr(intern-file_name.u, '/');
+   } else {
+   p1.s = strrchr(intern-file_name.s, '/');
+   }
 #if defined(PHP_WIN32) || defined(NETWARE)
-   if (type == IS_UNICODE) {
-   p2.u = u_strrchr(path.u, '\\');
-   } else {
-   p2.s = strrchr(path.s, '\\');
-   }
+   if (type == IS_UNICODE) {
+   p2.u = u_strrchr(intern-file_name.u, '\\');
+   } else {
+   p2.s = strrchr(intern-file_name.s, '\\');
+   }
 #else
-   p2.v = 0;
+   p2.v = 0;
 #endif
-   if (p1.v || p2.v) {
-   if (type == IS_UNICODE) {
-   intern-_path_len = (p1.u  p2.u ? p1.u : p2.u) - 
path.u;
+   if (p1.v || p2.v) {
+   zstr slash_pos;
+   
+   if (type == IS_UNICODE) {
+   slash_pos.u = (p1.u  p2.u ? p1.u : p2.u);
+   if (IS_SLASH_AT(type, intern-file_name, 
intern-file_name_len)) {
+   intern-file_name_len = slash_pos.u - 
intern-file_name.u;
+   
intern-file_name.u[intern-file_name_len] = 0;
+   continue;
+   }
+   intern-_path_len = slash_pos.u - 
intern-file_name.u;
+   } else {
+   slash_pos.s = (p1.s  p2.s ? p1.s : p2.s);
+   if (IS_SLASH_AT(type, intern-file_name, 
intern-file_name_len)) {
+   intern-file_name_len = slash_pos.s - 
intern-file_name.s;
+   
intern-file_name.s[intern-file_name_len] = 0;
+   continue;
+   }
+   intern-_path_len = slash_pos.s - 
intern-file_name.s;
+   }
} else {
-   intern-_path_len = (p1.s  p2.s ? p1.s : p2.s) - 
path.s;
+   intern-_path_len = 0;
}
-   } else {
-   intern-_path_len = 0;
+   break;
}
+
intern-_path_type = type;
intern-_path = ezstrndup(type, path, intern-_path_len);
 } /* }}} */
@@ -542,6 +560,27 @@
 }
 /* }}} */
 
+static zstr spl_filesystem_object_get_pathname(spl_filesystem_object *intern, 
int *len, zend_uchar *type  TSRMLS_DC) { /* {{{ */
+   switch (intern-type) {
+   case SPL_FS_INFO:
+   case SPL_FS_FILE:
+   *len = intern-file_name_len;
+   *type = intern-file_name_type;
+   return intern-file_name;
+   case SPL_FS_DIR:
+   if (intern-u.dir.entry.d_name[0]) {
+   spl_filesystem_object_get_file_name(intern TSRMLS_CC);
+   *len = intern-file_name_len;
+   *type = intern-file_name_type;
+   return intern-file_name;
+   }
+   }
+   *len  = 0;
+   *type = IS_STRING;
+   return intern-file_name; /* dummy */
+}
+/* }}} */
+
 static HashTable* spl_filesystem_object_get_debug_info(zval *obj, int *is_temp 
TSRMLS_DC) /*  */
 {
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(obj TSRMLS_CC);
@@ -564,13 +603,23 @@
 
zend_hash_copy(rv, intern-std.properties, 

[PHP-CVS] cvs: php-src /ext/spl spl_directory.c /ext/spl/tests fileobject_003.phpt

2008-07-08 Thread Etienne Kneuss
colder  Tue Jul  8 22:49:35 2008 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
/php-src/ext/spl/tests  fileobject_003.phpt 
  Log:
  Woopsy
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.158r2=1.159diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.158 
php-src/ext/spl/spl_directory.c:1.159
--- php-src/ext/spl/spl_directory.c:1.158   Tue Jul  8 22:40:29 2008
+++ php-src/ext/spl/spl_directory.c Tue Jul  8 22:49:35 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.158 2008/07/08 22:40:29 colder Exp $ */
+/* $Id: spl_directory.c,v 1.159 2008/07/08 22:49:35 colder Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -394,7 +394,7 @@

if (type == IS_UNICODE) {
slash_pos.u = (p1.u  p2.u ? p1.u : p2.u);
-   if (IS_SLASH_AT(type, intern-file_name, 
intern-file_name_len)) {
+   if (IS_SLASH_AT(type, intern-file_name, 
intern-file_name_len-1)) {
intern-file_name_len = slash_pos.u - 
intern-file_name.u;

intern-file_name.u[intern-file_name_len] = 0;
continue;
@@ -402,7 +402,7 @@
intern-_path_len = slash_pos.u - 
intern-file_name.u;
} else {
slash_pos.s = (p1.s  p2.s ? p1.s : p2.s);
-   if (IS_SLASH_AT(type, intern-file_name, 
intern-file_name_len)) {
+   if (IS_SLASH_AT(type, intern-file_name, 
intern-file_name_len-1)) {
intern-file_name_len = slash_pos.s - 
intern-file_name.s;

intern-file_name.s[intern-file_name_len] = 0;
continue;
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/fileobject_003.phpt?r1=1.9r2=1.10diff_format=u
Index: php-src/ext/spl/tests/fileobject_003.phpt
diff -u php-src/ext/spl/tests/fileobject_003.phpt:1.9 
php-src/ext/spl/tests/fileobject_003.phpt:1.10
--- php-src/ext/spl/tests/fileobject_003.phpt:1.9   Tue Jul  8 22:40:30 2008
+++ php-src/ext/spl/tests/fileobject_003.phpt   Tue Jul  8 22:49:35 2008
@@ -71,15 +71,15 @@
 ===1===
 object(SplFileInfo)#%d (2) {
   [upathName:uSplFileInfo:private]=
-  unicode(%d) %s
+  unicode(%d) %s%etests
   [ufileName:uSplFileInfo:private]=
-  unicode(%d) 
+  unicode(%d) tests
 }
 object(SplFileInfo)#%d (2) {
   [upathName:uSplFileInfo:private]=
   unicode(%d) %s
   [ufileName:uSplFileInfo:private]=
-  unicode(%d) 
+  unicode(%d) tests
 }
 bool(false)
 bool(true)
@@ -92,8 +92,8 @@
 string(%d) %sspl
 bool(true)
 unicode(%d) %stests
-unicode(%d) %stests
-unicode(%d) %stests
+unicode(%d) tests
+unicode(%d) %s%espl
 ===2===
 object(SplFileInfo)#%d (2) {
   [upathName:uSplFileInfo:private]=
@@ -103,7 +103,7 @@
 }
 object(SplFileInfo)#%d (2) {
   [upathName:uSplFileInfo:private]=
-  unicode(%d) %s
+  unicode(%d) %s%etests
   [ufileName:uSplFileInfo:private]=
   unicode(%d) %s
 }



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2008-07-05 Thread Marcus Boerger
Hello Antony,

  I thought all functions we use here are ext/standard and always
available. Or are we referencing non windows functions as well, if so,
could we figure that out somehow and not provide these functions at all?

marcus

Wednesday, July 2, 2008, 12:46:52 PM, you wrote:

 tony2001Wed Jul  2 10:46:52 2008 UTC

   Modified files:  
 /php-src/ext/splspl_directory.c 
   Log:
   use zend_ascii_hash_find() and check its return value to prevent crash when 
 function not found
   
   
 http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.156r2=1.157diff_format=u
 Index: php-src/ext/spl/spl_directory.c
 diff -u php-src/ext/spl/spl_directory.c:1.156
 php-src/ext/spl/spl_directory.c:1.157
 --- php-src/ext/spl/spl_directory.c:1.156   Wed Jun 18 10:05:14 2008
 +++ php-src/ext/spl/spl_directory.c Wed Jul  2 10:46:52 2008
 @@ -16,7 +16,7 @@

 +--+
   */
  
 -/* $Id: spl_directory.c,v 1.156 2008/06/18 10:05:14 colder Exp $ */
 +/* $Id: spl_directory.c,v 1.157 2008/07/02 10:46:52 tony2001 Exp $ */
  
  #ifdef HAVE_CONFIG_H
  # include config.h
 @@ -1870,7 +1870,12 @@
  #define FileFunctionCall(func_name, pass_num_args, arg2) /* {{{ */\
  { \
 zend_function *func_ptr; \
 -   zend_hash_find(EG(function_table), #func_name,
 sizeof(#func_name), (void **) func_ptr); \
 +   int ret; \
 +   ret = zend_ascii_hash_find(EG(function_table), #func_name,
 sizeof(#func_name), (void **) func_ptr); \
 +   if (ret != SUCCESS) { \
 +   zend_throw_exception_ex(spl_ce_RuntimeException, 0
 TSRMLS_CC, Internal error, function '%s' not found. Please report, 
 #func_name); \
 +   return; \
 +   } \
 spl_filesystem_file_call(intern, func_ptr, pass_num_args, 
 return_value, arg2 TSRMLS_CC); \
  } /* }}} */
  






Best regards,
 Marcus


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2008-07-02 Thread Antony Dovgal
tony2001Wed Jul  2 10:46:52 2008 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  use zend_ascii_hash_find() and check its return value to prevent crash when 
function not found
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.156r2=1.157diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.156 
php-src/ext/spl/spl_directory.c:1.157
--- php-src/ext/spl/spl_directory.c:1.156   Wed Jun 18 10:05:14 2008
+++ php-src/ext/spl/spl_directory.c Wed Jul  2 10:46:52 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.156 2008/06/18 10:05:14 colder Exp $ */
+/* $Id: spl_directory.c,v 1.157 2008/07/02 10:46:52 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1870,7 +1870,12 @@
 #define FileFunctionCall(func_name, pass_num_args, arg2) /* {{{ */\
 { \
zend_function *func_ptr; \
-   zend_hash_find(EG(function_table), #func_name, sizeof(#func_name), 
(void **) func_ptr); \
+   int ret; \
+   ret = zend_ascii_hash_find(EG(function_table), #func_name, 
sizeof(#func_name), (void **) func_ptr); \
+   if (ret != SUCCESS) { \
+   zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, 
Internal error, function '%s' not found. Please report, #func_name); \
+   return; \
+   } \
spl_filesystem_file_call(intern, func_ptr, pass_num_args, return_value, 
arg2 TSRMLS_CC); \
 } /* }}} */
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c /ext/spl/tests bug45216.phpt

2008-06-18 Thread Etienne Kneuss
colder  Wed Jun 18 10:05:15 2008 UTC

  Added files: 
/php-src/ext/spl/tests  bug45216.phpt 

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  Fix #45216 (Add a default size for fgetss)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.155r2=1.156diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.155 
php-src/ext/spl/spl_directory.c:1.156
--- php-src/ext/spl/spl_directory.c:1.155   Tue May 20 21:46:13 2008
+++ php-src/ext/spl/spl_directory.c Wed Jun 18 10:05:14 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.155 2008/05/20 21:46:13 colder Exp $ */
+/* $Id: spl_directory.c,v 1.156 2008/06/18 10:05:14 colder Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -2427,7 +2427,12 @@
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
zval *arg2 = NULL;
MAKE_STD_ZVAL(arg2);
-   ZVAL_LONG(arg2, intern-u.file.max_line_len);
+
+   if (intern-u.file.max_line_len  0) {
+   ZVAL_LONG(arg2, intern-u.file.max_line_len);
+   } else {
+   ZVAL_LONG(arg2, 1024);
+   }
 
spl_filesystem_file_free_line(intern TSRMLS_CC);
intern-u.file.current_line_num++;

http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/bug45216.phpt?view=markuprev=1.1
Index: php-src/ext/spl/tests/bug45216.phpt
+++ php-src/ext/spl/tests/bug45216.phpt
--TEST--
SPL: SplFileObject::fgetss (bug 45216)
--CREDITS--
Perrick Penet [EMAIL PROTECTED]
#testfest phpcampparis 2008-06-07
--FILE--
?php 
$file = dirname(__FILE__) . '/foo.html';
file_put_contents($file, 'text 0div class=testedtext 1/div');
$handle = fopen($file, 'r');

$object = new SplFileObject($file);
var_dump($object-fgetss());
var_dump(fgetss($handle));
?
--CLEAN--
?php
unlink(dirname(__FILE__) . '/foo.html');
?
--EXPECTF--
string(12) text 0text 1
string(12) text 0text 1



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_directory.h /ext/spl/tests fileobject_004.phpt

2008-05-20 Thread Etienne Kneuss
colder  Tue May 20 21:46:14 2008 UTC

  Added files: 
/php-src/ext/spl/tests  fileobject_004.phpt 

  Modified files:  
/php-src/ext/splspl_directory.c spl_directory.h 
  Log:
  Fix path lookup when include_path is used
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.154r2=1.155diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.154 
php-src/ext/spl/spl_directory.c:1.155
--- php-src/ext/spl/spl_directory.c:1.154   Fri May 16 13:22:02 2008
+++ php-src/ext/spl/spl_directory.c Tue May 20 21:46:13 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.154 2008/05/16 13:22:02 colder Exp $ */
+/* $Id: spl_directory.c,v 1.155 2008/05/20 21:46:13 colder Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -109,6 +109,9 @@
if (intern-u.file.open_mode) {
efree(intern-u.file.open_mode);
}
+   if (intern-orig_path) {
+   efree(intern-orig_path);
+   }
}
spl_filesystem_file_free_line(intern TSRMLS_CC);
break;
@@ -277,6 +280,10 @@
intern-file_name_len--;
}
 
+   /* NOTE: Works as long as stream-orig_path is not unicode aware, might
+* break later. */
+   intern-orig_path = estrndup(intern-u.file.stream-orig_path, 
strlen(intern-u.file.stream-orig_path));
+
intern-file_name = ezstrndup(intern-file_name_type, 
intern-file_name, intern-file_name_len);
intern-u.file.open_mode = estrndup(intern-u.file.open_mode, 
intern-u.file.open_mode_len);
 
@@ -1082,10 +1089,14 @@
spl_filesystem_object_get_file_name(intern TSRMLS_CC);
}
 
-   if (intern-file_name_type == IS_UNICODE) {
-   php_stream_path_encode(NULL, filename, filename_len, 
intern-file_name.u, intern-file_name_len, REPORT_ERRORS, FG(default_context));
+   if (intern-orig_path) {
+   filename = intern-orig_path;
} else {
-   filename = intern-file_name.s;
+   if (intern-file_name_type == IS_UNICODE) {
+   php_stream_path_encode(NULL, filename, filename_len, 
intern-file_name.u, intern-file_name_len, REPORT_ERRORS, FG(default_context));
+   } else {
+   filename = intern-file_name.s;
+   }
}
 
if (filename  VCWD_REALPATH(filename, buff)) {
@@ -1994,6 +2005,8 @@
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
zend_bool use_include_path = 0;
zstr p1, p2;
+   char *tmp_path;
+   int   tmp_path_len;
 
php_set_error_handling(EH_THROW, spl_ce_RuntimeException TSRMLS_CC);
 
@@ -2009,31 +2022,31 @@
}

if (spl_filesystem_file_open(intern, use_include_path, 0 TSRMLS_CC) == 
SUCCESS) {
-   if (intern-file_name_type == IS_UNICODE) {
-   p1.u = u_strrchr(intern-file_name.u, '/');
-   } else {
-   p1.s = strrchr(intern-file_name.s, '/');
+   tmp_path_len  = strlen(intern-u.file.stream-orig_path);
+
+   if (tmp_path_len  IS_SLASH_AT(IS_STRING, 
ZSTR(intern-u.file.stream-orig_path), tmp_path_len-1)) {
+   tmp_path_len--;
}
+
+   tmp_path = estrndup(intern-u.file.stream-orig_path, 
tmp_path_len);
+
+   p1.s = strrchr(tmp_path, '/');
 #if defined(PHP_WIN32) || defined(NETWARE)
-   if (intern-file_name_type == IS_UNICODE) {
-   p2.u = u_strrchr(intern-file_name.u, '\\');
-   } else {
-   p2.s = strrchr(intern-file_name.s, '\\');
-   }
+   p2.s = strrchr(tmp_path, '\\');
 #else
p2.v = 0;
 #endif
+
if (p1.v || p2.v) {
-   if (intern-file_name_type == IS_UNICODE) {
-   intern-_path_len = (p1.u  p2.u ? p1.u : p2.u) 
- intern-file_name.u;
-   } else {
-   intern-_path_len = (p1.s  p2.s ? p1.s : p2.s) 
- intern-file_name.s;
-   }
+   intern-_path_len = (p1.s  p2.s ? p1.s : p2.s) - 
tmp_path;
} 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);
+
+   efree(tmp_path);
+
+   intern-_path  = 
ZSTR(estrndup(intern-u.file.stream-orig_path, intern-_path_len));
+   intern-_path_type = IS_STRING;
}
 

[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_directory.h /ext/spl/tests dit_004.phpt dit_005.phpt

2008-05-16 Thread Etienne Kneuss
colder  Fri May 16 13:22:02 2008 UTC

  Added files: 
/php-src/ext/spl/tests  dit_004.phpt dit_005.phpt 

  Modified files:  
/php-src/ext/splspl_directory.c spl_directory.h 
  Log:
  Fix FilesystemIterator with ./..
  http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.153r2=1.154diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.153 
php-src/ext/spl/spl_directory.c:1.154
--- php-src/ext/spl/spl_directory.c:1.153   Thu May 15 17:22:03 2008
+++ php-src/ext/spl/spl_directory.c Fri May 16 13:22:02 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.153 2008/05/15 17:22:03 colder Exp $ */
+/* $Id: spl_directory.c,v 1.154 2008/05/16 13:22:02 colder Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -212,11 +212,18 @@
 
 #define IS_SLASH_AT(type, zs, pos) (type == IS_UNICODE ? IS_U_SLASH(zs.u[pos]) 
: IS_SLASH(zs.s[pos]))
 
+static inline int spl_filesystem_is_dot(const char * d_name) /* {{{ */
+{
+   return !strcmp(d_name, .) || !strcmp(d_name, ..);
+}
+/* }}} */
+
 /* {{{ spl_filesystem_dir_open */
 /* open a directory resource */
 static void spl_filesystem_dir_open(spl_filesystem_object* intern, zend_uchar 
type, zstr path, int path_len TSRMLS_DC)
 {
int options = REPORT_ERRORS;
+   int skip_dots = intern-flags  SPL_FILE_DIR_SKIPDOTS;
 
 #if HELLY_0
if (php_stream_is(intern-u.dir.dirp, php_glob_stream_ops)) {
@@ -240,7 +247,9 @@
/* throw exception: should've been already happened */
intern-u.dir.entry.d_name[0] = '\0';
} else {
-   spl_filesystem_dir_read(intern TSRMLS_CC);
+   do {
+   spl_filesystem_dir_read(intern TSRMLS_CC);
+   } while (skip_dots  
spl_filesystem_is_dot(intern-u.dir.entry.d_name));
}
 }
 /* }}} */
@@ -299,13 +308,18 @@
spl_filesystem_object *intern;
spl_filesystem_object *source;
int index;
+   int skip_dots;
 
old_object = zend_objects_get_address(zobject TSRMLS_CC);
source = (spl_filesystem_object*)old_object;
 
+   skip_dots = source-flags  SPL_FILE_DIR_SKIPDOTS;
+
new_obj_val = spl_filesystem_object_new_ex(old_object-ce, intern 
TSRMLS_CC);
new_object = intern-std;
 
+   intern-flags = source-flags;
+
switch (source-type) {
case SPL_FS_INFO:
intern-_path_type = source-_path_type;
@@ -319,7 +333,9 @@
spl_filesystem_dir_open(intern, source-_path_type, 
source-_path, source-_path_len TSRMLS_CC);
/* read until we hit the position in which we were before */
for(index = 0; index  source-u.dir.index; ++index) {
-   spl_filesystem_dir_read(intern TSRMLS_CC);
+   do {
+   spl_filesystem_dir_read(intern TSRMLS_CC);
+   } while (skip_dots  
spl_filesystem_is_dot(intern-u.dir.entry.d_name));
}
intern-u.dir.index = index;
break;
@@ -330,7 +346,6 @@

intern-file_class = source-file_class;
intern-info_class = source-info_class;
-   intern-flags = source-flags;
intern-oth = source-oth;
intern-oth_handler = source-oth_handler;
 
@@ -514,12 +529,6 @@
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);
@@ -614,6 +623,11 @@
flags = 
SPL_FILE_DIR_KEY_AS_PATHNAME|SPL_FILE_DIR_CURRENT_AS_SELF;
parsed = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t, 
path, len, path_type);
}
+
+   if (ctor_flags  SPL_FILE_DIR_SKIPDOTS) {
+   flags |= SPL_FILE_DIR_SKIPDOTS;
+   }
+
if (parsed == FAILURE) {
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
return;
@@ -625,6 +639,8 @@
}
 
intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() 
TSRMLS_CC);
+   intern-flags = flags;
+
if ((ctor_flags  DIT_CTOR_GLOB)  (
(path_type == IS_STRING  strstr(path.s, glob://) != path.s) 
||
(path_type == IS_UNICODE  u_strstr(path.u, u_glob) != path.u)
@@ -637,7 +653,6 @@
}
 
intern-u.dir.is_recursive = instanceof_function(intern-std.ce, 
spl_ce_RecursiveDirectoryIterator TSRMLS_CC) ? 1 : 0;
-   intern-flags = flags;
 
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
 }
@@ -692,9 +707,12 @@
 SPL_METHOD(DirectoryIterator, next)
 {
spl_filesystem_object *intern = 

[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2008-05-15 Thread Etienne Kneuss
colder  Thu May 15 17:22:03 2008 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  Replace the iterator correctly after being cloned (related to #44964)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.152r2=1.153diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.152 
php-src/ext/spl/spl_directory.c:1.153
--- php-src/ext/spl/spl_directory.c:1.152   Sat May  3 16:01:00 2008
+++ php-src/ext/spl/spl_directory.c Thu May 15 17:22:03 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.152 2008/05/03 16:01:00 colder Exp $ */
+/* $Id: spl_directory.c,v 1.153 2008/05/15 17:22:03 colder Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -298,6 +298,7 @@
zend_object_handle handle = Z_OBJ_HANDLE_P(zobject);
spl_filesystem_object *intern;
spl_filesystem_object *source;
+   int index;
 
old_object = zend_objects_get_address(zobject TSRMLS_CC);
source = (spl_filesystem_object*)old_object;
@@ -316,6 +317,11 @@
break;
case SPL_FS_DIR:
spl_filesystem_dir_open(intern, source-_path_type, 
source-_path, source-_path_len TSRMLS_CC);
+   /* read until we hit the position in which we were before */
+   for(index = 0; index  source-u.dir.index; ++index) {
+   spl_filesystem_dir_read(intern TSRMLS_CC);
+   }
+   intern-u.dir.index = index;
break;
case SPL_FS_FILE:
php_error_docref(NULL TSRMLS_CC, E_ERROR, An object of class 
%v cannot be cloned, old_object-ce-name);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2008-05-03 Thread Etienne Kneuss
colder  Sat May  3 16:01:00 2008 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  MFB: Fix #44838 (static class reference restricting overwriting)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.151r2=1.152diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.151 
php-src/ext/spl/spl_directory.c:1.152
--- php-src/ext/spl/spl_directory.c:1.151   Wed Apr  9 19:00:48 2008
+++ php-src/ext/spl/spl_directory.c Sat May  3 16:01:00 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.151 2008/04/09 19:00:48 colder Exp $ */
+/* $Id: spl_directory.c,v 1.152 2008/05/03 16:01:00 colder Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1276,7 +1276,7 @@
ZVAL_LONG(zflags, intern-flags);
ZVAL_ZSTRL(zpath, intern-file_name_type, intern-file_name, 
intern-file_name_len, 1);
 
-   spl_instantiate_arg_ex2(spl_ce_RecursiveDirectoryIterator, 
return_value, 0, zpath, zflags TSRMLS_CC);
+   spl_instantiate_arg_ex2(Z_OBJCE_P(getThis()), return_value, 0, zpath, 
zflags TSRMLS_CC);
 
zval_dtor(zpath);
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2008-04-09 Thread Etienne Kneuss
colder  Wed Apr  9 19:00:48 2008 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  Fix #44511 (Ensure no exception was already thrown by php_stream_opendir)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.150r2=1.151diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.150 
php-src/ext/spl/spl_directory.c:1.151
--- php-src/ext/spl/spl_directory.c:1.150   Thu Mar 13 19:45:22 2008
+++ php-src/ext/spl/spl_directory.c Wed Apr  9 19:00:48 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.150 2008/03/13 19:45:22 helly Exp $ */
+/* $Id: spl_directory.c,v 1.151 2008/04/09 19:00:48 colder Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -236,7 +236,7 @@
}
intern-u.dir.index = 0;
 
-   if (intern-u.dir.dirp == NULL) {
+   if (EG(exception) || intern-u.dir.dirp == NULL) {
/* throw exception: should've been already happened */
intern-u.dir.entry.d_name[0] = '\0';
} else {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c /ext/spl/tests dit_003.phpt

2008-03-13 Thread Marcus Boerger
helly   Thu Mar 13 19:45:22 2008 UTC

  Added files: 
/php-src/ext/spl/tests  dit_003.phpt 

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - Fix possible memory corruption
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.149r2=1.150diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.149 
php-src/ext/spl/spl_directory.c:1.150
--- php-src/ext/spl/spl_directory.c:1.149   Wed Feb 13 12:01:16 2008
+++ php-src/ext/spl/spl_directory.c Thu Mar 13 19:45:22 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.149 2008/02/13 12:01:16 helly Exp $ */
+/* $Id: spl_directory.c,v 1.150 2008/03/13 19:45:22 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1403,10 +1403,11 @@
 static void spl_filesystem_dir_it_dtor(zend_object_iterator *iter TSRMLS_DC)
 {
spl_filesystem_iterator *iterator = (spl_filesystem_iterator *)iter;
+   zval *zfree = (zval*)iterator-intern.data;
 
-   zval_ptr_dtor(iterator-current);
-   zval_ptr_dtor((zval**)iterator-intern.data);
iterator-intern.data = NULL; /* mark as unused */
+   zval_ptr_dtor(iterator-current);
+   zval_ptr_dtor(zfree);
 }
 /* }}} */
 
@@ -1469,12 +1470,15 @@
 static void spl_filesystem_tree_it_dtor(zend_object_iterator *iter TSRMLS_DC)
 {
spl_filesystem_iterator *iterator = (spl_filesystem_iterator *)iter;
+   zval *zfree = (zval*)iterator-intern.data;
 
if (iterator-current) {
zval_ptr_dtor(iterator-current);
}
-   zval_ptr_dtor((zval**)iterator-intern.data);
iterator-intern.data = NULL; /* mark as unused */
+   /* free twice as we add ref twice */
+   zval_ptr_dtor(zfree);
+   zval_ptr_dtor(zfree);
 }
 /* }}} */
 
@@ -1586,7 +1590,7 @@
dir_object = 
(spl_filesystem_object*)zend_object_store_get_object(object TSRMLS_CC);
iterator   = spl_filesystem_object_to_iterator(dir_object);
 
-   Z_ADDREF_P(object);
+   Z_SET_REFCOUNT_P(object, Z_REFCOUNT_P(object) + 2);
iterator-intern.data = (void*)object;
iterator-intern.funcs = spl_filesystem_tree_it_funcs;
iterator-current = NULL;

http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/dit_003.phpt?view=markuprev=1.1
Index: php-src/ext/spl/tests/dit_003.phpt
+++ php-src/ext/spl/tests/dit_003.phpt
--TEST--
SPL: FilesystemIterator and foreach
--SKIPIF--
?php if (!extension_loaded(spl)) print skip; ?
--FILE--
?php
$count = 0;
foreach(new FilesystemIterator('CVS') as $ent)
{
++$count;
}
var_dump($count  0);
?
===DONE===
--EXPECTF--
bool(true)
===DONE===



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2008-02-04 Thread Marcus Boerger
helly   Mon Feb  4 18:46:02 2008 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - Fix #44018 (RecursiveDirectoryIterator options inconsistancy)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.145r2=1.146diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.145 
php-src/ext/spl/spl_directory.c:1.146
--- php-src/ext/spl/spl_directory.c:1.145   Mon Feb  4 18:35:08 2008
+++ php-src/ext/spl/spl_directory.c Mon Feb  4 18:46:02 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.145 2008/02/04 18:35:08 helly Exp $ */
+/* $Id: spl_directory.c,v 1.146 2008/02/04 18:46:02 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -602,10 +602,8 @@
php_set_error_handling(EH_THROW, spl_ce_RuntimeException TSRMLS_CC);
 
if (ctor_flags  DIT_CTOR_FLAGS) {
-   flags = SPL_FILE_DIR_CURRENT_AS_FILEINFO;
parsed = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, 
t|l, path, len, path_type, flags);
} else {
-   flags = 0;
parsed = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t, 
path, len, path_type);
}
if (parsed == FAILURE) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2008-02-04 Thread Marcus Boerger
helly   Mon Feb  4 18:35:08 2008 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - Setting flags once is enough
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.144r2=1.145diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.144 
php-src/ext/spl/spl_directory.c:1.145
--- php-src/ext/spl/spl_directory.c:1.144   Mon Feb  4 17:18:48 2008
+++ php-src/ext/spl/spl_directory.c Mon Feb  4 18:35:08 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.144 2008/02/04 17:18:48 helly Exp $ */
+/* $Id: spl_directory.c,v 1.145 2008/02/04 18:35:08 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -619,8 +619,6 @@
}
 
intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() 
TSRMLS_CC);
-
-   intern-flags = flags;
if ((ctor_flags  DIT_CTOR_GLOB)  (
(path_type == IS_STRING  strstr(path.s, glob://) != path.s) 
||
(path_type == IS_UNICODE  u_strstr(path.u, u_glob) != path.u)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2008-02-04 Thread Marcus Boerger
helly   Mon Feb  4 17:18:48 2008 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
   Fix default flag value in contructor
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.143r2=1.144diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.143 
php-src/ext/spl/spl_directory.c:1.144
--- php-src/ext/spl/spl_directory.c:1.143   Sat Feb  2 22:53:05 2008
+++ php-src/ext/spl/spl_directory.c Mon Feb  4 17:18:48 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.143 2008/02/02 22:53:05 helly Exp $ */
+/* $Id: spl_directory.c,v 1.144 2008/02/04 17:18:48 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -597,7 +597,7 @@
zstr path;
int parsed, len;
zend_uchar path_type;
-   long flags;
+   long flags = 0;

php_set_error_handling(EH_THROW, spl_ce_RuntimeException TSRMLS_CC);
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_directory.h

2008-02-04 Thread Marcus Boerger
helly   Mon Feb  4 19:33:03 2008 UTC

  Modified files:  
/php-src/ext/splspl_directory.c spl_directory.h 
  Log:
  - Really fix flag handling
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.146r2=1.147diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.146 
php-src/ext/spl/spl_directory.c:1.147
--- php-src/ext/spl/spl_directory.c:1.146   Mon Feb  4 18:46:02 2008
+++ php-src/ext/spl/spl_directory.c Mon Feb  4 19:33:03 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.146 2008/02/04 18:46:02 helly Exp $ */
+/* $Id: spl_directory.c,v 1.147 2008/02/04 19:33:03 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -597,13 +597,15 @@
zstr path;
int parsed, len;
zend_uchar path_type;
-   long flags = 0;
+   long flags;

php_set_error_handling(EH_THROW, spl_ce_RuntimeException TSRMLS_CC);
 
if (ctor_flags  DIT_CTOR_FLAGS) {
+   flags = 0;
parsed = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, 
t|l, path, len, path_type, flags);
} else {
+   flags = 
SPL_FILE_DIR_KEY_AS_PATHNAME|SPL_FILE_DIR_CURRENT_AS_SELF;
parsed = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t, 
path, len, path_type);
}
if (parsed == FAILURE) {
@@ -837,7 +839,7 @@
 {
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
-   if (intern-flags  SPL_FILE_DIR_KEY_AS_FILENAME) {
+   if (SPL_FILE_DIR_KEY(intern, SPL_FILE_DIR_KEY_AS_FILENAME)) {
RETURN_RT_STRING(intern-u.dir.entry.d_name, ZSTR_DUPLICATE);
} else {
spl_filesystem_object_get_file_name(intern TSRMLS_CC);
@@ -852,10 +854,10 @@
 {
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
-   if (intern-flags  SPL_FILE_DIR_CURRENT_AS_PATHNAME) {
+   if (SPL_FILE_DIR_CURRENT(intern, SPL_FILE_DIR_CURRENT_AS_PATHNAME)) {
spl_filesystem_object_get_file_name(intern TSRMLS_CC);
RETURN_ZSTRL(intern-file_name_type, intern-file_name, 
intern-file_name_len, ZSTR_DUPLICATE);
-   } else if (intern-flags  SPL_FILE_DIR_CURRENT_AS_FILEINFO) {
+   } else if (SPL_FILE_DIR_CURRENT(intern, 
SPL_FILE_DIR_CURRENT_AS_FILEINFO)) {
spl_filesystem_object_get_file_name(intern TSRMLS_CC);
spl_filesystem_object_create_type(0, intern, SPL_FS_INFO, NULL, 
return_value TSRMLS_CC);
} else {
@@ -1460,14 +1462,14 @@
spl_filesystem_iterator *iterator = (spl_filesystem_iterator *)iter;
spl_filesystem_object   *object   = 
spl_filesystem_iterator_to_object(iterator);
 
-   if (object-flags  SPL_FILE_DIR_CURRENT_AS_PATHNAME) {
+   if (SPL_FILE_DIR_CURRENT(object, SPL_FILE_DIR_CURRENT_AS_PATHNAME)) {
if (!iterator-current) {
ALLOC_INIT_ZVAL(iterator-current);
spl_filesystem_object_get_file_name(object TSRMLS_CC);
ZVAL_ZSTRL(iterator-current, object-file_name_type, 
object-file_name, object-file_name_len, ZSTR_DUPLICATE);
}
*data = iterator-current;
-   } else if (object-flags  SPL_FILE_DIR_CURRENT_AS_FILEINFO) {
+   } else if (SPL_FILE_DIR_CURRENT(object, 
SPL_FILE_DIR_CURRENT_AS_FILEINFO)) {
if (!iterator-current) {
ALLOC_INIT_ZVAL(iterator-current);
spl_filesystem_object_get_file_name(object TSRMLS_CC);
@@ -1485,7 +1487,7 @@
 {
spl_filesystem_object *object = 
spl_filesystem_iterator_to_object((spl_filesystem_iterator *)iter);

-   if (object-flags  SPL_FILE_DIR_KEY_AS_FILENAME) {
+   if (SPL_FILE_DIR_KEY(object, SPL_FILE_DIR_KEY_AS_FILENAME)) {
*str_key_len = strlen(object-u.dir.entry.d_name) + 1;
str_key-s = estrndup(object-u.dir.entry.d_name, *str_key_len 
- 1);
return HASH_KEY_IS_STRING;
@@ -1898,11 +1900,11 @@
case IS_UNICODE:
return Z_STRLEN_P(intern-u.file.current_zval) == 0;
case IS_ARRAY:
-   if ((intern-flags  SPL_FILE_OBJECT_READ_CSV) 
+   if ((intern-flags  SPL_FILE_OBJECT_READ_CSV)
 
zend_hash_num_elements(Z_ARRVAL_P(intern-u.file.current_zval)) == 1) {
zval ** first = 
Z_ARRVAL_P(intern-u.file.current_zval)-pListHead-pData;

-   return (Z_TYPE_PP(first) == IS_STRING || 
Z_TYPE_PP(first) == IS_UNICODE) 
+   return (Z_TYPE_PP(first) == IS_STRING || 
Z_TYPE_PP(first) == IS_UNICODE)
   

[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2008-02-04 Thread Marcus Boerger
helly   Mon Feb  4 19:39:07 2008 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - Fix/add folding markers
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.147r2=1.148diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.147 
php-src/ext/spl/spl_directory.c:1.148
--- php-src/ext/spl/spl_directory.c:1.147   Mon Feb  4 19:33:03 2008
+++ php-src/ext/spl/spl_directory.c Mon Feb  4 19:39:07 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.147 2008/02/04 19:33:03 helly Exp $ */
+/* $Id: spl_directory.c,v 1.148 2008/02/04 19:39:07 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1337,7 +1337,7 @@
 }
 /* }}} */
 
-/* forward declarations to the iterator handlers */
+/* {{{ forward declarations to the iterator handlers */
 static void spl_filesystem_dir_it_dtor(zend_object_iterator *iter TSRMLS_DC);
 static int spl_filesystem_dir_it_valid(zend_object_iterator *iter TSRMLS_DC);
 static void spl_filesystem_dir_it_current_data(zend_object_iterator *iter, 
zval ***data TSRMLS_DC);
@@ -1354,6 +1354,7 @@
spl_filesystem_dir_it_move_forward,
spl_filesystem_dir_it_rewind
 };
+/* }}} */
 
 /* {{{ spl_ce_dir_get_iterator */
 zend_object_iterator *spl_filesystem_dir_get_iterator(zend_class_entry *ce, 
zval *object, int by_ref TSRMLS_DC)
@@ -1386,7 +1387,7 @@
iterator-intern.data = NULL; /* mark as unused */
 }
 /* }}} */
-   
+
 /* {{{ spl_filesystem_dir_it_valid */
 static int spl_filesystem_dir_it_valid(zend_object_iterator *iter TSRMLS_DC)
 {
@@ -1396,7 +1397,6 @@
 }
 /* }}} */
 
-
 /* {{{ spl_filesystem_dir_it_current_data */
 static void spl_filesystem_dir_it_current_data(zend_object_iterator *iter, 
zval ***data TSRMLS_DC)
 {
@@ -1455,7 +1455,7 @@
iterator-intern.data = NULL; /* mark as unused */
 }
 /* }}} */
-   
+
 /* {{{ spl_filesystem_tree_it_current_data */
 static void spl_filesystem_tree_it_current_data(zend_object_iterator *iter, 
zval ***data TSRMLS_DC)
 {
@@ -1541,7 +1541,7 @@
 }
 /* }}} */
 
-/* iterator handler table */
+/* {{{ iterator handler table */
 zend_object_iterator_funcs spl_filesystem_tree_it_funcs = {
spl_filesystem_tree_it_dtor,
spl_filesystem_dir_it_valid,
@@ -1550,6 +1550,7 @@
spl_filesystem_tree_it_move_forward,
spl_filesystem_tree_it_rewind
 };
+/* }}} */
 
 /* {{{ spl_ce_dir_get_iterator */
 zend_object_iterator *spl_filesystem_tree_get_iterator(zend_class_entry *ce, 
zval *object, int by_ref TSRMLS_DC)
@@ -1610,7 +1611,7 @@
 }
 /* }}} */
 
-/* declare method parameters */
+/* {{{ declare method parameters */
 /* supply a name and default to call by parameter */
 static
 ZEND_BEGIN_ARG_INFO(arginfo_info___construct, 0) 
@@ -1725,6 +1726,7 @@
SPL_ME(GlobIterator, count, NULL,  
ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
 };
+/* }}} */
 
 static int spl_filesystem_file_read(spl_filesystem_object *intern, int silent 
TSRMLS_DC) /* {{{ */
 {
@@ -1814,12 +1816,12 @@
return result;
 } /* }}} */
 
-#define FileFunctionCall(func_name, pass_num_args, arg2) \
+#define FileFunctionCall(func_name, pass_num_args, arg2) /* {{{ */\
 { \
zend_function *func_ptr; \
zend_hash_find(EG(function_table), #func_name, sizeof(#func_name), 
(void **) func_ptr); \
spl_filesystem_file_call(intern, func_ptr, pass_num_args, return_value, 
arg2 TSRMLS_CC); \
-}
+} /* }}} */
 
 static int spl_filesystem_file_read_csv(spl_filesystem_object *intern, char 
delimiter, char enclosure, char escape, zval *return_value TSRMLS_DC) /* {{{ */
 {
@@ -2311,7 +2313,6 @@
RETURN_BOOL(!php_stream_flush(intern-u.file.stream));
 } /* }}} */
 
-
 /* {{{ proto int SplFileObject::ftell() U
Return current file position */
 SPL_METHOD(SplFileObject, ftell)
@@ -2634,7 +2635,6 @@
 }
 /* }}} */
 
-
 /*
  * Local variables:
  * tab-width: 4

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_directory.h

2008-02-02 Thread Marcus Boerger
helly   Sat Feb  2 22:53:05 2008 UTC

  Modified files:  
/php-src/ext/splspl_directory.c spl_directory.h 
  Log:
  - MFB glob handling
  - Add GlobIterator and FilesystemIterator
  # Commit to 5.3 for more
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.142r2=1.143diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.142 
php-src/ext/spl/spl_directory.c:1.143
--- php-src/ext/spl/spl_directory.c:1.142   Thu Jan 31 11:09:50 2008
+++ php-src/ext/spl/spl_directory.c Sat Feb  2 22:53:05 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.142 2008/01/31 11:09:50 rrichards Exp $ */
+/* $Id: spl_directory.c,v 1.143 2008/02/02 22:53:05 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -43,15 +43,6 @@
 
 #include ext/standard/basic_functions.h
 #include ext/standard/php_filestat.h
-#include ext/standard/php_link.h
-
-#ifdef HAVE_GLOB
-# ifndef PHP_WIN32
-#  include glob.h
-# else
-#  include win32/glob.h
-# endif
-#endif
 
 /* declare the class handlers */
 static zend_object_handlers spl_filesystem_object_handlers;
@@ -59,7 +50,9 @@
 /* decalre the class entry */
 PHPAPI zend_class_entry *spl_ce_SplFileInfo;
 PHPAPI zend_class_entry *spl_ce_DirectoryIterator;
+PHPAPI zend_class_entry *spl_ce_FilesystemIterator;
 PHPAPI zend_class_entry *spl_ce_RecursiveDirectoryIterator;
+PHPAPI zend_class_entry *spl_ce_GlobIterator;
 PHPAPI zend_class_entry *spl_ce_SplFileObject;
 PHPAPI zend_class_entry *spl_ce_SplTempFileObject;
 
@@ -197,64 +190,49 @@
break;
case SPL_FS_DIR:
path = spl_filesystem_object_get_path(intern, NULL, 
path_type TSRMLS_CC);
-   intern-file_name_len = zspprintf(path_type, 
intern-file_name, 0, %R%c%s, path_type, path, DEFAULT_SLASH, 
intern-u.dir.entry.d_name);
+   intern-file_name_len = zspprintf(path_type, 
intern-file_name, 0, %R%c%s,
+ path_type, path,
+ DEFAULT_SLASH, 
intern-u.dir.entry.d_name);
intern-file_name_type = path_type;
break;
}
}
 } /* }}} */
 
-#define IS_SLASH_AT(type, zs, pos) (type == IS_UNICODE ? IS_U_SLASH(zs.u[pos]) 
: IS_SLASH(zs.s[pos]))
-
 static int spl_filesystem_dir_read(spl_filesystem_object *intern TSRMLS_DC) /* 
{{{ */
 {
if (!intern-u.dir.dirp || !php_stream_readdir(intern-u.dir.dirp, 
intern-u.dir.entry)) {
intern-u.dir.entry.d_name[0] = '\0';
return 0;
} else {
-   if (intern-flags  SPL_FILE_DIR_GLOB_REFETCH_PATH) {
-   if (intern-_path.v) {
-   efree(intern-_path.v);
-   }
-   intern-_path.s = 
php_glob_stream_get_path(intern-u.dir.dirp, 1, intern-_path_len);
-   intern-_path_type = IS_STRING;
-   }
return 1;
}
 }
 /* }}} */
 
+#define IS_SLASH_AT(type, zs, pos) (type == IS_UNICODE ? IS_U_SLASH(zs.u[pos]) 
: IS_SLASH(zs.s[pos]))
+
 /* {{{ spl_filesystem_dir_open */
 /* open a directory resource */
 static void spl_filesystem_dir_open(spl_filesystem_object* intern, zend_uchar 
type, zstr path, int path_len TSRMLS_DC)
 {
-   int options = REPORT_ERRORS, flags;
-   
-   if (intern-flags  SPL_FILE_DIR_GLOB_USE) {
+   int options = REPORT_ERRORS;
+
+#if HELLY_0
+   if (php_stream_is(intern-u.dir.dirp, php_glob_stream_ops)) {
options |= STREAM_USE_GLOB_DIR_OPEN;
}
+#endif
 
intern-type = SPL_FS_DIR;
intern-_path_type= type;
intern-_path_len = path_len;
intern-u.dir.dirp = php_stream_u_opendir(type, path, path_len, 
options, NULL);
 
-   if (intern-u.dir.dirp  php_stream_is(intern-u.dir.dirp, 
php_glob_stream_ops)) {
-   intern-_path.s = php_glob_stream_get_path(intern-u.dir.dirp, 
1, intern-_path_len);
-   intern-_path_type = IS_STRING;
-   intern-flags |= SPL_FILE_DIR_GLOB_USE;
-   php_glob_stream_get_count(intern-u.dir.dirp, flags);
-   if (flags  GLOB_APPEND) {
-   intern-flags |= SPL_FILE_DIR_GLOB_REFETCH_PATH;
-   } else {
-   intern-flags = ~SPL_FILE_DIR_GLOB_REFETCH_PATH;
-   }
-   } else if (intern-_path_len  IS_SLASH_AT(type, path, 
intern-_path_len-1)) {
+   if (intern-_path_len  IS_SLASH_AT(type, path, intern-_path_len-1)) {
intern-_path = ezstrndup(type, path, --intern-_path_len);
-   intern-flags = 
~(SPL_FILE_DIR_GLOB_USE|SPL_FILE_DIR_GLOB_REFETCH_PATH);
} else {
intern-_path = ezstrndup(type, path, intern-_path_len);
- 

[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2008-01-31 Thread Rob Richards
rrichards   Thu Jan 31 11:09:50 2008 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  fix win32 build
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.141r2=1.142diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.141 
php-src/ext/spl/spl_directory.c:1.142
--- php-src/ext/spl/spl_directory.c:1.141   Wed Jan 30 23:49:49 2008
+++ php-src/ext/spl/spl_directory.c Thu Jan 31 11:09:50 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.141 2008/01/30 23:49:49 helly Exp $ */
+/* $Id: spl_directory.c,v 1.142 2008/01/31 11:09:50 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -168,10 +168,10 @@
 {
if (intern-type == SPL_FS_DIR) {
if (php_stream_is(intern-u.dir.dirp ,php_glob_stream_ops)) {
+   zstr ret;
if (type) {
*type = IS_STRING;
}
-   zstr ret;
ret.s = php_glob_stream_get_path(intern-u.dir.dirp, 0, 
len);
return ret;
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_directory.h

2008-01-30 Thread Marcus Boerger
helly   Wed Jan 30 23:49:49 2008 UTC

  Modified files:  
/php-src/ext/splspl_directory.c spl_directory.h 
  Log:
  - MFB SplDirectoryIterator/glob:// stream integration
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.140r2=1.141diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.140 
php-src/ext/spl/spl_directory.c:1.141
--- php-src/ext/spl/spl_directory.c:1.140   Mon Dec 31 07:12:15 2007
+++ php-src/ext/spl/spl_directory.c Wed Jan 30 23:49:49 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.140 2007/12/31 07:12:15 sebastian Exp $ */
+/* $Id: spl_directory.c,v 1.141 2008/01/30 23:49:49 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -85,8 +85,8 @@

zend_object_std_dtor(intern-std TSRMLS_CC);

-   if (intern-path.v) {
-   efree(intern-path.v);
+   if (intern-_path.v) {
+   efree(intern-_path.v);
}
if (intern-file_name.v) {
efree(intern-file_name.v);
@@ -164,8 +164,31 @@
 }
 /* }}} */
 
+PHPAPI zstr spl_filesystem_object_get_path(spl_filesystem_object *intern, int 
*len, zend_uchar *type TSRMLS_DC) /* {{{ */
+{
+   if (intern-type == SPL_FS_DIR) {
+   if (php_stream_is(intern-u.dir.dirp ,php_glob_stream_ops)) {
+   if (type) {
+   *type = IS_STRING;
+   }
+   zstr ret;
+   ret.s = php_glob_stream_get_path(intern-u.dir.dirp, 0, 
len);
+   return ret;
+   }
+   }
+   if (len) {
+   *len = intern-_path_len;
+   }
+   if (type) {
+   *type = intern-_path_type;
+   }
+   return intern-_path;
+} /* }}} */
+
 static inline void spl_filesystem_object_get_file_name(spl_filesystem_object 
*intern TSRMLS_DC) /* {{{ */
 {
+   zstr path;
+   zend_uchar path_type;
if (!intern-file_name.v) {
switch (intern-type) {
case SPL_FS_INFO:
@@ -173,8 +196,9 @@
php_error_docref(NULL TSRMLS_CC, E_ERROR, Object not 
initialized);
break;
case SPL_FS_DIR:
-   intern-file_name_len = zspprintf(intern-path_type, 
intern-file_name, 0, %R%c%s, intern-path_type, intern-path, 
DEFAULT_SLASH, intern-u.dir.entry.d_name);
-   intern-file_name_type = intern-path_type;
+   path = spl_filesystem_object_get_path(intern, NULL, 
path_type TSRMLS_CC);
+   intern-file_name_len = zspprintf(path_type, 
intern-file_name, 0, %R%c%s, path_type, path, DEFAULT_SLASH, 
intern-u.dir.entry.d_name);
+   intern-file_name_type = path_type;
break;
}
}
@@ -189,10 +213,11 @@
return 0;
} else {
if (intern-flags  SPL_FILE_DIR_GLOB_REFETCH_PATH) {
-   if (intern-path.v) {
-   efree(intern-path.v);
+   if (intern-_path.v) {
+   efree(intern-_path.v);
}
-   intern-path.s = 
php_glob_stream_get_path(intern-u.dir.dirp, 1, intern-path_len);
+   intern-_path.s = 
php_glob_stream_get_path(intern-u.dir.dirp, 1, intern-_path_len);
+   intern-_path_type = IS_STRING;
}
return 1;
}
@@ -210,13 +235,13 @@
}
 
intern-type = SPL_FS_DIR;
-   intern-path_type= type;
-   intern-path_len = path_len;
+   intern-_path_type= type;
+   intern-_path_len = path_len;
intern-u.dir.dirp = php_stream_u_opendir(type, path, path_len, 
options, NULL);
 
if (intern-u.dir.dirp  php_stream_is(intern-u.dir.dirp, 
php_glob_stream_ops)) {
-   intern-path.s = php_glob_stream_get_path(intern-u.dir.dirp, 
1, intern-path_len);
-   intern-path_type = IS_STRING;
+   intern-_path.s = php_glob_stream_get_path(intern-u.dir.dirp, 
1, intern-_path_len);
+   intern-_path_type = IS_STRING;
intern-flags |= SPL_FILE_DIR_GLOB_USE;
php_glob_stream_get_count(intern-u.dir.dirp, flags);
if (flags  GLOB_APPEND) {
@@ -224,11 +249,11 @@
} else {
intern-flags = ~SPL_FILE_DIR_GLOB_REFETCH_PATH;
}
-   } else if (intern-path_len  IS_SLASH_AT(type, path, 
intern-path_len-1)) {
-   intern-path = ezstrndup(type, path, --intern-path_len);
+   } else if (intern-_path_len  IS_SLASH_AT(type, path, 
intern-_path_len-1)) {
+   intern-_path = ezstrndup(type, path, --intern-_path_len);
intern-flags = 

[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2007-10-05 Thread David Soria Parra
dsp Fri Oct  5 09:38:54 2007 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  WS/Indent fix.
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.137r2=1.138diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.137 
php-src/ext/spl/spl_directory.c:1.138
--- php-src/ext/spl/spl_directory.c:1.137   Wed Oct  3 10:31:03 2007
+++ php-src/ext/spl/spl_directory.c Fri Oct  5 09:38:54 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.137 2007/10/03 10:31:03 dsp Exp $ */
+/* $Id: spl_directory.c,v 1.138 2007/10/05 09:38:54 dsp Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -378,8 +378,7 @@
if (!file_path.v || !file_path_len) {
 #if defined(PHP_WIN32)
zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, 
Cannot create SplFileInfo for empty path);
-   if (file_path.v  !use_copy)
-   {
+   if (file_path.v  !use_copy) {
efree(file_path.v);
}
 #else
@@ -2156,29 +2155,29 @@
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |sss, delim, 
d_len, enclo, e_len, esc, esc_len) == SUCCESS) {
switch(ZEND_NUM_ARGS())
{
-   case 3:
-   if (esc_len != 1) {
-   php_error_docref(NULL TSRMLS_CC, 
E_WARNING, escape must be a character);
-   RETURN_FALSE;
-   }
-   escape = esc[0];
-
-   case 2:
-   if (e_len != 1) {
-   php_error_docref(NULL TSRMLS_CC, 
E_WARNING, enclosure must be a character);
-   RETURN_FALSE;
-   }
-   enclosure = enclo[0];
-   /* no break */
-   case 1:
-   if (d_len != 1) {
-   php_error_docref(NULL TSRMLS_CC, 
E_WARNING, delimiter must be a character);
-   RETURN_FALSE;
-   }
-   delimiter = delim[0];
-   /* no break */
-   case 0:
-   break;
+   case 3:
+   if (esc_len != 1) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
escape must be a character);
+   RETURN_FALSE;
+   }
+   escape = esc[0];
+   
+   case 2:
+   if (e_len != 1) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
enclosure must be a character);
+   RETURN_FALSE;
+   }
+   enclosure = enclo[0];
+   /* no break */
+   case 1:
+   if (d_len != 1) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
delimiter must be a character);
+   RETURN_FALSE;
+   }
+   delimiter = delim[0];
+   /* no break */
+   case 0:
+   break;
}
spl_filesystem_file_read_csv(intern, delimiter, enclosure, 
escape, return_value TSRMLS_CC);
}
@@ -2197,29 +2196,29 @@
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |sss, delim, 
d_len, enclo, e_len, esc, esc_len) == SUCCESS) {
switch(ZEND_NUM_ARGS())
{
-case 3:
-   if (esc_len != 1) {
-   php_error_docref(NULL TSRMLS_CC, 
E_WARNING, escape must be a character);
-   RETURN_FALSE;
-   }
-   escape = esc[0];
-/* no break */
-   case 2:
-   if (e_len != 1) {
-   php_error_docref(NULL TSRMLS_CC, 
E_WARNING, enclosure must be a character);
-   RETURN_FALSE;
-   }
-   enclosure = enclo[0];
-   /* no break */
-   case 1:
-   if (d_len != 1) {
-   php_error_docref(NULL TSRMLS_CC, 
E_WARNING, delimiter must be a character);
-   RETURN_FALSE;
-   }
-   

Re: [PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_directory.h /ext/standard file.c file.h /ext/standard/tests/file bug40501.csv bug40501.phpt fgetcsv_error.phpt

2007-10-03 Thread Marcus Boerger
Hello David,

  can you MFH this to 5.3.

marcus

Wednesday, October 3, 2007, 12:31:04 PM, you wrote:

 http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.136r2=1.137diff_format=u
 Index: php-src/ext/spl/spl_directory.c
 diff -u php-src/ext/spl/spl_directory.c:1.136
 php-src/ext/spl/spl_directory.c:1.137
 --- php-src/ext/spl/spl_directory.c:1.136   Thu Sep 27 18:28:42 2007
 +++ php-src/ext/spl/spl_directory.c Wed Oct  3 10:31:03 2007
 @@ -16,7 +16,7 @@
 +--+
   */
  
 -/* $Id: spl_directory.c,v 1.136 2007/09/27 18:28:42 dmitry Exp $ */
 +/* $Id: spl_directory.c,v 1.137 2007/10/03 10:31:03 dsp Exp $ */
  
  #ifdef HAVE_CONFIG_H
  # include config.h
 @@ -1771,7 +1771,7 @@
 spl_filesystem_file_call(intern, func_ptr, pass_num_args, 
 return_value, arg2
 TSRMLS_CC); \
  }
  
 -static int spl_filesystem_file_read_csv(spl_filesystem_object *intern, char 
 delimiter, char
 enclosure, zval *return_value TSRMLS_DC) /* {{{ */
 +static int spl_filesystem_file_read_csv(spl_filesystem_object *intern, char 
 delimiter, char
 enclosure, char escape, zval *return_value TSRMLS_DC) /* {{{ */
  {
 int ret = SUCCESS;
 
 @@ -1788,7 +1788,7 @@
 }
 ALLOC_INIT_ZVAL(intern-u.file.current_zval);
  
 -   php_fgetcsv(intern-u.file.stream, delimiter, enclosure, 
 buf_len, buf,
 intern-u.file.current_zval TSRMLS_CC);
 +   php_fgetcsv(intern-u.file.stream, delimiter, enclosure, 
 escape, buf_len, buf,
 intern-u.file.current_zval TSRMLS_CC);
 if (return_value) {
 if (Z_TYPE_P(return_value) != IS_NULL) {
 zval_dtor(return_value);
 @@ -1814,7 +1814,7 @@
 return FAILURE;
 }
 if (intern-flags  SPL_FILE_OBJECT_READ_CSV) {
 -   return spl_filesystem_file_read_csv(intern, 
 intern-u.file.delimiter,
 intern-u.file.enclosure, NULL TSRMLS_CC);
 +   return spl_filesystem_file_read_csv(intern, 
 intern-u.file.delimiter,
 intern-u.file.enclosure, intern-u.file.escape, NULL TSRMLS_CC);
 } else {
 zend_call_method_with_0_params(this_ptr, 
 Z_OBJCE_P(getThis()),
 intern-u.file.func_getCurr, getCurrentLine, retval);
 }
 @@ -2149,13 +2149,20 @@
  SPL_METHOD(SplFileObject, fgetcsv)
  {
 spl_filesystem_object *intern =
 (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 -   char delimiter = intern-u.file.delimiter, enclosure = 
 intern-u.file.enclosure;
 -   char *delim, *enclo;
 -   int d_len, e_len;
 +   char delimiter = intern-u.file.delimiter, enclosure = 
 intern-u.file.enclosure, escape
 = intern-u.file.escape;
 +   char *delim, *enclo, *esc;
 +   int d_len, e_len, esc_len;
 
 -   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |ss, delim, 
 d_len, enclo,
 e_len) == SUCCESS) {
 +   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |sss, delim, 
 d_len, enclo,
 e_len, esc, esc_len) == SUCCESS) {
 switch(ZEND_NUM_ARGS())
 {
 +   case 3:
 +   if (esc_len != 1) {
 +   php_error_docref(NULL TSRMLS_CC, 
 E_WARNING, escape
 must be a character);
 +   RETURN_FALSE;
 +   }
 +   escape = esc[0];
 +
 case 2:
 if (e_len != 1) {
 php_error_docref(NULL TSRMLS_CC, 
 E_WARNING, enclosure
 must be a character);
 @@ -2173,23 +2180,30 @@
 case 0:
 break;
 }
 -   spl_filesystem_file_read_csv(intern, delimiter, enclosure, 
 return_value
 TSRMLS_CC);
 +   spl_filesystem_file_read_csv(intern, delimiter, enclosure, 
 escape, return_value
 TSRMLS_CC);
 }
  }
  /* }}} */
  
 -/* {{{ proto void SplFileObject::setCsvControl([string delimiter = ',' [, 
 string enclosure =
 '']])
 +/* {{{ proto void SplFileObject::setCsvControl([string delimiter = ',' [, 
 string enclosure =
 '' [, string escape = '\\']]])
 Set the delimiter and enclosure character used in fgetcsv */
  SPL_METHOD(SplFileObject, setCsvControl)
  {
 spl_filesystem_object *intern =
 (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 -   char delimiter = ',', enclosure = '';
 -   char *delim, *enclo;
 -   int d_len, e_len;
 +   char delimiter = ',', enclosure = '', escape='\\';
 +   char *delim, *enclo, *esc;
 +   int d_len, e_len, esc_len;
 
 -   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |ss, delim, 
 d_len, enclo,
 e_len) == SUCCESS) {
 +   if 

[PHP-CVS] cvs: php-src /ext/spl spl_directory.c /ext/spl/tests bug42364.phpt

2007-08-21 Thread Johannes Schl
johannesTue Aug 21 22:43:38 2007 UTC

  Added files: 
/php-src/ext/spl/tests  bug42364.phpt 

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - Fixed Bug #42364 Crash when using getRealPath with DirectoryIterator
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.134r2=1.135diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.134 
php-src/ext/spl/spl_directory.c:1.135
--- php-src/ext/spl/spl_directory.c:1.134   Tue Jun  5 13:51:29 2007
+++ php-src/ext/spl/spl_directory.c Tue Aug 21 22:43:38 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.134 2007/06/05 13:51:29 tony2001 Exp $ */
+/* $Id: spl_directory.c,v 1.135 2007/08/21 22:43:38 johannes Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1020,13 +1020,17 @@
 
php_set_error_handling(EH_THROW, spl_ce_RuntimeException TSRMLS_CC);
 
+   if (intern-type == SPL_FS_DIR  !intern-file_name.v  
intern-u.dir.entry.d_name[0]) {
+   spl_filesystem_object_get_file_name(intern TSRMLS_CC);
+   }
+
if (intern-file_name_type == IS_UNICODE) {
php_stream_path_encode(NULL, filename, filename_len, 
intern-file_name.u, intern-file_name_len, REPORT_ERRORS, FG(default_context));
} else {
filename = intern-file_name.s;
}
 
-   if (VCWD_REALPATH(filename, buff)) {
+   if (filename  VCWD_REALPATH(filename, buff)) {
 #ifdef ZTS
if (VCWD_ACCESS(buff, F_OK)) {
RETVAL_FALSE;
@@ -1044,6 +1048,11 @@
} else {
RETVAL_FALSE;
}
+
+   if (intern-file_name_type == IS_UNICODE  filename) {
+   efree(filename);
+   }
+
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
 }
 /* }}} */

http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/bug42364.phpt?view=markuprev=1.1
Index: php-src/ext/spl/tests/bug42364.phpt
+++ php-src/ext/spl/tests/bug42364.phpt
--TEST--
Bug #42364 (Crash when using getRealPath with DirectoryIterator)
--SKIPIF--
?php if (!extension_loaded(spl)) print skip; ?
--FILE--
?php
$it = new DirectoryIterator(dirname(__FILE__));

$count = 0;

foreach ($it as $e) {
$count++;
$type = gettype($e-getRealPath());
if ($type != string  $type != unicode) {
echo $e-getFilename(),  is a , gettype($e-getRealPath()), \n;
}
}

if ($count  0) {
echo Found $count entries!\n;
}
echo ===DONE===
?
--EXPECTF--
Found %i entries!
===DONE===

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2007-06-05 Thread Antony Dovgal
tony2001Tue Jun  5 12:02:38 2007 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  no readlink() on windows
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.132r2=1.133diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.132 
php-src/ext/spl/spl_directory.c:1.133
--- php-src/ext/spl/spl_directory.c:1.132   Sun Mar  4 12:13:20 2007
+++ php-src/ext/spl/spl_directory.c Tue Jun  5 12:02:38 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.132 2007/03/04 12:13:20 helly Exp $ */
+/* $Id: spl_directory.c,v 1.133 2007/06/05 12:02:38 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -981,7 +981,11 @@
link = intern-file_name.s;
}
 
-   ret = readlink(link, buff, MAXPATHLEN-1);
+#ifdef HAVE_SYMLINK
+   ret = readlink(intern-file_name, buff, MAXPATHLEN-1);
+#else
+   ret = -1; /* always fail if not implemented */
+#endif
 
if (ret == -1) {
zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, 
Unable to read link %R, error: %s, intern-file_name_type, intern-file_name, 
strerror(errno));

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2007-06-05 Thread Antony Dovgal
tony2001Tue Jun  5 13:51:29 2007 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  fix build
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.133r2=1.134diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.133 
php-src/ext/spl/spl_directory.c:1.134
--- php-src/ext/spl/spl_directory.c:1.133   Tue Jun  5 12:02:38 2007
+++ php-src/ext/spl/spl_directory.c Tue Jun  5 13:51:29 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.133 2007/06/05 12:02:38 tony2001 Exp $ */
+/* $Id: spl_directory.c,v 1.134 2007/06/05 13:51:29 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -982,7 +982,7 @@
}
 
 #ifdef HAVE_SYMLINK
-   ret = readlink(intern-file_name, buff, MAXPATHLEN-1);
+   ret = readlink(intern-file_name.s, buff, MAXPATHLEN-1);
 #else
ret = -1; /* always fail if not implemented */
 #endif

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_iterators.c

2007-03-04 Thread Marcus Boerger
helly   Sun Mar  4 12:02:16 2007 UTC

  Modified files:  
/php-src/ext/splspl_directory.c spl_iterators.c 
  Log:
  - Simplify
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.130r2=1.131diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.130 
php-src/ext/spl/spl_directory.c:1.131
--- php-src/ext/spl/spl_directory.c:1.130   Sun Mar  4 00:42:30 2007
+++ php-src/ext/spl/spl_directory.c Sun Mar  4 12:02:16 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.130 2007/03/04 00:42:30 helly Exp $ */
+/* $Id: spl_directory.c,v 1.131 2007/03/04 12:02:16 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -508,6 +508,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);
+}
+/* }}} */
+
 static HashTable* spl_filesystem_object_get_debug_info(zval *obj, int *is_temp 
TSRMLS_DC) /*  */
 {
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(obj TSRMLS_CC);
@@ -1149,7 +1161,7 @@
}
do {
spl_filesystem_dir_read(intern TSRMLS_CC);
-   } 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));
 }
 /* }}} */
 
@@ -1162,7 +1174,7 @@
intern-u.dir.index++;
do {
spl_filesystem_dir_read(intern TSRMLS_CC);
-   } 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.v) {
efree(intern-file_name.v);
intern-file_name = NULL_ZSTR;
@@ -1177,7 +1189,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_FALSE;
} else {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |b, 
allow_links) == FAILURE) {
@@ -1443,7 +1455,7 @@
object-u.dir.index++;
do {
spl_filesystem_dir_read(object TSRMLS_CC);
-   } while (!strcmp(object-u.dir.entry.d_name, .) || 
!strcmp(object-u.dir.entry.d_name, ..));
+   } while (spl_filesystem_is_dot(object-u.dir.entry.d_name));
if (object-file_name.v) {
efree(object-file_name.v);
object-file_name = NULL_ZSTR;
@@ -1467,7 +1479,7 @@
}
do {
spl_filesystem_dir_read(object TSRMLS_CC);
-   } while (!strcmp(object-u.dir.entry.d_name, .) || 
!strcmp(object-u.dir.entry.d_name, ..));
+   } while (spl_filesystem_is_dot(object-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.158r2=1.159diff_format=u
Index: php-src/ext/spl/spl_iterators.c
diff -u php-src/ext/spl/spl_iterators.c:1.158 
php-src/ext/spl/spl_iterators.c:1.159
--- php-src/ext/spl/spl_iterators.c:1.158   Thu Feb  8 20:13:49 2007
+++ php-src/ext/spl/spl_iterators.c Sun Mar  4 12:02:16 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_iterators.c,v 1.158 2007/02/08 20:13:49 helly Exp $ */
+/* $Id: spl_iterators.c,v 1.159 2007/03/04 12:02:16 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1349,41 +1349,6 @@
spl_dual_it_construct(INTERNAL_FUNCTION_PARAM_PASSTHRU, 
spl_ce_ParentIterator, spl_ce_RecursiveIterator, DIT_ParentIterator);
 } /* }}} */
 
-/* {{{ proto bool ParentIterator::hasChildren() U
-   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() U
-   Return the inner iterator's children contained in a ParentIterator */
-SPL_METHOD(ParentIterator, getChildren)
-{
-   spl_dual_it_object   *intern;
- 

[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2007-03-04 Thread Marcus Boerger
helly   Sun Mar  4 12:13:20 2007 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - Missed one is-dot check
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.131r2=1.132diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.131 
php-src/ext/spl/spl_directory.c:1.132
--- php-src/ext/spl/spl_directory.c:1.131   Sun Mar  4 12:02:16 2007
+++ php-src/ext/spl/spl_directory.c Sun Mar  4 12:13:20 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.131 2007/03/04 12:02:16 helly Exp $ */
+/* $Id: spl_directory.c,v 1.132 2007/03/04 12:13:20 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -839,7 +839,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));
 }
 /* }}} */
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2007-03-03 Thread Marcus Boerger
helly   Sat Mar  3 14:37:17 2007 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - [DOC] Add SplInfo::getBasename(), DirectoryIterator::getBasename()
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.121r2=1.122diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.121 
php-src/ext/spl/spl_directory.c:1.122
--- php-src/ext/spl/spl_directory.c:1.121   Mon Feb 26 22:46:13 2007
+++ php-src/ext/spl/spl_directory.c Sat Mar  3 14:37:17 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.121 2007/02/26 22:46:13 helly Exp $ */
+/* $Id: spl_directory.c,v 1.122 2007/03/03 14:37:17 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -656,6 +656,53 @@
 }
 /* }}} */
 
+/* {{{ proto string SplFileInfo::getBasename([string $suffix]) U
+   Returns filename component of path */
+SPL_METHOD(SplFileInfo, getBasename)
+{
+   spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+   zstr fname, suffix;
+   int flen, slen = 0;
+
+   suffix.v = 0;
+   if (intern-file_name_type == IS_UNICODE) { 
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |t, 
suffix.u, slen) == FAILURE) {
+   return;
+   }
+   } else {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |s, 
suffix.s, slen) == FAILURE) {
+   return;
+   }
+   }
+
+   if (intern-file_name_type == IS_UNICODE) { 
+   php_u_basename(fname.u, flen, suffix.u, slen, fname.u, flen 
TSRMLS_CC);
+   } else {
+   php_basename(fname.s, flen, suffix.s, slen, fname.s, flen 
TSRMLS_CC);
+   }
+
+   RETURN_ZSTRL(intern-file_name_type, fname, flen, 0);
+}
+/* }}}*/   
+
+/* {{{ proto string DirectoryIterator::getBasename([string $suffix]) U
+   Returns filename component of current dir entry */
+SPL_METHOD(DirectoryIterator, getBasename)
+{
+   spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+   char *suffix = 0, *fname;
+   int slen = 0, flen;
+   
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |s, suffix, 
slen) == FAILURE) {
+   return;
+   }
+
+   php_basename(intern-u.dir.entry.d_name, 
strlen(intern-u.dir.entry.d_name), suffix, slen, fname, flen TSRMLS_CC);
+
+   RETURN_RT_STRINGL(fname, flen, ZSTR_AUTOFREE);
+}
+/* }}} */
+
 /* {{{ proto string SplFileInfo::getPathname() U
Return path and filename */
 SPL_METHOD(SplFileInfo, getPathname)
@@ -1452,12 +1499,18 @@
ZEND_ARG_INFO(0, class_name)
 ZEND_END_ARG_INFO()
 
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_optinalSuffix, 0, 0, 0)
+   ZEND_ARG_INFO(0, suffix)
+ZEND_END_ARG_INFO()
+
 /* the method table */
 /* each method can have its own parameters and visibility */
 static zend_function_entry spl_SplFileInfo_functions[] = {
SPL_ME(SplFileInfo,   __construct,   arginfo_info___construct, 
ZEND_ACC_PUBLIC)
SPL_ME(SplFileInfo,   getPath,   NULL, ZEND_ACC_PUBLIC)
SPL_ME(SplFileInfo,   getFilename,   NULL, ZEND_ACC_PUBLIC)
+   SPL_ME(SplFileInfo,   getBasename,   arginfo_optinalSuffix, 
ZEND_ACC_PUBLIC)
SPL_ME(SplFileInfo,   getPathname,   NULL, ZEND_ACC_PUBLIC)
SPL_ME(SplFileInfo,   getPerms,  NULL, ZEND_ACC_PUBLIC)
SPL_ME(SplFileInfo,   getInode,  NULL, ZEND_ACC_PUBLIC)
@@ -1495,6 +1548,7 @@
 static zend_function_entry spl_DirectoryIterator_functions[] = {
SPL_ME(DirectoryIterator, __construct,   arginfo_dir___construct, 
ZEND_ACC_PUBLIC)
SPL_ME(DirectoryIterator, getFilename,   NULL, ZEND_ACC_PUBLIC)
+   SPL_ME(DirectoryIterator, getBasename,   arginfo_optinalSuffix, 
ZEND_ACC_PUBLIC)
SPL_ME(DirectoryIterator, isDot, NULL, ZEND_ACC_PUBLIC)
SPL_ME(DirectoryIterator, rewind,NULL, ZEND_ACC_PUBLIC)
SPL_ME(DirectoryIterator, valid, NULL, ZEND_ACC_PUBLIC)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2007-03-03 Thread Marcus Boerger
helly   Sat Mar  3 14:46:44 2007 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  # This block got lost somehow
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.122r2=1.123diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.122 
php-src/ext/spl/spl_directory.c:1.123
--- php-src/ext/spl/spl_directory.c:1.122   Sat Mar  3 14:37:17 2007
+++ php-src/ext/spl/spl_directory.c Sat Mar  3 14:46:44 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.122 2007/03/03 14:37:17 helly Exp $ */
+/* $Id: spl_directory.c,v 1.123 2007/03/03 14:46:44 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -675,6 +675,18 @@
}
}
 
+   if (intern-path_len  intern-path_len  intern-file_name_len) {
+   if (intern-file_name_type == IS_UNICODE) {
+   fname.u = intern-file_name.u + intern-path_len + 1;
+   } else {
+   fname.s = intern-file_name.s + intern-path_len + 1;
+   }
+   flen = intern-file_name_len - (intern-path_len + 1);
+   } else {
+   fname = intern-file_name;
+   flen = intern-file_name_len;
+   }
+
if (intern-file_name_type == IS_UNICODE) { 
php_u_basename(fname.u, flen, suffix.u, slen, fname.u, flen 
TSRMLS_CC);
} else {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2007-03-03 Thread Marcus Boerger
helly   Sat Mar  3 14:51:40 2007 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - SplFileInfo::getRealPath() is not always present
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.123r2=1.124diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.123 
php-src/ext/spl/spl_directory.c:1.124
--- php-src/ext/spl/spl_directory.c:1.123   Sat Mar  3 14:46:44 2007
+++ php-src/ext/spl/spl_directory.c Sat Mar  3 14:51:40 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.123 2007/03/03 14:46:44 helly Exp $ */
+/* $Id: spl_directory.c,v 1.124 2007/03/03 14:51:40 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1540,7 +1540,9 @@
SPL_ME(SplFileInfo,   isDir, NULL, ZEND_ACC_PUBLIC)
SPL_ME(SplFileInfo,   isLink,NULL, ZEND_ACC_PUBLIC)
SPL_ME(SplFileInfo,   getLinkTarget, NULL, ZEND_ACC_PUBLIC)
+#if (!defined(__BEOS__)  !defined(NETWARE)  HAVE_REALPATH) || defined(ZTS)
SPL_ME(SplFileInfo,   getRealPath,   NULL, ZEND_ACC_PUBLIC)
+#endif
SPL_ME(SplFileInfo,   getFileInfo,   arginfo_info_optinalFileClass, 
ZEND_ACC_PUBLIC)
SPL_ME(SplFileInfo,   getPathInfo,   arginfo_info_optinalFileClass, 
ZEND_ACC_PUBLIC)
SPL_ME(SplFileInfo,   openFile,  arginfo_info_openFile, 
ZEND_ACC_PUBLIC)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_directory.h

2007-03-03 Thread Marcus Boerger
helly   Sat Mar  3 21:41:56 2007 UTC

  Modified files:  
/php-src/ext/splspl_directory.c spl_directory.h 
  Log:
  - Add glob support for DirectoryIterator
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.124r2=1.125diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.124 
php-src/ext/spl/spl_directory.c:1.125
--- php-src/ext/spl/spl_directory.c:1.124   Sat Mar  3 14:51:40 2007
+++ php-src/ext/spl/spl_directory.c Sat Mar  3 21:41:56 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.124 2007/03/03 14:51:40 helly Exp $ */
+/* $Id: spl_directory.c,v 1.125 2007/03/03 21:41:56 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -178,15 +178,27 @@
 /* open a directory resource */
 static void spl_filesystem_dir_open(spl_filesystem_object* intern, zend_uchar 
type, zstr path, int path_len TSRMLS_DC)
 {
+   int options = REPORT_ERRORS;
+   
+   if (intern-flags  SPL_FILE_DIR_USE_GLOB) {
+   options |= STREAM_USE_GLOB_DIR_OPEN;
+   }
+
intern-type = SPL_FS_DIR;
intern-path_type= type;
intern-path_len = path_len;
-   intern-u.dir.dirp = php_stream_u_opendir(type, path, path_len, 
REPORT_ERRORS, NULL);
+   intern-u.dir.dirp = php_stream_u_opendir(type, path, path_len, 
options, NULL);
 
-   if (intern-path_len  IS_SLASH_AT(type, path, intern-path_len-1)) {
+   if (php_stream_is(intern-u.dir.dirp, php_glob_stream_ops)) {
+   intern-path.s = php_glob_stream_get_path(intern-u.dir.dirp, 
1, intern-path_len);
+   intern-path_type = IS_STRING;
+   intern-flags |= SPL_FILE_DIR_USE_GLOB;
+   } else if (intern-path_len  IS_SLASH_AT(type, path, 
intern-path_len-1)) {
intern-path = ezstrndup(type, path, --intern-path_len);
+   intern-flags = ~SPL_FILE_DIR_USE_GLOB;
} else {
intern-path = ezstrndup(type, path, intern-path_len);
+   intern-flags = ~SPL_FILE_DIR_USE_GLOB;
}
intern-u.dir.index = 0;
 
@@ -518,7 +530,7 @@
 }
 /*  */
 
-/* {{{ proto void DirectoryIterator::__construct(string path) U
+/* {{{ proto void DirectoryIterator::__construct(string $path, [int $flags = 
0]) U
  Cronstructs a new dir iterator from a path. */
 SPL_METHOD(DirectoryIterator, __construct)
 {
@@ -526,10 +538,11 @@
zstr path;
int len;
zend_uchar path_type;
+   long flags = 0;

php_set_error_handling(EH_THROW, spl_ce_RuntimeException TSRMLS_CC);
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t, path, len, 
path_type) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t|l, path, 
len, path_type, flags) == FAILURE) {
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
return;
}
@@ -542,10 +555,10 @@
 
intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() 
TSRMLS_CC);
 
+   intern-flags = flags;
spl_filesystem_dir_open(intern, path_type, path, len TSRMLS_CC);
 
intern-u.dir.is_recursive = instanceof_function(intern-std.ce, 
spl_ce_RecursiveDirectoryIterator TSRMLS_CC) ? 1 : 0;
-   intern-flags = 0;
 
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
 }
@@ -1077,9 +1090,9 @@
}
 
intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() 
TSRMLS_CC);
-   spl_filesystem_dir_open(intern, path_type, path, path_len TSRMLS_CC);
intern-u.dir.is_recursive = instanceof_function(intern-std.ce, 
spl_ce_RecursiveDirectoryIterator TSRMLS_CC) ? 1 : 0;
intern-flags = flags;
+   spl_filesystem_dir_open(intern, path_type, path, path_len TSRMLS_CC);
 
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
 }
@@ -1151,17 +1164,32 @@
Returns an iterator for the current entry if it is a directory */
 SPL_METHOD(RecursiveDirectoryIterator, getChildren)
 {
-   zval zpath;
+   zval zpath, zflags;
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
spl_filesystem_object *subdir;

spl_filesystem_object_get_file_name(intern TSRMLS_CC);
 
+   INIT_PZVAL(zflags);
+   ZVAL_LONG(zflags, intern-flags);
+
INIT_PZVAL(zpath);
-   ZVAL_ZSTRL(zpath, intern-file_name_type, intern-file_name, 
intern-file_name_len, 0);
+   if (intern-flags  SPL_FILE_DIR_USE_GLOB) {
+   Z_TYPE(zpath) = IS_STRING;
+   spprintf(Z_STRVAL(zpath), 0, %R%c%s,
+   intern-file_name_type, intern-file_name,
+   DEFAULT_SLASH,
+   php_glob_stream_get_pattern(intern-u.dir.dirp, 0, 
NULL));
+   } else {
+   ZVAL_ZSTRL(zpath, intern-file_name_type, intern-file_name, 
intern-file_name_len, 

[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2007-03-03 Thread Marcus Boerger
helly   Sat Mar  3 23:07:33 2007 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - Add DirectoryIterator::count()
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.125r2=1.126diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.125 
php-src/ext/spl/spl_directory.c:1.126
--- php-src/ext/spl/spl_directory.c:1.125   Sat Mar  3 21:41:56 2007
+++ php-src/ext/spl/spl_directory.c Sat Mar  3 23:07:33 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.125 2007/03/03 21:41:56 helly Exp $ */
+/* $Id: spl_directory.c,v 1.126 2007/03/03 23:07:33 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -189,7 +189,7 @@
intern-path_len = path_len;
intern-u.dir.dirp = php_stream_u_opendir(type, path, path_len, 
options, NULL);
 
-   if (php_stream_is(intern-u.dir.dirp, php_glob_stream_ops)) {
+   if (intern-u.dir.dirp  php_stream_is(intern-u.dir.dirp, 
php_glob_stream_ops)) {
intern-path.s = php_glob_stream_get_path(intern-u.dir.dirp, 
1, intern-path_len);
intern-path_type = IS_STRING;
intern-flags |= SPL_FILE_DIR_USE_GLOB;
@@ -629,6 +629,19 @@
 }
 /* }}} */
 
+/* {{{ proto string DirectoryIterator::count() U
+   Return number of entries in directory, works only when USE_GLOB is in 
effect */
+SPL_METHOD(DirectoryIterator, count)
+{
+   spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+
+   if (intern-flags  SPL_FILE_DIR_USE_GLOB) {
+   RETURN_LONG(php_glob_stream_get_count(intern-u.dir.dirp));
+   }
+   zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, Unable 
to determine count unless USE_GLOG flag is in effect);
+}
+/* }}} */
+
 /* {{{ proto string SplFileInfo::getPath() U
Return the path */
 SPL_METHOD(SplFileInfo, getPath)
@@ -1597,6 +1610,7 @@
SPL_ME(DirectoryIterator, key,   NULL, ZEND_ACC_PUBLIC)
SPL_ME(DirectoryIterator, current,   NULL, ZEND_ACC_PUBLIC)
SPL_ME(DirectoryIterator, next,  NULL, ZEND_ACC_PUBLIC)
+   SPL_ME(DirectoryIterator, count, NULL, ZEND_ACC_PUBLIC)
SPL_MA(DirectoryIterator, __toString, DirectoryIterator, getFilename, 
NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
 };

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_directory.h

2007-03-03 Thread Marcus Boerger
helly   Sat Mar  3 23:41:43 2007 UTC

  Modified files:  
/php-src/ext/splspl_directory.c spl_directory.h 
  Log:
  - Glob might require us to refetch the path for every entry
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.126r2=1.127diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.126 
php-src/ext/spl/spl_directory.c:1.127
--- php-src/ext/spl/spl_directory.c:1.126   Sat Mar  3 23:07:33 2007
+++ php-src/ext/spl/spl_directory.c Sat Mar  3 23:41:43 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.126 2007/03/03 23:07:33 helly Exp $ */
+/* $Id: spl_directory.c,v 1.127 2007/03/03 23:41:43 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -45,6 +45,14 @@
 #include ext/standard/php_filestat.h
 #include ext/standard/php_link.h
 
+#ifdef HAVE_GLOB
+# ifndef PHP_WIN32
+#  include glob.h
+# else
+#  include win32/glob.h
+# endif
+#endif
+
 /* declare the class handlers */
 static zend_object_handlers spl_filesystem_object_handlers;
 
@@ -174,11 +182,28 @@
 
 #define IS_SLASH_AT(type, zs, pos) (type == IS_UNICODE ? IS_U_SLASH(zs.u[pos]) 
: IS_SLASH(zs.s[pos]))
 
+static int spl_filesystem_dir_read(spl_filesystem_object *intern TSRMLS_DC) /* 
{{{ */
+{
+   if (!intern-u.dir.dirp || !php_stream_readdir(intern-u.dir.dirp, 
intern-u.dir.entry)) {
+   intern-u.dir.entry.d_name[0] = '\0';
+   return 0;
+   } else {
+   if (intern-flags  SPL_FILE_DIR_GLOB_REFETCH_PATH) {
+   if (intern-path.v) {
+   efree(intern-path.v);
+   }
+   intern-path.s = 
php_glob_stream_get_path(intern-u.dir.dirp, 1, intern-path_len);
+   }
+   return 1;
+   }
+}
+/* }}} */
+
 /* {{{ spl_filesystem_dir_open */
 /* open a directory resource */
 static void spl_filesystem_dir_open(spl_filesystem_object* intern, zend_uchar 
type, zstr path, int path_len TSRMLS_DC)
 {
-   int options = REPORT_ERRORS;
+   int options = REPORT_ERRORS, flags;

if (intern-flags  SPL_FILE_DIR_USE_GLOB) {
options |= STREAM_USE_GLOB_DIR_OPEN;
@@ -193,12 +218,18 @@
intern-path.s = php_glob_stream_get_path(intern-u.dir.dirp, 
1, intern-path_len);
intern-path_type = IS_STRING;
intern-flags |= SPL_FILE_DIR_USE_GLOB;
+   php_glob_stream_get_count(intern-u.dir.dirp, flags);
+   if (flags  GLOB_APPEND) {
+   intern-flags |= SPL_FILE_DIR_GLOB_REFETCH_PATH;
+   } else {
+   intern-flags = ~SPL_FILE_DIR_GLOB_REFETCH_PATH;
+   }
} else if (intern-path_len  IS_SLASH_AT(type, path, 
intern-path_len-1)) {
intern-path = ezstrndup(type, path, --intern-path_len);
-   intern-flags = ~SPL_FILE_DIR_USE_GLOB;
+   intern-flags = 
~(SPL_FILE_DIR_USE_GLOB|SPL_FILE_DIR_GLOB_REFETCH_PATH);
} else {
intern-path = ezstrndup(type, path, intern-path_len);
-   intern-flags = ~SPL_FILE_DIR_USE_GLOB;
+   intern-flags = 
~(SPL_FILE_DIR_USE_GLOB|SPL_FILE_DIR_GLOB_REFETCH_PATH);
}
intern-u.dir.index = 0;
 
@@ -206,9 +237,7 @@
/* throw exception: should've been already happened */
intern-u.dir.entry.d_name[0] = '\0';
} else {
-   if (!php_stream_readdir(intern-u.dir.dirp, 
intern-u.dir.entry)) {
-   intern-u.dir.entry.d_name[0] = '\0';
-   }
+   spl_filesystem_dir_read(intern TSRMLS_CC);
}
 }
 /* }}} */
@@ -574,9 +603,8 @@
if (intern-u.dir.dirp) {
php_stream_rewinddir(intern-u.dir.dirp);
}
-   if (!intern-u.dir.dirp || !php_stream_readdir(intern-u.dir.dirp, 
intern-u.dir.entry)) {
-   intern-u.dir.entry.d_name[0] = '\0';
-   }
+
+   spl_filesystem_dir_read(intern TSRMLS_CC);
 }
 /* }}} */
 
@@ -609,9 +637,7 @@
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
intern-u.dir.index++;
-   if (!intern-u.dir.dirp || !php_stream_readdir(intern-u.dir.dirp, 
intern-u.dir.entry)) {
-   intern-u.dir.entry.d_name[0] = '\0';
-   }
+   spl_filesystem_dir_read(intern TSRMLS_CC);
if (intern-file_name.v) {
efree(intern-file_name.v);
intern-file_name = NULL_ZSTR;
@@ -636,7 +662,7 @@
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
if (intern-flags  SPL_FILE_DIR_USE_GLOB) {
-   RETURN_LONG(php_glob_stream_get_count(intern-u.dir.dirp));
+   RETURN_LONG(php_glob_stream_get_count(intern-u.dir.dirp, 

[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_directory.h

2007-03-03 Thread Marcus Boerger
helly   Sun Mar  4 00:23:07 2007 UTC

  Modified files:  
/php-src/ext/splspl_directory.c spl_directory.h 
  Log:
  - Fix a minor issue with glob support - forgot to set length of string 
  - Add ability to not use glob on subdirs
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.127r2=1.128diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.127 
php-src/ext/spl/spl_directory.c:1.128
--- php-src/ext/spl/spl_directory.c:1.127   Sat Mar  3 23:41:43 2007
+++ php-src/ext/spl/spl_directory.c Sun Mar  4 00:23:07 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.127 2007/03/03 23:41:43 helly Exp $ */
+/* $Id: spl_directory.c,v 1.128 2007/03/04 00:23:07 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1206,24 +1206,22 @@
spl_filesystem_object_get_file_name(intern TSRMLS_CC);
 
INIT_PZVAL(zflags);
-   ZVAL_LONG(zflags, intern-flags);
-
INIT_PZVAL(zpath);
-   if (intern-flags  SPL_FILE_DIR_USE_GLOB) {
+   if ((intern-flags  
(SPL_FILE_DIR_USE_GLOB|SPL_FILE_DIR_NO_GLOB_CHILD)) == SPL_FILE_DIR_USE_GLOB) {
+   ZVAL_LONG(zflags, intern-flags);
Z_TYPE(zpath) = IS_STRING;
-   spprintf(Z_STRVAL(zpath), 0, %R%c%s,
+   Z_STRLEN(zpath) = spprintf(Z_STRVAL(zpath), 0, %R%c%s,
intern-file_name_type, intern-file_name,
DEFAULT_SLASH,
php_glob_stream_get_pattern(intern-u.dir.dirp, 0, 
NULL));
} else {
-   ZVAL_ZSTRL(zpath, intern-file_name_type, intern-file_name, 
intern-file_name_len, 0);
+   ZVAL_LONG(zflags, intern-flags  ~SPL_FILE_DIR_USE_GLOB);
+   ZVAL_ZSTRL(zpath, intern-file_name_type, intern-file_name, 
intern-file_name_len, 1);
}
 
spl_instantiate_arg_ex2(spl_ce_RecursiveDirectoryIterator, 
return_value, 0, zpath, zflags TSRMLS_CC);
 
-   if (intern-flags  SPL_FILE_DIR_USE_GLOB) {
-   efree(Z_STRVAL(zpath));
-   }
+   zval_dtor(zpath);
 
subdir = 
(spl_filesystem_object*)zend_object_store_get_object(return_value TSRMLS_CC);
if (subdir) {
@@ -2509,7 +2507,8 @@
REGISTER_SPL_SUB_CLASS_EX(DirectoryIterator, SplFileInfo, 
spl_filesystem_object_new, spl_DirectoryIterator_functions);
zend_class_implements(spl_ce_DirectoryIterator TSRMLS_CC, 1, 
zend_ce_iterator);
 
-   REGISTER_SPL_CLASS_CONST_LONG(DirectoryIterator, USE_GLOB, 
SPL_FILE_DIR_USE_GLOB);
+   REGISTER_SPL_CLASS_CONST_LONG(DirectoryIterator, USE_GLOB,
SPL_FILE_DIR_USE_GLOB);
+   REGISTER_SPL_CLASS_CONST_LONG(DirectoryIterator, NO_GLOB_CHILD,   
SPL_FILE_DIR_NO_GLOB_CHILD);
 
spl_ce_DirectoryIterator-get_iterator = 
spl_filesystem_dir_get_iterator;
 
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.h?r1=1.31r2=1.32diff_format=u
Index: php-src/ext/spl/spl_directory.h
diff -u php-src/ext/spl/spl_directory.h:1.31 
php-src/ext/spl/spl_directory.h:1.32
--- php-src/ext/spl/spl_directory.h:1.31Sat Mar  3 23:41:43 2007
+++ php-src/ext/spl/spl_directory.h Sun Mar  4 00:23:07 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.h,v 1.31 2007/03/03 23:41:43 helly Exp $ */
+/* $Id: spl_directory.h,v 1.32 2007/03/04 00:23:07 helly Exp $ */
 
 #ifndef SPL_DIRECTORY_H
 #define SPL_DIRECTORY_H
@@ -122,6 +122,7 @@
 
 #define SPL_FILE_DIR_USE_GLOB  0x1000 /* use glob for open 
dir*/
 #define SPL_FILE_DIR_GLOB_REFETCH_PATH 0x2000 /* whether we need to 
refetch the path in glob mode */
+#define SPL_FILE_DIR_NO_GLOB_CHILD 0x4000 /* do not use glob on 
childs */
 
 #endif /* SPL_DIRECTORY_H */
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_directory.h

2007-03-03 Thread Marcus Boerger
helly   Sun Mar  4 00:36:08 2007 UTC

  Modified files:  
/php-src/ext/splspl_directory.c spl_directory.h 
  Log:
  - Reverting glob on child logic makes globbing work better with the example
code
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.128r2=1.129diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.128 
php-src/ext/spl/spl_directory.c:1.129
--- php-src/ext/spl/spl_directory.c:1.128   Sun Mar  4 00:23:07 2007
+++ php-src/ext/spl/spl_directory.c Sun Mar  4 00:36:08 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.128 2007/03/04 00:23:07 helly Exp $ */
+/* $Id: spl_directory.c,v 1.129 2007/03/04 00:36:08 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1207,7 +1207,7 @@
 
INIT_PZVAL(zflags);
INIT_PZVAL(zpath);
-   if ((intern-flags  
(SPL_FILE_DIR_USE_GLOB|SPL_FILE_DIR_NO_GLOB_CHILD)) == SPL_FILE_DIR_USE_GLOB) {
+   if ((intern-flags  (SPL_FILE_DIR_USE_GLOB|SPL_FILE_DIR_CHILD_GLOB)) 
== (SPL_FILE_DIR_USE_GLOB|SPL_FILE_DIR_CHILD_GLOB)) {
ZVAL_LONG(zflags, intern-flags);
Z_TYPE(zpath) = IS_STRING;
Z_STRLEN(zpath) = spprintf(Z_STRVAL(zpath), 0, %R%c%s,
@@ -1215,7 +1215,7 @@
DEFAULT_SLASH,
php_glob_stream_get_pattern(intern-u.dir.dirp, 0, 
NULL));
} else {
-   ZVAL_LONG(zflags, intern-flags  ~SPL_FILE_DIR_USE_GLOB);
+   ZVAL_LONG(zflags, intern-flags  
~(SPL_FILE_DIR_USE_GLOB|SPL_FILE_DIR_CHILD_GLOB));
ZVAL_ZSTRL(zpath, intern-file_name_type, intern-file_name, 
intern-file_name_len, 1);
}
 
@@ -2508,7 +2508,7 @@
zend_class_implements(spl_ce_DirectoryIterator TSRMLS_CC, 1, 
zend_ce_iterator);
 
REGISTER_SPL_CLASS_CONST_LONG(DirectoryIterator, USE_GLOB,
SPL_FILE_DIR_USE_GLOB);
-   REGISTER_SPL_CLASS_CONST_LONG(DirectoryIterator, NO_GLOB_CHILD,   
SPL_FILE_DIR_NO_GLOB_CHILD);
+   REGISTER_SPL_CLASS_CONST_LONG(DirectoryIterator, CHILD_GLOB,  
SPL_FILE_DIR_CHILD_GLOB);
 
spl_ce_DirectoryIterator-get_iterator = 
spl_filesystem_dir_get_iterator;
 
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.h?r1=1.32r2=1.33diff_format=u
Index: php-src/ext/spl/spl_directory.h
diff -u php-src/ext/spl/spl_directory.h:1.32 
php-src/ext/spl/spl_directory.h:1.33
--- php-src/ext/spl/spl_directory.h:1.32Sun Mar  4 00:23:07 2007
+++ php-src/ext/spl/spl_directory.h Sun Mar  4 00:36:08 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.h,v 1.32 2007/03/04 00:23:07 helly Exp $ */
+/* $Id: spl_directory.h,v 1.33 2007/03/04 00:36:08 helly Exp $ */
 
 #ifndef SPL_DIRECTORY_H
 #define SPL_DIRECTORY_H
@@ -122,7 +122,7 @@
 
 #define SPL_FILE_DIR_USE_GLOB  0x1000 /* use glob for open 
dir*/
 #define SPL_FILE_DIR_GLOB_REFETCH_PATH 0x2000 /* whether we need to 
refetch the path in glob mode */
-#define SPL_FILE_DIR_NO_GLOB_CHILD 0x4000 /* do not use glob on 
childs */
+#define SPL_FILE_DIR_CHILD_GLOB0x4000 /* do use glob on childs 
*/
 
 #endif /* SPL_DIRECTORY_H */
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_directory.h

2007-03-03 Thread Marcus Boerger
helly   Sun Mar  4 00:42:30 2007 UTC

  Modified files:  
/php-src/ext/splspl_directory.c spl_directory.h 
  Log:
  - And finally use prefix style names for consistency sake
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.129r2=1.130diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.129 
php-src/ext/spl/spl_directory.c:1.130
--- php-src/ext/spl/spl_directory.c:1.129   Sun Mar  4 00:36:08 2007
+++ php-src/ext/spl/spl_directory.c Sun Mar  4 00:42:30 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.129 2007/03/04 00:36:08 helly Exp $ */
+/* $Id: spl_directory.c,v 1.130 2007/03/04 00:42:30 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -205,7 +205,7 @@
 {
int options = REPORT_ERRORS, flags;

-   if (intern-flags  SPL_FILE_DIR_USE_GLOB) {
+   if (intern-flags  SPL_FILE_DIR_GLOB_USE) {
options |= STREAM_USE_GLOB_DIR_OPEN;
}
 
@@ -217,7 +217,7 @@
if (intern-u.dir.dirp  php_stream_is(intern-u.dir.dirp, 
php_glob_stream_ops)) {
intern-path.s = php_glob_stream_get_path(intern-u.dir.dirp, 
1, intern-path_len);
intern-path_type = IS_STRING;
-   intern-flags |= SPL_FILE_DIR_USE_GLOB;
+   intern-flags |= SPL_FILE_DIR_GLOB_USE;
php_glob_stream_get_count(intern-u.dir.dirp, flags);
if (flags  GLOB_APPEND) {
intern-flags |= SPL_FILE_DIR_GLOB_REFETCH_PATH;
@@ -226,10 +226,10 @@
}
} else if (intern-path_len  IS_SLASH_AT(type, path, 
intern-path_len-1)) {
intern-path = ezstrndup(type, path, --intern-path_len);
-   intern-flags = 
~(SPL_FILE_DIR_USE_GLOB|SPL_FILE_DIR_GLOB_REFETCH_PATH);
+   intern-flags = 
~(SPL_FILE_DIR_GLOB_USE|SPL_FILE_DIR_GLOB_REFETCH_PATH);
} else {
intern-path = ezstrndup(type, path, intern-path_len);
-   intern-flags = 
~(SPL_FILE_DIR_USE_GLOB|SPL_FILE_DIR_GLOB_REFETCH_PATH);
+   intern-flags = 
~(SPL_FILE_DIR_GLOB_USE|SPL_FILE_DIR_GLOB_REFETCH_PATH);
}
intern-u.dir.index = 0;
 
@@ -661,7 +661,7 @@
 {
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
-   if (intern-flags  SPL_FILE_DIR_USE_GLOB) {
+   if (intern-flags  SPL_FILE_DIR_GLOB_USE) {
RETURN_LONG(php_glob_stream_get_count(intern-u.dir.dirp, 
NULL));
}
zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, Unable 
to determine count unless USE_GLOG flag is in effect);
@@ -1207,7 +1207,7 @@
 
INIT_PZVAL(zflags);
INIT_PZVAL(zpath);
-   if ((intern-flags  (SPL_FILE_DIR_USE_GLOB|SPL_FILE_DIR_CHILD_GLOB)) 
== (SPL_FILE_DIR_USE_GLOB|SPL_FILE_DIR_CHILD_GLOB)) {
+   if ((intern-flags  (SPL_FILE_DIR_GLOB_USE|SPL_FILE_DIR_GLOB_CHILD)) 
== (SPL_FILE_DIR_GLOB_USE|SPL_FILE_DIR_GLOB_CHILD)) {
ZVAL_LONG(zflags, intern-flags);
Z_TYPE(zpath) = IS_STRING;
Z_STRLEN(zpath) = spprintf(Z_STRVAL(zpath), 0, %R%c%s,
@@ -1215,7 +1215,7 @@
DEFAULT_SLASH,
php_glob_stream_get_pattern(intern-u.dir.dirp, 0, 
NULL));
} else {
-   ZVAL_LONG(zflags, intern-flags  
~(SPL_FILE_DIR_USE_GLOB|SPL_FILE_DIR_CHILD_GLOB));
+   ZVAL_LONG(zflags, intern-flags  
~(SPL_FILE_DIR_GLOB_USE|SPL_FILE_DIR_GLOB_CHILD));
ZVAL_ZSTRL(zpath, intern-file_name_type, intern-file_name, 
intern-file_name_len, 1);
}
 
@@ -2507,8 +2507,8 @@
REGISTER_SPL_SUB_CLASS_EX(DirectoryIterator, SplFileInfo, 
spl_filesystem_object_new, spl_DirectoryIterator_functions);
zend_class_implements(spl_ce_DirectoryIterator TSRMLS_CC, 1, 
zend_ce_iterator);
 
-   REGISTER_SPL_CLASS_CONST_LONG(DirectoryIterator, USE_GLOB,
SPL_FILE_DIR_USE_GLOB);
-   REGISTER_SPL_CLASS_CONST_LONG(DirectoryIterator, CHILD_GLOB,  
SPL_FILE_DIR_CHILD_GLOB);
+   REGISTER_SPL_CLASS_CONST_LONG(DirectoryIterator, GLOB,
SPL_FILE_DIR_GLOB_USE);
+   REGISTER_SPL_CLASS_CONST_LONG(DirectoryIterator, GLOB_CHILD,  
SPL_FILE_DIR_GLOB_CHILD);
 
spl_ce_DirectoryIterator-get_iterator = 
spl_filesystem_dir_get_iterator;
 
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.h?r1=1.33r2=1.34diff_format=u
Index: php-src/ext/spl/spl_directory.h
diff -u php-src/ext/spl/spl_directory.h:1.33 
php-src/ext/spl/spl_directory.h:1.34
--- php-src/ext/spl/spl_directory.h:1.33Sun Mar  4 00:36:08 2007
+++ php-src/ext/spl/spl_directory.h Sun Mar  4 00:42:30 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.h,v 1.33 2007/03/04 00:36:08 helly 

[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2007-02-26 Thread Marcus Boerger
helly   Mon Feb 26 22:46:13 2007 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - Add missing access check
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.120r2=1.121diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.120 
php-src/ext/spl/spl_directory.c:1.121
--- php-src/ext/spl/spl_directory.c:1.120   Mon Feb 26 22:32:57 2007
+++ php-src/ext/spl/spl_directory.c Mon Feb 26 22:46:13 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.120 2007/02/26 22:32:57 helly Exp $ */
+/* $Id: spl_directory.c,v 1.121 2007/02/26 22:46:13 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -900,6 +900,11 @@
}
 
if (VCWD_REALPATH(filename, buff)) {
+#ifdef ZTS
+   if (VCWD_ACCESS(buff, F_OK)) {
+   RETVAL_FALSE;
+   } else
+#endif
if (UG(unicode)) {
if (php_stream_path_decode(NULL, path, path_len, 
buff, strlen(buff), REPORT_ERRORS, FG(default_context)) == SUCCESS) {
RETVAL_UNICODEL(path, path_len, 0);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2007-02-20 Thread Marcus Boerger
helly   Tue Feb 20 13:07:53 2007 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - Make stat based functions throw an exception
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.118r2=1.119diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.118 
php-src/ext/spl/spl_directory.c:1.119
--- php-src/ext/spl/spl_directory.c:1.118   Mon Feb 19 20:32:39 2007
+++ php-src/ext/spl/spl_directory.c Tue Feb 20 13:07:53 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.118 2007/02/19 20:32:39 helly Exp $ */
+/* $Id: spl_directory.c,v 1.119 2007/02/20 13:07:53 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -758,8 +758,10 @@
 { \
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); \
  \
+   php_set_error_handling(EH_THROW, spl_ce_RuntimeException TSRMLS_CC);\
spl_filesystem_object_get_file_name(intern TSRMLS_CC); \
php_u_stat(intern-file_name_type, intern-file_name, 
intern-file_name_len, func_num, FG(default_context), return_value TSRMLS_CC); \
+   php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);\
 }
 /* }}} */
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2007-02-19 Thread Marcus Boerger
helly   Mon Feb 19 20:32:39 2007 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - Bugfix #40546: SplFileInfo::getPathInfo() throws an execption if directory 
is in root dir.
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.117r2=1.118diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.117 
php-src/ext/spl/spl_directory.c:1.118
--- php-src/ext/spl/spl_directory.c:1.117   Sat Jan 20 16:19:20 2007
+++ php-src/ext/spl/spl_directory.c Mon Feb 19 20:32:39 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.117 2007/01/20 16:19:20 helly Exp $ */
+/* $Id: spl_directory.c,v 1.118 2007/02/19 20:32:39 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -334,11 +334,21 @@
zval *arg1;

if (!file_path.v || !file_path_len) {
+#if defined(PHP_WIN32)
zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, 
Cannot create SplFileInfo for empty path);
if (file_path.v  !use_copy)
{
efree(file_path.v);
}
+#else
+   if (file_path.v  !use_copy) {
+   efree(file_path.v);
+   }
+   use_copy = 1;
+   file_path_len = 1;
+   file_path.s = /;
+   file_type = IS_STRING;
+#endif
return NULL;
}
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2007-01-18 Thread Marcus Boerger
helly   Thu Jan 18 21:40:18 2007 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - Simplify by using zspprintf
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.112r2=1.113diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.112 
php-src/ext/spl/spl_directory.c:1.113
--- php-src/ext/spl/spl_directory.c:1.112   Wed Jan 17 22:43:53 2007
+++ php-src/ext/spl/spl_directory.c Thu Jan 18 21:40:18 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.112 2007/01/17 22:43:53 helly Exp $ */
+/* $Id: spl_directory.c,v 1.113 2007/01/18 21:40:18 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -164,11 +164,7 @@
php_error_docref(NULL TSRMLS_CC, E_ERROR, Object not 
initialized);
break;
case SPL_FS_DIR:
-   if (intern-path_type == IS_UNICODE) {
-   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_len = zspprintf(intern-path_type, 
intern-file_name, 0, %R%c%s, intern-path_type, intern-path, 
DEFAULT_SLASH, intern-u.dir.entry.d_name);
intern-file_name_type = intern-path_type;
break;
}
@@ -964,10 +960,8 @@

subdir = 
(spl_filesystem_object*)zend_object_store_get_object(return_value TSRMLS_CC);
if (subdir) {
-   if (intern-u.dir.sub_path_type == IS_UNICODE  
intern-u.dir.sub_path.u  intern-u.dir.sub_path.u[0]) {
-   subdir-u.dir.sub_path_len = 
uspprintf(subdir-u.dir.sub_path.s, 0, %r%c%s, intern-u.dir.sub_path, 
DEFAULT_SLASH, intern-u.dir.entry.d_name);
-   } else if (intern-u.dir.sub_path_type == IS_STRING  
intern-u.dir.sub_path.s  intern-u.dir.sub_path.s[0]) {
-   subdir-u.dir.sub_path_len = 
spprintf(subdir-u.dir.sub_path.s, 0, %s%c%s, intern-u.dir.sub_path, 
DEFAULT_SLASH, intern-u.dir.entry.d_name);
+   if (intern-u.dir.sub_path.v  intern-u.dir.sub_path_len  1) 
{
+   subdir-u.dir.sub_path_len = 
zspprintf(intern-u.dir.sub_path_type, subdir-u.dir.sub_path, 0, %R%c%s, 
intern-u.dir.sub_path_type, intern-u.dir.sub_path, DEFAULT_SLASH, 
intern-u.dir.entry.d_name);
} else {
subdir-u.dir.sub_path_len = 
strlen(intern-u.dir.entry.d_name);
subdir-u.dir.sub_path_type = IS_STRING;
@@ -1001,15 +995,11 @@
 {
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
zstr sub_name;
-   int len;
+   int sub_len;
 
-   if (intern-u.dir.sub_path.u) {
-   if (intern-u.dir.sub_path_type == IS_UNICODE) {
-   len = uspprintf(sub_name.s, 0, %r%c%s, 
intern-u.dir.sub_path, DEFAULT_SLASH, intern-u.dir.entry.d_name);
-   } else {
-   len = spprintf(sub_name.s, 0, %s%c%s, 
intern-u.dir.sub_path, DEFAULT_SLASH, intern-u.dir.entry.d_name);
-   }
-   RETURN_ZSTRL(intern-u.dir.sub_path_type, sub_name, len, 0);
+   if (intern-u.dir.sub_path.v) {
+   sub_len = zspprintf(intern-u.dir.sub_path_type, sub_name, 0, 
%R%c%s, intern-u.dir.sub_path_type, intern-u.dir.sub_path, DEFAULT_SLASH, 
intern-u.dir.entry.d_name);
+   RETURN_ZSTRL(intern-u.dir.sub_path_type, sub_name, sub_len, 0);
} else {
RETURN_RT_STRING(intern-u.dir.entry.d_name, ZSTR_DUPLICATE);
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2007-01-18 Thread Antony Dovgal
tony2001Thu Jan 18 22:52:32 2007 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  fix win32 build
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.113r2=1.114diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.113 
php-src/ext/spl/spl_directory.c:1.114
--- php-src/ext/spl/spl_directory.c:1.113   Thu Jan 18 21:40:18 2007
+++ php-src/ext/spl/spl_directory.c Thu Jan 18 22:52:32 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.113 2007/01/18 21:40:18 helly Exp $ */
+/* $Id: spl_directory.c,v 1.114 2007/01/18 22:52:32 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1628,7 +1628,7 @@
p1.s = strrchr(intern-file_name.s, '/');
}
 #if defined(PHP_WIN32) || defined(NETWARE)
-   if (type == IS_UNICODE) {
+   if (intern-file_name_type == IS_UNICODE) {
p2.u = u_strrchr(intern-file_name.u, '\\');
} else {
p2.s = strrchr(intern-file_name.s, '\\');

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c /ext/spl/tests bug36258.phpt bug36287.phpt

2007-01-18 Thread Marcus Boerger
helly   Fri Jan 19 00:36:11 2007 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
/php-src/ext/spl/tests  bug36258.phpt bug36287.phpt 
  Log:
  - A few unicode fixes and tidying
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.114r2=1.115diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.114 
php-src/ext/spl/spl_directory.c:1.115
--- php-src/ext/spl/spl_directory.c:1.114   Thu Jan 18 22:52:32 2007
+++ php-src/ext/spl/spl_directory.c Fri Jan 19 00:36:11 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.114 2007/01/18 22:52:32 tony2001 Exp $ */
+/* $Id: spl_directory.c,v 1.115 2007/01/19 00:36:11 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -157,7 +157,7 @@
 
 static inline void spl_filesystem_object_get_file_name(spl_filesystem_object 
*intern TSRMLS_DC) /* {{{ */
 {
-   if (!intern-file_name.s) {
+   if (!intern-file_name.v) {
switch (intern-type) {
case SPL_FS_INFO:
case SPL_FS_FILE:
@@ -862,18 +862,18 @@
spl_filesystem_object *intern;
zstr path;
zend_uchar path_type;
-   int len;
+   int path_len;
long flags = SPL_FILE_DIR_CURRENT_AS_FILEINFO;
 
php_set_error_handling(EH_THROW, spl_ce_UnexpectedValueException 
TSRMLS_CC);
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t|l, path, 
len, path_type, flags) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t|l, path, 
path_len, path_type, flags) == FAILURE) {
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
return;
}
 
intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() 
TSRMLS_CC);
-   spl_filesystem_dir_open(intern, path_type, path, len TSRMLS_CC);
+   spl_filesystem_dir_open(intern, path_type, path, path_len TSRMLS_CC);
intern-u.dir.is_recursive = instanceof_function(intern-std.ce, 
spl_ce_RecursiveDirectoryIterator TSRMLS_CC) ? 1 : 0;
intern-flags = flags;
 
@@ -926,16 +926,16 @@
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, ..)) {
-   RETURN_BOOL(0);
+   RETURN_FALSE;
} else {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |b, 
allow_links) == FAILURE) {
return;
}
spl_filesystem_object_get_file_name(intern TSRMLS_CC);
if (!allow_links) {
-   php_u_stat(intern-file_name_len, intern-file_name, 
intern-file_name_len, FS_IS_LINK, FG(default_context), return_value TSRMLS_CC);
+   php_u_stat(intern-file_name_type, intern-file_name, 
intern-file_name_len, FS_IS_LINK, FG(default_context), return_value TSRMLS_CC);
if (zend_is_true(return_value)) {
-   RETURN_BOOL(0);
+   RETURN_FALSE;
}
}
php_u_stat(intern-file_name_type, intern-file_name, 
intern-file_name_len, FS_IS_DIR, FG(default_context), return_value TSRMLS_CC);
@@ -961,6 +961,7 @@
subdir = 
(spl_filesystem_object*)zend_object_store_get_object(return_value TSRMLS_CC);
if (subdir) {
if (intern-u.dir.sub_path.v  intern-u.dir.sub_path_len  1) 
{
+   subdir-u.dir.sub_path_type = 
intern-u.dir.sub_path_type;
subdir-u.dir.sub_path_len = 
zspprintf(intern-u.dir.sub_path_type, subdir-u.dir.sub_path, 0, %R%c%s, 
intern-u.dir.sub_path_type, intern-u.dir.sub_path, DEFAULT_SLASH, 
intern-u.dir.entry.d_name);
} else {
subdir-u.dir.sub_path_len = 
strlen(intern-u.dir.entry.d_name);
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/bug36258.phpt?r1=1.3r2=1.4diff_format=u
Index: php-src/ext/spl/tests/bug36258.phpt
diff -u php-src/ext/spl/tests/bug36258.phpt:1.3 
php-src/ext/spl/tests/bug36258.phpt:1.4
--- php-src/ext/spl/tests/bug36258.phpt:1.3 Thu Mar 23 15:05:02 2006
+++ php-src/ext/spl/tests/bug36258.phpt Fri Jan 19 00:36:11 2007
@@ -13,9 +13,13 @@
break;
 }
 
-echo Done\n;
 ?
+===DONE===
 --EXPECTF--
 string(%d) %s
 string(%d) %s
-Done
+===DONE===
+--UEXPECTF--   
+unicode(%d) %s
+unicode(%d) %s
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/bug36287.phpt?r1=1.3r2=1.4diff_format=u
Index: php-src/ext/spl/tests/bug36287.phpt
diff -u php-src/ext/spl/tests/bug36287.phpt:1.3 
php-src/ext/spl/tests/bug36287.phpt:1.4
--- php-src/ext/spl/tests/bug36287.phpt:1.3 Sun May 21 12:48:42 2006
+++ php-src/ext/spl/tests/bug36287.phpt Fri Jan 19 00:36:11 2007
@@ -32,3 

Re: [PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_directory.h

2007-01-17 Thread Andrei Zmievski

+   if (intern-file_name.v) {
+   efree(intern-file_name.s);


Why not be consistent here and free intern-file_name.v?


-   if (!intern-file_name) {
+   if (!intern-file_name.s) {


I think it's clearer to check for intern-file_name.v, because  
otherwise it looks like you care only about .s part of the union.



+#if defined(PHP_WIN32) || defined(NETWARE)
+# define is_slash(c) (c == '/' || c == '\\')
+#else
+# define is_slash(c) (c == '/')
+#endif
+
+#define is_slash_at(type, zs, pos) (type == IS_UNICODE ? is_slash 
(zs.u[pos]) : is_slash(zs.s[pos]))


We already have these macros in tsrm_virtual_cwd.c (IS_SLASH,  
IS_U_SLASH, etc).


-Andrei


On Jan 16, 2007, at 3:52 PM, Marcus Boerger wrote:


helly   Tue Jan 16 23:52:14 2007 UTC

  Modified files:
/php-src/ext/splspl_directory.c spl_directory.h
  Log:
  - Steps towards unicode
helly-20070116235214.txt
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2007-01-17 Thread Marcus Boerger
helly   Wed Jan 17 21:23:55 2007 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - A little help from Andrei
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.109r2=1.110diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.109 
php-src/ext/spl/spl_directory.c:1.110
--- php-src/ext/spl/spl_directory.c:1.109   Tue Jan 16 23:52:14 2007
+++ php-src/ext/spl/spl_directory.c Wed Jan 17 21:23:55 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.109 2007/01/16 23:52:14 helly Exp $ */
+/* $Id: spl_directory.c,v 1.110 2007/01/17 21:23:55 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -77,10 +77,10 @@
zend_object_std_dtor(intern-std TSRMLS_CC);

if (intern-path.v) {
-   efree(intern-path.s);
+   efree(intern-path.v);
}
if (intern-file_name.v) {
-   efree(intern-file_name.s);
+   efree(intern-file_name.v);
}
switch(intern-type) {
case SPL_FS_INFO:
@@ -90,8 +90,8 @@
php_stream_close(intern-u.dir.dirp);
intern-u.dir.dirp = NULL;
}
-   if (intern-u.dir.sub_path.s) {
-   efree(intern-u.dir.sub_path.s);
+   if (intern-u.dir.sub_path.v) {
+   efree(intern-u.dir.sub_path.v);
}   
break;
case SPL_FS_FILE:
@@ -175,13 +175,7 @@
}
 } /* }}} */
 
-#if defined(PHP_WIN32) || defined(NETWARE)
-# define is_slash(c) (c == '/' || c == '\\')
-#else
-# define is_slash(c) (c == '/')
-#endif
-
-#define is_slash_at(type, zs, pos) (type == IS_UNICODE ? is_slash(zs.u[pos]) : 
is_slash(zs.s[pos]))
+#define IS_SLASH_AT(type, zs, pos) (type == IS_UNICODE ? IS_U_SLASH(zs.u[pos]) 
: IS_SLASH(zs.s[pos]))
 
 /* {{{ spl_filesystem_dir_open */
 /* open a directory resource */
@@ -192,7 +186,7 @@
intern-path_len = path_len;
intern-u.dir.dirp = php_stream_u_opendir(type, path, path_len, 
REPORT_ERRORS, NULL);
 
-   if (intern-path_len  is_slash_at(type, path, intern-path_len-1)) {
+   if (intern-path_len  IS_SLASH_AT(type, path, intern-path_len-1)) {
intern-path = ezstrndup(type, path, --intern-path_len);
} else {
intern-path = ezstrndup(type, path, intern-path_len);
@@ -229,7 +223,7 @@
zend_list_addref(Z_RESVAL_P(intern-u.file.zcontext));
}
 
-   if (intern-file_name_len  is_slash_at(intern-file_name_type, 
intern-file_name, intern-file_name_len-1)) {
+   if (intern-file_name_len  IS_SLASH_AT(intern-file_name_type, 
intern-file_name, intern-file_name_len-1)) {
intern-file_name_len--;
}
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2007-01-17 Thread Marcus Boerger
helly   Wed Jan 17 21:29:38 2007 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - More help from David
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.110r2=1.111diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.110 
php-src/ext/spl/spl_directory.c:1.111
--- php-src/ext/spl/spl_directory.c:1.110   Wed Jan 17 21:23:55 2007
+++ php-src/ext/spl/spl_directory.c Wed Jan 17 21:29:38 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.110 2007/01/17 21:23:55 helly Exp $ */
+/* $Id: spl_directory.c,v 1.111 2007/01/17 21:29:38 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -556,7 +556,7 @@
 {
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
-   RETURN_ZSTRL(intern-path_type, intern-path, intern-path_len, 1);
+   RETURN_ZSTRL(intern-path_type, intern-path, intern-path_len, 
ZSTR_DUPLICATE);
 }
 /* }}} */
 
@@ -575,7 +575,7 @@
}
RETURN_ZSTRL(intern-file_name_type, ret, intern-file_name_len 
- (intern-path_len + 1), 1);
} else {
-   RETURN_ZSTRL(intern-file_name_type, intern-file_name, 
intern-file_name_len, 1);
+   RETURN_ZSTRL(intern-file_name_type, intern-file_name, 
intern-file_name_len, ZSTR_DUPLICATE);
}
 }
 /* }}} */
@@ -599,11 +599,11 @@
switch (intern-type) {
case SPL_FS_INFO:
case SPL_FS_FILE:
-   RETURN_ZSTRL(intern-file_name_type, intern-file_name, 
intern-file_name_len, 1);
+   RETURN_ZSTRL(intern-file_name_type, intern-file_name, 
intern-file_name_len, ZSTR_DUPLICATE);
case SPL_FS_DIR:
if (intern-u.dir.entry.d_name[0]) {
spl_filesystem_object_get_file_name(intern TSRMLS_CC);
-   RETURN_ZSTRL(intern-file_name_type, intern-file_name, 
intern-file_name_len, 1);
+   RETURN_ZSTRL(intern-file_name_type, intern-file_name, 
intern-file_name_len, ZSTR_DUPLICATE);
}
}
RETURN_BOOL(0);
@@ -617,7 +617,7 @@
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
if (intern-flags  SPL_FILE_DIR_KEY_AS_FILENAME) {
-   RETURN_STRING(intern-u.dir.entry.d_name, 1);
+   RETURN_RT_STRING(intern-u.dir.entry.d_name, ZSTR_DUPLICATE);
} else {
spl_filesystem_object_get_file_name(intern TSRMLS_CC);
RETURN_ZSTRL(intern-file_name_type, intern-file_name, 
intern-file_name_len, 1);
@@ -633,7 +633,7 @@
 
if (intern-flags  SPL_FILE_DIR_CURRENT_AS_PATHNAME) {
spl_filesystem_object_get_file_name(intern TSRMLS_CC);
-   RETURN_ZSTRL(intern-file_name_type, intern-file_name, 
intern-file_name_len, 1);
+   RETURN_ZSTRL(intern-file_name_type, intern-file_name, 
intern-file_name_len, ZSTR_DUPLICATE);
} else if (intern-flags  SPL_FILE_DIR_CURRENT_AS_FILEINFO) {
spl_filesystem_object_get_file_name(intern TSRMLS_CC);
spl_filesystem_object_create_type(0, intern, SPL_FS_INFO, NULL, 
return_value TSRMLS_CC);
@@ -667,19 +667,19 @@
 {
spl_filesystem_object *intern;
zstr path;
-   int len;
-   zend_uchar type;
+   int path_len;
+   zend_uchar path_type;
 
php_set_error_handling(EH_THROW, spl_ce_RuntimeException TSRMLS_CC);
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t, path, len, 
type) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t, path, 
path_len, path_type) == FAILURE) {
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
return;
}
 
intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() 
TSRMLS_CC);

-   spl_filesystem_info_set_filename(intern, type, path, len, 1 TSRMLS_CC);
+   spl_filesystem_info_set_filename(intern, path_type, path, path_len, 1 
TSRMLS_CC);

/* intern-type = SPL_FS_INFO; already set */
 
@@ -980,7 +980,7 @@
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
if (intern-u.dir.sub_path.v) {
-   RETURN_ZSTRL(intern-u.dir.sub_path_type, 
intern-u.dir.sub_path, intern-u.dir.sub_path_len, 1);
+   RETURN_ZSTRL(intern-u.dir.sub_path_type, 
intern-u.dir.sub_path, intern-u.dir.sub_path_len, ZSTR_DUPLICATE);
} else {
RETURN_EMPTY_TEXT();
}
@@ -1003,7 +1003,7 @@
}
RETURN_ZSTRL(intern-u.dir.sub_path_type, sub_name, len, 0);
} else {
-   RETURN_STRING(intern-u.dir.entry.d_name, 1);
+   

[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2007-01-17 Thread Marcus Boerger
helly   Wed Jan 17 22:43:54 2007 UTC

  Modified files:  
/php-src/ext/splspl_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.111r2=1.112diff_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 @@

[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_directory.h

2007-01-16 Thread Marcus Boerger
helly   Tue Jan 16 23:52:14 2007 UTC

  Modified files:  
/php-src/ext/splspl_directory.c spl_directory.h 
  Log:
  - Steps towards unicode
  http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.108r2=1.109diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.108 
php-src/ext/spl/spl_directory.c:1.109
--- php-src/ext/spl/spl_directory.c:1.108   Mon Jan  1 09:29:29 2007
+++ php-src/ext/spl/spl_directory.c Tue Jan 16 23:52:14 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.108 2007/01/01 09:29:29 sebastian Exp $ */
+/* $Id: spl_directory.c,v 1.109 2007/01/16 23:52:14 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -76,11 +76,11 @@

zend_object_std_dtor(intern-std TSRMLS_CC);

-   if (intern-path) {
-   efree(intern-path);
+   if (intern-path.v) {
+   efree(intern-path.s);
}
-   if (intern-file_name) {
-   efree(intern-file_name);
+   if (intern-file_name.v) {
+   efree(intern-file_name.s);
}
switch(intern-type) {
case SPL_FS_INFO:
@@ -90,8 +90,8 @@
php_stream_close(intern-u.dir.dirp);
intern-u.dir.dirp = NULL;
}
-   if (intern-u.dir.sub_path) {
-   efree(intern-u.dir.sub_path);
+   if (intern-u.dir.sub_path.s) {
+   efree(intern-u.dir.sub_path.s);
}   
break;
case SPL_FS_FILE:
@@ -157,35 +157,45 @@
 
 static inline void spl_filesystem_object_get_file_name(spl_filesystem_object 
*intern TSRMLS_DC) /* {{{ */
 {
-   if (!intern-file_name) {
+   if (!intern-file_name.s) {
switch (intern-type) {
case SPL_FS_INFO:
case SPL_FS_FILE:
php_error_docref(NULL TSRMLS_CC, E_ERROR, Object not 
initialized);
break;
case SPL_FS_DIR:
-   intern-file_name_len = spprintf(intern-file_name, 0, 
%s%c%s, intern-path, DEFAULT_SLASH, intern-u.dir.entry.d_name);
+   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);
+   }
+   intern-file_name_type = intern-path_type;
break;
}
}
 } /* }}} */
 
+#if defined(PHP_WIN32) || defined(NETWARE)
+# define is_slash(c) (c == '/' || c == '\\')
+#else
+# define is_slash(c) (c == '/')
+#endif
+
+#define is_slash_at(type, zs, pos) (type == IS_UNICODE ? is_slash(zs.u[pos]) : 
is_slash(zs.s[pos]))
+
 /* {{{ spl_filesystem_dir_open */
 /* open a directory resource */
-static void spl_filesystem_dir_open(spl_filesystem_object* intern, char *path 
TSRMLS_DC)
+static void spl_filesystem_dir_open(spl_filesystem_object* intern, zend_uchar 
type, zstr path, int path_len TSRMLS_DC)
 {
intern-type = SPL_FS_DIR;
-   intern-path_len = strlen(path);
-   intern-u.dir.dirp = php_stream_opendir(path, REPORT_ERRORS, NULL);
+   intern-path_type= type;
+   intern-path_len = path_len;
+   intern-u.dir.dirp = php_stream_u_opendir(type, path, path_len, 
REPORT_ERRORS, NULL);
 
-   if (intern-path_len  (path[intern-path_len-1] == '/'
-#if defined(PHP_WIN32) || defined(NETWARE)
-   || path[intern-path_len-1] == '\\'
-#endif
-   )) {
-   intern-path = estrndup(path, --intern-path_len);
+   if (intern-path_len  is_slash_at(type, path, intern-path_len-1)) {
+   intern-path = ezstrndup(type, path, --intern-path_len);
} else {
-   intern-path = estrndup(path, intern-path_len);
+   intern-path = ezstrndup(type, path, intern-path_len);
}
intern-u.dir.index = 0;
 
@@ -204,13 +214,13 @@
 {
intern-type = SPL_FS_FILE;
intern-u.file.context = 
php_stream_context_from_zval(intern-u.file.zcontext, 0);
-   intern-u.file.stream = php_stream_open_wrapper_ex(intern-file_name, 
intern-u.file.open_mode, (use_include_path ? USE_PATH : 0) | REPORT_ERRORS, 
NULL, intern-u.file.context);
+   intern-u.file.stream = 
php_stream_u_open_wrapper(intern-file_name_type, intern-file_name, 
intern-file_name_len, intern-u.file.open_mode, (use_include_path ? USE_PATH : 
0) | REPORT_ERRORS, NULL, intern-u.file.context);
 
if (!intern-file_name_len || !intern-u.file.stream) {
if (!EG(exception)) {
-   

Re: [PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2006-12-21 Thread Marcus Boerger
Hello Andrei,

  cast tells mewhat type is requested. That must not necessarily be what
UG(unicode) tells me. So i have toreturn whatever that type says.

best regards
marcus

Thursday, December 21, 2006, 7:43:18 AM, you wrote:

 If UG(unicode) is on, ZVAL_ASCII_STRING() will convert binary string  
 arg to Unicode and return it as IS_UNICODE, otherwise it will return  
 string as-is (IS_STRING). In the former case, the string is assumed  
 to contain only ASCII chars.

 What are you after exactly?

 -Andrei


 On Dec 20, 2006, at 3:30 PM, Marcus Boerger wrote:

 helly Wed Dec 20 23:30:23 2006 UTC

   Modified files:
 /php-src/ext/spl  spl_directory.c
   Log:
   - Quick hackto make tests pass
   # There is something missing, ZVAL_TYPED_ASCII_STRING(z, type,  
 char*,flags)
   # Or am i overseeinghow that works?


 http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c? 
 r1=1.105r2=1.106diff_format=u
 Index: php-src/ext/spl/spl_directory.c
 diff -u php-src/ext/spl/spl_directory.c:1.105 php-src/ext/spl/ 
 spl_directory.c:1.106
 --- php-src/ext/spl/spl_directory.c:1.105 Sun Nov 12 17:56:14 2006
 +++ php-src/ext/spl/spl_directory.c   Wed Dec 20 23:30:23 2006
 @@ -16,7 +16,7 @@
  
 +- 
 -+
   */

 -/* $Id: spl_directory.c,v 1.105 2006/11/12 17:56:14 helly Exp $ */
 +/* $Id: spl_directory.c,v 1.106 2006/12/20 23:30:23 helly Exp $ */

  #ifdef HAVE_CONFIG_H
  # include config.h
 @@ -1225,16 +1225,28 @@
  {
   spl_filesystem_object *intern = (spl_filesystem_object*) 
 zend_object_store_get_object(readobj TSRMLS_CC);

 - if (type == IS_STRING) {
 - switch (intern-type) {
 - case SPL_FS_INFO:
 - case SPL_FS_FILE:
 + switch (intern-type) {
 + case SPL_FS_INFO:
 + case SPL_FS_FILE:
 + if (type == IS_STRING) {
   ZVAL_STRINGL(writeobj, intern-file_name, intern- 
 file_name_len, 1);
   return SUCCESS;
 - case SPL_FS_DIR:
 + }
 + if (type == IS_UNICODE  UG(unicode)) {
 + ZVAL_ASCII_STRINGL(writeobj, intern-file_name, 
 intern- 
 file_name_len, 1);
 + return SUCCESS;
 + }
 + break;
 + case SPL_FS_DIR:
 + if (type == IS_STRING) {
   ZVAL_STRING(writeobj, intern-u.dir.entry.d_name, 1);
   return SUCCESS;
   }
 + if (type == IS_UNICODE  UG(unicode)) {
 + ZVAL_ASCII_STRING(writeobj, 
 intern-u.dir.entry.d_name, 1);
 + return SUCCESS;
 + }
 + break;
   }
   ZVAL_NULL(writeobj);
   return FAILURE;

 -- 
 PHP CVS Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Best regards,
 Marcus

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2006-12-21 Thread Andrei Zmievski

So do an if() statement then..

-Andrei

On Dec 21, 2006, at 12:21 AM, Marcus Boerger wrote:


Hello Andrei,

  cast tells mewhat type is requested. That must not necessarily be  
what

UG(unicode) tells me. So i have toreturn whatever that type says.

best regards
marcus

Thursday, December 21, 2006, 7:43:18 AM, you wrote:


If UG(unicode) is on, ZVAL_ASCII_STRING() will convert binary string
arg to Unicode and return it as IS_UNICODE, otherwise it will return
string as-is (IS_STRING). In the former case, the string is assumed
to contain only ASCII chars.



What are you after exactly?



-Andrei




On Dec 20, 2006, at 3:30 PM, Marcus Boerger wrote:



helly Wed Dec 20 23:30:23 2006 UTC

  Modified files:
/php-src/ext/spl  spl_directory.c
  Log:
  - Quick hackto make tests pass
  # There is something missing, ZVAL_TYPED_ASCII_STRING(z, type,
char*,flags)
  # Or am i overseeinghow that works?


http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?
r1=1.105r2=1.106diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.105 php-src/ext/spl/
spl_directory.c:1.106
--- php-src/ext/spl/spl_directory.c:1.105 Sun Nov 12 17:56:14  
2006

+++ php-src/ext/spl/spl_directory.c   Wed Dec 20 23:30:23 2006
@@ -16,7 +16,7 @@

+ 
-

-+
  */

-/* $Id: spl_directory.c,v 1.105 2006/11/12 17:56:14 helly Exp $ */
+/* $Id: spl_directory.c,v 1.106 2006/12/20 23:30:23 helly Exp $ */

 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1225,16 +1225,28 @@
 {
  spl_filesystem_object *intern = (spl_filesystem_object*)
zend_object_store_get_object(readobj TSRMLS_CC);

- if (type == IS_STRING) {
- switch (intern-type) {
- case SPL_FS_INFO:
- case SPL_FS_FILE:
+ switch (intern-type) {
+ case SPL_FS_INFO:
+ case SPL_FS_FILE:
+ if (type == IS_STRING) {
  ZVAL_STRINGL(writeobj, intern-file_name,  
intern-

file_name_len, 1);

  return SUCCESS;
- case SPL_FS_DIR:
+ }
+ if (type == IS_UNICODE  UG(unicode)) {
+ ZVAL_ASCII_STRINGL(writeobj,  
intern-file_name, intern-

file_name_len, 1);

+ return SUCCESS;
+ }
+ break;
+ case SPL_FS_DIR:
+ if (type == IS_STRING) {
  ZVAL_STRING(writeobj,  
intern-u.dir.entry.d_name, 1);

  return SUCCESS;
  }
+ if (type == IS_UNICODE  UG(unicode)) {
+ ZVAL_ASCII_STRING(writeobj,  
intern-u.dir.entry.d_name, 1);

+ return SUCCESS;
+ }
+ break;
  }
  ZVAL_NULL(writeobj);
  return FAILURE;

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





Best regards,
 Marcus



--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c /ext/spl/tests fileobject_003.phpt

2006-11-12 Thread Hannes Magnusson
bjori   Sun Nov 12 17:08:45 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
/php-src/ext/spl/tests  fileobject_003.phpt 
  Log:
  SplFileObject::getFilename() should not overwrite SplFileInfo::getFilename()
  (Fixes bug where SplFileObject::getFilename() returns relative/path/to/file)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.103r2=1.104diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.103 
php-src/ext/spl/spl_directory.c:1.104
--- php-src/ext/spl/spl_directory.c:1.103   Mon Nov  6 23:19:46 2006
+++ php-src/ext/spl/spl_directory.c Sun Nov 12 17:08:45 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.103 2006/11/06 23:19:46 bjori Exp $ */
+/* $Id: spl_directory.c,v 1.104 2006/11/12 17:08:45 bjori Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -550,7 +550,7 @@
 {
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
-   if (intern-path_len) {
+   if (intern-path_len  intern-path_len  intern-file_name_len) {
RETURN_STRINGL(intern-file_name + intern-path_len + 1, 
intern-file_name_len - (intern-path_len + 1), 1);
} else {
RETURN_STRINGL(intern-file_name, intern-file_name_len, 1);
@@ -1654,15 +1654,6 @@
spl_filesystem_file_rewind(getThis(), intern TSRMLS_CC);
 } /* }}} */
 
-/* {{{ proto string SplFileObject::getFilename()
-   Return the filename */
-SPL_METHOD(SplFileObject, getFilename)
-{
-   spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
-
-   RETURN_STRINGL(intern-file_name, intern-file_name_len, 1);
-} /* }}} */
-
 /* {{{ proto void SplFileObject::eof()
Return whether end of file is reached */
 SPL_METHOD(SplFileObject, eof)
@@ -2140,7 +2131,6 @@
 
 static zend_function_entry spl_SplFileObject_functions[] = {
SPL_ME(SplFileObject, __construct,arginfo_file_object___construct,  
 ZEND_ACC_PUBLIC)
-   SPL_ME(SplFileObject, getFilename,NULL, ZEND_ACC_PUBLIC)
SPL_ME(SplFileObject, rewind, NULL, ZEND_ACC_PUBLIC)
SPL_ME(SplFileObject, eof,NULL, ZEND_ACC_PUBLIC)
SPL_ME(SplFileObject, valid,  NULL, ZEND_ACC_PUBLIC)
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/fileobject_003.phpt?r1=1.3r2=1.4diff_format=u
Index: php-src/ext/spl/tests/fileobject_003.phpt
diff -u php-src/ext/spl/tests/fileobject_003.phpt:1.3 
php-src/ext/spl/tests/fileobject_003.phpt:1.4
--- php-src/ext/spl/tests/fileobject_003.phpt:1.3   Mon Nov  6 15:20:23 2006
+++ php-src/ext/spl/tests/fileobject_003.phpt   Sun Nov 12 17:08:45 2006
@@ -55,12 +55,12 @@
 %s(%d) %sfileobject_001a.txt
 string(%d) %sfileobject_001a.txt
 bool(true)
-string(%d) %sfileobject_001a.txt
+string(19) fileobject_001a.txt
 bool(true)
 string(%d) %stests
 bool(true)
 string(%d) %sfileobject_001a.txt
-string(%d) %sfileobject_001a.txt
+string(19) fileobject_001a.txt
 string(%d) %stests
 ===1===
 object(SplFileInfo)#%d (0) {
@@ -73,7 +73,7 @@
 %s(%d) %stests/
 string(%d) %stests
 bool(true)
-string(%d) %stests
+string(5) tests
 bool(true)
 string(%d) %sspl
 bool(true)
@@ -91,11 +91,11 @@
 %s(%d) %stests
 string(%d) %stests
 bool(true)
-string(%d) %stests
+string(%d) tests
 bool(true)
 string(%d) %sspl
 bool(true)
 string(%d) %stests
-string(%d) %stests
+string(5) tests
 string(%d) %sspl
 ===DONE===

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_directory.h

2006-11-12 Thread Marcus Boerger
helly   Sun Nov 12 17:56:14 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c spl_directory.h 
  Log:
  - Optimize SPL directory stuff by making iterator part of object
  http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.104r2=1.105diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.104 
php-src/ext/spl/spl_directory.c:1.105
--- php-src/ext/spl/spl_directory.c:1.104   Sun Nov 12 17:08:45 2006
+++ php-src/ext/spl/spl_directory.c Sun Nov 12 17:56:14 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.104 2006/11/12 17:08:45 bjori Exp $ */
+/* $Id: spl_directory.c,v 1.105 2006/11/12 17:56:14 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -88,6 +88,7 @@
case SPL_FS_DIR:
if (intern-u.dir.dirp) {
php_stream_close(intern-u.dir.dirp);
+   intern-u.dir.dirp = NULL;
}
if (intern-u.dir.sub_path) {
efree(intern-u.dir.sub_path);
@@ -977,13 +978,6 @@
 }
 /* }}} */
 
-/* define an overloaded iterator structure */
-typedef struct {
-   zend_object_iterator  intern;
-   zval  *current;
-   spl_filesystem_object *object;
-} spl_filesystem_dir_it;
-
 /* forward declarations to the iterator handlers */
 static void spl_filesystem_dir_it_dtor(zend_object_iterator *iter TSRMLS_DC);
 static int spl_filesystem_dir_it_valid(zend_object_iterator *iter TSRMLS_DC);
@@ -1005,20 +999,19 @@
 /* {{{ spl_ce_dir_get_iterator */
 zend_object_iterator *spl_filesystem_dir_get_iterator(zend_class_entry *ce, 
zval *object, int by_ref TSRMLS_DC)
 {
-   spl_filesystem_dir_it *iterator;
-   spl_filesystem_object *dir_object;
+   spl_filesystem_iterator *iterator;
+   spl_filesystem_object   *dir_object;
 
if (by_ref) {
zend_error(E_ERROR, An iterator cannot be used with foreach by 
reference);
}
-   iterator   = emalloc(sizeof(spl_filesystem_dir_it));
dir_object = 
(spl_filesystem_object*)zend_object_store_get_object(object TSRMLS_CC);
+   iterator   = spl_filesystem_object_to_iterator(dir_object);
 
-   object-refcount += 2;;
+   object-refcount += 2;
iterator-intern.data = (void*)object;
iterator-intern.funcs = spl_filesystem_dir_it_funcs;
iterator-current = object;
-   iterator-object = dir_object;

return (zend_object_iterator*)iterator;
 }
@@ -1027,20 +1020,18 @@
 /* {{{ spl_filesystem_dir_it_dtor */
 static void spl_filesystem_dir_it_dtor(zend_object_iterator *iter TSRMLS_DC)
 {
-   spl_filesystem_dir_it *iterator = (spl_filesystem_dir_it *)iter;
+   spl_filesystem_iterator *iterator = (spl_filesystem_iterator *)iter;
 
zval_ptr_dtor(iterator-current);
zval_ptr_dtor((zval**)iterator-intern.data);
-
-   efree(iterator);
+   iterator-intern.data = NULL; /* mark as unused */
 }
 /* }}} */

 /* {{{ spl_filesystem_dir_it_valid */
 static int spl_filesystem_dir_it_valid(zend_object_iterator *iter TSRMLS_DC)
 {
-   spl_filesystem_dir_it *iterator = (spl_filesystem_dir_it *)iter;
-   spl_filesystem_object *object   = iterator-object;
+   spl_filesystem_object *object = 
spl_filesystem_iterator_to_object((spl_filesystem_iterator *)iter);
 
return object-u.dir.entry.d_name[0] != '\0' ? SUCCESS : FAILURE;
 }
@@ -1050,7 +1041,7 @@
 /* {{{ spl_filesystem_dir_it_current_data */
 static void spl_filesystem_dir_it_current_data(zend_object_iterator *iter, 
zval ***data TSRMLS_DC)
 {
-   spl_filesystem_dir_it *iterator = (spl_filesystem_dir_it *)iter;
+   spl_filesystem_iterator *iterator = (spl_filesystem_iterator *)iter;

*data = iterator-current;
 }
@@ -1059,8 +1050,7 @@
 /* {{{ spl_filesystem_dir_it_current_key */
 static int spl_filesystem_dir_it_current_key(zend_object_iterator *iter, zstr 
*str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
 {
-   spl_filesystem_dir_it *iterator = (spl_filesystem_dir_it *)iter;
-   spl_filesystem_object *object   = iterator-object;
+   spl_filesystem_object *object = 
spl_filesystem_iterator_to_object((spl_filesystem_iterator *)iter);

*int_key = object-u.dir.index;
return HASH_KEY_IS_LONG;
@@ -1070,8 +1060,7 @@
 /* {{{ spl_filesystem_dir_it_move_forward */
 static void spl_filesystem_dir_it_move_forward(zend_object_iterator *iter 
TSRMLS_DC)
 {
-   spl_filesystem_dir_it *iterator = (spl_filesystem_dir_it *)iter;
-   spl_filesystem_object *object   = iterator-object;
+   spl_filesystem_object *object = 
spl_filesystem_iterator_to_object((spl_filesystem_iterator *)iter);

object-u.dir.index++;
if (!object-u.dir.dirp || !php_stream_readdir(object-u.dir.dirp, 
object-u.dir.entry)) {
@@ -1087,8 

[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_iterators.c

2006-11-06 Thread Hannes Magnusson
bjori   Mon Nov  6 23:19:46 2006 UTC

  Modified files:  
/php-src/ext/splspl_iterators.c spl_directory.c 
  Log:
  Fix arginfo
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_iterators.c?r1=1.152r2=1.153diff_format=u
Index: php-src/ext/spl/spl_iterators.c
diff -u php-src/ext/spl/spl_iterators.c:1.152 
php-src/ext/spl/spl_iterators.c:1.153
--- php-src/ext/spl/spl_iterators.c:1.152   Fri Nov  3 14:08:11 2006
+++ php-src/ext/spl/spl_iterators.c Mon Nov  6 23:19:46 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_iterators.c,v 1.152 2006/11/03 14:08:11 bjori Exp $ */
+/* $Id: spl_iterators.c,v 1.153 2006/11/06 23:19:46 bjori Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -757,18 +757,19 @@
 /* }}} */
 
 static
-ZEND_BEGIN_ARG_INFO(arginfo_recursive_it___construct, 0) 
+ZEND_BEGIN_ARG_INFO_EX(arginfo_recursive_it___construct, 0, 0, 1) 
ZEND_ARG_OBJ_INFO(0, iterator, Traversable, 0)
ZEND_ARG_INFO(0, mode)
+   ZEND_ARG_INFO(0, flags)
 ZEND_END_ARG_INFO();
 
 static
-ZEND_BEGIN_ARG_INFO(arginfo_recursive_it_getSubIterator, 0) 
+ZEND_BEGIN_ARG_INFO_EX(arginfo_recursive_it_getSubIterator, 0, 0, 0)
ZEND_ARG_INFO(0, level)
 ZEND_END_ARG_INFO();
 
 static
-ZEND_BEGIN_ARG_INFO(arginfo_recursive_it_setMaxDepth, 0) 
+ZEND_BEGIN_ARG_INFO_EX(arginfo_recursive_it_setMaxDepth, 0, 0, 0)
ZEND_ARG_INFO(0, max_depth)
 ZEND_END_ARG_INFO();
 
@@ -1553,7 +1554,7 @@
}
 } /* }}} */
 
-/* {{{ proto bool RegexIterator::setFlags(int new_flags)
+/* {{{ proto bool RegexIterator::setPregFlags(int new_flags)
Set PREG flags */
 SPL_METHOD(RegexIterator, setPregFlags)
 {
@@ -1887,7 +1888,7 @@
 };
 
 static
-ZEND_BEGIN_ARG_INFO(arginfo_limit_it___construct, 0) 
+ZEND_BEGIN_ARG_INFO_EX(arginfo_limit_it___construct, 0, 0, 1) 
ZEND_ARG_OBJ_INFO(0, iterator, Iterator, 0)
ZEND_ARG_INFO(0, offset)
ZEND_ARG_INFO(0, count)
@@ -2236,7 +2237,7 @@
 }
 /* }}} */
 
-/* {{{ proto void CachingIterator::setFlags()
+/* {{{ proto void CachingIterator::setFlags(int flags)
Set the internal flags */
 SPL_METHOD(CachingIterator, setFlags)
 {
@@ -2270,7 +2271,7 @@
 /* }}} */
 
 static
-ZEND_BEGIN_ARG_INFO(arginfo_caching_it___construct, 0) 
+ZEND_BEGIN_ARG_INFO_EX(arginfo_caching_it___construct, 0, 0, 1) 
ZEND_ARG_OBJ_INFO(0, iterator, Iterator, 0)
ZEND_ARG_INFO(0, flags)
 ZEND_END_ARG_INFO();
@@ -2281,12 +2282,12 @@
 ZEND_END_ARG_INFO();
 
 static
-ZEND_BEGIN_ARG_INFO_EX(arginfo_caching_it_offsetGet, 0, 0, 1)
+ZEND_BEGIN_ARG_INFO(arginfo_caching_it_offsetGet, 0)
ZEND_ARG_INFO(0, index)
 ZEND_END_ARG_INFO();
 
 static
-ZEND_BEGIN_ARG_INFO_EX(arginfo_caching_it_offsetSet, 0, 0, 2)
+ZEND_BEGIN_ARG_INFO(arginfo_caching_it_offsetSet, 0)
ZEND_ARG_INFO(0, index)
ZEND_ARG_INFO(0, newval)
 ZEND_END_ARG_INFO();
@@ -2345,7 +2346,7 @@
 } /* }}} */
 
 static
-ZEND_BEGIN_ARG_INFO_EX(arginfo_caching_rec_it___construct, 0, 
ZEND_RETURN_VALUE, 2) 
+ZEND_BEGIN_ARG_INFO_EX(arginfo_caching_rec_it___construct, 0, 
ZEND_RETURN_VALUE, 1) 
ZEND_ARG_OBJ_INFO(0, iterator, Iterator, 0)
ZEND_ARG_INFO(0, flags)
 ZEND_END_ARG_INFO();
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.102r2=1.103diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.102 
php-src/ext/spl/spl_directory.c:1.103
--- php-src/ext/spl/spl_directory.c:1.102   Mon Nov  6 15:20:23 2006
+++ php-src/ext/spl/spl_directory.c Mon Nov  6 23:19:46 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.102 2006/11/06 15:20:23 bjori Exp $ */
+/* $Id: spl_directory.c,v 1.103 2006/11/06 23:19:46 bjori Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1327,18 +1327,23 @@
 };
 
 static
-ZEND_BEGIN_ARG_INFO(arginfo_r_dir___construct, 0) 
+ZEND_BEGIN_ARG_INFO_EX(arginfo_r_dir___construct, 0, 0, 1) 
ZEND_ARG_INFO(0, path)
ZEND_ARG_INFO(0, flags)
 ZEND_END_ARG_INFO()
 
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_r_dir_hasChildren, 0, 0, 0)
+   ZEND_ARG_INFO(0, allow_links)
+ZEND_END_ARG_INFO()
+
 static zend_function_entry spl_RecursiveDirectoryIterator_functions[] = {
SPL_ME(RecursiveDirectoryIterator, __construct,   
arginfo_r_dir___construct, ZEND_ACC_PUBLIC)
SPL_ME(RecursiveDirectoryIterator, rewind,NULL, ZEND_ACC_PUBLIC)
SPL_ME(RecursiveDirectoryIterator, next,  NULL, ZEND_ACC_PUBLIC)
SPL_ME(RecursiveDirectoryIterator, key,   NULL, ZEND_ACC_PUBLIC)
SPL_ME(RecursiveDirectoryIterator, current,   NULL, ZEND_ACC_PUBLIC)
-   SPL_ME(RecursiveDirectoryIterator, hasChildren,   NULL, ZEND_ACC_PUBLIC)
+   SPL_ME(RecursiveDirectoryIterator, hasChildren,   
arginfo_r_dir_hasChildren, ZEND_ACC_PUBLIC)
SPL_ME(RecursiveDirectoryIterator, 

[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2006-09-29 Thread Antony Dovgal
tony2001Fri Sep 29 12:18:54 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  declare subclass after adding class constants to the parent
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.97r2=1.98diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.97 
php-src/ext/spl/spl_directory.c:1.98
--- php-src/ext/spl/spl_directory.c:1.97Sun Aug  6 13:47:20 2006
+++ php-src/ext/spl/spl_directory.c Fri Sep 29 12:18:54 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.97 2006/08/06 13:47:20 helly Exp $ */
+/* $Id: spl_directory.c,v 1.98 2006/09/29 12:18:54 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -2211,12 +2211,12 @@
REGISTER_SPL_IMPLEMENTS(SplFileObject, RecursiveIterator);
REGISTER_SPL_IMPLEMENTS(SplFileObject, SeekableIterator);
 
-   REGISTER_SPL_SUB_CLASS_EX(SplTempFileObject, SplFileObject, 
spl_filesystem_object_new, spl_SplTempFileObject_functions);
-
REGISTER_SPL_CLASS_CONST_LONG(SplFileObject, DROP_NEW_LINE, 
SPL_FILE_OBJECT_DROP_NEW_LINE);
REGISTER_SPL_CLASS_CONST_LONG(SplFileObject, READ_AHEAD,
SPL_FILE_OBJECT_READ_AHEAD);
REGISTER_SPL_CLASS_CONST_LONG(SplFileObject, SKIP_EMPTY,
SPL_FILE_OBJECT_SKIP_EMPTY);
REGISTER_SPL_CLASS_CONST_LONG(SplFileObject, READ_CSV,  
SPL_FILE_OBJECT_READ_CSV);
+   
+   REGISTER_SPL_SUB_CLASS_EX(SplTempFileObject, SplFileObject, 
spl_filesystem_object_new, spl_SplTempFileObject_functions);
return SUCCESS;
 }
 /* }}} */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2006-09-29 Thread Hannes Magnusson
bjori   Fri Sep 29 12:28:57 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  Fix arginfo
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.98r2=1.99diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.98 
php-src/ext/spl/spl_directory.c:1.99
--- php-src/ext/spl/spl_directory.c:1.98Fri Sep 29 12:18:54 2006
+++ php-src/ext/spl/spl_directory.c Fri Sep 29 12:28:57 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.98 2006/09/29 12:18:54 tony2001 Exp $ */
+/* $Id: spl_directory.c,v 1.99 2006/09/29 12:28:57 bjori Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -2169,7 +2169,7 @@
 };
 
 static
-ZEND_BEGIN_ARG_INFO_EX(arginfo_temp_file_object___construct, 0, 0, 1)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_temp_file_object___construct, 0, 0, 0)
ZEND_ARG_INFO(0, max_memory)
 ZEND_END_ARG_INFO()
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c /ext/standard streamsfuncs.c

2006-09-29 Thread Hannes Magnusson
bjori   Fri Sep 29 13:22:43 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
/php-src/ext/standard   streamsfuncs.c 
  Log:
  fix proto
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.99r2=1.100diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.99 
php-src/ext/spl/spl_directory.c:1.100
--- php-src/ext/spl/spl_directory.c:1.99Fri Sep 29 12:28:57 2006
+++ php-src/ext/spl/spl_directory.c Fri Sep 29 13:22:43 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.99 2006/09/29 12:28:57 bjori Exp $ */
+/* $Id: spl_directory.c,v 1.100 2006/09/29 13:22:43 bjori Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1601,7 +1601,7 @@
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
 } /* }}} */
 
-/* {{{ proto void SplFileObject::__construct([int max_memory])
+/* {{{ proto void SplTempFileObject::__construct([int max_memory])
Construct a new temp file object */
 SPL_METHOD(SplTempFileObject, __construct)
 {
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.89r2=1.90diff_format=u
Index: php-src/ext/standard/streamsfuncs.c
diff -u php-src/ext/standard/streamsfuncs.c:1.89 
php-src/ext/standard/streamsfuncs.c:1.90
--- php-src/ext/standard/streamsfuncs.c:1.89Fri Sep 22 19:54:30 2006
+++ php-src/ext/standard/streamsfuncs.c Fri Sep 29 13:22:43 2006
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: streamsfuncs.c,v 1.89 2006/09/22 19:54:30 pollita Exp $ */
+/* $Id: streamsfuncs.c,v 1.90 2006/09/29 13:22:43 bjori Exp $ */
 
 #include php.h
 #include php_globals.h
@@ -467,7 +467,7 @@
 }
 /* }}} */
 
-/* {{{ proto resource stream_get_meta_data(resource fp) U
+/* {{{ proto array stream_get_meta_data(resource fp) U
 Retrieves header/meta data from streams/file pointers */
 PHP_FUNCTION(stream_get_meta_data)
 {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c /ext/spl/tests fileobject_003.phpt

2006-07-15 Thread Marcus Boerger
helly   Sat Jul 15 13:01:44 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
/php-src/ext/spl/tests  fileobject_003.phpt 
  Log:
  - Fix issue with SplFileObject and directories
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.92r2=1.93diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.92 
php-src/ext/spl/spl_directory.c:1.93
--- php-src/ext/spl/spl_directory.c:1.92Mon Jul 10 15:48:09 2006
+++ php-src/ext/spl/spl_directory.c Sat Jul 15 13:01:44 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.92 2006/07/10 15:48:09 dmitry Exp $ */
+/* $Id: spl_directory.c,v 1.93 2006/07/15 13:01:44 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -205,9 +205,9 @@
intern-u.file.context = 
php_stream_context_from_zval(intern-u.file.zcontext, 0);
intern-u.file.stream = php_stream_open_wrapper_ex(intern-file_name, 
intern-u.file.open_mode, (use_include_path ? USE_PATH : 0) | REPORT_ERRORS, 
NULL, intern-u.file.context);
 
-   if (intern-u.file.stream == NULL) {
+   if (!intern-file_name_len || !intern-u.file.stream) {
if (!EG(exception)) {
-   zend_throw_exception_ex(spl_ce_RuntimeException, 0 
TSRMLS_CC, Cannot open file %s, intern-file_name);
+   zend_throw_exception_ex(spl_ce_RuntimeException, 0 
TSRMLS_CC, Cannot open file '%s', intern-file_name);
}
intern-file_name = NULL; /* until here it is not a copy */
intern-u.file.open_mode = NULL;
@@ -218,6 +218,14 @@
zend_list_addref(Z_RESVAL_P(intern-u.file.zcontext));
}
 
+   if (intern-file_name[intern-file_name_len-1] == '/'
+#if defined(PHP_WIN32) || defined(NETWARE)
+ ||intern-file_name[intern-file_name_len-1] == '\\'
+#endif
+   ) {
+   intern-file_name_len--;
+   }
+
intern-file_name = estrndup(intern-file_name, intern-file_name_len);
intern-u.file.open_mode = estrndup(intern-u.file.open_mode, 
intern-u.file.open_mode_len);
 
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/fileobject_003.phpt?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/spl/tests/fileobject_003.phpt
diff -u php-src/ext/spl/tests/fileobject_003.phpt:1.1 
php-src/ext/spl/tests/fileobject_003.phpt:1.2
--- php-src/ext/spl/tests/fileobject_003.phpt:1.1   Sat Jul  8 11:43:07 2006
+++ php-src/ext/spl/tests/fileobject_003.phpt   Sat Jul 15 13:01:44 2006
@@ -5,7 +5,7 @@
 --FILE--
 ?php
 
-function test($name)
+function test($name, $lc, $lp)
 {
static $i = 0;
echo ===$i===\n;
@@ -19,10 +19,23 @@
var_dump($o === $c);
var_dump($o == $c);
var_dump($o-getPathname() == $c-getPathname());
+   
+   $f = new SplFileObject($name);
+   var_dump($name);
+   var_dump($f-getPathName());
+   $l = substr($f-getPathName(), -1);
+   var_dump($l != '/'  $l != '\\'  $l == $lc);
+   var_dump($f-getFileName());
+   $l = substr($f-getFileName(), -1);
+   var_dump($l != '/'  $l != '\\'  $l == $lc);
+   var_dump($f-getPath());
+   $l = substr($f-getPath(), -1);
+   var_dump($l != '/'  $l != '\\'  $l == $lp);
 }
 
-test(dirname(__FILE__) . '/' . 'fileobject_001a.txt');
-test(dirname(__FILE__) . '/');
+test(dirname(__FILE__) . '/' . 'fileobject_001a.txt', 't', 
substr(dirname(__FILE__),-1));
+test(dirname(__FILE__) . '/', substr(dirname(__FILE__),-1), 'l');
+test(dirname(__FILE__),   substr(dirname(__FILE__),-1), 'l');
 
 ?
 ===DONE===
@@ -36,6 +49,13 @@
 bool(false)
 bool(true)
 bool(true)
+%s(%d) %sfileobject_001a.txt
+string(%d) %sfileobject_001a.txt
+bool(true)
+string(%d) %sfileobject_001a.txt
+bool(true)
+string(%d) %stests
+bool(true)
 ===1===
 object(SplFileInfo)#%d (0) {
 }
@@ -44,4 +64,26 @@
 bool(false)
 bool(true)
 bool(true)
+%s(%d) %stests/
+string(%d) %stests
+bool(true)
+string(%d) %stests
+bool(true)
+string(%d) %sspl
+bool(true)
+===2===
+object(SplFileInfo)#1 (0) {
+}
+object(SplFileInfo)#2 (0) {
+}
+bool(false)
+bool(true)
+bool(true)
+%s(%d) %stests
+string(%d) %stests
+bool(true)
+string(%d) %stests
+bool(true)
+string(%d) %sspl
+bool(true)
 ===DONE===

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2006-07-15 Thread Marcus Boerger
helly   Sat Jul 15 14:50:38 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - Implement todo: SplFileObject: ability to set the CSV separator per object, 
part 2
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.94r2=1.95diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.94 
php-src/ext/spl/spl_directory.c:1.95
--- php-src/ext/spl/spl_directory.c:1.94Sat Jul 15 14:31:51 2006
+++ php-src/ext/spl/spl_directory.c Sat Jul 15 14:50:38 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.94 2006/07/15 14:31:51 helly Exp $ */
+/* $Id: spl_directory.c,v 1.95 2006/07/15 14:50:38 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1826,6 +1826,60 @@
 }
 /* }}} */
 
+/* {{{ proto void SplFileObject::setCsvControl([string delimiter = ',' [, 
string enclosure = '']])
+   Set the delimiter and enclosure character used in fgetcsv */
+SPL_METHOD(SplFileObject, setCsvControl)
+{
+   spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+   char delimiter = ',', enclosure = '';
+   char *delim, *enclo;
+   int d_len, e_len;
+   
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |ss, delim, 
d_len, enclo, e_len) == SUCCESS) {
+   switch(ZEND_NUM_ARGS())
+   {
+   case 2:
+   if (e_len != 1) {
+   php_error_docref(NULL TSRMLS_CC, 
E_WARNING, enclosure must be a character);
+   RETURN_FALSE;
+   }
+   enclosure = enclo[0];
+   /* no break */
+   case 1:
+   if (d_len != 1) {
+   php_error_docref(NULL TSRMLS_CC, 
E_WARNING, delimiter must be a character);
+   RETURN_FALSE;
+   }
+   delimiter = delim[0];
+   /* no break */
+   case 0:
+   break;
+   }
+   intern-u.file.delimiter = delimiter;
+   intern-u.file.enclosure = enclosure;
+   }
+}
+/* }}} */
+
+/* {{{ proto array SplFileObject::getCsvControl()
+   Get the delimiter and enclosure character used in fgetcsv */
+SPL_METHOD(SplFileObject, getCsvControl)
+{
+   spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+   char delimiter[2], enclosure[2];
+
+   array_init(return_value);
+   
+   delimiter[0] = intern-u.file.delimiter;
+   delimiter[1] = '\0';
+   enclosure[0] = intern-u.file.enclosure;
+   enclosure[1] = '\0';
+
+   add_next_index_ascii_string(return_value, delimiter, ZSTR_DUPLICATE);
+   add_next_index_ascii_string(return_value, enclosure, ZSTR_DUPLICATE);
+}
+/* }}} */
+
 /* {{{ proto bool SplFileObject::flock(int operation [, int wouldblock])
Portable file locking */
 FileFunction(flock)
@@ -2074,6 +2128,8 @@
SPL_ME(SplFileObject, valid,  NULL, ZEND_ACC_PUBLIC)
SPL_ME(SplFileObject, fgets,  NULL, ZEND_ACC_PUBLIC)
SPL_ME(SplFileObject, fgetcsv,arginfo_file_object_fgetcsv,  
 ZEND_ACC_PUBLIC)
+   SPL_ME(SplFileObject, setCsvControl,  arginfo_file_object_fgetcsv,  
 ZEND_ACC_PUBLIC)
+   SPL_ME(SplFileObject, getCsvControl,  NULL, 
 ZEND_ACC_PUBLIC)
SPL_ME(SplFileObject, flock,  arginfo_file_object_flock,
 ZEND_ACC_PUBLIC)
SPL_ME(SplFileObject, fflush, NULL, ZEND_ACC_PUBLIC)
SPL_ME(SplFileObject, ftell,  NULL, ZEND_ACC_PUBLIC)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2006-07-15 Thread Marcus Boerger
helly   Sat Jul 15 14:54:57 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - Be on the safe side
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.95r2=1.96diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.95 
php-src/ext/spl/spl_directory.c:1.96
--- php-src/ext/spl/spl_directory.c:1.95Sat Jul 15 14:50:38 2006
+++ php-src/ext/spl/spl_directory.c Sat Jul 15 14:54:57 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.95 2006/07/15 14:50:38 helly Exp $ */
+/* $Id: spl_directory.c,v 1.96 2006/07/15 14:54:57 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1450,6 +1450,10 @@
size_t buf_len = intern-u.file.current_line_len;
char *buf = estrndup(intern-u.file.current_line, buf_len);
 
+   if (Z_TYPE_P(return_value) != IS_NULL) {
+   zval_dtor(return_value);
+   ZVAL_NULL(return_value);
+   }
php_fgetcsv(intern-u.file.stream, delimiter, enclosure, 
buf_len, buf, return_value TSRMLS_CC);
}
return ret;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2006-07-10 Thread Dmitry Stogov
dmitry  Mon Jul 10 15:48:09 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  Fixed memory leaks in ext/spl/tests/fileobject_003.phpt
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.91r2=1.92diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.91 
php-src/ext/spl/spl_directory.c:1.92
--- php-src/ext/spl/spl_directory.c:1.91Fri Apr 28 19:03:58 2006
+++ php-src/ext/spl/spl_directory.c Mon Jul 10 15:48:09 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.91 2006/04/28 19:03:58 fmk Exp $ */
+/* $Id: spl_directory.c,v 1.92 2006/07/10 15:48:09 dmitry Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -254,8 +254,8 @@
 
switch (source-type) {
case SPL_FS_INFO:
-   source-path_len = source-path_len;
-   source-path = estrndup(source-path, source-path_len);
+   intern-path_len = source-path_len;
+   intern-path = estrndup(source-path, source-path_len);
intern-file_name_len = source-file_name_len;
intern-file_name = estrndup(source-file_name, 
intern-file_name_len);
break;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c /ext/standard file.c http_fopen_wrapper.c image.c /main php_streams.h

2006-04-28 Thread Frank M. Kromann
fmk Fri Apr 28 19:03:58 2006 UTC

  Modified files:  
/php-src/ext/standard   image.c file.c http_fopen_wrapper.c 
/php-src/main   php_streams.h 
/php-src/ext/splspl_directory.c 
  Log:
  Remove ZSTR() from stream macros. Calling function must apply this macro
  http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/image.c?r1=1.122r2=1.123diff_format=u
Index: php-src/ext/standard/image.c
diff -u php-src/ext/standard/image.c:1.122 php-src/ext/standard/image.c:1.123
--- php-src/ext/standard/image.c:1.122  Sat Apr 22 10:39:30 2006
+++ php-src/ext/standard/image.cFri Apr 28 19:03:57 2006
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: image.c,v 1.122 2006/04/22 10:39:30 fmk Exp $ */
+/* $Id: image.c,v 1.123 2006/04/28 19:03:57 fmk Exp $ */
 
 #include php.h
 #include stdio.h
@@ -1023,7 +1023,7 @@
if (php_stream_rewind(stream)) {
return 0;
}
-   while ((fline=php_stream_gets(stream, NULL, 0)) != NULL) {
+   while ((fline=php_stream_gets(stream, NULL_ZSTR, 0)) != NULL) {
iname = estrdup(fline); /* simple way to get necessary buffer 
of required size */
if (sscanf(fline, #define %s %d, iname, value) == 2) {
if (!(type = strrchr(iname, '_'))) {
http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/file.c?r1=1.438r2=1.439diff_format=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.438 php-src/ext/standard/file.c:1.439
--- php-src/ext/standard/file.c:1.438   Sat Apr 22 10:39:30 2006
+++ php-src/ext/standard/file.c Fri Apr 28 19:03:57 2006
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.438 2006/04/22 10:39:30 fmk Exp $ */
+/* $Id: file.c,v 1.439 2006/04/28 19:03:57 fmk Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -1049,7 +1049,7 @@
 
php_stream_from_zval(stream, zstream);
 
-   buf.v = php_stream_get_line_ex(stream, stream-readbuf_type, NULL, 0, 
length, retlen);
+   buf.v = php_stream_get_line_ex(stream, stream-readbuf_type, NULL_ZSTR, 
0, length, retlen);
if (!buf.v) {
RETURN_FALSE;
}
@@ -1110,7 +1110,7 @@
php_stream_from_zval(stream, zstream);
 
if (stream-readbuf_type == IS_UNICODE) {
-   UChar *buf = php_stream_get_line_ex(stream, IS_UNICODE, NULL, 
0, length, retlen);
+   UChar *buf = php_stream_get_line_ex(stream, IS_UNICODE, 
NULL_ZSTR, 0, length, retlen);
UChar *allowed = NULL;
int allowed_len = 0;
 
@@ -1127,7 +1127,7 @@
 
RETURN_UNICODEL(buf, retlen, 0);
} else { /* IS_STRING */
-   char *buf = php_stream_get_line_ex(stream, IS_STRING, NULL, 0, 
length, retlen);
+   char *buf = php_stream_get_line_ex(stream, IS_STRING, 
NULL_ZSTR, 0, length, retlen);
char *allowed = NULL;
int allowed_len = 0;
 
@@ -1189,7 +1189,7 @@
}
 
 
-   buf = php_stream_get_line((php_stream *) what, NULL, 0, len);
+   buf = php_stream_get_line((php_stream *) what, NULL_ZSTR, 0, len);
if (buf == NULL) {
efree(args);
RETURN_FALSE;
@@ -2056,12 +2056,12 @@
}
 
if (len  0) {
-   if ((buf = php_stream_get_line(stream, NULL, 0, buf_len)) == 
NULL) {
+   if ((buf = php_stream_get_line(stream, NULL_ZSTR, 0, buf_len)) 
== NULL) {
RETURN_FALSE;
}
} else {
buf = emalloc(len + 1);
-   if (php_stream_get_line(stream, buf, len + 1, buf_len) == 
NULL) {
+   if (php_stream_get_line(stream, ZSTR(buf), len + 1, buf_len) 
== NULL) {
efree(buf);
RETURN_FALSE;
}
@@ -2153,7 +2153,7 @@
memcpy(tptr, 
line_end, line_end_len);
tptr += 
line_end_len;
 
-   if ((new_buf = 
php_stream_get_line(stream, NULL, 0, new_len)) == NULL) {
+   if ((new_buf = 
php_stream_get_line(stream, NULL_ZSTR, 0, new_len)) == NULL) {
/* 
we've got an unterminated enclosure,
 * 
assign all the data from the start of
 * the 
enclosure to end of data to the
http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/http_fopen_wrapper.c?r1=1.115r2=1.116diff_format=u
Index: php-src/ext/standard/http_fopen_wrapper.c
diff -u 

[PHP-CVS] cvs: php-src /ext/spl spl_directory.c /ext/standard file.c image.c /sapi/cli php_cli.c

2006-04-22 Thread Frank M. Kromann
fmk Sat Apr 22 10:39:31 2006 UTC

  Modified files:  
/php-src/ext/standard   file.c image.c 
/php-src/ext/splspl_directory.c 
/php-src/sapi/cli   php_cli.c 
  Log:
  Fix Win32 build. NULL_ZSTR was converted to ZSTR(NULL_ZSTR)
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/file.c?r1=1.437r2=1.438diff_format=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.437 php-src/ext/standard/file.c:1.438
--- php-src/ext/standard/file.c:1.437   Tue Apr 18 19:10:12 2006
+++ php-src/ext/standard/file.c Sat Apr 22 10:39:30 2006
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.437 2006/04/18 19:10:12 pollita Exp $ */
+/* $Id: file.c,v 1.438 2006/04/22 10:39:30 fmk Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -1049,7 +1049,7 @@
 
php_stream_from_zval(stream, zstream);
 
-   buf.v = php_stream_get_line_ex(stream, stream-readbuf_type, NULL_ZSTR, 
0, length, retlen);
+   buf.v = php_stream_get_line_ex(stream, stream-readbuf_type, NULL, 0, 
length, retlen);
if (!buf.v) {
RETURN_FALSE;
}
@@ -1110,7 +1110,7 @@
php_stream_from_zval(stream, zstream);
 
if (stream-readbuf_type == IS_UNICODE) {
-   UChar *buf = php_stream_get_line_ex(stream, IS_UNICODE, 
NULL_ZSTR, 0, length, retlen);
+   UChar *buf = php_stream_get_line_ex(stream, IS_UNICODE, NULL, 
0, length, retlen);
UChar *allowed = NULL;
int allowed_len = 0;
 
@@ -1127,7 +1127,7 @@
 
RETURN_UNICODEL(buf, retlen, 0);
} else { /* IS_STRING */
-   char *buf = php_stream_get_line_ex(stream, IS_STRING, 
NULL_ZSTR, 0, length, retlen);
+   char *buf = php_stream_get_line_ex(stream, IS_STRING, NULL, 0, 
length, retlen);
char *allowed = NULL;
int allowed_len = 0;
 
@@ -1189,7 +1189,7 @@
}
 
 
-   buf = php_stream_get_line((php_stream *) what, NULL_ZSTR, 0, len);
+   buf = php_stream_get_line((php_stream *) what, NULL, 0, len);
if (buf == NULL) {
efree(args);
RETURN_FALSE;
@@ -2056,7 +2056,7 @@
}
 
if (len  0) {
-   if ((buf = php_stream_get_line(stream, NULL_ZSTR, 0, buf_len)) 
== NULL) {
+   if ((buf = php_stream_get_line(stream, NULL, 0, buf_len)) == 
NULL) {
RETURN_FALSE;
}
} else {
@@ -2153,7 +2153,7 @@
memcpy(tptr, 
line_end, line_end_len);
tptr += 
line_end_len;
 
-   if ((new_buf = 
php_stream_get_line(stream, NULL_ZSTR, 0, new_len)) == NULL) {
+   if ((new_buf = 
php_stream_get_line(stream, NULL, 0, new_len)) == NULL) {
/* 
we've got an unterminated enclosure,
 * 
assign all the data from the start of
 * the 
enclosure to end of data to the
http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/image.c?r1=1.121r2=1.122diff_format=u
Index: php-src/ext/standard/image.c
diff -u php-src/ext/standard/image.c:1.121 php-src/ext/standard/image.c:1.122
--- php-src/ext/standard/image.c:1.121  Fri Mar 17 22:52:55 2006
+++ php-src/ext/standard/image.cSat Apr 22 10:39:30 2006
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: image.c,v 1.121 2006/03/17 22:52:55 andrei Exp $ */
+/* $Id: image.c,v 1.122 2006/04/22 10:39:30 fmk Exp $ */
 
 #include php.h
 #include stdio.h
@@ -1023,7 +1023,7 @@
if (php_stream_rewind(stream)) {
return 0;
}
-   while ((fline=php_stream_gets(stream, NULL_ZSTR, 0)) != NULL) {
+   while ((fline=php_stream_gets(stream, NULL, 0)) != NULL) {
iname = estrdup(fline); /* simple way to get necessary buffer 
of required size */
if (sscanf(fline, #define %s %d, iname, value) == 2) {
if (!(type = strrchr(iname, '_'))) {
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.c?r1=1.89r2=1.90diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.89 
php-src/ext/spl/spl_directory.c:1.90
--- php-src/ext/spl/spl_directory.c:1.89Thu Apr  6 19:11:06 2006
+++ php-src/ext/spl/spl_directory.c Sat Apr 22 10:39:30 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.89 2006/04/06 19:11:06 tony2001 Exp $ */
+/* $Id: 

[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2006-04-06 Thread Antony Dovgal
tony2001Thu Apr  6 19:11:06 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  MF51: fix #36981 (SplFileObject-fgets() ignores max_length)
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.c?r1=1.88r2=1.89diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.88 
php-src/ext/spl/spl_directory.c:1.89
--- php-src/ext/spl/spl_directory.c:1.88Wed Mar 29 15:08:52 2006
+++ php-src/ext/spl/spl_directory.c Thu Apr  6 19:11:06 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.88 2006/03/29 15:08:52 tony2001 Exp $ */
+/* $Id: spl_directory.c,v 1.89 2006/04/06 19:11:06 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1335,7 +1335,7 @@
 static int spl_filesystem_file_read(spl_filesystem_object *intern, int silent 
TSRMLS_DC) /* {{{ */
 {
char *buf;
-   size_t line_len;
+   size_t line_len = 0;
long line_add = (intern-u.file.current_line || 
intern-u.file.current_zval) ? 1 : 0;
 
spl_filesystem_file_free_line(intern TSRMLS_CC);
@@ -1347,7 +1347,17 @@
return FAILURE;
}
 
-   buf = php_stream_get_line(intern-u.file.stream, NULL_ZSTR, 
intern-u.file.max_line_len, line_len);
+   if (intern-u.file.max_line_len  0) {
+   buf = emalloc((intern-u.file.max_line_len + 1) * sizeof(char));
+   if (php_stream_get_line(intern-u.file.stream, buf, 
intern-u.file.max_line_len, line_len) == NULL) {
+   efree(buf);
+   buf = NULL;
+   } else {
+   buf[line_len] = '\0';
+   }
+   } else {
+   buf = php_stream_get_line(intern-u.file.stream, NULL_ZSTR, 0, 
line_len);
+   }
 
if (!buf) {
intern-u.file.current_line = estrdup();

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2006-03-20 Thread Antony Dovgal
tony2001Mon Mar 20 13:53:56 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  initialize retval
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.c?r1=1.86r2=1.87diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.86 
php-src/ext/spl/spl_directory.c:1.87
--- php-src/ext/spl/spl_directory.c:1.86Fri Mar 17 22:52:55 2006
+++ php-src/ext/spl/spl_directory.c Mon Mar 20 13:53:56 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.86 2006/03/17 22:52:55 andrei Exp $ */
+/* $Id: spl_directory.c,v 1.87 2006/03/20 13:53:56 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1435,7 +1435,7 @@
 
 static int spl_filesystem_file_read_line_ex(zval * this_ptr, 
spl_filesystem_object *intern, int silent TSRMLS_DC) /* {{{ */
 {
-   zval *retval;
+   zval *retval = NULL;
 
/* 1) use fgetcsv? 2) overloaded call the function, 3) do it directly */
if (intern-flags  SPL_FILE_OBJECT_READ_CSV || 
intern-u.file.func_getCurr-common.scope != spl_ce_SplFileObject) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c /ext/standard file.c image.c /main/streams streams.c /sapi/cli php_cli.c

2006-03-17 Thread Andrei Zmievski
andrei  Fri Mar 17 22:52:55 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
/php-src/ext/standard   file.c image.c 
/php-src/main/streams   streams.c 
/php-src/sapi/cli   php_cli.c 
  Log:
  Fix compiler errors by using NULL_ZSTR where zstr is expected.
  
  # I guess we need to use NULL_ZSTR instead of NULL when passing NULL to
  # functions that expect zstr parameter.
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.c?r1=1.85r2=1.86diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.85 
php-src/ext/spl/spl_directory.c:1.86
--- php-src/ext/spl/spl_directory.c:1.85Thu Mar  9 23:03:08 2006
+++ php-src/ext/spl/spl_directory.c Fri Mar 17 22:52:55 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.85 2006/03/09 23:03:08 helly Exp $ */
+/* $Id: spl_directory.c,v 1.86 2006/03/17 22:52:55 andrei Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1349,7 +1349,7 @@
return FAILURE;
}
 
-   buf = php_stream_get_line(intern-u.file.stream, NULL, 
intern-u.file.max_line_len, line_len);
+   buf = php_stream_get_line(intern-u.file.stream, NULL_ZSTR, 
intern-u.file.max_line_len, line_len);
 
if (!buf) {
intern-u.file.current_line = estrdup();
http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/file.c?r1=1.427r2=1.428diff_format=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.427 php-src/ext/standard/file.c:1.428
--- php-src/ext/standard/file.c:1.427   Wed Mar 15 00:28:57 2006
+++ php-src/ext/standard/file.c Fri Mar 17 22:52:55 2006
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.427 2006/03/15 00:28:57 pollita Exp $ */
+/* $Id: file.c,v 1.428 2006/03/17 22:52:55 andrei Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -1002,7 +1002,7 @@
 
php_stream_from_zval(stream, zstream);
 
-   buf.v = php_stream_get_line_ex(stream, php_stream_reads_unicode(stream) 
? IS_UNICODE : IS_STRING, NULL, 0, length, retlen);
+   buf.v = php_stream_get_line_ex(stream, php_stream_reads_unicode(stream) 
? IS_UNICODE : IS_STRING, NULL_ZSTR, 0, length, retlen);
if (!buf.v) {
RETURN_FALSE;
}
@@ -1157,7 +1157,7 @@
}
 
 
-   buf = php_stream_get_line((php_stream *) what, NULL, 0, len);
+   buf = php_stream_get_line((php_stream *) what, NULL_ZSTR, 0, len);
if (buf == NULL) {
efree(args);
RETURN_FALSE;
@@ -1991,7 +1991,7 @@
}
 
if (len  0) {
-   if ((buf = php_stream_get_line(stream, NULL, 0, buf_len)) == 
NULL) {
+   if ((buf = php_stream_get_line(stream, NULL_ZSTR, 0, buf_len)) 
== NULL) {
RETURN_FALSE;
}
} else {
@@ -2088,7 +2088,7 @@
memcpy(tptr, 
line_end, line_end_len);
tptr += 
line_end_len;
 
-   if ((new_buf = 
php_stream_get_line(stream, NULL, 0, new_len)) == NULL) {
+   if ((new_buf = 
php_stream_get_line(stream, NULL_ZSTR, 0, new_len)) == NULL) {
/* 
we've got an unterminated enclosure,
 * 
assign all the data from the start of
 * the 
enclosure to end of data to the
http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/image.c?r1=1.120r2=1.121diff_format=u
Index: php-src/ext/standard/image.c
diff -u php-src/ext/standard/image.c:1.120 php-src/ext/standard/image.c:1.121
--- php-src/ext/standard/image.c:1.120  Thu Mar  2 13:12:45 2006
+++ php-src/ext/standard/image.cFri Mar 17 22:52:55 2006
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: image.c,v 1.120 2006/03/02 13:12:45 dmitry Exp $ */
+/* $Id: image.c,v 1.121 2006/03/17 22:52:55 andrei Exp $ */
 
 #include php.h
 #include stdio.h
@@ -1023,7 +1023,7 @@
if (php_stream_rewind(stream)) {
return 0;
}
-   while ((fline=php_stream_gets(stream, NULL, 0)) != NULL) {
+   while ((fline=php_stream_gets(stream, NULL_ZSTR, 0)) != NULL) {
iname = estrdup(fline); /* simple way to get necessary buffer 
of required size */
if (sscanf(fline, #define %s %d, iname, value) == 2) {
if (!(type = strrchr(iname, '_'))) {

[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_directory.h

2006-03-09 Thread Marcus Boerger
helly   Thu Mar  9 23:03:08 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c spl_directory.h 
  Log:
  - Add read ahead ability
  - Add skipping empty lines
  - Add ability to read lines as csv
  
  http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.c?r1=1.84r2=1.85diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.84 
php-src/ext/spl/spl_directory.c:1.85
--- php-src/ext/spl/spl_directory.c:1.84Wed Mar  8 20:30:12 2006
+++ php-src/ext/spl/spl_directory.c Thu Mar  9 23:03:08 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.84 2006/03/08 20:30:12 helly Exp $ */
+/* $Id: spl_directory.c,v 1.85 2006/03/09 23:03:08 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1368,19 +1368,89 @@
return SUCCESS;
 } /* }}} */
 
-static int spl_filesystem_file_read_line(zval * this_ptr, 
spl_filesystem_object *intern, int silent TSRMLS_DC) /* {{{ */
+static int spl_filesystem_file_call(spl_filesystem_object *intern, 
zend_function *func_ptr, int pass_num_args, zval *return_value, zval *arg2 
TSRMLS_DC) /* {{{ */
+{
+   zend_fcall_info fci;
+   zend_fcall_info_cache fcic;
+   zval z_fname;
+   zval * zresource_ptr = intern-u.file.zresource, *retval;
+   int result;
+   int num_args = pass_num_args + (arg2 ? 2 : 1);
+
+   zval ***params = (zval***)safe_emalloc(num_args, sizeof(zval**), 0);
+
+   params[0] = zresource_ptr;
+   
+   if (arg2) {
+   params[1] = arg2;
+   }
+
+   zend_get_parameters_array_ex(pass_num_args, params+(arg2 ? 2 : 1));
+
+   ZVAL_STRING(z_fname, func_ptr-common.function_name.s, 0);
+
+   fci.size = sizeof(fci);
+   fci.function_table = EG(function_table);
+   fci.object_pp = NULL;
+   fci.function_name = z_fname;
+   fci.retval_ptr_ptr = retval;
+   fci.param_count = num_args;
+   fci.params = params;
+   fci.no_separation = 1;
+   fci.symbol_table = NULL;
+
+   fcic.initialized = 1;
+   fcic.function_handler = func_ptr;
+   fcic.calling_scope = NULL;
+   fcic.object_pp = NULL;
+
+   result = zend_call_function(fci, fcic TSRMLS_CC);
+   
+   ZVAL_ZVAL(return_value, retval, 1, 1);
+
+   efree(params);
+   return result;
+} /* }}} */
+
+#define FileFunctionCall(func_name, pass_num_args, arg2) \
+{ \
+   zend_function *func_ptr; \
+   zend_hash_find(EG(function_table), #func_name, sizeof(#func_name), 
(void **) func_ptr); \
+   spl_filesystem_file_call(intern, func_ptr, pass_num_args, return_value, 
arg2 TSRMLS_CC); \
+}
+
+static void spl_filesystem_file_read_csv(zval * this_ptr, 
spl_filesystem_object *intern, int pass_num_args, zval *return_value TSRMLS_DC) 
/* {{{ */
+{
+   zval *arg2 = NULL;
+   MAKE_STD_ZVAL(arg2);
+   ZVAL_LONG(arg2, intern-u.file.max_line_len);
+
+   spl_filesystem_file_free_line(intern TSRMLS_CC);
+
+   FileFunctionCall(fgetcsv, pass_num_args, arg2);
+
+   zval_ptr_dtor(arg2);
+}
+/* }}} */
+
+static int spl_filesystem_file_read_line_ex(zval * this_ptr, 
spl_filesystem_object *intern, int silent TSRMLS_DC) /* {{{ */
 {
zval *retval;
 
-   /* if overloaded call the function, otherwise do it directly */
-   if (intern-u.file.func_getCurr-common.scope != spl_ce_SplFileObject) {
+   /* 1) use fgetcsv? 2) overloaded call the function, 3) do it directly */
+   if (intern-flags  SPL_FILE_OBJECT_READ_CSV || 
intern-u.file.func_getCurr-common.scope != spl_ce_SplFileObject) {
if (php_stream_eof(intern-u.file.stream)) {
if (!silent) {

zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, Cannot read from 
file %s, intern-file_name);
}
return FAILURE;
}
-   zend_call_method_with_0_params(getThis(), 
Z_OBJCE_P(getThis()), intern-u.file.func_getCurr, getCurrentLine, retval);
+   if (intern-flags  SPL_FILE_OBJECT_READ_CSV) {
+   MAKE_STD_ZVAL(retval);
+   spl_filesystem_file_read_csv(this_ptr, intern, 0, 
retval TSRMLS_CC);
+   } else {
+   zend_call_method_with_0_params(this_ptr, 
Z_OBJCE_P(getThis()), intern-u.file.func_getCurr, getCurrentLine, retval);
+   }
if (retval) {
if (intern-u.file.current_line || 
intern-u.file.current_zval) {
intern-u.file.current_line_num++;
@@ -1403,7 +1473,49 @@
}
 } /* }}} */
 
-static void spl_filesystem_file_rewind(spl_filesystem_object *intern 
TSRMLS_DC) /* {{{ */
+static int spl_filesystem_file_is_empty_line(spl_filesystem_object *intern 
TSRMLS_DC) /* {{{ */
+{
+   if (intern-u.file.current_line) {
+   return 

[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_directory.h

2006-03-08 Thread Marcus Boerger
helly   Wed Mar  8 20:06:16 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c spl_directory.h 
  Log:
  - Something that uses void* oth might want to deinitialize it in the dtor
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.c?r1=1.82r2=1.83diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.82 
php-src/ext/spl/spl_directory.c:1.83
--- php-src/ext/spl/spl_directory.c:1.82Wed Mar  8 00:43:28 2006
+++ php-src/ext/spl/spl_directory.c Wed Mar  8 20:06:16 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.82 2006/03/08 00:43:28 pajoye Exp $ */
+/* $Id: spl_directory.c,v 1.83 2006/03/08 20:06:16 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -70,6 +70,9 @@
 {
spl_filesystem_object *intern = (spl_filesystem_object*)object;
 
+   if (intern-oth_dtor) {
+   intern-oth_dtor(intern TSRMLS_CC);
+   }
zend_hash_destroy(intern-std.properties);
FREE_HASHTABLE(intern-std.properties);
 
@@ -1330,7 +1333,6 @@
 {
char *buf;
size_t line_len;
-   int len;
long line_add = (intern-u.file.current_line || 
intern-u.file.current_zval) ? 1 : 0;
 
spl_filesystem_file_free_line(intern TSRMLS_CC);
@@ -1823,7 +1825,6 @@
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
char *str;
int str_len;
-   int ret;
long length = 0;
 
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|l, str, 
str_len, length) == FAILURE) {
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.h?r1=1.20r2=1.21diff_format=u
Index: php-src/ext/spl/spl_directory.h
diff -u php-src/ext/spl/spl_directory.h:1.20 
php-src/ext/spl/spl_directory.h:1.21
--- php-src/ext/spl/spl_directory.h:1.20Mon Feb 27 18:15:29 2006
+++ php-src/ext/spl/spl_directory.h Wed Mar  8 20:06:16 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.h,v 1.20 2006/02/27 18:15:29 helly Exp $ */
+/* $Id: spl_directory.h,v 1.21 2006/03/08 20:06:16 helly Exp $ */
 
 #ifndef SPL_DIRECTORY_H
 #define SPL_DIRECTORY_H
@@ -38,9 +38,14 @@
SPL_FS_FILE,
 } SPL_FS_OBJ_TYPE;
 
-typedef struct _spl_filesystem_object {
+typedef struct _spl_filesystem_object  spl_filesystem_object;
+
+typedef void (*spl_foreign_dtor_t)(spl_filesystem_object *object TSRMLS_DC);
+
+struct _spl_filesystem_object {
zend_objectstd;
void   *oth;
+   spl_foreign_dtor_t oth_dtor;
char   *path;
intpath_len;
char   *file_name;
@@ -73,7 +78,7 @@
zend_function  *func_getCurr;
} file;
} u;
-} spl_filesystem_object;
+};
 
 #define SPL_FILE_OBJECT_DROP_NEW_LINE  0x0001 /* drop new lines */
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_directory.h

2006-03-08 Thread Marcus Boerger
helly   Wed Mar  8 20:30:12 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c spl_directory.h 
  Log:
  - Cloning might need special treatment as well
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.c?r1=1.83r2=1.84diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.83 
php-src/ext/spl/spl_directory.c:1.84
--- php-src/ext/spl/spl_directory.c:1.83Wed Mar  8 20:06:16 2006
+++ php-src/ext/spl/spl_directory.c Wed Mar  8 20:30:12 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.83 2006/03/08 20:06:16 helly Exp $ */
+/* $Id: spl_directory.c,v 1.84 2006/03/08 20:30:12 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -70,8 +70,8 @@
 {
spl_filesystem_object *intern = (spl_filesystem_object*)object;
 
-   if (intern-oth_dtor) {
-   intern-oth_dtor(intern TSRMLS_CC);
+   if (intern-oth_handler  intern-oth_handler-dtor) {
+   intern-oth_handler-dtor(intern TSRMLS_CC);
}
zend_hash_destroy(intern-std.properties);
FREE_HASHTABLE(intern-std.properties);
@@ -133,7 +133,7 @@
intern = emalloc(sizeof(spl_filesystem_object));
memset(intern, 0, sizeof(spl_filesystem_object));
intern-std.ce = class_type;
-   /* intern-type = SPL_FS_INFO; done by set o */
+   /* intern-type = SPL_FS_INFO; done by set 0 */
intern-file_class = spl_ce_SplFileObject;
intern-info_class = spl_ce_SplFileInfo;
if (obj) *obj = intern;
@@ -273,9 +273,14 @@
intern-info_class = source-info_class;
intern-flags = source-flags;
intern-oth = source-oth;
+   intern-oth_handler = source-oth_handler;
 
zend_objects_clone_members(new_object, new_obj_val, old_object, handle 
TSRMLS_CC);
 
+   if (intern-oth_handler  intern-oth_handler-clone) {
+   intern-oth_handler-clone(source, intern TSRMLS_CC);
+   }
+
return new_obj_val;
 }
 /* }}} */
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.h?r1=1.21r2=1.22diff_format=u
Index: php-src/ext/spl/spl_directory.h
diff -u php-src/ext/spl/spl_directory.h:1.21 
php-src/ext/spl/spl_directory.h:1.22
--- php-src/ext/spl/spl_directory.h:1.21Wed Mar  8 20:06:16 2006
+++ php-src/ext/spl/spl_directory.h Wed Mar  8 20:30:12 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.h,v 1.21 2006/03/08 20:06:16 helly Exp $ */
+/* $Id: spl_directory.h,v 1.22 2006/03/08 20:30:12 helly Exp $ */
 
 #ifndef SPL_DIRECTORY_H
 #define SPL_DIRECTORY_H
@@ -33,7 +33,7 @@
 PHP_MINIT_FUNCTION(spl_directory);
 
 typedef enum {
-   SPL_FS_INFO,
+   SPL_FS_INFO, /* must be 0 */
SPL_FS_DIR,
SPL_FS_FILE,
 } SPL_FS_OBJ_TYPE;
@@ -41,11 +41,17 @@
 typedef struct _spl_filesystem_object  spl_filesystem_object;
 
 typedef void (*spl_foreign_dtor_t)(spl_filesystem_object *object TSRMLS_DC);
+typedef void (*spl_foreign_clone_t)(spl_filesystem_object *src, 
spl_filesystem_object *dst TSRMLS_DC);
+
+typedef struct _spl_other_handler {
+   spl_foreign_dtor_t dtor;
+   spl_foreign_clone_tclone;
+} spl_other_handler;
 
 struct _spl_filesystem_object {
zend_objectstd;
void   *oth;
-   spl_foreign_dtor_t oth_dtor;
+   spl_other_handler  *oth_handler;
char   *path;
intpath_len;
char   *file_name;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2006-03-07 Thread Marcus Boerger
helly   Tue Mar  7 20:22:12 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - WS
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.c?r1=1.80r2=1.81diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.80 
php-src/ext/spl/spl_directory.c:1.81
--- php-src/ext/spl/spl_directory.c:1.80Mon Mar  6 09:45:25 2006
+++ php-src/ext/spl/spl_directory.c Tue Mar  7 20:22:12 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.80 2006/03/06 09:45:25 helly Exp $ */
+/* $Id: spl_directory.c,v 1.81 2006/03/07 20:22:12 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -437,8 +437,8 @@
 
if (!len) {
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
-zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, 
Directory name must not be empty.);
-return;
+   zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, 
Directory name must not be empty.);
+   return;
}
 
intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() 
TSRMLS_CC);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_iterators.c spl_sxe.c

2006-03-06 Thread Marcus Boerger
helly   Mon Mar  6 09:45:25 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c spl_iterators.c spl_sxe.c 
  Log:
  - Proto fixes
  http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.c?r1=1.79r2=1.80diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.79 
php-src/ext/spl/spl_directory.c:1.80
--- php-src/ext/spl/spl_directory.c:1.79Sat Mar  4 22:56:11 2006
+++ php-src/ext/spl/spl_directory.c Mon Mar  6 09:45:25 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.79 2006/03/04 22:56:11 helly Exp $ */
+/* $Id: spl_directory.c,v 1.80 2006/03/06 09:45:25 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -741,7 +741,7 @@
 }
 /* }}} */
 
-/* {{{ proto SplFileObject SplFileInfo::setFileClass([string class_name])
+/* {{{ proto void SplFileInfo::setFileClass([string class_name])
Class to use in openFile() */
 SPL_METHOD(SplFileInfo, setFileClass)
 {
@@ -758,7 +758,7 @@
 }
 /* }}} */
 
-/* {{{ proto SplFileObject SplFileInfo::setInfoClass([string class_name])
+/* {{{ proto void SplFileInfo::setInfoClass([string class_name])
Class to use in getFileInfo(), getPathInfo() */
 SPL_METHOD(SplFileInfo, setInfoClass)
 {
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_iterators.c?r1=1.118r2=1.119diff_format=u
Index: php-src/ext/spl/spl_iterators.c
diff -u php-src/ext/spl/spl_iterators.c:1.118 
php-src/ext/spl/spl_iterators.c:1.119
--- php-src/ext/spl/spl_iterators.c:1.118   Sat Mar  4 17:01:16 2006
+++ php-src/ext/spl/spl_iterators.c Mon Mar  6 09:45:25 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_iterators.c,v 1.118 2006/03/04 17:01:16 helly Exp $ */
+/* $Id: spl_iterators.c,v 1.119 2006/03/06 09:45:25 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -367,7 +367,7 @@
spl_recursive_it_rewind
 };
 
-/* {{{ proto 
RecursiveIteratorIterator::__construct(RecursiveIterator|IteratorAggregate it 
[, int mode = RIT_LEAVES_ONLY [, int flags = 0]]) throws 
InvalidArgumentException
+/* {{{ proto void 
RecursiveIteratorIterator::__construct(RecursiveIterator|IteratorAggregate it 
[, int mode = RIT_LEAVES_ONLY [, int flags = 0]]) throws 
InvalidArgumentException
Creates a RecursiveIteratorIterator from a RecursiveIterator. */
 SPL_METHOD(RecursiveIteratorIterator, __construct)
 {
@@ -456,7 +456,7 @@
spl_recursive_it_rewind_ex(object, getThis() TSRMLS_CC);
 } /* }}} */
 
-/* {{{ proto bolean RecursiveIteratorIterator::valid()
+/* {{{ proto bool RecursiveIteratorIterator::valid()
Check whether the current position is valid */
 SPL_METHOD(RecursiveIteratorIterator, valid)
 {
@@ -601,28 +601,28 @@
}
 } /* }}} */
 
-/* {{{ proto RecursiveIterator RecursiveIteratorIterator::beginChildren()
+/* {{{ proto void RecursiveIteratorIterator::beginChildren()
Called when recursing one level down */
 SPL_METHOD(RecursiveIteratorIterator, beginChildren)
 {
/* nothing to do */
 } /* }}} */
 
-/* {{{ proto RecursiveIterator RecursiveIteratorIterator::endChildren()
+/* {{{ proto void RecursiveIteratorIterator::endChildren()
Called when end recursing one level */
 SPL_METHOD(RecursiveIteratorIterator, endChildren)
 {
/* nothing to do */
 } /* }}} */
 
-/* {{{ proto RecursiveIterator RecursiveIteratorIterator::nextElement()
+/* {{{ proto void RecursiveIteratorIterator::nextElement()
Called when the next element is available */
 SPL_METHOD(RecursiveIteratorIterator, nextElement)
 {
/* nothing to do */
 } /* }}} */
 
-/* {{{ proto RecursiveIterator 
RecursiveIteratorIterator::setMaxDepth([$max_depth = -1])
+/* {{{ proto void RecursiveIteratorIterator::setMaxDepth([$max_depth = -1])
Set the maximum allowed depth (or any depth if pmax_depth = -1] */
 SPL_METHOD(RecursiveIteratorIterator, setMaxDepth)
 {
@@ -639,7 +639,7 @@
object-max_depth = max_depth;
 } /* }}} */
 
-/* {{{ proto RecursiveIterator RecursiveIteratorIterator::getMaxDepth()
+/* {{{ proto int|false RecursiveIteratorIterator::getMaxDepth()
Return the maximum accepted depth or false if any depth is allowed */
 SPL_METHOD(RecursiveIteratorIterator, getMaxDepth)
 {
@@ -979,7 +979,7 @@
return intern;
 }
 
-/* {{{ proto FilterIterator::__construct(Iterator it) 
+/* {{{ proto void FilterIterator::__construct(Iterator it) 
Create an Iterator from another iterator */
 SPL_METHOD(FilterIterator, __construct)
 {
@@ -1095,10 +1095,10 @@
spl_dual_it_fetch(intern, 1 TSRMLS_CC);
 } /* }}} */
 
-/* {{{ proto boolean FilterIterator::valid()
-   proto boolean ParentIterator::valid()
-   proto boolean IteratorIterator::valid()
-   proto boolean NoRewindIterator::valid()
+/* {{{ proto bool FilterIterator::valid()
+   proto bool ParentIterator::valid()
+   proto bool IteratorIterator::valid()
+  

[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2006-02-10 Thread Antony Dovgal
tony2001Fri Feb 10 16:56:56 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  fix #36359 (splFileObject::fwrite() doesn't write when no data length 
specified)
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.c?r1=1.73r2=1.74diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.73 
php-src/ext/spl/spl_directory.c:1.74
--- php-src/ext/spl/spl_directory.c:1.73Sun Feb  5 23:31:47 2006
+++ php-src/ext/spl/spl_directory.c Fri Feb 10 16:56:56 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.73 2006/02/05 23:31:47 helly Exp $ */
+/* $Id: spl_directory.c,v 1.74 2006/02/10 16:56:56 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1809,13 +1809,13 @@
char *str;
int str_len;
int ret;
-   long length;
+   long length = 0;
 
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|l, str, 
str_len, length) == FAILURE) {
return;
}
 
-   if (ZEND_NUM_ARGS()  2) {
+   if (ZEND_NUM_ARGS()  1) {
str_len = MAX(0, MIN(length, str_len));
}
if (!str_len) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2006-02-05 Thread Marcus Boerger
helly   Sun Feb  5 11:43:28 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - Fix bug #36287
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.c?r1=1.70r2=1.71diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.70 
php-src/ext/spl/spl_directory.c:1.71
--- php-src/ext/spl/spl_directory.c:1.70Thu Feb  2 19:02:05 2006
+++ php-src/ext/spl/spl_directory.c Sun Feb  5 11:43:28 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.70 2006/02/02 19:02:05 helly Exp $ */
+/* $Id: spl_directory.c,v 1.71 2006/02/05 11:43:28 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1199,6 +1199,7 @@
return SUCCESS;
}
}
+   ZVAL_NULL(writeobj);
return FAILURE;
 }
 /* }}} */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2006-02-05 Thread Antony Dovgal
tony2001Sun Feb  5 19:22:13 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  fix #36295 (typo in SplFileObject::flock() parameter name)
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.c?r1=1.71r2=1.72diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.71 
php-src/ext/spl/spl_directory.c:1.72
--- php-src/ext/spl/spl_directory.c:1.71Sun Feb  5 11:43:28 2006
+++ php-src/ext/spl/spl_directory.c Sun Feb  5 19:22:13 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.71 2006/02/05 11:43:28 helly Exp $ */
+/* $Id: spl_directory.c,v 1.72 2006/02/05 19:22:13 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1895,7 +1895,7 @@
 static
 ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_flock, 0, 0, 1) 
ZEND_ARG_INFO(0, operation)
-   ZEND_ARG_INFO(1, wouldblock])
+   ZEND_ARG_INFO(1, wouldblock)
 ZEND_END_ARG_INFO()
 
 static

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2006-02-02 Thread Antony Dovgal
tony2001Thu Feb  2 12:20:26 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  MF51: fix #36258 (SplFileObject::getPath() may lead to segfault)
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.c?r1=1.66r2=1.67diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.66 
php-src/ext/spl/spl_directory.c:1.67
--- php-src/ext/spl/spl_directory.c:1.66Mon Jan 23 15:24:41 2006
+++ php-src/ext/spl/spl_directory.c Thu Feb  2 12:20:26 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.66 2006/01/23 15:24:41 iliaa Exp $ */
+/* $Id: spl_directory.c,v 1.67 2006/02/02 12:20:26 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -340,6 +340,8 @@
spl_filesystem_object_get_file_name(source TSRMLS_CC);
intern-file_name = estrndup(source-file_name, 
source-file_name_len);
intern-file_name_len = source-file_name_len;
+   intern-path = estrndup(source-path, source-path_len);
+   intern-path_len = source-path_len;
break;
case SPL_FS_FILE:
return_value-value.obj = spl_filesystem_object_new_ex(ce ? ce 
: source-file_class, intern TSRMLS_CC);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2006-02-02 Thread Ilia Alshanetsky
iliaa   Thu Feb  2 15:10:23 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  MFB51: Only use win32 directory separators on win32 or netware.
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.c?r1=1.68r2=1.69diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.68 
php-src/ext/spl/spl_directory.c:1.69
--- php-src/ext/spl/spl_directory.c:1.68Thu Feb  2 12:40:07 2006
+++ php-src/ext/spl/spl_directory.c Thu Feb  2 15:10:23 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.68 2006/02/02 12:40:07 tony2001 Exp $ */
+/* $Id: spl_directory.c,v 1.69 2006/02/02 15:10:23 iliaa Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -176,7 +176,11 @@
intern-path_len = strlen(path);
intern-u.dir.dirp = php_stream_opendir(path, 
ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL);
 
-   if (intern-path_len  (path[intern-path_len-1] == '/' || 
path[intern-path_len-1] == '\\')) {
+   if (intern-path_len  (path[intern-path_len-1] == '/'
+#if defined(PHP_WIN32) || defined(NETWARE)
+   || path[intern-path_len-1] == '\\'
+#endif
+   )) {
intern-path = estrndup(path, --intern-path_len);
} else {
intern-path = estrndup(path, intern-path_len);
@@ -279,7 +283,11 @@
intern-file_name_len = len;
 
p1 = strrchr(path, '/');
+#if defined(PHP_WIN32) || defined(NETWARE)
p2 = strrchr(path, '\\');
+#else
+   p2 = 0;
+#endif
if (p1 || p2) {
intern-path_len = (p1  p2 ? p1 : p2) - path;
} else {
@@ -1393,7 +1401,11 @@

if (spl_filesystem_file_open(intern, use_include_path, 0 TSRMLS_CC) == 
SUCCESS) {
p1 = strrchr(intern-file_name, '/');
-   p2 = strrchr(intern-file_name, '\\');
+#if defined(PHP_WIN32) || defined(NETWARE)
+   p2 = strrchr(path, '\\');
+#else
+   p2 = 0;
+#endif
if (p1 || p2) {
intern-path_len = (p1  p2 ? p1 : p2) - 
intern-file_name;
} else {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2006-02-02 Thread Marcus Boerger
helly   Thu Feb  2 19:02:05 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - Fix oversight
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.c?r1=1.69r2=1.70diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.69 
php-src/ext/spl/spl_directory.c:1.70
--- php-src/ext/spl/spl_directory.c:1.69Thu Feb  2 15:10:23 2006
+++ php-src/ext/spl/spl_directory.c Thu Feb  2 19:02:05 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.69 2006/02/02 15:10:23 iliaa Exp $ */
+/* $Id: spl_directory.c,v 1.70 2006/02/02 19:02:05 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1402,7 +1402,7 @@
if (spl_filesystem_file_open(intern, use_include_path, 0 TSRMLS_CC) == 
SUCCESS) {
p1 = strrchr(intern-file_name, '/');
 #if defined(PHP_WIN32) || defined(NETWARE)
-   p2 = strrchr(path, '\\');
+   p2 = strrchr(intern-file_name, '\\');
 #else
p2 = 0;
 #endif

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2006-01-23 Thread Ilia Alshanetsky
iliaa   Mon Jan 23 15:24:41 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  MFB51: Fixed bug #36134 (DirectoryIterator constructor failed to detect 
  empty directory names).
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.c?r1=1.65r2=1.66diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.65 
php-src/ext/spl/spl_directory.c:1.66
--- php-src/ext/spl/spl_directory.c:1.65Sun Jan 15 00:17:08 2006
+++ php-src/ext/spl/spl_directory.c Mon Jan 23 15:24:41 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.65 2006/01/15 00:17:08 helly Exp $ */
+/* $Id: spl_directory.c,v 1.66 2006/01/23 15:24:41 iliaa Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -393,6 +393,12 @@
return;
}
 
+   if (!len) {
+   php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
+zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, 
Directory name must not be empty.);
+return;
+   }
+
intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() 
TSRMLS_CC);
spl_filesystem_dir_open(intern, path TSRMLS_CC);
intern-u.dir.is_recursive = instanceof_function(intern-std.ce, 
U_CLASS_ENTRY(spl_ce_RecursiveDirectoryIterator) TSRMLS_CC) ? 1 : 0;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2006-01-14 Thread Marcus Boerger
helly   Sun Jan 15 00:17:08 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - Fix issue found by nuno
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.c?r1=1.64r2=1.65diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.64 
php-src/ext/spl/spl_directory.c:1.65
--- php-src/ext/spl/spl_directory.c:1.64Fri Jan 13 19:35:27 2006
+++ php-src/ext/spl/spl_directory.c Sun Jan 15 00:17:08 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.64 2006/01/13 19:35:27 helly Exp $ */
+/* $Id: spl_directory.c,v 1.65 2006/01/15 00:17:08 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -368,6 +368,7 @@
Z_TYPE_P(return_value) = IS_NULL;
return NULL;
}
+   break;
case SPL_FS_DIR:
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
zend_throw_exception_ex(U_CLASS_ENTRY(spl_ce_RuntimeException), 
0 TSRMLS_CC, Operation not supported);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2006-01-13 Thread Marcus Boerger
helly   Fri Jan 13 19:35:27 2006 UTC

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - Fix #35998 (getPathname() method always returns unix style filenames)
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.c?r1=1.63r2=1.64diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.63 
php-src/ext/spl/spl_directory.c:1.64
--- php-src/ext/spl/spl_directory.c:1.63Sun Jan  1 13:09:54 2006
+++ php-src/ext/spl/spl_directory.c Fri Jan 13 19:35:27 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.63 2006/01/01 13:09:54 sniper Exp $ */
+/* $Id: spl_directory.c,v 1.64 2006/01/13 19:35:27 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -162,7 +162,7 @@
php_error_docref(NULL TSRMLS_CC, E_ERROR, Object not 
initialized);
break;
case SPL_FS_DIR:
-   intern-file_name_len = spprintf(intern-file_name, 0, 
%s/%s, intern-path, intern-u.dir.entry.d_name);
+   intern-file_name_len = spprintf(intern-file_name, 0, 
%s%c%s, intern-path, DEFAULT_SLASH, intern-u.dir.entry.d_name);
break;
}
}
@@ -852,7 +852,7 @@
subdir = 
(spl_filesystem_object*)zend_object_store_get_object(return_value TSRMLS_CC);
if (subdir) {
if (intern-u.dir.sub_path  intern-u.dir.sub_path[0]) {
-   subdir-u.dir.sub_path_len = 
spprintf(subdir-u.dir.sub_path, 0, %s/%s, intern-u.dir.sub_path, 
intern-u.dir.entry.d_name);
+   subdir-u.dir.sub_path_len = 
spprintf(subdir-u.dir.sub_path, 0, %s%c%s, intern-u.dir.sub_path, 
DEFAULT_SLASH, intern-u.dir.entry.d_name);
} else {
subdir-u.dir.sub_path_len = 
strlen(intern-u.dir.entry.d_name);
subdir-u.dir.sub_path = 
estrndup(intern-u.dir.entry.d_name, subdir-u.dir.sub_path_len);
@@ -885,7 +885,7 @@
int len;
 
if (intern-u.dir.sub_path) {
-   len = spprintf(sub_name, 0, %s/%s, intern-u.dir.sub_path, 
intern-u.dir.entry.d_name);
+   len = spprintf(sub_name, 0, %s%c%s, intern-u.dir.sub_path, 
DEFAULT_SLASH, intern-u.dir.entry.d_name);
RETURN_STRINGL(sub_name, len, 0);
} else {
RETURN_STRING(intern-u.dir.entry.d_name, 1);
@@ -907,7 +907,7 @@
}
 
if (intern-u.dir.sub_path) {
-   len = spprintf(sub_name, 0, %s/%s, intern-u.dir.sub_path, 
intern-u.dir.entry.d_name);
+   len = spprintf(sub_name, 0, %s%c%s, intern-u.dir.sub_path, 
DEFAULT_SLASH, intern-u.dir.entry.d_name);
spl_filesystem_object_create_info(intern, sub_name, len, 0, ce, 
return_value TSRMLS_CC);
} else {
spl_filesystem_object_create_info(intern, intern-path, 
intern-path_len, 1, ce, return_value TSRMLS_CC);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2005-12-18 Thread Zeev Suraski
zeevSun Dec 18 14:05:23 2005 EDT

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  Fix prototype (MFB)
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.c?r1=1.61r2=1.62diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.61 
php-src/ext/spl/spl_directory.c:1.62
--- php-src/ext/spl/spl_directory.c:1.61Wed Dec 14 09:55:04 2005
+++ php-src/ext/spl/spl_directory.c Sun Dec 18 14:05:23 2005
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.61 2005/12/14 09:55:04 helly Exp $ */
+/* $Id: spl_directory.c,v 1.62 2005/12/18 14:05:23 zeev Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1563,8 +1563,8 @@
RETURN_LONG((long)intern-u.file.max_line_len);
 } /* }}} */
 
-/* {{{ proto bool SplFileObjecthasChildren()
-   Rturn false */
+/* {{{ proto bool SplFileObject::hasChildren()
+   Return false */
 SPL_METHOD(SplFileObject, hasChildren)
 {
RETURN_FALSE;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2005-12-14 Thread Marcus Boerger
helly   Wed Dec 14 09:55:04 2005 EDT

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - Fix issue spotted by Wez using ms vc 2005
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.c?r1=1.60r2=1.61diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.60 
php-src/ext/spl/spl_directory.c:1.61
--- php-src/ext/spl/spl_directory.c:1.60Sun Dec 11 16:43:00 2005
+++ php-src/ext/spl/spl_directory.c Wed Dec 14 09:55:04 2005
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.60 2005/12/11 16:43:00 helly Exp $ */
+/* $Id: spl_directory.c,v 1.61 2005/12/14 09:55:04 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -303,7 +303,7 @@
 
php_set_error_handling(EH_THROW, U_CLASS_ENTRY(spl_ce_RuntimeException) 
TSRMLS_CC);
 
-   return_value-value.obj = spl_filesystem_object_new_ex(ce ? ce : 
intern-info_class, intern TSRMLS_CC);
+   return_value-value.obj = spl_filesystem_object_new_ex(ce ? ce : 
source-info_class, intern TSRMLS_CC);
Z_TYPE_P(return_value) = IS_OBJECT;
 
spl_filesystem_info_set_filename(intern, file_path, file_path_len, 
use_copy TSRMLS_CC);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2005-12-11 Thread Marcus Boerger
helly   Sun Dec 11 16:43:00 2005 EDT

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - Change to use sane default flags fro RecursiveDirectoryIterator
  - Drop 2nd parameter from DirectoryIterator::__construct() 
  
  
http://cvs.php.net/diff.php/php-src/ext/spl/spl_directory.c?r1=1.59r2=1.60
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.59 
php-src/ext/spl/spl_directory.c:1.60
--- php-src/ext/spl/spl_directory.c:1.59Fri Dec  9 13:32:07 2005
+++ php-src/ext/spl/spl_directory.c Sun Dec 11 16:43:00 2005
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.59 2005/12/09 13:32:07 tony2001 Exp $ */
+/* $Id: spl_directory.c,v 1.60 2005/12/11 16:43:00 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -377,25 +377,17 @@
return NULL;
 } /* }}} */
 
-/* {{{ proto void DirectoryIterator::__construct(string path [, int flags])
+/* {{{ proto void DirectoryIterator::__construct(string path)
  Cronstructs a new dir iterator from a path. */
-/* php_set_error_handling() is used to throw exceptions in case
-   the constructor fails. Here we use this to ensure the object
-   has a valid directory resource.
-   
-   When the constructor gets called the object is already created 
-   by the engine, so we must only call 'additional' initializations.
- */
 SPL_METHOD(DirectoryIterator, __construct)
 {
spl_filesystem_object *intern;
char *path;
int len;
-   long flags = 0;
 
php_set_error_handling(EH_THROW, U_CLASS_ENTRY(spl_ce_RuntimeException) 
TSRMLS_CC);
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|l, path, 
len, flags) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, path, len) 
== FAILURE) {
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
return;
}
@@ -403,7 +395,7 @@
intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() 
TSRMLS_CC);
spl_filesystem_dir_open(intern, path TSRMLS_CC);
intern-u.dir.is_recursive = instanceof_function(intern-std.ce, 
U_CLASS_ENTRY(spl_ce_RecursiveDirectoryIterator) TSRMLS_CC) ? 1 : 0;
-   intern-flags = flags;
+   intern-flags = 0;
 
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
 }
@@ -544,7 +536,7 @@
 /* }}} */
 
 /* {{{ proto string RecursiveDirectoryIterator::current()
-   Return getFilename() or getFileInfo() depending on flags */
+   Return getFilename(), getFileInfo() or $this depending on flags */
 SPL_METHOD(RecursiveDirectoryIterator, current)
 {
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
@@ -755,6 +747,31 @@
spl_filesystem_object_create_info(intern, intern-path, 
intern-path_len, 1, ce, return_value TSRMLS_CC);
 }
 
+/* {{{ proto void RecursiveDirectoryIterator::__construct(string path [, int 
flags])
+ Cronstructs a new dir iterator from a path. */
+SPL_METHOD(RecursiveDirectoryIterator, __construct)
+{
+   spl_filesystem_object *intern;
+   char *path;
+   int len;
+   long flags = SPL_FILE_DIR_CURRENT_AS_FILEINFO;
+
+   php_set_error_handling(EH_THROW, U_CLASS_ENTRY(spl_ce_RuntimeException) 
TSRMLS_CC);
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|l, path, 
len, flags) == FAILURE) {
+   php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
+   return;
+   }
+
+   intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() 
TSRMLS_CC);
+   spl_filesystem_dir_open(intern, path TSRMLS_CC);
+   intern-u.dir.is_recursive = instanceof_function(intern-std.ce, 
U_CLASS_ENTRY(spl_ce_RecursiveDirectoryIterator) TSRMLS_CC) ? 1 : 0;
+   intern-flags = flags;
+
+   php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
+}
+/* }}} */
+
 /* {{{ proto void RecursiveDirectoryIterator::rewind()
Rewind dir back to the start */
 SPL_METHOD(RecursiveDirectoryIterator, rewind)
@@ -1234,7 +1251,14 @@
{NULL, NULL, NULL}
 };
 
+static
+ZEND_BEGIN_ARG_INFO(arginfo_r_dir___construct, 0) 
+   ZEND_ARG_INFO(0, path)
+   ZEND_ARG_INFO(0, flags)
+ZEND_END_ARG_INFO();
+
 static zend_function_entry spl_RecursiveDirectoryIterator_functions[] = {
+   SPL_ME(RecursiveDirectoryIterator, __construct,   
arginfo_r_dir___construct, ZEND_ACC_PUBLIC)
SPL_ME(RecursiveDirectoryIterator, rewind,NULL, ZEND_ACC_PUBLIC)
SPL_ME(RecursiveDirectoryIterator, next,  NULL, ZEND_ACC_PUBLIC)
SPL_ME(RecursiveDirectoryIterator, key,   NULL, ZEND_ACC_PUBLIC)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c

2005-11-27 Thread Marcus Boerger
helly   Sun Nov 27 07:13:44 2005 EDT

  Modified files:  
/php-src/ext/splspl_directory.c 
  Log:
  - Fix editor blocks
  
http://cvs.php.net/diff.php/php-src/ext/spl/spl_directory.c?r1=1.55r2=1.56ty=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.55 
php-src/ext/spl/spl_directory.c:1.56
--- php-src/ext/spl/spl_directory.c:1.55Tue Nov  1 11:54:44 2005
+++ php-src/ext/spl/spl_directory.c Sun Nov 27 07:13:42 2005
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.55 2005/11/01 16:54:44 helly Exp $ */
+/* $Id: spl_directory.c,v 1.56 2005/11/27 12:13:42 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1803,8 +1803,9 @@
while(intern-u.file.current_line_num  line_pos) {
spl_filesystem_file_read_line(getThis(), intern, 1 TSRMLS_CC);
}
-}
+} /* }}} */
 
+/* {{{ Function/Class/Method definitions */
 static
 ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object___construct, 0, 0, 1)
ZEND_ARG_INFO(0, file_name)
@@ -1911,6 +1912,7 @@
SPL_ME(SplTempFileObject, __construct, 
arginfo_temp_file_object___construct,  ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
 };
+/* }}} */
 
 /* {{{ PHP_MINIT_FUNCTION(spl_directory)
  */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl spl_directory.c spl_directory.h

2005-11-27 Thread Marcus Boerger
helly   Sun Nov 27 08:07:19 2005 EDT

  Modified files:  
/php-src/ext/splspl_directory.c spl_directory.h 
  Log:
  - Fix minor issues in RecursiveDirectoryIterator  provide new flag consts
  
  
http://cvs.php.net/diff.php/php-src/ext/spl/spl_directory.c?r1=1.56r2=1.57ty=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.56 
php-src/ext/spl/spl_directory.c:1.57
--- php-src/ext/spl/spl_directory.c:1.56Sun Nov 27 07:13:42 2005
+++ php-src/ext/spl/spl_directory.c Sun Nov 27 08:07:18 2005
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.56 2005/11/27 12:13:42 helly Exp $ */
+/* $Id: spl_directory.c,v 1.57 2005/11/27 13:07:18 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -334,7 +334,7 @@
 
switch (type) {
case SPL_FS_INFO:
-   return_value-value.obj = spl_filesystem_object_new_ex(ce ? ce 
: intern-info_class, intern TSRMLS_CC);
+   return_value-value.obj = spl_filesystem_object_new_ex(ce ? ce 
: source-info_class, intern TSRMLS_CC);
Z_TYPE_P(return_value) = IS_OBJECT;

spl_filesystem_object_get_file_name(source TSRMLS_CC);
@@ -342,7 +342,7 @@
intern-file_name_len = source-file_name_len;
break;
case SPL_FS_FILE:
-   return_value-value.obj = spl_filesystem_object_new_ex(ce ? ce 
: intern-file_class, intern TSRMLS_CC);
+   return_value-value.obj = spl_filesystem_object_new_ex(ce ? ce 
: source-file_class, intern TSRMLS_CC);
Z_TYPE_P(return_value) = IS_OBJECT;

spl_filesystem_object_get_file_name(source TSRMLS_CC);
@@ -549,11 +549,15 @@
 {
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
-   if (intern-flags  SPL_FILE_DIR_CURRENT_AS_FILEINFO) {
+   if (intern-flags  SPL_FILE_DIR_CURRENT_AS_PATHNAME) {
+   spl_filesystem_object_get_file_name(intern TSRMLS_CC);
+   RETURN_STRINGL(intern-file_name, intern-file_name_len, 1);
+   } else if (intern-flags  SPL_FILE_DIR_CURRENT_AS_FILEINFO) {
spl_filesystem_object_get_file_name(intern TSRMLS_CC);
spl_filesystem_object_create_type(0, intern, SPL_FS_INFO, NULL, 
return_value TSRMLS_CC);
} else {
-   RETURN_STRING(intern-u.dir.entry.d_name, 1);
+   RETURN_ZVAL(getThis(), 1, 0);
+   /*RETURN_STRING(intern-u.dir.entry.d_name, 1);*/
}
 }
 /* }}} */
@@ -1031,7 +1035,14 @@
spl_filesystem_dir_it *iterator = (spl_filesystem_dir_it *)iter;
spl_filesystem_object *object   = iterator-object;
 
-   if (object-flags  SPL_FILE_DIR_CURRENT_AS_FILEINFO) {
+   if (object-flags  SPL_FILE_DIR_CURRENT_AS_PATHNAME) {
+   if (!iterator-current) {
+   ALLOC_INIT_ZVAL(iterator-current);
+   spl_filesystem_object_get_file_name(object TSRMLS_CC);
+   ZVAL_STRINGL(iterator-current, object-file_name, 
object-file_name_len, 1);
+   }
+   *data = iterator-current;
+   } else if (object-flags  SPL_FILE_DIR_CURRENT_AS_FILEINFO) {
if (!iterator-current) {
ALLOC_INIT_ZVAL(iterator-current);
spl_filesystem_object_get_file_name(object TSRMLS_CC);
@@ -1930,7 +1941,13 @@
 
REGISTER_SPL_SUB_CLASS_EX(RecursiveDirectoryIterator, 
DirectoryIterator, spl_filesystem_object_new, 
spl_RecursiveDirectoryIterator_functions);
REGISTER_SPL_IMPLEMENTS(RecursiveDirectoryIterator, RecursiveIterator);
+
+   REGISTER_SPL_CLASS_CONST_LONG(RecursiveDirectoryIterator, 
CURRENT_MODE_MASK,   SPL_FILE_DIR_CURRENT_MODE_MASK);
+   REGISTER_SPL_CLASS_CONST_LONG(RecursiveDirectoryIterator, 
CURRENT_AS_PATHNAME, SPL_FILE_DIR_CURRENT_AS_PATHNAME);
REGISTER_SPL_CLASS_CONST_LONG(RecursiveDirectoryIterator, 
CURRENT_AS_FILEINFO, SPL_FILE_DIR_CURRENT_AS_FILEINFO);
+   REGISTER_SPL_CLASS_CONST_LONG(RecursiveDirectoryIterator, 
CURRENT_AS_SELF, 0);
+   REGISTER_SPL_CLASS_CONST_LONG(RecursiveDirectoryIterator, 
KEY_MODE_MASK,   SPL_FILE_DIR_KEY_MODE_MASK);
+   REGISTER_SPL_CLASS_CONST_LONG(RecursiveDirectoryIterator, 
KEY_AS_PATHNAME, 0);
REGISTER_SPL_CLASS_CONST_LONG(RecursiveDirectoryIterator, 
KEY_AS_FILENAME, SPL_FILE_DIR_KEY_AS_FILENAME);
REGISTER_SPL_CLASS_CONST_LONG(RecursiveDirectoryIterator, 
NEW_CURRENT_AND_KEY, 
SPL_FILE_DIR_KEY_AS_FILENAME|SPL_FILE_DIR_CURRENT_AS_FILEINFO);
 
http://cvs.php.net/diff.php/php-src/ext/spl/spl_directory.h?r1=1.17r2=1.18ty=u
Index: php-src/ext/spl/spl_directory.h
diff -u php-src/ext/spl/spl_directory.h:1.17 
php-src/ext/spl/spl_directory.h:1.18
--- php-src/ext/spl/spl_directory.h:1.17Tue Nov  1 11:54:44 

  1   2   >