Clearer non inverted logic for primitive case insensitive compare, updated readme.

This commit is contained in:
Steffen Schuemann 2019-05-07 22:02:38 +02:00
parent 87ae60ed83
commit 275a1b714c
2 changed files with 9 additions and 8 deletions

View File

@ -403,7 +403,8 @@ and part of the justification for the proposed solution is "we did it so for alm
But this makes `fs::copy` with `fs::copy_options::create_symlinks` or `fs::copy_options::create_hard_links`
just a more complicated syntax for the `fs::create_symlink` or `fs::create_hardlink` operation
and I don't want to believe, that this was the intention of the original writing.
As there is another issue related to copy, with a different take on the description,
As there is another issue related to copy, with a different take on the description.
*Note:* With v1.1.2 I decided to integrate a behavior switch for this and make the LWG #2682
the default.

View File

@ -1379,20 +1379,20 @@ inline path::path(InputIterator first, InputIterator last, format fmt)
namespace detail {
GHC_INLINE bool compare_no_case(const char* str1, const char* str2)
GHC_INLINE bool equals_simple_insensitive(const char* str1, const char* str2)
{
#ifdef GHC_OS_WINDOWS
# ifdef __GNUC__
while (::tolower((unsigned char)*str1) == ::tolower((unsigned char)*str2++)) {
if (*str1++ == 0)
return false;
return true;
}
return true;
return false;
# else
return ::_stricmp(str1, str2);
return 0 == ::_stricmp(str1, str2);
# endif
#else
return ::strcasecmp(str1, str2);
return 0 == ::strcasecmp(str1, str2);
#endif
}
@ -1650,7 +1650,7 @@ GHC_INLINE file_status status_from_INFO(const path& p, const INFO* info, std::er
prms = prms | perms::owner_write | perms::group_write | perms::others_write;
}
std::string ext = p.extension().generic_string();
if (!compare_no_case(ext.c_str(), ".exe") || !compare_no_case(ext.c_str(), ".cmd") || !compare_no_case(ext.c_str(), ".bat") || !compare_no_case(ext.c_str(), ".com")) {
if (equals_simple_insensitive(ext.c_str(), ".exe") || equals_simple_insensitive(ext.c_str(), ".cmd") || equals_simple_insensitive(ext.c_str(), ".bat") || equals_simple_insensitive(ext.c_str(), ".com")) {
prms = prms | perms::owner_exec | perms::group_exec | perms::others_exec;
}
if (sz) {
@ -1810,7 +1810,7 @@ GHC_INLINE u8arguments::u8arguments(int& argc, char**& argv)
#if defined(__ANDROID__) && __ANDROID_API__ < 26
_isvalid = true;
#else
if (!detail::compare_no_case(::nl_langinfo(CODESET), "UTF-8")) {
if (detail::equals_simple_insensitive(::nl_langinfo(CODESET), "UTF-8")) {
_isvalid = true;
}
#endif