summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2010-10-22 11:14:17 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2010-10-22 11:14:58 -0700
commitba6c03ba1a75ab19506e823d7a1d2f7daa70821b (patch)
tree0e3b5bc9cacab2db4e6333230f9636972b844e69
parenta0598ff28d2256e53968f760492c55879055ea94 (diff)
downloadgnulib-ba6c03ba1a75ab19506e823d7a1d2f7daa70821b.tar.gz
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'.
-rw-r--r--ChangeLog14
-rw-r--r--lib/anytostr.c6
-rw-r--r--lib/imaxtostr.c1
-rw-r--r--lib/inttostr.c1
-rw-r--r--lib/offtostr.c1
-rw-r--r--lib/uinttostr.c1
-rw-r--r--lib/umaxtostr.c1
-rw-r--r--modules/inttostr1
8 files changed, 15 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 1239a1092b..5015e22fa6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+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.
diff --git a/lib/anytostr.c b/lib/anytostr.c
index 27ad985024..a64011f5ee 100644
--- a/lib/anytostr.c
+++ b/lib/anytostr.c
@@ -20,7 +20,6 @@
#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,12 +28,10 @@
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)
+ if (TYPE_SIGNED (inttype) && i < 0)
{
do
*--p = '0' - i % 10;
@@ -43,7 +40,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 d2a0429b0d..b91ac98c4e 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 14db9b8c11..c96b5ca39b 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 68f2b695be..96082aafc0 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 21fa3761a9..48fd98f21c 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 7fd995084e..f95bfc3ee0 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 495ef25cf5..6bbec28955 100644
--- a/modules/inttostr
+++ b/modules/inttostr
@@ -14,7 +14,6 @@ m4/inttostr.m4
Depends-on:
intprops
stdint
-verify
configure.ac:
gl_INTTOSTR