xref: /freebsd/lib/libc/locale/mblen.c (revision b85aa4e3f7564d62ec733d7f7b4c49f7984ca23e)
17438fc3aSTim J. Robbins /*-
2b85aa4e3STim J. Robbins  * Copyright (c) 2002, 2003 Tim J. Robbins.
3b85aa4e3STim J. Robbins  * All rights reserved.
47438fc3aSTim J. Robbins  *
57438fc3aSTim J. Robbins  * Redistribution and use in source and binary forms, with or without
67438fc3aSTim J. Robbins  * modification, are permitted provided that the following conditions
77438fc3aSTim J. Robbins  * are met:
87438fc3aSTim J. Robbins  * 1. Redistributions of source code must retain the above copyright
97438fc3aSTim J. Robbins  *    notice, this list of conditions and the following disclaimer.
107438fc3aSTim J. Robbins  * 2. Redistributions in binary form must reproduce the above copyright
117438fc3aSTim J. Robbins  *    notice, this list of conditions and the following disclaimer in the
127438fc3aSTim J. Robbins  *    documentation and/or other materials provided with the distribution.
137438fc3aSTim J. Robbins  *
14b85aa4e3STim J. Robbins  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
157438fc3aSTim J. Robbins  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
167438fc3aSTim J. Robbins  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17b85aa4e3STim J. Robbins  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
187438fc3aSTim J. Robbins  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
197438fc3aSTim J. Robbins  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
207438fc3aSTim J. Robbins  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
217438fc3aSTim J. Robbins  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
227438fc3aSTim J. Robbins  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
237438fc3aSTim J. Robbins  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
247438fc3aSTim J. Robbins  * SUCH DAMAGE.
257438fc3aSTim J. Robbins  */
267438fc3aSTim J. Robbins 
277438fc3aSTim J. Robbins #include <sys/cdefs.h>
287438fc3aSTim J. Robbins __FBSDID("$FreeBSD$");
297438fc3aSTim J. Robbins 
30b6f33850STim J. Robbins #include <stdlib.h>
317438fc3aSTim J. Robbins 
327438fc3aSTim J. Robbins int
33b6f33850STim J. Robbins mblen(const char *s, size_t n)
347438fc3aSTim J. Robbins {
357438fc3aSTim J. Robbins 
36b85aa4e3STim J. Robbins 	/*
37b85aa4e3STim J. Robbins 	 * Calling mbtowc() is only legal because we don't support
38b85aa4e3STim J. Robbins 	 * state-dependent encodings.
39b85aa4e3STim J. Robbins 	 */
40b85aa4e3STim J. Robbins 	return (mbtowc(NULL, s, n));
417438fc3aSTim J. Robbins }
42