summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Lefevre <vincent@vinc17.net>2021-05-15 14:11:49 -0700
committerBart Schaefer <schaefer@ipost.com>2021-05-15 14:11:49 -0700
commit4fa4dcad17f593a8def8799ad1d5258c328d9ead (patch)
treeefcfb9a34916f69fdc067a2a0264979db005fb27
parentdb3614900602b51edd79ae8c1308b8665de9f913 (diff)
downloadzsh-4fa4dcad17f593a8def8799ad1d5258c328d9ead.tar.gz
zsh-4fa4dcad17f593a8def8799ad1d5258c328d9ead.zip
48723: locale-safe recognition of "Inf" and "NaN" constants in math
-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;