diff options
author | Steve Bennett <steveb@workware.net.au> | 2010-12-14 10:41:40 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2010-12-14 11:01:28 +1000 |
commit | 7e50b8cbb20c3cee9193249d0150aa6f5cc778ee (patch) | |
tree | e61058463b8b2b320e09b01b48c581c245047829 | |
parent | 66a081898ffe0ebc643284160b4e937872274c5f (diff) | |
download | jimtcl-7e50b8cbb20c3cee9193249d0150aa6f5cc778ee.zip jimtcl-7e50b8cbb20c3cee9193249d0150aa6f5cc778ee.tar.gz jimtcl-7e50b8cbb20c3cee9193249d0150aa6f5cc778ee.tar.bz2 |
Include all double colons as part of the var name
e.g. $::a::b is considered as ${::a::b}
This helps be more Tcl compatible by allowing fake namespace variables
Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r-- | jim.c | 11 | ||||
-rw-r--r-- | tests/misc.test | 7 |
2 files changed, 13 insertions, 5 deletions
@@ -1309,12 +1309,13 @@ static int JimParseVar(struct JimParserCtx *pc) } } else { - /* Include leading colons */ - while (*pc->p == ':') { - pc->p++; - pc->len--; - } while (!stop) { + /* Skip double colon, but not single colon! */ + if (pc->p[0] == ':' && pc->len > 1 && pc->p[1] == ':') { + pc->p += 2; + pc->len -= 2; + continue; + } if (!((*pc->p >= 'a' && *pc->p <= 'z') || (*pc->p >= 'A' && *pc->p <= 'Z') || (*pc->p >= '0' && *pc->p <= '9') || *pc->p == '_')) diff --git a/tests/misc.test b/tests/misc.test index 5fb84cb..f9a2de7 100644 --- a/tests/misc.test +++ b/tests/misc.test @@ -331,4 +331,11 @@ test split-1.1 "Split with leading null" { split "\0abc\0def\0" \0 } {{} abc def {}} +test parsevar-1.1 "Variables should include double colons" { + set ::a::b 2 + set x $::a::b + unset ::a::b + set x +} 2 + testreport |