diff options
author | dgp <dgp@noemail.net> | 2011-03-09 14:56:37 (GMT) |
---|---|---|
committer | dgp <dgp@noemail.net> | 2011-03-09 14:56:37 (GMT) |
commit | decb7e1a3a9bb6fe941bf62ed52b746820cd66d1 (patch) | |
tree | 7462dd2f8b6a7545c9a33c400f01d2a277ac4f29 /generic/tclNamesp.c | |
parent | 71e40ef264f4a326eecca459a6f074ca9acd17f8 (diff) | |
download | tcl-decb7e1a3a9bb6fe941bf62ed52b746820cd66d1.zip tcl-decb7e1a3a9bb6fe941bf62ed52b746820cd66d1.tar.gz tcl-decb7e1a3a9bb6fe941bf62ed52b746820cd66d1.tar.bz2 |
* generic/tclNamesp.c: Tighten the detector of nested [namespace code]
* tests/namespace.test: quoting that the quoted scriptsfunction
properly even in a namespace that contains a custom "namespace"
command. [Bug 3202171]
FossilOrigin-Name: ac4c249ecfb6ff77a5aac99c07d75270410ee002
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 1747c99..16f14e9 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -3007,7 +3007,7 @@ NamespaceCodeCmd( { Namespace *currNsPtr; Tcl_Obj *listPtr, *objPtr; - register char *arg, *p; + register char *arg; int length; if (objc != 3) { @@ -3017,21 +3017,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; } /* |