[SV 65448] intcmp: Compare values instead of magnitudes

* src/function.c (func_intcmp): Reverse comparison direction when
both arguments are negative.
* tests/scripts/functions/intcmp: Add tests and remove useless ones.
This commit is contained in:
Jouke Witteveen
2024-03-24 14:08:59 -04:00
committed by Paul Smith
parent 21a538ce8f
commit bfbf169b63
2 changed files with 36 additions and 11 deletions

View File

@@ -1328,6 +1328,8 @@ func_intcmp (char *o, char **argv, const char *funcname UNUSED)
cmp = (llen > rlen) - (llen < rlen);
if (cmp == 0)
cmp = memcmp (lnum, rnum, llen);
if (lsign < 0)
cmp *= -1;
}
argv += 2;