142172Sbostic /*- 242172Sbostic * Copyright (c) 1990 The Regents of the University of California. 342172Sbostic * All rights reserved. 442172Sbostic * 542172Sbostic * This code is derived from software contributed to Berkeley by 642172Sbostic * Chris Torek. 742172Sbostic * 842172Sbostic * %sccs.include.redist.c% 942172Sbostic */ 1042172Sbostic 1142172Sbostic #if defined(LIBC_SCCS) && !defined(lint) 12*56418Sbostic static char sccsid[] = "@(#)strxfrm.c 5.3 (Berkeley) 10/04/92"; 1342172Sbostic #endif /* LIBC_SCCS and not lint */ 1442172Sbostic 1546144Sbostic #include <sys/cdefs.h> 1642172Sbostic #include <string.h> 1742172Sbostic 1842172Sbostic /* 1942172Sbostic * Transform src, storing the result in dst, such that 2042172Sbostic * strcmp() on transformed strings returns what strcoll() 2142172Sbostic * on the original untransformed strings would return. 2242172Sbostic */ 2342172Sbostic size_t 2442172Sbostic strxfrm(dst, src, n) 2542172Sbostic register char *dst; 26*56418Sbostic const char *src; 27*56418Sbostic size_t n; 2842172Sbostic { 29*56418Sbostic register size_t srclen, copysize; 3042172Sbostic 3142172Sbostic /* 3242172Sbostic * Since locales are unimplemented, this is just a copy. 3342172Sbostic */ 34*56418Sbostic srclen = strlen(src); 3542172Sbostic if (n != 0) { 36*56418Sbostic copysize = srclen < n ? srclen : n - 1; 37*56418Sbostic (void)memcpy(dst, src, copysize); 38*56418Sbostic dst[copysize] = 0; 3942172Sbostic } 40*56418Sbostic return (srclen); 4142172Sbostic } 42