mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 00:58:19 +00:00
Allow the empty field separator to be empty; use in config framework.
This small change allows the empty field separator to be empty. This means that we can represent an empty list by a empty input string, which was not possible before. Before, an empty empty field separator meant that there is no empty field - to get back to this behavior one now has to set the empty field separator to a string that is guaranteed to not be part of the input data. Note that we did not use "empty" empty field separators anywhere and I am not aware of this being used by anyone - the new behavior seems like it is much more useful in practice. This also changes the config framework to interpret empty lists as... empty, instead of interpreting them as lists that have one zero-length element; this seems like the saner default.
This commit is contained in:
parent
01005e99af
commit
196994a48d
4 changed files with 8 additions and 2 deletions
|
@ -8,7 +8,9 @@ export {
|
|||
const set_separator = Input::set_separator &redef;
|
||||
|
||||
## String to use for empty fields.
|
||||
const empty_field = Input::empty_field &redef;
|
||||
## By default this is the empty string, meaning that an empty input field
|
||||
## will result in an empty set.
|
||||
const empty_field = "" &redef;
|
||||
|
||||
## Fail on file read problems. If set to true, the config
|
||||
## input reader will fail when encountering any problems
|
||||
|
|
|
@ -329,6 +329,9 @@ threading::Value* Ascii::ParseValue(const string& s, const string& name, TypeTag
|
|||
if ( separators.empty_field.size() > 0 && s.compare(separators.empty_field) == 0 )
|
||||
length = 0;
|
||||
|
||||
if ( separators.empty_field.empty() && s.empty() )
|
||||
length = 0;
|
||||
|
||||
threading::Value** lvals = new threading::Value* [length];
|
||||
|
||||
if ( type == TYPE_TABLE )
|
||||
|
|
|
@ -22,7 +22,7 @@ testinterval 60
|
|||
testtime 1507321987
|
||||
test_set a,b,c,d,erdbeerschnitzel
|
||||
test_vector 1,2,3,4,5,6
|
||||
test_set (empty)
|
||||
test_set
|
||||
test_set -
|
||||
@TEST-END-FILE
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
@load base/protocols/conn
|
||||
|
||||
redef exit_only_after_terminate = T;
|
||||
redef InputConfig::empty_field = "(empty)";
|
||||
|
||||
@TEST-START-FILE configfile
|
||||
testbool F
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue