mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Fixed bug in do_split implementation.
Test suite succeeds!
This commit is contained in:
parent
266acde342
commit
9cfef93522
1 changed files with 1 additions and 7 deletions
|
@ -204,10 +204,6 @@ Val* do_split(StringVal* str_val, RE_Matcher* re, TableVal* other_sep,
|
||||||
if ( other_sep && other_sep->Size() > 0 )
|
if ( other_sep && other_sep->Size() > 0 )
|
||||||
other_strings = other_sep->ConvertToPureList();
|
other_strings = other_sep->ConvertToPureList();
|
||||||
|
|
||||||
// Currently let us assume that str is NUL-terminated. In
|
|
||||||
// the future we expect to change this by giving RE_Matcher a
|
|
||||||
// const char* segment.
|
|
||||||
|
|
||||||
const u_char* s = str_val->Bytes();
|
const u_char* s = str_val->Bytes();
|
||||||
int n = str_val->Len();
|
int n = str_val->Len();
|
||||||
const u_char* end_of_s = s + n;
|
const u_char* end_of_s = s + n;
|
||||||
|
@ -215,7 +211,6 @@ Val* do_split(StringVal* str_val, RE_Matcher* re, TableVal* other_sep,
|
||||||
int num_sep = 0;
|
int num_sep = 0;
|
||||||
|
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
while ( n > 0 )
|
while ( n > 0 )
|
||||||
{
|
{
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
@ -224,7 +219,7 @@ Val* do_split(StringVal* str_val, RE_Matcher* re, TableVal* other_sep,
|
||||||
while ( n > 0 &&
|
while ( n > 0 &&
|
||||||
(end_of_match = re->MatchPrefix(&s[offset], n)) <= 0 )
|
(end_of_match = re->MatchPrefix(&s[offset], n)) <= 0 )
|
||||||
{
|
{
|
||||||
// Move on to next character.
|
// Move on to next byte.
|
||||||
++offset;
|
++offset;
|
||||||
--n;
|
--n;
|
||||||
}
|
}
|
||||||
|
@ -249,7 +244,6 @@ Val* do_split(StringVal* str_val, RE_Matcher* re, TableVal* other_sep,
|
||||||
|
|
||||||
++num_sep;
|
++num_sep;
|
||||||
|
|
||||||
offset += end_of_match;
|
|
||||||
n -= end_of_match;
|
n -= end_of_match;
|
||||||
s += offset;
|
s += offset;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue