From 97cb81ead5b47d9528c48936ed529cd7e8c8f3ef Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 23 Mar 2020 10:18:00 +0100 Subject: [PATCH] Remove HAVE_REALPATH checks We do not actually use realpath(), but a custom implementation. Make sure the realpath() function is always available. Closes GH-5290. --- Zend/zend_virtual_cwd.c | 4 ---- configure.ac | 1 - ext/opcache/Optimizer/zend_func_info.c | 2 -- ext/spl/spl_directory.c | 4 ---- ext/standard/basic_functions.c | 2 -- ext/standard/basic_functions.stub.php | 2 -- ext/standard/basic_functions_arginfo.h | 2 -- ext/standard/file.c | 2 -- ext/standard/file.h | 2 -- win32/ioutil.h | 1 - 10 files changed, 22 deletions(-) diff --git a/Zend/zend_virtual_cwd.c b/Zend/zend_virtual_cwd.c index 2e012237b37..f0cbd971a86 100644 --- a/Zend/zend_virtual_cwd.c +++ b/Zend/zend_virtual_cwd.c @@ -65,10 +65,6 @@ # include #endif -#ifndef HAVE_REALPATH -#define realpath(x,y) strcpy(y,x) -#endif - #define VIRTUAL_CWD_DEBUG 0 #include "TSRM.h" diff --git a/configure.ac b/configure.ac index d1d483447f7..7e36718342d 100644 --- a/configure.ac +++ b/configure.ac @@ -582,7 +582,6 @@ nl_langinfo \ poll \ ptsname \ putenv \ -realpath \ rand_r \ scandir \ setitimer \ diff --git a/ext/opcache/Optimizer/zend_func_info.c b/ext/opcache/Optimizer/zend_func_info.c index 4fe614be396..7cde2dd34f1 100644 --- a/ext/opcache/Optimizer/zend_func_info.c +++ b/ext/opcache/Optimizer/zend_func_info.c @@ -321,9 +321,7 @@ static const func_info_t func_infos[] = { F1("stream_resolve_include_path", MAY_BE_FALSE | MAY_BE_STRING), F1("get_headers", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY), F1("socket_get_status", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY), -#if HAVE_REALPATH || defined(ZTS) F1("realpath", MAY_BE_FALSE | MAY_BE_STRING), -#endif F1("fsockopen", MAY_BE_FALSE | MAY_BE_RESOURCE), FN("pfsockopen", MAY_BE_FALSE | MAY_BE_RESOURCE), F1("pack", MAY_BE_FALSE | MAY_BE_STRING), diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 05672a14bf0..ef7584ac583 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -1284,7 +1284,6 @@ SPL_METHOD(SplFileInfo, getLinkTarget) } /* }}} */ -#if HAVE_REALPATH || defined(ZTS) /* {{{ proto string SplFileInfo::getRealPath() Return the resolved path */ SPL_METHOD(SplFileInfo, getRealPath) @@ -1325,7 +1324,6 @@ SPL_METHOD(SplFileInfo, getRealPath) zend_restore_error_handling(&error_handling); } /* }}} */ -#endif /* {{{ proto SplFileObject SplFileInfo::openFile([string mode = 'r' [, bool use_include_path [, resource context]]]) Open the current file */ @@ -1900,9 +1898,7 @@ static const zend_function_entry spl_SplFileInfo_functions[] = { SPL_ME(SplFileInfo, isDir, arginfo_class_SplFileInfo_isDir, ZEND_ACC_PUBLIC) SPL_ME(SplFileInfo, isLink, arginfo_class_SplFileInfo_isLink, ZEND_ACC_PUBLIC) SPL_ME(SplFileInfo, getLinkTarget, arginfo_class_SplFileInfo_getLinkTarget, ZEND_ACC_PUBLIC) -#if HAVE_REALPATH || defined(ZTS) SPL_ME(SplFileInfo, getRealPath, arginfo_class_SplFileInfo_getRealPath, ZEND_ACC_PUBLIC) -#endif SPL_ME(SplFileInfo, getFileInfo, arginfo_class_SplFileInfo_getFileInfo, ZEND_ACC_PUBLIC) SPL_ME(SplFileInfo, getPathInfo, arginfo_class_SplFileInfo_getPathInfo, ZEND_ACC_PUBLIC) SPL_ME(SplFileInfo, openFile, arginfo_class_SplFileInfo_openFile, ZEND_ACC_PUBLIC) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 88a7af1c241..d47b9dc740b 100755 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -597,9 +597,7 @@ static const zend_function_entry basic_functions[] = { /* {{{ */ PHP_FALIAS(socket_get_status, stream_get_meta_data, arginfo_socket_get_status) -#if HAVE_REALPATH || defined(ZTS) PHP_FE(realpath, arginfo_realpath) -#endif #ifdef HAVE_FNMATCH PHP_FE(fnmatch, arginfo_fnmatch) diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index c153b752e62..1186d28f0f1 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -877,9 +877,7 @@ function fputcsv($handle, array $fields, string $delimiter = ",", string $enclos /** @param resource $handle */ function fgetcsv($handle, $length = UNKNOWN, string $delimiter = ",", string $enclosure = '"', string $escape = "\\"): array|false {} -#if HAVE_REALPATH || defined(ZTS) function realpath(string $path): string|false {} -#endif #ifdef HAVE_FNMATCH function fnmatch(string $pattern, string $filename, int $flags = 0): bool {} diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index fa5e762c2e6..d6fd7acf025 100755 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -1358,11 +1358,9 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_fgetcsv, 0, 1, MAY_BE_ARRAY|MAY_ ZEND_ARG_TYPE_INFO(0, escape, IS_STRING, 0) ZEND_END_ARG_INFO() -#if HAVE_REALPATH || defined(ZTS) ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_realpath, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0) ZEND_END_ARG_INFO() -#endif #if defined(HAVE_FNMATCH) ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_fnmatch, 0, 2, _IS_BOOL, 0) diff --git a/ext/standard/file.c b/ext/standard/file.c index bf18f0ca30e..6c97a00f57f 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -2293,7 +2293,6 @@ out: } /* }}} */ -#if HAVE_REALPATH || defined(ZTS) /* {{{ proto string|false realpath(string path) Return the resolved path */ PHP_FUNCTION(realpath) @@ -2322,7 +2321,6 @@ PHP_FUNCTION(realpath) } } /* }}} */ -#endif /* See http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2 */ #define PHP_META_HTML401_CHARS "-_.:" diff --git a/ext/standard/file.h b/ext/standard/file.h index bcca86f9a3f..dbbaae0f39e 100644 --- a/ext/standard/file.h +++ b/ext/standard/file.h @@ -55,9 +55,7 @@ PHP_FUNCTION(get_meta_tags); PHP_FUNCTION(flock); PHP_FUNCTION(fd_set); PHP_FUNCTION(fd_isset); -#if HAVE_REALPATH || defined(ZTS) PHP_FUNCTION(realpath); -#endif #ifdef HAVE_FNMATCH PHP_FUNCTION(fnmatch); #endif diff --git a/win32/ioutil.h b/win32/ioutil.h index 1c2f1a213e3..8a522fe2f38 100644 --- a/win32/ioutil.h +++ b/win32/ioutil.h @@ -630,7 +630,6 @@ __forceinline static int php_win32_ioutil_link(const char *target, const char *l return ret; }/*}}}*/ -#define HAVE_REALPATH 1 PW32IO char *realpath(const char *path, char *resolved); __forceinline static char *php_win32_ioutil_realpath_ex0(const char *path, char *resolved, PBY_HANDLE_FILE_INFORMATION info)