mbrtowc.c revision 227753
138363Swpaul/*- 238363Swpaul * Copyright (c) 2002-2004 Tim J. Robbins. 338363Swpaul * All rights reserved. 438363Swpaul * 538363Swpaul * Copyright (c) 2011 The FreeBSD Foundation 638363Swpaul * All rights reserved. 738363Swpaul * Portions of this software were developed by David Chisnall 838363Swpaul * under sponsorship from the FreeBSD Foundation. 938363Swpaul * 1038363Swpaul * Redistribution and use in source and binary forms, with or without 1138363Swpaul * modification, are permitted provided that the following conditions 1238363Swpaul * are met: 1338363Swpaul * 1. Redistributions of source code must retain the above copyright 1438363Swpaul * notice, this list of conditions and the following disclaimer. 1538363Swpaul * 2. Redistributions in binary form must reproduce the above copyright 1638363Swpaul * notice, this list of conditions and the following disclaimer in the 1738363Swpaul * documentation and/or other materials provided with the distribution. 1838363Swpaul * 1938363Swpaul * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 2038363Swpaul * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2138363Swpaul * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2238363Swpaul * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2338363Swpaul * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2438363Swpaul * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2538363Swpaul * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2638363Swpaul * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2738363Swpaul * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2838363Swpaul * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2938363Swpaul * SUCH DAMAGE. 3038363Swpaul */ 3138363Swpaul 3250477Speter#include <sys/cdefs.h> 3338363Swpaul__FBSDID("$FreeBSD: head/lib/libc/locale/mbrtowc.c 227753 2011-11-20 14:45:42Z theraven $"); 3438363Swpaul 3538363Swpaul#include <wchar.h> 3638363Swpaul#include "mblocal.h" 3738363Swpaul 3838363Swpaulsize_t 3967233Simpmbrtowc_l(wchar_t * __restrict pwc, const char * __restrict s, 4038363Swpaul size_t n, mbstate_t * __restrict ps, locale_t locale) 4138363Swpaul{ 4238363Swpaul FIX_LOCALE(locale); 4338363Swpaul if (ps == NULL) 4438363Swpaul ps = &locale->mbrtowc; 4538363Swpaul return (XLOCALE_CTYPE(locale)->__mbrtowc(pwc, s, n, ps)); 4638363Swpaul} 4738363Swpaul 4838363Swpaulsize_t 4938363Swpaulmbrtowc(wchar_t * __restrict pwc, const char * __restrict s, 5038363Swpaul size_t n, mbstate_t * __restrict ps) 5138363Swpaul{ 5238363Swpaul return mbrtowc_l(pwc, s, n, ps, __get_locale()); 5338363Swpaul} 5438363Swpaul