mirror of
https://github.com/zeek/zeek.git
synced 2025-10-11 19:18:19 +00:00
Misc. tweaks to vector slicing implementation
* Minor style/format changes * Fix a signed/unsigned comparison compiler warning * Use a non-fatal error for non-integral slice indices so we can report any further scripting errors instead of stopping the parse right there
This commit is contained in:
parent
502ad9abc3
commit
91835752b7
5 changed files with 18 additions and 10 deletions
13
src/Expr.cc
13
src/Expr.cc
|
@ -3200,27 +3200,26 @@ void IndexExpr::Assign(Frame* f, Val* v, Opcode op)
|
|||
switch ( v1->Type()->Tag() ) {
|
||||
case TYPE_VECTOR:
|
||||
{
|
||||
const ListVal *lv = v2->AsListVal();
|
||||
const ListVal* lv = v2->AsListVal();
|
||||
VectorVal* v1_vect = v1->AsVectorVal();
|
||||
|
||||
if ( lv->Length() > 1 )
|
||||
{
|
||||
int len = v1_vect->Size();
|
||||
auto len = v1_vect->Size();
|
||||
bro_int_t first = get_slice_index(lv->Index(0)->CoerceToInt(), len);
|
||||
bro_int_t last = get_slice_index(lv->Index(1)->CoerceToInt(), len);
|
||||
|
||||
// Remove the elements from the vector within the slice
|
||||
for ( int idx = first; idx < last; idx++ )
|
||||
for ( auto idx = first; idx < last; idx++ )
|
||||
v1_vect->Remove(first);
|
||||
|
||||
// Insert the new elements starting at the first position
|
||||
VectorVal* v_vect = v->AsVectorVal();
|
||||
for ( int idx = 0; idx < v_vect->Size(); idx++, first++ )
|
||||
{
|
||||
|
||||
for ( auto idx = 0u; idx < v_vect->Size(); idx++, first++ )
|
||||
v1_vect->Insert(first, v_vect->Lookup(idx)->Ref());
|
||||
}
|
||||
}
|
||||
else if ( !v1_vect->Assign(v2, v, op) )
|
||||
else if ( ! v1_vect->Assign(v2, v, op) )
|
||||
{
|
||||
if ( v )
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue