diff options
| author | sebres <sebres@users.sourceforge.net> | 2024-03-06 19:22:10 (GMT) |
|---|---|---|
| committer | sebres <sebres@users.sourceforge.net> | 2024-03-06 19:22:10 (GMT) |
| commit | ea30fa77faf70296eb26e071f149f8a935a8bc30 (patch) | |
| tree | b5ba4a3c203f42933f688d27fc3626c1493614a7 /generic/tclNamesp.c | |
| parent | 5a74f345ac466a0a61b8c46bdcb3576848e6f987 (diff) | |
| download | tcl-ea30fa77faf70296eb26e071f149f8a935a8bc30.zip tcl-ea30fa77faf70296eb26e071f149f8a935a8bc30.tar.gz tcl-ea30fa77faf70296eb26e071f149f8a935a8bc30.tar.bz2 | |
better variant of fix for [910d67a229fe7f65] with improved search for NS::command (find NS even if command is not simple name), additionally
it'd invoke handler of parent NS if child NS doesn't have unknown handler (see test namespace-52.14)
Diffstat (limited to 'generic/tclNamesp.c')
| -rw-r--r-- | generic/tclNamesp.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index 290dcea..37092fe 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -2280,11 +2280,8 @@ TclGetNamespaceForQualName( if (flags & TCL_FIND_ONLY_NS) { nsName = start; } else { - *nsPtrPtr = nsPtr; - *altNsPtrPtr = altNsPtr; *simpleNamePtr = start; - Tcl_DStringFree(&buffer); - return TCL_OK; + goto done; } } else { /* @@ -2334,6 +2331,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; } } @@ -2364,11 +2370,8 @@ TclGetNamespaceForQualName( */ if ((nsPtr == NULL) && (altNsPtr == NULL)) { - *nsPtrPtr = NULL; - *altNsPtrPtr = NULL; *simpleNamePtr = NULL; - Tcl_DStringFree(&buffer); - return TCL_OK; + goto done; } start = end; @@ -2398,6 +2401,7 @@ TclGetNamespaceForQualName( nsPtr = NULL; } +done: *nsPtrPtr = nsPtr; *altNsPtrPtr = altNsPtr; Tcl_DStringFree(&buffer); |
