]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
constVariablePointer 264/head
authorgtsoul-tech <gtsoulkanakis@gmail.com>
Thu, 2 May 2024 11:21:16 +0000 (14:21 +0300)
committergtsoul-tech <gtsoulkanakis@gmail.com>
Thu, 2 May 2024 11:30:18 +0000 (14:30 +0300)
32 files changed:
examples/simplegrep.c
src/nfa/castle.c
src/nfa/gough.c
src/nfa/goughcompile.cpp
src/nfa/goughcompile_reg.cpp
src/nfa/limex_compile.cpp
src/nfa/limex_runtime_impl.h
src/nfa/mcclellancompile.cpp
src/nfa/mcsheng_compile.cpp
src/nfa/mpv.c
src/nfa/nfa_api_queue.h
src/nfa/nfa_api_util.h
src/nfagraph/ng_som.cpp
src/nfagraph/ng_violet.cpp
src/parser/ComponentAlternation.cpp
src/parser/ComponentAssertion.cpp
src/parser/ComponentAtomicGroup.cpp
src/parser/ComponentCondReference.cpp
src/parser/ComponentSequence.cpp
src/rose/block.c
src/rose/catchup.c
src/rose/match.c
src/rose/match.h
src/rose/rose_build_anchored.cpp
src/rose/rose_build_merge.cpp
src/rose/stream.c
src/rose/stream_long_lit.h
src/som/som_runtime.c
src/som/som_stream.c
src/util/multibit.h
src/util/multibit_compress.h
unit/internal/shufti.cpp

index d6bd4b39260b407b35d651530c3aabe4d6ac4dff..b4b287e8d29c25aae33f4df670ead09bfcc261b8 100644 (file)
@@ -150,7 +150,7 @@ int main(int argc, char *argv[]) {
     }
 
     char *pattern = argv[1];
