summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-01-19 22:15:41 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2011-01-19 22:16:29 -0800
commit80905e10d427a3abdeb61e2677a6cbe0f8ac1aba (patch)
treee589c23789b3d0811bbd6f9c2203af595b9cd833
parentc93f15eceb7bad3fd57d32ebf7f0676fb5fd3247 (diff)
downloadgnulib-80905e10d427a3abdeb61e2677a6cbe0f8ac1aba.tar.gz
assume <ctype.h>, ..., <time.h> exist
For years gnulib has been assuming the existence of the headers <ctime.h>, <errno.h>, <fcntl.h>, <locale.h>, <signal.h>, <stdio.h>, <stdlib.h>, <string.h>, and <time.h>. Omit checks for them, since they don't appear to be needed. * README (Portability guidelines): Document this. * lib/flock.c: Assume <fcntl.h> exists. * lib/regex_internal.h: Assume <locale.h> exists. * m4/ctype.m4 (gl_CTYPE_H): Assume <ctype.h> exists. * m4/errno_h.m4 (gl_HEADER_ERRNO_H): Assume <errno.h> exists. * m4/fcntl_h.m4 (gl_FCNTL_H): Assume <fcntl.h> exists. * m4/flock.m4 (gl_PREREQ_FLOCK): Likewise. * m4/locale_h.m4 (gl_LOCALE_H): Assume <locale.h> exists. * m4/regex.m4 (gl_REGEX): Likewise. * m4/signal_h.m4 (gl_SIGNAL_H): Assume <signal.h> exists. * m4/stdio_h.m4 (gl_STDIO_H): Assume <stdio.h> exists. * m4/stdlib_h.m4 (gl_STDLIB_H): Assume <stdlib.h> exists. * m4/string_h.m4 (gl_STRING_H): Assume <string.h> exists. * tests/test-argp.c: Likewise. * m4/time_h.m4 (gl_HEADER_TIME_H_BODY): Assume <time.h> exists.
-rw-r--r--ChangeLog21
-rw-r--r--README11
-rw-r--r--lib/flock.c2
-rw-r--r--lib/regex_internal.h6
-rw-r--r--m4/ctype.m44
-rw-r--r--m4/errno_h.m44
-rw-r--r--m4/fcntl_h.m44
-rw-r--r--m4/flock.m44
-rw-r--r--m4/locale_h.m44
-rw-r--r--m4/regex.m456
-rw-r--r--m4/signal_h.m42
-rw-r--r--m4/stdio_h.m42
-rw-r--r--m4/stdlib_h.m44
-rw-r--r--m4/string_h.m44
-rw-r--r--m4/time_h.m44
-rw-r--r--tests/test-argp.c4
16 files changed, 74 insertions, 62 deletions
diff --git a/ChangeLog b/ChangeLog
index 41a445298f..167680366c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,26 @@
2011-01-19 Paul Eggert <eggert@cs.ucla.edu>
+ assume <ctype.h>, ..., <time.h> exist
+ For years gnulib has been assuming the existence of the headers
+ <ctime.h>, <errno.h>, <fcntl.h>, <locale.h>, <signal.h>,
+ <stdio.h>, <stdlib.h>, <string.h>, and <time.h>. Omit checks for
+ them, since they don't appear to be needed.
+ * README (Portability guidelines): Document this.
+ * lib/flock.c: Assume <fcntl.h> exists.
+ * lib/regex_internal.h: Assume <locale.h> exists.
+ * m4/ctype.m4 (gl_CTYPE_H): Assume <ctype.h> exists.
+ * m4/errno_h.m4 (gl_HEADER_ERRNO_H): Assume <errno.h> exists.
+ * m4/fcntl_h.m4 (gl_FCNTL_H): Assume <fcntl.h> exists.
+ * m4/flock.m4 (gl_PREREQ_FLOCK): Likewise.
+ * m4/locale_h.m4 (gl_LOCALE_H): Assume <locale.h> exists.
+ * m4/regex.m4 (gl_REGEX): Likewise.
+ * m4/signal_h.m4 (gl_SIGNAL_H): Assume <signal.h> exists.
+ * m4/stdio_h.m4 (gl_STDIO_H): Assume <stdio.h> exists.
+ * m4/stdlib_h.m4 (gl_STDLIB_H): Assume <stdlib.h> exists.
+ * m4/string_h.m4 (gl_STRING_H): Assume <string.h> exists.
+ * tests/test-argp.c: Likewise.
+ * m4/time_h.m4 (gl_HEADER_TIME_H_BODY): Assume <time.h> exists.
+
multiarch: remove AA_APPLE_UNIVERSAL_BUILD
* m4/multiarch.m4 (gl_MULTIARCH): Don't AC_DEFINE
AA_APPLE_UNIVERSAL_BUILD. See
diff --git a/README b/README
index 0d8ac6dd88..492827a03e 100644
--- a/README
+++ b/README
@@ -221,13 +221,16 @@ some point we may start assuming a C89 library as well.
Because we assume a freestanding C89 compiler, Gnulib code can include
<float.h>, <limits.h>, <stdarg.h>, and <stddef.h> unconditionally. It
-can also include hosted headers like <errno.h> that were present in
-Unix Version 7 and are thus widely available. Similarly, many modules
-include <sys/types.h> even though it's not even in C99; that's OK
-since <sys/types.h> has been around nearly forever. <string.h> and
+can also assume the existence of <ctime.h>, <errno.h>, <fcntl.h>,
+<locale.h>, <signal.h>, <stdio.h>, <stdlib.h>, <string.h>, and
+<time.h>. Some of these headers, such as <errno.h>, were present in
+Unix Version 7 and are thus widely available. <string.h> and
<stdlib.h> were not in Unix Version 7, so they weren't universally
available on ancient hosts, but they are both in SunOS 4 (the oldest
platform still in relatively-common use) so Gnulib assumes them now.
+Similarly, many modules include <sys/types.h> even though it's not
+even in C99; that's OK since <sys/types.h> has been around nearly
+forever.
Even if the include files exist, they may not conform to C89.
However, GCC has a "fixincludes" script that attempts to fix most
diff --git a/lib/flock.c b/lib/flock.c
index aae7fc624f..7db5663559 100644
--- a/lib/flock.c
+++ b/lib/flock.c
@@ -163,9 +163,7 @@ flock (int fd, int operation)
#ifdef HAVE_STRUCT_FLOCK_L_TYPE
/* We know how to implement flock in terms of fcntl. */
-#ifdef HAVE_FCNTL_H
#include <fcntl.h>
-#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index 0bd2b97acc..b599cc1199 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -31,9 +31,7 @@
#ifndef _LIBC
# include "localcharset.h"
#endif
-#if defined HAVE_LOCALE_H || defined _LIBC
-# include <locale.h>
-#endif
+#include <locale.h>
#include <wchar.h>
#include <wctype.h>
@@ -83,7 +81,7 @@
# define SIZE_MAX ((size_t) -1)
#endif
-#if (defined MB_CUR_MAX && HAVE_LOCALE_H && HAVE_WCTYPE_H && HAVE_ISWCTYPE && HAVE_WCSCOLL) || _LIBC
+#if (defined MB_CUR_MAX && HAVE_WCTYPE_H && HAVE_ISWCTYPE && HAVE_WCSCOLL) || _LIBC
# define RE_ENABLE_I18N
#endif
diff --git a/m4/ctype.m4 b/m4/ctype.m4
index 603c9db707..4a86ba94ac 100644
--- a/m4/ctype.m4
+++ b/m4/ctype.m4
@@ -1,4 +1,4 @@
-# ctype_h.m4 serial 5
+# ctype_h.m4 serial 6
dnl Copyright (C) 2009-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -9,7 +9,7 @@ AC_DEFUN([gl_CTYPE_H],
AC_REQUIRE([gl_CTYPE_H_DEFAULTS])
dnl <ctype.h> is always overridden, because of GNULIB_POSIXCHECK.
- gl_CHECK_NEXT_HEADERS([ctype.h])
+ gl_NEXT_HEADERS([ctype.h])
dnl Check for declarations of anything we want to poison if the
dnl corresponding gnulib module is not in use.
diff --git a/m4/errno_h.m4 b/m4/errno_h.m4
index 427c3f25f6..687bafff2d 100644
--- a/m4/errno_h.m4
+++ b/m4/errno_h.m4
@@ -1,4 +1,4 @@
-# errno_h.m4 serial 7
+# errno_h.m4 serial 8
dnl Copyright (C) 2004, 2006, 2008-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -50,7 +50,7 @@ booboo
if test $gl_cv_header_errno_h_complete = yes; then
ERRNO_H=''
else
- gl_CHECK_NEXT_HEADERS([errno.h])
+ gl_NEXT_HEADERS([errno.h])
ERRNO_H='errno.h'
fi
AC_SUBST([ERRNO_H])
diff --git a/m4/fcntl_h.m4 b/m4/fcntl_h.m4
index 5df6bbade9..1ef4f455b7 100644
--- a/m4/fcntl_h.m4
+++ b/m4/fcntl_h.m4
@@ -1,4 +1,4 @@
-# serial 12
+# serial 13
# Configure fcntl.h.
dnl Copyright (C) 2006-2007, 2009-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
@@ -11,7 +11,7 @@ AC_DEFUN([gl_FCNTL_H],
[
AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
AC_REQUIRE([gl_FCNTL_O_FLAGS])
- gl_CHECK_NEXT_HEADERS([fcntl.h])
+ gl_NEXT_HEADERS([fcntl.h])
dnl Check for declarations of anything we want to poison if the
dnl corresponding gnulib module is not in use, if it is not common
diff --git a/m4/flock.m4 b/m4/flock.m4
index ba22043654..7d8c7030d1 100644
--- a/m4/flock.m4
+++ b/m4/flock.m4
@@ -1,4 +1,4 @@
-# flock.m4 serial 1
+# flock.m4 serial 2
dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -19,7 +19,7 @@ dnl Prerequisites of lib/flock.c.
AC_DEFUN([gl_PREREQ_FLOCK],
[
AC_CHECK_FUNCS_ONCE([fcntl])
- AC_CHECK_HEADERS_ONCE([unistd.h fcntl.h])
+ AC_CHECK_HEADERS_ONCE([unistd.h])
dnl Do we have a POSIX fcntl lock implementation?
AC_CHECK_MEMBERS([struct flock.l_type],[],[],[[#include <fcntl.h>]])
diff --git a/m4/locale_h.m4 b/m4/locale_h.m4
index 60e6798db8..a1a0870146 100644
--- a/m4/locale_h.m4
+++ b/m4/locale_h.m4
@@ -1,4 +1,4 @@
-# locale_h.m4 serial 11
+# locale_h.m4 serial 12
dnl Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -55,7 +55,7 @@ AC_DEFUN([gl_LOCALE_H],
AC_SUBST([HAVE_XLOCALE_H])
dnl <locale.h> is always overridden, because of GNULIB_POSIXCHECK.
- gl_CHECK_NEXT_HEADERS([locale.h])
+ gl_NEXT_HEADERS([locale.h])
if test -n "$STDDEF_H" \
|| test $gl_cv_header_locale_h_posix2001 = no \
diff --git a/m4/regex.m4 b/m4/regex.m4
index 4191acb5de..24198b5570 100644
--- a/m4/regex.m4
+++ b/m4/regex.m4
@@ -1,4 +1,4 @@
-# serial 57
+# serial 58
# Copyright (C) 1996-2001, 2003-2011 Free Software Foundation, Inc.
#
@@ -13,8 +13,6 @@ AC_PREREQ([2.50])
AC_DEFUN([gl_REGEX],
[
- AC_CHECK_HEADERS_ONCE([locale.h])
-
AC_ARG_WITH([included-regex],
[AS_HELP_STRING([--without-included-regex],
[don't compile regex; this is the default on systems
@@ -34,9 +32,7 @@ AC_DEFUN([gl_REGEX],
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[AC_INCLUDES_DEFAULT[
- #if HAVE_LOCALE_H
- #include <locale.h>
- #endif
+ #include <locale.h>
#include <limits.h>
#include <regex.h>
]],
@@ -47,31 +43,29 @@ AC_DEFUN([gl_REGEX],
const char *s;
struct re_registers regs;
- #if HAVE_LOCALE_H
- /* http://sourceware.org/ml/libc-hacker/2006-09/msg00008.html
- This test needs valgrind to catch the bug on Debian
- GNU/Linux 3.1 x86, but it might catch the bug better
- on other platforms and it shouldn't hurt to try the
- test here. */
- if (setlocale (LC_ALL, "en_US.UTF-8"))
- {
- static char const pat[] = "insert into";
- static char const data[] =
- "\xFF\0\x12\xA2\xAA\xC4\xB1,K\x12\xC4\xB1*\xACK";
- re_set_syntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE
- | RE_ICASE);
- memset (&regex, 0, sizeof regex);
- s = re_compile_pattern (pat, sizeof pat - 1, &regex);
- if (s)
- result |= 1;
- else if (re_search (&regex, data, sizeof data - 1,
- 0, sizeof data - 1, &regs)
- != -1)
- result |= 1;
- if (! setlocale (LC_ALL, "C"))
- return 1;
- }
- #endif
+ /* http://sourceware.org/ml/libc-hacker/2006-09/msg00008.html
+ This test needs valgrind to catch the bug on Debian
+ GNU/Linux 3.1 x86, but it might catch the bug better
+ on other platforms and it shouldn't hurt to try the
+ test here. */
+ if (setlocale (LC_ALL, "en_US.UTF-8"))
+ {
+ static char const pat[] = "insert into";
+ static char const data[] =
+ "\xFF\0\x12\xA2\xAA\xC4\xB1,K\x12\xC4\xB1*\xACK";
+ re_set_syntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE
+ | RE_ICASE);
+ memset (&regex, 0, sizeof regex);
+ s = re_compile_pattern (pat, sizeof pat - 1, &regex);
+ if (s)
+ result |= 1;
+ else if (re_search (&regex, data, sizeof data - 1,
+ 0, sizeof data - 1, &regs)
+ != -1)
+ result |= 1;
+ if (! setlocale (LC_ALL, "C"))
+ return 1;
+ }
/* This test is from glibc bug 3957, reported by Andrew Mackey. */
re_set_syntax (RE_SYNTAX_EGREP | RE_HAT_LISTS_NOT_NEWLINE);
diff --git a/m4/signal_h.m4 b/m4/signal_h.m4
index 52edf718fd..77eb125710 100644
--- a/m4/signal_h.m4
+++ b/m4/signal_h.m4
@@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_SIGNAL_H],
[
AC_REQUIRE([gl_SIGNAL_H_DEFAULTS])
- gl_CHECK_NEXT_HEADERS([signal.h])
+ gl_NEXT_HEADERS([signal.h])
# AIX declares sig_atomic_t to already include volatile, and C89 compilers
# then choke on 'volatile sig_atomic_t'. C99 requires that it compile.
AC_CHECK_TYPE([volatile sig_atomic_t], [],
diff --git a/m4/stdio_h.m4 b/m4/stdio_h.m4
index 945a93abd7..b6163d6806 100644
--- a/m4/stdio_h.m4
+++ b/m4/stdio_h.m4
@@ -9,7 +9,7 @@ AC_DEFUN([gl_STDIO_H],
AC_REQUIRE([gl_STDIO_H_DEFAULTS])
AC_REQUIRE([AC_C_INLINE])
AC_REQUIRE([gl_ASM_SYMBOL_PREFIX])
- gl_CHECK_NEXT_HEADERS([stdio.h])
+ gl_NEXT_HEADERS([stdio.h])
dnl No need to create extra modules for these functions. Everyone who uses
dnl <stdio.h> likely needs them.
GNULIB_FPRINTF=1
diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4
index e7ed4a952e..a71468f13c 100644
--- a/m4/stdlib_h.m4
+++ b/m4/stdlib_h.m4
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 33
+# stdlib_h.m4 serial 34
dnl Copyright (C) 2007-2011 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_STDLIB_H],
[
AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
- gl_CHECK_NEXT_HEADERS([stdlib.h])
+ gl_NEXT_HEADERS([stdlib.h])
AC_CHECK_HEADERS([random.h], [], [], [AC_INCLUDES_DEFAULT])
if test $ac_cv_header_random_h = yes; then
HAVE_RANDOM_H=1
diff --git a/m4/string_h.m4 b/m4/string_h.m4
index bde607fb3f..30ddfbc3a4 100644
--- a/m4/string_h.m4
+++ b/m4/string_h.m4
@@ -5,7 +5,7 @@
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
-# serial 18
+# serial 19
# Written by Paul Eggert.
@@ -20,7 +20,7 @@ AC_DEFUN([gl_HEADER_STRING_H_BODY],
[
AC_REQUIRE([AC_C_RESTRICT])
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
- gl_CHECK_NEXT_HEADERS([string.h])
+ gl_NEXT_HEADERS([string.h])
dnl Check for declarations of anything we want to poison if the
dnl corresponding gnulib module is not in use, and which is not
diff --git a/m4/time_h.m4 b/m4/time_h.m4
index dc601c574a..615da1cfd3 100644
--- a/m4/time_h.m4
+++ b/m4/time_h.m4
@@ -2,7 +2,7 @@
# Copyright (C) 2000-2001, 2003-2007, 2009-2011 Free Software Foundation, Inc.
-# serial 3
+# serial 4
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -21,7 +21,7 @@ AC_DEFUN([gl_HEADER_TIME_H_BODY],
[
AC_REQUIRE([AC_C_RESTRICT])
AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
- gl_CHECK_NEXT_HEADERS([time.h])
+ gl_NEXT_HEADERS([time.h])
AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
])
diff --git a/tests/test-argp.c b/tests/test-argp.c
index 7da426f066..f0b864d81d 100644
--- a/tests/test-argp.c
+++ b/tests/test-argp.c
@@ -21,9 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
-#if HAVE_STRING_H
-# include <string.h>
-#endif
+#include <string.h>
#if HAVE_STRINGS_H
# include <strings.h>
#endif