bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: patch to fix build warning for gettext-0.14.4


From: Jeff Rizzo
Subject: Re: patch to fix build warning for gettext-0.14.4
Date: Mon, 2 May 2005 06:40:34 -0700
User-agent: Mutt/1.4.2.1i

On Mon, May 02, 2005 at 01:25:14PM +0200, Bruno Haible wrote:
> Jeff Rizzo wrote:
> > When building gettext-0.14.4 for NetBSD/macppc, the following warning
> > happens:
> > In function `mb_width':
> > /usr/src-current/gnu/dist/gettext/gettext-tools/src/po-lex.c:313: warning:
> > comparison is always true due to limited range of data type
> >
> 
> Thanks for the report and patch. But your patch introduces ugly #ifs
> in the code, and makes the code more brittle. I prefer the existing code
> because it is more robust, even if it elicits (benign) warnings on some
> platforms.

If you look at the existing code, this *exact* test is done elsewhere
in the same file.  That's why I implemented it thus, for consitency with
what was there.  If you like, apply *this* patch, which gets rid of the
warning (which, benign or not, is there for a reason;  when you get enough
of them in a project, people can ignore things that are genuine portability
problems) and also removes the OTHER #if *which is already there* from the
code.

Once again, this diff is against the 0.14.4 release.

--- gettext-tools/src/po-lex.c.orig     2004-09-07 04:27:07.000000000 -0700
+++ gettext-tools/src/po-lex.c  2005-05-02 06:31:11.000000000 -0700
@@ -266,14 +266,7 @@
     return (mbc->uc >= 0x0000 && mbc->uc <= 0x007F);
   else
 #endif
-    return (mbc->bytes == 1
-#if CHAR_MIN < 0x00 /* to avoid gcc warning */
-           && mbc->buf[0] >= 0x00
-#endif
-#if CHAR_MAX > 0x7F /* to avoid gcc warning */
-           && mbc->buf[0] <= 0x7F
-#endif
-          );
+    return mbc->bytes == 1 && (mbc->buf[0] & 0x80) == 0;
 }
 
 /* Extra <wchar.h> function.  */
@@ -310,7 +303,7 @@
     {
       if (mbc->bytes == 1)
        {
-         if (mbc->buf[0] >= 0x00 && mbc->buf[0] <= 0x1F)
+         if ((mbc->buf[0] & 0x80) == 0 && mbc->buf[0] <= 0x1F)
            {
              if (mbc->buf[0] == 0x09)
                return 8 - (gram_pos_column & 7);

Attachment: pgpS4NO27bDsz.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]