Print this page
2964 need POSIX 2008 locale object support
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Approved by: TBD

*** 1,6 **** --- 1,7 ---- /* + * Copyright 2014 Garrett D'Amore <garrett@damore.org> * Copyright 2010 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2002-2004 Tim J. Robbins. * All rights reserved. * * Redistribution and use in source and binary forms, with or without
*** 26,48 **** */ #include "lint.h" #include <stdlib.h> #include <wchar.h> #include "mblocal.h" int ! wctomb(char *s, wchar_t wchar) { ! static const mbstate_t initial = { 0 }; ! static mbstate_t mbs; size_t rval; if (s == NULL) { /* No support for state dependent encodings. */ - mbs = initial; return (0); } ! if ((rval = __wcrtomb(s, wchar, &mbs)) == (size_t)-1) return (-1); return ((int)rval); } --- 27,55 ---- */ #include "lint.h" #include <stdlib.h> #include <wchar.h> + #include <locale.h> + #include <xlocale.h> #include "mblocal.h" int ! wctomb_l(char *s, wchar_t wchar, locale_t loc) { ! mbstate_t mbs = { 0 }; size_t rval; if (s == NULL) { /* No support for state dependent encodings. */ return (0); } ! if ((rval = wcrtomb_l(s, wchar, &mbs, loc)) == (size_t)-1) return (-1); return ((int)rval); + } + + int + wctomb(char *s, wchar_t wchar) + { + return (wctomb_l(s, wchar, uselocale(NULL))); }