Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Jun 1998 10:05:28 +0600 (ESS)
From:      sg@mplik.ru
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   bin/6825: strxfrm() function returns junk in any locale except "C"
Message-ID:  <199806020405.KAA23435@dream.mplik.ru>

next in thread | raw e-mail | index | archive | help

>Number:         6825
>Category:       bin
>Synopsis:       strxfrm() function returns junk in any locale except "C"
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun  1 21:30:00 PDT 1998
>Last-Modified:
>Originator:     Sergey Gershtein
>Organization:
Ural Relcom Ltd
>Release:        FreeBSD 3.0-CURRENT i386
>Environment:

	The problem appears to exist both in FreeBSD 2.2.5-RELEASE and
	FreeBSD 3.0-CURRENT

>Description:

	The strxfrm() function always fill up all the supplied *dst
	space with THE SAME character IF supplied *src string is
	longer than 1 character AND current locale is not "C".

	The particular character that is filled in *dst seems to
	depend only on the first character of *src.

	This behaviour makes strxfrm() function useless for comapring
	strings that start with the same character.

	strcoll() function works fine.

>How-To-Repeat:

#include <iostream.h>
#include <string.h>
#include <locale.h>

int main() {

	/* any but C locale seems to produce the bug */
	setlocale(LC_ALL,"ru_SU.KOI8-R");

	char s1[50]="qasdf", s2[50]="qdfg", s3[50], s4[50];

	strxfrm(s3,s1,49);
	strxfrm(s4,s2,49);

	/* The following line prints 0 though strings aren't equal */
	cerr << strcmp(s3,s4) << endl;

	/* This reveals WHY strcmp() returned 0 */
	cerr << s3 << endl;
	cerr << s4 << endl;

	/* This shows that strcoll() still works fine */
	cerr << strcoll(s1,s2) << endl;

	return 0;
}
	

>Fix:
	

>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



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