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 2010 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2002 Tim J. Robbins. * All rights reserved. * * Redistribution and use in source and binary forms, with or without
*** 24,53 **** * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include "lint.h" #include <errno.h> #include <string.h> #include <wctype.h> enum { _WCT_ERROR = 0, _WCT_TOLOWER = 1, _WCT_TOUPPER = 2 }; wint_t ! towctrans(wint_t wc, wctrans_t desc) { - switch (desc) { case _WCT_TOLOWER: ! wc = towlower(wc); break; case _WCT_TOUPPER: ! wc = towupper(wc); break; case _WCT_ERROR: default: errno = EINVAL; break; --- 25,55 ---- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include "lint.h" + #include <note.h> #include <errno.h> #include <string.h> #include <wctype.h> + #include <locale.h> enum { _WCT_ERROR = 0, _WCT_TOLOWER = 1, _WCT_TOUPPER = 2 }; wint_t ! towctrans_l(wint_t wc, wctrans_t desc, locale_t loc) { switch (desc) { case _WCT_TOLOWER: ! wc = towlower_l(wc, loc); break; case _WCT_TOUPPER: ! wc = towupper_l(wc, loc); break; case _WCT_ERROR: default: errno = EINVAL; break;
*** 54,65 **** } return (wc); } wctrans_t ! wctrans(const char *charclass) { struct { const char *name; wctrans_t trans; } ccls[] = { --- 56,77 ---- } return (wc); } + wint_t + towctrans(wint_t wc, wctrans_t desc) + { + return (towctrans_l(wc, desc, uselocale(NULL))); + } + + /* + * For *now* we don't support locale sensitive transforms besides toupper + * and tolower. + */ wctrans_t ! wctrans_l(const char *charclass, locale_t loc) { struct { const char *name; wctrans_t trans; } ccls[] = {
*** 66,79 **** --- 78,98 ---- { "tolower", _WCT_TOLOWER }, { "toupper", _WCT_TOUPPER }, { NULL, _WCT_ERROR }, /* Default */ }; int i; + _NOTE(ARGUNUSED(loc)); i = 0; while (ccls[i].name != NULL && strcmp(ccls[i].name, charclass) != 0) i++; if (ccls[i].trans == _WCT_ERROR) errno = EINVAL; return (ccls[i].trans); + } + + wctrans_t + wctrans(const char *charclass) + { + return (wctrans_l(charclass, uselocale(NULL))); }