- {
- /*
- * If this is a caseless search, convert
- * uppercase in the input line to lowercase.
- * While we're at it, remove any backspaces
- * along with the preceeding char.
- * This allows us to match text which is
- * underlined or overstruck.
- */
- for (p = q = line; *p != '\0'; p++, q++)
- {
- if (*p >= 'A' && *p <= 'Z')
- /* Convert uppercase to lowercase. */
- *q = *p + 'a' - 'A';
- else if (q > line && *p == '\b')
- /* Delete BS and preceeding char. */
- q -= 2;
- else
- /* Otherwise, just copy. */
- *q = *p;
- }
- }
+ for (p = q = line; *p; p++, q++)
+ *q = isupper(*p) ? tolower(*p) : *p;
+
+ /*
+ * Remove any backspaces along with the preceeding char.
+ * This allows us to match text which is underlined or
+ * overstruck.
+ */
+ for (p = q = line; *p; p++, q++)
+ if (q > line && *p == '\b')
+ /* Delete BS and preceeding char. */
+ q -= 2;
+ else
+ /* Otherwise, just copy. */
+ *q = *p;