From d57739782fbedbebcf73b5375258d0b7791740ce Mon Sep 17 00:00:00 2001 From: Peter Howkins Date: Tue, 3 Sep 2013 14:34:11 +0100 Subject: [PATCH] dtstyle: Alphabetically sort the backdrops in the backdrop list. --- cde/programs/dtstyle/Backdrop.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cde/programs/dtstyle/Backdrop.c b/cde/programs/dtstyle/Backdrop.c index 33c48e1d..0760cfb8 100644 --- a/cde/programs/dtstyle/Backdrop.c +++ b/cde/programs/dtstyle/Backdrop.c @@ -42,6 +42,8 @@ /* include files */ /*+++++++++++++++++++++++++++++++++++++++*/ #include +#include +#include #include #if defined(_AIX) || defined(__apollo) @@ -538,6 +540,17 @@ MoreBitmaps( void ) backdrops.maxNumBitmaps += 100; } +/************************************************************************ + * cmpstringp() + * qsort() sort function, used for sorting bitmap names into alphabetical order + * can't use strcmp() due to char** rather than char* + ************************************************************************/ +static int +cmpstringp(const void *p1, const void *p2) +{ + return strcmp(*(char * const *) p1, *(char * const *) p2); +} + /************************************************************************ * ReadBitmaps() * Create an array of bitmaps by reading backdrop directories in the @@ -595,6 +608,9 @@ static free_dirList(backdrops.dirList, backdrops.dirCount); return 0; } + + /* Sort the list into alphanetical order */ + qsort(backdrops.tmpBitmapNames, backdrops.tmpNumBitmaps, sizeof(char *), cmpstringp); /* get the fg/bg colors from Dtwm */ if (backdrops.newColors) -- 2.25.1