summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhobbs <hobbs>2007-12-23 21:29:40 (GMT)
committerhobbs <hobbs>2007-12-23 21:29:40 (GMT)
commitf98c90831ad984d50a60f541c50fd3b85c05a6e6 (patch)
tree90b1e3cd3e2b5290c96cf7533067296260067ca9
parentf762a775b0f50b12a52f497f0cc0078e0be159f5 (diff)
downloadtcl-f98c90831ad984d50a60f541c50fd3b85c05a6e6.zip
tcl-f98c90831ad984d50a60f541c50fd3b85c05a6e6.tar.gz
tcl-f98c90831ad984d50a60f541c50fd3b85c05a6e6.tar.bz2
* generic/tclCompCmds.c (TclCompileRegexpCmd): TCL_REG_NOSUB cannot
* tests/regexp.test (regexp-22.2): be used because it * tests/regexpComp.test: [Bug 1857126] disallows backrefs.
-rw-r--r--ChangeLog6
-rw-r--r--generic/tclCompCmds.c11
-rw-r--r--tests/regexp.test5
-rw-r--r--tests/regexpComp.test12
4 files changed, 27 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 0ee3b92..b07d174 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-12-23 Jeff Hobbs <jeffh@ActiveState.com>
+
+ * generic/tclCompCmds.c (TclCompileRegexpCmd): TCL_REG_NOSUB cannot
+ * tests/regexp.test (regexp-22.2): be used because it
+ * tests/regexpComp.test: [Bug 1857126] disallows backrefs.
+
2007-12-21 Miguel Sofer <msofer@users.sf.net>
* generic/tclCmdIL.c: speed patch for lsort [Patch 1856994].
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index 7dbcc2a..83bb1ae 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCompCmds.c,v 1.138 2007/12/19 21:09:37 hobbs Exp $
+ * RCS: @(#) $Id: tclCompCmds.c,v 1.139 2007/12/23 21:29:41 hobbs Exp $
*/
#include "tclInt.h"
@@ -3195,10 +3195,9 @@ TclCompileRegexpCmd(
/*
* Pass correct RE compile flags. We use only Int1 (8-bit), but
* that handles all the flags we want to pass.
- * Use TCL_REG_NOSUB as we don't have capture vars.
+ * Don't use TCL_REG_NOSUB as we may have backrefs.
*/
- int cflags = TCL_REG_ADVANCED | TCL_REG_NOSUB
- | (nocase ? TCL_REG_NOCASE : 0);
+ int cflags = TCL_REG_ADVANCED | (nocase ? TCL_REG_NOCASE : 0);
TclEmitInstInt1(INST_REGEXP, cflags, envPtr);
}
@@ -4442,8 +4441,8 @@ TclCompileSwitchCmd(
/*
* Pass correct RE compile flags. We use only Int1
* (8-bit), but that handles all the flags we want to
- * pass.
- * Don't use TCL_REG_NOSUB as we may have capture vars.
+ * pass. Don't use TCL_REG_NOSUB as we may have backrefs
+ * or capture vars.
*/
int cflags = TCL_REG_ADVANCED
| (noCase ? TCL_REG_NOCASE : 0);
diff --git a/tests/regexp.test b/tests/regexp.test
index 5471ca5..92b6c6a 100644
--- a/tests/regexp.test
+++ b/tests/regexp.test
@@ -11,7 +11,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: regexp.test,v 1.29 2007/12/13 15:26:07 dgp Exp $
+# RCS: @(#) $Id: regexp.test,v 1.30 2007/12/23 21:29:42 hobbs Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -659,6 +659,9 @@ test regexp-22.1 {Bug 1810038} {
regexp ($|^X)* {}
} 1
+test regexp-22.2 {regexp compile and backrefs, Bug 1857126} {
+ regexp -- {([bc])\1} bb
+} 1
# cleanup
::tcltest::cleanupTests
diff --git a/tests/regexpComp.test b/tests/regexpComp.test
index 8460006..c104a69 100644
--- a/tests/regexpComp.test
+++ b/tests/regexpComp.test
@@ -802,6 +802,18 @@ test regexpComp-21.11 {regexp command compiling tests} {
}
} {0 {}}
+test regexpComp-22.1 {Bug 1810038} {
+ evalInProc {
+ regexp ($|^X)* {}
+ }
+} 1
+
+test regexpComp-22.2 {regexp compile and backrefs, Bug 1857126} {
+ evalInProc {
+ regexp -- {([bc])\1} bb
+ }
+} 1
+
set i 0
foreach {str exp result} {
foo ^foo 1