diff options
Diffstat (limited to 'generic/tclCompCmds.c')
-rw-r--r-- | generic/tclCompCmds.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c index 24d72d2..d66f672 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.109.2.17 2007/12/10 18:32:55 dgp Exp $ + * RCS: @(#) $Id: tclCompCmds.c,v 1.109.2.18 2008/01/23 16:42:18 dgp Exp $ */ #include "tclInt.h" @@ -3134,6 +3134,7 @@ TclCompileRegexpCmd( /* * Get the regexp string. If it is not a simple string or can't be * converted to a glob pattern, push the word for the INST_REGEXP. + * Keep changes here in sync with TclCompileSwitchCmd Switch_Regexp. */ varTokenPtr = TokenAfter(varTokenPtr); @@ -3194,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); } @@ -4397,6 +4397,9 @@ TclCompileSwitchCmd( case Switch_Regexp: { int simple = 0, exact = 0; + /* + * Keep in sync with TclCompileRegexpCmd. + */ if (bodyToken[i]->type == TCL_TOKEN_TEXT) { Tcl_DString ds; @@ -4435,7 +4438,15 @@ TclCompileSwitchCmd( TclEmitInstInt1(INST_STR_MATCH, noCase, envPtr); } } else { - TclEmitInstInt1(INST_REGEXP, noCase, envPtr); + /* + * 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 backrefs + * or capture vars. + */ + int cflags = TCL_REG_ADVANCED + | (noCase ? TCL_REG_NOCASE : 0); + TclEmitInstInt1(INST_REGEXP, cflags, envPtr); } break; } |