shithub: sl

Download patch

ref: 9b028cd426e8d21e57b25e4e6a098edfb1bebc94
parent: 89b1e536ebafa324208ea3f8fc594430b4ce616d
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)