diff options
author | ericm <ericm@noemail.net> | 2000-08-21 01:37:50 (GMT) |
---|---|---|
committer | ericm <ericm@noemail.net> | 2000-08-21 01:37:50 (GMT) |
commit | 78dfed2a70b95b1783e088fb7b20875c768f89c9 (patch) | |
tree | fd4936346c5f2cd37275fa1a3958dd1742c575b2 | |
parent | 1413397f4e95161d97ff640b795fb017ec08cda6 (diff) | |
download | tcl-78dfed2a70b95b1783e088fb7b20875c768f89c9.zip tcl-78dfed2a70b95b1783e088fb7b20875c768f89c9.tar.gz tcl-78dfed2a70b95b1783e088fb7b20875c768f89c9.tar.bz2 |
Added check for non-arrays for [array statistics].
FossilOrigin-Name: b857b66be3c7ad19c1ccaf6e8c50236f3a798c42
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | generic/tclVar.c | 7 | ||||
-rw-r--r-- | tests/set-old.test | 7 |
3 files changed, 16 insertions, 3 deletions
@@ -1,3 +1,8 @@ +2000-08-20 Eric Melski <ericm@ajubasolutions.com> + + * generic/tclVar.c: Added check for non-arrays for [array statistics] + command (patch from Mark Patton). + 2000-08-19 David Gravereaux <davygrvy@ajubasolutions.com> * generic/tclPlatDecls.h: without a previous '#include <windows.h>', diff --git a/generic/tclVar.c b/generic/tclVar.c index 8990ab8..8e431c7 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -14,7 +14,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclVar.c,v 1.20 2000/07/25 22:41:05 ericm Exp $ + * RCS: @(#) $Id: tclVar.c,v 1.21 2000/08/21 01:37:51 ericm Exp $ */ #include "tclInt.h" @@ -3228,6 +3228,11 @@ Tcl_ArrayObjCmd(dummy, interp, objc, objv) case ARRAY_STATISTICS: { char *stats; + + if (notArray) { + goto error; + } + stats = Tcl_HashStats(varPtr->value.tablePtr); if (stats != NULL) { Tcl_SetResult(interp, stats, TCL_VOLATILE); diff --git a/tests/set-old.test b/tests/set-old.test index a4c061a..6a63200 100644 --- a/tests/set-old.test +++ b/tests/set-old.test @@ -13,7 +13,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: set-old.test,v 1.11 2000/06/01 00:33:27 hobbs Exp $ +# RCS: @(#) $Id: set-old.test,v 1.12 2000/08/21 01:37:51 ericm Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -668,7 +668,10 @@ test set-old-8.52 {array command, array names -glob} { set a(-exact) 1 list [catch {array names a -glob} msg] $msg } {0 -glob} - +test set-old-8.53 {array command, array statistics on a non-array} { + catch {unset a} + list [catch {array statistics a} msg] $msg +} [list 1 "\"a\" isn't an array"] test set-old-9.1 {ids for array enumeration} { catch {unset a} |