mbrtowc.c revision 129153
1254721Semaste/*-
2254721Semaste * Copyright (c) 2002-2004 Tim J. Robbins.
3254721Semaste * All rights reserved.
4254721Semaste *
5254721Semaste * Redistribution and use in source and binary forms, with or without
6254721Semaste * modification, are permitted provided that the following conditions
7254721Semaste * are met:
8254721Semaste * 1. Redistributions of source code must retain the above copyright
9254721Semaste *    notice, this list of conditions and the following disclaimer.
10296417Sdim * 2. Redistributions in binary form must reproduce the above copyright
11296417Sdim *    notice, this list of conditions and the following disclaimer in the
12296417Sdim *    documentation and/or other materials provided with the distribution.
13296417Sdim *
14314564Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15321369Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16254721Semaste * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17254721Semaste * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18254721Semaste * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19296417Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20254721Semaste * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21254721Semaste * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22254721Semaste * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23254721Semaste * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24254721Semaste * SUCH DAMAGE.
25254721Semaste */
26254721Semaste
27254721Semaste#include <sys/cdefs.h>
28254721Semaste__FBSDID("$FreeBSD: head/lib/libc/locale/mbrtowc.c 129153 2004-05-12 14:09:04Z tjr $");
29321369Sdim
30254721Semaste#include <wchar.h>
31254721Semaste#include "mblocal.h"
32254721Semaste
33314564Sdimsize_t
34314564Sdimmbrtowc(wchar_t * __restrict pwc, const char * __restrict s,
35314564Sdim    size_t n, mbstate_t * __restrict ps)
36309124Sdim{
37314564Sdim	static mbstate_t mbs;
38309124Sdim
39314564Sdim	if (ps == NULL)
40314564Sdim		ps = &mbs;
41309124Sdim	return (__mbrtowc(pwc, s, n, ps));
42314564Sdim}
43314564Sdim