summaryrefslogtreecommitdiffstats
path: root/generic/tclNamesp.c
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2024-03-08 13:35:50 (GMT)
committersebres <sebres@users.sourceforge.net>2024-03-08 13:35:50 (GMT)
commite2289c9ee3d4e7c6427d60926f2c05696812f359 (patch)
tree488e0485fbcb12d7589c8530f00ceed5d9a08da2 /generic/tclNamesp.c
parent9f323759ed36ceb562207b565028db3fc8877326 (diff)
parent2f4b14eb621e899aa118933870b6af34d9f3b022 (diff)
downloadtcl-e2289c9ee3d4e7c6427d60926f2c05696812f359.zip
tcl-e2289c9ee3d4e7c6427d60926f2c05696812f359.tar.gz
tcl-e2289c9ee3d4e7c6427d60926f2c05696812f359.tar.bz2
merge 8.7
Diffstat (limited to 'generic/tclNamesp.c')
-rw-r--r--generic/tclNamesp.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c
index 8030699..6b57e6c 100644
--- a/generic/tclNamesp.c
+++ b/generic/tclNamesp.c
@@ -2234,7 +2234,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;
@@ -2375,17 +2375,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;
}
}
@@ -2407,6 +2402,8 @@ TclGetNamespaceForQualName(
if (entryPtr != NULL) {
altNsPtr = (Namespace *)Tcl_GetHashValue(entryPtr);
} else {
+ /* Remember last found in alternate path */
+ lastAltNsPtr = altNsPtr;
altNsPtr = NULL;
}
}
@@ -2416,6 +2413,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;
}