shithub: sl

Download patch

ref: 4b75c6aaf9a17788f78215072027f53b04d727e7
parent: 10edeefbcbac6cb53205902005adbbb2a37b8cdc
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Tue Jan 21 20:59:55 EST 2025

printing: check for infinity before NaN

On m68k the isnan test returns true for infinity, which resulted
in -inf.0/+inf.0 printed as -nan.0/+nan.0.

Checking for infinity before NaN fixes it.

--- a/print.c
+++ b/print.c
@@ -565,6 +565,10 @@
 		width = 0;
 		keepz = 1;
 	}
+	if(isinf(r)){
+		strncpy(s, signbit(r) ? "-inf" : "inf", cnt);
+		return;
+	}
 	if(isnan(r)){
 		strncpy(s, signbit(r) ? "-nan" : "nan", cnt);
 		return;
@@ -683,10 +687,12 @@
 		}
 		if(!isfinite(d)){
 			const char *rep;
-			if(isnan(d))
+			if(isinf(d))
+				rep = signbit(d) ? "-inf.0" : "+inf.0";
+			else if(isnan(d))
 				rep = signbit(d) ? "-nan.0" : "+nan.0";
 			else
-				rep = signbit(d) ? "-inf.0" : "+inf.0";
+				rep = signbit(d) ? "-wtf.0" : "+wtf.0";
 			if(type == FL_floatsym && !FL(print_princ) && !weak)
 				FL(hpos) += ios_printf(f, "#%s(%s)", symbol_name(type), rep);
 			else