|
From: Jan N. <nij...@us...> - 2008-12-16 00:29:21
|
2008/12/12 Jan Nijtmans <jan...@gm...>: > 2008/12/12 Daniel A. Steffen <da...@us...>: >> No, if you want to stay backwards compatible, there is no way around a >> second hash table IMO, otherwise you cannot avoid key collision of >> ordinary entries (e.g. key "tk" for package "tk") with phony entries >> (e.g. case-folded key "tk" for package "Tk") I am stubborn enough to experiment with a solution that doesn't need a second hash table. The collision is prevented by removing the phony entries as soon as a real entry for the same package name is encountered. Apart from that, I tried to be as close as possible to the ideas discussed in this thread. The resulting patch is available at: https://sourceforge.net/tracker2/?func=detail&aid=2432057&group_id=10894&atid=310894 but I'll outline the idea here. The idea is, not trying to make package handling case-insensitive, but in stead only handle the situation that someone provides a package "FooBar" and we want to make it available under the name "foobar" as well. So, "foobar" is a phony package. We do that by changing "package require FooBar" such that it automatically provides "foobar" as wel, if it was not provided before. In addition, providing a new real "foobar" package, where a phony "foobar" was already provided, no longer is an error, it just ignores the phony package. The "ifneeded" is changed to work as if package ifneeded FooBar $version somescript automatically does: package ifneeded foobar $version [list package require -exact FooBar $version] as well. The extra "package provide" (as in Don's original idea) is not neccesary, because that is handled by the "package provide" which is already in the loaded package. The nice thing here is that from the ifneeded script we can immediately see if the package is phony or not. For phony packages the ifneeded script is always a 5-element list in which the 4th element is the name of the real package! That's transparent! The implementation starts with extending the Package structure with a flag "real", and extend the FindPackage with an extra "Package **phony" argument. Every time an entry is created in the hashtable for "FooBar", another entry "foobar" is created as well. If the package name is lowercase, FindPackage functions as before, otherwise the additional phony package is returned as well as the real package. This function is used in a lot of other places. Then the changes to "package ifneeded" and "package provide" are rather streight-forward. The only possible incompatibility is that extra phony package names can magically apprear and disappear: every time a real package name might conflict with a phony package, the situation is handled as if the phony package simply doesn't exist. The only problem there is left, is that autoMkindex.test crashes, I'm still trying to debug that (if someone has a good debugger, I appreciate help in tracing this down, somewhere still is a bug). All other tests pass, even some additional ones that I wrote (but didn't include in this patch, I should have done that......). It's late now, so my apologies if this mail is a little condensed.... Regards, Jan Nijtmans |