delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2005/01/18/13:50:29

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 <Brian DOT Inglis AT SystematicSw DOT ab DOT ca>
Subject: Re: strxfrm
In-reply-to: <tilqu0hfoiinq6vb3qef9t11a2vfia789d@4ax.com>
To: DJGPP-workers <DJGPP-workers AT delorie DOT com>
Message-id: <eemqu0pfd02nm2r8k7m6en13eai2iide8j@4ax.com>
Organization: Systematic Software
MIME-version: 1.0
X-Mailer: Forte Agent 1.93/32.576 English (American)
References: <tilqu0hfoiinq6vb3qef9t11a2vfia789d AT 4ax DOT com>
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

On Tue, 18 Jan 2005 11:40:14 -0700, Brian Inglis <Brian DOT Inglis AT SystematicSW DOT ab DOT ca> 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 <string.h>
 
+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;

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019