inttostr: revert most-recent change
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 22 Oct 2010 19:42:17 +0000 (12:42 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 22 Oct 2010 19:42:59 +0000 (12:42 -0700)
ChangeLog
lib/anytostr.c
lib/imaxtostr.c
lib/inttostr.c
lib/offtostr.c
lib/uinttostr.c
lib/umaxtostr.c
modules/inttostr

index 5015e22..1239a10 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,17 +1,3 @@
-2010-10-22  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, use TYPE_SIGNED (inttype) directly.
-       This removes the need for inttype_is_signed, which was put in to
-       suppress some GCC warnings about conversions.  This rewrite should
-       also suppress those warnings.
-       * 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-21  Bruno Haible  <bruno@clisp.org>
 
        nl_langinfo test: Avoid test failure on NetBSD 5.
index a64011f..27ad985 100644 (file)
@@ -20,6 +20,7 @@
 #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
 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 (TYPE_SIGNED (inttype) && i < 0)
+#if inttype_is_signed
+  if (i < 0)
     {
       do
         *--p = '0' - i % 10;
@@ -40,6 +43,7 @@ anytostr (inttype i, char *buf)
       *--p = '-';
     }
   else
+#endif
     {
       do
         *--p = '0' + i % 10;
index b91ac98..d2a0429 100644 (file)
@@ -1,3 +1,4 @@
 #define anytostr imaxtostr
 #define inttype intmax_t
+#define inttype_is_signed 1
 #include "anytostr.c"
index c96b5ca..14db9b8 100644 (file)
@@ -1,3 +1,4 @@
 #define anytostr inttostr
 #define inttype int
+#define inttype_is_signed 1
 #include "anytostr.c"
index 96082aa..68f2b69 100644 (file)
@@ -1,3 +1,4 @@
 #define anytostr offtostr
 #define inttype off_t
+#define inttype_is_signed 1
 #include "anytostr.c"
index 48fd98f..21fa376 100644 (file)
@@ -1,3 +1,4 @@
 #define anytostr uinttostr
 #define inttype unsigned int
+#define inttype_is_signed 0
 #include "anytostr.c"
index f95bfc3..7fd9950 100644 (file)
@@ -1,3 +1,4 @@
 #define anytostr umaxtostr
 #define inttype uintmax_t
+#define inttype_is_signed 0
 #include "anytostr.c"
index 6bbec28..495ef25 100644 (file)
@@ -14,6 +14,7 @@ m4/inttostr.m4
 Depends-on:
 intprops
 stdint
+verify
 
 configure.ac:
 gl_INTTOSTR