summaryrefslogtreecommitdiffstats
path: root/library/tm.tcl
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-10-29 15:39:02 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-10-29 15:39:02 (GMT)
commitf21fa0e01c0fb463b0ec26f3b0cef1218243908a (patch)
tree0fe2010a58b021f880f03fd319b7dce9e764cd63 /library/tm.tcl
parent151836cea1737631c005e07ca9a26e7641ff009d (diff)
downloadtcl-f21fa0e01c0fb463b0ec26f3b0cef1218243908a.zip
tcl-f21fa0e01c0fb463b0ec26f3b0cef1218243908a.tar.gz
tcl-f21fa0e01c0fb463b0ec26f3b0cef1218243908a.tar.bz2
Allow ensembles to rewrite their subcommands' error messages to be more
relevant to users. [Patch 1056864] Also patches to core to take advantage of this Also other general cleaning up of Tcl_WrongNumArgs usage
Diffstat (limited to 'library/tm.tcl')
-rw-r--r--library/tm.tcl23
1 files changed, 5 insertions, 18 deletions
diff --git a/library/tm.tcl b/library/tm.tcl
index 491d25d..14dab45 100644
--- a/library/tm.tcl
+++ b/library/tm.tcl
@@ -79,7 +79,7 @@ namespace eval ::tcl::tm {
# paths to search for Tcl Modules. The subcommand 'list' has no
# sideeffects.
-proc ::tcl::tm::add {args} {
+proc ::tcl::tm::add {path args} {
# PART OF THE ::tcl::tm::path ENSEMBLE
#
# The path is added at the head to the list of module paths.
@@ -91,11 +91,6 @@ proc ::tcl::tm::add {args} {
# If the path is already present as is no error will be raised and
# no action will be taken.
- if {[llength $args] == 0} {
- return -code error \
- "wrong # args: should be \"::tcl::tm::path add path ?path ...?\""
- }
-
variable paths
# We use a copy of the path as source during validation, and
@@ -107,7 +102,7 @@ proc ::tcl::tm::add {args} {
# paths to the official state var.
set newpaths $paths
- foreach p $args {
+ foreach p [linsert $args 0 $path] {
if {$p in $newpaths} {
# Ignore a path already on the list.
continue
@@ -148,20 +143,15 @@ proc ::tcl::tm::add {args} {
return
}
-proc ::tcl::tm::remove {args} {
+proc ::tcl::tm::remove {path args} {
# PART OF THE ::tcl::tm::path ENSEMBLE
#
# Removes the path from the list of module paths. The command is
# silently ignored if the path is not on the list.
- if {[llength $args] == 0} {
- return -code error \
- "wrong # args: should be \"::tcl::tm::path remove path ?path ...?\""
- }
-
variable paths
- foreach p $args {
+ foreach p [linsert $args 0 $path] {
set pos [lsearch -exact $paths $p]
if {$pos >= 0} {
set paths [lreplace $paths $pos $pos]
@@ -169,12 +159,9 @@ proc ::tcl::tm::remove {args} {
}
}
-proc ::tcl::tm::list {args} {
+proc ::tcl::tm::list {} {
# PART OF THE ::tcl::tm::path ENSEMBLE
- if {[llength $args] != 0} {
- return -code error "wrong # args: should be \"::tcl::tm::path list\""
- }
variable paths
return $paths
}