From ef1835f54fe0f6a4f76a9f3f4592faa34c0172ba Mon Sep 17 00:00:00 2001 From: Andi Gutmans Date: Wed, 25 Apr 2001 06:30:24 +0000 Subject: [PATCH] - Fix filetype() and lstat() too. --- ext/standard/filestat.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index 33d688a614..1ea165677d 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -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 -- 2.50.1