From: Paul Eggert Date: Fri, 2 Dec 2005 00:42:52 +0000 (+0000) Subject: Import from gnulib. X-Git-Tag: v6.0~1227 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=76bebf24a531f7019ba6369eb5eafe34c2992882;p=thirdparty%2Fcoreutils.git Import from gnulib. --- diff --git a/lib/ChangeLog b/lib/ChangeLog index 18e7622605..73b7e2acfd 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,38 @@ +2005-12-01 Paul Eggert + + Sync from gnulib. + + * exclude.c: Include verify.h. + (verify): Remove. All callers changed to use verify.h's version. + * strtoimax.c: Likewise. + * utimecmp.c: Likewis.e + + * obstack.c [defined _LIBC && defined USE_IN_LIBIO]: Don't + include ; no longer needed. + +2005-12-01 Jim Meyering + + Sync from gnulib. + + * intprops.h (signed_type_or_expr__): Define. + (INT_STRLEN_BOUND) [__GNUC__]: Use a slightly tighter bound + for unsigned types. + +2005-12-01 Jakub Jelinek + and Ulrich Drepper + + Import from libc via gnulib. + * obstack.c (print_and_abort) [defined _LIBC]: Use __fxprintf + instead of inline stream orientation test and two separate + function calls. Pay no attention to USE_IN_LIBIO. + +2005-12-01 Roland McGrath + + Import from libc via gnulib. [BZ #1331] + * obstack.h [!__STDC__] (obstack_int_grow_fast): Fix misnamed + macro argument. + Reported by Matej Vela . + 2005-11-30 Jim Meyering * openat-priv.h: New file, defining macros used by mkdirat.c diff --git a/lib/exclude.c b/lib/exclude.c index de1a5c3f3b..6a0c14974d 100644 --- a/lib/exclude.c +++ b/lib/exclude.c @@ -37,6 +37,7 @@ #include "fnmatch.h" #include "strcase.h" #include "xalloc.h" +#include "verify.h" #if USE_UNLOCKED_IO # include "unlocked-io.h" @@ -54,9 +55,6 @@ is_space (unsigned char c) return IN_CTYPE_DOMAIN (c) && isspace (c); } -/* Verify a requirement at compile-time (unlike assert, which is runtime). */ -#define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; } - /* Non-GNU systems lack these options, so we don't need to check them. */ #ifndef FNM_CASEFOLD # define FNM_CASEFOLD 0 @@ -65,11 +63,10 @@ is_space (unsigned char c) # define FNM_LEADING_DIR 0 #endif -verify (EXCLUDE_macros_do_not_collide_with_FNM_macros, - (((EXCLUDE_ANCHORED | EXCLUDE_INCLUDE | EXCLUDE_WILDCARDS) - & (FNM_PATHNAME | FNM_NOESCAPE | FNM_PERIOD | FNM_LEADING_DIR - | FNM_CASEFOLD)) - == 0)); +verify (((EXCLUDE_ANCHORED | EXCLUDE_INCLUDE | EXCLUDE_WILDCARDS) + & (FNM_PATHNAME | FNM_NOESCAPE | FNM_PERIOD | FNM_LEADING_DIR + | FNM_CASEFOLD)) + == 0); /* An exclude pattern-options pair. The options are fnmatch options ORed with EXCLUDE_* options. */ diff --git a/lib/intprops.h b/lib/intprops.h index 65280b159f..34f971cbaa 100644 --- a/lib/intprops.h +++ b/lib/intprops.h @@ -53,12 +53,25 @@ ? (t) -1 \ : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))) +/* Return zero if T can be determined to be an unsigned type. + Otherwise, return 1. + When compiling with GCC, INT_STRLEN_BOUND uses this macro to obtain a + tighter bound. Otherwise, it overestimates the true bound by one byte + when applied to unsigned types of size 2, 4, 16, ... bytes. + The symbol signed_type_or_expr__ is private to this header file. */ +#if __GNUC__ >= 2 +# define signed_type_or_expr__(t) TYPE_SIGNED (__typeof__ (t)) +#else +# define signed_type_or_expr__(t) 1 +#endif + /* Bound on length of the string representing an integer type or expression T. - Subtract 1 for the sign bit if t is signed; log10 (2.0) < 146/485; + Subtract 1 for the sign bit if T is signed; log10 (2.0) < 146/485; add 1 for integer division truncation; add 1 more for a minus sign if needed. */ #define INT_STRLEN_BOUND(t) \ - ((sizeof (t) * CHAR_BIT - 1) * 146 / 485 + 2) + ((sizeof (t) * CHAR_BIT - signed_type_or_expr__ (t)) * 146 / 485 \ + + signed_type_or_expr__ (t) + 1) /* Bound on buffer size needed to represent an integer type or expression T, including the terminating null. */ diff --git a/lib/obstack.c b/lib/obstack.c index f3ca2c2e06..6df0611d26 100644 --- a/lib/obstack.c +++ b/lib/obstack.c @@ -51,10 +51,6 @@ # endif #endif -#if defined _LIBC && defined USE_IN_LIBIO -# include -#endif - #include #ifndef ELIDE_CODE @@ -433,12 +429,11 @@ print_and_abort (void) happen because the "memory exhausted" message appears in other places like this and the translation should be reused instead of creating a very similar string which requires a separate translation. */ -# if defined _LIBC && defined USE_IN_LIBIO - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s\n", _("memory exhausted")); - else +# ifdef _LIBC + (void) __fxprintf (NULL, "%s\n", _("memory exhausted")); +# else + fprintf (stderr, "%s\n", _("memory exhausted")); # endif - fprintf (stderr, "%s\n", _("memory exhausted")); exit (obstack_exit_failure); } diff --git a/lib/obstack.h b/lib/obstack.h index 940bc8051e..95dd438ff7 100644 --- a/lib/obstack.h +++ b/lib/obstack.h @@ -1,11 +1,7 @@ /* obstack.h - object stack macros - Copyright (C) 1988-1994,1996-1999,2003,2004 Free Software Foundation, Inc. - - This file is part of the GNU C Library. Its master source is NOT part of - the C library, however. The master source lives in /gd/gnu/lib. - - NOTE: The canonical source of this file is maintained with the GNU C Library. - Bugs can be reported to bug-glibc@gnu.org. + Copyright (C) 1988-1994,1996-1999,2003,2004,2005 + Free Software Foundation, Inc. + This file is part of the GNU C Library. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -464,7 +460,7 @@ __extension__ \ (((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr)) # define obstack_int_grow_fast(h,aint) \ - (((int *) ((h)->next_free += sizeof (int)))[-1] = (aptr)) + (((int *) ((h)->next_free += sizeof (int)))[-1] = (aint)) # define obstack_blank(h,length) \ ( (h)->temp.tempint = (length), \ diff --git a/lib/strtoimax.c b/lib/strtoimax.c index 43a690d24b..a15b84af3a 100644 --- a/lib/strtoimax.c +++ b/lib/strtoimax.c @@ -32,8 +32,7 @@ #include -/* Verify a requirement at compile-time (unlike assert, which is runtime). */ -#define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; } +#include "verify.h" #ifdef UNSIGNED # ifndef HAVE_DECL_STRTOULL @@ -68,15 +67,13 @@ INT strtoimax (char const *ptr, char **endptr, int base) { #if HAVE_LONG_LONG - verify (size_is_that_of_long_or_long_long, - (sizeof (INT) == sizeof (long int) - || sizeof (INT) == sizeof (long long int))); + verify (sizeof (INT) == sizeof (long int) + || sizeof (INT) == sizeof (long long int)); if (sizeof (INT) != sizeof (long int)) return strtoll (ptr, endptr, base); #else - verify (size_is_that_of_long, - sizeof (INT) == sizeof (long int)); + verify (sizeof (INT) == sizeof (long int)); #endif return strtol (ptr, endptr, base); diff --git a/lib/utimecmp.c b/lib/utimecmp.c index 7308929f43..9d07e9fd3e 100644 --- a/lib/utimecmp.c +++ b/lib/utimecmp.c @@ -39,11 +39,9 @@ #include "stat-time.h" #include "timespec.h" #include "utimens.h" +#include "verify.h" #include "xalloc.h" -/* Verify a requirement at compile-time (unlike assert, which is runtime). */ -#define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; } - #ifndef MAX # define MAX(a, b) ((a) > (b) ? (a) : (b)) #endif @@ -139,8 +137,8 @@ utimecmp (char const *dst_name, time_t might be unsigned. */ - verify (time_t_is_integer, TYPE_IS_INTEGER (time_t)); - verify (twos_complement_arithmetic, TYPE_TWOS_COMPLEMENT (int)); + verify (TYPE_IS_INTEGER (time_t)); + verify (TYPE_TWOS_COMPLEMENT (int)); /* Destination and source time stamps. */ time_t dst_s = dst_stat->st_mtime; diff --git a/m4/ChangeLog b/m4/ChangeLog index 78cfe51285..fcc9f2af62 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,18 @@ +2005-12-01 Paul Eggert + + * regex.m4 (gl_REGEX): Check whether off_t can be used in a switch + statement, to work around an HP-UX 10.20 compiler bug reported by + Peter O'Gorman. + +2005-12-01 Bruno Haible + + Import from gnulib. + * mbchar.m4 (gl_MBCHAR): Check for wchar.h and wctype.h. Don't compile + mbchar.c if they are not both present. + * mbiter.m4 (gl_MBITER): Likewise. + * strstr.m4 (gl_PREREQ_STRSTR): Use AC_REQUIRE. + * strcase.m4 (gl_PREREQ_STRCASECMP): Likewise. + 2005-11-30 Jim Meyering * openat.m4 (gl_FUNC_OPENAT): Require and compile mkdirat.c. diff --git a/m4/mbchar.m4 b/m4/mbchar.m4 index 7657b69740..df351a6eb2 100644 --- a/m4/mbchar.m4 +++ b/m4/mbchar.m4 @@ -9,13 +9,12 @@ dnl From Bruno Haible. AC_DEFUN([gl_MBCHAR], [ - AC_CHECK_HEADERS_ONCE(wchar.h wctype.h) - - case $ac_cv_header_wchar_h,$ac_cv_header_wctype_h in - yes,yes) - AC_LIBOBJ([mbchar]);; - esac - AC_REQUIRE([AC_GNU_SOURCE]) - : + dnl The following line is that so the user can test + dnl HAVE_WCHAR_H && HAVE_WCTYPE_H before #include "mbchar.h". + AC_CHECK_HEADERS_ONCE(wchar.h wctype.h) + dnl Compile mbchar.c only if HAVE_WCHAR_H && HAVE_WCTYPE_H. + if test $ac_cv_header_wchar_h = yes && test $ac_cv_header_wctype_h = yes; then + AC_LIBOBJ([mbchar]) + fi ]) diff --git a/m4/mbiter.m4 b/m4/mbiter.m4 index 3eb92bcca7..7d51af10dc 100644 --- a/m4/mbiter.m4 +++ b/m4/mbiter.m4 @@ -1,4 +1,4 @@ -# mbiter.m4 serial 1 +# mbiter.m4 serial 2 dnl Copyright (C) 2005 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -10,5 +10,8 @@ dnl From Bruno Haible. AC_DEFUN([gl_MBITER], [ AC_REQUIRE([AC_TYPE_MBSTATE_T]) + dnl The following line is that so the user can test HAVE_MBRTOWC before + dnl #include "mbiter.h" or "mbuiter.h". + AC_REQUIRE([gl_FUNC_MBRTOWC]) : ]) diff --git a/m4/strcase.m4 b/m4/strcase.m4 index 8a8ff3a451..6db401bb1b 100644 --- a/m4/strcase.m4 +++ b/m4/strcase.m4 @@ -1,4 +1,4 @@ -# strcase.m4 serial 2 +# strcase.m4 serial 3 dnl Copyright (C) 2002, 2005 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -29,7 +29,8 @@ AC_DEFUN([gl_FUNC_STRNCASECMP], # Prerequisites of lib/strcasecmp.c. AC_DEFUN([gl_PREREQ_STRCASECMP], [ - gl_FUNC_MBRTOWC + AC_REQUIRE([gl_FUNC_MBRTOWC]) + : ]) # Prerequisites of lib/strncasecmp.c. diff --git a/m4/strstr.m4 b/m4/strstr.m4 index aea809ebd1..a785d42866 100644 --- a/m4/strstr.m4 +++ b/m4/strstr.m4 @@ -1,4 +1,4 @@ -# strstr.m4 serial 4 +# strstr.m4 serial 5 dnl Copyright (C) 2002-2003, 2005 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -14,5 +14,6 @@ AC_DEFUN([gl_FUNC_STRSTR], # Prerequisites of lib/strstr.c. AC_DEFUN([gl_PREREQ_STRSTR], [ - gl_FUNC_MBRTOWC + AC_REQUIRE([gl_FUNC_MBRTOWC]) + : ])