changeset 5691:ec62790f0938

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.
author Paul Eggert <eggert@cs.ucla.edu>
date Wed, 09 Mar 2005 19:11:23 +0000
parents e44b4f85ad9b
children 406d0874ad6a
files lib/ChangeLog lib/getloadavg.c lib/human.c lib/human.h lib/intprops.h lib/inttostr.h lib/mktime.c lib/sig2str.h lib/strftime.c lib/strtol.c lib/userspec.c lib/utimecmp.c lib/xnanosleep.c lib/xstrtol.c modules/getloadavg modules/human modules/inttostr modules/sig2str modules/userspec modules/utimecmp modules/xnanosleep modules/xstrtol
diffstat 22 files changed, 164 insertions(+), 91 deletions(-) [+]
line wrap: on
line diff
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,40 @@
+2005-03-09  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Factor int-properties macros into a single file, except for
+	glibc-related files.
+	* intprops.h: New file.
+	* getloadavg.c: Include it instead of limits.h.
+	(INT_STRLEN_BOUND): Remove.
+	* human.c: Include intprops.h.
+	(group_number): Use INT_STRLEN_BOUND instead of rolling it ourself.
+	* human.h (LONGEST_HUMAN_READABLE): Use 146/485 rather than 302/1000.
+	* inttostr.h: Include intprops.h instead of limits.h.
+	(INT_STRLEN_BOUND, INT_BUFSIZE_BOUND): Remove.
+	* mktime.c (TYPE_IS_INTEGER, TYPE_TWOS_COMPLEMENT): New macros,
+	for consistency with intprops.h.
+	(time_t_is_integer, twos_complement_arithmetic): Use them.
+	* sig2str.h: Include <signal.h>, intprops.h.
+	(INT_STRLEN_BOUND): Remove.
+	* strftime.c (TYPE_SIGNED): Remove.
+	(INT_STRLEN_BOUND): Switch to same implementation as intprops.h.
+	* strtol.c: Adjust comments to match intprops.h.
+	* userspec.c: Include intprops.h.
+	(TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM): Remove.
+	* utimecmp.c, xnanosleep.c, xstrtol.c: Likewise.
+	* utimecmp.c (utimecmp): Use TYPE_IS_INTEGER, TYPE_TWOS_COMPLEMENT
+	instead of rolling our own expressions.
+	* xstrtol.c: Include xstrtol.h first, to test interface.
+
+	* strftime.c: Include <stdbool.h>.  Use bool where appropriate,
+	instead of int.
+	(my_strftime): Do not mishandle years close to INT_MAX, by doing
+	the right thing even if adding 1900 would overflow.  Similarly
+	for tm_mon + 1 and tm_yday + 1.
+	Make %Y always equivalent to %C%y, and similarly for %G and %g.
+	(DO_NUMBER, DO_NUMBER_SPACEPAD): Set digits to d, not a conditional.
+	(DO_SIGNED_NUMBER): New macro.
+	(my_strftime) [HAVE_TZNAME]: Don't dump core if tp->tm_dst > 1.
+
 2005-03-07  Bruno Haible  <bruno@clisp.org>
 
 	* pagealign_alloc.c (MAP_FILE, MAP_FAILED): Define fallbacks.
--- a/lib/getloadavg.c
+++ b/lib/getloadavg.c
@@ -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 bug-gnulib@gnu.org.
@@ -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 @@
 #   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;
--- a/lib/human.c
+++ b/lib/human.c
@@ -35,6 +35,7 @@
 
 #include <argmatch.h>
 #include <error.h>
+#include <intprops.h>
 #include <xstrtol.h>
 
 #ifndef SIZE_MAX
@@ -99,10 +100,8 @@
   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;
--- a/lib/human.h
+++ b/lib/human.h
@@ -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.  */
new file mode 100644
--- /dev/null
+++ b/lib/intprops.h
@@ -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)
--- a/lib/inttostr.h
+++ b/lib/inttostr.h
@@ -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 *);
--- a/lib/mktime.c
+++ b/lib/mktime.c
@@ -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 (eggert@twinsun.com).
 
@@ -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 @@
     {
       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
--- a/lib/sig2str.h
+++ b/lib/sig2str.h
@@ -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)
--- a/lib/strftime.c
+++ b/lib/strftime.c
@@ -120,15 +120,12 @@
    ? (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
 
--- a/lib/strtol.c
+++ b/lib/strtol.c
@@ -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 @@
 # 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) \
--- a/lib/userspec.c
+++ b/lib/userspec.c
@@ -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 @@
 # 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
--- a/lib/utimecmp.c
+++ b/lib/utimecmp.c
@@ -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 @@
 
      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;
--- a/lib/xnanosleep.c
+++ b/lib/xnanosleep.c
@@ -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)
--- a/lib/xstrtol.c
+++ b/lib/xstrtol.c
@@ -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
--- a/modules/getloadavg
+++ b/modules/getloadavg
@@ -3,6 +3,7 @@
 
 Files:
 lib/getloadavg.c
+lib/intprops.h
 
 Depends-on:
 cloexec
--- a/modules/human
+++ b/modules/human
@@ -5,6 +5,7 @@
 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 @@
 
 Maintainer:
 Paul Eggert
-
--- a/modules/inttostr
+++ b/modules/inttostr
@@ -3,6 +3,7 @@
 
 Files:
 lib/imaxtostr.c
+lib/intprops.h
 lib/inttostr.c
 lib/inttostr.h
 lib/offtostr.c
--- a/modules/sig2str
+++ b/modules/sig2str
@@ -2,6 +2,7 @@
 Convert between signal names and signal numbers.
 
 Files:
+lib/intprops.h
 lib/sig2str.h
 lib/sig2str.c
 m4/sig2str.m4
@@ -22,4 +23,3 @@
 
 Maintainer:
 Paul Eggert, Jim Meyering
-
--- a/modules/userspec
+++ b/modules/userspec
@@ -2,6 +2,7 @@
 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
--- a/modules/utimecmp
+++ b/modules/utimecmp
@@ -2,6 +2,7 @@
 compare file time stamps
 
 Files:
+lib/intprops.h
 lib/utimecmp.h
 lib/utimecmp.c
 m4/utimecmp.m4
@@ -26,4 +27,3 @@
 
 Maintainer:
 Paul Eggert, Jim Meyering
-
--- a/modules/xnanosleep
+++ b/modules/xnanosleep
@@ -2,6 +2,7 @@
 a more convenient interface to nanosleep
 
 Files:
+lib/intprops.h
 lib/xnanosleep.h
 lib/xnanosleep.c
 m4/xnanosleep.m4
--- a/modules/xstrtol
+++ b/modules/xstrtol
@@ -2,6 +2,7 @@
 Convert string to 'long` or 'unsigned long', with error checking.
 
 Files:
+lib/intprops.h
 lib/xstrtol.h
 lib/xstrtol.c
 lib/xstrtoul.c