summaryrefslogtreecommitdiff
path: root/usr/src/lib/libc/port/locale/wcwidth.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2014-05-18 20:08:38 -0700
committerGarrett D'Amore <garrett@damore.org>2014-07-11 20:35:28 -0700
commit2d08521bd15501c8370ba2153b9cca4f094979d0 (patch)
treecd843bc37fe795bc7bbdd04b5b13b0310a2d6be1 /usr/src/lib/libc/port/locale/wcwidth.c
parent961519c5bffd5ec670890fc3596d6c4ff1cefea0 (diff)
downloadillumos-gate-2d08521bd15501c8370ba2153b9cca4f094979d0.tar.gz
2964 need POSIX 2008 locale object support
Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: Gordon Ross <gordon.ross@nexenta.com> Approved by: Dan McDonald <danmcd@omniti.com>
Diffstat (limited to 'usr/src/lib/libc/port/locale/wcwidth.c')
-rw-r--r--usr/src/lib/libc/port/locale/wcwidth.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/usr/src/lib/libc/port/locale/wcwidth.c b/usr/src/lib/libc/port/locale/wcwidth.c
index a6ff73b357..5151f84951 100644
--- a/usr/src/lib/libc/port/locale/wcwidth.c
+++ b/usr/src/lib/libc/port/locale/wcwidth.c
@@ -1,4 +1,5 @@
/*
+ * Copyright 2013 Garrett D'Amore <garrett@damore.org>
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
@@ -44,25 +45,33 @@
#include <wchar.h>
#include "_ctype.h"
#include "runetype.h"
+#include "localeimpl.h"
#undef wcwidth
int
-wcwidth(wchar_t wc)
+wcwidth_l(wchar_t wc, locale_t loc)
{
unsigned int x;
+ const _RuneLocale *rl = loc->runelocale;
if (wc == 0)
return (0);
- x = ((wc < 0 || wc >= _CACHED_RUNES) ? ___runetype(wc) :
- _CurrentRuneLocale->__runetype[wc]) & (_CTYPE_SWM|_CTYPE_R);
+ x = ((wc < 0 || wc >= _CACHED_RUNES) ? __runetype(rl, wc) :
+ rl->__runetype[wc]) & (_CTYPE_SWM|_CTYPE_R);
if ((x & _CTYPE_SWM) != 0)
return ((x & _CTYPE_SWM) >> _CTYPE_SWS);
return ((x & _CTYPE_R) != 0 ? 1 : -1);
}
+int
+wcwidth(wchar_t wc)
+{
+ return (wcwidth_l(wc, uselocale(NULL)));
+}
+
#pragma weak _scrwidth = scrwidth
/*