Date: Fri, 13 Dec 2002 14:32:40 +0200 From: Ruslan Ermilov <ru@FreeBSD.ORG> To: "Andrey A. Chernov" <ache@nagual.pp.ru> Cc: bwk@bell-labs.com, obrien@FreeBSD.ORG, current@FreeBSD.ORG Subject: Re: New AWK bug with collating Message-ID: <20021213123240.GC86638@sunbay.com> In-Reply-To: <20021213122654.GA32014@nagual.pp.ru> References: <20021213122654.GA32014@nagual.pp.ru>
next in thread | previous in thread | raw e-mail | index | archive | help
--E/DnYTRukya0zdZ1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 13, 2002 at 03:26:54PM +0300, Andrey A. Chernov wrote: > Since both operands are unsigned, result can't be negative, but supposed > to be. Here is the fix: >=20 > --- b.c.bak Fri Dec 13 14:54:12 2002 > +++ b.c Fri Dec 13 15:20:15 2002 > @@ -292,7 +292,7 @@ > s[0][0] =3D a; > s[1][0] =3D b; > if ((r =3D strcoll(s[0], s[1])) =3D=3D 0) > - r =3D (uschar)a - (uschar)b; > + r =3D (int)((uschar)a) - (int)((uschar)b); > return r; > } > =20 Pardon my ignorance here, but the following fragment returns -1, doesn't it? #include <stdio.h> void main(void) { int i; i =3D (unsigned char)1 - (unsigned char)2; printf("%d\n", i); } Cheers, --=20 Ruslan Ermilov Sysadmin and DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age --E/DnYTRukya0zdZ1 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQE9+dNoUkv4P6juNwoRAouxAJ95j0CIEkMNi2ImK2/4c7tnYMJLQACfaDXV lNkeU+y9kegl+MeyHwNFwkU= =lggI -----END PGP SIGNATURE----- --E/DnYTRukya0zdZ1-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021213123240.GC86638>