mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00

Using positional and vararg arguments for BIFs, it's not possible to do proper runtime type checking on them as discussed in #2425. The bifcl produced code unconditionally attempts to convert the positional arguments to StringVals, but nothing ever type checks them. Instead of improving the vararg support in Zeek script and bifcl, align cat_sep() with fmt() in making it fully vararg and do implement type checks by hand. With this change, passing wrong types for the separator and default argument isn't a fatal error anymore and the error messages are also more descriptive. It's a bit of a crutch working around varargs limitations. Fixes #2425
24 lines
351 B
Text
24 lines
351 B
Text
#
|
|
# @TEST-EXEC: zeek -b %INPUT >out
|
|
# @TEST-EXEC: btest-diff out
|
|
|
|
event zeek_init()
|
|
{
|
|
local a = "foo";
|
|
local b = 3;
|
|
local c = T;
|
|
|
|
print cat(a, b, c);
|
|
|
|
print cat();
|
|
|
|
print cat("", 3, T);
|
|
|
|
print cat_sep("|", "<empty>", a, b, c);
|
|
|
|
print cat_sep("|", "<empty>");
|
|
|
|
print cat_sep("|", "<empty>", "");
|
|
|
|
print cat_sep("|", "<empty>", "", b, c);
|
|
}
|