Fixed the do_split bug and added a test.

* do_split was having a problem if there was another match
  after the end of the number of separators.  It would only
  return the match up to the point of the next match instead
  of the rest of the string.
This commit is contained in:
Seth Hall 2011-04-19 22:24:46 -04:00
parent 2bc5e69961
commit cba5766bc8
3 changed files with 16 additions and 1 deletions

View file

@ -225,6 +225,8 @@ Val* do_split(StringVal* str_val, RE_Matcher* re, TableVal* other_sep,
} }
Val* ind = new Val(++num, TYPE_COUNT); Val* ind = new Val(++num, TYPE_COUNT);
if ( num_sep >= max_num_sep )
offset = end_of_s-s;
a->Assign(ind, new StringVal(offset, (const char*) s)); a->Assign(ind, new StringVal(offset, (const char*) s));
Unref(ind); Unref(ind);

View file

@ -0,0 +1,4 @@
{
[2] = Testing Test (http://www.example.com),
[1] = X-Mailer
}

View file

@ -0,0 +1,9 @@
#
# @TEST-EXEC: bro %INPUT >out
# @TEST-EXEC: btest-diff out
event bro_init()
{
local a = "X-Mailer: Testing Test (http://www.example.com)";
print split1(a, /:[[:blank:]]*/);
}