diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-11-25 15:06:13 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-11-25 15:06:13 (GMT) |
| commit | ecda933dfc862ebf78720a334cba598bd3fca8bd (patch) | |
| tree | ac31caa64067eb47d063456c7a53d6eeadd09f5a /generic/tclRegexp.c | |
| parent | 43f0f227009722898d5c1a484c1b82030e42bedc (diff) | |
| parent | df537d0dfb0d776a346f5c04aca6cb5f090c0b1a (diff) | |
| download | tcl-ecda933dfc862ebf78720a334cba598bd3fca8bd.zip tcl-ecda933dfc862ebf78720a334cba598bd3fca8bd.tar.gz tcl-ecda933dfc862ebf78720a334cba598bd3fca8bd.tar.bz2 | |
Merge trunk.
Implementation looks complete. Still missing: test-cases and documentation.
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 ea25d4b..eb23f72 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 */, |
