Mercurial > hg > octave-jordi > gnulib-hg
changeset 14186:cd4635d4dbe6
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.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Wed, 19 Jan 2011 22:15:41 -0800 |
parents | 2be94b732a01 |
children | 07245aecd139 |
files | ChangeLog README lib/flock.c lib/regex_internal.h m4/ctype.m4 m4/errno_h.m4 m4/fcntl_h.m4 m4/flock.m4 m4/locale_h.m4 m4/regex.m4 m4/signal_h.m4 m4/stdio_h.m4 m4/stdlib_h.m4 m4/string_h.m4 m4/time_h.m4 tests/test-argp.c |
diffstat | 16 files changed, 74 insertions(+), 62 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- a/README +++ b/README @@ -221,13 +221,16 @@ 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
--- a/lib/flock.c +++ b/lib/flock.c @@ -163,9 +163,7 @@ #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>
--- 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
--- 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_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.
--- 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 @@ 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])
--- 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_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
--- 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 @@ 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>]])
--- 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_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 \
--- 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_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_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 @@ 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 (®ex, 0, sizeof regex); - s = re_compile_pattern (pat, sizeof pat - 1, ®ex); - if (s) - result |= 1; - else if (re_search (®ex, data, sizeof data - 1, - 0, sizeof data - 1, ®s) - != -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 (®ex, 0, sizeof regex); + s = re_compile_pattern (pat, sizeof pat - 1, ®ex); + if (s) + result |= 1; + else if (re_search (®ex, data, sizeof data - 1, + 0, sizeof data - 1, ®s) + != -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);
--- a/m4/signal_h.m4 +++ b/m4/signal_h.m4 @@ -7,7 +7,7 @@ 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], [],
--- a/m4/stdio_h.m4 +++ b/m4/stdio_h.m4 @@ -9,7 +9,7 @@ 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
--- 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 @@ 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
--- 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_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
--- 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_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]) ])