diff options
author | tjr <tjr@FreeBSD.org> | 2004-05-23 13:20:09 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2004-05-23 13:20:09 +0000 |
commit | ea28a65744d7be97cde494385959133c04b57090 (patch) | |
tree | 8258a3bcc03b1429f71b6976f5f3bbf75337a41d /lib/libc | |
parent | 74bd7acb1b7e48ddbab0329274e029fe76e100c8 (diff) | |
download | FreeBSD-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.c | 12 |
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); } - |