[Forensics-changes] [yara] 329/407: Rename double to float
Hilko Bengen
bengen at moszumanska.debian.org
Sat Jul 1 10:28:41 UTC 2017
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to annotated tag v3.3.0
in repository yara.
commit 111133d2127bdc2b9aecafd8c47e7faebe2bd186
Author: Victor M. Alvarez <plusvic at gmail.com>
Date: Thu Jan 8 15:07:38 2015 +0100
Rename double to float
"float" is a more general and easy to recognize way of referring to floating-point numbers, "double" represents an specific floating-point precision.
---
libyara/exec.c | 2 +-
libyara/grammar.c | 26 +++++++-------
libyara/grammar.y | 26 +++++++-------
libyara/include/yara/lexer.h | 2 +-
libyara/include/yara/modules.h | 37 ++++++++-----------
libyara/include/yara/object.h | 4 +--
libyara/modules/math.c | 80 +++++++++++++++++++++---------------------
libyara/modules/tests.c | 30 ++++++++++------
libyara/object.c | 16 ++++-----
libyara/parser.c | 8 ++---
yara-python/tests.py | 9 +++--
11 files changed, 122 insertions(+), 118 deletions(-)
diff --git a/libyara/exec.c b/libyara/exec.c
index e31610b..9efe38a 100644
--- a/libyara/exec.c
+++ b/libyara/exec.c
@@ -420,7 +420,7 @@ int yr_execute_code(
r1.i = ((YR_OBJECT_INTEGER*) r1.o)->value;
break;
- case OBJECT_TYPE_DOUBLE:
+ case OBJECT_TYPE_FLOAT:
if (isnan(((YR_OBJECT_DOUBLE*) r1.o)->value))
r1.i = UNDEFINED;
else
diff --git a/libyara/grammar.c b/libyara/grammar.c
index 3677ca3..b622bb7 100644
--- a/libyara/grammar.c
+++ b/libyara/grammar.c
@@ -219,9 +219,9 @@
yr_compiler_set_error_extra_info( \
compiler, "wrong type \"integer\" for " op " operator"); \
break; \
- case EXPRESSION_TYPE_DOUBLE: \
+ case EXPRESSION_TYPE_FLOAT: \
yr_compiler_set_error_extra_info( \
- compiler, "wrong type \"double\" for " op " operator"); \
+ compiler, "wrong type \"float\" for " op " operator"); \
break; \
case EXPRESSION_TYPE_STRING: \
yr_compiler_set_error_extra_info( \
@@ -2379,8 +2379,8 @@ yyreduce:
case EXPRESSION_TYPE_INTEGER:
strlcpy((yyval.c_string), "i", MAX_FUNCTION_ARGS);
break;
- case EXPRESSION_TYPE_DOUBLE:
- strlcpy((yyval.c_string), "d", MAX_FUNCTION_ARGS);
+ case EXPRESSION_TYPE_FLOAT:
+ strlcpy((yyval.c_string), "f", MAX_FUNCTION_ARGS);
break;
case EXPRESSION_TYPE_BOOLEAN:
strlcpy((yyval.c_string), "b", MAX_FUNCTION_ARGS);
@@ -2411,8 +2411,8 @@ yyreduce:
case EXPRESSION_TYPE_INTEGER:
strlcat((yyvsp[(1) - (3)].c_string), "i", MAX_FUNCTION_ARGS);
break;
- case EXPRESSION_TYPE_DOUBLE:
- strlcat((yyvsp[(1) - (3)].c_string), "d", MAX_FUNCTION_ARGS);
+ case EXPRESSION_TYPE_FLOAT:
+ strlcat((yyvsp[(1) - (3)].c_string), "f", MAX_FUNCTION_ARGS);
break;
case EXPRESSION_TYPE_BOOLEAN:
strlcat((yyvsp[(1) - (3)].c_string), "b", MAX_FUNCTION_ARGS);
@@ -3155,7 +3155,7 @@ yyreduce:
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
- (yyval.expression).type = EXPRESSION_TYPE_DOUBLE;
+ (yyval.expression).type = EXPRESSION_TYPE_FLOAT;
}
break;
@@ -3270,8 +3270,8 @@ yyreduce:
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = UNDEFINED;
break;
- case OBJECT_TYPE_DOUBLE:
- (yyval.expression).type = EXPRESSION_TYPE_DOUBLE;
+ case OBJECT_TYPE_FLOAT:
+ (yyval.expression).type = EXPRESSION_TYPE_FLOAT;
break;
case OBJECT_TYPE_STRING:
(yyval.expression).type = EXPRESSION_TYPE_STRING;
@@ -3309,7 +3309,7 @@ yyreduce:
}
else
{
- (yyval.expression).type = EXPRESSION_TYPE_DOUBLE;
+ (yyval.expression).type = EXPRESSION_TYPE_FLOAT;
}
}
break;
@@ -3330,7 +3330,7 @@ yyreduce:
}
else
{
- (yyval.expression).type = EXPRESSION_TYPE_DOUBLE;
+ (yyval.expression).type = EXPRESSION_TYPE_FLOAT;
}
}
break;
@@ -3351,7 +3351,7 @@ yyreduce:
}
else
{
- (yyval.expression).type = EXPRESSION_TYPE_DOUBLE;
+ (yyval.expression).type = EXPRESSION_TYPE_FLOAT;
}
}
break;
@@ -3372,7 +3372,7 @@ yyreduce:
}
else
{
- (yyval.expression).type = EXPRESSION_TYPE_DOUBLE;
+ (yyval.expression).type = EXPRESSION_TYPE_FLOAT;
}
}
break;
diff --git a/libyara/grammar.y b/libyara/grammar.y
index cbfc4b7..20fae0f 100644
--- a/libyara/grammar.y
+++ b/libyara/grammar.y
@@ -58,9 +58,9 @@ limitations under the License.
yr_compiler_set_error_extra_info( \
compiler, "wrong type \"integer\" for " op " operator"); \
break; \
- case EXPRESSION_TYPE_DOUBLE: \
+ case EXPRESSION_TYPE_FLOAT: \
yr_compiler_set_error_extra_info( \
- compiler, "wrong type \"double\" for " op " operator"); \
+ compiler, "wrong type \"float\" for " op " operator"); \
break; \
case EXPRESSION_TYPE_STRING: \
yr_compiler_set_error_extra_info( \
@@ -769,8 +769,8 @@ arguments_list
case EXPRESSION_TYPE_INTEGER:
strlcpy($$, "i", MAX_FUNCTION_ARGS);
break;
- case EXPRESSION_TYPE_DOUBLE:
- strlcpy($$, "d", MAX_FUNCTION_ARGS);
+ case EXPRESSION_TYPE_FLOAT:
+ strlcpy($$, "f", MAX_FUNCTION_ARGS);
break;
case EXPRESSION_TYPE_BOOLEAN:
strlcpy($$, "b", MAX_FUNCTION_ARGS);
@@ -798,8 +798,8 @@ arguments_list
case EXPRESSION_TYPE_INTEGER:
strlcat($1, "i", MAX_FUNCTION_ARGS);
break;
- case EXPRESSION_TYPE_DOUBLE:
- strlcat($1, "d", MAX_FUNCTION_ARGS);
+ case EXPRESSION_TYPE_FLOAT:
+ strlcat($1, "f", MAX_FUNCTION_ARGS);
break;
case EXPRESSION_TYPE_BOOLEAN:
strlcat($1, "b", MAX_FUNCTION_ARGS);
@@ -1458,7 +1458,7 @@ primary_expression
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
- $$.type = EXPRESSION_TYPE_DOUBLE;
+ $$.type = EXPRESSION_TYPE_FLOAT;
}
| _TEXT_STRING_
{
@@ -1558,8 +1558,8 @@ primary_expression
$$.type = EXPRESSION_TYPE_INTEGER;
$$.value.integer = UNDEFINED;
break;
- case OBJECT_TYPE_DOUBLE:
- $$.type = EXPRESSION_TYPE_DOUBLE;
+ case OBJECT_TYPE_FLOAT:
+ $$.type = EXPRESSION_TYPE_FLOAT;
break;
case OBJECT_TYPE_STRING:
$$.type = EXPRESSION_TYPE_STRING;
@@ -1594,7 +1594,7 @@ primary_expression
}
else
{
- $$.type = EXPRESSION_TYPE_DOUBLE;
+ $$.type = EXPRESSION_TYPE_FLOAT;
}
}
| primary_expression '-' primary_expression
@@ -1612,7 +1612,7 @@ primary_expression
}
else
{
- $$.type = EXPRESSION_TYPE_DOUBLE;
+ $$.type = EXPRESSION_TYPE_FLOAT;
}
}
| primary_expression '*' primary_expression
@@ -1630,7 +1630,7 @@ primary_expression
}
else
{
- $$.type = EXPRESSION_TYPE_DOUBLE;
+ $$.type = EXPRESSION_TYPE_FLOAT;
}
}
| primary_expression '\\' primary_expression
@@ -1648,7 +1648,7 @@ primary_expression
}
else
{
- $$.type = EXPRESSION_TYPE_DOUBLE;
+ $$.type = EXPRESSION_TYPE_FLOAT;
}
}
| primary_expression '%' primary_expression
diff --git a/libyara/include/yara/lexer.h b/libyara/include/yara/lexer.h
index e10dcb1..a186664 100644
--- a/libyara/include/yara/lexer.h
+++ b/libyara/include/yara/lexer.h
@@ -56,7 +56,7 @@ typedef void* yyscan_t;
#define EXPRESSION_TYPE_STRING 3
#define EXPRESSION_TYPE_REGEXP 4
#define EXPRESSION_TYPE_OBJECT 5
-#define EXPRESSION_TYPE_DOUBLE 6
+#define EXPRESSION_TYPE_FLOAT 6
typedef struct _EXPRESSION
{
diff --git a/libyara/include/yara/modules.h b/libyara/include/yara/modules.h
index 2f2b0d8..2473033 100644
--- a/libyara/include/yara/modules.h
+++ b/libyara/include/yara/modules.h
@@ -131,15 +131,6 @@ limitations under the License.
}
-#define declare_double(name) { \
- FAIL_ON_ERROR(yr_object_create( \
- OBJECT_TYPE_DOUBLE, \
- name, \
- stack[stack_top], \
- NULL)); \
- }
-
-
#define declare_integer_array(name) { \
YR_OBJECT* array; \
FAIL_ON_ERROR(yr_object_create( \
@@ -170,16 +161,16 @@ limitations under the License.
}
-#define declare_double(name) { \
+#define declare_float(name) { \
FAIL_ON_ERROR(yr_object_create( \
- OBJECT_TYPE_DOUBLE, \
+ OBJECT_TYPE_FLOAT, \
name, \
stack[stack_top], \
NULL)); \
}
-#define declare_double_array(name) { \
+#define declare_float_array(name) { \
YR_OBJECT* array; \
FAIL_ON_ERROR(yr_object_create( \
OBJECT_TYPE_ARRAY, \
@@ -187,14 +178,14 @@ limitations under the License.
stack[stack_top], \
&array)); \
FAIL_ON_ERROR(yr_object_create( \
- OBJECT_TYPE_DOUBLE, \
+ OBJECT_TYPE_FLOAT, \
name, \
array, \
NULL)); \
}
-#define declare_double_dictionary(name) { \
+#define declare_float_dictionary(name) { \
YR_OBJECT* dict; \
FAIL_ON_ERROR(yr_object_create( \
OBJECT_TYPE_DICTIONARY, \
@@ -202,7 +193,7 @@ limitations under the License.
stack[stack_top], \
&dict)); \
FAIL_ON_ERROR(yr_object_create( \
- OBJECT_TYPE_DOUBLE, \
+ OBJECT_TYPE_FLOAT, \
name, \
dict, \
NULL)); \
@@ -276,7 +267,7 @@ limitations under the License.
#define integer_argument(n) \
(((int64_t*) __args)[n-1])
-#define double_argument(n) \
+#define float_argument(n) \
(((double*) __args)[n-1])
#define regexp_argument(n) \
@@ -310,8 +301,8 @@ limitations under the License.
yr_object_get_integer(object, __VA_ARGS__)
-#define get_double(object, ...) \
- yr_object_get_double(object, __VA_ARGS__)
+#define get_float(object, ...) \
+ yr_object_get_float(object, __VA_ARGS__)
#define get_string(object, ...) \
@@ -322,8 +313,8 @@ limitations under the License.
yr_object_set_integer(value, object, __VA_ARGS__)
-#define set_double(value, object, ...) \
- yr_object_set_double(value, object, __VA_ARGS__)
+#define set_float(value, object, ...) \
+ yr_object_set_float(value, object, __VA_ARGS__)
#define set_sized_string(value, len, object, ...) \
@@ -346,12 +337,12 @@ limitations under the License.
}
-#define return_double(double_) { \
+#define return_float(double_) { \
assertf( \
- __function_obj->return_obj->type == OBJECT_TYPE_DOUBLE, \
+ __function_obj->return_obj->type == OBJECT_TYPE_FLOAT, \
"return type differs from function declaration"); \
double d = (double) (double_); \
- yr_object_set_double( \
+ yr_object_set_float( \
(d != (double) UNDEFINED) ? d : NAN, \
__function_obj->return_obj, \
NULL); \
diff --git a/libyara/include/yara/object.h b/libyara/include/yara/object.h
index 7929529..07a0340 100644
--- a/libyara/include/yara/object.h
+++ b/libyara/include/yara/object.h
@@ -29,7 +29,7 @@ limitations under the License.
#define OBJECT_TYPE_FUNCTION 5
#define OBJECT_TYPE_REGEXP 6
#define OBJECT_TYPE_DICTIONARY 7
-#define OBJECT_TYPE_DOUBLE 8
+#define OBJECT_TYPE_FLOAT 8
int yr_object_create(
@@ -93,7 +93,7 @@ void yr_object_set_integer(
...);
-void yr_object_set_double(
+void yr_object_set_float(
double value,
YR_OBJECT* object,
const char* field,
diff --git a/libyara/modules/math.c b/libyara/modules/math.c
index 1838440..dc9c190 100644
--- a/libyara/modules/math.c
+++ b/libyara/modules/math.c
@@ -32,7 +32,7 @@ define_function(string_entropy)
uint32_t* data = (uint32_t*) yr_calloc(256, sizeof(uint32_t));
if (data == NULL)
- return_double(UNDEFINED);
+ return_float(UNDEFINED);
for (int i = 0; i < s->length; i++)
{
@@ -52,7 +52,7 @@ define_function(string_entropy)
}
yr_free(data);
- return_double(entropy);
+ return_float(entropy);
}
@@ -72,7 +72,7 @@ define_function(data_entropy)
uint32_t* data = (uint32_t*) yr_calloc(256, sizeof(uint32_t));
if (data == NULL)
- return_double(UNDEFINED);
+ return_float(UNDEFINED);
bool past_first_block = false;
uint64_t total_len = 0;
@@ -106,7 +106,7 @@ define_function(data_entropy)
// undefined.
yr_free(data);
- return_double(UNDEFINED);
+ return_float(UNDEFINED);
}
if (block->base + block->size > offset + length)
@@ -116,7 +116,7 @@ define_function(data_entropy)
if (!past_first_block)
{
yr_free(data);
- return_double(UNDEFINED);
+ return_float(UNDEFINED);
}
double entropy = 0.0;
@@ -131,20 +131,20 @@ define_function(data_entropy)
}
yr_free(data);
- return_double(entropy);
+ return_float(entropy);
}
define_function(string_deviation)
{
SIZED_STRING* s = sized_string_argument(1);
- double mean = double_argument(2);
+ double mean = float_argument(2);
double sum = 0.0;
for (int i = 0; i < s->length; i++)
sum += fabs(((double) s->c_string[i]) - mean);
- return_double(sum / s->length);
+ return_float(sum / s->length);
}
@@ -153,7 +153,7 @@ define_function(data_deviation)
int64_t offset = integer_argument(1);
int64_t length = integer_argument(2);
- double mean = double_argument(3);
+ double mean = float_argument(3);
double sum = 0.0;
YR_SCAN_CONTEXT* context = scan_context();
@@ -191,7 +191,7 @@ define_function(data_deviation)
// the checksum over a range of non contiguos blocks. As
// range contains gaps of undefined data the checksum is
// undefined.
- return_double(UNDEFINED);
+ return_float(UNDEFINED);
}
if (block->base + block->size > offset + length)
@@ -199,9 +199,9 @@ define_function(data_deviation)
}
if (!past_first_block)
- return_double(UNDEFINED);
+ return_float(UNDEFINED);
- return_double(sum / total_len);
+ return_float(sum / total_len);
}
@@ -214,7 +214,7 @@ define_function(string_mean)
for (int i = 0; i < s->length; i++)
sum += (double) s->c_string[i];
- return_double(sum / s->length);
+ return_float(sum / s->length);
}
@@ -259,7 +259,7 @@ define_function(data_mean)
// the checksum over a range of non contiguos blocks. As
// range contains gaps of undefined data the checksum is
// undefined.
- return_double(UNDEFINED);
+ return_float(UNDEFINED);
}
if (block->base + block->size > offset + length)
@@ -267,9 +267,9 @@ define_function(data_mean)
}
if (!past_first_block)
- return_double(UNDEFINED);
+ return_float(UNDEFINED);
- return_double(sum / total_len);
+ return_float(sum / total_len);
}
@@ -325,7 +325,7 @@ define_function(data_serial_correlation)
// the checksum over a range of non contiguos blocks. As
// range contains gaps of undefined data the checksum is
// undefined.
- return_double(UNDEFINED);
+ return_float(UNDEFINED);
}
if (block->base + block->size > offset + length)
@@ -333,7 +333,7 @@ define_function(data_serial_correlation)
}
if (!past_first_block)
- return_double(UNDEFINED);
+ return_float(UNDEFINED);
scct1 += scclast * sccun;
scct2 *= scct2;
@@ -345,7 +345,7 @@ define_function(data_serial_correlation)
else
scc = (total_len * scct1 - scct2) / scc;
- return_double(scc);
+ return_float(scc);
}
@@ -378,7 +378,7 @@ define_function(string_serial_correlation)
else
scc = (s->length * scct1 - scct2) / scc;
- return_double(scc);
+ return_float(scc);
}
@@ -446,7 +446,7 @@ define_function(data_monte_carlo_pi)
// the checksum over a range of non contiguos blocks. As
// range contains gaps of undefined data the checksum is
// undefined.
- return_double(UNDEFINED);
+ return_float(UNDEFINED);
}
if (block->base + block->size > offset + length)
@@ -454,11 +454,11 @@ define_function(data_monte_carlo_pi)
}
if (!past_first_block)
- return_double(UNDEFINED);
+ return_float(UNDEFINED);
double mpi = 4.0 * ((double) inmont / mcount);
- return_double(fabs((mpi - PI) / PI));
+ return_float(fabs((mpi - PI) / PI));
}
@@ -495,15 +495,15 @@ define_function(string_monte_carlo_pi)
}
double mpi = 4.0 * ((double) inmont / mcount);
- return_double(fabs((mpi - PI) / PI));
+ return_float(fabs((mpi - PI) / PI));
}
define_function(in_range)
{
- double test = double_argument(1);
- double lower = double_argument(2);
- double upper = double_argument(3);
+ double test = float_argument(1);
+ double lower = float_argument(2);
+ double upper = float_argument(3);
return_integer((lower <= test && test <= upper) ? 1 : 0);
}
@@ -511,18 +511,18 @@ define_function(in_range)
begin_declarations;
- declare_double("MEAN_BYTES");
- declare_function("in_range", "ddd", "i", in_range);
- declare_function("deviation", "iid", "d", data_deviation);
- declare_function("deviation", "sd", "d", string_deviation);
- declare_function("mean", "ii", "d", data_mean);
- declare_function("mean", "s", "d", string_mean);
- declare_function("serial_correlation", "ii", "d", data_serial_correlation);
- declare_function("serial_correlation", "s", "d", string_serial_correlation);
- declare_function("monte_carlo_pi", "ii", "d", data_monte_carlo_pi);
- declare_function("monte_carlo_pi", "s", "d", string_monte_carlo_pi);
- declare_function("entropy", "ii", "d", data_entropy);
- declare_function("entropy", "s", "d", string_entropy);
+ declare_float("MEAN_BYTES");
+ declare_function("in_range", "fff", "i", in_range);
+ declare_function("deviation", "iif", "f", data_deviation);
+ declare_function("deviation", "sf", "f", string_deviation);
+ declare_function("mean", "ii", "f", data_mean);
+ declare_function("mean", "s", "f", string_mean);
+ declare_function("serial_correlation", "ii", "f", data_serial_correlation);
+ declare_function("serial_correlation", "s", "f", string_serial_correlation);
+ declare_function("monte_carlo_pi", "ii", "f", data_monte_carlo_pi);
+ declare_function("monte_carlo_pi", "s", "f", string_monte_carlo_pi);
+ declare_function("entropy", "ii", "f", data_entropy);
+ declare_function("entropy", "s", "f", string_entropy);
end_declarations;
@@ -547,7 +547,7 @@ int module_load(
void* module_data,
size_t module_data_size)
{
- set_double(127.5, module_object, "MEAN_BYTES");
+ set_float(127.5, module_object, "MEAN_BYTES");
return ERROR_SUCCESS;
}
diff --git a/libyara/modules/tests.c b/libyara/modules/tests.c
index 9481e54..e36a6da 100644
--- a/libyara/modules/tests.c
+++ b/libyara/modules/tests.c
@@ -19,15 +19,24 @@ limitations under the License.
#define MODULE_NAME tests
-define_function(double_sum)
+define_function(fsum_2)
{
- double a = double_argument(1);
- double b = double_argument(2);
+ double a = float_argument(1);
+ double b = float_argument(2);
- return_double(a + b);
+ return_float(a + b);
}
-define_function(sum_2)
+define_function(fsum_3)
+{
+ double a = float_argument(1);
+ double b = float_argument(2);
+ double c = float_argument(2);
+
+ return_float(a + b + c);
+}
+
+define_function(isum_2)
{
int64_t a = integer_argument(1);
int64_t b = integer_argument(2);
@@ -36,7 +45,7 @@ define_function(sum_2)
}
-define_function(sum_3)
+define_function(isum_3)
{
int64_t a = integer_argument(1);
int64_t b = integer_argument(2);
@@ -63,7 +72,7 @@ begin_declarations;
begin_struct("undefined");
declare_integer("i");
- declare_double("d");
+ declare_float("f");
end_struct("undefined");
declare_integer_array("integer_array");
@@ -82,10 +91,11 @@ begin_declarations;
declare_string("s");
end_struct_dictionary("struct_dict");
- declare_function("sum", "ii", "i", sum_2);
- declare_function("sum", "iii", "i", sum_3);
+ declare_function("isum", "ii", "i", isum_2);
+ declare_function("isum", "iii", "i", isum_3);
+ declare_function("fsum", "ff", "f", fsum_2);
+ declare_function("fsum", "fff", "f", fsum_3);
declare_function("length", "s", "i", length);
- declare_function("double_sum", "dd", "d", double_sum);
end_declarations;
diff --git a/libyara/object.c b/libyara/object.c
index 442bdb0..1b17227 100644
--- a/libyara/object.c
+++ b/libyara/object.c
@@ -58,7 +58,7 @@ int yr_object_create(
case OBJECT_TYPE_INTEGER:
object_size = sizeof(YR_OBJECT_INTEGER);
break;
- case OBJECT_TYPE_DOUBLE:
+ case OBJECT_TYPE_FLOAT:
object_size = sizeof(YR_OBJECT_DOUBLE);
break;
case OBJECT_TYPE_STRING:
@@ -106,7 +106,7 @@ int yr_object_create(
case OBJECT_TYPE_INTEGER:
((YR_OBJECT_INTEGER*) obj)->value = UNDEFINED;
break;
- case OBJECT_TYPE_DOUBLE:
+ case OBJECT_TYPE_FLOAT:
((YR_OBJECT_DOUBLE*) obj)->value = NAN;
break;
case OBJECT_TYPE_STRING:
@@ -180,7 +180,7 @@ int yr_object_function_create(
return_type = OBJECT_TYPE_STRING;
break;
case 'd':
- return_type = OBJECT_TYPE_DOUBLE;
+ return_type = OBJECT_TYPE_FLOAT;
break;
default:
return ERROR_INVALID_FORMAT;
@@ -843,7 +843,7 @@ int yr_object_has_undefined_value(
switch(field_obj->type)
{
- case OBJECT_TYPE_DOUBLE:
+ case OBJECT_TYPE_FLOAT:
return isnan(((YR_OBJECT_DOUBLE*) field_obj)->value);
case OBJECT_TYPE_STRING:
return ((YR_OBJECT_STRING*) field_obj)->value == NULL;
@@ -882,7 +882,7 @@ int64_t yr_object_get_integer(
}
-double yr_object_get_double(
+double yr_object_get_float(
YR_OBJECT* object,
const char* field,
...)
@@ -902,7 +902,7 @@ double yr_object_get_double(
if (double_obj == NULL)
return NAN;
- assertf(double_obj->type == OBJECT_TYPE_DOUBLE,
+ assertf(double_obj->type == OBJECT_TYPE_FLOAT,
"type of \"%s\" is not double\n", field);
return ((YR_OBJECT_DOUBLE*) double_obj)->value;
@@ -962,7 +962,7 @@ void yr_object_set_integer(
}
-void yr_object_set_double(
+void yr_object_set_float(
double value,
YR_OBJECT* object,
const char* field,
@@ -982,7 +982,7 @@ void yr_object_set_double(
va_end(args);
assert(double_obj != NULL);
- assert(double_obj->type == OBJECT_TYPE_DOUBLE);
+ assert(double_obj->type == OBJECT_TYPE_FLOAT);
((YR_OBJECT_DOUBLE*) double_obj)->value = value;
}
diff --git a/libyara/parser.c b/libyara/parser.c
index 181b043..a9d9ce4 100644
--- a/libyara/parser.c
+++ b/libyara/parser.c
@@ -965,7 +965,7 @@ int _yr_parser_operator_to_opcode(
case EXPRESSION_TYPE_INTEGER:
opcode = OP_INT_BEGIN;
break;
- case EXPRESSION_TYPE_DOUBLE:
+ case EXPRESSION_TYPE_FLOAT:
opcode = OP_DBL_BEGIN;
break;
case EXPRESSION_TYPE_STRING:
@@ -1031,9 +1031,9 @@ int yr_parser_reduce_operation(
YR_COMPILER* compiler = yyget_extra(yyscanner);
if ((left_operand.type == EXPRESSION_TYPE_INTEGER ||
- left_operand.type == EXPRESSION_TYPE_DOUBLE) &&
+ left_operand.type == EXPRESSION_TYPE_FLOAT) &&
(right_operand.type == EXPRESSION_TYPE_INTEGER ||
- right_operand.type == EXPRESSION_TYPE_DOUBLE))
+ right_operand.type == EXPRESSION_TYPE_FLOAT))
{
if (left_operand.type != right_operand.type)
{
@@ -1049,7 +1049,7 @@ int yr_parser_reduce_operation(
if (compiler->last_result == ERROR_SUCCESS)
{
- int expression_type = EXPRESSION_TYPE_DOUBLE;
+ int expression_type = EXPRESSION_TYPE_FLOAT;
if (left_operand.type == EXPRESSION_TYPE_INTEGER &&
right_operand.type == EXPRESSION_TYPE_INTEGER)
diff --git a/yara-python/tests.py b/yara-python/tests.py
index 6e26c3e..20220a7 100644
--- a/yara-python/tests.py
+++ b/yara-python/tests.py
@@ -760,14 +760,17 @@ class TestYara(unittest.TestCase):
'import "tests" rule test { condition: tests.string_array[2] == "baz"}',
'import "tests" rule test { condition: tests.string_dict["foo"] == "foo"}',
'import "tests" rule test { condition: tests.string_dict["bar"] == "bar"}',
- 'import "tests" rule test { condition: tests.sum(1,2) == 3}',
- 'import "tests" rule test { condition: tests.sum(1,2,3) == 6}',
+ 'import "tests" rule test { condition: tests.isum(1,2) == 3}',
+ 'import "tests" rule test { condition: tests.isum(1,2,3) == 6}',
+ 'import "tests" rule test { condition: tests.fsum(1.0,2.0) == 3.0}',
+ 'import "tests" rule test { condition: tests.fsum(1.0,2.0,3.0) == 6.0}',
'import "tests" rule test { condition: tests.length("dummy") == 5}',
])
self.assertFalseRules([
'import "tests" rule test { condition: tests.struct_array[0].i == 1 }',
- 'import "tests" rule test { condition: tests.sum(1,1) == 3}',
+ 'import "tests" rule test { condition: tests.isum(1,1) == 3}',
+ 'import "tests" rule test { condition: tests.fsum(1.0,1.0) == 3.0}',
])
def testIntegerFunctions(self):
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/forensics/yara.git
More information about the forensics-changes
mailing list