File tree Expand file tree Collapse file tree 1 file changed +22
-8
lines changed
Expand file tree Collapse file tree 1 file changed +22
-8
lines changed Original file line number Diff line number Diff line change 11#include " Util/StringUtil.h"
22#include < cstdlib>
33#include < cstring>
4-
4+ # include < algorithm >
55#include " wildcards/match.hpp"
66
77std::vector<std::string_view> StringUtil::Split (std::string_view source, std::string_view separator)
@@ -162,16 +162,30 @@ struct equal_to
162162{
163163 constexpr auto operator ()(const char & lhs, const char & rhs) const -> decltype(lhs == rhs)
164164 {
165- if (lhs == rhs)
166- {
167- return true ;
168- }
169- return (lhs == ' \\ ' || lhs == ' /' ) && (rhs == ' \\ ' || rhs == ' /' );
165+ return lhs == rhs
166+ || ((lhs == ' \\ ' || lhs == ' /' ) && (rhs == ' \\ ' || rhs == ' /' ))
167+ || (::tolower (lhs) == ::tolower (rhs));
170168 }
171169};
172170
173171bool StringUtil::FileWildcardMatch (std::string_view sourceFile, std::string_view pattern)
174172{
175- return wildcards::match (sourceFile, pattern, equal_to ()).res ;
176- }
173+ equal_to eq;
177174
175+ auto minSize = std::min (sourceFile.size (), pattern.size ());
176+ bool match = true ;
177+ for (std::size_t i = 0 ; i != minSize; i++)
178+ {
179+ if (!eq (sourceFile[i], pattern[i]))
180+ {
181+ match = false ;
182+ break ;
183+ }
184+ }
185+
186+ if (!match)
187+ {
188+ match = wildcards::match (sourceFile, pattern, equal_to ()).res ;
189+ }
190+ return match;
191+ }
You can’t perform that action at this time.
0 commit comments