summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2004-05-23 13:20:09 +0000
committertjr <tjr@FreeBSD.org>2004-05-23 13:20:09 +0000
commitea28a65744d7be97cde494385959133c04b57090 (patch)
tree8258a3bcc03b1429f71b6976f5f3bbf75337a41d /lib/libc
parent74bd7acb1b7e48ddbab0329274e029fe76e100c8 (diff)
downloadFreeBSD-src-ea28a65744d7be97cde494385959133c04b57090.zip
FreeBSD-src-ea28a65744d7be97cde494385959133c04b57090.tar.gz
Grab all the information we need about a character with one call to
__maskrune() instead of one direct call and one through iswprint().
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/locale/wcwidth.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/libc/locale/wcwidth.c b/lib/libc/locale/wcwidth.c
index bc852bc..9706430 100644
--- a/lib/libc/locale/wcwidth.c
+++ b/lib/libc/locale/wcwidth.c
@@ -51,15 +51,13 @@ __FBSDID("$FreeBSD$");
int
wcwidth(wchar_t wc)
{
- int width;
+ unsigned int x;
if (wc == L'\0')
return (0);
- width = __maskrune(wc, _CTYPE_SWM);
-
- /* 0 is autowidth (default) */
- return (width ? (int)((unsigned)width >> _CTYPE_SWS)
- : (iswprint(wc) ? 1 : -1));
+ x = (unsigned int)__maskrune(wc, _CTYPE_SWM|_CTYPE_R);
+ if ((x & _CTYPE_SWM) != 0)
+ return ((x & _CTYPE_SWM) >> _CTYPE_SWS);
+ return ((x & _CTYPE_R) != 0 ? 1 : -1);
}
-
OpenPOWER on IntegriCloud