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-2004 Tim J. Robbins. * All rights reserved. * * Redistribution and use in source and binary forms, with or without
*** 26,39 **** */ #include "lint.h" #include <stdlib.h> #include <wchar.h> #include "mblocal.h" int ! mbtowc(wchar_t *_RESTRICT_KYWD pwc, const char *_RESTRICT_KYWD s, size_t n) { static const mbstate_t initial = { 0 }; static mbstate_t mbs; size_t rval; --- 27,43 ---- */ #include "lint.h" #include <stdlib.h> #include <wchar.h> + #include <locale.h> + #include <xlocale.h> #include "mblocal.h" int ! mbtowc_l(wchar_t *_RESTRICT_KYWD pwc, const char *_RESTRICT_KYWD s, size_t n, ! locale_t loc) { static const mbstate_t initial = { 0 }; static mbstate_t mbs; size_t rval;
*** 40,49 **** if (s == NULL) { /* No support for state dependent encodings. */ mbs = initial; return (0); } ! rval = __mbrtowc(pwc, s, n, &mbs); if (rval == (size_t)-1 || rval == (size_t)-2) return (-1); return ((int)rval); } --- 44,59 ---- if (s == NULL) { /* No support for state dependent encodings. */ mbs = initial; return (0); } ! rval = mbrtowc_l(pwc, s, n, &mbs, loc); if (rval == (size_t)-1 || rval == (size_t)-2) return (-1); return ((int)rval); + } + + int + mbtowc(wchar_t *_RESTRICT_KYWD pwc, const char *_RESTRICT_KYWD s, size_t n) + { + return (mbtowc_l(pwc, s, n, uselocale(NULL))); }