-    char *inputFN = argv[2];
+    const char *inputFN = argv[2];
 
     /* First, we attempt to compile the pattern provided on the command line.
      * We assume 'DOTALL' semantics, meaning that the '.' meta-character will
index 35b202a27141413bc93341e945680fdf95acda3c..b6fadc75915b14b51050deffa81240e38b693468 100644 (file)
@@ -94,8 +94,8 @@ char subCastleReportCurrent(const struct Castle *c, struct mq *q,
     const struct SubCastle *sub = getSubCastle(c, subIdx);
     const struct RepeatInfo *info = getRepeatInfo(sub);
 
-    union RepeatControl *rctrl = getControl(q->state, sub);
-    char *rstate = (char *)q->streamState + sub->streamStateOffset +
+    const union RepeatControl *rctrl = getControl(q->state, sub);
+    const char *rstate = (char *)q->streamState + sub->streamStateOffset +
                    info->packedCtrlSize;
     enum RepeatMatch match =
         repeatHasMatch(info, rctrl, rstate, offset);
@@ -118,10 +118,10 @@ int castleReportCurrent(const struct Castle *c, struct mq *q) {
 
     if (c->exclusive) {
         u8 *active = (u8 *)q->streamState;
-        u8 *groups = active + c->groupIterOffset;
+        const u8 *groups = active + c->groupIterOffset;
         for (u32 i = mmbit_iterate(groups, c->numGroups, MMB_INVALID);
              i != MMB_INVALID; i = mmbit_iterate(groups, c->numGroups, i)) {
-            u8 *cur = active + i * c->activeIdxSize;
+            const u8 *cur = active + i * c->activeIdxSize;
             const u32 activeIdx = partial_load_u32(cur, c->activeIdxSize);
             DEBUG_PRINTF("subcastle %u\n", activeIdx);
             if (subCastleReportCurrent(c, q,
@@ -156,8 +156,8 @@ char subCastleInAccept(const struct Castle *c, struct mq *q,
     }
     const struct RepeatInfo *info = getRepeatInfo(sub);
 
-    union RepeatControl *rctrl = getControl(q->state, sub);
-    char *rstate = (char *)q->streamState + sub->streamStateOffset +
+    const union RepeatControl *rctrl = getControl(q->state, sub);
+    const char *rstate = (char *)q->streamState + sub->streamStateOffset +
                    info->packedCtrlSize;
     enum RepeatMatch match =
         repeatHasMatch(info, rctrl, rstate, offset);
@@ -180,10 +180,10 @@ char castleInAccept(const struct Castle *c, struct mq *q,
 
     if (c->exclusive) {
         u8 *active = (u8 *)q->streamState;
-        u8 *groups = active + c->groupIterOffset;
+        const u8 *groups = active + c->groupIterOffset;
         for (u32 i = mmbit_iterate(groups, c->numGroups, MMB_INVALID);
              i != MMB_INVALID; i = mmbit_iterate(groups, c->numGroups, i)) {
-            u8 *cur = active + i * c->activeIdxSize;
+            const u8 *cur = active + i * c->activeIdxSize;
             const u32 activeIdx = partial_load_u32(cur, c->activeIdxSize);
             DEBUG_PRINTF("subcastle %u\n", activeIdx);
             if (subCastleInAccept(c, q, report, offset, activeIdx)) {
@@ -213,8 +213,8 @@ void subCastleDeactivateStaleSubs(const struct Castle *c, const u64a offset,
     const struct SubCastle *sub = getSubCastle(c, subIdx);
     const struct RepeatInfo *info = getRepeatInfo(sub);
 
-    union RepeatControl *rctrl = getControl(full_state, sub);
-    char *rstate = (char *)stream_state + sub->streamStateOffset +
+    const union RepeatControl *rctrl = getControl(full_state, sub);
+    const char *rstate = (char *)stream_state + sub->streamStateOffset +
                        info->packedCtrlSize;
 
     if (repeatHasMatch(info, rctrl, rstate, offset) == REPEAT_STALE) {
@@ -242,10 +242,10 @@ void castleDeactivateStaleSubs(const struct Castle *c, const u64a offset,
 
     if (c->exclusive) {
         u8 *active = (u8 *)stream_state;
-        u8 *groups = active + c->groupIterOffset;
+        const u8 *groups = active + c->groupIterOffset;
         for (u32 i = mmbit_iterate(groups, c->numGroups, MMB_INVALID);
              i != MMB_INVALID; i = mmbit_iterate(groups, c->numGroups, i)) {
-            u8 *cur = active + i * c->activeIdxSize;
+            const u8 *cur = active + i * c->activeIdxSize;
             const u32 activeIdx = partial_load_u32(cur, c->activeIdxSize);
             DEBUG_PRINTF("subcastle %u\n", activeIdx);
             subCastleDeactivateStaleSubs(c, offset, full_state,
@@ -329,8 +329,8 @@ void subCastleFindMatch(const struct Castle *c, const u64a begin,
                         size_t *mloc, char *found, const u32 subIdx) {
     const struct SubCastle *sub = getSubCastle(c, subIdx);
     const struct RepeatInfo *info = getRepeatInfo(sub);
-    union RepeatControl *rctrl = getControl(full_state, sub);
-    char *rstate = (char *)stream_state + sub->streamStateOffset +
+    const union RepeatControl *rctrl = getControl(full_state, sub);
+    const char *rstate = (char *)stream_state + sub->streamStateOffset +
                    info->packedCtrlSize;
 
     u64a match = repeatNextMatch(info, rctrl, rstate, begin);
@@ -374,10 +374,10 @@ char castleFindMatch(const struct Castle *c, const u64a begin, const u64a end,
 
     if (c->exclusive) {
         u8 *active = (u8 *)stream_state;
-        u8 *groups = active + c->groupIterOffset;
+        const u8 *groups = active + c->groupIterOffset;
         for (u32 i = mmbit_iterate(groups, c->numGroups, MMB_INVALID);
              i != MMB_INVALID; i = mmbit_iterate(groups, c->numGroups, i)) {
-            u8 *cur = active + i * c->activeIdxSize;
+            const u8 *cur = active + i * c->activeIdxSize;
             const u32 activeIdx = partial_load_u32(cur, c->activeIdxSize);
             DEBUG_PRINTF("subcastle %u\n", activeIdx);
             subCastleFindMatch(c, begin, end, full_state, stream_state, mloc,
@@ -386,7 +386,7 @@ char castleFindMatch(const struct Castle *c, const u64a begin, const u64a end,
     }
 
     if (c->exclusive != PURE_EXCLUSIVE) {
-        u8 *active = (u8 *)stream_state + c->activeOffset;
+        const u8 *active = (u8 *)stream_state + c->activeOffset;
         for (u32 i = mmbit_iterate(active, c->numRepeats, MMB_INVALID);
              i != MMB_INVALID;
              i = mmbit_iterate(active, c->numRepeats, i)) {
@@ -495,7 +495,7 @@ char castleMatchLoop(const struct Castle *c, const u64a begin, const u64a end,
             u8 *groups = active + c->groupIterOffset;
             for (u32 i = mmbit_iterate(groups, c->numGroups, MMB_INVALID);
                  i != MMB_INVALID; i = mmbit_iterate(groups, c->numGroups, i)) {
-                u8 *cur = active + i * c->activeIdxSize;
+                const u8 *cur = active + i * c->activeIdxSize;
                 u32 activeIdx = partial_load_u32(cur, c->activeIdxSize);
                 u64a match = subCastleNextMatch(c, full_state, stream_state,
                                                 loc, activeIdx);
@@ -796,7 +796,7 @@ char nfaExecCastle_Q_i(const struct NFA *n, struct mq *q, s64a end,
 
         char found = 0;
         if (c->exclusive) {
-            u8 *groups = (u8 *)q->streamState + c->groupIterOffset;
+            const u8 *groups = (u8 *)q->streamState + c->groupIterOffset;
             found = mmbit_any(groups, c->numGroups);
         }
 
@@ -863,7 +863,7 @@ char nfaExecCastle_Q_i(const struct NFA *n, struct mq *q, s64a end,
     }
 
     if (c->exclusive) {
-        u8 *groups = (u8 *)q->streamState + c->groupIterOffset;
+        const u8 *groups = (u8 *)q->streamState + c->groupIterOffset;
         if (mmbit_any_precise(groups, c->numGroups)) {
             return 1;
         }
@@ -957,7 +957,7 @@ char nfaExecCastle_QR(const struct NFA *n, struct mq *q, ReportID report) {
 
     char found = 0;
     if (c->exclusive) {
-        u8 *groups = (u8 *)q->streamState + c->groupIterOffset;
+        const u8 *groups = (u8 *)q->streamState + c->groupIterOffset;
         found = mmbit_any_precise(groups, c->numGroups);
 
     }
@@ -1005,10 +1005,10 @@ char nfaExecCastle_inAnyAccept(const struct NFA *n, struct mq *q) {
 
     if (c->exclusive) {
         u8 *active = (u8 *)q->streamState;
-        u8 *groups = active + c->groupIterOffset;
+        const u8 *groups = active + c->groupIterOffset;
         for (u32 i = mmbit_iterate(groups, c->numGroups, MMB_INVALID);
              i != MMB_INVALID; i = mmbit_iterate(groups, c->numGroups, i)) {
-            u8 *cur = active + i * c->activeIdxSize;
+            const u8 *cur = active + i * c->activeIdxSize;
             const u32 activeIdx = partial_load_u32(cur, c->activeIdxSize);
             DEBUG_PRINTF("subcastle %u\n", activeIdx);
             const struct SubCastle *sub = getSubCastle(c, activeIdx);
@@ -1077,7 +1077,7 @@ void subCastleQueueCompressState(const struct Castle *c, const u32 subIdx,
                                  const struct mq *q, const u64a offset) {
     const struct SubCastle *sub = getSubCastle(c, subIdx);
     const struct RepeatInfo *info = getRepeatInfo(sub);
-    union RepeatControl *rctrl = getControl(q->state, sub);
+    const union RepeatControl *rctrl = getControl(q->state, sub);
     char *packed = (char *)q->streamState + sub->streamStateOffset;
     DEBUG_PRINTF("sub %u next match %llu\n", subIdx,
                  repeatNextMatch(info, rctrl,
@@ -1098,10 +1098,10 @@ char nfaExecCastle_queueCompressState(const struct NFA *n, const struct mq *q,
     DEBUG_PRINTF("offset=%llu\n", offset);
     if (c->exclusive) {
         u8 *active = (u8 *)q->streamState;
-        u8 *groups = active + c->groupIterOffset;
+        const u8 *groups = active + c->groupIterOffset;
         for (u32 i = mmbit_iterate(groups, c->numGroups, MMB_INVALID);
              i != MMB_INVALID; i = mmbit_iterate(groups, c->numGroups, i)) {
-            u8 *cur = active + i * c->activeIdxSize;
+            const u8 *cur = active + i * c->activeIdxSize;
             const u32 activeIdx = partial_load_u32(cur, c->activeIdxSize);
             DEBUG_PRINTF("packing state for sub %u\n", activeIdx);
             subCastleQueueCompressState(c, activeIdx, q, offset);
index 44acd4c28652fffb03cc9bd11766f1ea4bc56488..d0ea0bbd2992f4db12fe637a4e60f122175b2744 100644 (file)
@@ -981,7 +981,7 @@ char nfaExecGough8_reportCurrent(const struct NFA *n, struct mq *q) {
     void *ctxt = q->context;
     u8 s = *(u8 *)q->state;
     u64a offset = q_cur_offset(q);
-    struct gough_som_info *som = getSomInfo(q->state);
+    const struct gough_som_info *som = getSomInfo(q->state);
     assert(q_cur_type(q) == MQE_START);
     assert(s);
 
@@ -1004,7 +1004,7 @@ char nfaExecGough16_reportCurrent(const struct NFA *n, struct mq *q) {
     u16 s = *(u16 *)q->state;
     const struct mstate_aux *aux = get_aux(m, s);
     u64a offset = q_cur_offset(q);
-    struct gough_som_info *som = getSomInfo(q->state);
+    const struct gough_som_info *som = getSomInfo(q->state);
     assert(q_cur_type(q) == MQE_START);
     DEBUG_PRINTF("state %hu\n", s);
     assert(s);
index 62cdf72c63477b5e90444d5262926c2d72bf2976..980316171e211dc185191a009ed5248670a71354 100644 (file)
@@ -444,7 +444,7 @@ static
 void copy_propagate_report_set(vector<pair<ReportID, GoughSSAVar *> > &rep) {
     vector<pair<ReportID, GoughSSAVar *> >::iterator it = rep.begin();
     while (it != rep.end()) {
-        GoughSSAVar *var = it->second;
+        const GoughSSAVar *var = it->second;
         if (!var) {
             ++it;
             continue;
@@ -546,7 +546,7 @@ void remove_dead(GoughGraph &g) {
     }
 
     while (!queue.empty()) {
-        GoughSSAVar *v = queue.back();
+        const GoughSSAVar *v = queue.back();
         queue.pop_back();
         for (GoughSSAVar *var : v->get_inputs()) {
             if (var->seen) {
index 4798a9c392e438a5a25ca293d6f156d2403ceb2a..60e32f127129ff8c99dc3daceb542779b65660ba 100644 (file)
@@ -194,7 +194,7 @@ void handle_pending_vars(GoughSSAVar *def, const GoughGraph &g,
         if (contains(aux.containing_v, var)) {
             /* def is used by join vertex, value only needs to be live on some
              * incoming edges */
