From 7fd3079bb634a553e4d27e7e6d72e97a8ccfb1a0 Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Tue, 4 Oct 2016 10:35:58 -0700 Subject: [PATCH] remove one of the wrealpath() definitions It is believed there are no longer any platforms we support that do not support passing NULL as the second argument to realpath(). So rather than duplicating the logic to get reasonable behavior from our wrealpath() wrapper simply remove the redundant implementation. --- configure.ac | 39 --------------------------------------- src/wutil.cpp | 24 ------------------------ 2 files changed, 63 deletions(-) diff --git a/configure.ac b/configure.ac index e67595c5d..2df950807 100644 --- a/configure.ac +++ b/configure.ac @@ -320,45 +320,6 @@ fi # features that Autoconf doesn't tell us about # - -# -# Check if realpath accepts null for its second argument -# - -AC_MSG_CHECKING([if realpath accepts null for its second argument]) -AC_RUN_IFELSE( - [ - AC_LANG_PROGRAM( - [ - #include - #include - #include - ], - [ - int status; - char *res; - res = realpath( "somefile", 0 ); - status = !(res != 0 || errno == ENOENT); - exit( status ); - ] - ) - ], - [have_realpath_null=yes], - [have_realpath_null=no] -) - -if test "$have_realpath_null" = yes; then - AC_MSG_RESULT(yes) - AC_DEFINE( - [HAVE_REALPATH_NULL], - [1], - [Define to 1 if realpath accepts null for its second argument.] - ) -else - AC_MSG_RESULT(no) -fi - - # # Check if struct winsize and TIOCGWINSZ exist # diff --git a/src/wutil.cpp b/src/wutil.cpp index 27bd0c508..24069b398 100644 --- a/src/wutil.cpp +++ b/src/wutil.cpp @@ -332,8 +332,6 @@ void safe_perror(const char *message) { errno = err; } -#ifdef HAVE_REALPATH_NULL - wchar_t *wrealpath(const wcstring &pathname, wchar_t *resolved_path) { if (pathname.size() == 0) return NULL; @@ -389,28 +387,6 @@ wchar_t *wrealpath(const wcstring &pathname, wchar_t *resolved_path) { return wcsdup(wreal_path.c_str()); } -#else - -wchar_t *wrealpath(const wcstring &pathname, wchar_t *resolved_path) { - cstring tmp = wcs2string(pathname); - char narrow_buff[PATH_MAX]; - char *narrow_res = realpath(tmp.c_str(), narrow_buff); - wchar_t *res; - - if (!narrow_res) return 0; - - const wcstring wide_res = str2wcstring(narrow_res); - if (resolved_path) { - wcslcpy(resolved_path, wide_res.c_str(), PATH_MAX); - res = resolved_path; - } else { - res = wcsdup(wide_res.c_str()); - } - return res; -} - -#endif - wcstring wdirname(const wcstring &path) { char *tmp = wcs2str(path.c_str()); char *narrow_res = dirname(tmp);