summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-10-04 13:56:37 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-10-04 13:56:37 (GMT)
commitf740197ce220d1842b0a408a30031c150b54db0c (patch)
tree85adf71928ce31288bb2fed800ac1caa4010064b
parentb33be65e4a3a29aae1ef59d24db32aff7dcb84ab (diff)
downloadtcl-f740197ce220d1842b0a408a30031c150b54db0c.zip
tcl-f740197ce220d1842b0a408a30031c150b54db0c.tar.gz
tcl-f740197ce220d1842b0a408a30031c150b54db0c.tar.bz2
Stop words starting with 'eq' or 'ne' from being subdivided by the expression
parser. [Bug 884830]
-rw-r--r--ChangeLog4
-rw-r--r--generic/tclParseExpr.c8
-rw-r--r--tests/expr.test10
3 files changed, 18 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 59606cc..c0c3fed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2004-10-04 Donal K. Fellows <donal.k.fellows@man.ac.uk>
+ * generic/tclParseExpr.c (GetLexeme): Ensure that the 'eq' and
+ 'ne' operators are followed by non-alphabetic characters so
+ lexemes can't run together. [Bug 884830]
+
* doc/DictObj.3, doc/dict.n: Clarified that a dictionary is not
order-preserving. [Bug 1032243] Also added another example to
show off more ways of using a dictionary and a few other
diff --git a/generic/tclParseExpr.c b/generic/tclParseExpr.c
index 2a8abec..266466c 100644
--- a/generic/tclParseExpr.c
+++ b/generic/tclParseExpr.c
@@ -13,7 +13,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclParseExpr.c,v 1.21 2004/04/06 22:25:54 dgp Exp $
+ * RCS: @(#) $Id: tclParseExpr.c,v 1.22 2004/10/04 13:56:37 dkf Exp $
*/
#include "tclInt.h"
@@ -1856,7 +1856,8 @@ GetLexeme(infoPtr)
return TCL_OK;
case 'e':
- if ((src[1] == 'q') && ((infoPtr->lastChar - src) > 1)) {
+ if ((src[1] == 'q') && ((infoPtr->lastChar - src) > 1) &&
+ (infoPtr->lastChar-src==2 || !isalpha(UCHAR(src[2])))) {
infoPtr->lexeme = STREQ;
infoPtr->size = 2;
infoPtr->next = src+2;
@@ -1867,7 +1868,8 @@ GetLexeme(infoPtr)
}
case 'n':
- if ((src[1] == 'e') && ((infoPtr->lastChar - src) > 1)) {
+ if ((src[1] == 'e') && ((infoPtr->lastChar - src) > 1) &&
+ (infoPtr->lastChar-src==2 || !isalpha(UCHAR(src[2])))) {
infoPtr->lexeme = STRNEQ;
infoPtr->size = 2;
infoPtr->next = src+2;
diff --git a/tests/expr.test b/tests/expr.test
index 4cfa615..4cc644e 100644
--- a/tests/expr.test
+++ b/tests/expr.test
@@ -10,7 +10,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: expr.test,v 1.27 2004/09/26 16:36:05 msofer Exp $
+# RCS: @(#) $Id: expr.test,v 1.28 2004/10/04 13:56:37 dkf Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -314,6 +314,14 @@ test expr-8.21 {CompileBitAndExpr: error in equality expr} {
catch {expr a eq b} msg
set msg
} {syntax error in expression "a eq b": variable references require preceding $}
+test expr-8.22 {CompileBitAndExpr: error in equality expr} {
+ catch {expr {false eqfalse}} msg
+ set msg
+} {syntax error in expression "false eqfalse": extra tokens at end of expression}
+test expr-8.23 {CompileBitAndExpr: error in equality expr} {
+ catch {expr {false nefalse}} msg
+ set msg
+} {syntax error in expression "false nefalse": extra tokens at end of expression}
test expr-9.1 {CompileRelationalExpr: just shift expr} {expr 3<<2} 12
test expr-9.2 {CompileRelationalExpr: just shift expr} {expr 0xff>>2} 63