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: Bruno Haible
Subject: Re: patch to fix build warning for gettext-0.14.4
Date: Mon, 18 Jul 2005 13:59:09 +0200
User-agent: KMail/1.5

Jeff Rizzo wrote:
> > 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.

Ouch. You are right. So I've added one more #if, to keep the tradition.

Meanwhile we have discussed this issue among GNU package maintainers, and
there is consensus that there's no good way to silence this warning in
general, and therefore that it should be ignored.

In this particular case, a cast of the quantity to (unsigned char) would
also have done it, but for the moment I continue the tradition...

+    return mbc->bytes == 1 && (mbc->buf[0] & 0x80) == 0;

For better portability (i.e.to not assume that 'char' has exactly 8 bits),
the second part should be

                               (mbc->buf[0] & ~0x7F) == 0;

or

                               (unsigned char) mbc->buf[0] <= 0x7F;

Bruno


2005-07-17  Bruno Haible  <address@hidden>

        * po-lex.c (mb_width): Remove gcc warnings on platform with unsigned
        'char' type (e.g. Linux/PowerPC).
        Reported by Jeff Rizzo <address@hidden>.

diff -r -c3 gettext-cvs/gettext-tools/src/po-lex.c 
gettext-6/gettext-tools/src/po-lex.c
*** gettext-cvs/gettext-tools/src/po-lex.c      Sat May 21 00:18:42 2005
--- gettext-6/gettext-tools/src/po-lex.c        Mon Jul 18 02:37:25 2005
***************
*** 310,316 ****
      {
        if (mbc->bytes == 1)
        {
!         if (mbc->buf[0] >= 0x00 && mbc->buf[0] <= 0x1F)
            {
              if (mbc->buf[0] == 0x09)
                return 8 - (gram_pos_column & 7);
--- 310,320 ----
      {
        if (mbc->bytes == 1)
        {
!         if (
! #if CHAR_MIN < 0x00 /* to avoid gcc warning */
!             mbc->buf[0] >= 0x00 &&
! #endif
!             mbc->buf[0] <= 0x1F)
            {
              if (mbc->buf[0] == 0x09)
                return 8 - (gram_pos_column & 7);





reply via email to

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