Blame SOURCES/autofs-5.0.7-workaround-missing-GNU-versionsort-extension.patch

ab3a3d
autofs-5.0.7 - workaround missing GNU versionsort extension
ab3a3d
ab3a3d
From: Chris Packham <chris.packham@alliedtelesis.co.nz>
ab3a3d
ab3a3d
alphasort() and scandir() are specified in POSIX.1-2008, versionsort()
ab3a3d
is a GNU extension. When versionsort isn't available fallback to using
ab3a3d
alphasort.
ab3a3d
---
ab3a3d
ab3a3d
 CHANGELOG            |    1 +
ab3a3d
 configure            |   62 ++++++++++++++++++++++++++++++++++++++++++++++++++
ab3a3d
 configure.in         |    6 +++++
ab3a3d
 include/config.h.in  |    3 ++
ab3a3d
 modules/lookup_dir.c |    5 ++++
ab3a3d
 5 files changed, 77 insertions(+), 0 deletions(-)
ab3a3d
ab3a3d
ab3a3d
diff --git a/CHANGELOG b/CHANGELOG
ab3a3d
index 4eaa9f9..39388a5 100644
ab3a3d
--- a/CHANGELOG
ab3a3d
+++ b/CHANGELOG
ab3a3d
@@ -27,6 +27,7 @@
ab3a3d
 - lib/defaults.c: use WITH_LDAP conditional around LDAP types.
ab3a3d
 - make yellow pages support optional.
ab3a3d
 - modules/replicated.c: use sin6_addr.s6_addr32.
ab3a3d
+- workaround missing GNU versionsort extension.
ab3a3d
 
ab3a3d
 25/07/2012 autofs-5.0.7
ab3a3d
 =======================
ab3a3d
diff --git a/configure b/configure
ab3a3d
index cf6428c..c1423d8 100755
ab3a3d
--- a/configure
ab3a3d
+++ b/configure
ab3a3d
@@ -4010,6 +4010,68 @@ $as_echo "yes" >&6; }
ab3a3d
   KRB5_FLAGS=`$KRB5_CONFIG --cflags`
ab3a3d
 fi
ab3a3d
 
ab3a3d
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing versionsort" >&5
ab3a3d
+$as_echo_n "checking for library containing versionsort... " >&6; }
ab3a3d
+if ${ac_cv_search_versionsort+:} false; then :
ab3a3d
+  $as_echo_n "(cached) " >&6
ab3a3d
+else
ab3a3d
+  ac_func_search_save_LIBS=$LIBS
ab3a3d
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
ab3a3d
+/* end confdefs.h.  */
ab3a3d
+
ab3a3d
+/* Override any GCC internal prototype to avoid an error.
ab3a3d
+   Use char because int might match the return type of a GCC
ab3a3d
+   builtin and then its argument prototype would still apply.  */
ab3a3d
+#ifdef __cplusplus
ab3a3d
+extern "C"
ab3a3d
+#endif
ab3a3d
+char versionsort ();
ab3a3d
+int
ab3a3d
+main ()
ab3a3d
+{
ab3a3d
+return versionsort ();
ab3a3d
+  ;
ab3a3d
+  return 0;
ab3a3d
+}
ab3a3d
+_ACEOF
ab3a3d
+for ac_lib in '' ; do
ab3a3d
+  if test -z "$ac_lib"; then
ab3a3d
+    ac_res="none required"
ab3a3d
+  else
ab3a3d
+    ac_res=-l$ac_lib
ab3a3d
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
ab3a3d
+  fi
ab3a3d
+  if ac_fn_c_try_link "$LINENO"; then :
ab3a3d
+  ac_cv_search_versionsort=$ac_res
ab3a3d
+fi
ab3a3d
+rm -f core conftest.err conftest.$ac_objext \
ab3a3d
+    conftest$ac_exeext
ab3a3d
+  if ${ac_cv_search_versionsort+:} false; then :
ab3a3d
+  break
ab3a3d
+fi
ab3a3d
+done
ab3a3d
+if ${ac_cv_search_versionsort+:} false; then :
ab3a3d
+
ab3a3d
+else
ab3a3d
+  ac_cv_search_versionsort=no
ab3a3d
+fi
ab3a3d
+rm conftest.$ac_ext
ab3a3d
+LIBS=$ac_func_search_save_LIBS
ab3a3d
+fi
ab3a3d
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_versionsort" >&5
ab3a3d
+$as_echo "$ac_cv_search_versionsort" >&6; }
ab3a3d
+ac_res=$ac_cv_search_versionsort
ab3a3d
+if test "$ac_res" != no; then :
ab3a3d
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
ab3a3d
+
ab3a3d
+fi
ab3a3d
+
ab3a3d
+if test "$ac_cv_search_versionsort" = "no"; then
ab3a3d
+
ab3a3d
+$as_echo "#define WITHOUT_VERSIONSORT 1" >>confdefs.h
ab3a3d
+
ab3a3d
+fi
ab3a3d
+
ab3a3d
 #
ab3a3d
 # glibc/libc 6 new libraries
ab3a3d
 #
ab3a3d
diff --git a/configure.in b/configure.in
ab3a3d
index 363c376..4029375 100644
ab3a3d
--- a/configure.in
ab3a3d
+++ b/configure.in
ab3a3d
@@ -163,6 +163,12 @@ AF_SLOPPY_MOUNT()
ab3a3d
 AF_CHECK_LIBXML()
ab3a3d
 AF_CHECK_KRB5()
ab3a3d
 
ab3a3d
+AC_SEARCH_LIBS([versionsort],[])
ab3a3d
+if test "$ac_cv_search_versionsort" = "no"; then
ab3a3d
+	AC_DEFINE(WITHOUT_VERSIONSORT, 1,
ab3a3d
+		[Define if your C library does not provide versionsort])
ab3a3d
+fi
ab3a3d
+
ab3a3d
 #
ab3a3d
 # glibc/libc 6 new libraries
ab3a3d
 #
ab3a3d
diff --git a/include/config.h.in b/include/config.h.in
ab3a3d
index 7f1c5b5..a2a05a8 100644
ab3a3d
--- a/include/config.h.in
ab3a3d
+++ b/include/config.h.in
ab3a3d
@@ -135,6 +135,9 @@
ab3a3d
 /* Define to 1 to use the libtirpc tsd usage workaround */
ab3a3d
 #undef TIRPC_WORKAROUND
ab3a3d
 
ab3a3d
+/* Define if your C library does not provide versionsort */
ab3a3d
+#undef WITHOUT_VERSIONSORT
ab3a3d
+
ab3a3d
 /* Define if using the dmalloc debugging malloc package */
ab3a3d
 #undef WITH_DMALLOC
ab3a3d
 
ab3a3d
diff --git a/modules/lookup_dir.c b/modules/lookup_dir.c
ab3a3d
index 33901c0..07471b7 100644
ab3a3d
--- a/modules/lookup_dir.c
ab3a3d
+++ b/modules/lookup_dir.c
ab3a3d
@@ -39,6 +39,11 @@
ab3a3d
 #define AUTOFS_DIR_EXT ".autofs"
ab3a3d
 #define AUTOFS_DIR_EXTSIZ (sizeof(AUTOFS_DIR_EXT) - 1)
ab3a3d
 
ab3a3d
+/* Work around non-GNU systems that don't provide versionsort */
ab3a3d
+#ifdef WITHOUT_VERSIONSORT
ab3a3d
+#define versionsort alphasort
ab3a3d
+#endif
ab3a3d
+
ab3a3d
 struct lookup_context {
ab3a3d
   const char *mapname;
ab3a3d
 };