]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
Fix variableScope
authorKonstantinos Margaritis <konstantinos@vectorcamp.gr>
Wed, 15 May 2024 14:01:31 +0000 (17:01 +0300)
committerKonstantinos Margaritis <konstantinos@vectorcamp.gr>
Wed, 15 May 2024 14:04:11 +0000 (17:04 +0300)
src/nfa/gough.c
src/nfa/mcclellancompile.cpp
src/nfa/sheng.c
src/rose/rose_build_add_mask.cpp
src/rose/rose_build_bytecode.cpp

index d0ea0bbd2992f4db12fe637a4e60f122175b2744..f0d5bc64d5600ea27f429d8a09b3a2d3b006c742 100644 (file)
@@ -978,7 +978,6 @@ char nfaExecGough16_initCompressedState(const struct NFA *nfa, u64a offset,
 char nfaExecGough8_reportCurrent(const struct NFA *n, struct mq *q) {
     const struct mcclellan *m = (const struct mcclellan *)getImplNfa(n);
     NfaCallback cb = q->cb;
-    void *ctxt = q->context;
     u8 s = *(u8 *)q->state;
     u64a offset = q_cur_offset(q);
     const struct gough_som_info *som = getSomInfo(q->state);
@@ -986,6 +985,7 @@ char nfaExecGough8_reportCurrent(const struct NFA *n, struct mq *q) {
     assert(s);
 
     if (s >= m->accept_limit_8) {
+        void *ctxt = q->context;
         u32 cached_accept_id = 0;
         u16 cached_accept_state = 0;
         u32 cached_accept_som = 0;
@@ -1000,7 +1000,6 @@ char nfaExecGough8_reportCurrent(const struct NFA *n, struct mq *q) {
 char nfaExecGough16_reportCurrent(const struct NFA *n, struct mq *q) {
     const struct mcclellan *m = (const struct mcclellan *)getImplNfa(n);
     NfaCallback cb = q->cb;
-    void *ctxt = q->context;
     u16 s = *(u16 *)q->state;
     const struct mstate_aux *aux = get_aux(m, s);
     u64a offset = q_cur_offset(q);
@@ -1010,6 +1009,7 @@ char nfaExecGough16_reportCurrent(const struct NFA *n, struct mq *q) {
     assert(s);
 
     if (aux->accept) {
+        void *ctxt = q->context;
         u32 cached_accept_id = 0;
         u16 cached_accept_state = 0;
         u32 cached_accept_som = 0;
index 6ada4e50a130eb5e7f791e7dbd48d2e369f9f8d5..bf9b407a68290c4c84a9d02ad6cc54492736ecb1 100644 (file)
@@ -1379,7 +1379,6 @@ void generate_symbol_chain(dfa_info &info, vector<symbol_t> &chain_tail) {
 
         for (size_t j = 0; j < width; j++) {
             dstate_id_t curr_id = state_chain[j];
-            dstate_id_t next_id = state_chain[j + 1];
 
             // The last state of the chain doesn't belong to a wide state.
             info.extra[curr_id].wideState = true;
@@ -1388,6 +1387,7 @@ void generate_symbol_chain(dfa_info &info, vector<symbol_t> &chain_tail) {
             if (j == width - 1) {
                 symbol_chain.emplace_back(chain_tail[i]);
             } else {
+                dstate_id_t next_id = state_chain[j + 1];
                 for (symbol_t sym = 0; sym < info.impl_alpha_size; sym++) {
                     if (rdfa.states[curr_id].next[sym] == next_id) {
                         symbol_chain.emplace_back(sym);
index 922e8f80a88c87b5e686e34d67f7908b4fd5f306..e6b299d473fb23a20a4842a871bdfa1e92e28fab 100644 (file)
@@ -814,7 +814,6 @@ char nfaExecSheng_testEOD(const struct NFA *nfa, const char *state,
 char nfaExecSheng_reportCurrent(const struct NFA *n, struct mq *q) {
     const struct sheng *sh = (const struct sheng *)getImplNfa(n);
     NfaCallback cb = q->cb;
-    void *ctxt = q->context;
     u8 s = *(u8 *)q->state;
     const struct sstate_aux *aux = get_aux(sh, s);
     u64a offset = q_cur_offset(q);
@@ -823,6 +822,7 @@ char nfaExecSheng_reportCurrent(const struct NFA *n, struct mq *q) {
     assert(q_cur_type(q) == MQE_START);
 
     if (aux->accept) {
+        void *ctxt = q->context;
         if (sh->flags & SHENG_FLAG_SINGLE_REPORT) {
             fireSingleReport(cb, ctxt, sh->report, offset);
         } else {
index 05f3a6209a07ba56fe71019565bd50bc21c57a6a..5312e6c844f711aae5896516d1151f81216d69a1 100644 (file)
@@ -392,8 +392,9 @@ bool validateTransientMask(const vector<CharReach> &mask, bool anchored,
            none_of(begin(lits), end(lits), mixed_sensitivity));
 
     // Build the HWLM literal mask.
-    vector<u8> msk, lcmp;
+    vector<u8> msk;
     if (grey.roseHamsterMasks) {
+        vector<u8> lcmp;
         buildLiteralMask(mask, msk, lcmp, delay);
     }
 
index b456c0b563eb993d01bbafdc5184c394766ce371..df24a23430252371e1a254a4f442e5acdc031c03 100644 (file)
@@ -1901,8 +1901,8 @@ void findExclusiveSuffixes(RoseBuildImpl &tbi, build_context &bc,
 
         // We may have already built this NFA.
         if (contains(suffixes, s)) {
-            u32 id = suffixes[s];
             if (!tbi.isInETable(v)) {
+                u32 id = suffixes[s];
                 vertex_map[id].emplace_back(v);
             }
             continue;
@@ -2233,10 +2233,10 @@ vector<u32> buildSuffixEkeyLists(const RoseBuildImpl &build, build_context &bc,
 
     for (const auto &e : bc.suffixes) {
         const suffix_id &s = e.first;
-        u32 qi = e.second;
         set<u32> ekeys = reportsToEkeys(all_reports(s), build.rm);
 
         if (!ekeys.empty()) {
+            u32 qi = e.second;
             qi_to_ekeys[qi] = {ekeys.begin(), ekeys.end()};
         }
     }
@@ -2987,7 +2987,7 @@ void buildFragmentPrograms(const RoseBuildImpl &build,
             const auto &cfrag = fragments[pfrag.included_frag_id];
             /** assert(pfrag.s.length() >= cfrag.s.length() && **/
             assert(pfrag.s.length() == cfrag.s.length() &&
-                   !pfrag.s.any_nocase() >= !cfrag.s.any_nocase());
+                   !pfrag.s.any_nocase() != !cfrag.s.any_nocase());
             u32 child_offset = cfrag.delay_program_offset;
             DEBUG_PRINTF("child %u offset %u\n", cfrag.fragment_id,
                          child_offset);