1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-04-28 12:55:19 +02:00

48723: locale-safe recognition of "Inf" and "NaN" constants in math

This commit is contained in:
Vincent Lefevre 2021-05-15 14:11:49 -07:00 committed by Bart Schaefer
parent db36149006
commit 4fa4dcad17
2 changed files with 9 additions and 2 deletions

View File

@ -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

View File

@ -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;