diff options
author | Ron Yorston <rmy@pobox.com> | 2018-12-08 20:25:14 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-12-08 20:25:14 +0000 |
commit | 44477db354f67c4eacfced89fac5fbf3dbeaa3ff (patch) | |
tree | 23d74f8c25decf11c9745a9cc0dac164aedbb731 | |
parent | 195902a645b794092959ac3818f367104c7ffeb8 (diff) | |
download | busybox-w32-44477db354f67c4eacfced89fac5fbf3dbeaa3ff.tar.gz busybox-w32-44477db354f67c4eacfced89fac5fbf3dbeaa3ff.tar.bz2 busybox-w32-44477db354f67c4eacfced89fac5fbf3dbeaa3ff.zip |
lineedit: more case-insensitive comparisons in tab completion
-rw-r--r-- | include/mingw.h | 1 | ||||
-rw-r--r-- | libbb/bb_qsort.c | 12 | ||||
-rw-r--r-- | libbb/lineedit.c | 14 |
3 files changed, 27 insertions, 0 deletions
diff --git a/include/mingw.h b/include/mingw.h index a828e6613..b8c0b12b5 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
@@ -448,6 +448,7 @@ int kill_SIGTERM_by_handle(HANDLE process, int exit_code); | |||
448 | #define find_mount_point(n, s) find_mount_point(n) | 448 | #define find_mount_point(n, s) find_mount_point(n) |
449 | 449 | ||
450 | char *is_prefixed_with_case(const char *string, const char *key) FAST_FUNC; | 450 | char *is_prefixed_with_case(const char *string, const char *key) FAST_FUNC; |
451 | void qsort_string_vector_case(char **sv, unsigned count) FAST_FUNC; | ||
451 | 452 | ||
452 | /* | 453 | /* |
453 | * helpers | 454 | * helpers |
diff --git a/libbb/bb_qsort.c b/libbb/bb_qsort.c index 505045533..7afddf468 100644 --- a/libbb/bb_qsort.c +++ b/libbb/bb_qsort.c | |||
@@ -17,3 +17,15 @@ void FAST_FUNC qsort_string_vector(char **sv, unsigned count) | |||
17 | { | 17 | { |
18 | qsort(sv, count, sizeof(char*), bb_pstrcmp); | 18 | qsort(sv, count, sizeof(char*), bb_pstrcmp); |
19 | } | 19 | } |
20 | |||
21 | #if ENABLE_PLATFORM_MINGW32 | ||
22 | static int bb_pstrcasecmp(const void *a, const void *b) | ||
23 | { | ||
24 | return strcasecmp(*(char**)a, *(char**)b); | ||
25 | } | ||
26 | |||
27 | void FAST_FUNC qsort_string_vector_case(char **sv, unsigned count) | ||
28 | { | ||
29 | qsort(sv, count, sizeof(char*), bb_pstrcasecmp); | ||
30 | } | ||
31 | #endif | ||
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 979e0d544..89178bbc3 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -684,6 +684,9 @@ static void input_forward(void) | |||
684 | # if ENABLE_PLATFORM_MINGW32 | 684 | # if ENABLE_PLATFORM_MINGW32 |
685 | /* use case-insensitive comparisons for filenames */ | 685 | /* use case-insensitive comparisons for filenames */ |
686 | # define is_prefixed_with(s, k) is_prefixed_with_case(s, k) | 686 | # define is_prefixed_with(s, k) is_prefixed_with_case(s, k) |
687 | # define qsort_string_vector(s, c) qsort_string_vector_case(s, c) | ||
688 | # define strcmp(s, t) strcasecmp(s, t) | ||
689 | # define strncmp(s, t, n) strncasecmp(s, t, n) | ||
687 | # endif | 690 | # endif |
688 | 691 | ||
689 | static void free_tab_completion_data(void) | 692 | static void free_tab_completion_data(void) |
@@ -1278,7 +1281,11 @@ static NOINLINE void input_tab(smallint *lastWasTab) | |||
1278 | for (cp = chosen_match; *cp; cp++) { | 1281 | for (cp = chosen_match; *cp; cp++) { |
1279 | unsigned n; | 1282 | unsigned n; |
1280 | for (n = 1; n < num_matches; n++) { | 1283 | for (n = 1; n < num_matches; n++) { |
1284 | # if !ENABLE_PLATFORM_MINGW32 | ||
1281 | if (matches[n][cp - chosen_match] != *cp) { | 1285 | if (matches[n][cp - chosen_match] != *cp) { |
1286 | # else | ||
1287 | if (tolower(matches[n][cp - chosen_match]) != tolower(*cp)) { | ||
1288 | # endif | ||
1282 | goto stop; | 1289 | goto stop; |
1283 | } | 1290 | } |
1284 | } | 1291 | } |
@@ -1351,6 +1358,13 @@ static NOINLINE void input_tab(smallint *lastWasTab) | |||
1351 | free(match_buf); | 1358 | free(match_buf); |
1352 | } | 1359 | } |
1353 | 1360 | ||
1361 | # if ENABLE_PLATFORM_MINGW32 | ||
1362 | # undef is_prefixed_with | ||
1363 | # undef qsort_string_vector | ||
1364 | # undef strcmp | ||
1365 | # undef strncmp | ||
1366 | # endif | ||
1367 | |||
1354 | #endif /* FEATURE_TAB_COMPLETION */ | 1368 | #endif /* FEATURE_TAB_COMPLETION */ |
1355 | 1369 | ||
1356 | 1370 | ||