xref: /illumos-gate/usr/src/lib/libc/port/locale/wscol.c (revision 803376f0)
1*4297a3b0SGarrett D'Amore /*
2*4297a3b0SGarrett D'Amore  * Copyright 2010 Nexenta Systems, Inc.  All rights reserved.
3*4297a3b0SGarrett D'Amore  * Use is subject to license terms.
4*4297a3b0SGarrett D'Amore  *
5*4297a3b0SGarrett D'Amore  * Redistribution and use in source and binary forms, with or without
6*4297a3b0SGarrett D'Amore  * modification, are permitted provided that the following conditions
7*4297a3b0SGarrett D'Amore  * are met:
8*4297a3b0SGarrett D'Amore  * 1. Redistributions of source code must retain the above copyright
9*4297a3b0SGarrett D'Amore  *    notice, this list of conditions and the following disclaimer.
10*4297a3b0SGarrett D'Amore  * 2. Redistributions in binary form must reproduce the above copyright
11*4297a3b0SGarrett D'Amore  *    notice, this list of conditions and the following disclaimer in the
12*4297a3b0SGarrett D'Amore  *    documentation and/or other materials provided with the distribution.
13*4297a3b0SGarrett D'Amore  *
14*4297a3b0SGarrett D'Amore  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15*4297a3b0SGarrett D'Amore  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*4297a3b0SGarrett D'Amore  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*4297a3b0SGarrett D'Amore  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18*4297a3b0SGarrett D'Amore  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*4297a3b0SGarrett D'Amore  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*4297a3b0SGarrett D'Amore  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*4297a3b0SGarrett D'Amore  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*4297a3b0SGarrett D'Amore  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*4297a3b0SGarrett D'Amore  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*4297a3b0SGarrett D'Amore  * SUCH DAMAGE.
25*4297a3b0SGarrett D'Amore  */
26*4297a3b0SGarrett D'Amore 
27*4297a3b0SGarrett D'Amore #include "lint.h"
28*4297a3b0SGarrett D'Amore #include <wchar.h>
29*4297a3b0SGarrett D'Amore 
30*4297a3b0SGarrett D'Amore int
wscol(const wchar_t * s)31*4297a3b0SGarrett D'Amore wscol(const wchar_t *s)
32*4297a3b0SGarrett D'Amore {
33*4297a3b0SGarrett D'Amore 	int	l = 0;
34*4297a3b0SGarrett D'Amore 	while (*s) {
35*4297a3b0SGarrett D'Amore 		l += wcwidth(*s);
36*4297a3b0SGarrett D'Amore 		s++;
37*4297a3b0SGarrett D'Amore 	}
38*4297a3b0SGarrett D'Amore 	return (l);
39*4297a3b0SGarrett D'Amore }
40