Print this page
2964 need POSIX 2008 locale object support
Reviewed by: Robert Mustacchi <rm@joyent.com>
*** 1,6 ****
--- 1,7 ----
/*
+ * Copyright 2013 Garrett D'Amore <garrett@damore.org>
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 1995 Alex Tatmanjants <alex@elvisti.kiev.ua>
* at Electronni Visti IA, Kiev, Ukraine.
* All rights reserved.
*
*** 34,56 ****
#include "collate.h"
#define WCS_XFRM_OFFSET 1
size_t
! wcsxfrm(wchar_t *_RESTRICT_KYWD dest,
! const wchar_t *_RESTRICT_KYWD src, size_t len)
{
size_t slen;
if (*src == L'\0') {
if (len != 0)
*dest = L'\0';
return (0);
}
! if ((_collate_load_error) ||
! ((slen = _collate_wxfrm(src, dest, len)) == (size_t)-1)) {
goto error;
}
/* Add null termination at the correct location. */
if (len > slen) {
--- 35,58 ----
#include "collate.h"
#define WCS_XFRM_OFFSET 1
size_t
! wcsxfrm_l(wchar_t *_RESTRICT_KYWD dest,
! const wchar_t *_RESTRICT_KYWD src, size_t len, locale_t loc)
{
size_t slen;
+ const struct lc_collate *lcc = loc->collate;
if (*src == L'\0') {
if (len != 0)
*dest = L'\0';
return (0);
}
! if ((lcc->lc_is_posix) ||
! ((slen = _collate_wxfrm(lcc, src, dest, len)) == (size_t)-1)) {
goto error;
}
/* Add null termination at the correct location. */
if (len > slen) {
*** 68,73 ****
--- 70,82 ----
else if (len != 0) {
(void) wcsncpy(dest, src, len - 1);
dest[len - 1] = L'\0';
}
return (slen);
+ }
+
+ size_t
+ wcsxfrm(wchar_t *_RESTRICT_KYWD dest,
+ const wchar_t *_RESTRICT_KYWD src, size_t len)
+ {
+ return (wcsxfrm_l(dest, src, len, uselocale(NULL)));
}