shell32/autocomplete: Sort the enumerated strings using a helper function.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Gabriel Ivăncescu 2018-11-28 18:27:46 +02:00 committed by Alexandre Julliard
parent 1582ae6b04
commit d288d4dbd1

View file

@ -103,11 +103,16 @@ static void set_text_and_selection(IAutoCompleteImpl *ac, HWND hwnd, WCHAR *text
CallWindowProcW(proc, hwnd, EM_SETSEL, start, end);
}
static int enumerate_strings_cmpfn(const void *a, const void *b)
static int sort_strs_cmpfn(const void *a, const void *b)
{
return strcmpiW(*(WCHAR* const*)a, *(WCHAR* const*)b);
}
static void sort_strs(WCHAR **strs, UINT numstrs)
{
qsort(strs, numstrs, sizeof(*strs), sort_strs_cmpfn);
}
/*
Enumerate all of the strings and sort them in the internal list.
@ -140,7 +145,7 @@ static void enumerate_strings(IAutoCompleteImpl *ac)
{
strs = tmp;
if (cur > 0)
qsort(strs, cur, sizeof(*strs), enumerate_strings_cmpfn);
sort_strs(strs, cur);
ac->enum_strs = strs;
ac->enum_strs_num = cur;