aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2010-10-30 15:20:38 +1000
committerSteve Bennett <steveb@workware.net.au>2010-11-19 22:26:21 +1000
commitd98489727fe31fa217d237b36901211adc35282d (patch)
tree807297728746e597799dee38560455be3742691a
parent64de34132f32f91e573e8f66d843daf3fd50b16d (diff)
downloadjimtcl-d98489727fe31fa217d237b36901211adc35282d.zip
jimtcl-d98489727fe31fa217d237b36901211adc35282d.tar.gz
jimtcl-d98489727fe31fa217d237b36901211adc35282d.tar.bz2
Better Tcl compatibility for [lrepeat]
With zero count and also with no list elements Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r--jim.c8
-rw-r--r--tests/misc.test10
2 files changed, 10 insertions, 8 deletions
diff --git a/jim.c b/jim.c
index a03ff0b..dbe6d89 100644
--- a/jim.c
+++ b/jim.c
@@ -13163,11 +13163,15 @@ static int Jim_LrepeatCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *
Jim_Obj *objPtr;
long count;
- if (argc < 3 || Jim_GetLong(interp, argv[1], &count) != JIM_OK || count <= 0) {
- Jim_WrongNumArgs(interp, 1, argv, "positiveCount value ?value ...?");
+ if (argc < 2 || Jim_GetLong(interp, argv[1], &count) != JIM_OK || count < 0) {
+ Jim_WrongNumArgs(interp, 1, argv, "count ?value ...?");
return JIM_ERR;
}
+ if (count == 0 || argc == 2) {
+ return JIM_OK;
+ }
+
argc -= 2;
argv += 2;
diff --git a/tests/misc.test b/tests/misc.test
index e4b086a..0dc1112 100644
--- a/tests/misc.test
+++ b/tests/misc.test
@@ -134,19 +134,17 @@ test lrepeat-1.5 "Errors" {
} {1}
test lrepeat-1.6 "Errors" {
- catch {lrepeat 1}
-} {1}
+ lrepeat 1
+} {}
test lrepeat-1.7 "Errors" {
- catch {lrepeat 0 a b}
-} {1}
+ lrepeat 0 a b
+} {}
test lrepeat-1.8 "Errors" {
catch {lrepeat -10 a}
} {1}
-section "string/list index"
-
test lindex-1.1 "Integer" {
lindex {a b c} 0
} a