\documentclass[]{article}
\usepackage{amsmath,graphicx,supertabular,hyperref,tabularx,ifthen}
\title{TIP \#241: Case-Insensitive Switches and List Searching and Sorting}
\date{February 26, 2005}
\author{Joe Mistachkin}
\urlstyle{sf}
\setlength{\parskip}{1ex}
\setlength{\parindent}{0pt}
\def\tipversion$#1${\texttt{\$#1\$}}
\def\tiplangle#1{\ensuremath{<}}
\def\tiprangle#1{\ensuremath{>}}
\def\tipbar#1{\ensuremath{|}}
\def\tipmail#1#2{\(\langle\){\small\expandafter\url{#1@#2}}\(\rangle\)}
\ifx\pdfoutput\undefined
\newcommand{\tipimage}[2]{\typeout{Make sure you download #1.eps}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.eps}}{\includegraphics[width=0.8\textwidth]{#1.eps}}}
\newcommand{\tipxref}[1]{}
\newcommand{\tipxrefend}{}
\else
\newcommand{\tipimage}[2]{\typeout{Make sure you create #1.pdf}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.pdf}}{\includegraphics[width=0.8\textwidth]{#1.pdf}}}
\pdfcatalog{/PageMode /UseOutlines}
\newcommand{\tipxref}[1]{\pdfannotlink attr {/C [0.5 0.5 1.0] /Border [0 0 1]} goto name {#1}}
\newcommand{\tipxrefend}{\pdfendlink}
\fi
\newenvironment{tipabstract}{\begin{abstract}}{\end{abstract}}
\begin{document}\maketitle
\begin{center}\begin{tabularx}{\linewidth}{|r@{: }X|}\hline
\textbf{TIP \#241}&\textbf{Case-Insensitive Switches and List Searching and Sorting}\\\hline
Author&

Joe Mistachkin \tipmail{joe}{mistachkin.com}
\\
Created&Saturday, \(\text{26}^{\text{th}}\) February 2005\\
Type&Project\\
Tcl Version&\(8.5\)\\
State&Final\\
Vote&Done\\
Version&\tipversion$Revision: 1.6 $\\
Keywords&Tcl, sorted lists, matching\\
Post History&\\
\hline\end{tabularx}\end{center}
\thispagestyle{empty}\pagestyle{empty}
\begin{tipabstract}

This TIP proposes a \textbf{-nocase} option for the \textbf{lsearch}, \textbf{lsort} and \textbf{switch} commands to allow for case-insensitive handling of the specified list.
\end{tipabstract}
\tableofcontents\setcounter{page}{0}\clearpage\pagestyle{plain}

\section{Rationale}

The \textbf{lsearch}, \textbf{lsort} and \textbf{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 \textbf{-nocase} option, various unnatural workarounds are required. In addition, the \textbf{-nocase} option will finally bring the \textbf{lsearch} command into parity with the other comparison related operations, including \textbf{string compare}, \textbf{string match}, and \textbf{regexp}.

\section{Specification}

Options will be added like this:

\begin{quote}
\textbf{lsearch} ?\textbf{-nocase}? \textit{list} \textit{pattern}
\end{quote}

\begin{quote}
\textbf{lsort} ?\textbf{-nocase}? \textit{list}
\end{quote}

\begin{quote}
\textbf{switch} ?\textbf{-nocase}? \textit{string bodyDefinition}
\end{quote}

For \textbf{lsearch}, the \textbf{-nocase} option can be used with the \textbf{-ascii}, \textbf{-exact}, \textbf{-glob}, and \textbf{-regexp} options. It indicates that the string of the found entry of \textit{list} should match \textit{pattern} case-insensitively. It is compatible with the \textbf{-all}, \textbf{-decreasing}, \textbf{-increasing}, \textbf{-inline}, \textbf{-not} and \textbf{-start} options.

For \textbf{lsort}, the \textbf{-nocase} option can be used with the \textbf{-ascii} option. It indicates that the list should be sorted based on a case-insensitive ordering. It is compatible with the \textbf{-decreasing}, \textbf{-increasing}, \textbf{-index} and \textbf{-unique} options.

For both \textbf{lsearch} and \textbf{lsort}, the \textbf{-nocase} option has no effect when used with the \textbf{-dictionary}, \textbf{-integer}, or \textbf{-real} options. For \textbf{lsort}, the \textbf{-nocase} option has no effect when used with the \textbf{-command} option.

For \textbf{switch}, the \textbf{-nocase} option can be used with all three matching modes (\textbf{-exact}, \textbf{-glob}, \textbf{-regexp}) and indicates that the matching of \textit{string} should be performed in a case-insensitive manner.

\section{Reference Implementation}

A reference implementation of this TIP is available [\url{http://sourceforge.net/tracker/index.php?func=detail&aid=1152746&group_id=10894&atid=310894}].

\section{Copyright}

This document has been placed in the public domain.

\section{Colophon}

\textit{TIP AutoGenerator --- written by Donal K. Fellows}
\end{document}
