diff options
author | 2003-09-06 22:43:12 +0000 | |
---|---|---|
committer | 2003-09-06 22:43:12 +0000 | |
commit | 0fa58eff6f4008ab36cf4c3ddf3f886ef8a02b4a (patch) | |
tree | be919a1a696b5b768b01c6f6e5dd88c5d55e86d0 /lib/libc/string | |
parent | MD installation notes updates for 3.4, 2/3 (diff) | |
download | wireguard-openbsd-0fa58eff6f4008ab36cf4c3ddf3f886ef8a02b4a.tar.xz wireguard-openbsd-0fa58eff6f4008ab36cf4c3ddf3f886ef8a02b4a.zip |
standards compliant strxfrm. much simpler too. fixes sorting in glib2.
ok deraadt@ espie@ marcm@
Diffstat (limited to 'lib/libc/string')
-rw-r--r-- | lib/libc/string/strxfrm.c | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/lib/libc/string/strxfrm.c b/lib/libc/string/strxfrm.c index b7c8d4822d8..a2e2dbc4405 100644 --- a/lib/libc/string/strxfrm.c +++ b/lib/libc/string/strxfrm.c @@ -31,7 +31,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: strxfrm.c,v 1.4 2003/06/11 21:08:16 deraadt Exp $"; +static char *rcsid = "$OpenBSD: strxfrm.c,v 1.5 2003/09/06 22:43:12 tedu Exp $"; #endif /* LIBC_SCCS and not lint */ #include <string.h> @@ -44,23 +44,11 @@ static char *rcsid = "$OpenBSD: strxfrm.c,v 1.4 2003/06/11 21:08:16 deraadt Exp size_t strxfrm(char *dst, const char *src, size_t n) { - size_t r = 0; - int c; /* * Since locales are unimplemented, this is just a copy. */ - if (n != 0) { - while ((c = *src++) != 0) { - r++; - if (--n == 0) { - while (*src++ != 0) - r++; - break; - } - *dst++ = c; - } - *dst = 0; - } - return (r); + if (n == 0) + return (strlen(src)); + return (strlcpy(dst, src, n)); } |