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

2008-07-09 Thread Dmitry Stogov
Hi Etienne,

After this patch I see 4 broken tests in ext/phar.
I'm not sure if the new behavior is expected, could you please take a look.

Thanks. Dmitry.

Etienne Kneuss wrote:
 colderTue Jul  8 22:40:49 2008 UTC
 
   Modified files:  (Branch: PHP_5_3)
 /php-src/ext/spl  spl_directory.c 
 /php-src/ext/spl/testsdit_001.phpt fileobject_003.phpt 
   fileobject_getfileinfo_basic.phpt 
   Log:
   MFH: - Fix filename in debug_info
   - Fix #45345 (getPathInfo on the file instead of the dir)
   - Remove trailing / on input
   
 

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



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

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

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/splspl_directory.c 
/php-src/ext/spl/tests  dit_001.phpt fileobject_003.phpt 
fileobject_getfileinfo_basic.phpt 
  Log:
  MFH: - 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.45.2.27.2.23.2.23r2=1.45.2.27.2.23.2.24diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.45.2.27.2.23.2.23 
php-src/ext/spl/spl_directory.c:1.45.2.27.2.23.2.24
--- php-src/ext/spl/spl_directory.c:1.45.2.27.2.23.2.23 Wed Jul  2 10:47:11 2008
+++ php-src/ext/spl/spl_directory.c Tue Jul  8 22:40:48 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.45.2.27.2.23.2.23 2008/07/02 10:47:11 tony2001 Exp 
$ */
+/* $Id: spl_directory.c,v 1.45.2.27.2.23.2.24 2008/07/08 22:40:48 colder Exp $ 
*/
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -347,17 +347,23 @@
intern-file_name = use_copy ? estrndup(path, len) : path;
intern-file_name_len = len;
 
-   p1 = strrchr(path, '/');
+   while(IS_SLASH_AT(intern-file_name, intern-file_name_len-1)) {
+   intern-file_name[intern-file_name_len-1] = 0;
+   intern-file_name_len--;
+   }
+
+   p1 = strrchr(intern-file_name, '/');
 #if defined(PHP_WIN32) || defined(NETWARE)
-   p2 = strrchr(path, '\\');
+   p2 = strrchr(intern-file_name, '\\');
 #else
p2 = 0;
 #endif
if (p1 || p2) {
-   intern-_path_len = (p1  p2 ? p1 : p2) - path;
+   intern-_path_len = (p1  p2 ? p1 : p2) - intern-file_name;
} else {
intern-_path_len = 0;
}
+
intern-_path = estrndup(path, intern-_path_len);
 } /* }}} */
 
@@ -499,7 +505,25 @@
 }
 /* }}} */
 
-static HashTable* spl_filesystem_object_get_debug_info(zval *obj, int *is_temp 
TSRMLS_DC) /*  */
+static char *spl_filesystem_object_get_pathname(spl_filesystem_object *intern, 
int *len TSRMLS_DC) { /* {{{ */
+   switch (intern-type) {
+   case SPL_FS_INFO:
+   case SPL_FS_FILE:
+   *len = intern-file_name_len;
+   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;
+   return intern-file_name;
+   }
+   }
+   *len = 0;
+   return NULL;
+}
+/* }}} */
+
+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);
HashTable *rv;
@@ -518,13 +542,20 @@
 
zend_hash_copy(rv, intern-std.properties, (copy_ctor_func_t) 
zval_add_ref, (void *) tmp, sizeof(zval *));
 
-   path = spl_filesystem_object_get_path(intern, path_len TSRMLS_CC);
pnstr = spl_gen_private_prop_name(spl_ce_SplFileInfo, pathName, 
sizeof(pathName)-1, pnlen TSRMLS_CC);
+   path = spl_filesystem_object_get_pathname(intern, path_len TSRMLS_CC);
add_assoc_stringl_ex(zrv, pnstr, pnlen+1, path, path_len, 1);
efree(pnstr);
+
if (intern-file_name) {
pnstr = spl_gen_private_prop_name(spl_ce_SplFileInfo, 
fileName, sizeof(fileName)-1, pnlen TSRMLS_CC);
-   add_assoc_stringl_ex(zrv, pnstr, pnlen+1, intern-file_name, 
intern-file_name_len, 1);
+   spl_filesystem_object_get_path(intern, path_len TSRMLS_CC);
+   
+   if (path_len  path_len  intern-file_name_len) {
+   add_assoc_stringl_ex(zrv, pnstr, pnlen+1, 
intern-file_name + path_len + 1, intern-file_name_len - (path_len + 1), 1);
+   } else {
+   add_assoc_stringl_ex(zrv, pnstr, pnlen+1, 
intern-file_name, intern-file_name_len, 1);
+   }
efree(pnstr);
}
if (intern-type == SPL_FS_DIR) {
@@ -560,7 +591,7 @@
 
return rv;
 }
-/*  */
+/* }}} */
 
 #define DIT_CTOR_FLAGS  0x0001
 #define DIT_CTOR_GLOB   0x0002
@@ -775,18 +806,14 @@
 SPL_METHOD(SplFileInfo, getPathname)
 {
spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
-
-   switch (intern-type) {
-   case SPL_FS_INFO:
-   case SPL_FS_FILE:
-   RETURN_STRINGL(intern-file_name, intern-file_name_len, 1);
-   case SPL_FS_DIR:
-   if (intern-u.dir.entry.d_name[0]) {
-   spl_filesystem_object_get_file_name(intern TSRMLS_CC);
-   RETURN_STRINGL(intern-file_name, 
intern-file_name_len, 1);
-