Mail Archives: djgpp-workers/2005/01/18/13:50:29
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 -