Skip site navigation (1)Skip section navigation (2)
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>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
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:
> 
> --- 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] = a;
>  	s[1][0] = b;
>  	if ((r = strcoll(s[0], s[1])) == 0)
> -		r = (uschar)a - (uschar)b;
> +		r = (int)((uschar)a) - (int)((uschar)b);
>  	return r;
>  }
>  
Pardon my ignorance here, but the following fragment
returns -1, doesn't it?

#include <stdio.h>
void
main(void)
{
        int i;

        i = (unsigned char)1 - (unsigned char)2;
        printf("%d\n", i);
}


Cheers,
-- 
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

[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (FreeBSD)

iD8DBQE9+dNoUkv4P6juNwoRAouxAJ95j0CIEkMNi2ImK2/4c7tnYMJLQACfaDXV
lNkeU+y9kegl+MeyHwNFwkU=
=lggI
-----END PGP SIGNATURE-----
help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021213123240.GC86638>