summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--generic/tclCompCmds.c15
2 files changed, 7 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 860597d..5ca8133 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
* generic/tclCompCmds.c (TclCompileRegexpCmd): clean up comments,
only free dstring on OK from TclReToGlob.
+ (TclCompileSwitchCmd): simplify TclReToGlob usage.
2007-11-14 Donal K. Fellows <dkf@users.sf.net>
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index 60f209f..f16d579 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.125 2007/11/14 00:50:50 hobbs Exp $
+ * RCS: @(#) $Id: tclCompCmds.c,v 1.126 2007/11/14 00:56:44 hobbs Exp $
*/
#include "tclInt.h"
@@ -4090,7 +4090,6 @@ TclCompileSwitchCmd(
if (bodyToken[i]->type == TCL_TOKEN_TEXT) {
Tcl_DString ds;
- simple = 1;
if (bodyToken[i]->size == 0) {
/*
* The semantics of regexps are that they always match
@@ -4106,17 +4105,15 @@ TclCompileSwitchCmd(
* the converted pattern.
*/
- Tcl_DStringInit(&ds);
if (TclReToGlob(NULL, bodyToken[i]->start,
- bodyToken[i]->size, &ds, &exact) != TCL_OK) {
- TclCompileTokens(interp, bodyToken[i], 1, envPtr);
- simple = 0;
- } else {
+ bodyToken[i]->size, &ds, &exact) == TCL_OK) {
+ simple = 1;
PushLiteral(envPtr, Tcl_DStringValue(&ds),
Tcl_DStringLength(&ds));
+ Tcl_DStringFree(&ds);
}
- Tcl_DStringFree(&ds);
- } else {
+ }
+ if (!simple) {
TclCompileTokens(interp, bodyToken[i], 1, envPtr);
}