diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-03-07 21:58:26 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-03-07 21:58:26 (GMT) |
commit | 710fa5935db4072a97afaa19013c94e6911ed0dc (patch) | |
tree | 31610483f9dc283efd60fe6764bd582446548570 | |
parent | 4e5e3b0ad659dbebd39e0350556fc53805877af6 (diff) | |
download | tcl-710fa5935db4072a97afaa19013c94e6911ed0dc.zip tcl-710fa5935db4072a97afaa19013c94e6911ed0dc.tar.gz tcl-710fa5935db4072a97afaa19013c94e6911ed0dc.tar.bz2 |
Add internal flag TCL_FIND_IF_NOT_SIMPLE for (internal) TclGetNamespaceForQualName(). Not used yet.
-rw-r--r-- | generic/tclInt.h | 3 | ||||
-rw-r--r-- | generic/tclNamesp.c | 13 |
2 files changed, 14 insertions, 2 deletions
diff --git a/generic/tclInt.h b/generic/tclInt.h index 68c07f2..de92a7d 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -400,10 +400,13 @@ struct NamespacePathEntry { * TCL_NAMESPACE_ONLY - (see tcl.h) Look only in the context ns. * TCL_CREATE_NS_IF_UNKNOWN - Create unknown namespaces. * TCL_FIND_ONLY_NS - The name sought is a namespace name. + * TCL_FIND_IF_NOT_SIMPLE - Retrieve last namespace even if the rest of + * name is not simple name (contains ::). */ #define TCL_CREATE_NS_IF_UNKNOWN 0x800 #define TCL_FIND_ONLY_NS 0x1000 +#define TCL_FIND_IF_NOT_SIMPLE 0x2000 /* * The client data for an ensemble command. This consists of the table of diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index 96769eb..099e29f 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -2332,6 +2332,15 @@ TclGetNamespaceForQualName( } } else { /* Namespace not found and was not * created. */ + if (flags & TCL_FIND_IF_NOT_SIMPLE) { + /* + * return last found NS and not simple name relative it, + * e. g. ::A::B::C::D -> ::A::B and C::D, if + * namespace C cannot be found in ::A::B + */ + *simpleNamePtr = start; + goto done; + } nsPtr = NULL; } } @@ -2893,8 +2902,8 @@ GetNamespaceFromObj( resNamePtr = (ResolvedNsName *)objPtr->internalRep.twoPtrValue.ptr1; nsPtr = resNamePtr->nsPtr; refNsPtr = resNamePtr->refNsPtr; - if (!(nsPtr->flags & NS_DYING) && (interp == nsPtr->interp) && - (!refNsPtr || ((interp == refNsPtr->interp) && + if (!(nsPtr->flags & NS_DYING) && (interp == nsPtr->interp) + && (!refNsPtr || ((interp == refNsPtr->interp) && (refNsPtr == (Namespace *)Tcl_GetCurrentNamespace(interp))))){ *nsPtrPtr = (Tcl_Namespace *)nsPtr; return TCL_OK; |