Mercurial > hg > octave-nkf > gnulib-hg
annotate m4/strtok_r.m4 @ 14079:97fc9a21a8fb
maint: update almost all copyright ranges to include 2011
Run the new "make update-copyright" rule.
author | Jim Meyering <meyering@redhat.com> |
---|---|
date | Sat, 01 Jan 2011 20:17:23 +0100 |
parents | bc49ffbc1e03 |
children | c9ecfab74059 |
rev | line source |
---|---|
14019
bc49ffbc1e03
strtok_r: Fix C syntax error in autoconf macro.
Bruno Haible <bruno@clisp.org>
parents:
13503
diff
changeset
|
1 # strtok_r.m4 serial 12 |
14079
97fc9a21a8fb
maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents:
14019
diff
changeset
|
2 dnl Copyright (C) 2002-2004, 2006-2007, 2009-2011 Free Software Foundation, |
12559
c2cbabec01dd
update nearly all FSF copyright year lists to include 2010
Jim Meyering <meyering@redhat.com>
parents:
11961
diff
changeset
|
3 dnl Inc. |
5611
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5434
diff
changeset
|
4 dnl This file is free software; the Free Software Foundation |
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5434
diff
changeset
|
5 dnl gives unlimited permission to copy and/or distribute it, |
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5434
diff
changeset
|
6 dnl with or without modifications, as long as this notice is preserved. |
5434 | 7 |
8 AC_DEFUN([gl_FUNC_STRTOK_R], | |
9 [ | |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
8814
diff
changeset
|
10 dnl The strtok_r() declaration in lib/string.in.h uses 'restrict'. |
8814
04b21457982b
Ensure AC_C_RESTRICT is invoked.
Bruno Haible <bruno@clisp.org>
parents:
7982
diff
changeset
|
11 AC_REQUIRE([AC_C_RESTRICT]) |
04b21457982b
Ensure AC_C_RESTRICT is invoked.
Bruno Haible <bruno@clisp.org>
parents:
7982
diff
changeset
|
12 |
7982
6b61aba76343
Enforce ordering constraints between gl_HEADER_STRING_H_DEFAULTS and the
Bruno Haible <bruno@clisp.org>
parents:
7944
diff
changeset
|
13 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) |
11960
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
14 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
15 AC_CHECK_FUNCS([strtok_r]) |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
16 if test $ac_cv_func_strtok_r = yes; then |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
17 dnl glibc 2.7 has a bug in strtok_r that causes a segmentation fault |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
18 dnl when the second argument to strtok_r is a constant string that has |
14019
bc49ffbc1e03
strtok_r: Fix C syntax error in autoconf macro.
Bruno Haible <bruno@clisp.org>
parents:
13503
diff
changeset
|
19 dnl exactly one byte and compiling with optimization. This bug is, for |
11960
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
20 dnl example, present in the glibc 2.7-18 package in Debian "lenny". |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
21 dnl See <http://sources.redhat.com/bugzilla/show_bug.cgi?id=5614>. |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
22 AC_CACHE_CHECK([whether strtok_r works], [gl_cv_func_strtok_r_works], |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
23 [AC_RUN_IFELSE( |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
24 [AC_LANG_PROGRAM([[ |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
25 #ifndef __OPTIMIZE__ |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
26 # define __OPTIMIZE__ 1 |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
27 #endif |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
28 #undef __OPTIMIZE_SIZE__ |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
29 #undef __NO_INLINE__ |
11961
53f6a3c1d867
For NULL, include <stdlib.h>, not <stdio.h>.
Bruno Haible <bruno@clisp.org>
parents:
11960
diff
changeset
|
30 #include <stdlib.h> |
11960
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
31 #include <string.h> |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
32 ]], |
13503
d352958def8f
strtok_r: Avoid triggering bug in AIX 7.1 xlc compiler.
Bruno Haible <bruno@clisp.org>
parents:
13160
diff
changeset
|
33 [[static const char dummy[] = "\177\01a"; |
d352958def8f
strtok_r: Avoid triggering bug in AIX 7.1 xlc compiler.
Bruno Haible <bruno@clisp.org>
parents:
13160
diff
changeset
|
34 char delimiters[] = "xxxxxxxx"; |
14019
bc49ffbc1e03
strtok_r: Fix C syntax error in autoconf macro.
Bruno Haible <bruno@clisp.org>
parents:
13503
diff
changeset
|
35 char *save_ptr = (char *) dummy; |
bc49ffbc1e03
strtok_r: Fix C syntax error in autoconf macro.
Bruno Haible <bruno@clisp.org>
parents:
13503
diff
changeset
|
36 strtok_r (delimiters, "x", &save_ptr); |
bc49ffbc1e03
strtok_r: Fix C syntax error in autoconf macro.
Bruno Haible <bruno@clisp.org>
parents:
13503
diff
changeset
|
37 strtok_r (NULL, "x", &save_ptr); |
bc49ffbc1e03
strtok_r: Fix C syntax error in autoconf macro.
Bruno Haible <bruno@clisp.org>
parents:
13503
diff
changeset
|
38 return 0; |
11960
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
39 ]]) |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
40 ], |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
41 [gl_cv_func_strtok_r_works=yes], |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
42 [gl_cv_func_strtok_r_works=no], |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
43 [ |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
44 changequote(,)dnl |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
45 case "$host_os" in |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
46 # Guess no on glibc systems. |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
47 *-gnu*) gl_cv_func_strtok_r_works="guessing no";; |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
48 *) gl_cv_func_strtok_r_works="guessing yes";; |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
49 esac |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
50 changequote([,])dnl |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
51 ]) |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
52 ]) |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
53 case "$gl_cv_func_strtok_r_works" in |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
54 *no) |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
55 dnl We could set REPLACE_STRTOK_R=1 and AC_LIBOBJ([strtok_r]) here, |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
56 dnl but it's only the macro version in <bits/string2.h> which is wrong. |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
57 dnl The code compiled into libc is fine. |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
58 UNDEFINE_STRTOK_R=1 |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
59 ;; |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
60 esac |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
61 else |
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
62 AC_LIBOBJ([strtok_r]) |
13160 | 63 gl_PREREQ_STRTOK_R |
11960
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11007
diff
changeset
|
64 fi |
11007
f6cba5a556ce
many *.m4 files: improve m4 quoting
Jim Meyering <meyering@redhat.com>
parents:
9264
diff
changeset
|
65 AC_CHECK_DECLS_ONCE([strtok_r]) |
7944
a1d177cd9523
* doc/gnulib-tool.texi (Initial import): Update to match current
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
66 if test $ac_cv_have_decl_strtok_r = no; then |
a1d177cd9523
* doc/gnulib-tool.texi (Initial import): Update to match current
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
67 HAVE_DECL_STRTOK_R=0 |
a1d177cd9523
* doc/gnulib-tool.texi (Initial import): Update to match current
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
68 fi |
5434 | 69 ]) |
70 | |
7944
a1d177cd9523
* doc/gnulib-tool.texi (Initial import): Update to match current
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
71 # Prerequisites of lib/strtok_r.c. |
5434 | 72 AC_DEFUN([gl_PREREQ_STRTOK_R], [ |
8814
04b21457982b
Ensure AC_C_RESTRICT is invoked.
Bruno Haible <bruno@clisp.org>
parents:
7982
diff
changeset
|
73 : |
5434 | 74 ]) |