48 #undef wcwidth
49
50 int
51 wcwidth(wchar_t wc)
52 {
53 unsigned int x;
54
55 if (wc == 0)
56 return (0);
57
58 x = ((wc < 0 || wc >= _CACHED_RUNES) ? ___runetype(wc) :
59 _CurrentRuneLocale->__runetype[wc]) & (_CTYPE_SWM|_CTYPE_R);
60
61 if ((x & _CTYPE_SWM) != 0)
62 return ((x & _CTYPE_SWM) >> _CTYPE_SWS);
63 return ((x & _CTYPE_R) != 0 ? 1 : -1);
64 }
65
66 #pragma weak _scrwidth = scrwidth
67
68 /*
69 * This is a Solaris extension. It never returns a negative width, even for
70 * non-printable characters. It is used internally by the printf
71 * implementation for %ws.
72 */
73 int
74 scrwidth(wchar_t wc)
75 {
76 int v = wcwidth(wc);
77 return (v > 0 ? v : 0);
78 }
|
48 #undef wcwidth
49
50 int
51 wcwidth(wchar_t wc)
52 {
53 unsigned int x;
54
55 if (wc == 0)
56 return (0);
57
58 x = ((wc < 0 || wc >= _CACHED_RUNES) ? ___runetype(wc) :
59 _CurrentRuneLocale->__runetype[wc]) & (_CTYPE_SWM|_CTYPE_R);
60
61 if ((x & _CTYPE_SWM) != 0)
62 return ((x & _CTYPE_SWM) >> _CTYPE_SWS);
63 return ((x & _CTYPE_R) != 0 ? 1 : -1);
64 }
65
66 #pragma weak _scrwidth = scrwidth
67
68 int
69 wcwidth(wchar_t wc, locale_t locale)
70 {
71 /* XXX */
72 return (0);
73 }
74
75 /*
76 * This is a Solaris extension. It never returns a negative width, even for
77 * non-printable characters. It is used internally by the printf
78 * implementation for %ws.
79 */
80 int
81 scrwidth(wchar_t wc)
82 {
83 int v = wcwidth(wc);
84 return (v > 0 ? v : 0);
85 }
|