X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f Date: Tue, 18 Jan 2005 11:49:10 -0700 From: Brian Inglis Subject: Re: strxfrm In-reply-to: To: DJGPP-workers Message-id: Organization: Systematic Software MIME-version: 1.0 X-Mailer: Forte Agent 1.93/32.576 English (American) Content-type: text/plain; charset=us-ascii References: Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id j0IIoP1R022328 Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Tue, 18 Jan 2005 11:40:14 -0700, Brian Inglis wrote: >I was checking the Standard for setlocale() and noticed that strxfrm() >should be affected, and we don't have a liblocal.02 version. >So I checked the current version in CVS and it is ancient K&R code that >does not return the correct value when the third size parameter is zero, >and what it is doing seemed overly complex for what it should be doing. >So here's an update to make strxfrm.c meet the spec and simplify >operation, and updated documentation. And here's the update to the previous update for a liblocal.02 version. Thanks. Take care, Brian Inglis --- src/libc/ansi/string/strxfrm.c 2005-01-18 04:28:38.000000000 -0700 +++ contrib/liblocal.02/src/ansi/string/strxfrm.c 2005-01-18 11:19:32.000000000 -0700 @@ -3,6 +3,10 @@ #include +extern char __dj_collate_table[]; + +#define coll(c) __dj_collate_table[(unsigned char)c] + size_t strxfrm( char *dst, const char *src, size_t n) { @@ -10,8 +14,9 @@ strxfrm( char *dst, const char *src, siz /* if dst has space for src */ if (n > r) - /* copy string */ - strcpy( dst, src); + /* copy collation value of bytes */ + while ((*dst++ = coll( *src++ ))) + continue; /* return len to copy/copied excluding nul */ return r;