Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2003-09-11
03:29 • Closed ticket [803968ffff]: Opt badly guesses type of null default values pl... artifact: 1eab0c5bfb user: dgp
03:13 • Ticket [803968ffff]: 4 changes artifact: 6a4e328376 user: andreas_kupries
2003-09-10
20:00 • New ticket [803968ffff]. artifact: 02ae11fd0f user: revar

Opt badly guesses type of null default values

Closed / Fixed803968ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 23 years ago
Descriptionplain2003-09-10 20:00:43
In optparse.tcl, there was an optimization made between 
CVS file version 1.8 and 1.9 that replaced the old regexp 
number pattern check with a [string is integer] check.  
Unfortunately, this will return true for null strings.  This 
breaks all code that uses opt0.4 with null string default 
values without specifying them as strings with -string.

The fix for this is to add a short test at the beginning of proc 
OptGuessType in optparse.tcl:

if {$arg == "" } {
    return string
}
andreas_kupriesplain2003-09-11 03:13:38
Logged In: YES 
user_id=75003

A better fix is to use the -strict switch for string is integer.
dgpplain2003-09-11 03:29:28
Logged In: YES 
user_id=80530


Actually Revision 1.9 only
appears in version 0.4.5 of
the opt package, which is
only part of the HEAD development,
that is, Tcl 8.5a0.

Commiting [string is ... -strict ...] fix.
Log in (anonymous is fine) to add a comment.