From a1d719e3bbfe8cd39c05d2a8f49143b9e814f876 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Thu, 7 Dec 2023 16:18:50 +0800 Subject: fixing issue #157. --- src/3rdParty/efsw/FileInfo.cpp | 14 ++++++++------ src/3rdParty/linenoise.hpp | 13 ++++++++++++- 2 files changed, 20 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/3rdParty/efsw/FileInfo.cpp b/src/3rdParty/efsw/FileInfo.cpp index 707f617..072cd6d 100755 --- a/src/3rdParty/efsw/FileInfo.cpp +++ b/src/3rdParty/efsw/FileInfo.cpp @@ -35,6 +35,10 @@ #endif #endif +#if EFSW_PLATFORM != EFSW_PLATFORM_WIN32 +#include +#endif + namespace efsw { bool FileInfo::exists( const std::string& filePath ) { @@ -182,14 +186,12 @@ bool FileInfo::isLink() const { std::string FileInfo::linksTo() { #if EFSW_PLATFORM != EFSW_PLATFORM_WIN32 if ( isLink() ) { - char* ch = realpath( Filepath.c_str(), NULL ); - - if ( NULL != ch ) { - std::string tstr( ch ); + std::error_code ec; + auto ch = std::filesystem::canonical( Filepath, ec ); - free( ch ); + if ( !ec ) { - return tstr; + return ch.string(); } } #endif diff --git a/src/3rdParty/linenoise.hpp b/src/3rdParty/linenoise.hpp index 604f889..b5b0efa 100644 --- a/src/3rdParty/linenoise.hpp +++ b/src/3rdParty/linenoise.hpp @@ -1578,6 +1578,17 @@ inline void SetMultiLine(bool ml) { mlmode = ml; } +inline int Strcasecmp(const char *a, const char *b) { + int ca, cb; + do { + ca = (unsigned char) *a; a++; + cb = (unsigned char) *b; b++; + ca = tolower(toupper(ca)); + cb = tolower(toupper(cb)); + } while (ca == cb && ca != '\0'); + return ca - cb; +} + /* Return true if the terminal name is in the list of terminals we know are * not able to understand basic escape sequences. */ inline bool isUnsupportedTerm(void) { @@ -1587,7 +1598,7 @@ inline bool isUnsupportedTerm(void) { if (term == NULL) return false; for (j = 0; unsupported_term[j]; j++) - if (!strcasecmp(term,unsupported_term[j])) return true; + if (!Strcasecmp(term,unsupported_term[j])) return true; #endif return false; } -- cgit v1.2.3-55-g6feb