142172Sbostic /*-
2*61193Sbostic * Copyright (c) 1990, 1993
3*61193Sbostic * The Regents of the University of California. 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*61193Sbostic static char sccsid[] = "@(#)strxfrm.c 8.1 (Berkeley) 06/04/93";
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
strxfrm(dst,src,n)2442172Sbostic strxfrm(dst, src, n)
2542172Sbostic register char *dst;
2656418Sbostic const char *src;
2756418Sbostic size_t n;
2842172Sbostic {
2956418Sbostic register size_t srclen, copysize;
3042172Sbostic
3142172Sbostic /*
3242172Sbostic * Since locales are unimplemented, this is just a copy.
3342172Sbostic */
3456418Sbostic srclen = strlen(src);
3542172Sbostic if (n != 0) {
3656418Sbostic copysize = srclen < n ? srclen : n - 1;
3756418Sbostic (void)memcpy(dst, src, copysize);
3856418Sbostic dst[copysize] = 0;
3942172Sbostic }
4056418Sbostic return (srclen);
4142172Sbostic }
42