diff options
author | dgp <dgp@users.sourceforge.net> | 2005-05-05 18:37:43 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2005-05-05 18:37:43 (GMT) |
commit | 06ccaebaafb55508004011a0cb9ec73a6872c23b (patch) | |
tree | 528333d487c2d5ed865f278d50536ea98959741c /generic/tclVar.c | |
parent | 9c427bf1e80bcbb05860cb838266240040b91f07 (diff) | |
download | tcl-06ccaebaafb55508004011a0cb9ec73a6872c23b.zip tcl-06ccaebaafb55508004011a0cb9ec73a6872c23b.tar.gz tcl-06ccaebaafb55508004011a0cb9ec73a6872c23b.tar.bz2 |
* generic/tclInt.decls: Converted TclMatchIsTrivial to a macro.
* generic/tclInt.h:
* generic/tclUtil.c:
* generic/tclIntDecls.h: `make genstubs`
* generic/tclStubInit.c:
* generic/tclBasic.c: Added callers of TclMatchIsTrivial where
* generic/tclCmdIL.c: a search can be done more efficiently
* generic/tclCompCmds.c:when it is recognized that a pattern match
* generic/tclDictObj.c: is really an exact match. [Patch 1076088]
* generic/tclIO.c:
* generic/tclNamesp.c:
* generic/tclVar.c:
Diffstat (limited to 'generic/tclVar.c')
-rw-r--r-- | generic/tclVar.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/generic/tclVar.c b/generic/tclVar.c index 0b5497f..314f958 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.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: tclVar.c,v 1.104 2005/04/16 19:17:34 msofer Exp $ + * RCS: @(#) $Id: tclVar.c,v 1.105 2005/05/05 18:38:06 dgp Exp $ */ #include "tclInt.h" @@ -2771,7 +2771,23 @@ Tcl_ArrayObjCmd(dummy, interp, objc, objv) TclNewObj(nameLstPtr); Tcl_IncrRefCount(nameLstPtr); - + if ((pattern != NULL) && TclMatchIsTrivial(pattern)) { + hPtr = Tcl_FindHashEntry(varPtr->value.tablePtr, pattern); + if (hPtr == NULL) { + goto searchDone; + } + varPtr2 = (Var *) Tcl_GetHashValue(hPtr); + if (TclIsVarUndefined(varPtr2)) { + goto searchDone; + } + result = Tcl_ListObjAppendElement(interp, nameLstPtr, + Tcl_NewStringObj(pattern, -1)); + if (result != TCL_OK) { + Tcl_DecrRefCount(nameLstPtr); + return result; + } + goto searchDone; + } for (hPtr = Tcl_FirstHashEntry(varPtr->value.tablePtr, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { varPtr2 = (Var *) Tcl_GetHashValue(hPtr); @@ -2792,6 +2808,7 @@ Tcl_ArrayObjCmd(dummy, interp, objc, objv) return result; } } +searchDone: /* * Make sure the Var structure of the array is not removed by @@ -2881,6 +2898,19 @@ Tcl_ArrayObjCmd(dummy, interp, objc, objv) } } TclNewObj(resultPtr); + if ((((enum options) mode) == OPT_GLOB) && (pattern != NULL) + && TclMatchIsTrivial(pattern)) { + hPtr = Tcl_FindHashEntry(varPtr->value.tablePtr, pattern); + if ((hPtr != NULL) + && !TclIsVarUndefined((Var *) Tcl_GetHashValue(hPtr)) + && (result = Tcl_ListObjAppendElement(interp, + resultPtr, Tcl_NewStringObj(pattern, -1))) != TCL_OK) { + Tcl_DecrRefCount(resultPtr); + return result; + } + Tcl_SetObjResult(interp, resultPtr); + return TCL_OK; + } for (hPtr = Tcl_FirstHashEntry(varPtr->value.tablePtr, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { varPtr2 = (Var *) Tcl_GetHashValue(hPtr); @@ -3059,6 +3089,15 @@ Tcl_ArrayObjCmd(dummy, interp, objc, objv) } } else { pattern = TclGetString(objv[3]); + if (TclMatchIsTrivial(pattern)) { + hPtr = Tcl_FindHashEntry(varPtr->value.tablePtr, pattern); + result = TCL_OK; + (hPtr != NULL) + && !TclIsVarUndefined((Var *) Tcl_GetHashValue(hPtr)) + && (result + = TclObjUnsetVar2(interp, varNamePtr, pattern, 0)); + return result; + } for (hPtr = Tcl_FirstHashEntry(varPtr->value.tablePtr, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { |