summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-05-13 15:03:08 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-05-14 20:16:44 +0200
commit91c38de28f885458cb5364e0280e0cb230ee9956 (patch)
treed6d843d7d834198d73d13cb4eeb5a2083483687e /lib
parentcbdf1e6dfaa895b12c40cfb2aa15dee65f0b85d6 (diff)
downloadbarebox-91c38de28f885458cb5364e0280e0cb230ee9956.tar.gz
barebox-91c38de28f885458cb5364e0280e0cb230ee9956.tar.xz
glob: Add sorted output support
This allows us for example to execute init scripts in the correct order. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/glob.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/glob.c b/lib/glob.c
index 74d2b123e3..c4c60674b6 100644
--- a/lib/glob.c
+++ b/lib/glob.c
@@ -22,6 +22,7 @@ Cambridge, MA 02139, USA. */
#include <malloc.h>
#include <xfuncs.h>
#include <fnmatch.h>
+#include <qsort.h>
#define _GNU_SOURCE
#include <glob.h>
@@ -75,12 +76,10 @@ int glob_pattern_p(const char *pattern, int quote)
#ifdef CONFIG_GLOB_SORT
/* Do a collated comparison of A and B. */
-static int collated_compare(a, b)
-const __ptr_t a;
-const __ptr_t b;
+static int collated_compare(const void *a, const void *b)
{
- const char *const s1 = *(const char *const *)a;
- const char *const s2 = *(const char *const *)b;
+ const char *s1 = a;
+ const char *s2 = b;
if (s1 == s2)
return 0;
@@ -266,7 +265,7 @@ int glob(const char *pattern, int flags,
/* Sort the vector. */
qsort((__ptr_t) & pglob->gl_pathv[oldcount],
pglob->gl_pathc - oldcount,
- sizeof(char *), (__compar_fn_t) collated_compare);
+ sizeof(char *), collated_compare);
#endif
status = 0;
out: