xref: /haiku/src/system/libroot/posix/wchar/wcsxfrm.cpp (revision cbe0a0c436162d78cc3f92a305b64918c839d079)
1 /*
2  * Copyright 2011, Oliver Tappe, zooey@hirschkaefer.de.
3  * All rights reserved. Distributed under the terms of the MIT license.
4  */
5 
6 #include <errno.h>
7 
8 #include <errno_private.h>
9 #include <LocaleBackend.h>
10 #include <wchar_private.h>
11 
12 
13 using BPrivate::Libroot::gLocaleBackend;
14 
15 
16 extern "C" size_t
17 __wcsxfrm(wchar_t* dest, const wchar_t* src, size_t destSize)
18 {
19 	if (gLocaleBackend != NULL) {
20 		size_t outSize = 0;
21 		status_t status = gLocaleBackend->Wcsxfrm(dest, src, destSize, outSize);
22 
23 		if (status != B_OK)
24 			__set_errno(EINVAL);
25 
26 		return outSize;
27 	}
28 
29 	return wcslcpy(dest, src, destSize);
30 }
31 
32 
33 B_DEFINE_WEAK_ALIAS(__wcsxfrm, wcsxfrm);
34