From owner-freebsd-hackers Mon Mar 17 12:52:51 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id MAA04009 for hackers-outgoing; Mon, 17 Mar 1997 12:52:51 -0800 (PST) Received: from odin.INS.CWRU.Edu (odin.INS.CWRU.Edu [129.22.8.102]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id MAA04000 for ; Mon, 17 Mar 1997 12:52:43 -0800 (PST) Received: (chet@localhost) by odin.INS.CWRU.Edu (8.7.6+cwru/CWRU-2.3-ins) id PAA29341; Mon, 17 Mar 1997 15:52:30 -0500 (EST) (from chet) Date: Mon, 17 Mar 1997 15:37:12 -0500 From: Chet Ramey To: freebsd-hackers@freebsd.org Subject: Problem with strcoll in FreeBSD 2.1.7 Cc: chet@odin.INS.CWRU.Edu Reply-To: chet@po.CWRU.Edu Message-ID: <9703172037.AA28815.SM@odin.INS.CWRU.Edu> Read-Receipt-To: chet@po.CWRU.Edu MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Hi. I'm puzzled by the following results, and I'm wondering if there's a bug in strcoll(3) or if I'm misunderstanding things. Given the following program: #include #include #include void testcoll(s1, s2) char *s1, *s2; { int r1, r2; r1 = strcoll(s1, s2); r2 = strcmp(s1, s2); printf ("strcoll(%s, %s) -> %d\n", s1, s2, r1); printf ("strcmp(%s, %s) -> %d\n", s1, s2, r2); } main(c, v) int c; char *v[]; { char *deflocale, *defcoll; char xf1[16], xf2[16]; deflocale = setlocale(LC_ALL, (char *)NULL); defcoll = setlocale(LC_COLLATE, (char *)NULL); printf ("default locale: %s\n", deflocale); printf ("default collation order: %s\n", defcoll); testcoll (v[1], v[2]); strxfrm(xf1, v[1], 16); strxfrm(xf2, v[2], 16); printf ("%s locale, after strxfrm:\n", deflocale); testcoll(xf1, xf2); setlocale (LC_ALL, "POSIX"); setlocale (LC_COLLATE, "POSIX"); printf ("POSIX locale:\n"); printf ("POSIX collation order:\n"); testcoll(v[1], v[2]); strxfrm(xf1, v[1], 16); strxfrm(xf2, v[2], 16); printf ("POSIX locale, after strxfrm:\n"); testcoll(xf1, xf2); exit (0); } I get the following output, which seems strange: bash$ ./x1 abd aXd default locale: C default collation order: C strcoll(abd, aXd) -> -22 strcmp(abd, aXd) -> 10 C locale, after strxfrm: strcoll(abd, aXd) -> -22 strcmp(abd, aXd) -> 10 POSIX locale: POSIX collation order: strcoll(abd, aXd) -> -22 strcmp(abd, aXd) -> 10 POSIX locale, after strxfrm: strcoll(abd, aXd) -> -22 strcmp(abd, aXd) -> 10 Shouldn't both strcoll(3) and strcmp(3) return values > 0? Thanks for any help. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer Chet Ramey, Case Western Reserve University Internet: chet@po.CWRU.Edu