mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
rose: use normal callback for pure-literal cases
This commit is contained in:
parent
8435f918d1
commit
d497a1259a
@ -582,29 +582,6 @@ hwlmcb_rv_t roseFloatingCallback(size_t start, size_t end, u32 id, void *ctxt) {
|
|||||||
return roseCallback_i(start, end, id, ctxt) & t->floating_group_mask;
|
return roseCallback_i(start, end, id, ctxt) & t->floating_group_mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Match callback adaptor used for matches from pure-literal cases.
|
|
||||||
*
|
|
||||||
* Literal match IDs in this path run limited Rose programs that do not use
|
|
||||||
* Rose state (which is not initialised in the pure-literal path). They can
|
|
||||||
* still, for example, check lookarounds or literal masks.
|
|
||||||
*/
|
|
||||||
hwlmcb_rv_t rosePureLiteralCallback(size_t start, size_t end, u32 id,
|
|
||||||
void *context) {
|
|
||||||
DEBUG_PRINTF("start=%zu, end=%zu, id=%u\n", start, end, id);
|
|
||||||
struct hs_scratch *scratch = context;
|
|
||||||
struct core_info *ci = &scratch->core_info;
|
|
||||||
const u64a real_end = (u64a)end + ci->buf_offset + 1;
|
|
||||||
const u64a som = 0;
|
|
||||||
const size_t match_len = end - start + 1;
|
|
||||||
const struct RoseEngine *rose = ci->rose;
|
|
||||||
const u32 *programs = getByOffset(rose, rose->litProgramOffset);
|
|
||||||
assert(id < rose->literalCount);
|
|
||||||
const u8 flags = 0;
|
|
||||||
return roseRunProgram(rose, scratch, programs[id], som, real_end, match_len,
|
|
||||||
flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Execute a boundary report program.
|
* \brief Execute a boundary report program.
|
||||||
*
|
*
|
||||||
|
@ -46,8 +46,7 @@ void roseStreamExec(const struct RoseEngine *t, struct hs_scratch *scratch);
|
|||||||
void roseStreamEodExec(const struct RoseEngine *t, u64a offset,
|
void roseStreamEodExec(const struct RoseEngine *t, u64a offset,
|
||||||
struct hs_scratch *scratch);
|
struct hs_scratch *scratch);
|
||||||
|
|
||||||
hwlmcb_rv_t rosePureLiteralCallback(size_t start, size_t end, u32 id,
|
hwlmcb_rv_t roseCallback(size_t start, size_t end, u32 id, void *context);
|
||||||
void *context);
|
|
||||||
|
|
||||||
int roseReportAdaptor(u64a start, u64a end, ReportID id, void *context);
|
int roseReportAdaptor(u64a start, u64a end, ReportID id, void *context);
|
||||||
|
|
||||||
|
@ -198,7 +198,11 @@ void pureLiteralBlockExec(const struct RoseEngine *rose,
|
|||||||
size_t length = scratch->core_info.len;
|
size_t length = scratch->core_info.len;
|
||||||
DEBUG_PRINTF("rose engine %d\n", rose->runtimeImpl);
|
DEBUG_PRINTF("rose engine %d\n", rose->runtimeImpl);
|
||||||
|
|
||||||
hwlmExec(ftable, buffer, length, 0, rosePureLiteralCallback, scratch,
|
// RoseContext values that need to be set for use by roseCallback.
|
||||||
|
scratch->tctxt.groups = rose->initialGroups;
|
||||||
|
scratch->tctxt.lit_offset_adjust = 1;
|
||||||
|
|
||||||
|
hwlmExec(ftable, buffer, length, 0, roseCallback, scratch,
|
||||||
rose->initialGroups);
|
rose->initialGroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -742,11 +746,15 @@ void pureLiteralStreamExec(struct hs_stream *stream_state,
|
|||||||
DEBUG_PRINTF("::: streaming rose ::: offset = %llu len = %zu\n",
|
DEBUG_PRINTF("::: streaming rose ::: offset = %llu len = %zu\n",
|
||||||
stream_state->offset, scratch->core_info.len);
|
stream_state->offset, scratch->core_info.len);
|
||||||
|
|
||||||
|
// RoseContext values that need to be set for use by roseCallback.
|
||||||
|
scratch->tctxt.groups = loadGroups(rose, scratch->core_info.state);
|
||||||
|
scratch->tctxt.lit_offset_adjust = scratch->core_info.buf_offset + 1;
|
||||||
|
|
||||||
// Pure literal cases don't have floatingMinDistance set, so we always
|
// Pure literal cases don't have floatingMinDistance set, so we always
|
||||||
// start the match region at zero.
|
// start the match region at zero.
|
||||||
const size_t start = 0;
|
const size_t start = 0;
|
||||||
|
|
||||||
hwlmExecStreaming(ftable, scratch, len2, start, rosePureLiteralCallback,
|
hwlmExecStreaming(ftable, scratch, len2, start, roseCallback,
|
||||||
scratch, rose->initialGroups, hwlm_stream_state);
|
scratch, rose->initialGroups, hwlm_stream_state);
|
||||||
|
|
||||||
if (!told_to_stop_matching(scratch) &&
|
if (!told_to_stop_matching(scratch) &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user