summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/misc/dirent/Makefile.in4
-rw-r--r--libc/misc/dirent/versionsort.c15
-rw-r--r--libc/misc/dirent/versionsort64.c17
3 files changed, 34 insertions, 2 deletions
diff --git a/libc/misc/dirent/Makefile.in b/libc/misc/dirent/Makefile.in
index e2a48e757..b3a017896 100644
--- a/libc/misc/dirent/Makefile.in
+++ b/libc/misc/dirent/Makefile.in
@@ -6,10 +6,10 @@
#
CSRC := alphasort.c closedir.c dirfd.c opendir.c readdir.c rewinddir.c \
- scandir.c seekdir.c telldir.c readdir_r.c
+ scandir.c seekdir.c telldir.c readdir_r.c versionsort.c
ifeq ($(UCLIBC_HAS_LFS),y)
-CSRC += readdir64.c alphasort64.c scandir64.c readdir64_r.c
+CSRC += readdir64.c alphasort64.c scandir64.c readdir64_r.c versionsort64.c
endif
MISC_DIRENT_DIR := $(top_srcdir)libc/misc/dirent
diff --git a/libc/misc/dirent/versionsort.c b/libc/misc/dirent/versionsort.c
new file mode 100644
index 000000000..53476e67f
--- /dev/null
+++ b/libc/misc/dirent/versionsort.c
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2008-2009 Hai Zaar, Codefidence Ltd <haizaar@codefidence.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <dirent.h>
+#include <string.h>
+#include "dirstream.h"
+
+int versionsort(const void *a, const void *b)
+{
+ return strverscmp((*(const struct dirent **) a)->d_name,
+ (*(const struct dirent **) b)->d_name);
+}
diff --git a/libc/misc/dirent/versionsort64.c b/libc/misc/dirent/versionsort64.c
new file mode 100644
index 000000000..684a46283
--- /dev/null
+++ b/libc/misc/dirent/versionsort64.c
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2008-2009 Hai Zaar, Codefidence Ltd <haizaar@codefidence.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <_lfs_64.h>
+
+#include <dirent.h>
+#include <string.h>
+#include "dirstream.h"
+
+int versionsort64(const void *a, const void *b)
+{
+ return strverscmp((*(const struct dirent64 **) a)->d_name,
+ (*(const struct dirent64 **) b)->d_name);
+}