hyperscan 组合策略的解决方法:
需要单独处理的情况:
const char *expr[] = {
"abc", /* 101 hit */
"def", /* 102 hit */
"foobar.*gh", /* 103 not */
"teakettle{4,10}", /* 104 hit */
"ijkl[mMn]", /* 105 hit */
"102 & !103"
};
[root@fanpf-resty hyperscan_demo]# ./simplegrep_multi
data:[abcdef abteakettleeeeeeee ijklM toher]
id:[101] Match for at offset 3
id:[102] Match for at offset 6
id:[1001] Match for at offset 6
id:[104] Match for at offset 21
id:[104] Match for at offset 22
id:[104] Match for at offset 23
id:[104] Match for at offset 24
id:[104] Match for at offset 25
id:[105] Match for at offset 31
如果1001没有!符号, 则组合规则命中结果直接有效
如果1001有!符号,
如果1001没有命中偏移量, 则命中直接有效
如果1001有命中偏移量, 将带!的子规则偏移量进行查询
如果子规则有偏移量
1001的offset 和101一样
情况1:1001的子规则103没有命中, 则组合规则结果为真
情况2:1001的子规则103命中, 则组合规则结果为假