xref: /freebsd/lib/libc/locale/wcwidth.c (revision 559a218c9b257775fb249b67945fe4a05b7a6b9f)
18a16b7a1SPedro F. Giffuni /*-
28a16b7a1SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
38a16b7a1SPedro F. Giffuni  *
4d8d0cebeSAndrey A. Chernov  * Copyright (c) 1989, 1993
5d8d0cebeSAndrey A. Chernov  *	The Regents of the University of California.  All rights reserved.
6d8d0cebeSAndrey A. Chernov  * (c) UNIX System Laboratories, Inc.
7d8d0cebeSAndrey A. Chernov  * All or some portions of this file are derived from material licensed
8d8d0cebeSAndrey A. Chernov  * to the University of California by American Telephone and Telegraph
9d8d0cebeSAndrey A. Chernov  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10d8d0cebeSAndrey A. Chernov  * the permission of UNIX System Laboratories, Inc.
11d8d0cebeSAndrey A. Chernov  *
12d8d0cebeSAndrey A. Chernov  * This code is derived from software contributed to Berkeley by
13d8d0cebeSAndrey A. Chernov  * Paul Borman at Krystal Technologies.
14d8d0cebeSAndrey A. Chernov  *
153c87aa1dSDavid Chisnall  * Copyright (c) 2011 The FreeBSD Foundation
16*5b5fa75aSEd Maste  *
173c87aa1dSDavid Chisnall  * Portions of this software were developed by David Chisnall
183c87aa1dSDavid Chisnall  * under sponsorship from the FreeBSD Foundation.
193c87aa1dSDavid Chisnall  *
20d8d0cebeSAndrey A. Chernov  * Redistribution and use in source and binary forms, with or without
21d8d0cebeSAndrey A. Chernov  * modification, are permitted provided that the following conditions
22d8d0cebeSAndrey A. Chernov  * are met:
23d8d0cebeSAndrey A. Chernov  * 1. Redistributions of source code must retain the above copyright
24d8d0cebeSAndrey A. Chernov  *    notice, this list of conditions and the following disclaimer.
25d8d0cebeSAndrey A. Chernov  * 2. Redistributions in binary form must reproduce the above copyright
26d8d0cebeSAndrey A. Chernov  *    notice, this list of conditions and the following disclaimer in the
27d8d0cebeSAndrey A. Chernov  *    documentation and/or other materials provided with the distribution.
28fbbd9655SWarner Losh  * 3. Neither the name of the University nor the names of its contributors
29d8d0cebeSAndrey A. Chernov  *    may be used to endorse or promote products derived from this software
30d8d0cebeSAndrey A. Chernov  *    without specific prior written permission.
31d8d0cebeSAndrey A. Chernov  *
32d8d0cebeSAndrey A. Chernov  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
33d8d0cebeSAndrey A. Chernov  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34d8d0cebeSAndrey A. Chernov  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35d8d0cebeSAndrey A. Chernov  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
36d8d0cebeSAndrey A. Chernov  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37d8d0cebeSAndrey A. Chernov  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38d8d0cebeSAndrey A. Chernov  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39d8d0cebeSAndrey A. Chernov  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40d8d0cebeSAndrey A. Chernov  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
41d8d0cebeSAndrey A. Chernov  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42d8d0cebeSAndrey A. Chernov  * SUCH DAMAGE.
43d8d0cebeSAndrey A. Chernov  */
44d8d0cebeSAndrey A. Chernov 
45d8d0cebeSAndrey A. Chernov #include <wchar.h>
463c87aa1dSDavid Chisnall #include <wctype.h>
473c87aa1dSDavid Chisnall #include <xlocale.h>
48d8d0cebeSAndrey A. Chernov 
49de6c9c9dSTim J. Robbins #undef wcwidth
509424df44SAndrey A. Chernov 
51d8d0cebeSAndrey A. Chernov int
wcwidth(wchar_t wc)521da6b56aSAndrey A. Chernov wcwidth(wchar_t wc)
53d8d0cebeSAndrey A. Chernov {
54de6c9c9dSTim J. Robbins 	return (__wcwidth(wc));
55d8d0cebeSAndrey A. Chernov }
563c87aa1dSDavid Chisnall int
wcwidth_l(wchar_t wc,locale_t locale)573c87aa1dSDavid Chisnall wcwidth_l(wchar_t wc, locale_t locale)
583c87aa1dSDavid Chisnall {
593c87aa1dSDavid Chisnall 	return (__wcwidth_l(wc, locale));
603c87aa1dSDavid Chisnall }
61