Mercurial > hg > octave-shane > gnulib-hg
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 |
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 | 3 dnl This file is free software; the Free Software Foundation |
4 dnl gives unlimited permission to copy and/or distribute it, | |
5 dnl with or without modifications, as long as this notice is preserved. | |
6 | |
7 AC_DEFUN([gl_FUNC_TSEARCH], | |
8 [ | |
8532 | 9 AC_REQUIRE([gl_SEARCH_H_DEFAULTS]) |
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 | 50 HAVE_TSEARCH=0 |
51 AC_LIBOBJ([tsearch]) | |
7585 | 52 gl_PREREQ_TSEARCH |
53 fi | |
54 ]) | |
55 | |
56 # Prerequisites of lib/tsearch.c. | |
57 AC_DEFUN([gl_PREREQ_TSEARCH], [ | |
58 : | |
59 ]) |