mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 00:28:21 +00:00
Merge remote-tracking branch 'origin/topic/johanna/string_vec_null'
* origin/topic/johanna/string_vec_null: Make join_string_vec work with vectors containing empty elements. BIT-1495 #merged
This commit is contained in:
commit
ecc09c11ca
3 changed files with 12 additions and 1 deletions
|
@ -216,7 +216,13 @@ function join_string_vec%(vec: string_vec, sep: string%): string
|
||||||
if ( i > 0 )
|
if ( i > 0 )
|
||||||
d.Add(sep->CheckString(), 0);
|
d.Add(sep->CheckString(), 0);
|
||||||
|
|
||||||
v->Lookup(i)->Describe(&d);
|
Val* e = v->Lookup(i);
|
||||||
|
|
||||||
|
// If the element is empty, skip it.
|
||||||
|
if ( ! e )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
e->Describe(&d);
|
||||||
}
|
}
|
||||||
|
|
||||||
BroString* s = new BroString(1, d.TakeBytes(), d.Len());
|
BroString* s = new BroString(1, d.TakeBytes(), d.Len());
|
||||||
|
|
|
@ -4,3 +4,4 @@ mytest
|
||||||
this__is__another__test
|
this__is__another__test
|
||||||
thisisanothertest
|
thisisanothertest
|
||||||
Test
|
Test
|
||||||
|
...hi..there
|
||||||
|
|
|
@ -10,6 +10,9 @@ event bro_init()
|
||||||
local b: string_array = { [1] = "mytest" };
|
local b: string_array = { [1] = "mytest" };
|
||||||
local c: string_vec = vector( "this", "is", "another", "test" );
|
local c: string_vec = vector( "this", "is", "another", "test" );
|
||||||
local d: string_vec = vector( "Test" );
|
local d: string_vec = vector( "Test" );
|
||||||
|
local e: string_vec = vector();
|
||||||
|
e[3] = "hi";
|
||||||
|
e[5] = "there";
|
||||||
|
|
||||||
print join_string_array(" * ", a);
|
print join_string_array(" * ", a);
|
||||||
print join_string_array("", a);
|
print join_string_array("", a);
|
||||||
|
@ -18,4 +21,5 @@ event bro_init()
|
||||||
print join_string_vec(c, "__");
|
print join_string_vec(c, "__");
|
||||||
print join_string_vec(c, "");
|
print join_string_vec(c, "");
|
||||||
print join_string_vec(d, "-");
|
print join_string_vec(d, "-");
|
||||||
|
print join_string_vec(e, ".");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue