mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Merge remote-tracking branch 'markoverholser/master'
* markoverholser/master: Fix incorrect syntax for static_cast in to_count that I introduced in a previous merge Update baselines after changes to to_count and to_int fix to_count in zeek.bif to resolve conflict from bbanier's adjustment to static casting of the return from strtoull Fix tests in to_count to reflect appropriate function; add tests for 0x-formatted hex values for to_count and to_int update BIFs to_int() and to_count() to accept optional 'base' argument; allows more more exotic conversions from hex, octal, binary Fixes #4076; update BIFs to_int() and to_count() to accept optional 'base' argument for more easy conversions of strings representing (for example) hexadecimal, octal, or binary numbers
This commit is contained in:
commit
66e3232dcc
12 changed files with 46 additions and 12 deletions
18
CHANGES
18
CHANGES
|
@ -1,3 +1,21 @@
|
||||||
|
7.2.0-dev.228 | 2025-02-24 11:37:42 -0700
|
||||||
|
|
||||||
|
* Fix incorrect syntax for static_cast in to_count that I introduced in a previous merge (Mark Overholser)
|
||||||
|
|
||||||
|
* Update baselines after changes to to_count and to_int (Mark Overholser)
|
||||||
|
|
||||||
|
* fix to_count in zeek.bif to resolve conflict from bbanier's adjustment to static casting of the return from strtoull (Mark Overholser)
|
||||||
|
|
||||||
|
* Fix tests in to_count to reflect appropriate function; add tests for 0x-formatted hex values for to_count and to_int (Mark Overholser)
|
||||||
|
|
||||||
|
* update BIFs to_int() and to_count() to accept optional 'base' argument; allows more more exotic conversions from hex, octal, binary (Mark Overholser)
|
||||||
|
|
||||||
|
* Fixes #4076; update BIFs to_int() and to_count() to accept optional 'base' argument for more easy conversions of strings representing (for example) hexadecimal, octal, or binary numbers (Mark Overholser)
|
||||||
|
|
||||||
|
* geneve/functions.bif: Fix :zeek:see directive, take two (Arne Welzel, Corelight)
|
||||||
|
|
||||||
|
* geneve/functions.bif: Fix :zeek:see directive (Arne Welzel, Corelight)
|
||||||
|
|
||||||
7.2.0-dev.217 | 2025-02-22 12:33:25 -0800
|
7.2.0-dev.217 | 2025-02-22 12:33:25 -0800
|
||||||
|
|
||||||
* PacketAnalyzer::Geneve: Add get_options() (Arne Welzel, Corelight)
|
* PacketAnalyzer::Geneve: Add get_options() (Arne Welzel, Corelight)
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
7.2.0-dev.217
|
7.2.0-dev.228
|
||||||
|
|
|
@ -2608,12 +2608,12 @@ function enum_to_int%(e: any%): int
|
||||||
## Returns: The :zeek:type:`string` *str* as :zeek:type:`int`.
|
## Returns: The :zeek:type:`string` *str* as :zeek:type:`int`.
|
||||||
##
|
##
|
||||||
## .. zeek:see:: to_addr to_port to_subnet
|
## .. zeek:see:: to_addr to_port to_subnet
|
||||||
function to_int%(str: string%): int
|
function to_int%(str: string, base: count &default=10%): int
|
||||||
%{
|
%{
|
||||||
const char* s = str->CheckString();
|
const char* s = str->CheckString();
|
||||||
char* end_s;
|
char* end_s;
|
||||||
|
|
||||||
zeek_int_t i = strtoll(s, &end_s, 10);
|
zeek_int_t i = strtoll(s, &end_s, base);
|
||||||
|
|
||||||
if ( s[0] == '\0' || std::any_of(static_cast<const char*>(end_s), s + ::strlen(s),
|
if ( s[0] == '\0' || std::any_of(static_cast<const char*>(end_s), s + ::strlen(s),
|
||||||
[](char c) { return ! (c == '\0' || ::isspace(c)); }) )
|
[](char c) { return ! (c == '\0' || ::isspace(c)); }) )
|
||||||
|
@ -2676,12 +2676,12 @@ function double_to_count%(d: double%): count
|
||||||
## an invalid format.
|
## an invalid format.
|
||||||
##
|
##
|
||||||
## .. zeek:see:: to_addr to_int to_port to_subnet
|
## .. zeek:see:: to_addr to_int to_port to_subnet
|
||||||
function to_count%(str: string%): count
|
function to_count%(str: string, base: count &default=10%): count
|
||||||
%{
|
%{
|
||||||
const char* s = str->CheckString();
|
const char* s = str->CheckString();
|
||||||
char* end_s;
|
char* end_s;
|
||||||
|
|
||||||
uint64_t u = static_cast<uint64_t>(strtoull(s, &end_s, 10));
|
uint64_t u = static_cast<uint64_t>(strtoull(s, &end_s, base));
|
||||||
|
|
||||||
if ( s[0] == '\0' || std::any_of(static_cast<const char*>(end_s), s + ::strlen(s),
|
if ( s[0] == '\0' || std::any_of(static_cast<const char*>(end_s), s + ::strlen(s),
|
||||||
[](char c) { return ! (c == '\0' || ::isspace(c)); }) )
|
[](char c) { return ! (c == '\0' || ::isspace(c)); }) )
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
error in <...>/to_count.zeek, line 8: bad conversion to count (int_to_count(a) and -2)
|
error in <...>/to_count.zeek, line 8: bad conversion to count (int_to_count(a) and -2)
|
||||||
error in <...>/to_count.zeek, line 20: bad conversion to count (to_count() and )
|
error in <...>/to_count.zeek, line 20: bad conversion to count (to_count(, 10) and )
|
||||||
error in <...>/to_count.zeek, line 25: bad conversion to count (to_count(not a count) and not a count)
|
error in <...>/to_count.zeek, line 29: bad conversion to count (to_count(not a count, 10) and not a count)
|
||||||
|
|
|
@ -8,6 +8,10 @@
|
||||||
18446744073709551611
|
18446744073709551611
|
||||||
205
|
205
|
||||||
206
|
206
|
||||||
|
172
|
||||||
|
35
|
||||||
|
195
|
||||||
|
195
|
||||||
0
|
0
|
||||||
123
|
123
|
||||||
9223372036854775808 and 9223372036854775808 are the same
|
9223372036854775808 and 9223372036854775808 are the same
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
error in <...>/to_int.zeek, line 10: bad conversion to integer (to_int(not an int) and not an int)
|
error in <...>/to_int.zeek, line 14: bad conversion to integer (to_int(not an int, 10) and not an int)
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
1
|
1
|
||||||
-1
|
-1
|
||||||
|
188
|
||||||
|
39
|
||||||
|
243
|
||||||
|
243
|
||||||
4294967296
|
4294967296
|
||||||
0
|
0
|
||||||
205
|
205
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
error in <...>/assert.zeek, line 3: assertion failure: (coerce to_count("42") to double) == 42.5 (always failing)
|
error in <...>/assert.zeek, line 3: assertion failure: (coerce to_count("42", 10) to double) == 42.5 (always failing)
|
||||||
fatal error: errors occurred while initializing
|
fatal error: errors occurred while initializing
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
assertion_failure, to_count("5") == 4, 5 is not 4
|
assertion_failure, to_count("5", 10) == 4, 5 is not 4
|
||||||
assert <...>/assert-hook.zeek:21
|
assert <...>/assert-hook.zeek:21
|
||||||
f <...>/assert-hook.zeek:25
|
f <...>/assert-hook.zeek:25
|
||||||
g <...>/assert-hook.zeek:26
|
g <...>/assert-hook.zeek:26
|
||||||
|
|
|
@ -3,9 +3,9 @@ f, lambda_<10820400278317158366>: function() : void
|
||||||
{
|
{
|
||||||
assert 0 < getpid(), fmt("my pid is funny: %s", getpid());
|
assert 0 < getpid(), fmt("my pid is funny: %s", getpid());
|
||||||
}
|
}
|
||||||
g, lambda_<9730512750166342063>: function() : void
|
g, lambda_<16208386833253569415>: function() : void
|
||||||
{
|
{
|
||||||
assert to_count("42") == 42;
|
assert to_count("42", 10) == 42;
|
||||||
}
|
}
|
||||||
test_function, test_function: function() : void
|
test_function, test_function: function() : void
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,6 +22,10 @@ event zeek_init()
|
||||||
# We automatically trim leading, but not trailing whitespace.
|
# We automatically trim leading, but not trailing whitespace.
|
||||||
print to_count(" 205"); # Okay.
|
print to_count(" 205"); # Okay.
|
||||||
print to_count("206 "); # Error.
|
print to_count("206 "); # Error.
|
||||||
|
print to_count("10101100", 2);
|
||||||
|
print to_count("43", 8);
|
||||||
|
print to_count("C3", 16);
|
||||||
|
print to_count("0xC3", 16);
|
||||||
print to_count("not a count");
|
print to_count("not a count");
|
||||||
|
|
||||||
local e: port = 123/tcp;
|
local e: port = 123/tcp;
|
||||||
|
|
|
@ -6,6 +6,10 @@ event zeek_init()
|
||||||
{
|
{
|
||||||
print to_int("1");
|
print to_int("1");
|
||||||
print to_int("-1");
|
print to_int("-1");
|
||||||
|
print to_int("10111100", 2);
|
||||||
|
print to_int("47", 8);
|
||||||
|
print to_int("F3", 16);
|
||||||
|
print to_int("0xF3", 16);
|
||||||
print to_int("4294967296");
|
print to_int("4294967296");
|
||||||
print to_int("not an int");
|
print to_int("not an int");
|
||||||
# We automatically trim leading, but not trailing whitespace.
|
# We automatically trim leading, but not trailing whitespace.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue