From 4fa4dcad17f593a8def8799ad1d5258c328d9ead Mon Sep 17 00:00:00 2001 From: Vincent Lefevre Date: Sat, 15 May 2021 14:11:49 -0700 Subject: [PATCH] 48723: locale-safe recognition of "Inf" and "NaN" constants in math --- ChangeLog | 3 +++ Src/math.c | 8 ++++++-- 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 + * 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;