From 030aaf8733e03063daa3c730c5b258575b9386ba Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 26 Sep 2008 19:54:56 +0000 Subject: TIP #323 IMPLEMENTATION (partial) * doc/tm.n: Revise [tcl::tm::path add] and * library/tm.tcl: [tcl::tm::path remove] to accept zero paths. * tests/tm.test: --- ChangeLog | 4 ++++ doc/tm.n | 6 +++--- library/tm.tcl | 8 ++++---- tests/tm.test | 10 +++++----- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1fca8c8..2f53284 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,10 @@ TIP #323 IMPLEMENTATION (partial) + * doc/tm.n: Revise [tcl::tm::path add] and + * library/tm.tcl: [tcl::tm::path remove] to accept zero paths. + * tests/tm.test: + * doc/namespace.n: Revise [namespace upvar] to accept zero * generic/tclNamesp.c: variable names. * tests/upvar.test: diff --git a/doc/tm.n b/doc/tm.n index 883eb4c..3deca0f 100644 --- a/doc/tm.n +++ b/doc/tm.n @@ -4,7 +4,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: tm.n,v 1.16 2008/06/25 18:18:37 dgp Exp $ +'\" RCS: @(#) $Id: tm.n,v 1.17 2008/09/26 19:54:56 dgp Exp $ '\" .so man.macros .TH tm n 8.5 Tcl "Tcl Built-In Commands" @@ -24,7 +24,7 @@ tm \- Facilities for locating and loading of Tcl Modules This document describes the facilities for locating and loading Tcl Modules. The following commands are supported: .TP -\fB::tcl::tm::path\fR \fBadd\fR \fIpath\fR... +\fB::tcl::tm::path\fR \fBadd \fR?\fIpath\fR...? . The paths are added at the head to the list of module paths, in order of appearance. This means that the last argument ends up as the new @@ -46,7 +46,7 @@ reverse order of addition. In other words, the paths added last are looked at first. .RE .TP -\fB::tcl::tm::path\fR \fBremove\fR \fIpath\fR... +\fB::tcl::tm::path\fR \fBremove \fR?\fIpath\fR...? . Removes the paths from the list of module paths. The command silently ignores all paths which are not on the list. diff --git a/library/tm.tcl b/library/tm.tcl index 4f8e09e..a58b2ea 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 {path args} { +proc ::tcl::tm::add {args} { # PART OF THE ::tcl::tm::path ENSEMBLE # # The path is added at the head to the list of module paths. @@ -102,7 +102,7 @@ proc ::tcl::tm::add {path args} { # paths to the official state var. set newpaths $paths - foreach p [linsert $args 0 $path] { + foreach p $args { if {$p in $newpaths} { # Ignore a path already on the list. continue @@ -143,7 +143,7 @@ proc ::tcl::tm::add {path args} { return } -proc ::tcl::tm::remove {path args} { +proc ::tcl::tm::remove {args} { # PART OF THE ::tcl::tm::path ENSEMBLE # # Removes the path from the list of module paths. The command is @@ -151,7 +151,7 @@ proc ::tcl::tm::remove {path args} { variable paths - foreach p [linsert $args 0 $path] { + foreach p $args { set pos [lsearch -exact $paths $p] if {$pos >= 0} { set paths [lreplace $paths $pos $pos] diff --git a/tests/tm.test b/tests/tm.test index d2f88a2..72bcc72 100644 --- a/tests/tm.test +++ b/tests/tm.test @@ -6,7 +6,7 @@ # Copyright (c) 2004 by Donal K. Fellows. # All rights reserved. # -# RCS: @(#) $Id: tm.test,v 1.7 2008/07/19 22:50:39 nijtmans Exp $ +# RCS: @(#) $Id: tm.test,v 1.8 2008/09/26 19:54:59 dgp Exp $ package require Tcl 8.5 if {"::tcltest" ni [namespace children]} { @@ -21,12 +21,12 @@ test tm-1.1 {tm: path command exists} { test tm-1.2 {tm: path command syntax} -returnCodes error -body { ::tcl::tm::path foo } -result {unknown or ambiguous subcommand "foo": must be add, list, or remove} -test tm-1.3 {tm: path command syntax} -returnCodes error -body { +test tm-1.3 {tm: path command syntax} { ::tcl::tm::path add -} -result "wrong # args: should be \"::tcl::tm::path add path ?arg ...?\"" -test tm-1.4 {tm: path command syntax} -returnCodes error -body { +} {} +test tm-1.4 {tm: path command syntax} { ::tcl::tm::path remove -} -result "wrong # args: should be \"::tcl::tm::path remove path ?arg ...?\"" +} {} test tm-1.5 {tm: path command syntax} -returnCodes error -body { ::tcl::tm::path list foobar } -result "wrong # args: should be \"::tcl::tm::path list\"" -- cgit v0.12