leading/trailing whitespace handling
Closed / Duplicate1360532fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 21 years ago
Descriptionplain2005-11-18 20:16:31
bug present in both branches: % string is double 1\u00a0 1 % expr 1\u00a0 syntax error in expression "1 ": extra tokens at end of expression
dgpplain2005-11-19 23:43:18
Logged In: YES user_id=80530 contrast with % string is double \u00a01 0 % expr \u00a01 syntax error in expression " 1": character not legal in expressions which is consistent, but possibly wrong.
marttjplain2005-11-24 07:36:22
Logged In: YES
user_id=114531
I find this very confusing. Is this really a bug? The code
for [string is integer] and [string is double] both seem to
specifically allow trailing whitespace. The man page makes
no mention of this, though.
Why was trailing white space ever allowed? Allowing it
means I cannot safely do this:
if {[string is double $d]} {
set x [expr $d + 1]
}
Since trailing white space has been allowed for a long time,
there could be code out there that does this:
if {[string is double $d]} {
incr d
}
This currently works, but would be broken if trailing white
space was disallowed.
I would really like to know what the plan to fix this is.
For sure, the documentation should be updated.
dgpplain2005-11-25 22:18:37
Logged In: YES user_id=80530 Not to worry, the bug I'm reporting is the inconsistency, not the fact that trailing whitespace is permitted. I strongly suspect the "plan to fix this" will be either to make TclParseNumber ([expr]) more accepting of all kinds of whitespace to match [string is], or if that's difficult, or raises other problems, just leave things as they are. Removing the acceptance of whitespace is not an option in the 8.x series of releases, and likely not an option even after that.
dgpplain2005-12-20 01:27:56
Logged In: YES user_id=80530 patch @ 1382287 fixes this. Watch that report for resolution.
Log in (anonymous is fine) to add a comment.