changeset 33515:d917384c06f0

inttostr: simplify by removing unnecessary redundancy * lib/anytostr.c: Don't include verify.h. (anytostr): Don't verify that TYPE_SIGNED (inttype) equals inttype_is_signed. Instead, disable the bogus GCC warnings, so that there's no need for inttype_is_signed and for calling TYPE_SIGNED. * lib/imaxtostr.c (inttype_is_signed): Remove; no longer needed. * lib/inttostr.c, lib/offtostr.c, lib/uinttostr.c, lib/umaxtostr.c: Likewise. * modules/inttostr (Depends-on): Remove 'verify'.
author Paul Eggert <eggert@cs.ucla.edu>
date Sun, 24 Oct 2010 10:11:16 -0700
parents 3c865faa29d7
children d3b3cbf1b19a
files ChangeLog lib/anytostr.c lib/imaxtostr.c lib/inttostr.c lib/offtostr.c lib/uinttostr.c lib/umaxtostr.c modules/inttostr
diffstat 8 files changed, 17 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Oct 23 14:50:38 2010 +0200
+++ b/ChangeLog	Sun Oct 24 10:11:16 2010 -0700
@@ -1,3 +1,15 @@
+2010-10-23  Paul Eggert  <eggert@cs.ucla.edu>
+
+	inttostr: simplify by removing unnecessary redundancy
+	* lib/anytostr.c: Don't include verify.h.
+	(anytostr): Don't verify that TYPE_SIGNED (inttype) equals
+	inttype_is_signed.  Instead, disable the bogus GCC warnings, so that
+	there's no need for inttype_is_signed and for calling TYPE_SIGNED.
+	* lib/imaxtostr.c (inttype_is_signed): Remove; no longer needed.
+	* lib/inttostr.c, lib/offtostr.c, lib/uinttostr.c, lib/umaxtostr.c:
+	Likewise.
+	* modules/inttostr (Depends-on): Remove 'verify'.
+
 2010-10-23  Bruno Haible  <bruno@clisp.org>
 
 	nl_langinfo: Mention problem with CRNCYSTR on NetBSD 5.0.
--- a/lib/anytostr.c	Sat Oct 23 14:50:38 2010 +0200
+++ b/lib/anytostr.c	Sun Oct 24 10:11:16 2010 -0700
@@ -17,10 +17,14 @@
 
 /* Written by Paul Eggert */
 
+/* Tell gcc not to warn about the (i < 0) test, below.  */
+#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__
+# pragma GCC diagnostic ignored "-Wtype-limits"
+#endif
+
 #include <config.h>
 
 #include "inttostr.h"
-#include "verify.h"
 
 /* Convert I to a printable string in BUF, which must be at least
    INT_BUFSIZE_BOUND (INTTYPE) bytes long.  Return the address of the
@@ -29,11 +33,9 @@
 char * __attribute_warn_unused_result__
 anytostr (inttype i, char *buf)
 {
-  verify (TYPE_SIGNED (inttype) == inttype_is_signed);
   char *p = buf + INT_STRLEN_BOUND (inttype);
   *p = 0;
 
-#if inttype_is_signed
   if (i < 0)
     {
       do
@@ -43,7 +45,6 @@
       *--p = '-';
     }
   else
-#endif
     {
       do
         *--p = '0' + i % 10;
--- a/lib/imaxtostr.c	Sat Oct 23 14:50:38 2010 +0200
+++ b/lib/imaxtostr.c	Sun Oct 24 10:11:16 2010 -0700
@@ -1,4 +1,3 @@
 #define anytostr imaxtostr
 #define inttype intmax_t
-#define inttype_is_signed 1
 #include "anytostr.c"
--- a/lib/inttostr.c	Sat Oct 23 14:50:38 2010 +0200
+++ b/lib/inttostr.c	Sun Oct 24 10:11:16 2010 -0700
@@ -1,4 +1,3 @@
 #define anytostr inttostr
 #define inttype int
-#define inttype_is_signed 1
 #include "anytostr.c"
--- a/lib/offtostr.c	Sat Oct 23 14:50:38 2010 +0200
+++ b/lib/offtostr.c	Sun Oct 24 10:11:16 2010 -0700
@@ -1,4 +1,3 @@
 #define anytostr offtostr
 #define inttype off_t
-#define inttype_is_signed 1
 #include "anytostr.c"
--- a/lib/uinttostr.c	Sat Oct 23 14:50:38 2010 +0200
+++ b/lib/uinttostr.c	Sun Oct 24 10:11:16 2010 -0700
@@ -1,4 +1,3 @@
 #define anytostr uinttostr
 #define inttype unsigned int
-#define inttype_is_signed 0
 #include "anytostr.c"
--- a/lib/umaxtostr.c	Sat Oct 23 14:50:38 2010 +0200
+++ b/lib/umaxtostr.c	Sun Oct 24 10:11:16 2010 -0700
@@ -1,4 +1,3 @@
 #define anytostr umaxtostr
 #define inttype uintmax_t
-#define inttype_is_signed 0
 #include "anytostr.c"
--- a/modules/inttostr	Sat Oct 23 14:50:38 2010 +0200
+++ b/modules/inttostr	Sun Oct 24 10:11:16 2010 -0700
@@ -14,7 +14,6 @@
 Depends-on:
 intprops
 stdint
-verify
 
 configure.ac:
 gl_INTTOSTR