2007-04-09 Joel Schopp <jschopp@austin.ibm.com>
* libc/machine/spu/strxfrm.c: Fix strxfrm so we still copy data even if the passed in length n is shorter than the source string. This matches both the non-spu specific and the glibc strxfrm behaviour.
This commit is contained in:
parent
69de39769d
commit
abe43f4262
|
@ -1,3 +1,10 @@
|
||||||
|
2007-04-09 Joel Schopp <jschopp@austin.ibm.com>
|
||||||
|
|
||||||
|
* libc/machine/spu/strxfrm.c: Fix strxfrm so we still copy data
|
||||||
|
even if the passed in length n is shorter than the source string.
|
||||||
|
This matches both the non-spu specific and the glibc strxfrm
|
||||||
|
behaviour.
|
||||||
|
|
||||||
2007-04-04 Mark Mitchell <mark@codesourcery.com>
|
2007-04-04 Mark Mitchell <mark@codesourcery.com>
|
||||||
|
|
||||||
* libc/stdlib/__call_atexit.c (__call_exitprocs): Handle atexit
|
* libc/stdlib/__call_atexit.c (__call_exitprocs): Handle atexit
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#define min(a, b) (a) < (b) ? (a) : (b)
|
||||||
|
|
||||||
/* The strxfrm() function transforms the src string into a form such that
|
/* The strxfrm() function transforms the src string into a form such that
|
||||||
* the result of strcmp() on two strings that have been transformed with
|
* the result of strcmp() on two strings that have been transformed with
|
||||||
|
@ -54,13 +55,7 @@ size_t strxfrm(char * __restrict__ dest, const char * __restrict__ src, size_t n
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
len = strlen(src);
|
len = strlen(src);
|
||||||
|
(void)memcpy((void *)dest, (void *)src, min(n,len + 1));
|
||||||
|
|
||||||
/* Since the destination is indeterminant if n is less than of equal
|
return len;
|
||||||
* to the string length, we skip performing the copy (altogether) in
|
|
||||||
* this case.
|
|
||||||
*/
|
|
||||||
if (n > len) {
|
|
||||||
(void)memcpy((void *)dest, (void *)src, n);
|
|
||||||
}
|
|
||||||
return (len);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue