summaryrefslogtreecommitdiff
path: root/src/lib/libc/string/strxfrm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/string/strxfrm.c')
-rw-r--r--src/lib/libc/string/strxfrm.c32
1 files changed, 6 insertions, 26 deletions
diff --git a/src/lib/libc/string/strxfrm.c b/src/lib/libc/string/strxfrm.c
index d9df77b957..a2e2dbc440 100644
--- a/src/lib/libc/string/strxfrm.c
+++ b/src/lib/libc/string/strxfrm.c
@@ -13,11 +13,7 @@
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution. 15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software 16 * 3. Neither the name of the University nor the names of its contributors
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software 17 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission. 18 * without specific prior written permission.
23 * 19 *
@@ -35,8 +31,7 @@
35 */ 31 */
36 32
37#if defined(LIBC_SCCS) && !defined(lint) 33#if defined(LIBC_SCCS) && !defined(lint)
38/*static char *sccsid = "from: @(#)strxfrm.c 5.2 (Berkeley) 1/26/91";*/ 34static char *rcsid = "$OpenBSD: strxfrm.c,v 1.5 2003/09/06 22:43:12 tedu Exp $";
39static char *rcsid = "$Id: strxfrm.c,v 1.1.1.1 1995/10/18 08:42:23 deraadt Exp $";
40#endif /* LIBC_SCCS and not lint */ 35#endif /* LIBC_SCCS and not lint */
41 36
42#include <string.h> 37#include <string.h>
@@ -47,28 +42,13 @@ static char *rcsid = "$Id: strxfrm.c,v 1.1.1.1 1995/10/18 08:42:23 deraadt Exp $
47 * on the original untransformed strings would return. 42 * on the original untransformed strings would return.
48 */ 43 */
49size_t 44size_t
50strxfrm(dst, src, n) 45strxfrm(char *dst, const char *src, size_t n)
51 register char *dst;
52 register const char *src;
53 register size_t n;
54{ 46{
55 register size_t r = 0;
56 register int c;
57 47
58 /* 48 /*
59 * Since locales are unimplemented, this is just a copy. 49 * Since locales are unimplemented, this is just a copy.
60 */ 50 */
61 if (n != 0) { 51 if (n == 0)
62 while ((c = *src++) != 0) { 52 return (strlen(src));
63 r++; 53 return (strlcpy(dst, src, n));
64 if (--n == 0) {
65 while (*src++ != 0)
66 r++;
67 break;
68 }
69 *dst++ = c;
70 }
71 *dst = 0;
72 }
73 return (r);
74} 54}