summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2003-04-28 10:05:14 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2003-04-28 10:05:14 (GMT)
commit270dd26ada27456d73cfdcaf7623fee880227569 (patch)
tree60a15fad984f16bbee15913a3f56f55381838c15
parent044b2f3286bfc5afce188db48744bc1512a55cea (diff)
downloadtcl-270dd26ada27456d73cfdcaf7623fee880227569.zip
tcl-270dd26ada27456d73cfdcaf7623fee880227569.tar.gz
tcl-270dd26ada27456d73cfdcaf7623fee880227569.tar.bz2
Default mode of operation of [switch] is exact matching. [Bug 727563]
-rw-r--r--ChangeLog5
-rw-r--r--generic/tclCompCmds.c4
-rw-r--r--tests/switch.test23
3 files changed, 28 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 76bdcde..6a2e9ab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2003-04-28 Donal K. Fellows <fellowsd@cs.man.ac.uk>
+
+ * generic/tclCompCmds.c (TclCompileSwitchCmd): Default mode of
+ operation of [switch] is exact matching. [Bug 727563]
+
2003-04-25 Don Porter <dgp@users.sourceforge.net>
* generic/tclBasic.c: Tcl_EvalObjv() failed to honor the
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index ee4e809..ce8c76d 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.c
@@ -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: tclCompCmds.c,v 1.46 2003/04/07 20:00:47 dgp Exp $
+ * RCS: @(#) $Id: tclCompCmds.c,v 1.47 2003/04/28 10:05:27 dkf Exp $
*/
#include "tclInt.h"
@@ -2902,7 +2902,7 @@ TclCompileSwitchCmd(interp, parsePtr, envPtr)
* If no control flag present, use glob matching. We end up
* re-checking this word, but that's the way things are...
*/
- mode = Switch_Glob;
+ mode = Switch_Exact;
} else {
return TCL_OUT_LINE_COMPILE;
}
diff --git a/tests/switch.test b/tests/switch.test
index 153557f..cfc80ec 100644
--- a/tests/switch.test
+++ b/tests/switch.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: switch.test,v 1.8 2003/03/05 22:31:24 dkf Exp $
+# RCS: @(#) $Id: switch.test,v 1.9 2003/04/28 10:05:28 dkf Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -331,7 +331,26 @@ test switch-10.9 {comparison of compiled and interpreted behaviour of switch, ex
test switch-10.10 {comparison of compiled and interpreted behaviour of switch, glob matching with default} {
expr {[cswtest2-glob abcb] eq [iswtest2-glob abcb]}
} 1
-
+proc cswtest-default-exact {x} {
+ switch -- $x {
+ a* {return b}
+ aa {return c}
+ default {return d}
+ }
+}
+test switch-10.11 {default to exact matching when compiled} {
+ cswtest-default-exact a
+} d
+test switch-10.12 {default to exact matching when compiled} {
+ cswtest-default-exact aa
+} c
+test switch-10.13 {default to exact matching when compiled} {
+ cswtest-default-exact a*
+} b
+test switch-10.14 {default to exact matching when compiled} {
+ cswtest-default-exact a**
+} d
+rename cswtest-default-exact {}
rename cswtest-glob {}
rename iswtest-glob {}
rename cswtest2-glob {}