]> granicus.if.org Git - php/commitdiff
Fixed bug #16861.
authorYasuo Ohgaki <yohgaki@php.net>
Fri, 26 Apr 2002 23:46:51 +0000 (23:46 +0000)
committerYasuo Ohgaki <yohgaki@php.net>
Fri, 26 Apr 2002 23:46:51 +0000 (23:46 +0000)
touch sets wrong atime or mtime when they are not specified.
touch silently failed when HAVE_UTIME is not defined.
(This needs more consideration. Which platform does not support it?)
# Derick, after HAVE_UTIME issue is resovled, this should be merged.
# or we can just merge 1st problem for now.

ext/standard/basic_functions.c
ext/standard/filestat.c
ext/standard/php_filestat.h

index 6a2ab33467f830ee89fe28b671750dcd715d7034..85be8bcf6ef97ee834e318c41f6ebeac29e99e5e 100644 (file)
@@ -680,7 +680,9 @@ function_entry basic_functions[] = {
        PHP_FE(chown,                                                                                                                   NULL)
        PHP_FE(chgrp,                                                                                                                   NULL)
        PHP_FE(chmod,                                                                                                                   NULL)
+#if HAVE_UTIME
        PHP_FE(touch,                                                                                                                   NULL)
+#endif 
        PHP_FE(clearstatcache,                                                                                                  NULL)
        PHP_FE(disk_total_space,                                                                                                NULL)
        PHP_FE(disk_free_space,                                                                                                 NULL)
index c74355dd804bda9842c9d8116eae2eeeda5367c1..d3d7abf658d2ef4477ede6c7a56810a6d451cf84 100644 (file)
@@ -465,17 +465,17 @@ PHP_FUNCTION(chmod)
 }
 /* }}} */
 
+#if HAVE_UTIME
 /* {{{ proto bool touch(string filename [, int time [, int atime]])
    Set modification time of file */
 PHP_FUNCTION(touch)
 {
-#if HAVE_UTIME
        pval **filename, **filetime, **fileatime;
        int ret;
        struct stat sb;
        FILE *file;
        struct utimbuf newtimebuf;
-       struct utimbuf *newtime = &newtimebuf;
+       struct utimbuf *newtime = NULL;
        int ac = ZEND_NUM_ARGS();
 
        if (ac == 1 && zend_get_parameters_ex(1, &filename) != FAILURE) {
@@ -483,9 +483,12 @@ PHP_FUNCTION(touch)
                newtime->modtime = newtime->actime = time(NULL);
 #endif
        } else if (ac == 2 && zend_get_parameters_ex(2, &filename, &filetime) != FAILURE) {
+               newtime = &newtimebuf;
                convert_to_long_ex(filetime);
+               newtime->actime = time(NULL);
                newtime->modtime = newtime->actime = Z_LVAL_PP(filetime);
        } else if (ac == 3 && zend_get_parameters_ex(3, &filename, &filetime, &fileatime) != FAILURE) {
+               newtime = &newtimebuf;
                convert_to_long_ex(fileatime);
                convert_to_long_ex(filetime);
                newtime->actime = Z_LVAL_PP(fileatime);
@@ -519,12 +522,11 @@ PHP_FUNCTION(touch)
        if (ret == -1) {
                php_error(E_WARNING, "utime failed: %s", strerror(errno));
                RETURN_FALSE;
-       } else {
-               RETURN_TRUE;
        }
-#endif
+       RETURN_TRUE;
 }
 /* }}} */
+#endif
 
 /* {{{ proto void clearstatcache(void)
    Clear file stat cache */
index 095e4f92922a9d211aec6ad6c86a6e6577646f49..62cd4f57b94fc118c586c3188febbc5b37b399a6 100644 (file)
@@ -48,7 +48,9 @@ PHP_FUNCTION(disk_free_space);
 PHP_FUNCTION(chown);
 PHP_FUNCTION(chgrp);
 PHP_FUNCTION(chmod);
+#if HAVE_UTIME
 PHP_FUNCTION(touch);
+#endif
 PHP_FUNCTION(clearstatcache);
 
 #define MAKE_LONG_ZVAL_INCREF(name, val)\