svn commit: trunk/uClibc: include libc/misc/dirent
vda at uclibc.org
vda at uclibc.org
Sun Feb 8 22:40:17 UTC 2009
Author: vda
Date: 2009-02-08 22:40:17 +0000 (Sun, 08 Feb 2009)
New Revision: 25265
Log:
Add strverscmp() and versionsort[64]().
By Hai Zaar (haizaar AT codefidence.com)
Added:
trunk/uClibc/libc/misc/dirent/versionsort.c
trunk/uClibc/libc/misc/dirent/versionsort64.c
Modified:
trunk/uClibc/include/dirent.h
trunk/uClibc/include/string.h
trunk/uClibc/libc/misc/dirent/Makefile.in
Changeset:
Modified: trunk/uClibc/include/dirent.h
===================================================================
--- trunk/uClibc/include/dirent.h 2009-02-08 11:00:44 UTC (rev 25264)
+++ trunk/uClibc/include/dirent.h 2009-02-08 22:40:17 UTC (rev 25265)
@@ -293,6 +293,25 @@
__THROW __attribute_pure__ __nonnull ((1, 2));
# endif
+/* Function to compare two `struct dirent's alphabetically. */
+# ifndef __USE_FILE_OFFSET64
+extern int versionsort (__const void *__e1, __const void *__e2)
+ __THROW __attribute_pure__ __nonnull ((1, 2));
+# else
+# ifdef __REDIRECT
+extern int __REDIRECT (versionsort,
+ (__const void *__e1, __const void *__e2),
+ versionsort64) __attribute_pure__ __nonnull ((1, 2));
+# else
+# define versionsort versionsort64
+# endif
+# endif
+
+# if defined __USE_GNU && defined __USE_LARGEFILE64
+extern int versionsort64 (__const void *__e1, __const void *__e2)
+ __THROW __attribute_pure__ __nonnull ((1, 2));
+# endif
+
#endif /* Use BSD or misc. */
__END_DECLS
Modified: trunk/uClibc/include/string.h
===================================================================
--- trunk/uClibc/include/string.h 2009-02-08 11:00:44 UTC (rev 25264)
+++ trunk/uClibc/include/string.h 2009-02-08 22:40:17 UTC (rev 25265)
@@ -422,11 +422,9 @@
#ifdef __USE_GNU
/* Compare S1 and S2 as strings holding name & indices/version numbers. */
-# if 0
extern int strverscmp (__const char *__s1, __const char *__s2)
__THROW __attribute_pure__ __nonnull ((1, 2));
libc_hidden_proto(strverscmp)
-# endif
/* Return a string describing the meaning of the signal number in SIG. */
extern char *strsignal (int __sig) __THROW;
Modified: trunk/uClibc/libc/misc/dirent/Makefile.in
===================================================================
--- trunk/uClibc/libc/misc/dirent/Makefile.in 2009-02-08 11:00:44 UTC (rev 25264)
+++ trunk/uClibc/libc/misc/dirent/Makefile.in 2009-02-08 22:40:17 UTC (rev 25265)
@@ -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
Added: trunk/uClibc/libc/misc/dirent/versionsort.c
===================================================================
--- trunk/uClibc/libc/misc/dirent/versionsort.c (rev 0)
+++ trunk/uClibc/libc/misc/dirent/versionsort.c 2009-02-08 22:40:17 UTC (rev 25265)
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2008-2009 Hai Zaar, Codefidence Ltd <haizaar at 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);
+}
Added: trunk/uClibc/libc/misc/dirent/versionsort64.c
===================================================================
--- trunk/uClibc/libc/misc/dirent/versionsort64.c (rev 0)
+++ trunk/uClibc/libc/misc/dirent/versionsort64.c 2009-02-08 22:40:17 UTC (rev 25265)
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2008-2009 Hai Zaar, Codefidence Ltd <haizaar at 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);
+}
More information about the uClibc-cvs
mailing list