diff options
author | dgp <dgp@noemail.net> | 2011-03-09 16:42:06 (GMT) |
---|---|---|
committer | dgp <dgp@noemail.net> | 2011-03-09 16:42:06 (GMT) |
commit | 98312d80dfdffa585474a65d663f851c5c7db594 (patch) | |
tree | a7cb38052fffb01584c3102dd50121cc02f7855b /generic/tclNamesp.c | |
parent | f039711530152ec7b9ac3e60316fbb75d0122593 (diff) | |
parent | 0b1d5aa85d4e7d161ede43b31811c2df1687c4e1 (diff) | |
download | tcl-98312d80dfdffa585474a65d663f851c5c7db594.zip tcl-98312d80dfdffa585474a65d663f851c5c7db594.tar.gz tcl-98312d80dfdffa585474a65d663f851c5c7db594.tar.bz2 |
* generic/tclNamesp.c: Tighten the detector of nested [namespace code]
* tests/namespace.test: quoting that the quoted scripts function
properly even in a namespace that contains a custom "namespace"
command. [Bug 3202171]
* doc/tclvars.n: Formatting fix. Thanks to Pat Thotys.
FossilOrigin-Name: 52f5d3218acc2595a2cb5c620acde30703ef9820
Diffstat (limited to 'generic/tclNamesp.c')
-rw-r--r-- | generic/tclNamesp.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index a777d27..1d84131 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -3077,7 +3077,7 @@ NamespaceCodeCmd( { Namespace *currNsPtr; Tcl_Obj *listPtr, *objPtr; - register const char *arg, *p; + register const char *arg; int length; if (objc != 3) { @@ -3087,21 +3087,17 @@ NamespaceCodeCmd( /* * If "arg" is already a scoped value, then return it directly. + * Take care to only check for scoping in precisely the style that + * [::namespace code] generates it. Anything more forgiving can have + * the effect of failing in namespaces that contain their own custom + " "namespace" command. [Bug 3202171]. */ arg = TclGetStringFromObj(objv[2], &length); - while (*arg == ':') { - arg++; - length--; - } - if (*arg=='n' && length>17 && strncmp(arg, "namespace", 9)==0) { - for (p=arg+9 ; isspace(UCHAR(*p)) ; p++) { - /* empty body: skip over whitespace */ - } - if (*p=='i' && (p+7 <= arg+length) && strncmp(p, "inscope", 7)==0) { - Tcl_SetObjResult(interp, objv[2]); - return TCL_OK; - } + if (*arg==':' && length > 20 + && strncmp(arg, "::namespace inscope ", 20) == 0) { + Tcl_SetObjResult(interp, objv[2]); + return TCL_OK; } /* |