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

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -320,23 +320,6 @@ bool ue2_literal::any_nocase() const {
return find(nocase.begin(), nocase.end(), true) != nocase.end();
}
bool mixed_sensitivity(const ue2_literal &s) {
bool cs = false;
bool nc = false;
for (ue2_literal::const_iterator it = s.begin(); it != s.end(); ++it) {
if (!ourisalpha(it->c)) {
continue;
}
if (it->nocase) {
nc = true;
} else {
cs = true;
}
}
return cs && nc;
}
void make_nocase(ue2_literal *lit) {
ue2_literal rv;

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);