fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libc / string / strxfrm.c
blob65ed4f1b120c4cd1a7896916a736d7573614504c
1 /*
2 FUNCTION
3 <<strxfrm>>---transform string
5 INDEX
6 strxfrm
8 ANSI_SYNOPSIS
9 #include <string.h>
10 size_t strxfrm(char *<[s1]>, const char *<[s2]>, size_t <[n]>);
12 TRAD_SYNOPSIS
13 #include <string.h>
14 size_t strxfrm(<[s1]>, <[s2]>, <[n]>);
15 char *<[s1]>;
16 char *<[s2]>;
17 size_t <[n]>;
19 DESCRIPTION
20 This function transforms the string pointed to by <[s2]> and
21 places the resulting string into the array pointed to by
22 <[s1]>. The transformation is such that if the <<strcmp>>
23 function is applied to the two transformed strings, it returns
24 a value greater than, equal to, or less than zero,
25 correspoinding to the result of a <<strcoll>> function applied
26 to the same two original strings.
28 No more than <[n]> characters are placed into the resulting
29 array pointed to by <[s1]>, including the terminating null
30 character. If <[n]> is zero, <[s1]> may be a null pointer. If
31 copying takes place between objects that overlap, the behavior
32 is undefined.
34 With a C locale, this function just copies.
36 RETURNS
37 The <<strxfrm>> function returns the length of the transformed string
38 (not including the terminating null character). If the value returned
39 is <[n]> or more, the contents of the array pointed to by
40 <[s1]> are indeterminate.
42 PORTABILITY
43 <<strxfrm>> is ANSI C.
45 <<strxfrm>> requires no supporting OS subroutines.
47 QUICKREF
48 strxfrm ansi pure
51 #include <string.h>
53 size_t
54 _DEFUN (strxfrm, (s1, s2, n),
55 char *s1 _AND
56 _CONST char *s2 _AND
57 size_t n)
59 size_t res;
60 res = 0;
61 while (n-- > 0)
63 if ((*s1++ = *s2++) != '\0')
64 ++res;
65 else
66 return res;
68 while (*s2)
70 ++s2;
71 ++res;
74 return res;