mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Support appending to vector of any
For consistency, since it already works to assign to an index within vector of any.
This commit is contained in:
parent
808f1d1524
commit
ca014d6e35
5 changed files with 31 additions and 3 deletions
4
CHANGES
4
CHANGES
|
@ -1,4 +1,8 @@
|
|||
|
||||
2.6-beta2-80 | 2018-11-07 11:46:34 -0600
|
||||
|
||||
* Support appending to vector of any (Jon Siwek, Corelight)
|
||||
|
||||
2.6-beta2-79 | 2018-11-07 10:27:00 -0600
|
||||
|
||||
* Fix coding conventions nits/typos (Vern Paxson, Corelight)
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
2.6-beta2-79
|
||||
2.6-beta2-80
|
||||
|
|
|
@ -1485,8 +1485,9 @@ AddToExpr::AddToExpr(Expr* arg_op1, Expr* arg_op2)
|
|||
ExprError("appending non-arithmetic to arithmetic vector");
|
||||
}
|
||||
|
||||
else if ( bt1 != bt2 )
|
||||
ExprError("incompatible vector append");
|
||||
else if ( bt1 != bt2 && bt1 != TYPE_ANY )
|
||||
ExprError(fmt("incompatible vector append: %s and %s",
|
||||
type_name(bt1), type_name(bt2)));
|
||||
|
||||
else
|
||||
SetType(op1->Type()->Ref());
|
||||
|
|
1
testing/btest/Baseline/language.vector-any-append/out
Normal file
1
testing/btest/Baseline/language.vector-any-append/out
Normal file
|
@ -0,0 +1 @@
|
|||
[0, 1, 2, 3]
|
22
testing/btest/language/vector-any-append.bro
Normal file
22
testing/btest/language/vector-any-append.bro
Normal file
|
@ -0,0 +1,22 @@
|
|||
# @TEST-EXEC: bro -b %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
function assign(v: vector of any)
|
||||
{
|
||||
v[|v|] = |v|;
|
||||
}
|
||||
|
||||
function append(v: vector of any)
|
||||
{
|
||||
v += |v|;
|
||||
}
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
local v: vector of count;
|
||||
assign(v);
|
||||
assign(v);
|
||||
append(v);
|
||||
append(v);
|
||||
print v;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue