]> Savannah Git Hosting - gnulib.git/commitdiff
tsearch: Fix compilation error on Android.
authorBruno Haible <bruno@clisp.org>
Sun, 13 May 2018 22:02:48 +0000 (00:02 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 13 May 2018 22:02:48 +0000 (00:02 +0200)
* lib/search.in.h (twalk): Declare when HAVE_TWALK, not HAVE_TSEARCH,
is 0.
(GNULIB_defined_tsearch, GNULIB_defined_twalk): New macros.
* lib/tsearch.c (tsearch, tfind, tdelete): Define only if
GNULIB_defined_tsearch is true.
(twalk): Define only if GNULIB_defined_twalk is true.
* modules/tsearch (configure.ac): Compile tsearch.c also if HAVE_TWALK
is 0.
* m4/tsearch.m4 (gl_FUNC_TSEARCH): Set HAVE_TWALK.
* m4/search_h.m4 (gl_SEARCH_H_DEFAULTS): Initialize HAVE_TWALK.
* modules/search (Makefile.am): Substitute HAVE_TWALK.

ChangeLog
lib/search.in.h
lib/tsearch.c
m4/search_h.m4
m4/tsearch.m4
modules/search
modules/tsearch

index 9dc6edb5e641110279c118dd9fbeb3b894d0c618..4dee31dfe63083848b9744e376533eae20e80a89 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2018-05-13  Bruno Haible  <bruno@clisp.org>
+
+       tsearch: Fix compilation error on Android.
+       * lib/search.in.h (twalk): Declare when HAVE_TWALK, not HAVE_TSEARCH,
+       is 0.
+       (GNULIB_defined_tsearch, GNULIB_defined_twalk): New macros.
+       * lib/tsearch.c (tsearch, tfind, tdelete): Define only if
+       GNULIB_defined_tsearch is true.
+       (twalk): Define only if GNULIB_defined_twalk is true.
+       * modules/tsearch (configure.ac): Compile tsearch.c also if HAVE_TWALK
+       is 0.
+       * m4/tsearch.m4 (gl_FUNC_TSEARCH): Set HAVE_TWALK.
+       * m4/search_h.m4 (gl_SEARCH_H_DEFAULTS): Initialize HAVE_TWALK.
+       * modules/search (Makefile.am): Substitute HAVE_TWALK.
+
 2018-05-13  Bruno Haible  <bruno@clisp.org>
 
        imaxdiv: Fix compilation error on Android.
index ce0a0fdb0d8bb3d9f12a0cfa204e51c2c7599925..47a4460c80e83ccd0a9468b102bb9801abd99c54 100644 (file)
@@ -169,7 +169,7 @@ _GL_FUNCDECL_RPL (twalk, void,
 _GL_CXXALIAS_RPL (twalk, void,
                   (const void *vroot, _gl_search_action_fn action));
 # else
-#  if !@HAVE_TSEARCH@
+#  if !@HAVE_TWALK@
 _GL_FUNCDECL_SYS (twalk, void,
                   (const void *vroot, _gl_search_action_fn action)
                   _GL_ARG_NONNULL ((2)));
@@ -179,6 +179,10 @@ _GL_CXXALIAS_SYS (twalk, void,
 # endif
 _GL_CXXALIASWARN (twalk);
 
+/* Flags used by tsearch.c.  */
+# define GNULIB_defined_tsearch  (@REPLACE_TSEARCH@ || !@HAVE_TSEARCH@)
+# define GNULIB_defined_twalk    (@REPLACE_TSEARCH@ || !@HAVE_TWALK@)
+
 #elif defined GNULIB_POSIXCHECK
 # undef tsearch
 # if HAVE_RAW_DECL_TSEARCH
index bce1e9f0f6bd57908482e0582dc4246aac882607..dabd760631b9b208a24ae25f1d7caad722ae78e9 100644 (file)
@@ -174,6 +174,8 @@ check_tree (node root)
 
 #endif
 
+#if GNULIB_defined_tsearch
+
 /* Possibly "split" a node with two red successors, and/or fix up two red
    edges in a row.  ROOTP is a pointer to the lowest node we visited, PARENTP
    and GPARENTP pointers to its parent/grandparent.  P_R and GP_R contain the
@@ -612,6 +614,10 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar)
 weak_alias (__tdelete, tdelete)
 #endif
 
+#endif /* GNULIB_defined_tsearch */
+
+
+#if GNULIB_defined_twalk
 
 /* Walk the nodes of a tree.
    ROOT is the root of the tree to be walked, ACTION the function to be
@@ -654,6 +660,8 @@ __twalk (const void *vroot, __action_fn_t action)
 weak_alias (__twalk, twalk)
 #endif
 
+#endif /* GNULIB_defined_twalk */
+
 
 #ifdef _LIBC
 
index d2f7263ced008b89625d94b1518e4defe7421f92..66fe46431b087d80c0e855a8136a63a8bd2a43b0 100644 (file)
@@ -1,4 +1,4 @@
-# search_h.m4 serial 9
+# search_h.m4 serial 10
 dnl Copyright (C) 2007-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -56,5 +56,6 @@ AC_DEFUN([gl_SEARCH_H_DEFAULTS],
   GNULIB_TSEARCH=0; AC_SUBST([GNULIB_TSEARCH])
   dnl Assume proper GNU behavior unless another module says otherwise.
   HAVE_TSEARCH=1;    AC_SUBST([HAVE_TSEARCH])
+  HAVE_TWALK=1;      AC_SUBST([HAVE_TWALK])
   REPLACE_TSEARCH=0; AC_SUBST([REPLACE_TSEARCH])
 ])
index 87d0d90c7485aa667ecba09299fd6b0bbbbf1df2..82350c97616c658ac6c655e0b2f2d10f97355b7d 100644 (file)
@@ -1,4 +1,4 @@
-# tsearch.m4 serial 7
+# tsearch.m4 serial 8
 dnl Copyright (C) 2006-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_FUNC_TSEARCH],
 [
   AC_REQUIRE([gl_SEARCH_H_DEFAULTS])
-  AC_CHECK_FUNCS([tsearch])
+  AC_CHECK_FUNCS([tsearch twalk])
   if test $ac_cv_func_tsearch = yes; then
     dnl On OpenBSD 4.0, the return value of tdelete() is incorrect.
     AC_REQUIRE([AC_PROG_CC])
@@ -53,6 +53,9 @@ main ()
   else
     HAVE_TSEARCH=0
   fi
+  if test $ac_cv_func_twalk != yes; then
+    HAVE_TWALK=0
+  fi
 ])
 
 # Prerequisites of lib/tsearch.c.
