From 34c1b26fda7971d730ebcf6498ef36793dc84609 Mon Sep 17 00:00:00 2001 From: dkf Date: Fri, 29 Jul 2005 14:57:25 +0000 Subject: Take care with globals that have an entry in the var table but "don't exist" --- ChangeLog | 5 +++++ generic/tclCmdIL.c | 9 ++++++--- tests/info.test | 17 +++++++++++++++-- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 17782af..9b1b01d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-07-29 Donal K. Fellows + + * generic/tclCmdIL.c (InfoGlobalsCmd): Even in high-speed mode, + still have to take care with non-existant variables. [Bug 1247135] + 2005-07-28 Mo DeJong * win/README: Update link to msys_mingw8.zip. diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index 283d842..ab5c876 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -15,7 +15,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.47.2.5 2004/11/24 19:28:12 dgp Exp $ + * RCS: @(#) $Id: tclCmdIL.c,v 1.47.2.6 2005/07/29 14:57:26 dkf Exp $ */ #include "tclInt.h" @@ -1105,8 +1105,11 @@ InfoGlobalsCmd(dummy, interp, objc, objv) if (pattern != NULL && TclMatchIsTrivial(pattern)) { entryPtr = Tcl_FindHashEntry(&globalNsPtr->varTable, pattern); if (entryPtr != NULL) { - Tcl_ListObjAppendElement(interp, listPtr, - Tcl_NewStringObj(pattern, -1)); + varPtr = (Var *) Tcl_GetHashValue(entryPtr); + if (!TclIsVarUndefined(varPtr)) { + Tcl_ListObjAppendElement(interp, listPtr, + Tcl_NewStringObj(pattern, -1)); + } } } else { for (entryPtr = Tcl_FirstHashEntry(&globalNsPtr->varTable, &search); diff --git a/tests/info.test b/tests/info.test index 0f65324..7a31b27 100644 --- a/tests/info.test +++ b/tests/info.test @@ -11,10 +11,10 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: info.test,v 1.24.2.3 2004/11/24 19:28:13 dgp Exp $ +# RCS: @(#) $Id: info.test,v 1.24.2.4 2005/07/29 14:57:28 dkf Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest + package require tcltest 2 namespace import -force ::tcltest::* } @@ -295,6 +295,19 @@ test info-8.4 {info globals option: may have leading namespace qualifiers} { set x 0 list [info globals x] [info globals :x] [info globals ::x] [info globals :::x] [info globals ::::x] } {x {} x x x} +test info-8.5 {info globals option: only return existing global variables} { + -setup { + catch {unset ::NO_SUCH_VAR} + proc evalInProc script {eval $script} + } + -body { + evalInProc {global NO_SUCH_VAR; info globals NO_SUCH_VAR} + } + -cleanup { + rename evalInProc {} + } + -result {} +} test info-9.1 {info level option} { info level -- cgit v0.12