diff options
| author | dgp <dgp@users.sourceforge.net> | 2016-11-28 16:08:33 (GMT) |
|---|---|---|
| committer | dgp <dgp@users.sourceforge.net> | 2016-11-28 16:08:33 (GMT) |
| commit | e615b5470447167aa8fbcb94824cd5285e8abeaa (patch) | |
| tree | 0bc5f840a6bd251cb90c5c690fdef2b905ead1e9 /generic/tclRegexp.c | |
| parent | e2d691eda81e4b943c815e3cb0fc52f62c82b73f (diff) | |
| parent | df537d0dfb0d776a346f5c04aca6cb5f090c0b1a (diff) | |
| download | tcl-e615b5470447167aa8fbcb94824cd5285e8abeaa.zip tcl-e615b5470447167aa8fbcb94824cd5285e8abeaa.tar.gz tcl-e615b5470447167aa8fbcb94824cd5285e8abeaa.tar.bz2 | |
merge trunk
Diffstat (limited to 'generic/tclRegexp.c')
| -rw-r--r-- | generic/tclRegexp.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/generic/tclRegexp.c b/generic/tclRegexp.c index 6845f7d..7596fa0 100644 --- a/generic/tclRegexp.c +++ b/generic/tclRegexp.c @@ -520,9 +520,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 */, |