index 70536ea5a9c1e504ef7a5fefac33bd73bc68d897..72dbe12a1bfedc17d13a8cc3add594b03a2cbcff 100644 (file)
@@ -31,6 +31,7 @@ search.h: search.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
              -e 's|@''HAVE_TYPE_VISIT''@|$(HAVE_TYPE_VISIT)|g' \
              -e 's/@''GNULIB_TSEARCH''@/$(GNULIB_TSEARCH)/g' \
              -e 's|@''HAVE_TSEARCH''@|$(HAVE_TSEARCH)|g' \
+             -e 's|@''HAVE_TWALK''@|$(HAVE_TWALK)|g' \
              -e 's|@''REPLACE_TSEARCH''@|$(REPLACE_TSEARCH)|g' \
              -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
              -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
index ffb952b8c16c5c80f6207850b5ee38c3978e1eed..4a2b5ed230a2d8fcbc544f61f997661dccdccfa6 100644 (file)
@@ -10,7 +10,7 @@ search
 
 configure.ac:
 gl_FUNC_TSEARCH
-if test $HAVE_TSEARCH = 0 || test $REPLACE_TSEARCH = 1; then
+if test $HAVE_TSEARCH = 0 || test $HAVE_TWALK = 0 || test $REPLACE_TSEARCH = 1; then
   AC_LIBOBJ([tsearch])
   gl_PREREQ_TSEARCH
 fi