Merge branch 'add-X-to-double' of https://github.com/ynadji/zeek

- Minor whitespace/grammar/doc tweaks during merge

* 'add-X-to-double' of https://github.com/ynadji/zeek:
  Add `count_to_double` and `int_to_double` bif functions
This commit is contained in:
Jon Siwek 2020-12-02 12:53:04 -08:00
commit 71f9340e75
6 changed files with 41 additions and 1 deletions

View file

@ -1,4 +1,8 @@
3.3.0-dev.593 | 2020-12-02 12:53:04 -0800
* Add `count_to_double` and `int_to_double` bif functions (Yacin Nadji, Corelight)
3.3.0-dev.590 | 2020-12-02 11:11:26 -0800 3.3.0-dev.590 | 2020-12-02 11:11:26 -0800
* Update minimum required CMake to 3.5 (Jon Siwek, Corelight) * Update minimum required CMake to 3.5 (Jon Siwek, Corelight)

2
NEWS
View file

@ -84,6 +84,8 @@ New Functionality
is a special version indicating that the server/client supports both SSH2 and is a special version indicating that the server/client supports both SSH2 and
SSH1. SSH1.
- Added ``count_to_double()`` and ``int_to_double()`` type-conversion BIFs.
Changed Functionality Changed Functionality
--------------------- ---------------------

View file

@ -1 +1 @@
3.3.0-dev.590 3.3.0-dev.593

View file

@ -2537,6 +2537,30 @@ function interval_to_double%(i: interval%): double
return zeek::make_intrusive<zeek::DoubleVal>(i); return zeek::make_intrusive<zeek::DoubleVal>(i);
%} %}
## Converts a :zeek:type:`count` to a :zeek:type:`double`.
##
## c: The :zeek:type:`count` to convert.
##
## Returns: The :zeek:type:`count` *c* as :zeek:type:`double`.
##
## .. zeek:see:: int_to_double double_to_count
function count_to_double%(c: count%): double
%{
return zeek::make_intrusive<zeek::DoubleVal>(c);
%}
## Converts an :zeek:type:`int` to a :zeek:type:`double`.
##
## i: The :zeek:type:`int` to convert.
##
## Returns: The :zeek:type:`int` *i* as :zeek:type:`double`.
##
## .. zeek:see:: count_to_double double_to_count
function int_to_double%(i: int%): double
%{
return zeek::make_intrusive<zeek::DoubleVal>(i);
%}
## Converts a :zeek:type:`time` value to a :zeek:type:`double`. ## Converts a :zeek:type:`time` value to a :zeek:type:`double`.
## ##
## t: The :zeek:type:`time` to convert. ## t: The :zeek:type:`time` to convert.

View file

@ -4,3 +4,6 @@
3600.0 3600.0
86400.0 86400.0
1342748947.655087 1342748947.655087
0.0
10000.0
-41.0

View file

@ -17,4 +17,11 @@ event zeek_init()
local f = current_time(); local f = current_time();
print time_to_double(f); print time_to_double(f);
local g = 0;
print count_to_double(g);
local h = 10000;
print count_to_double(h);
local i = -41;
print int_to_double(i);
} }