]> granicus.if.org Git - php/commitdiff
- Fix filetype() and lstat() too.
authorAndi Gutmans <andi@php.net>
Wed, 25 Apr 2001 06:30:24 +0000 (06:30 +0000)
committerAndi Gutmans <andi@php.net>
Wed, 25 Apr 2001 06:30:24 +0000 (06:30 +0000)
ext/standard/filestat.c

index 33d688a61456ab8cd2073269a564dd8cb2cde751..1ea165677db91afa42830c7746f92a5da10120e4 100644 (file)
@@ -446,6 +446,7 @@ PHP_FUNCTION(clearstatcache)
 }
 /* }}} */
 
+#define IS_LINK_OPERATION() (type == 8 /* filetype */ || type == 14 /* is_link */ || type == 16 /* lstat */)
 
 static void php_stat(const char *filename, php_stat_len filename_length, int type, pval *return_value)
 {
@@ -469,29 +470,23 @@ static void php_stat(const char *filename, php_stat_len filename_length, int typ
                BG(lsb).st_mode = 0; /* mark lstat buf invalid */
 #endif
                if (V_STAT(BG(CurrentStatFile), &BG(sb)) == -1) {
-                       if ((type != 14) && (type != 15 || errno != ENOENT)) { /* fileexists() test must print no error */
+                       if (!IS_LINK_OPERATION() && (type != 15 || errno != ENOENT)) { /* fileexists() test must print no error */
                                php_error(E_NOTICE,"stat failed for %s (errno=%d - %s)", BG(CurrentStatFile), errno, strerror(errno));
                        }
                        efree(BG(CurrentStatFile));
                        BG(CurrentStatFile) = NULL;
-                       if (type != 14) { /* Don't require success for is link */
+                       if (!IS_LINK_OPERATION()) { /* Don't require success for link operation */
                                RETURN_FALSE;
                        }
                }
        }
 
 #if HAVE_SYMLINK
-       if (8 == type /* filetype */
-               || 14 == type /* is link */
-               || 16 == type) { /* lstat */
-
+       if (IS_LINK_OPERATION() && !BG(lsb).st_mode) {
                /* do lstat if the buffer is empty */
-
-               if (!BG(lsb).st_mode) {
-                       if (V_LSTAT(filename, &BG(lsb)) == -1) {
-                               php_error(E_NOTICE, "lstat failed for %s (errno=%d - %s)", filename, errno, strerror(errno));
-                               RETURN_FALSE;
-                       }
+               if (V_LSTAT(filename, &BG(lsb)) == -1) {
+                       php_error(E_NOTICE, "lstat failed for %s (errno=%d - %s)", filename, errno, strerror(errno));
+                       RETURN_FALSE;
                }
        }
 #endif