|Title:||Case-Insensitive Switches and List Searching and Sorting|
|Version:||$Revision: 1.6 $|
|Author:||Joe Mistachkin <joe at mistachkin dot com>|
|Created:||Saturday, 26 February 2005|
|Keywords:||Tcl, sorted lists, matching|
This TIP proposes a -nocase option for the lsearch, lsort and switch commands to allow for case-insensitive handling of the specified list.
The lsearch, lsort and switch commands are very flexible and powerful. However, in certain situations the ability to perform case-insensitive searching and sorting is absolutely required (such as searching fully qualified file names on file systems that do not differentiate between upper and lower case). Without the -nocase option, various unnatural workarounds are required. In addition, the -nocase option will finally bring the lsearch command into parity with the other comparison related operations, including string compare, string match, and regexp.
Options will be added like this:
lsearch ?-nocase? list pattern
lsort ?-nocase? list
switch ?-nocase? string bodyDefinition
For lsearch, the -nocase option can be used with the -ascii, -exact, -glob, and -regexp options. It indicates that the string of the found entry of list should match pattern case-insensitively. It is compatible with the -all, -decreasing, -increasing, -inline, -not and -start options.
For lsort, the -nocase option can be used with the -ascii option. It indicates that the list should be sorted based on a case-insensitive ordering. It is compatible with the -decreasing, -increasing, -index and -unique options.
For both lsearch and lsort, the -nocase option has no effect when used with the -dictionary, -integer, or -real options. For lsort, the -nocase option has no effect when used with the -command option.
For switch, the -nocase option can be used with all three matching modes (-exact, -glob, -regexp) and indicates that the matching of string should be performed in a case-insensitive manner.
A reference implementation of this TIP is available .
This document has been placed in the public domain.
[Index] [History] [HTML Format] [Source Format] [LaTeX Format] [Text Format] [XML Format] [*roff Format (experimental)] [RTF Format (experimental)]TIP AutoGenerator - written by Donal K. Fellows