-            GoughSSAVarJoin *vj = (GoughSSAVarJoin *)var;
+            const GoughSSAVarJoin *vj = (GoughSSAVarJoin *)var;
             const flat_set<GoughEdge> &live_edges
                 = vj->get_edges_for_input(def);
             for (const auto &e : live_edges) {
index 2ec65552def40c9ada02af33edd0392ba4cb8ed3..14fad3523c973c44d95cbad4352bedc78603a669 100644 (file)
@@ -290,7 +290,7 @@ void maskSetBits(Mask &m, const NFAStateSet &bits) {
 
 template<class Mask>
 bool isMaskZero(Mask &m) {
-    u8 *m8 = (u8 *)&m;
+    const u8 *m8 = (u8 *)&m;
     for (u32 i = 0; i < sizeof(m); i++) {
         if (m8[i]) {
             return false;
@@ -1700,7 +1700,7 @@ struct Factory {
     static
     void allocState(NFA *nfa, u32 repeatscratchStateSize,
                     u32 repeatStreamState) {
-        implNFA_t *limex = (implNFA_t *)getMutableImplNfa(nfa);
+        const implNFA_t *limex = (implNFA_t *)getMutableImplNfa(nfa);
 
         // LimEx NFAs now store the following in state:
         // 1. state bitvector (always present)
index 7b89182bea6d89abe11a91a67d4f9370589b47d8..d21739d614d3e24a1fe6ff7f2b0672bfd9190e84 100644 (file)
@@ -984,9 +984,9 @@ char JOIN(LIMEX_API_ROOT, _inAccept)(const struct NFA *nfa,
     assert(q->state && q->streamState);
 
     const IMPL_NFA_T *limex = getImplNfa(nfa);
-    union RepeatControl *repeat_ctrl =
+    const union RepeatControl *repeat_ctrl =
         getRepeatControlBase(q->state, sizeof(STATE_T));
-    char *repeat_state = q->streamState + limex->stateSize;
+    const char *repeat_state = q->streamState + limex->stateSize;
     STATE_T state = *(STATE_T *)q->state;
     u64a offset = q->offset + q_last_loc(q) + 1;
 
@@ -999,9 +999,9 @@ char JOIN(LIMEX_API_ROOT, _inAnyAccept)(const struct NFA *nfa, struct mq *q) {
     assert(q->state && q->streamState);
 
     const IMPL_NFA_T *limex = getImplNfa(nfa);
-    union RepeatControl *repeat_ctrl =
+    const union RepeatControl *repeat_ctrl =
         getRepeatControlBase(q->state, sizeof(STATE_T));
-    char *repeat_state = q->streamState + limex->stateSize;
+    const char *repeat_state = q->streamState + limex->stateSize;
     STATE_T state = *(STATE_T *)q->state;
     u64a offset = q->offset + q_last_loc(q) + 1;
 
@@ -1020,9 +1020,9 @@ enum nfa_zombie_status JOIN(LIMEX_API_ROOT, _zombie_status)(
 
     if (limex->repeatCount) {
         u64a offset = q->offset + loc + 1;
-        union RepeatControl *repeat_ctrl =
+        const union RepeatControl *repeat_ctrl =
             getRepeatControlBase(q->state, sizeof(STATE_T));
-        char *repeat_state = q->streamState + limex->stateSize;
+        const char *repeat_state = q->streamState + limex->stateSize;
         SQUASH_UNTUG_BR_FN(limex, repeat_ctrl, repeat_state, offset, &state);
     }
 
index d0e305733b9947827de57ba7c34658cba157ebd3..463cb46c37d185d3505c893d58e91179b0ba9170 100644 (file)
@@ -176,7 +176,7 @@ static
 mstate_aux *getAux(NFA *n, dstate_id_t i) {
     assert(isMcClellanType(n->type));
 
-    mcclellan *m = (mcclellan *)getMutableImplNfa(n);
+    const mcclellan *m = (mcclellan *)getMutableImplNfa(n);
     mstate_aux *aux_base = (mstate_aux *)((char *)n + m->aux_offset);
 
     mstate_aux *aux = aux_base + i;
@@ -202,7 +202,7 @@ void markEdges(NFA *n, u16 *succ_table, const dfa_info &info) {
                 continue;
             }
 
-            mstate_aux *aux = getAux(n, succ_table[c_prime]);
+            const mstate_aux *aux = getAux(n, succ_table[c_prime]);
 
             if (aux->accept) {
                 succ_table[c_prime] |= ACCEPT_FLAG;
@@ -231,7 +231,7 @@ void markEdges(NFA *n, u16 *succ_table, const dfa_info &info) {
                 continue;
             }
 
-            mstate_aux *aux = getAux(n, succ_i);
+            const mstate_aux *aux = getAux(n, succ_i);
 
             if (aux->accept) {
                 succ_i |= ACCEPT_FLAG;
@@ -261,7 +261,7 @@ void markEdges(NFA *n, u16 *succ_table, const dfa_info &info) {
             // check successful transition
             u16 next = unaligned_load_u16((u8 *)trans);
             if (next < wide_limit) {
-                mstate_aux *aux = getAux(n, next);
+                const mstate_aux *aux = getAux(n, next);
                 if (aux->accept) {
                     next |= ACCEPT_FLAG;
                 }
@@ -278,7 +278,7 @@ void markEdges(NFA *n, u16 *succ_table, const dfa_info &info) {
                 if (next_k >= wide_limit) {
                     continue;
                 }
-                mstate_aux *aux_k = getAux(n, next_k);
+                const mstate_aux *aux_k = getAux(n, next_k);
                 if (aux_k->accept) {
                     next_k |= ACCEPT_FLAG;
                 }
index 81db7024dd36a6a9ebeffc0211f7dc431ab9c8e5..8e2f2d119867f2f25cce521a01306aaf00e8a53c 100644 (file)
@@ -144,7 +144,7 @@ u8 dfa_info::getAlphaShift() const {
 
 static
 mstate_aux *getAux(NFA *n, dstate_id_t i) {
-    mcsheng *m = (mcsheng *)getMutableImplNfa(n);
+    const mcsheng *m = (mcsheng *)getMutableImplNfa(n);
     mstate_aux *aux_base = (mstate_aux *)((char *)n + m->aux_offset);
 
     mstate_aux *aux = aux_base + i;
@@ -244,7 +244,7 @@ void populateBasicInfo(size_t state_size, const dfa_info &info,
 
 static
 mstate_aux *getAux64(NFA *n, dstate_id_t i) {
-    mcsheng64 *m = (mcsheng64 *)getMutableImplNfa(n);
+    const mcsheng64 *m = (mcsheng64 *)getMutableImplNfa(n);
     mstate_aux *aux_base = (mstate_aux *)((char *)n + m->aux_offset);
 
     mstate_aux *aux = aux_base + i;
@@ -674,7 +674,7 @@ void fill_in_aux_info(NFA *nfa, const dfa_info &info,
 
 static
 u16 get_edge_flags(NFA *nfa, dstate_id_t target_impl_id) {
-    mstate_aux *aux = getAux(nfa, target_impl_id);
+    const mstate_aux *aux = getAux(nfa, target_impl_id);
     u16 flags = 0;
 
     if (aux->accept) {
@@ -748,7 +748,7 @@ void fill_in_aux_info64(NFA *nfa, const dfa_info &info,
 
 static
 u16 get_edge_flags64(NFA *nfa, dstate_id_t target_impl_id) {
-    mstate_aux *aux = getAux64(nfa, target_impl_id);
+    const mstate_aux *aux = getAux64(nfa, target_impl_id);
     u16 flags = 0;
 
     if (aux->accept) {
index edfe5f89349781cba851f8fb50114543e9faf8f3..f84e9af1b50a785daaecfc56608266aa99553b34 100644 (file)
@@ -1074,7 +1074,7 @@ s64a nfaExecMpv_QueueExecRaw(const struct NFA *nfa, struct mq *q, s64a end) {
         return 0;
     } else {
         const struct mpv *m = getImplNfa(nfa);
-        u8 *reporters = (u8 *)q->state + m->reporter_offset;
+        const u8 *reporters = (u8 *)q->state + m->reporter_offset;
 
         if (mmbit_any_precise(reporters, m->kilo_count)) {
             DEBUG_PRINTF("next byte\n");
@@ -1087,7 +1087,7 @@ s64a nfaExecMpv_QueueExecRaw(const struct NFA *nfa, struct mq *q, s64a end) {
                 next_event = q->items[q->cur].location;
             }
 
-            struct mpv_decomp_state *s = (struct mpv_decomp_state *)q->state;
+            const struct mpv_decomp_state *s = (struct mpv_decomp_state *)q->state;
             struct mpv_pq_item *pq
                 = (struct mpv_pq_item *)(q->state + m->pq_offset);
             if (s->pq_size) {
index e3579a7ee2aaeaa8515f9f10196bfea61e87c710..16a4c011d94a47c0e3a6024114577f15e634c6e4 100644 (file)
@@ -167,7 +167,7 @@ void pushQueueNoMerge(struct mq * restrict q, u32 e, s64a loc) {
     // We assert that the event is different from its predecessor. If it's a
     // dupe, you should have used the ordinary pushQueue call.
     if (q->end) {
-        UNUSED struct mq_item *prev = &q->items[q->end - 1];
+        UNUSED const struct mq_item *prev = &q->items[q->end - 1];
         assert(prev->type != e || prev->location != loc);
     }
 #endif
index affc5f38f335b9b8fb3ea3e7152126a9ad99cd01..1af9c801830441be46c6deee879ce26583360ace 100644 (file)
@@ -68,7 +68,7 @@ void pushQueueAt(struct mq * restrict q, u32 pos, u32 e, s64a loc) {
     // We assert that the event is different from its predecessor. If it's a
     // dupe, you should have used the ordinary pushQueue call.
     if (q->end) {
-        UNUSED struct mq_item *prev = &q->items[q->end - 1];
+        UNUSED const struct mq_item *prev = &q->items[q->end - 1];
         assert(prev->type != e || prev->location != loc);
     }
 #endif
index fcc5bf1bffc16c4252ad1e6b8d63614a8d2509b7..bbe141245dfe9ac876e95248ec15decb1a816a3e 100644 (file)
@@ -1408,7 +1408,7 @@ bool doSomPlanning(NGHolder &g, bool stuck_in,
 
     /* Need to verify how far the lock covers */
     u32 bad_region;
-    NGHolder *ap_pref = plan.back().prefix.get();
+    const NGHolder *ap_pref = plan.back().prefix.get();
     NGHolder ap_temp;
     if (hasBigCycles(*ap_pref)) {
         fillRoughMidfix(&ap_temp, g, regions, info, picked);
index 525d2f1431a7e8ddea7590785ef3954b41f77b48..14bdf73f75d84b983c7872b26fb8dba6b509c2a1 100644 (file)
@@ -1791,7 +1791,7 @@ void removeRedundantLiteralsFromInfixes(RoseInGraph &g,
     }
 
     for (const auto &m : infixes) {
-        NGHolder *h = m.first;
+        const NGHolder *h = m.first;
         const auto &edges = m.second;
         removeRedundantLiteralsFromInfix(*h, g, edges, cc);
     }
index c4bad67254bf6c0dbaea869780a04ec88e26cd05..a33749075cc9bae5eaa905654073f67906a69132 100644 (file)
@@ -73,7 +73,7 @@ Component *ComponentAlternation::accept(ComponentVisitor &v) {
     }
 
     for (auto i = children.begin(), e = children.end(); i != e; ++i) {
-        Component *child = i->get();
+        const Component *child = i->get();
         c = (*i)->accept(v);
         if (c != child) {
             // Child has been replaced (new Component pointer) or we've been
index cadff93264fff7c225fe3c2d58d07f45334356a3..a2b4c24c237ae0c70df2d838a1c952204f020283 100644 (file)
@@ -59,7 +59,7 @@ Component * ComponentAssertion::accept(ComponentVisitor &v) {
     }
 
     for (auto i = children.begin(), e = children.end(); i != e; ++i) {
-        Component *child = i->get();
+        const Component *child = i->get();
         c = (*i)->accept(v);
         if (c != child) {
             // Child has been replaced (new Component pointer) or we've been
index 106f24fc4d9daac8c2690aebeeaf8620c6e42d37..3630021f95e3d8eeef08027b5ef08219e6a46b85 100644 (file)
@@ -51,7 +51,7 @@ Component *ComponentAtomicGroup::accept(ComponentVisitor &v) {
     }
 
     for (auto i = children.begin(), e = children.end(); i != e; ++i) {
-        Component *child = i->get();
+        const Component *child = i->get();
         c = (*i)->accept(v);
         if (c != child) {
             // Child has been replaced (new Component pointer) or we've been
index b6ff44db96fd01d470b8fc9c1dfd49ce15e445cb..cfd2a38dedd517dd0d201e2186d7568043753e9b 100644 (file)
@@ -79,7 +79,7 @@ Component *ComponentCondReference::accept(ComponentVisitor &v) {
     }
 
     if (kind == CONDITION_ASSERTION) {
-        Component *a = assertion.get();
+        const Component *a = assertion.get();
         c = assertion->accept(v);
         if (c != a) {
             assertion.reset(c);
@@ -87,7 +87,7 @@ Component *ComponentCondReference::accept(ComponentVisitor &v) {
     }
 
     for (auto i = children.begin(), e = children.end(); i != e; ++i) {
-        Component *child = i->get();
+        const Component *child = i->get();
         c = (*i)->accept(v);
         if (c != child) {
             // Child has been replaced (new Component pointer) or we've been
index f520020696db67686442507a8231214a9fe1c1ce..c67a277bf617e4dfd4be97bcce2f0daea6a23697 100644 (file)
@@ -82,7 +82,7 @@ Component *ComponentSequence::accept(ComponentVisitor &v) {
     }
 
     for (auto i = children.begin(), e = children.end(); i != e; ++i) {
-        Component *child = i->get();
+        const Component *child = i->get();
         c = (*i)->accept(v);
         if (c != child) {
             // Child has been replaced (new Component pointer) or we've been
index b3f424cb73cf4db2ac0780f39eb324fe4add02a7..60572d494a5fb15ce8f702e1e5a3e21b804bfad4 100644 (file)
@@ -227,7 +227,7 @@ int roseBlockFloating(const struct RoseEngine *t, struct hs_scratch *scratch) {
 
     const size_t length = scratch->core_info.len;
     char *state = scratch->core_info.state;
-    struct RoseContext *tctxt = &scratch->tctxt;
+    const struct RoseContext *tctxt = &scratch->tctxt;
 
     DEBUG_PRINTF("ftable fd=%u fmd %u\n", t->floatingDistance,
                  t->floatingMinDistance);
@@ -377,7 +377,7 @@ void roseBlockExec(const struct RoseEngine *t, struct hs_scratch *scratch) {
 
     init_for_block(t, scratch, state, is_small_block);
 
-    struct RoseContext *tctxt = &scratch->tctxt;
+    const struct RoseContext *tctxt = &scratch->tctxt;
 
     if (is_small_block) {
         const void *sbtable = getSBLiteralMatcher(t);
index 7a6648da980119bd4416b17af420464feec3bd1a..ad0636b80349af52eb0249a9b47b2d72f47ca18c 100644 (file)
@@ -679,7 +679,7 @@ hwlmcb_rv_t buildSufPQ(const struct RoseEngine *t, char *state, s64a safe_loc,
                        s64a final_loc, struct hs_scratch *scratch) {
     assert(scratch->catchup_pq.qm_size <= t->outfixEndQueue);
 
-    struct RoseContext *tctxt = &scratch->tctxt;
+    const struct RoseContext *tctxt = &scratch->tctxt;
     assert(t->activeArrayCount);
 
     assert(scratch->core_info.buf_offset + final_loc
index 84d3b1fdc2c1771b663e6c50c27b7d3bbf58ecff..643b1d9fcbed46ee78d79aac1cd87107f0d4880c 100644 (file)
@@ -68,7 +68,7 @@ void printMatch(const struct core_info *ci, u64a start, u64a end) {
 
 hwlmcb_rv_t roseDelayRebuildCallback(size_t end, u32 id,
                                      struct hs_scratch *scratch) {
-    struct RoseContext *tctx = &scratch->tctxt;
+    const struct RoseContext *tctx = &scratch->tctxt;
     struct core_info *ci = &scratch->core_info;
     const struct RoseEngine *t = ci->rose;
     size_t rb_len = MIN(ci->hlen, t->delayRebuildLength);
@@ -296,7 +296,7 @@ hwlmcb_rv_t flushAnchoredLiteralAtLoc(const struct RoseEngine *t,
                                       struct hs_scratch *scratch,
                                       u32 curr_loc) {
     struct RoseContext *tctxt = &scratch->tctxt;
-    struct fatbit *curr_row = getAnchoredLiteralLog(scratch)[curr_loc - 1];
+    const struct fatbit *curr_row = getAnchoredLiteralLog(scratch)[curr_loc - 1];
     u32 region_width = t->anchored_count;
 
     const u32 *programs = getByOffset(t, t->anchoredProgramOffset);
@@ -334,7 +334,7 @@ hwlmcb_rv_t flushAnchoredLiteralAtLoc(const struct RoseEngine *t,
 
 static really_inline
 u32 anchored_it_begin(struct hs_scratch *scratch) {
-    struct RoseContext *tctxt = &scratch->tctxt;
+    const struct RoseContext *tctxt = &scratch->tctxt;
     if (tctxt->lastEndOffset >= scratch->anchored_literal_region_len) {
         return MMB_INVALID;
     }
index c03b1ebbaed6d1ac1fc3eb4d05324a261f7325d1..5a4bfa6bc2919d499a7303c356b29180fff89ab8 100644 (file)
@@ -254,8 +254,8 @@ void roseFlushLastByteHistory(const struct RoseEngine *t,
         return;
     }
 
-    struct RoseContext *tctxt = &scratch->tctxt;
-    struct core_info *ci = &scratch->core_info;
+    const struct RoseContext *tctxt = &scratch->tctxt;
+    const struct core_info *ci = &scratch->core_info;
 
     /* currEnd is last byte of string + 1 */
     if (tctxt->lastEndOffset == ci->buf_offset + ci->len
index 027aefd0b8cdf6701d57d01e9d884d9692c32a34..88128a8d56bdef43b5642f71d0fe2df3a0392df4 100644 (file)
@@ -896,7 +896,7 @@ buildAnchoredMatcher(RoseBuildImpl &build, const vector<LitFragment> &fragments,
     for (size_t i = 0; i < nfas.size(); i++) {
         const NFA *nfa = nfas[i].get();
         anchored_matcher_info *ami = (anchored_matcher_info *)curr;
-        char *prev_curr = curr;
+        const char *prev_curr = curr;
 
         curr += sizeof(anchored_matcher_info);
 
index 343cd308982d442b9979b497e6166f9c7a0491fb..1172728b558de161481a01880710a8894f1b7cfb 100644 (file)
@@ -1186,8 +1186,8 @@ bool mergeLeftVL_tryMergeCandidate(RoseBuildImpl &build, left_id &r1,
 
     assert(!r1.graph() == !r2.graph());
     if (r1.graph()) {
-        NGHolder *h1 = r1.graph();
-        NGHolder *h2 = r2.graph();
+        const NGHolder *h1 = r1.graph();
+        const NGHolder *h2 = r2.graph();
         CharReach stop1 = findStopAlphabet(*h1, SOM_NONE);
         CharReach stop2 = findStopAlphabet(*h2, SOM_NONE);
         CharReach stopboth = stop1 & stop2;
index acf4855a8c2f0ef448812b0cb2a1d4a2ea3a86f7..94da8717d6daf372a52c67da77836b6bbb660288 100644 (file)
@@ -382,7 +382,7 @@ void roseSaveNfaStreamState(const struct RoseEngine *t, char *state,
          qi = mmbit_iterate(aa, aaCount, qi)) {
         DEBUG_PRINTF("saving stream state for qi=%u\n", qi);
 
-        struct mq *q = queues + qi;
+        const struct mq *q = queues + qi;
 
         // If it's active, it should have an active queue (as we should have
         // done some work!)
@@ -517,7 +517,7 @@ void runEagerPrefixesStream(const struct RoseEngine *t,
 static really_inline
 int can_never_match(const struct RoseEngine *t, char *state,
                     struct hs_scratch *scratch, size_t length, u64a offset) {
-    struct RoseContext *tctxt = &scratch->tctxt;
+    const struct RoseContext *tctxt = &scratch->tctxt;
 
     if (tctxt->groups) {
         DEBUG_PRINTF("still has active groups\n");
index df9b57f4e27f51ad32064b72665a250bb657f9c4..68adc136d8b2e3deba8972445335440191bb5150 100644 (file)
@@ -332,7 +332,7 @@ void storeLongLiteralState(const struct RoseEngine *t, char *state,
         return;
     }
 
-    struct core_info *ci = &scratch->core_info;
+    const struct core_info *ci = &scratch->core_info;
     const struct RoseLongLitTable *ll_table =
         getByOffset(t, t->longLitTableOffset);
     assert(ll_table->maxLen);
index ce179ca059911925cfcc67854cc4e7a43949c881..3544309c4a7df318a1050aef91e37fb1bbf8217c 100644 (file)
@@ -512,7 +512,7 @@ int flushStoredSomMatches_i(struct hs_scratch *scratch, u64a offset) {
     /* fire any reports from the logs and clear them */
     if (offset == scratch->deduper.current_report_offset + 1) {
         struct fatbit *done_log = scratch->deduper.som_log[offset % 2];
-        u64a *done_starts = scratch->deduper.som_start_log[offset % 2];
+        const u64a *done_starts = scratch->deduper.som_start_log[offset % 2];
 
         halt = clearSomLog(scratch, scratch->deduper.current_report_offset - 1,
                            done_log, done_starts);
@@ -522,9 +522,9 @@ int flushStoredSomMatches_i(struct hs_scratch *scratch, u64a offset) {
         u64a f_offset = scratch->deduper.current_report_offset - 1;
         u64a s_offset = scratch->deduper.current_report_offset;
         struct fatbit *first_log = scratch->deduper.som_log[f_offset % 2];
-        u64a *first_starts = scratch->deduper.som_start_log[f_offset % 2];
+        const u64a *first_starts = scratch->deduper.som_start_log[f_offset % 2];
         struct fatbit *second_log = scratch->deduper.som_log[s_offset % 2];
-        u64a *second_starts = scratch->deduper.som_start_log[s_offset % 2];
+        const u64a *second_starts = scratch->deduper.som_start_log[s_offset % 2];
 
         halt = clearSomLog(scratch, f_offset, first_log, first_starts) ||
                clearSomLog(scratch, s_offset, second_log, second_starts);
index 93ab709edde089bec51ed13b41b5eddd2bab308c..6502d87c000cb38a0ddd61bf7dc3f966dac30f0d 100644 (file)
@@ -102,7 +102,7 @@ void storeSomToStream(struct hs_scratch *scratch, const u64a offset) {
     const u32 som_store_count = rose->somLocationCount;
     assert(som_store_count); // Caller should ensure that we have work to do.
 
-    u8 *som_store_valid = (u8 *)ci->state + rose->stateOffsets.somValid;
+    const u8 *som_store_valid = (u8 *)ci->state + rose->stateOffsets.somValid;
     char *stream_som_store = ci->state + rose->stateOffsets.somLocation;
     const u64a *som_store = scratch->som_store;
     const u8 som_size = rose->somHorizon;
index 95261b371d2d34da41c005f3dd62c68bca05c85b..3ec45d6ff3d8c95130a6cb471d14b16a35c66d20 100644 (file)
@@ -1421,7 +1421,7 @@ uplevel:
             if (level == 0) {
                 return; // we are done
             }
-            u8 *block_ptr =
+            const u8 *block_ptr =
                 mmbit_get_level_root(bits, level) + key * sizeof(MMB_TYPE);
             MMB_TYPE real_block = mmb_load(block_ptr);
             key >>= MMB_KEY_SHIFT;
index e7b4fd8e861c06f01c22e9de2a4d587b2532ebd9..018bfec2028461243f88a969f52ca5dfd9050964 100644 (file)
@@ -167,7 +167,7 @@ char mmbit_decompress(u8 *bits, u32 total_bits, const u8 *comp,
     comp += sizeof(MMB_TYPE);
     while (1) {
         if (key_rem < MMB_KEY_BITS) {
-            u8 *block_ptr = mmbit_get_level_root(bits, level) +
+            const u8 *block_ptr = mmbit_get_level_root(bits, level) +
                             key * sizeof(MMB_TYPE);
             MMB_TYPE block = mmb_load(block_ptr);
             MMB_TYPE block_1 = block & ~mmb_mask_zero_to_nocheck(key_rem);
index fb8d58a843da009a012d2422bcdb0f57005482f1..a3955267211ae91731c23d04decd0232c97e36f6 100644 (file)
@@ -79,8 +79,8 @@ TEST(Shufti, BuildMask2) {
     int ret = shuftiBuildMasks(chars, (u8 *)&lomask, (u8 *)&himask);
     ASSERT_NE(-1, ret);
 
-    u8 *lo = (u8 *)&lomask;
-    u8 *hi = (u8 *)&himask;
+    const u8 *lo = (u8 *)&lomask;
+    const u8 *hi = (u8 *)&himask;
     ASSERT_TRUE(lo['a' % 16] & hi['a' >> 4]);
     ASSERT_TRUE(lo['B' % 16] & hi['B' >> 4]);
     ASSERT_FALSE(lo['a' % 16] & hi['B' >> 4]);
@@ -100,8 +100,8 @@ TEST(Shufti, BuildMask4) {
     int ret = shuftiBuildMasks(chars, (u8 *)&lomask, (u8 *)&himask);
     ASSERT_NE(-1, ret);
 
-    u8 *lo = (u8 *)&lomask;
-    u8 *hi = (u8 *)&himask;
+    const u8 *lo = (u8 *)&lomask;
+    const u8 *hi = (u8 *)&himask;
     ASSERT_TRUE(lo['a' % 16] & hi['a' >> 4]);
     ASSERT_TRUE(lo['A' % 16] & hi['A' >> 4]);
     ASSERT_TRUE(lo['b' % 16] & hi['b' >> 4]);
@@ -331,10 +331,10 @@ TEST(DoubleShufti, BuildMask2) {
                                      (u8 *)&lo2m, (u8 *)&hi2m);
     ASSERT_TRUE(ret);
 
-    u8 *lo1 = (u8 *)&lo1m;
-    u8 *lo2 = (u8 *)&lo2m;
-    u8 *hi1 = (u8 *)&hi1m;
-    u8 *hi2 = (u8 *)&hi2m;
+    const u8 *lo1 = (u8 *)&lo1m;
+    const u8 *lo2 = (u8 *)&lo2m;
+    const u8 *hi1 = (u8 *)&hi1m;
+    const u8 *hi2 = (u8 *)&hi2m;
     ASSERT_NE(0xff,
               lo1['a' % 16] | hi1['a' >> 4] | lo2['z' % 16] | hi2['z' >> 4]);
     ASSERT_NE(0xff,
@@ -359,10 +359,10 @@ TEST(DoubleShufti, BuildMask4) {
                                      (u8 *)&lo2m, (u8 *)&hi2m);
     ASSERT_TRUE(ret);
 
-    u8 *lo1 = (u8 *)&lo1m;
-    u8 *lo2 = (u8 *)&lo2m;
-    u8 *hi1 = (u8 *)&hi1m;
-    u8 *hi2 = (u8 *)&hi2m;
+    const u8 *lo1 = (u8 *)&lo1m;
+    const u8 *lo2 = (u8 *)&lo2m;
+    const u8 *hi1 = (u8 *)&hi1m;
+    const u8 *hi2 = (u8 *)&hi2m;
     ASSERT_NE(0xff,
               lo1['a' % 16] | hi1['a' >> 4] | lo2['z' % 16] | hi2['z' >> 4]);
     ASSERT_NE(0xff,
@@ -388,10 +388,10 @@ TEST(DoubleShufti, BuildMask5) {
                                      (u8 *)&lo2m, (u8 *)&hi2m);
     ASSERT_TRUE(ret);
 
-    u8 *lo1 = (u8 *)&lo1m;
-    u8 *lo2 = (u8 *)&lo2m;
-    u8 *hi1 = (u8 *)&hi1m;
-    u8 *hi2 = (u8 *)&hi2m;
+    const u8 *lo1 = (u8 *)&lo1m;
+    const u8 *lo2 = (u8 *)&lo2m;
+    const u8 *hi1 = (u8 *)&hi1m;
+    const u8 *hi2 = (u8 *)&hi2m;
     ASSERT_NE(0xff,
               lo1['a' % 16] | hi1['a' >> 4] | lo2['z' % 16] | hi2['z' >> 4]);
     ASSERT_EQ(0xff,
@@ -426,10 +426,10 @@ TEST(DoubleShufti, BuildMask6) {
                                      (u8 *)&lo2m, (u8 *)&hi2m);
     ASSERT_TRUE(ret);
 
-    u8 *lo1 = (u8 *)&lo1m;
-    u8 *lo2 = (u8 *)&lo2m;
-    u8 *hi1 = (u8 *)&hi1m;
-    u8 *hi2 = (u8 *)&hi2m;
+    const u8 *lo1 = (u8 *)&lo1m;
+    const u8 *lo2 = (u8 *)&lo2m;
+    const u8 *hi1 = (u8 *)&hi1m;
+    const u8 *hi2 = (u8 *)&hi2m;
     ASSERT_NE(0xff,
               lo1['a' % 16] | hi1['a' >> 4] | lo2['z' % 16] | hi2['z' >> 4]);
     ASSERT_NE(0xff,