ref: 8574b45cc43b0880306ea853d4345d5f27dde385
parent: 6d3bbb1c8a8b1b4a465242c5af79e1d8fdaa188e
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Thu Oct 31 02:08:10 EDT 2024
OP_LT: fall back to non-numeric compare *only* if failed in numeric mode
--- a/flisp.c
+++ b/flisp.c
@@ -936,7 +936,7 @@
uint32_t bp;
const uint8_t *ip;
fixnum_t s, hi;
- int tail;
+ int tail, x;
// temporary variables (not necessary to preserve across calls)
uint32_t op, i;
@@ -1252,12 +1252,11 @@
NEXT_OP;
OP(OP_LT)
- if(bothfixnums(Stack[SP-2], Stack[SP-1]))
- v = numval(Stack[SP-2]) < numval(Stack[SP-1]) ? FL_T : FL_F;
- else
- v = numval(fl_compare(Stack[SP-2], Stack[SP-1])) < 0 ? FL_T : FL_F;
+ x = numeric_compare(Stack[SP-2], Stack[SP-1], 0, 0, 0);
+ if(x > 1)
+ x = numval(fl_compare(Stack[SP-2], Stack[SP-1]));
POPN(1);
- Stack[SP-1] = v;
+ Stack[SP-1] = x < 0 ? FL_T : FL_F;
NEXT_OP;
OP(OP_ADD2)