1 /*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Chris Torek. 7 * 8 * %sccs.include.redist.c% 9 */ 10 11 #if defined(LIBC_SCCS) && !defined(lint) 12 static char sccsid[] = "@(#)strxfrm.c 8.1 (Berkeley) 06/04/93"; 13 #endif /* LIBC_SCCS and not lint */ 14 15 #include <sys/cdefs.h> 16 #include <string.h> 17 18 /* 19 * Transform src, storing the result in dst, such that 20 * strcmp() on transformed strings returns what strcoll() 21 * on the original untransformed strings would return. 22 */ 23 size_t 24 strxfrm(dst, src, n) 25 register char *dst; 26 const char *src; 27 size_t n; 28 { 29 register size_t srclen, copysize; 30 31 /* 32 * Since locales are unimplemented, this is just a copy. 33 */ 34 srclen = strlen(src); 35 if (n != 0) { 36 copysize = srclen < n ? srclen : n - 1; 37 (void)memcpy(dst, src, copysize); 38 dst[copysize] = 0; 39 } 40 return (srclen); 41 } 42