[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gnulib] factored integer properties into intprops.h
From: |
Paul Eggert |
Subject: |
[bug-gnulib] factored integer properties into intprops.h |
Date: |
Wed, 09 Mar 2005 11:16:09 -0800 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux) |
I factored out various places in gnulib that refer to integer
properties like TYPE_MAXIMUM and INT_STRLEN_BOUND, and put them
into a common file intprops.h. I installed this patch into
gnulib and will do the same to coreutils shortly.
The only developer-visible change should be the new file lib/intprops.h.
I used 146/485 by popular request. However, I didn't have
INT_STRLEN_BOUND refer to TYPE_SIGNED, as that broke some code in
coreutils that applied INT_STRLEN_BOUND to a value, not to a type. I
think this usage is useful enough that we should continue to support
it, so I documented it.
2005-03-09 Paul Eggert <address@hidden>
Factor int-properties macros into a single file, except for
glibc-related files.
* lib/intprops.h: New file.
* lib/getloadavg.c: Include it instead of limits.h.
(INT_STRLEN_BOUND): Remove.
* lib/human.c: Include intprops.h.
(group_number): Use INT_STRLEN_BOUND instead of rolling it ourself.
* lib/human.h (LONGEST_HUMAN_READABLE): Use 146/485 rather than
302/1000.
* lib/inttostr.h: Include intprops.h instead of limits.h.
(INT_STRLEN_BOUND, INT_BUFSIZE_BOUND): Remove.
* lib/mktime.c (TYPE_IS_INTEGER, TYPE_TWOS_COMPLEMENT): New macros,
for consistency with intprops.h.
(time_t_is_integer, twos_complement_arithmetic): Use them.
* lib/sig2str.h: Include <signal.h>, intprops.h.
(INT_STRLEN_BOUND): Remove.
* lib/strftime.c (TYPE_SIGNED): Remove.
(INT_STRLEN_BOUND): Switch to same implementation as intprops.h.
* lib/strtol.c: Adjust comments to match intprops.h.
* lib/userspec.c: Include intprops.h.
(TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM): Remove.
* lib/utimecmp.c, lib/xnanosleep.c, lib/xstrtol.c: Likewise.
* lib/utimecmp.c (utimecmp): Use TYPE_IS_INTEGER, TYPE_TWOS_COMPLEMENT
instead of rolling our own expressions.
* lib/xstrtol.c: Include xstrtol.h first, to test interface.
* modules/getloadavg (Files): Add lib/intprops.h.
* modules/human (Files): Likewise.
* modules/inttostr (Files): Likewise.
* modules/sig2str (Files): Likewise.
* modules/userspec (Files): Likewise.
* modules/utimecmp (Files): Likewise.
* modules/xnanosleep (Files): Likewise.
* modules/xstrtol (Files): Likewise.
--- /dev/null 2003-03-18 13:55:57 -0800
+++ lib/intprops.h 2005-03-09 10:46:40 -0800
@@ -0,0 +1,55 @@
+/* intprops.h -- properties of integer types
+
+ Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+ 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* Written by Paul Eggert. */
+
+#include <limits.h>
+
+/* The extra casts in the following macros work around compiler bugs,
+ e.g., in Cray C 5.0.3.0. */
+
+/* True if the arithmetic type T is an integer type. bool counts as
+ an integer. */
+#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
+
+/* True if negative values of the integer type T use twos complement
+ representation. */
+#define TYPE_TWOS_COMPLEMENT(t) ((t) - (t) 1 == (t) ((t) ~ (t) 1 + (t) 1))
+
+/* True if the arithmetic type T is signed. */
+#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
+
+/* The maximum and minimum values for the integer type T. These
+ macros have undefined behavior if T is signed and has padding bits
+ (i.e., bits that do not contribute to the value), or if T uses
+ signed-magnitude representation. If this is a problem for you,
+ please let us know how to fix it for your host. */
+#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
+ ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
+#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
+
+/* Bound on length of the string representing an integer value or type T.
+ 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)
+
+/* Bound on buffer size needed to represent an integer value or type T,
+ including the terminating null. */
+#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
Index: lib/getloadavg.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/getloadavg.c,v
retrieving revision 1.23
diff -p -u -r1.23 getloadavg.c
--- lib/getloadavg.c 7 Aug 2004 00:09:39 -0000 1.23
+++ lib/getloadavg.c 9 Mar 2005 19:07:38 -0000
@@ -1,7 +1,7 @@
/* Get the system load averages.
Copyright (C) 1985, 1986, 1987, 1988, 1989, 1991, 1992, 1993, 1994,
- 1995, 1997, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
+ 1995, 1997, 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with gnulib.
Bugs can be reported to address@hidden
@@ -104,6 +104,7 @@
# include "c-strtod.h"
# include "cloexec.h"
+# include "intprops.h"
# include "xalloc.h"
/* The existing Emacs configuration files define a macro called
@@ -349,8 +350,6 @@
# include <unistd.h>
# endif
-# include <limits.h>
-
/* LOAD_AVE_TYPE should only get defined if we're going to use the
nlist method. */
# if !defined (LOAD_AVE_TYPE) && (defined (BSD) || defined (LDAV_CVT) ||
defined (KERNEL_FILE) || defined (LDAV_SYMBOL))
@@ -578,11 +577,6 @@ getloadavg (double loadavg[], int nelem)
# define LINUX_LDAV_FILE "/proc/loadavg"
# endif
-/* Upper bound on the string length of an integer converted to string.
- 302 / 1000 is ceil (log10 (2.0)). Subtract 1 for the sign bit;
- add 1 for integer division truncation; add 1 more for a minus sign. */
-# define INT_STRLEN_BOUND(t) ((sizeof (t) * CHAR_BIT - 1) * 302 / 1000 + 2)
-
char ldavgbuf[3 * (INT_STRLEN_BOUND (long int) + sizeof ".00")];
char const *ptr = ldavgbuf;
int fd, count;
Index: lib/human.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/human.c,v
retrieving revision 1.28
diff -p -u -r1.28 human.c
--- lib/human.c 4 Jan 2005 18:46:24 -0000 1.28
+++ lib/human.c 9 Mar 2005 19:07:38 -0000
@@ -35,6 +35,7 @@
#include <argmatch.h>
#include <error.h>
+#include <intprops.h>
#include <xstrtol.h>
#ifndef SIZE_MAX
@@ -99,10 +100,8 @@ group_number (char *number, size_t numbe
size_t i = numberlen;
/* The maximum possible value for NUMBERLEN is the number of digits
- in the square of the largest uintmax_t, so double the size of
- uintmax_t before converting to a bound. 302 / 1000 is ceil
- (log10 (2.0)). Add 1 for integer division truncation. */
- char buf[2 * sizeof (uintmax_t) * CHAR_BIT * 302 / 1000 + 1];
+ in the square of the largest uintmax_t, so double the size needed. */
+ char buf[2 * INT_STRLEN_BOUND (uintmax_t) + 1];
memcpy (buf, number, numberlen);
d = number + numberlen;
Index: lib/human.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/human.h,v
retrieving revision 1.10
diff -p -u -r1.10 human.h
--- lib/human.h 17 Nov 2004 07:18:27 -0000 1.10
+++ lib/human.h 9 Mar 2005 19:07:38 -0000
@@ -1,6 +1,6 @@
/* human.h -- print human readable file size
- Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+ Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -39,13 +39,13 @@
/* A conservative bound on the maximum length of a human-readable string.
The output can be the square of the largest uintmax_t, so double
its size before converting to a bound.
- 302 / 1000 is ceil (log10 (2.0)). Add 1 for integer division truncation.
+ log10 (2.0) < 146/485. Add 1 for integer division truncation.
Also, the output can have a thousands separator between every digit,
so multiply by MB_LEN_MAX + 1 and then subtract MB_LEN_MAX.
Append 1 for a space before the suffix.
Finally, append 3, the maximum length of a suffix. */
# define LONGEST_HUMAN_READABLE \
- ((2 * sizeof (uintmax_t) * CHAR_BIT * 302 / 1000 + 1) * (MB_LEN_MAX + 1) \
+ ((2 * sizeof (uintmax_t) * CHAR_BIT * 146 / 485 + 1) * (MB_LEN_MAX + 1) \
- MB_LEN_MAX + 1 + 3)
/* Options for human_readable. */
Index: lib/inttostr.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/inttostr.h,v
retrieving revision 1.2
diff -p -u -r1.2 inttostr.h
--- lib/inttostr.h 12 Apr 2004 06:47:06 -0000 1.2
+++ lib/inttostr.h 9 Mar 2005 19:07:38 -0000
@@ -1,6 +1,6 @@
/* inttostr.h -- convert integers to printable strings
- Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
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
@@ -29,18 +29,11 @@
# include <stdint.h>
#endif
-#include <limits.h>
-
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
-/* Upper bound on the string length of an integer converted to string.
- 302 / 1000 is ceil (log10 (2.0)). Subtract 1 for the sign bit;
- add 1 for integer division truncation; add 1 more for a minus sign. */
-#define INT_STRLEN_BOUND(t) ((sizeof (t) * CHAR_BIT - 1) * 302 / 1000 + 2)
-
-#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
+#include "intprops.h"
char *offtostr (off_t, char *);
char *imaxtostr (intmax_t, char *);
Index: lib/mktime.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/mktime.c,v
retrieving revision 1.47
diff -p -u -r1.47 mktime.c
--- lib/mktime.c 8 Mar 2005 13:25:38 -0000 1.47
+++ lib/mktime.c 9 Mar 2005 19:07:38 -0000
@@ -1,5 +1,6 @@
/* Convert a `struct tm' to a time_t value.
- Copyright (C) 1993-1999, 2002-2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1993-1999, 2002, 2003, 2004, 2005 Free Software Foundation,
+ Inc.
This file is part of the GNU C Library.
Contributed by Paul Eggert (address@hidden).
@@ -60,10 +61,25 @@
? (a) >> (b) \
: (a) / (1 << (b)) - ((a) % (1 << (b)) < 0))
-/* The extra casts work around common compiler bugs. */
+/* The extra casts in the following macros work around compiler bugs,
+ e.g., in Cray C 5.0.3.0. */
+
+/* True if the arithmetic type T is an integer type. bool counts as
+ an integer. */
+#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
+
+/* True if negative values of the integer type T use twos complement
+ representation. */
+#define TYPE_TWOS_COMPLEMENT(t) ((t) - (t) 1 == (t) ((t) ~ (t) 1 + (t) 1))
+
+/* True if the arithmetic type T is signed. */
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
-/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
- It is necessary at least when t == time_t. */
+
+/* The maximum and minimum values for the integer type T. These
+ macros have undefined behavior if T is signed and has padding bits
+ (i.e., bits that do not contribute to the value), or if T uses
+ signed-magnitude representation. If this is a problem for you,
+ please let us know how to fix it for your host. */
#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
@@ -79,8 +95,8 @@
/* Verify a requirement at compile-time (unlike assert, which is runtime). */
#define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; }
-verify (time_t_is_integer, (time_t) 0.5 == 0);
-verify (twos_complement_arithmetic, -1 == ~1 + 1);
+verify (time_t_is_integer, TYPE_IS_INTEGER (time_t));
+verify (twos_complement_arithmetic, TYPE_TWOS_COMPLEMENT (int));
/* The code also assumes that signed integer overflow silently wraps
around, but this assumption can't be stated without causing a
diagnostic on some hosts. */
@@ -208,8 +224,7 @@ ranged_convert (struct tm *(*convert) (c
{
time_t bad = *t;
time_t ok = 0;
- /* Initialize to make the compiler happy. */
- struct tm tm = { 0, };
+ struct tm tm;
/* BAD is a known unconvertible time_t, and OK is a known good one.
Use binary search to narrow the range between BAD and OK until
Index: lib/sig2str.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/sig2str.h,v
retrieving revision 1.2
diff -p -u -r1.2 sig2str.h
--- lib/sig2str.h 29 Apr 2002 06:59:24 -0000 1.2
+++ lib/sig2str.h 9 Mar 2005 19:07:38 -0000
@@ -1,6 +1,6 @@
/* sig2str.h -- convert between signal names and numbers
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
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
@@ -18,15 +18,12 @@
/* Written by Paul Eggert. */
-/* Include <signal.h> before including this file. */
+#include <signal.h>
/* Don't override system declarations of SIG2STR_MAX, sig2str, str2sig. */
#ifndef SIG2STR_MAX
-/* Upper bound on the string length of an integer converted to string.
- 302 / 1000 is ceil (log10 (2.0)). Subtract 1 for the sign bit;
- add 1 for integer division truncation; add 1 more for a minus sign. */
-# define INT_STRLEN_BOUND(t) ((sizeof (t) * CHAR_BIT - 1) * 302 / 1000 + 2)
+# include "intprops.h"
/* Size of a buffer needed to hold a signal name like "HUP". */
# define SIG2STR_MAX (sizeof "SIGRTMAX" + INT_STRLEN_BOUND (int) - 1)
Index: lib/strftime.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/strftime.c,v
retrieving revision 1.77
diff -p -u -r1.77 strftime.c
--- lib/strftime.c 9 Mar 2005 18:39:39 -0000 1.77
+++ lib/strftime.c 9 Mar 2005 19:07:39 -0000
@@ -120,15 +120,12 @@ extern char *tzname[];
? (a) >> (b) \
: (a) / (1 << (b)) - ((a) % (1 << (b)) < 0))
-#define TYPE_SIGNED(t) ((t) -1 < 0)
-
-/* Bound on length of the string representing an integer value of type t.
- Subtract one for the sign bit if t is signed;
- 302 / 1000 is log10 (2) rounded up;
- add one for integer division truncation;
- add one more for a minus sign if t is signed. */
+/* Bound on length of the string representing an integer value or type T.
+ 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 - TYPE_SIGNED (t)) * 302 / 1000 + 1 + TYPE_SIGNED (t))
+ ((sizeof (t) * CHAR_BIT - 1) * 146 / 485 + 2)
#define TM_YEAR_BASE 1900
Index: lib/strtol.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/strtol.c,v
retrieving revision 1.18
diff -p -u -r1.18 strtol.c
--- lib/strtol.c 12 Sep 2003 20:22:47 -0000 1.18
+++ lib/strtol.c 9 Mar 2005 19:07:39 -0000
@@ -1,6 +1,6 @@
/* Convert string representation of a number into an integer value.
- Copyright (C) 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2003
+ Copyright (C) 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2003, 2005
Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C
@@ -124,11 +124,19 @@ extern int errno;
# define STRTOL_LONG_MAX LONG_LONG_MAX
# define STRTOL_ULONG_MAX ULONG_LONG_MAX
-/* The extra casts work around common compiler bugs,
- e.g. Cray C 5.0.3.0 when t == time_t. */
+/* The extra casts in the following macros work around compiler bugs,
+ e.g., in Cray C 5.0.3.0. */
+
+/* True if the arithmetic type T is signed. */
# ifndef TYPE_SIGNED
# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
# endif
+
+/* The maximum and minimum values for the integer type T. These
+ macros have undefined behavior if T is signed and has padding bits
+ (i.e., bits that do not contribute to the value), or if T uses
+ signed-magnitude representation. If this is a problem for you,
+ please let us know how to fix it for your host. */
# ifndef TYPE_MINIMUM
# define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \
Index: lib/userspec.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/userspec.c,v
retrieving revision 1.45
diff -p -u -r1.45 userspec.c
--- lib/userspec.c 5 Oct 2004 06:47:18 -0000 1.45
+++ lib/userspec.c 9 Mar 2005 19:07:39 -0000
@@ -1,5 +1,5 @@
/* userspec.c -- Parse a user and group string.
- Copyright (C) 1989-1992, 1997-1998, 2000, 2002-2004 Free Software
+ Copyright (C) 1989-1992, 1997-1998, 2000, 2002-2005 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -43,6 +43,7 @@
# include <unistd.h>
#endif
+#include "intprops.h"
#include "inttostr.h"
#include "strdup.h"
#include "xalloc.h"
@@ -66,14 +67,6 @@ struct group *getgrgid ();
# define endpwent() ((void) 0)
#endif
-/* The extra casts work around common compiler bugs. */
-#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
-/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
- It is necessary at least when t == time_t. */
-#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
- ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
-#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
-
#ifndef UID_T_MAX
# define UID_T_MAX TYPE_MAXIMUM (uid_t)
#endif
Index: lib/utimecmp.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/utimecmp.c,v
retrieving revision 1.1
diff -p -u -r1.1 utimecmp.c
--- lib/utimecmp.c 6 Aug 2004 22:38:20 -0000 1.1
+++ lib/utimecmp.c 9 Mar 2005 19:07:39 -0000
@@ -1,6 +1,6 @@
/* utimecmp.c -- compare file time stamps
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
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
@@ -35,6 +35,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include "hash.h"
+#include "intprops.h"
#include "timespec.h"
#include "utimens.h"
#include "xalloc.h"
@@ -50,14 +51,6 @@
# define SIZE_MAX ((size_t) -1)
#endif
-/* The extra casts work around common compiler bugs. */
-#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
-/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
- It is necessary at least when t == time_t. */
-#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
- ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
-#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
-
enum { BILLION = 1000 * 1000 * 1000 };
/* Best possible resolution that utimens can set and stat can return,
@@ -140,8 +133,8 @@ utimecmp (char const *dst_name,
time_t might be unsigned. */
- verify (time_t_is_integer, (time_t) 0.5 == 0);
- verify (twos_complement_arithmetic, -1 == ~1 + 1);
+ verify (time_t_is_integer, TYPE_IS_INTEGER (time_t));
+ verify (twos_complement_arithmetic, TYPE_TWOS_COMPLEMENT (int));
/* Destination and source time stamps. */
time_t dst_s = dst_stat->st_mtime;
Index: lib/xnanosleep.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/xnanosleep.c,v
retrieving revision 1.3
diff -p -u -r1.3 xnanosleep.c
--- lib/xnanosleep.c 1 Mar 2005 17:25:10 -0000 1.3
+++ lib/xnanosleep.c 9 Mar 2005 19:07:39 -0000
@@ -32,15 +32,7 @@
#include <sys/types.h>
#include <time.h>
-#include "timespec.h"
-
-/* The extra casts work around common compiler bugs. */
-#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
-/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
- It is necessary at least when t == time_t. */
-#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
- ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
-#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
+#include "intprops.h"
#ifndef TIME_T_MAX
# define TIME_T_MAX TYPE_MAXIMUM (time_t)
Index: lib/xstrtol.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/xstrtol.c,v
retrieving revision 1.35
diff -p -u -r1.35 xstrtol.c
--- lib/xstrtol.c 7 Aug 2004 00:09:39 -0000 1.35
+++ lib/xstrtol.c 9 Mar 2005 19:07:39 -0000
@@ -1,7 +1,7 @@
/* A more useful interface to strtol.
- Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2003, 2004 Free
- Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2003, 2004, 2005
+ Free Software Foundation, Inc.
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
@@ -23,6 +23,8 @@
# include <config.h>
#endif
+#include "xstrtol.h"
+
#ifndef __strtol
# define __strtol strtol
# define __strtol_t long int
@@ -42,12 +44,7 @@
#include <stdlib.h>
#include <string.h>
-/* The extra casts work around common compiler bugs. */
-#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
-#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
- ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \
- : (t) 0))
-#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
+#include "intprops.h"
#ifndef STRTOL_T_MINIMUM
# define STRTOL_T_MINIMUM TYPE_MINIMUM (__strtol_t)
@@ -62,8 +59,6 @@
#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
-#include "xstrtol.h"
-
#if !HAVE_DECL_STRTOIMAX && !defined strtoimax
intmax_t strtoimax ();
#endif
Index: modules/getloadavg
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/getloadavg,v
retrieving revision 1.6
diff -p -u -r1.6 getloadavg
--- modules/getloadavg 28 Jan 2005 23:23:32 -0000 1.6
+++ modules/getloadavg 9 Mar 2005 19:07:39 -0000
@@ -3,6 +3,7 @@ Return the current system load averages.
Files:
lib/getloadavg.c
+lib/intprops.h
Depends-on:
cloexec
Index: modules/human
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/human,v
retrieving revision 1.5
diff -p -u -r1.5 human
--- modules/human 22 Sep 2004 15:11:04 -0000 1.5
+++ modules/human 9 Mar 2005 19:07:39 -0000
@@ -5,6 +5,7 @@ with K/M/G suffix.
Files:
lib/human.h
lib/human.c
+lib/intprops.h
m4/ulonglong.m4
m4/stdint_h.m4
m4/inttypes_h.m4
@@ -32,4 +33,3 @@ GPL
Maintainer:
Paul Eggert
-
Index: modules/inttostr
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/inttostr,v
retrieving revision 1.4
diff -p -u -r1.4 inttostr
--- modules/inttostr 22 Sep 2004 15:11:04 -0000 1.4
+++ modules/inttostr 9 Mar 2005 19:07:39 -0000
@@ -3,6 +3,7 @@ Convert integers to printable strings.
Files:
lib/imaxtostr.c
+lib/intprops.h
lib/inttostr.c
lib/inttostr.h
lib/offtostr.c
Index: modules/sig2str
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/sig2str,v
retrieving revision 1.4
diff -p -u -r1.4 sig2str
--- modules/sig2str 22 Sep 2004 15:11:04 -0000 1.4
+++ modules/sig2str 9 Mar 2005 19:07:39 -0000
@@ -2,6 +2,7 @@ Description:
Convert between signal names and signal numbers.
Files:
+lib/intprops.h
lib/sig2str.h
lib/sig2str.c
m4/sig2str.m4
@@ -22,4 +23,3 @@ GPL
Maintainer:
Paul Eggert, Jim Meyering
-
Index: modules/userspec
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/userspec,v
retrieving revision 1.8
diff -p -u -r1.8 userspec
--- modules/userspec 22 Sep 2004 15:11:04 -0000 1.8
+++ modules/userspec 9 Mar 2005 19:07:39 -0000
@@ -2,6 +2,7 @@ Description:
Parse a `user:group' specifier (e.g. the first argument of chown utility).
Files:
+lib/intprops.h
lib/userspec.c
lib/userspec.h
m4/userspec.m4
Index: modules/utimecmp
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/utimecmp,v
retrieving revision 1.2
diff -p -u -r1.2 utimecmp
--- modules/utimecmp 22 Sep 2004 15:11:04 -0000 1.2
+++ modules/utimecmp 9 Mar 2005 19:07:39 -0000
@@ -2,6 +2,7 @@ Description:
compare file time stamps
Files:
+lib/intprops.h
lib/utimecmp.h
lib/utimecmp.c
m4/utimecmp.m4
@@ -26,4 +27,3 @@ GPL
Maintainer:
Paul Eggert, Jim Meyering
-
Index: modules/xnanosleep
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/xnanosleep,v
retrieving revision 1.4
diff -p -u -r1.4 xnanosleep
--- modules/xnanosleep 1 Mar 2005 17:25:10 -0000 1.4
+++ modules/xnanosleep 9 Mar 2005 19:07:39 -0000
@@ -2,6 +2,7 @@ Description:
a more convenient interface to nanosleep
Files:
+lib/intprops.h
lib/xnanosleep.h
lib/xnanosleep.c
m4/xnanosleep.m4
Index: modules/xstrtol
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/xstrtol,v
retrieving revision 1.7
diff -p -u -r1.7 xstrtol
--- modules/xstrtol 11 Nov 2004 09:29:44 -0000 1.7
+++ modules/xstrtol 9 Mar 2005 19:07:39 -0000
@@ -2,6 +2,7 @@ Description:
Convert string to 'long` or 'unsigned long', with error checking.
Files:
+lib/intprops.h
lib/xstrtol.h
lib/xstrtol.c
lib/xstrtoul.c
- [bug-gnulib] factored integer properties into intprops.h,
Paul Eggert <=