summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2001-04-09 09:48:41 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2001-04-09 09:48:41 (GMT)
commit32c13b3778a26251f9c69ccc78007c9c1c9a21de (patch)
tree6417353e84ce8af8bb2b71b7b022d88fb6f9a359 /generic
parentb2a008bec7dcd0a3668e07ba075f89bb68d7b2d8 (diff)
downloadtcl-32c13b3778a26251f9c69ccc78007c9c1c9a21de.zip
tcl-32c13b3778a26251f9c69ccc78007c9c1c9a21de.tar.gz
tcl-32c13b3778a26251f9c69ccc78007c9c1c9a21de.tar.bz2
Recognise the non-numeric boolean literals (true,false,yes,no,on,off.)
[Bug #217777]
Diffstat (limited to 'generic')
-rw-r--r--generic/tclParseExpr.c50
1 files changed, 47 insertions, 3 deletions
diff --git a/generic/tclParseExpr.c b/generic/tclParseExpr.c
index fbdd9ea..ccd58a9 100644
--- a/generic/tclParseExpr.c
+++ b/generic/tclParseExpr.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: tclParseExpr.c,v 1.7 2000/05/09 00:00:35 hobbs Exp $
+ * RCS: @(#) $Id: tclParseExpr.c,v 1.8 2001/04/09 09:48:41 dkf Exp $
*/
#include "tclInt.h"
@@ -1199,7 +1199,7 @@ ParsePrimaryExpr(infoPtr)
exprTokenPtr->size = infoPtr->size;
exprTokenPtr->numComponents = 1;
break;
-
+
case DOLLAR:
/*
* $var variable reference.
@@ -1406,7 +1406,7 @@ ParsePrimaryExpr(infoPtr)
exprTokenPtr->size = (infoPtr->next - exprTokenPtr->start);
exprTokenPtr->numComponents = parsePtr->numTokens - firstIndex;
break;
-
+
default:
goto syntaxError;
}
@@ -1778,6 +1778,50 @@ GetLexeme(infoPtr)
infoPtr->size = (src - infoPtr->start);
infoPtr->next = src;
parsePtr->term = infoPtr->next;
+ /*
+ * Check for boolean literals (true, false, yes, no, on, off)
+ */
+ switch (infoPtr->start[0]) {
+ case 'f':
+ if (infoPtr->size == 5 &&
+ strncmp("false", infoPtr->start, 5) == 0) {
+ infoPtr->lexeme = LITERAL;
+ return TCL_OK;
+ }
+ break;
+ case 'n':
+ if (infoPtr->size == 2 &&
+ strncmp("no", infoPtr->start, 2) == 0) {
+ infoPtr->lexeme = LITERAL;
+ return TCL_OK;
+ }
+ break;
+ case 'o':
+ if (infoPtr->size == 3 &&
+ strncmp("off", infoPtr->start, 3) == 0) {
+ infoPtr->lexeme = LITERAL;
+ return TCL_OK;
+ } else if (infoPtr->size == 2 &&
+ strncmp("on", infoPtr->start, 2) == 0) {
+ infoPtr->lexeme = LITERAL;
+ return TCL_OK;
+ }
+ break;
+ case 't':
+ if (infoPtr->size == 4 &&
+ strncmp("true", infoPtr->start, 4) == 0) {
+ infoPtr->lexeme = LITERAL;
+ return TCL_OK;
+ }
+ break;
+ case 'y':
+ if (infoPtr->size == 3 &&
+ strncmp("yes", infoPtr->start, 3) == 0) {
+ infoPtr->lexeme = LITERAL;
+ return TCL_OK;
+ }
+ break;
+ }
return TCL_OK;
}
infoPtr->lexeme = UNKNOWN;