mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
mpv: fire only one report when simple-exhaustible
This commit is contained in:
parent
9852ac0091
commit
5354b7a5ca
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Intel Corporation
|
* Copyright (c) 2015-2016, Intel Corporation
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -124,7 +124,7 @@ char processReports(const struct mpv *m, u8 *reporters,
|
|||||||
DEBUG_PRINTF("report %u at %llu\n", curr->report,
|
DEBUG_PRINTF("report %u at %llu\n", curr->report,
|
||||||
report_offset);
|
report_offset);
|
||||||
|
|
||||||
if (curr->unbounded) {
|
if (curr->unbounded && !curr->simple_exhaust) {
|
||||||
assert(rl_count < m->puffette_count);
|
assert(rl_count < m->puffette_count);
|
||||||
*rl = curr->report;
|
*rl = curr->report;
|
||||||
++rl;
|
++rl;
|
||||||
@ -176,6 +176,8 @@ char processReportsForRange(const struct mpv *m, u8 *reporters,
|
|||||||
return MO_CONTINUE_MATCHING;
|
return MO_CONTINUE_MATCHING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEBUG_PRINTF("length=%zu, rl_count=%u\n", length, rl_count);
|
||||||
|
|
||||||
for (size_t i = 2; i <= length; i++) {
|
for (size_t i = 2; i <= length; i++) {
|
||||||
for (u32 j = 0; j < rl_count; j++) {
|
for (u32 j = 0; j < rl_count; j++) {
|
||||||
if (cb(first_offset + i, rl[j], ctxt) == MO_HALT_MATCHING) {
|
if (cb(first_offset + i, rl[j], ctxt) == MO_HALT_MATCHING) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Intel Corporation
|
* Copyright (c) 2015-2016, Intel Corporation
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -108,6 +108,9 @@ void dumpKilo(FILE *f, const mpv *m, const mpv_kilopuff *k) {
|
|||||||
fprintf(f, " Puffette %u\n", i);
|
fprintf(f, " Puffette %u\n", i);
|
||||||
fprintf(f, " repeats: %u%s\n", p[i].repeats,
|
fprintf(f, " repeats: %u%s\n", p[i].repeats,
|
||||||
p[i].unbounded ? "," : "");
|
p[i].unbounded ? "," : "");
|
||||||
|
if (p[i].simple_exhaust) {
|
||||||
|
fprintf(f, " simple exhaustible\n");
|
||||||
|
}
|
||||||
fprintf(f, " report id: %u\n", p[i].report);
|
fprintf(f, " report id: %u\n", p[i].report);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Intel Corporation
|
* Copyright (c) 2015-2016, Intel Corporation
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -40,6 +40,15 @@
|
|||||||
struct mpv_puffette {
|
struct mpv_puffette {
|
||||||
u32 repeats;
|
u32 repeats;
|
||||||
char unbounded;
|
char unbounded;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Report is simple-exhaustible.
|
||||||
|
*
|
||||||
|
* If this is true, we do best-effort suppression of runs of reports, only
|
||||||
|
* delivering the first one.
|
||||||
|
*/
|
||||||
|
char simple_exhaust;
|
||||||
|
|
||||||
ReportID report;
|
ReportID report;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Intel Corporation
|
* Copyright (c) 2015-2016, Intel Corporation
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -53,10 +53,8 @@ namespace ue2 {
|
|||||||
namespace {
|
namespace {
|
||||||
struct pcomp {
|
struct pcomp {
|
||||||
bool operator()(const raw_puff &a, const raw_puff &b) const {
|
bool operator()(const raw_puff &a, const raw_puff &b) const {
|
||||||
ORDER_CHECK(repeats);
|
return tie(a.repeats, a.unbounded, a.simple_exhaust, a.report) <
|
||||||
ORDER_CHECK(unbounded);
|
tie(b.repeats, b.unbounded, b.simple_exhaust, b.report);
|
||||||
ORDER_CHECK(report);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -89,6 +87,7 @@ void writePuffette(mpv_puffette *out, const raw_puff &rp) {
|
|||||||
rp.report, out);
|
rp.report, out);
|
||||||
out->repeats = rp.repeats;
|
out->repeats = rp.repeats;
|
||||||
out->unbounded = rp.unbounded;
|
out->unbounded = rp.unbounded;
|
||||||
|
out->simple_exhaust = rp.simple_exhaust;
|
||||||
out->report = rp.report;
|
out->report = rp.report;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Intel Corporation
|
* Copyright (c) 2015-2016, Intel Corporation
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -42,12 +42,15 @@ namespace ue2 {
|
|||||||
|
|
||||||
struct raw_puff {
|
struct raw_puff {
|
||||||
raw_puff(u32 repeats_in, bool unbounded_in, ReportID report_in,
|
raw_puff(u32 repeats_in, bool unbounded_in, ReportID report_in,
|
||||||
const CharReach &reach_in, bool auto_restart_in = false)
|
const CharReach &reach_in, bool auto_restart_in = false,
|
||||||
|
bool simple_exhaust_in = false)
|
||||||
: repeats(repeats_in), unbounded(unbounded_in),
|
: repeats(repeats_in), unbounded(unbounded_in),
|
||||||
auto_restart(auto_restart_in), report(report_in), reach(reach_in) {}
|
auto_restart(auto_restart_in), simple_exhaust(simple_exhaust_in),
|
||||||
|
report(report_in), reach(reach_in) {}
|
||||||
u32 repeats; /**< report match after this many matching bytes */
|
u32 repeats; /**< report match after this many matching bytes */
|
||||||
bool unbounded; /**< keep producing matches after repeats are reached */
|
bool unbounded; /**< keep producing matches after repeats are reached */
|
||||||
bool auto_restart; /**< for /[^X]{n}/ type patterns */
|
bool auto_restart; /**< for /[^X]{n}/ type patterns */
|
||||||
|
bool simple_exhaust; /* first report will exhaust us */
|
||||||
ReportID report;
|
ReportID report;
|
||||||
CharReach reach; /**< = ~escapes */
|
CharReach reach; /**< = ~escapes */
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Intel Corporation
|
* Copyright (c) 2015-2016, Intel Corporation
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -270,12 +270,16 @@ void constructPuff(NGHolder &g, const NFAVertex a, const NFAVertex puffv,
|
|||||||
DEBUG_PRINTF("constructing Puff for report %u\n", report);
|
DEBUG_PRINTF("constructing Puff for report %u\n", report);
|
||||||
DEBUG_PRINTF("a = %u\n", g[a].index);
|
DEBUG_PRINTF("a = %u\n", g[a].index);
|
||||||
|
|
||||||
|
const Report &puff_report = rm.getReport(report);
|
||||||
|
const bool simple_exhaust = isSimpleExhaustible(puff_report);
|
||||||
|
|
||||||
const bool pureAnchored = a == g.start && singleStart(g);
|
const bool pureAnchored = a == g.start && singleStart(g);
|
||||||
if (!pureAnchored) {
|
if (!pureAnchored) {
|
||||||
if (a == g.startDs || a == g.start) {
|
if (a == g.startDs || a == g.start) {
|
||||||
DEBUG_PRINTF("add outfix ar(false)\n");
|
DEBUG_PRINTF("add outfix ar(false)\n");
|
||||||
|
|
||||||
raw_puff rp(width, unbounded, report, cr, auto_restart);
|
raw_puff rp(width, unbounded, report, cr, auto_restart,
|
||||||
|
simple_exhaust);
|
||||||
rose.addOutfix(rp);
|
rose.addOutfix(rp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -300,7 +304,7 @@ void constructPuff(NGHolder &g, const NFAVertex a, const NFAVertex puffv,
|
|||||||
} else {
|
} else {
|
||||||
DEBUG_PRINTF("add outfix ar(%d)\n", (int)auto_restart);
|
DEBUG_PRINTF("add outfix ar(%d)\n", (int)auto_restart);
|
||||||
assert(!auto_restart || unbounded);
|
assert(!auto_restart || unbounded);
|
||||||
raw_puff rp(width, unbounded, report, cr, auto_restart);
|
raw_puff rp(width, unbounded, report, cr, auto_restart, simple_exhaust);
|
||||||
rose.addOutfix(rp);
|
rose.addOutfix(rp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user