[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] new casefold completion patch
From: |
Peder Stray |
Subject: |
[PATCH] new casefold completion patch |
Date: |
22 Sep 2001 11:39:19 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 |
just minor correction. a < shoould have been <=. any comments greatly
appreciated.
--- bash-2.05/lib/readline/complete.c.foldfix Wed Feb 14 13:47:18 2001
+++ bash-2.05/lib/readline/complete.c Sat Sep 22 11:19:04 2001
@@ -747,7 +747,7 @@
}
/* Find the common prefix of the list of matches, and put it into
- matches[0]. */
+ match_list[0]. */
static int
compute_lcd_of_matches (match_list, matches, text)
char **match_list;
@@ -803,7 +803,42 @@
else
{
match_list[0] = xmalloc (low + 1);
- strncpy (match_list[0], match_list[1], low);
+
+ /* If we use case folding, try to keep the same case as text */
+ if (_rl_completion_case_fold)
+ {
+
+ if (strlen(text) <= low)
+ {
+ /* we need a sorted list to get consistent answers */
+ qsort (match_list+1, matches, sizeof (char *),
+ (QSFUNC *)_rl_qsort_string_compare);
+
+ /* find the first entry in match_list with text as prefix */
+ for (i = 1; i <= matches; i++)
+ if (!strncmp(match_list[i], text, strlen (text)))
+ {
+ strncpy (match_list[0], match_list[i], low);
+ break;
+ }
+
+ /* no casematch, so use the first entry */
+ if (i > matches)
+ strncpy (match_list[0], match_list[1], low);
+
+ }
+ else
+ {
+ /* else just use text */
+ strncpy (match_list[0], text, low);
+ }
+
+ }
+ else
+ {
+ strncpy (match_list[0], match_list[1], low);
+ }
+
match_list[0][low] = '\0';
}
--
[ IRL: Peder Stray ]
[ "A new life awaits you in the off world colonies" ]
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] new casefold completion patch,
Peder Stray <=