bjori           Sun Nov 12 17:08:45 2006 UTC

  Modified files:              
    /php-src/ext/spl    spl_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.103&r2=1.104&diff_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.3&r2=1.4&diff_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

Reply via email to