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

* 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
30 lines
711 B
Text
30 lines
711 B
Text
# @TEST-EXEC: zeek -b %INPUT 1>out 2>err
|
|
# @TEST-EXEC: btest-diff out
|
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=${SCRIPTS}/diff-remove-abspath btest-diff err
|
|
|
|
event zeek_init()
|
|
{
|
|
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("not an int");
|
|
# We automatically trim leading, but not trailing whitespace.
|
|
print to_int(" 205"); # Okay.
|
|
print to_int("206 "); # Error.
|
|
|
|
local a: double = 3.14;
|
|
print double_to_int(a);
|
|
|
|
local b: double = 3.9;
|
|
print double_to_int(b);
|
|
|
|
local c: double = -3.14;
|
|
print double_to_int(c);
|
|
|
|
local d: double = -3.9;
|
|
print double_to_int(d);
|
|
}
|