rose_build_matchers: be more careful w/ mixed-case

Overhaul the way fragment literals are added to HWLM and accel, fix
some bugs shaken out by stricter mask use.
This commit is contained in:
Justin Viiret
2017-06-22 10:37:31 +10:00
committed by Matthew Barr
parent 3bd0c7f6ad
commit c83f2ea389
3 changed files with 155 additions and 95 deletions

View File

@@ -35,6 +35,7 @@
#include "ue2common.h"
#include "util/charreach.h"
#include "util/compare.h"
#include "util/hash.h"
#include <iterator>
@@ -226,9 +227,36 @@ size_t maxStringSelfOverlap(const ue2_literal &a);
size_t minStringPeriod(const ue2_literal &a);
size_t maxStringOverlap(const ue2_literal &a, const ue2_literal &b);
/** \brief True iff the literal cannot be considered entirely case-sensitive
* nor entirely case-insensitive */
bool mixed_sensitivity(const ue2_literal &lit);
/**
* \brief True iff the range of a literal given cannot be considered entirely
* case-sensitive nor entirely case-insensitive.
*/
template<class Iter>
bool mixed_sensitivity_in(Iter begin, Iter end) {
bool cs = false;
bool nc = false;
for (auto it = begin; it != end; ++it) {
if (!ourisalpha(it->c)) {
continue;
}
if (it->nocase) {
nc = true;
} else {
cs = true;
}
}
return cs && nc;
}
/**
* \brief True iff the literal cannot be considered entirely case-sensitive
* nor entirely case-insensitive.
*/
inline
bool mixed_sensitivity(const ue2_literal &s) {
return mixed_sensitivity_in(s.begin(), s.end());
}
void make_nocase(ue2_literal *lit);