summaryrefslogtreecommitdiffstats
path: root/generic/tclRegexp.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2016-12-19 10:42:42 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2016-12-19 10:42:42 (GMT)
commita728d03f7d2b232dbc44f2669d8eb326b1029d3d (patch)
tree5e462694ca52e0a37de87c6786d4028e6da22080 /generic/tclRegexp.c
parent82903a4b1fb9b7ea432581d5c197770473c49021 (diff)
parent89f9758279f36f87e7b7efa0c7b2358635a1ea10 (diff)
downloadtcl-a728d03f7d2b232dbc44f2669d8eb326b1029d3d.zip
tcl-a728d03f7d2b232dbc44f2669d8eb326b1029d3d.tar.gz
tcl-a728d03f7d2b232dbc44f2669d8eb326b1029d3d.tar.bz2
merge novem
Diffstat (limited to 'generic/tclRegexp.c')
-rw-r--r--generic/tclRegexp.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/generic/tclRegexp.c b/generic/tclRegexp.c
index e912ba4..be2cb4d 100644
--- a/generic/tclRegexp.c
+++ b/generic/tclRegexp.c
@@ -502,9 +502,16 @@ Tcl_RegExpMatchObj(
{
Tcl_RegExp re;
- re = Tcl_GetRegExpFromObj(interp, patternObj,
- TCL_REG_ADVANCED | TCL_REG_NOSUB);
- if (re == NULL) {
+ /*
+ * For performance reasons, first try compiling the RE without support for
+ * subexpressions. On failure, try again without TCL_REG_NOSUB in case the
+ * RE has backreferences in it. Closely related to [Bug 1366683]. If this
+ * still fails, an error message will be left in the interpreter.
+ */
+
+ if (!(re = Tcl_GetRegExpFromObj(interp, patternObj,
+ TCL_REG_ADVANCED | TCL_REG_NOSUB))
+ && !(re = Tcl_GetRegExpFromObj(interp, patternObj, TCL_REG_ADVANCED))) {
return -1;
}
return Tcl_RegExpExecObj(interp, re, textObj, 0 /* offset */,