[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] inttostr: simplify by removing unnecessary redundancy
From: |
Paul Eggert |
Subject: |
Re: [PATCH] inttostr: simplify by removing unnecessary redundancy |
Date: |
Sun, 24 Oct 2010 10:21:58 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.11) Gecko/20101006 Thunderbird/3.1.5 |
On 10/22/2010 01:31 PM, Eric Blake wrote:
> Yes, I can live with re-adding that pragma.
OK, thanks, I installed this:
---
ChangeLog | 12 ++++++++++++
lib/anytostr.c | 9 +++++----
lib/imaxtostr.c | 1 -
lib/inttostr.c | 1 -
lib/offtostr.c | 1 -
lib/uinttostr.c | 1 -
lib/umaxtostr.c | 1 -
modules/inttostr | 1 -
8 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f312a88..95328fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2010-10-23 Paul Eggert <address@hidden>
+
+ 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 <address@hidden>
nl_langinfo: Mention problem with CRNCYSTR on NetBSD 5.0.
diff --git a/lib/anytostr.c b/lib/anytostr.c
index 27ad985..eb71553 100644
--- a/lib/anytostr.c
+++ b/lib/anytostr.c
@@ -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 @@ anytostr (inttype i, char *buf)
*--p = '-';
}
else
-#endif
{
do
*--p = '0' + i % 10;
diff --git a/lib/imaxtostr.c b/lib/imaxtostr.c
index d2a0429..b91ac98 100644
--- a/lib/imaxtostr.c
+++ b/lib/imaxtostr.c
@@ -1,4 +1,3 @@
#define anytostr imaxtostr
#define inttype intmax_t
-#define inttype_is_signed 1
#include "anytostr.c"
diff --git a/lib/inttostr.c b/lib/inttostr.c
index 14db9b8..c96b5ca 100644
--- a/lib/inttostr.c
+++ b/lib/inttostr.c
@@ -1,4 +1,3 @@
#define anytostr inttostr
#define inttype int
-#define inttype_is_signed 1
#include "anytostr.c"
diff --git a/lib/offtostr.c b/lib/offtostr.c
index 68f2b69..96082aa 100644
--- a/lib/offtostr.c
+++ b/lib/offtostr.c
@@ -1,4 +1,3 @@
#define anytostr offtostr
#define inttype off_t
-#define inttype_is_signed 1
#include "anytostr.c"
diff --git a/lib/uinttostr.c b/lib/uinttostr.c
index 21fa376..48fd98f 100644
--- a/lib/uinttostr.c
+++ b/lib/uinttostr.c
@@ -1,4 +1,3 @@
#define anytostr uinttostr
#define inttype unsigned int
-#define inttype_is_signed 0
#include "anytostr.c"
diff --git a/lib/umaxtostr.c b/lib/umaxtostr.c
index 7fd9950..f95bfc3 100644
--- a/lib/umaxtostr.c
+++ b/lib/umaxtostr.c
@@ -1,4 +1,3 @@
#define anytostr umaxtostr
#define inttype uintmax_t
-#define inttype_is_signed 0
#include "anytostr.c"
diff --git a/modules/inttostr b/modules/inttostr
index 495ef25..6bbec28 100644
--- a/modules/inttostr
+++ b/modules/inttostr
@@ -14,7 +14,6 @@ m4/inttostr.m4
Depends-on:
intprops
stdint
-verify
configure.ac:
gl_INTTOSTR
--
1.7.2
Re: [PATCH] inttostr: simplify by removing unnecessary redundancy, Eric Blake, 2010/10/22