aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez>2005-03-28 17:47:15 +0000
committerantirez <antirez>2005-03-28 17:47:15 +0000
commitd6f57adaa070c9e06d6d2e2e90edf166afea7933 (patch)
treef7f9c9a49e6ac8429c3109d4949a84072354b17f
parentfdf5499a95b2aad40243e1d5a16334096115b0f2 (diff)
downloadjimtcl-d6f57adaa070c9e06d6d2e2e90edf166afea7933.zip
jimtcl-d6f57adaa070c9e06d6d2e2e90edf166afea7933.tar.gz
jimtcl-d6f57adaa070c9e06d6d2e2e90edf166afea7933.tar.bz2
The behaviour of [scope] modified a bit. Test updated accordingly.
-rw-r--r--ChangeLog4
-rw-r--r--jim.c8
-rw-r--r--test.tcl14
3 files changed, 16 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 1e21475..f3b0d0d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-03-28 18:57 antirez
+
+ * ChangeLog, jim.c, test.tcl: [scope] command + tests
+
2005-03-26 15:12 antirez
* ChangeLog, Makefile, jim-sdl.c, jim.c: some GFX primitive to SDL
diff --git a/jim.c b/jim.c
index 4ea60f3..25594b6 100644
--- a/jim.c
+++ b/jim.c
@@ -2,7 +2,7 @@
* Copyright 2005 Salvatore Sanfilippo <antirez@invece.org>
* Copyright 2005 Clemens Hintze <c.hintze@gmx.net>
*
- * $Id: jim.c,v 1.131 2005/03/28 16:57:36 antirez Exp $
+ * $Id: jim.c,v 1.132 2005/03/28 17:47:15 antirez Exp $
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -10764,7 +10764,8 @@ static int Jim_ScopeCoreCommand(Jim_Interp *interp, int argc,
Jim_WrongNumArgs(interp, 1, argv, "varList body");
return JIM_ERR;
}
- /* Save the value of every var in varList into the 'savedVect' vector. */
+ /* Save the value of every var in varList into the 'savedVect' vector.
+ * Also unset every var name. */
Jim_ListLength(interp, argv[1], &len);
savedVect = Jim_Alloc(len*sizeof(Jim_Obj*));
for (i = 0; i < len; i++) {
@@ -10772,6 +10773,7 @@ static int Jim_ScopeCoreCommand(Jim_Interp *interp, int argc,
savedVect[i] = Jim_GetVariable(interp, varNameObjPtr, JIM_NONE);
if (savedVect[i] != NULL)
Jim_IncrRefCount(savedVect[i]);
+ Jim_UnsetVariable(interp, varNameObjPtr, JIM_NONE);
}
/* Eval the body */
retCode = Jim_EvalObj(interp, argv[2]);
@@ -10924,7 +10926,7 @@ int Jim_InteractivePrompt(Jim_Interp *interp)
printf("Welcome to Jim version %d.%d, "
"Copyright (c) 2005 Salvatore Sanfilippo\n",
JIM_VERSION / 100, JIM_VERSION % 100);
- printf("CVS ID: $Id: jim.c,v 1.131 2005/03/28 16:57:36 antirez Exp $\n");
+ printf("CVS ID: $Id: jim.c,v 1.132 2005/03/28 17:47:15 antirez Exp $\n");
Jim_SetVariableStrWithStr(interp, "jim_interactive", "1");
while (1) {
char buf[1024];
diff --git a/test.tcl b/test.tcl
index 9f0a312..ccd7858 100644
--- a/test.tcl
+++ b/test.tcl
@@ -1,4 +1,4 @@
-# $Id: test.tcl,v 1.27 2005/03/28 16:57:36 antirez Exp $
+# $Id: test.tcl,v 1.28 2005/03/28 17:47:15 antirez Exp $
#
# This are Tcl tests imported into Jim. Tests that will probably not be passed
# in the long term are usually removed (for example all the tests about
@@ -4183,14 +4183,14 @@ test scope-1.4 {Non existing array element} {
info exists x(a)
} {0}
-test scope-1.5 {Array element and var contaning the dict modifications} {
- set x "a 1 b 2"
- scope {x(a) x} {
- set x "foo"
+test scope-1.5 {Info exists} {
+ set x foo
+ scope x {
+ info exists x
}
- set x
-} {a 1 b 2}
+} {0}
+catch {unset x}
catch {unset y}
################################################################################