Add case-ignoring string matcher.

This commit is contained in:
Bartosz Taudul 2018-12-18 16:52:05 +01:00
parent 24235406a0
commit acddcbd9bf

View File

@ -4,6 +4,13 @@
# include <sys/time.h>
#endif
#if defined _MSC_VER || defined __MINGW32__
# include <malloc.h>
#else
# include <alloca.h>
#endif
#include <cctype>
#include <chrono>
#include <mutex>
#include <string.h>
@ -1215,6 +1222,25 @@ const char* Worker::GetZoneName( const GpuEvent& ev, const SourceLocation& srclo
}
}
static bool strstr_nocase( const char* l, const char* r )
{
const auto lsz = strlen( l );
const auto rsz = strlen( r );
auto ll = (char*)alloca( lsz + 1 );
auto rl = (char*)alloca( lsz + 1 );
for( size_t i=0; i<lsz; i++ )
{
ll[i] = tolower( l[i] );
}
ll[lsz] = '\0';
for( size_t i=0; i<rsz; i++ )
{
rl[i] = tolower( r[i] );
}
rl[rsz] = '\0';
return strstr( ll, rl ) != nullptr;
}
std::vector<int32_t> Worker::GetMatchingSourceLocation( const char* query ) const
{
std::vector<int32_t> match;