commit 309658f3b318912f9a29c14e008d75d5c7d05a68 from: Omar Polo date: Wed Aug 04 17:34:10 2021 UTC fix val_eq for casted integer commit - ae3939af3a33d4e6baaa0c599e8d13d5aad1b988 commit + 309658f3b318912f9a29c14e008d75d5c7d05a68 blob - 23ccf3c683e1efb510e60348929983322dd5dc63 blob + cb287e71a61d1e066699d7373ff451e5df703d1b --- script.c +++ script.c @@ -387,13 +387,27 @@ val_isnum(struct value *a) || a->type == V_U8 || a->type == V_U16 || a->type == V_U32; +} + +static inline int64_t +val_tonum(struct value *a) +{ + switch (a->type) { + case V_NUM: return a->v.num; + case V_U8: return a->v.u8; + case V_U16: return a->v.u16; + case V_U32: return a->v.u32; + default: + fprintf(stderr, "%s: given value is not a number\n", __func__); + abort(); + } } int val_eq(struct value *a, struct value *b) { if (val_isnum(a) && val_isnum(b)) - return a->v.num == b->v.num; + return val_tonum(a) == val_tonum(b); if (a->type != b->type) return 0;