mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 20:48:21 +00:00
Merge remote-tracking branch 'origin/topic/dev/patterns-in-sets'
Fixes in merge: - Memory leak in HashKey ctor - Minor whitespace/style changes * origin/topic/dev/patterns-in-sets: Enable Patterns as Table index in non singleton cases Added support to create a Hashkey for PatternVals using their Pattern Texts
This commit is contained in:
commit
d581aa76aa
8 changed files with 140 additions and 4 deletions
43
testing/btest/language/table-pattern-index.zeek
Normal file
43
testing/btest/language/table-pattern-index.zeek
Normal file
|
@ -0,0 +1,43 @@
|
|||
# @TEST-EXEC: zeek -b %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
local p1: pattern = /one|foo|bar/;
|
||||
local p2: pattern = /two|oob/;
|
||||
local p3: pattern = /three|oob/;
|
||||
local p4 = /four/;
|
||||
|
||||
local p: set[pattern] = {p1, p2, p3, p4};
|
||||
|
||||
local t: table[pattern] of count = {
|
||||
[p1] = 0,
|
||||
[p2] = 1,
|
||||
[p3] = 2,
|
||||
[p4] = 3
|
||||
};
|
||||
|
||||
local t2: table[pattern, count] of count = {
|
||||
[p1,2] = 0,
|
||||
[p2,3] = 2,
|
||||
[p3,4] = 4,
|
||||
[p4,5] = 6
|
||||
};
|
||||
|
||||
print p1;
|
||||
print p2;
|
||||
print p3;
|
||||
print p4;
|
||||
|
||||
print "-----------------";
|
||||
|
||||
for ( key in p )
|
||||
print key;
|
||||
|
||||
print "-----------------";
|
||||
|
||||
for ( key, value in t )
|
||||
print key, value;
|
||||
|
||||
print "-----------------";
|
||||
|
||||
for ( [c1, c2], value in t2)
|
||||
print c1, c2, value;
|
Loading…
Add table
Add a link
Reference in a new issue