2000-02-18 03:39:52 +08:00
|
|
|
/*
|
|
|
|
FUNCTION
|
|
|
|
<<strxfrm>>---transform string
|
|
|
|
|
|
|
|
INDEX
|
|
|
|
strxfrm
|
|
|
|
|
|
|
|
ANSI_SYNOPSIS
|
|
|
|
#include <string.h>
|
* libc/sys/linux/include/netdb.h, libc/sys/linux/net/getaddrinfo.c,
libc/sys/linux/net/getnameinfo.c: Add restrict keyword to getnameinfo()
and getaddrinfo() to increase standards compliance and match glibc.
* libc/include/string.h, libc/string/memccpy.c, libc/string/memcpy.c,
libc/string/stpcpy.c, libc/string/stpncpy.c, libc/string/strcat.c,
libc/string/strncat.c, libc/string/strncpy.c, libc/string/strtok.c,
libc/string/strtok_r.c, libc/string/strxfrm.c
libc/machine/microblaze/strcpy.c, libc/machine/xscale/memcpy.c,
libc/machine/cris/memcpy.c: Add __restrict to prototype to
increase standards compliance.
2013-07-23 15:05:31 +08:00
|
|
|
size_t strxfrm(char *restrict <[s1]>, const char *restrict <[s2]>,
|
|
|
|
size_t <[n]>);
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
TRAD_SYNOPSIS
|
|
|
|
#include <string.h>
|
|
|
|
size_t strxfrm(<[s1]>, <[s2]>, <[n]>);
|
|
|
|
char *<[s1]>;
|
|
|
|
char *<[s2]>;
|
|
|
|
size_t <[n]>;
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
This function transforms the string pointed to by <[s2]> and
|
|
|
|
places the resulting string into the array pointed to by
|
|
|
|
<[s1]>. The transformation is such that if the <<strcmp>>
|
|
|
|
function is applied to the two transformed strings, it returns
|
|
|
|
a value greater than, equal to, or less than zero,
|
|
|
|
correspoinding to the result of a <<strcoll>> function applied
|
|
|
|
to the same two original strings.
|
|
|
|
|
|
|
|
No more than <[n]> characters are placed into the resulting
|
|
|
|
array pointed to by <[s1]>, including the terminating null
|
|
|
|
character. If <[n]> is zero, <[s1]> may be a null pointer. If
|
|
|
|
copying takes place between objects that overlap, the behavior
|
|
|
|
is undefined.
|
|
|
|
|
|
|
|
With a C locale, this function just copies.
|
|
|
|
|
|
|
|
RETURNS
|
|
|
|
The <<strxfrm>> function returns the length of the transformed string
|
|
|
|
(not including the terminating null character). If the value returned
|
|
|
|
is <[n]> or more, the contents of the array pointed to by
|
|
|
|
<[s1]> are indeterminate.
|
|
|
|
|
|
|
|
PORTABILITY
|
|
|
|
<<strxfrm>> is ANSI C.
|
|
|
|
|
|
|
|
<<strxfrm>> requires no supporting OS subroutines.
|
|
|
|
|
|
|
|
QUICKREF
|
|
|
|
strxfrm ansi pure
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
size_t
|
|
|
|
_DEFUN (strxfrm, (s1, s2, n),
|
* libc/sys/linux/include/netdb.h, libc/sys/linux/net/getaddrinfo.c,
libc/sys/linux/net/getnameinfo.c: Add restrict keyword to getnameinfo()
and getaddrinfo() to increase standards compliance and match glibc.
* libc/include/string.h, libc/string/memccpy.c, libc/string/memcpy.c,
libc/string/stpcpy.c, libc/string/stpncpy.c, libc/string/strcat.c,
libc/string/strncat.c, libc/string/strncpy.c, libc/string/strtok.c,
libc/string/strtok_r.c, libc/string/strxfrm.c
libc/machine/microblaze/strcpy.c, libc/machine/xscale/memcpy.c,
libc/machine/cris/memcpy.c: Add __restrict to prototype to
increase standards compliance.
2013-07-23 15:05:31 +08:00
|
|
|
char *__restrict s1 _AND
|
|
|
|
_CONST char *__restrict s2 _AND
|
2000-02-18 03:39:52 +08:00
|
|
|
size_t n)
|
|
|
|
{
|
|
|
|
size_t res;
|
|
|
|
res = 0;
|
|
|
|
while (n-- > 0)
|
|
|
|
{
|
|
|
|
if ((*s1++ = *s2++) != '\0')
|
|
|
|
++res;
|
|
|
|
else
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
while (*s2)
|
|
|
|
{
|
|
|
|
++s2;
|
|
|
|
++res;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|