Overview
| Artifact ID: | 90399480ca1da52ea891a1523db238724af23abb |
|---|---|
| Ticket: | 759545ffffffffffffffffffffffffffffffffff
lsearch -dictionary documentation misleading |
| User & Date: | kenj on 2003-06-23 23:38:24 |
Changes
- assignee changed to: "dkf"
- cmimetype changed to: "text/plain"
- comment changed to:
Either the documentation for the lsearch -dictionary option is misleading, or the option isn't implemented properly. The documentation states: "-dictionary: The list elements are to be compared using dictionary-style comparisons. This option is only meaningful when used with -exact or -sorted." Drawing from the behavior of lsort -dictionary, one would assume that the lsearch -dictionary would be case- insensitive and handle embedded numbers appropriately. In other words, one might reasonably assume that both of the following lsearch commands would return 1: % set vals [lsort -dictionary {B4.GIF b13.gif b2.Gif B7.gif b8.gif}] b2.Gif B4.GIF B7.gif b8.gif b13.gif % lsearch -sorted -dictionary $vals b4.gif -1 % lsearch -exact -dictionary $vals b4.gif -1 In fact, they return -1. Thus, in reality the only use currently for lsearch -dictionary is to signal the the list is sorted equivalently to the return value of lsort - dictionary. In fact, given such a list, a programmer *must* use lsearch -dictionary; omitting it can fail to match successfully. For example: % lsearch -sorted -dictionary $vals B4.GIF 1 % lsearch -sorted $vals B4.GIF -1 Reading the code for lsearch in tclCmdIL.c, I'm not sure what is the intended operation of lsearch -dictionary in cases like this. Even in the case of a linear search (for example, if the user executes lsearch -exact - dictionary), the DictionaryCompare() function is used. But this is pointless, as the "secondary comparison" feature of DictionaryCompare() still reports "B4.GIF" as less than "b4.gif" (not equal), the same as a simple string comparison. So, I don't know what the proper resolution is. I see 2 options: 1) Change the documentation to indicate that the only purpose of lsearch -dictionary is to signal a "dictionary- sorted" list in conjunction with -sorted; or 2) Change the implementation of lsearch -dictionary to produce the following results from the above examples: % lsearch -sorted -dictionary $vals b4.gif 1 % lsearch -exact -dictionary $vals b4.gif 1 - foundin changed to: "obsolete: 8.4.2"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "kenj"
- subsystem changed to: "17. Commands I-L"
- title changed to: "lsearch -dictionary documentation misleading"
- type changed to: "Bug"