about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--Src/math.c8
2 files changed, 9 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 8e241fa6a..91d45894b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2021-05-15  Bart Schaefer  <schaefer@zsh.org>
 
+	* Vincent Lefevre: 48723: Src/math.c: locale-safe recognition of
+	"Inf" and "NaN" constants
+
 	* Peter Stephenson: users/26742: Src/builtin.c: break out of
 	surrounding shell loops when "exit" is called from an exit hook
 
diff --git a/Src/math.c b/Src/math.c
index 1d0d86639..ade02d80c 100644
--- a/Src/math.c
+++ b/Src/math.c
@@ -864,13 +864,17 @@ zzlex(void)
 		p = ptr;
 		ptr = ie;
 		if (ie - p == 3) {
-		    if (strncasecmp(p, "NaN", 3) == 0) {
+		    if ((p[0] == 'N' || p[0] == 'n') &&
+			(p[1] == 'A' || p[1] == 'a') &&
+			(p[2] == 'N' || p[2] == 'n')) {
 			yyval.type = MN_FLOAT;
 			yyval.u.d = 0.0;
 			yyval.u.d /= yyval.u.d;
 			return NUM;
 		    }
-		    else if (strncasecmp(p, "Inf", 3) == 0) {
+		    else if ((p[0] == 'I' || p[0] == 'i') &&
+			     (p[1] == 'N' || p[1] == 'n') &&
+			     (p[2] == 'F' || p[2] == 'f')) {
 			yyval.type = MN_FLOAT;
 			yyval.u.d = 0.0;
 			yyval.u.d = 1.0 / yyval.u.d;