diff --git a/src/builtin_string.cpp b/src/builtin_string.cpp index ef544c7da..3b4b17b6a 100644 --- a/src/builtin_string.cpp +++ b/src/builtin_string.cpp @@ -633,7 +633,7 @@ class wildcard_matcher_t : public string_matcher_t { io_streams_t &streams) : string_matcher_t(opts, streams), wcpattern(parse_util_unescape_wildcards(pattern)) { if (opts.ignore_case) { - wcpattern = std::tolower(std::move(wcpattern)); + wcpattern = wcstolower(std::move(wcpattern)); } if (opts.entire) { if (!wcpattern.empty()) { @@ -654,7 +654,7 @@ class wildcard_matcher_t : public string_matcher_t { bool match; if (opts.ignore_case) { - match = wildcard_match(std::tolower(arg), wcpattern, false); + match = wildcard_match(wcstolower(arg), wcpattern, false); } else { match = wildcard_match(arg, wcpattern, false); } diff --git a/src/expand.h b/src/expand.h index 40d4832c1..371724307 100644 --- a/src/expand.h +++ b/src/expand.h @@ -79,9 +79,9 @@ enum : wchar_t { VARIABLE_EXPAND, /// Character representing variable expansion into a single element. VARIABLE_EXPAND_SINGLE, - /// Character representing the start of a brace expansion. + /// Character representing the start of a bracket expansion. BRACE_BEGIN, - /// Character representing the end of a brace expansion. + /// Character representing the end of a bracket expansion. BRACE_END, /// Character representing separation between two bracket elements. BRACE_SEP, diff --git a/src/history.cpp b/src/history.cpp index 182e0b3b3..ea2bb5c1c 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -181,7 +180,7 @@ bool history_item_t::matches_search(const wcstring &term, enum history_search_ty // search object if we're doing a case insensitive search. wcstring contents_lower; if (!case_sensitive) { - contents_lower = std::tolower(contents); + contents_lower = wcstolower(contents); } const wcstring &content_to_match = case_sensitive ? contents : contents_lower; diff --git a/src/wcstringutil.cpp b/src/wcstringutil.cpp index ea5f8b9a9..3691f79e5 100644 --- a/src/wcstringutil.cpp +++ b/src/wcstringutil.cpp @@ -4,6 +4,8 @@ #include "common.h" #include "wcstringutil.h" +#include + typedef wcstring::size_type size_type; wcstring_range wcstring_tok(wcstring &str, const wcstring &needle, wcstring_range last) { @@ -62,3 +64,9 @@ wcstring trim(wcstring input, const wchar_t *any_of) { result.erase(0, prefix); return result; } + +wcstring wcstolower(wcstring input) { + wcstring result = std::move(input); + std::transform(result.begin(), result.end(), result.begin(), towlower); + return result; +} diff --git a/src/wcstringutil.h b/src/wcstringutil.h index ee884b857..54ce9ba2a 100644 --- a/src/wcstringutil.h +++ b/src/wcstringutil.h @@ -68,4 +68,7 @@ wcstring truncate(const wcstring &input, int max_len, wcstring trim(wcstring input); wcstring trim(wcstring input, const wchar_t *any_of); +/// Converts a string to lowercase. +wcstring wcstolower(wcstring input); + #endif