RLIB 1.3.3: function abs() works only for integers

"Derek Giromini" <dgiromini-nkJVuyUqn/[email protected]> Thu, 12 May 2005 13:34:41 -0500
Newsgroups gmane.text.rlib.user
Message-ID <3B90249B7FEA5040A85595B1C5C4F97D0222EC@gelbermail1.gelbergroup.com>
RLIB Gurus--

The RLIB function abs() works only for integers, which explains why float values passed to this function break in our reports. I refer you to pcode_op_functions.c lines 688 through 701:

gint rlib_pcode_operator_abs(rlib *r, struct rlib_value_stack *vs, struct rlib_value *this_field_value) {
    689         struct rlib_value *v1, rval_rtn;
    690         v1 = rlib_value_stack_pop(vs);
    691         if(RLIB_VALUE_IS_NUMBER(v1)) {
    692                 gint64 result = abs(RLIB_VALUE_GET_AS_NUMBER(v1));
    693                 rlib_value_free(v1);
    694                 rlib_value_stack_push(vs, rlib_value_new_number(&rval_rtn, result));
    695                 return TRUE;
    696         }
    697         rlib_pcode_operator_fatal_execption("abs", 1, v1, NULL, NULL);
    698         rlib_value_free(v1);
    699         rlib_value_stack_push(vs, rlib_value_new_error(&rval_rtn));
    700         return FALSE;
    701 }

It calls only the standard abs() function and doesn't attempt to check if the number is a double so that it could instead call the standard fabs() function.

I could take a crack at fixing this if you'd prefer, but I wanted to bring it to your attention.

Cheers

--
Derek Giromini
Gelber Group, L.L.C.
desk: +1.312.692.2843
pager: +1.312.689.0378