Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2011-09-02
01:27 • Closed ticket [3402540fff]: expr parser and "nan()" plus 7 other c... artifact: 3114b5027b user: dgp
2011-09-01
23:07 • Ticket [3402540fff]: 4 changes artifact: e864e249c2 user: dgp
23:07 • Ticket [3402540fff]: 4 changes artifact: e32f6d6b0e user: ferrieux
23:05 • Ticket [3402540fff]: 4 changes artifact: 9b2a4f8968 user: ferrieux
23:03 • Ticket [3402540fff]: 4 changes artifact: b59e860c65 user: dgp
22:58 • Ticket [3402540fff]: 4 changes artifact: c4bd86d269 user: ferrieux
22:52 • Ticket [3402540fff]: 4 changes artifact: c60a471bfc user: ferrieux
15:40 • New ticket [3402540fff]. artifact: 94b9e875d9 user: dgp

expr parser and "nan()"

Closed / Fixed3402540fffffffffffffffffffffffffffffffffCreated 15 years agoUpdated 15 years ago
Descriptionplain2011-09-01 15:40:39
% expr {nan()}
missing operator at _@_
in expression "...es.
#
# Copyright (c) _@_"

Something's way off here, sending us
where we shouldn't be going.
ferrieuxplain2011-09-01 22:52:08
Also broken in 8.6 trunk and *not* fixed by the bug-3401704 patch.
ferrieuxplain2011-09-01 22:58:37
It goes astray because in sNANPAREN the case of en empty argument is not checked, hence the closing paren is taken as an hex digit, and the final \0 continues into the state machine...
Will fix by adding an "else" in sNANPAREN.
dgpplain2011-09-01 23:03:51
elated bugs:

% string is double nan(1,2,3,4,5)
1
% string is double nan(
1

Patch on the way.
ferrieuxplain2011-09-01 23:05:36
--- generic/tclStrToD.c
+++ generic/tclStrToD.c
@@ -1099,10 +1099,14 @@
                    d = c - '0';
                } else if (c >= 'a' && c <= 'f') {
                    d = 10 + c - 'a';
                } else if (c >= 'A' && c <= 'F') {
                    d = 10 + c - 'A';
+               } else {
+                   /* Nan(NotHex) or Nan() => we stop at Nan */
+                   /* acceptPoint and acceptLen have been set in sNAN */
+                   goto endgame;
                }
                significandWide = (significandWide << 4) + d;
                state = sNANHEX;
                break;
            }
ferrieuxplain2011-09-01 23:07:06
sorry, xed. This patch fixes it by parsing Nan() and Nan(nonhex) as "Nan"+"(...)".
Is it okay ?
dgpplain2011-09-01 23:07:19
Yes, that plus adding the missing increment
on numSigDigs.  Will commit after adding tests
as well.
dgpplain2011-09-02 01:27:59
allow_comments - 1
Log in (anonymous is fine) to add a comment.