summaryrefslogtreecommitdiffstats
path: root/generic/tclCmdIL.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2003-02-11 21:54:38 (GMT)
committerhobbs <hobbs>2003-02-11 21:54:38 (GMT)
commit5ea88a91277fd9a447ef118a88f4699698335841 (patch)
tree0d749ad255e3fcc6ef1ada93e00ad67966ab069e /generic/tclCmdIL.c
parent736f0317f936ab603c6157110e8efdeb4a329a86 (diff)
downloadtcl-5ea88a91277fd9a447ef118a88f4699698335841.zip
tcl-5ea88a91277fd9a447ef118a88f4699698335841.tar.gz
tcl-5ea88a91277fd9a447ef118a88f4699698335841.tar.bz2
* tests/lsearch.test:
* generic/tclCmdIL.c (Tcl_LsearchObjCmd): protect against the case that lsearch -regepx list and pattern objects are equal.
Diffstat (limited to 'generic/tclCmdIL.c')
-rw-r--r--generic/tclCmdIL.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c
index 36b1ef5..f464d25 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.44 2002/06/11 13:22:36 msofer Exp $
+ * RCS: @(#) $Id: tclCmdIL.c,v 1.45 2003/02/11 21:54:48 hobbs Exp $
*/
#include "tclInt.h"
@@ -2778,6 +2778,7 @@ Tcl_LsearchObjCmd(clientData, interp, objc, objv)
int offset, allMatches, inlineReturn, negatedMatch;
double patDouble, objDouble;
Tcl_Obj *patObj, **listv, *listPtr, *startPtr;
+ Tcl_RegExp regexp;
static CONST char *options[] = {
"-all", "-ascii", "-decreasing", "-dictionary",
"-exact", "-glob", "-increasing", "-inline",
@@ -2890,6 +2891,21 @@ Tcl_LsearchObjCmd(clientData, interp, objc, objv)
}
}
+ if ((enum modes) mode == REGEXP) {
+ /*
+ * We can shimmer regexp/list if listv[i] == pattern, so get the
+ * regexp rep before the list rep.
+ */
+ regexp = Tcl_GetRegExpFromObj(interp, objv[objc - 1],
+ TCL_REG_ADVANCED | TCL_REG_NOSUB);
+ if (regexp == NULL) {
+ if (startPtr) {
+ Tcl_DecrRefCount(startPtr);
+ }
+ return TCL_ERROR;
+ }
+ }
+
/*
* Make sure the list argument is a list object and get its length and
* a pointer to its array of element pointers.
@@ -3085,8 +3101,9 @@ Tcl_LsearchObjCmd(clientData, interp, objc, objv)
patternBytes);
break;
case REGEXP:
- match = Tcl_RegExpMatchObj(interp, listv[i], patObj);
+ match = Tcl_RegExpExecObj(interp, regexp, listv[i], 0, 0, 0);
if (match < 0) {
+ Tcl_DecrRefCount(patObj);
if (listPtr) {
Tcl_DecrRefCount(listPtr);
}