summaryrefslogtreecommitdiffstats
path: root/generic/tclObj.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2016-12-21 12:59:30 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2016-12-21 12:59:30 (GMT)
commitaef9317c2b61b05b7e2c172f1cb28a3dc3988829 (patch)
tree6205a7c7efe574d1e320fe1681ea1f171892e320 /generic/tclObj.c
parent9adc1d86b363addf539bedb62a8d19763f14d87c (diff)
downloadtcl-aef9317c2b61b05b7e2c172f1cb28a3dc3988829.zip
tcl-aef9317c2b61b05b7e2c172f1cb28a3dc3988829.tar.gz
tcl-aef9317c2b61b05b7e2c172f1cb28a3dc3988829.tar.bz2
Experimental (partial) fix for [39f6304c2e90549c209cd11a7920dc9921b9f48e|39f6304c2e]: Tcl_LinkVar is not tolerant to minus, plus, dot.
This handled minus and plus only, not other possible errors. Will need a TIP, because the boolean type is extended to consider '-', '+' and 'o' (necessary for being able to type 'on' or 'off') as valid booleans Dot, and integer prefixes (such as 0x) not handled yet, should be handled completely different.
Diffstat (limited to 'generic/tclObj.c')
-rw-r--r--generic/tclObj.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/generic/tclObj.c b/generic/tclObj.c
index 416e5ed..0c95e7c 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -2004,9 +2004,10 @@ static int
ParseBoolean(
register Tcl_Obj *objPtr) /* The object to parse/convert. */
{
- int i, length, newBool;
+ int newBool;
char lowerCase[6];
- const char *str = TclGetStringFromObj(objPtr, &length);
+ const char *str = TclGetString(objPtr);
+ size_t i, length = objPtr->length;
if ((length == 0) || (length > 5)) {
/*
@@ -2029,6 +2030,18 @@ ParseBoolean(
goto numericBoolean;
}
return TCL_ERROR;
+ case '-':
+ if (length == 1) {
+ newBool = 0;
+ goto goodBoolean;
+ }
+ return TCL_ERROR;
+ case '+':
+ if (length == 1) {
+ newBool = 1;
+ goto goodBoolean;
+ }
+ return TCL_ERROR;
}
/*
@@ -2082,15 +2095,12 @@ ParseBoolean(
}
return TCL_ERROR;
case 'o':
- if (length < 2) {
- return TCL_ERROR;
- }
- if (strncmp(lowerCase, "on", (size_t) length) == 0) {
- newBool = 1;
- goto goodBoolean;
- } else if (strncmp(lowerCase, "off", (size_t) length) == 0) {
+ if (strncmp(lowerCase, "off", (size_t) length) == 0) {
newBool = 0;
goto goodBoolean;
+ } else if (strncmp(lowerCase, "on", (size_t) length) == 0) {
+ newBool = 1;
+ goto goodBoolean;
}
return TCL_ERROR;
default: