diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2005-12-02 00:42:52 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2005-12-02 00:42:52 +0000 |
commit | 76bebf24a531f7019ba6369eb5eafe34c2992882 (patch) | |
tree | 49f0a2466e3dceb957fee8fb154d7cba140f2f87 /lib | |
parent | b3c0bca1f8a793e886889f711a11d4490b8cab85 (diff) | |
download | coreutils-76bebf24a531f7019ba6369eb5eafe34c2992882.tar.xz |
Import from gnulib.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ChangeLog | 35 | ||||
-rw-r--r-- | lib/exclude.c | 13 | ||||
-rw-r--r-- | lib/intprops.h | 17 | ||||
-rw-r--r-- | lib/obstack.c | 13 | ||||
-rw-r--r-- | lib/obstack.h | 12 | ||||
-rw-r--r-- | lib/strtoimax.c | 11 | ||||
-rw-r--r-- | lib/utimecmp.c | 8 |
7 files changed, 70 insertions, 39 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog index 18e762260..73b7e2acf 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,38 @@ +2005-12-01 Paul Eggert <eggert@cs.ucla.edu> + + 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 <wchar.h>; no longer needed. + +2005-12-01 Jim Meyering <jim@meyering.net> + + 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 <jakub@redhat.com> + and Ulrich Drepper <drepper@redhat.com> + + 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 <roland@redhat.com> + + Import from libc via gnulib. [BZ #1331] + * obstack.h [!__STDC__] (obstack_int_grow_fast): Fix misnamed + macro argument. + Reported by Matej Vela <vela@debian.org>. + 2005-11-30 Jim Meyering <jim@meyering.net> * openat-priv.h: New file, defining macros used by mkdirat.c diff --git a/lib/exclude.c b/lib/exclude.c index de1a5c3f3..6a0c14974 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 65280b159..34f971cba 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 f3ca2c2e0..6df0611d2 100644 --- a/lib/obstack.c +++ b/lib/obstack.c @@ -51,10 +51,6 @@ # endif #endif -#if defined _LIBC && defined USE_IN_LIBIO -# include <wchar.h> -#endif - #include <stddef.h> #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 940bc8051..95dd438ff 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 43a690d24..a15b84af3 100644 --- a/lib/strtoimax.c +++ b/lib/strtoimax.c @@ -32,8 +32,7 @@ #include <stdlib.h> -/* 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 7308929f4..9d07e9fd3 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; |