summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhobbs <hobbs>2007-11-23 21:19:49 (GMT)
committerhobbs <hobbs>2007-11-23 21:19:49 (GMT)
commit0cf11b03177cded9d26650e22e10b28dacfa57c8 (patch)
tree837e8bc7a716b7532c464c62bbe2743d5a062309
parentb400e7071cf4016d6bcc94da3ab8cd195c59c222 (diff)
downloadtcl-0cf11b03177cded9d26650e22e10b28dacfa57c8.zip
tcl-0cf11b03177cded9d26650e22e10b28dacfa57c8.tar.gz
tcl-0cf11b03177cded9d26650e22e10b28dacfa57c8.tar.bz2
* generic/tclVar.c (Tcl_ArrayObjCmd): handle the right data for
* tests/var.test (var-14.2): [array names $var -glob $ptn]
-rw-r--r--ChangeLog5
-rw-r--r--generic/tclVar.c17
-rw-r--r--tests/var.test6
3 files changed, 21 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 2b3b920..6083aab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-11-23 Jeff Hobbs <jeffh@ActiveState.com>
+
+ * generic/tclVar.c (Tcl_ArrayObjCmd): handle the right data for
+ * tests/var.test (var-14.2): [array names $var -glob $ptn]
+
2007-11-23 Donal K. Fellows <donal.k.fellows@manchester.ac.uk>
* generic/tclCmdMZ.c (String*Cmd, TclInitStringCmd): Rebuilt [string]
diff --git a/generic/tclVar.c b/generic/tclVar.c
index d7393e4..9f7595c 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.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: tclVar.c,v 1.157 2007/11/18 21:59:25 dkf Exp $
+ * RCS: @(#) $Id: tclVar.c,v 1.158 2007/11/23 21:19:50 hobbs Exp $
*/
#include "tclInt.h"
@@ -3048,9 +3048,9 @@ Tcl_ArrayObjCmd(
case ARRAY_NAMES: {
Tcl_HashSearch search;
Var *varPtr2;
- char *pattern = NULL;
+ char *pattern;
char *name;
- Tcl_Obj *namePtr, *resultPtr;
+ Tcl_Obj *namePtr, *resultPtr, *patternPtr;
int mode, matched = 0;
static const char *options[] = {
"-exact", "-glob", "-regexp", NULL
@@ -3067,18 +3067,23 @@ Tcl_ArrayObjCmd(
return TCL_OK;
}
if (objc == 4) {
- pattern = TclGetString(objv[3]);
+ patternPtr = objv[3];
+ pattern = TclGetString(patternPtr);
} else if (objc == 5) {
- pattern = TclGetString(objv[4]);
+ patternPtr = objv[4];
+ pattern = TclGetString(patternPtr);
if (Tcl_GetIndexFromObj(interp, objv[3], options, "option", 0,
&mode) != TCL_OK) {
return TCL_ERROR;
}
+ } else {
+ patternPtr = NULL;
+ pattern = NULL;
}
TclNewObj(resultPtr);
if (((enum options) mode)==OPT_GLOB && pattern!=NULL &&
TclMatchIsTrivial(pattern)) {
- varPtr2 = VarHashFindVar(varPtr->value.tablePtr, objv[3]);
+ varPtr2 = VarHashFindVar(varPtr->value.tablePtr, patternPtr);
if ((varPtr2 != NULL) && !TclIsVarUndefined(varPtr2)) {
result = Tcl_ListObjAppendElement(interp, resultPtr,
VarHashGetKey(varPtr2));
diff --git a/tests/var.test b/tests/var.test
index 57c6fe4..e1a616d 100644
--- a/tests/var.test
+++ b/tests/var.test
@@ -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: var.test,v 1.28 2007/03/12 18:06:14 dgp Exp $
+# RCS: @(#) $Id: var.test,v 1.29 2007/11/23 21:19:51 hobbs Exp $
#
if {[lsearch [namespace children] ::tcltest] == -1} {
@@ -680,6 +680,10 @@ test var-14.1 {array names syntax} -body {
array names foo bar baz snafu
} -returnCodes 1 -match glob -result *
+test var-14.2 {array names -glob} -body {
+ array names tcl_platform -glob os
+} -returnCodes 0 -match exact -result os
+
test var-15.1 {segfault in [unset], [Bug 735335]} {
proc A { name } {
upvar $name var