diff options
author | sebres <sebres@users.sourceforge.net> | 2024-03-08 13:31:41 (GMT) |
---|---|---|
committer | sebres <sebres@users.sourceforge.net> | 2024-03-08 13:31:41 (GMT) |
commit | 2f4b14eb621e899aa118933870b6af34d9f3b022 (patch) | |
tree | 534ecb27a07b2398aea7f136a5a0b7ce328ba026 | |
parent | 0f4cecde6f8e9135d771818d7b1410d575b8dfce (diff) | |
parent | 17b2152b59677828539fa420e11f2b11e79450f9 (diff) | |
download | tcl-2f4b14eb621e899aa118933870b6af34d9f3b022.zip tcl-2f4b14eb621e899aa118933870b6af34d9f3b022.tar.gz tcl-2f4b14eb621e899aa118933870b6af34d9f3b022.tar.bz2 |
merge 8.6
-rw-r--r-- | generic/tclNamesp.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index dab51c3..0648b25 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -2237,7 +2237,7 @@ TclGetNamespaceForQualName( * TCL_FIND_ONLY_NS was specified. */ { Interp *iPtr = (Interp *) interp; - Namespace *nsPtr = cxtNsPtr; + Namespace *nsPtr = cxtNsPtr, *lastNsPtr = NULL, *lastAltNsPtr = NULL; Namespace *altNsPtr; Namespace *globalNsPtr = iPtr->globalNsPtr; const char *start, *end; @@ -2378,17 +2378,12 @@ TclGetNamespaceForQualName( if (nsPtr == NULL) { Tcl_Panic("Could not create namespace '%s'", nsName); } - } 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; - } + } else { + /* + * Namespace not found and was not created. + * Remember last found namespace for TCL_FIND_IF_NOT_SIMPLE. + */ + lastNsPtr = nsPtr; nsPtr = NULL; } } @@ -2410,6 +2405,8 @@ TclGetNamespaceForQualName( if (entryPtr != NULL) { altNsPtr = (Namespace *)Tcl_GetHashValue(entryPtr); } else { + /* Remember last found in alternate path */ + lastAltNsPtr = altNsPtr; altNsPtr = NULL; } } @@ -2419,6 +2416,17 @@ TclGetNamespaceForQualName( */ if ((nsPtr == NULL) && (altNsPtr == NULL)) { + if (flags & TCL_FIND_IF_NOT_SIMPLE) { + /* + * return last found NS, regardless simple name or not, + * e. g. ::A::B::C::D -> ::A::B and C::D, if namespace C + * cannot be found in ::A::B + */ + nsPtr = lastNsPtr; + altNsPtr = lastAltNsPtr; + *simpleNamePtr = start; + goto done; + } *simpleNamePtr = NULL; goto done; } |