summaryrefslogtreecommitdiff
path: root/src/locale/wcsxfrm.c
blob: 5d89e7dd522747d0167ca7e4e4e78b46ab6966cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <wchar.h>
#include <locale.h>
#include "libc.h"

/* collate only by code points */
size_t __wcsxfrm_l(wchar_t *restrict dest, const wchar_t *restrict src, size_t n, locale_t loc)
{
	size_t l = wcslen(src);
	if (l < n) {
		wmemcpy(dest, src, l+1);
	} else if (n) {
		wmemcpy(dest, src, n-1);
		dest[n-1] = 0;
	}
	return l;
}

size_t wcsxfrm(wchar_t *restrict dest, const wchar_t *restrict src, size_t n)
{
	return __wcsxfrm_l(dest, src, n, 0);
}

weak_alias(__wcsxfrm_l, wcsxfrm_l);