summaryrefslogtreecommitdiffstats
path: root/generic/tclVar.c
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 /generic/tclVar.c
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]
Diffstat (limited to 'generic/tclVar.c')
-rw-r--r--generic/tclVar.c17
1 files changed, 11 insertions, 6 deletions
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));