summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortedu <>2003-09-06 22:43:12 +0000
committertedu <>2003-09-06 22:43:12 +0000
commit6fc3be9c670852e899a4e265db78f218c4150b50 (patch)
tree600695669c60d0e196d7171b5f788188b284c4d5
parent0d17c6a7f6bb982804d629d297cde2df23ff111b (diff)
downloadopenbsd-6fc3be9c670852e899a4e265db78f218c4150b50.tar.gz
openbsd-6fc3be9c670852e899a4e265db78f218c4150b50.tar.bz2
openbsd-6fc3be9c670852e899a4e265db78f218c4150b50.zip
standards compliant strxfrm. much simpler too. fixes sorting in glib2.
ok deraadt@ espie@ marcm@
-rw-r--r--src/lib/libc/string/strxfrm.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/src/lib/libc/string/strxfrm.c b/src/lib/libc/string/strxfrm.c
index b7c8d4822d..a2e2dbc440 100644
--- a/src/lib/libc/string/strxfrm.c
+++ b/src/lib/libc/string/strxfrm.c
@@ -31,7 +31,7 @@
31 */ 31 */
32 32
33#if defined(LIBC_SCCS) && !defined(lint) 33#if defined(LIBC_SCCS) && !defined(lint)
34static char *rcsid = "$OpenBSD: strxfrm.c,v 1.4 2003/06/11 21:08:16 deraadt Exp $"; 34static char *rcsid = "$OpenBSD: strxfrm.c,v 1.5 2003/09/06 22:43:12 tedu Exp $";
35#endif /* LIBC_SCCS and not lint */ 35#endif /* LIBC_SCCS and not lint */
36 36
37#include <string.h> 37#include <string.h>
@@ -44,23 +44,11 @@ static char *rcsid = "$OpenBSD: strxfrm.c,v 1.4 2003/06/11 21:08:16 deraadt Exp
44size_t 44size_t
45strxfrm(char *dst, const char *src, size_t n) 45strxfrm(char *dst, const char *src, size_t n)
46{ 46{
47 size_t r = 0;
48 int c;
49 47
50 /* 48 /*
51 * Since locales are unimplemented, this is just a copy. 49 * Since locales are unimplemented, this is just a copy.
52 */ 50 */
53 if (n != 0) { 51 if (n == 0)
54 while ((c = *src++) != 0) { 52 return (strlen(src));
55 r++; 53 return (strlcpy(dst, src, n));
56 if (--n == 0) {
57 while (*src++ != 0)
58 r++;
59 break;
60 }
61 *dst++ = c;
62 }
63 *dst = 0;
64 }
65 return (r);
66} 54}