diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclParseExpr.c | 50 |
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; |