From f47fa38944c02518936f12a7bf883cb48b7feca8 Mon Sep 17 00:00:00 2001 From: dgp Date: Mon, 29 Sep 2008 15:38:30 +0000 Subject: TIP #323 IMPLEMENTATION (partial) * doc/linsert.n: Revise [linsert] to accept zero elements. * generic/tclCmdIL.c: * tests/linsert.test: --- ChangeLog | 8 ++++++++ doc/linsert.n | 4 ++-- generic/tclCmdIL.c | 6 +++--- tests/linsert.test | 12 +++++++++--- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4a1c197..03715da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-09-29 Don Porter + + TIP #323 IMPLEMENTATION (partial) + + * doc/linsert.n: Revise [linsert] to accept zero elements. + * generic/tclCmdIL.c: + * tests/linsert.test: + 2008-09-29 Donal K. Fellows TIP #326 IMPLEMENTATION diff --git a/doc/linsert.n b/doc/linsert.n index 79ec3ff..c552a54 100644 --- a/doc/linsert.n +++ b/doc/linsert.n @@ -6,7 +6,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: linsert.n,v 1.15 2008/06/29 22:28:24 dkf Exp $ +'\" RCS: @(#) $Id: linsert.n,v 1.16 2008/09/29 15:38:32 dgp Exp $ '\" .so man.macros .TH linsert n 8.2 Tcl "Tcl Built-In Commands" @@ -15,7 +15,7 @@ .SH NAME linsert \- Insert elements into a list .SH SYNOPSIS -\fBlinsert \fIlist index element \fR?\fIelement element ...\fR? +\fBlinsert \fIlist index \fR?\fIelement element ...\fR? .BE .SH DESCRIPTION .PP diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index 4041512..d479f81 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -16,7 +16,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCmdIL.c,v 1.157 2008/09/29 13:33:16 dkf Exp $ + * RCS: @(#) $Id: tclCmdIL.c,v 1.158 2008/09/29 15:38:32 dgp Exp $ */ #include "tclInt.h" @@ -2189,8 +2189,8 @@ Tcl_LinsertObjCmd( Tcl_Obj *listPtr; int index, len, result; - if (objc < 4) { - Tcl_WrongNumArgs(interp, 1, objv, "list index element ?element ...?"); + if (objc < 3) { + Tcl_WrongNumArgs(interp, 1, objv, "list index ?element ...?"); return TCL_ERROR; } diff --git a/tests/linsert.test b/tests/linsert.test index 3419c74..e9c545a 100644 --- a/tests/linsert.test +++ b/tests/linsert.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: linsert.test,v 1.10 2005/05/10 18:35:22 kennykb Exp $ +# RCS: @(#) $Id: linsert.test,v 1.11 2008/09/29 15:38:32 dgp Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -84,16 +84,22 @@ test linsert-1.20 {linsert command, use of end-int index} { test linsert-2.1 {linsert errors} { list [catch linsert msg] $msg -} {1 {wrong # args: should be "linsert list index element ?element ...?"}} +} {1 {wrong # args: should be "linsert list index ?element ...?"}} test linsert-2.2 {linsert errors} { list [catch {linsert a b} msg] $msg -} {1 {wrong # args: should be "linsert list index element ?element ...?"}} +} {1 {bad index "b": must be integer?[+-]integer? or end?[+-]integer?}} test linsert-2.3 {linsert errors} { list [catch {linsert a 12x 2} msg] $msg } {1 {bad index "12x": must be integer?[+-]integer? or end?[+-]integer?}} test linsert-2.4 {linsert errors} { list [catch {linsert \{ 12 2} msg] $msg } {1 {unmatched open brace in list}} +test linsert-2.5 {syntax (TIP 323)} { + linsert {a b c} 0 +} [list a b c] +test linsert-2.6 {syntax (TIP 323)} { + linsert "a\nb\nc" 0 +} [list a b c] test linsert-3.1 {linsert won't modify shared argument objects} { proc p {} { -- cgit v0.12