Overview
| Artifact ID: | 9d6c5d541b086a28ffe568297581c16d61ce2d0e300ddd90b35e2ffaade7008b |
|---|---|
| Ticket: | 63449c05144fa85be0217ee3f82a78c6605bbdd3
[namespace children] doesn't match non-glob patterns below the global namespace |
| User & Date: | stu on 2024-02-22 07:17:55 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-plain"
- comment changed to:
# Create namespaces namespace eval a { namespace eval b {} } # Good result with non-glob pattern, and global namespace namespace children :: a ;# => ::a # Good result with single-char glob pattern, and other namespace namespace children a {[b]} ;# => ::a::b # Good result because of glob char in pattern, and other namespace namespace children a b* ;# => ::a::b # Bad result with non-glob pattern, and other namespace namespace children a b ;# => {} In generic/tclNamespace.c, function NamespaceChildrenCmd (lines 2988-3108), Tcl_StringMatch will be called if a glob char is present in the pattern, otherwise the matching will be performed with a combination of strncmp() and Tcl_FindHashEntry: line 3067: if ((pattern != NULL) && TclMatchIsTrivial(pattern)) { The hash table lookup: line 3075 or 3078: Tcl_FindHashEntry(&nsPtr->childTable, pattern+length) != NULL These two chars might be added but they won't be taken into account when matching: lines 3053-3055: if (nsPtr != globalNsPtr) { TclDStringAppendLiteral(&buffer, "::"); } With a quick hack patch: -Tcl_FindHashEntry(&nsPtr->childTable, pattern+length) != NULL +Tcl_FindHashEntry(&nsPtr->childTable, 2+pattern+length) != NULL The child namespace can now be found: namespace children a b ;# => ::a::b However namespace ::a can no longer be found in the global namespace! namespace children :: a ;# => {} The two namespace separator ("::") chars are not being accounted for properly. - foundin changed to: "Current"
- is_private changed to: "0"
- login: "stu"
- priority changed to: "5 Medium"
- private_contact changed to: "702b65e835b7b4b4720d6e9d37fc582f82909394"
- resolution changed to: "None"
- severity changed to: "Important"
- status changed to: "Open"
- submitter changed to: "stu"
- subsystem changed to: "21. [namespace]"
- title changed to:
[namespace children] doesn't match non-glob patterns below the global namespace
- type changed to: "Bug"