summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorwelch <welch>1998-06-29 15:30:16 (GMT)
committerwelch <welch>1998-06-29 15:30:16 (GMT)
commit9f3869587887d7104addbb0423000d468cc198bd (patch)
treee5d2957e0ca63321138bf46f64ce92c4f8d13b2d /library
parent456c19cd15beb3a33e96c9d0d22b3b29acca121f (diff)
downloadtcl-9f3869587887d7104addbb0423000d468cc198bd.zip
tcl-9f3869587887d7104addbb0423000d468cc198bd.tar.gz
tcl-9f3869587887d7104addbb0423000d468cc198bd.tar.bz2
expr bracing
Diffstat (limited to 'library')
-rw-r--r--library/http/http.tcl30
-rw-r--r--library/http1.0/http.tcl32
-rw-r--r--library/http2.0/http.tcl30
-rw-r--r--library/http2.1/http.tcl30
-rw-r--r--library/http2.3/http.tcl30
-rw-r--r--library/opt0.1/optparse.tcl49
-rw-r--r--library/opt0.1/pkgIndex.tcl2
7 files changed, 104 insertions, 99 deletions
diff --git a/library/http/http.tcl b/library/http/http.tcl
index 79c83c3..222e127 100644
--- a/library/http/http.tcl
+++ b/library/http/http.tcl
@@ -9,7 +9,7 @@
# See the file "license.terms" for information on usage and
# redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# SCCS: @(#) http.tcl 1.8 97/10/28 16:23:30
+# SCCS: %Z% $Id: http.tcl,v 1.2 1998/06/29 15:30:16 welch Exp $
package provide http 2.0 ;# This uses Tcl namespaces
@@ -73,7 +73,7 @@ proc http::config {args} {
}
} else {
foreach {flag value} $args {
- if [regexp -- $pat $flag] {
+ if {[regexp -- $pat $flag]} {
set http($flag) $value
} else {
return -code error "Unknown option $flag, must be: $usage"
@@ -140,7 +140,7 @@ proc http::reset { token {why reset} } {
proc http::geturl { url args } {
variable http
- if ![info exists http(uid)] {
+ if {![info exists http(uid)]} {
set http(uid) 0
}
set token [namespace current]::[incr http(uid)]
@@ -166,7 +166,7 @@ proc http::geturl { url args } {
regsub -all -- - $options {} options
set pat ^-([join $options |])$
foreach {flag value} $args {
- if [regexp $pat $flag] {
+ if {[regexp $pat $flag]} {
# Validate numbers
if {[info exists state($flag)] && \
[regexp {^[0-9]+$} $state($flag)] && \
@@ -285,7 +285,7 @@ proc http::size {token} {
upvar 0 $token state
set s $state(sock)
- if [::eof $s] then {
+ if {[::eof $s]} {
Eof $token
return
}
@@ -293,7 +293,7 @@ proc http::size {token} {
set n [gets $s line]
if {$n == 0} {
set state(state) body
- if ![regexp -nocase ^text $state(type)] {
+ if {![regexp -nocase ^text $state(type)]} {
# Turn off conversions for non-text data
fconfigure $s -translation binary
if {[info exists state(-channel)]} {
@@ -307,20 +307,20 @@ proc http::size {token} {
CopyStart $s $token
}
} elseif {$n > 0} {
- if [regexp -nocase {^content-type:(.+)$} $line x type] {
+ if {[regexp -nocase {^content-type:(.+)$} $line x type]} {
set state(type) [string trim $type]
}
- if [regexp -nocase {^content-length:(.+)$} $line x length] {
+ if {[regexp -nocase {^content-length:(.+)$} $line x length]} {
set state(totalsize) [string trim $length]
}
- if [regexp -nocase {^([^:]+):(.+)$} $line x key value] {
+ if {[regexp -nocase {^([^:]+):(.+)$} $line x key value]} {
lappend state(meta) $key $value
} elseif {[regexp ^HTTP $line]} {
set state(http) $line
}
}
} else {
- if [catch {
+ if {[catch {
if {[info exists state(-handler)]} {
set n [eval $state(-handler) {$s $token}]
} else {
@@ -333,10 +333,10 @@ proc http::size {token} {
if {$n >= 0} {
incr state(currentsize) $n
}
- } err] {
+ } err]} {
Finish $token $err
} else {
- if [info exists state(-progress)] {
+ if {[info exists state(-progress)]} {
eval $state(-progress) {$token $state(totalsize) $state(currentsize)}
}
}
@@ -345,10 +345,10 @@ proc http::size {token} {
proc http::CopyStart {s token} {
variable $token
upvar 0 $token state
- if [catch {
+ if {[catch {
fcopy $s $state(-channel) -size $state(-blocksize) -command \
[list http::CopyDone $token]
- } err] {
+ } err]} {
Finish $token $err
}
}
@@ -357,7 +357,7 @@ proc http::size {token} {
upvar 0 $token state
set s $state(sock)
incr state(currentsize) $count
- if [info exists state(-progress)] {
+ if {[info exists state(-progress)]} {
eval $state(-progress) {$token $state(totalsize) $state(currentsize)}
}
if {([string length $error] != 0)} {
diff --git a/library/http1.0/http.tcl b/library/http1.0/http.tcl
index f6dd351..7ee62cd 100644
--- a/library/http1.0/http.tcl
+++ b/library/http1.0/http.tcl
@@ -5,7 +5,7 @@
# These procedures use a callback interface to avoid using vwait,
# which is not defined in the safe base.
#
-# SCCS: @(#) http.tcl 1.10 97/10/29 16:12:55
+# SCCS: %Z% $Id: http.tcl,v 1.2 1998/06/29 15:30:24 welch Exp $
#
# See the http.n man page for documentation
@@ -40,7 +40,7 @@ proc http_config {args} {
}
} else {
foreach {flag value} $args {
- if [regexp -- $pat $flag] {
+ if {[regexp -- $pat $flag]} {
set http($flag) $value
} else {
return -code error "Unknown option $flag, must be: $usage"
@@ -81,7 +81,7 @@ proc http_reset { token {why reset} } {
}
proc http_get { url args } {
global http
- if ![info exists http(uid)] {
+ if {![info exists http(uid)]} {
set http(uid) 0
}
set token http#[incr http(uid)]
@@ -106,7 +106,7 @@ proc http_get { url args } {
regsub -all -- - $options {} options
set pat ^-([join $options |])$
foreach {flag value} $args {
- if [regexp $pat $flag] {
+ if {[regexp $pat $flag]} {
# Validate numbers
if {[info exists state($flag)] && \
[regexp {^[0-9]+$} $state($flag)] && \
@@ -213,7 +213,7 @@ proc http_size {token} {
upvar #0 $token state
set s $state(sock)
- if [eof $s] then {
+ if {[eof $s]} {
httpEof $token
return
}
@@ -221,7 +221,7 @@ proc http_size {token} {
set n [gets $s line]
if {$n == 0} {
set state(state) body
- if ![regexp -nocase ^text $state(type)] {
+ if {![regexp -nocase ^text $state(type)]} {
# Turn off conversions for non-text data
fconfigure $s -translation binary
if {[info exists state(-channel)]} {
@@ -235,20 +235,20 @@ proc http_size {token} {
httpCopyStart $s $token
}
} elseif {$n > 0} {
- if [regexp -nocase {^content-type:(.+)$} $line x type] {
+ if {[regexp -nocase {^content-type:(.+)$} $line x type]} {
set state(type) [string trim $type]
}
- if [regexp -nocase {^content-length:(.+)$} $line x length] {
+ if {[regexp -nocase {^content-length:(.+)$} $line x length]} {
set state(totalsize) [string trim $length]
}
- if [regexp -nocase {^([^:]+):(.+)$} $line x key value] {
+ if {[regexp -nocase {^([^:]+):(.+)$} $line x key value]} {
lappend state(meta) $key $value
} elseif {[regexp ^HTTP $line]} {
set state(http) $line
}
}
} else {
- if [catch {
+ if {[catch {
if {[info exists state(-handler)]} {
set n [eval $state(-handler) {$s $token}]
} else {
@@ -261,10 +261,10 @@ proc http_size {token} {
if {$n >= 0} {
incr state(currentsize) $n
}
- } err] {
+ } err]} {
httpFinish $token $err
} else {
- if [info exists state(-progress)] {
+ if {[info exists state(-progress)]} {
eval $state(-progress) {$token $state(totalsize) $state(currentsize)}
}
}
@@ -272,10 +272,10 @@ proc http_size {token} {
}
proc httpCopyStart {s token} {
upvar #0 $token state
- if [catch {
+ if {[catch {
fcopy $s $state(-channel) -size $state(-blocksize) -command \
[list httpCopyDone $token]
- } err] {
+ } err]} {
httpFinish $token $err
}
}
@@ -283,7 +283,7 @@ proc http_size {token} {
upvar #0 $token state
set s $state(sock)
incr state(currentsize) $count
- if [info exists state(-progress)] {
+ if {[info exists state(-progress)]} {
eval $state(-progress) {$token $state(totalsize) $state(currentsize)}
}
if {([string length $error] != 0)} {
@@ -345,7 +345,7 @@ proc http_formatQuery {args} {
proc httpMapReply {string} {
global httpFormMap
set alphanumeric a-zA-Z0-9
- if ![info exists httpFormMap] {
+ if {![info exists httpFormMap]} {
for {set i 1} {$i <= 256} {incr i} {
set c [format %c $i]
diff --git a/library/http2.0/http.tcl b/library/http2.0/http.tcl
index 79c83c3..222e127 100644
--- a/library/http2.0/http.tcl
+++ b/library/http2.0/http.tcl
@@ -9,7 +9,7 @@
# See the file "license.terms" for information on usage and
# redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# SCCS: @(#) http.tcl 1.8 97/10/28 16:23:30
+# SCCS: %Z% $Id: http.tcl,v 1.2 1998/06/29 15:30:16 welch Exp $
package provide http 2.0 ;# This uses Tcl namespaces
@@ -73,7 +73,7 @@ proc http::config {args} {
}
} else {
foreach {flag value} $args {
- if [regexp -- $pat $flag] {
+ if {[regexp -- $pat $flag]} {
set http($flag) $value
} else {
return -code error "Unknown option $flag, must be: $usage"
@@ -140,7 +140,7 @@ proc http::reset { token {why reset} } {
proc http::geturl { url args } {
variable http
- if ![info exists http(uid)] {
+ if {![info exists http(uid)]} {
set http(uid) 0
}
set token [namespace current]::[incr http(uid)]
@@ -166,7 +166,7 @@ proc http::geturl { url args } {
regsub -all -- - $options {} options
set pat ^-([join $options |])$
foreach {flag value} $args {
- if [regexp $pat $flag] {
+ if {[regexp $pat $flag]} {
# Validate numbers
if {[info exists state($flag)] && \
[regexp {^[0-9]+$} $state($flag)] && \
@@ -285,7 +285,7 @@ proc http::size {token} {
upvar 0 $token state
set s $state(sock)
- if [::eof $s] then {
+ if {[::eof $s]} {
Eof $token
return
}
@@ -293,7 +293,7 @@ proc http::size {token} {
set n [gets $s line]
if {$n == 0} {
set state(state) body
- if ![regexp -nocase ^text $state(type)] {
+ if {![regexp -nocase ^text $state(type)]} {
# Turn off conversions for non-text data
fconfigure $s -translation binary
if {[info exists state(-channel)]} {
@@ -307,20 +307,20 @@ proc http::size {token} {
CopyStart $s $token
}
} elseif {$n > 0} {
- if [regexp -nocase {^content-type:(.+)$} $line x type] {
+ if {[regexp -nocase {^content-type:(.+)$} $line x type]} {
set state(type) [string trim $type]
}
- if [regexp -nocase {^content-length:(.+)$} $line x length] {
+ if {[regexp -nocase {^content-length:(.+)$} $line x length]} {
set state(totalsize) [string trim $length]
}
- if [regexp -nocase {^([^:]+):(.+)$} $line x key value] {
+ if {[regexp -nocase {^([^:]+):(.+)$} $line x key value]} {
lappend state(meta) $key $value
} elseif {[regexp ^HTTP $line]} {
set state(http) $line
}
}
} else {
- if [catch {
+ if {[catch {
if {[info exists state(-handler)]} {
set n [eval $state(-handler) {$s $token}]
} else {
@@ -333,10 +333,10 @@ proc http::size {token} {
if {$n >= 0} {
incr state(currentsize) $n
}
- } err] {
+ } err]} {
Finish $token $err
} else {
- if [info exists state(-progress)] {
+ if {[info exists state(-progress)]} {
eval $state(-progress) {$token $state(totalsize) $state(currentsize)}
}
}
@@ -345,10 +345,10 @@ proc http::size {token} {
proc http::CopyStart {s token} {
variable $token
upvar 0 $token state
- if [catch {
+ if {[catch {
fcopy $s $state(-channel) -size $state(-blocksize) -command \
[list http::CopyDone $token]
- } err] {
+ } err]} {
Finish $token $err
}
}
@@ -357,7 +357,7 @@ proc http::size {token} {
upvar 0 $token state
set s $state(sock)
incr state(currentsize) $count
- if [info exists state(-progress)] {
+ if {[info exists state(-progress)]} {
eval $state(-progress) {$token $state(totalsize) $state(currentsize)}
}
if {([string length $error] != 0)} {
diff --git a/library/http2.1/http.tcl b/library/http2.1/http.tcl
index 79c83c3..222e127 100644
--- a/library/http2.1/http.tcl
+++ b/library/http2.1/http.tcl
@@ -9,7 +9,7 @@
# See the file "license.terms" for information on usage and
# redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# SCCS: @(#) http.tcl 1.8 97/10/28 16:23:30
+# SCCS: %Z% $Id: http.tcl,v 1.2 1998/06/29 15:30:16 welch Exp $
package provide http 2.0 ;# This uses Tcl namespaces
@@ -73,7 +73,7 @@ proc http::config {args} {
}
} else {
foreach {flag value} $args {
- if [regexp -- $pat $flag] {
+ if {[regexp -- $pat $flag]} {
set http($flag) $value
} else {
return -code error "Unknown option $flag, must be: $usage"
@@ -140,7 +140,7 @@ proc http::reset { token {why reset} } {
proc http::geturl { url args } {
variable http
- if ![info exists http(uid)] {
+ if {![info exists http(uid)]} {
set http(uid) 0
}
set token [namespace current]::[incr http(uid)]
@@ -166,7 +166,7 @@ proc http::geturl { url args } {
regsub -all -- - $options {} options
set pat ^-([join $options |])$
foreach {flag value} $args {
- if [regexp $pat $flag] {
+ if {[regexp $pat $flag]} {
# Validate numbers
if {[info exists state($flag)] && \
[regexp {^[0-9]+$} $state($flag)] && \
@@ -285,7 +285,7 @@ proc http::size {token} {
upvar 0 $token state
set s $state(sock)
- if [::eof $s] then {
+ if {[::eof $s]} {
Eof $token
return
}
@@ -293,7 +293,7 @@ proc http::size {token} {
set n [gets $s line]
if {$n == 0} {
set state(state) body
- if ![regexp -nocase ^text $state(type)] {
+ if {![regexp -nocase ^text $state(type)]} {
# Turn off conversions for non-text data
fconfigure $s -translation binary
if {[info exists state(-channel)]} {
@@ -307,20 +307,20 @@ proc http::size {token} {
CopyStart $s $token
}
} elseif {$n > 0} {
- if [regexp -nocase {^content-type:(.+)$} $line x type] {
+ if {[regexp -nocase {^content-type:(.+)$} $line x type]} {
set state(type) [string trim $type]
}
- if [regexp -nocase {^content-length:(.+)$} $line x length] {
+ if {[regexp -nocase {^content-length:(.+)$} $line x length]} {
set state(totalsize) [string trim $length]
}
- if [regexp -nocase {^([^:]+):(.+)$} $line x key value] {
+ if {[regexp -nocase {^([^:]+):(.+)$} $line x key value]} {
lappend state(meta) $key $value
} elseif {[regexp ^HTTP $line]} {
set state(http) $line
}
}
} else {
- if [catch {
+ if {[catch {
if {[info exists state(-handler)]} {
set n [eval $state(-handler) {$s $token}]
} else {
@@ -333,10 +333,10 @@ proc http::size {token} {
if {$n >= 0} {
incr state(currentsize) $n
}
- } err] {
+ } err]} {
Finish $token $err
} else {
- if [info exists state(-progress)] {
+ if {[info exists state(-progress)]} {
eval $state(-progress) {$token $state(totalsize) $state(currentsize)}
}
}
@@ -345,10 +345,10 @@ proc http::size {token} {
proc http::CopyStart {s token} {
variable $token
upvar 0 $token state
- if [catch {
+ if {[catch {
fcopy $s $state(-channel) -size $state(-blocksize) -command \
[list http::CopyDone $token]
- } err] {
+ } err]} {
Finish $token $err
}
}
@@ -357,7 +357,7 @@ proc http::size {token} {
upvar 0 $token state
set s $state(sock)
incr state(currentsize) $count
- if [info exists state(-progress)] {
+ if {[info exists state(-progress)]} {
eval $state(-progress) {$token $state(totalsize) $state(currentsize)}
}
if {([string length $error] != 0)} {
diff --git a/library/http2.3/http.tcl b/library/http2.3/http.tcl
index 79c83c3..222e127 100644
--- a/library/http2.3/http.tcl
+++ b/library/http2.3/http.tcl
@@ -9,7 +9,7 @@
# See the file "license.terms" for information on usage and
# redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# SCCS: @(#) http.tcl 1.8 97/10/28 16:23:30
+# SCCS: %Z% $Id: http.tcl,v 1.2 1998/06/29 15:30:16 welch Exp $
package provide http 2.0 ;# This uses Tcl namespaces
@@ -73,7 +73,7 @@ proc http::config {args} {
}
} else {
foreach {flag value} $args {
- if [regexp -- $pat $flag] {
+ if {[regexp -- $pat $flag]} {
set http($flag) $value
} else {
return -code error "Unknown option $flag, must be: $usage"
@@ -140,7 +140,7 @@ proc http::reset { token {why reset} } {
proc http::geturl { url args } {
variable http
- if ![info exists http(uid)] {
+ if {![info exists http(uid)]} {
set http(uid) 0
}
set token [namespace current]::[incr http(uid)]
@@ -166,7 +166,7 @@ proc http::geturl { url args } {
regsub -all -- - $options {} options
set pat ^-([join $options |])$
foreach {flag value} $args {
- if [regexp $pat $flag] {
+ if {[regexp $pat $flag]} {
# Validate numbers
if {[info exists state($flag)] && \
[regexp {^[0-9]+$} $state($flag)] && \
@@ -285,7 +285,7 @@ proc http::size {token} {
upvar 0 $token state
set s $state(sock)
- if [::eof $s] then {
+ if {[::eof $s]} {
Eof $token
return
}
@@ -293,7 +293,7 @@ proc http::size {token} {
set n [gets $s line]
if {$n == 0} {
set state(state) body
- if ![regexp -nocase ^text $state(type)] {
+ if {![regexp -nocase ^text $state(type)]} {
# Turn off conversions for non-text data
fconfigure $s -translation binary
if {[info exists state(-channel)]} {
@@ -307,20 +307,20 @@ proc http::size {token} {
CopyStart $s $token
}
} elseif {$n > 0} {
- if [regexp -nocase {^content-type:(.+)$} $line x type] {
+ if {[regexp -nocase {^content-type:(.+)$} $line x type]} {
set state(type) [string trim $type]
}
- if [regexp -nocase {^content-length:(.+)$} $line x length] {
+ if {[regexp -nocase {^content-length:(.+)$} $line x length]} {
set state(totalsize) [string trim $length]
}
- if [regexp -nocase {^([^:]+):(.+)$} $line x key value] {
+ if {[regexp -nocase {^([^:]+):(.+)$} $line x key value]} {
lappend state(meta) $key $value
} elseif {[regexp ^HTTP $line]} {
set state(http) $line
}
}
} else {
- if [catch {
+ if {[catch {
if {[info exists state(-handler)]} {
set n [eval $state(-handler) {$s $token}]
} else {
@@ -333,10 +333,10 @@ proc http::size {token} {
if {$n >= 0} {
incr state(currentsize) $n
}
- } err] {
+ } err]} {
Finish $token $err
} else {
- if [info exists state(-progress)] {
+ if {[info exists state(-progress)]} {
eval $state(-progress) {$token $state(totalsize) $state(currentsize)}
}
}
@@ -345,10 +345,10 @@ proc http::size {token} {
proc http::CopyStart {s token} {
variable $token
upvar 0 $token state
- if [catch {
+ if {[catch {
fcopy $s $state(-channel) -size $state(-blocksize) -command \
[list http::CopyDone $token]
- } err] {
+ } err]} {
Finish $token $err
}
}
@@ -357,7 +357,7 @@ proc http::size {token} {
upvar 0 $token state
set s $state(sock)
incr state(currentsize) $count
- if [info exists state(-progress)] {
+ if {[info exists state(-progress)]} {
eval $state(-progress) {$token $state(totalsize) $state(currentsize)}
}
if {([string length $error] != 0)} {
diff --git a/library/opt0.1/optparse.tcl b/library/opt0.1/optparse.tcl
index 12135da..4f859dd 100644
--- a/library/opt0.1/optparse.tcl
+++ b/library/opt0.1/optparse.tcl
@@ -13,9 +13,9 @@
# written initially with Brent Welch, itself initially
# based on work with Steve Uhler. Thanks them !
#
-# SCCS: @(#) optparse.tcl 1.13 97/08/21 11:50:42
+# SCCS: %Z% $Id: optparse.tcl,v 1.2 1998/06/29 15:30:44 welch Exp $
-package provide opt 0.2
+package provide opt 0.3
namespace eval ::tcl {
@@ -416,9 +416,6 @@ proc ::tcl::OptProcArgGiven {argname} {
OptNextDesc descriptions;
set state [OptCurState $descriptions];
}
- if {![Lempty $arguments]} {
- return -code error [OptTooManyArgs $descriptions $arguments];
- }
}
# Process one step for the state machine,
@@ -431,8 +428,12 @@ proc ::tcl::OptProcArgGiven {argname} {
# the special state/instruction "args" eats all
# the remaining args (if any)
if {($state == "args")} {
- OptCurSetValue descriptions $arguments;
- set arguments {};
+ if {![Lempty $arguments]} {
+ # If there is no additional arguments, leave the default value
+ # in.
+ OptCurSetValue descriptions $arguments;
+ set arguments {};
+ }
# puts "breaking out ('args' state: consuming every reminding args)"
return -code break;
}
@@ -489,8 +490,8 @@ proc ::tcl::OptProcArgGiven {argname} {
value {
set item [OptCurDesc $descriptions];
# Test the values against their required type
- if [catch {OptCheckType $arg\
- [OptType $item] [OptTypeArgs $item]} val] {
+ if {[catch {OptCheckType $arg\
+ [OptType $item] [OptTypeArgs $item]} val]} {
return -code error [OptBadValue $item $arg $val]
}
# consume the value
@@ -509,8 +510,8 @@ proc ::tcl::OptProcArgGiven {argname} {
optValue {
set item [OptCurDesc $descriptions];
# Test the values against their required type
- if ![catch {OptCheckType $arg\
- [OptType $item] [OptTypeArgs $item]} val] {
+ if {![catch {OptCheckType $arg\
+ [OptType $item] [OptTypeArgs $item]} val]} {
# right type, so :
# consume the value
OptNextArg arguments;
@@ -541,10 +542,14 @@ proc ::tcl::OptKeyParse {descKey arglist} {
}
OptDoAll desc arglist;
+
+ if {![Lempty $arglist]} {
+ return -code error [OptTooManyArgs $desc $arglist];
+ }
# Analyse the result
# Walk through the tree:
- OptTreeVars $desc "#[expr [info level]-1]" ;
+ OptTreeVars $desc "#[expr {[info level]-1}]" ;
}
# determine string length for nice tabulated output
@@ -583,13 +588,13 @@ proc ::tcl::OptCheckType {arg type {typeArgs ""}} {
switch -exact -- $type {
int {
- if ![regexp {^(-+)?[0-9]+$} $arg] {
+ if {![regexp {^(-+)?[0-9]+$} $arg]} {
error "not an integer"
}
return $arg;
}
float {
- return [expr double($arg)]
+ return [expr {double($arg)}]
}
script -
list {
@@ -602,7 +607,7 @@ proc ::tcl::OptCheckType {arg type {typeArgs ""}} {
return $arg;
}
boolean {
- if ![regexp -nocase {^(true|false|0|1)$} $arg] {
+ if {![regexp -nocase {^(true|false|0|1)$} $arg]} {
error "non canonic boolean"
}
# convert true/false because expr/if is broken with "!,...
@@ -644,7 +649,7 @@ proc ::tcl::OptCheckType {arg type {typeArgs ""}} {
set larg [string tolower $arg];
set len [string length $larg];
- set last [expr $len-1];
+ set last [expr {$len-1}];
foreach item [lrange $desc 1 end] {
set flag [OptName $item]
@@ -798,7 +803,7 @@ proc ::tcl::OptCheckType {arg type {typeArgs ""}} {
# varname type value
# varname value comment
- if [regexp {^-(.+)$} $arg1 x type] {
+ if {[regexp {^-(.+)$} $arg1 x type]} {
# flags/optValue as they are optional, need a "value",
# on the contrary, for a variable (non optional),
# default value is pointless, 'cept for choices :
@@ -813,7 +818,7 @@ proc ::tcl::OptCheckType {arg type {typeArgs ""}} {
}
}
4 {
- if [regexp {^-(.+)$} $arg1 x type] {
+ if {[regexp {^-(.+)$} $arg1 x type]} {
return [OptNewInst $state $varname $type $arg2 $arg3];
} else {
return -code error [OptOptUsage $item];
@@ -827,13 +832,13 @@ proc ::tcl::OptCheckType {arg type {typeArgs ""}} {
# Auto magic lasy type determination
proc OptGuessType {arg} {
- if [regexp -nocase {^(true|false)$} $arg] {
+ if {[regexp -nocase {^(true|false)$} $arg]} {
return boolean
}
- if [regexp {^(-+)?[0-9]+$} $arg] {
+ if {[regexp {^(-+)?[0-9]+$} $arg]} {
return int
}
- if ![catch {expr double($arg)}] {
+ if {![catch {expr {double($arg)}}]} {
return float
}
return string
@@ -1029,7 +1034,7 @@ proc ::tcl::Lvarincr {listName indexLst {howMuch 1}} {
# Increments the value of one cell of a list
proc ::tcl::Lvarincr1 {listName index {howMuch 1}} {
upvar $listName list;
- set newValue [expr [lindex $list $index]+$howMuch];
+ set newValue [expr {[lindex $list $index]+$howMuch}];
set list [lreplace $list $index $index $newValue];
return $newValue;
}
diff --git a/library/opt0.1/pkgIndex.tcl b/library/opt0.1/pkgIndex.tcl
index 7a7ad90..7f2baaf 100644
--- a/library/opt0.1/pkgIndex.tcl
+++ b/library/opt0.1/pkgIndex.tcl
@@ -4,4 +4,4 @@
# the package now, so they can readily use it
# and even "namespace import tcl::*" ...
# (tclPkgSetup just makes things slow and do not work so well with namespaces)
-package ifneeded opt 0.2 [list source [file join $dir optparse.tcl]]
+package ifneeded opt 0.3 [list source [file join $dir optparse.tcl]]