]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
rose_build_matchers: fix fragment noruns calc
authorJustin Viiret <justin.viiret@intel.com>
Fri, 23 Jun 2017 01:30:24 +0000 (11:30 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Mon, 21 Aug 2017 01:10:08 +0000 (11:10 +1000)
src/rose/rose_build_matchers.cpp

index 836ac9658fac4225b4ce3a83b0f35703c52b596b..57269747a132553bcda89686ee0b4d85c0abdfae 100644 (file)
@@ -556,6 +556,17 @@ bool isNoRunsLiteral(const RoseBuildImpl &build, const u32 id,
     return true;
 }
 
+static
+bool isNoRunsFragment(const RoseBuildImpl &build, const LitFragment &f,
+                      const size_t max_len) {
+    // For the fragment to be marked "no runs", every literal it fires must
+    // need no further confirmation work.
+    return all_of_in(f.lit_ids, [&](u32 lit_id) {
+        const auto &info = build.literal_info.at(lit_id);
+        return isNoRunsLiteral(build, lit_id, info, max_len);
+    });
+}
+
 static
 const raw_puff &getChainedPuff(const RoseBuildImpl &build,
                                const Report &report) {
@@ -691,15 +702,15 @@ void addFragmentLiteral(const RoseBuildImpl &build, MatcherProto &mp,
                         const LitFragment &f, u32 id, bool delay_rebuild,
                         size_t max_len) {
     const rose_literal_id &lit = build.literals.at(id);
-    assert(id < build.literal_info.size());
-    const auto &info = build.literal_info.at(id);
 
     DEBUG_PRINTF("lit='%s' (len %zu)\n", dumpString(lit.s).c_str(),
                  lit.s.length());
 
     vector<u8> msk = lit.msk; // copy
     vector<u8> cmp = lit.cmp; // copy
-    bool noruns = isNoRunsLiteral(build, id, info, max_len);
+
+    bool noruns = isNoRunsFragment(build, f, max_len);
+    DEBUG_PRINTF("fragment is %s\n", noruns ? "noruns" : "not noruns");
 
     auto lit_final = lit.s; // copy