annotate m4/tsearch.m4 @ 11219:aaeb2f86d096

Fix *printf behaviour regarding the %ls directive.
author Bruno Haible <bruno@clisp.org>
date Thu, 26 Feb 2009 12:54:20 +0100
parents 53dc0fa4233a
children 56ceeef91c22
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9595
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
1 # tsearch.m4 serial 3
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
2 dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
7585
0cac6db530a1 New module 'tsearch'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 dnl This file is free software; the Free Software Foundation
0cac6db530a1 New module 'tsearch'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
0cac6db530a1 New module 'tsearch'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
0cac6db530a1 New module 'tsearch'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6
0cac6db530a1 New module 'tsearch'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 AC_DEFUN([gl_FUNC_TSEARCH],
0cac6db530a1 New module 'tsearch'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 [
8532
11f6a87d953a New module 'search'.
Bruno Haible <bruno@clisp.org>
parents: 7585
diff changeset
9 AC_REQUIRE([gl_SEARCH_H_DEFAULTS])
11f6a87d953a New module 'search'.
Bruno Haible <bruno@clisp.org>
parents: 7585
diff changeset
10 AC_CHECK_FUNCS([tsearch])
9595
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
11 if test $ac_cv_func_tsearch = yes; then
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
12 dnl On OpenBSD 4.0, the return value of tdelete() is incorrect.
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
13 AC_REQUIRE([AC_PROG_CC])
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
14 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
15 AC_CACHE_CHECK([whether tdelete works], [gl_cv_func_tdelete_works],
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
16 [
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
17 AC_TRY_RUN([
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
18 #include <stddef.h>
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
19 #include <search.h>
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
20 static int
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
21 cmp_fn (const void *a, const void *b)
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
22 {
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
23 return *(const int *) a - *(const int *) b;
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
24 }
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
25 int
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
26 main ()
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
27 {
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
28 int x = 0;
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
29 void *root = NULL;
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
30 if (!(tfind (&x, &root, cmp_fn) == NULL)) return 1;
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
31 tsearch (&x, &root, cmp_fn);
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
32 if (!(tfind (&x, &root, cmp_fn) != NULL)) return 1;
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
33 if (!(tdelete (&x, &root, cmp_fn) != NULL)) return 1;
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
34 return 0;
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
35 }], [gl_cv_func_tdelete_works=yes], [gl_cv_func_tdelete_works=no],
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
36 [case "$host_os" in
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
37 openbsd*) gl_cv_func_tdelete_works="guessing no";;
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
38 *) gl_cv_func_tdelete_works="guessing yes";;
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
39 esac
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
40 ])
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
41 ])
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
42 case "$gl_cv_func_tdelete_works" in
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
43 *no)
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
44 REPLACE_TSEARCH=1
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
45 AC_LIBOBJ([tsearch])
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
46 gl_PREREQ_TSEARCH
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
47 ;;
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
48 esac
53dc0fa4233a Work around OpenBSD 4.0 tdelete() bug.
Bruno Haible <bruno@clisp.org>
parents: 8532
diff changeset
49 else
8532
11f6a87d953a New module 'search'.
Bruno Haible <bruno@clisp.org>
parents: 7585
diff changeset
50 HAVE_TSEARCH=0
11f6a87d953a New module 'search'.
Bruno Haible <bruno@clisp.org>
parents: 7585
diff changeset
51 AC_LIBOBJ([tsearch])
7585
0cac6db530a1 New module 'tsearch'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 gl_PREREQ_TSEARCH
0cac6db530a1 New module 'tsearch'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 fi
0cac6db530a1 New module 'tsearch'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 ])
0cac6db530a1 New module 'tsearch'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55
0cac6db530a1 New module 'tsearch'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 # Prerequisites of lib/tsearch.c.
0cac6db530a1 New module 'tsearch'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 AC_DEFUN([gl_PREREQ_TSEARCH], [
0cac6db530a1 New module 'tsearch'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 :
0cac6db530a1 New module 'tsearch'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 ])