fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libc / string / wcwidth.c
blob2cbd59e18325f7c2c058b7d246bc6fe6bbd7d07c
1 /*
2 FUNCTION
3 <<wcwidth>>---number of column positions of a wide-character code
5 INDEX
6 wcwidth
8 ANSI_SYNOPSIS
9 #include <wchar.h>
10 int wcwidth(const wchar_t <[wc]>);
12 TRAD_SYNOPSIS
13 #include <wchar.h>
14 int wcwidth(<[wc]>)
15 wchar_t *<[wc]>;
17 DESCRIPTION
18 The <<wcwidth>> function shall determine the number of column
19 positions required for the wide character wc. The application
20 shall ensure that the value of wc is a character representable
21 as a wchar_t, and is a wide-character code corresponding to a
22 valid character in the current locale.
24 RETURNS
25 The <<wcwidth>> function shall either return 0 (if wc is a null
26 wide-character code), or return the number of column positions to
27 be occupied by the wide-character code wc, or return -1 (if wc
28 does not correspond to a printable wide-character code).
30 The current implementation of <<wcwidth>> simply sets the width
31 of all printable characters to 1 since newlib has no character
32 tables around.
34 PORTABILITY
35 <<wcwidth>> has been introduced in the Single UNIX Specification Volume 2
36 <<wcwidth>> has been marked as extension in Single UNIX Specification Volume 3
39 #include <_ansi.h>
40 #include <wchar.h>
41 #include <wctype.h>
43 int
44 _DEFUN (wcwidth, (wc),
45 _CONST wchar_t wc)
48 if (iswprint (wc))
49 return 1;
50 if (iswcntrl (wc) || wc == L'\0')
51 return 0;
52 return -1;