TIP #241: CASE-INSENSITIVE SWITCHES AND LIST SEARCHING AND SORTING ==================================================================== Version: $Revision: 1.6 $ Author: Joe Mistachkin State: Final Type: Project Tcl-Version: 8.5 Vote: Done Created: Saturday, 26 February 2005 URL: https://tip.tcl-lang.org241.html Post-History: ------------------------------------------------------------------------- ABSTRACT ========== This TIP proposes a *-nocase* option for the *lsearch*, *lsort* and *switch* commands to allow for case-insensitive handling of the specified list. RATIONALE =========== 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*. SPECIFICATION =============== 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. REFERENCE IMPLEMENTATION ========================== A reference implementation of this TIP is available []. COPYRIGHT =========== This document has been placed in the public domain. ------------------------------------------------------------------------- TIP AutoGenerator - written by Donal K. Fellows