Print this page
2964 need POSIX 2008 locale object support
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Approved by: TBD
*** 1,6 ****
--- 1,7 ----
/*
+ * 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.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
*** 42,70 ****
#include "lint.h"
#include <wchar.h>
#include "_ctype.h"
#include "runetype.h"
#undef wcwidth
int
! wcwidth(wchar_t wc)
{
unsigned int x;
if (wc == 0)
return (0);
! x = ((wc < 0 || wc >= _CACHED_RUNES) ? ___runetype(wc) :
! _CurrentRuneLocale->__runetype[wc]) & (_CTYPE_SWM|_CTYPE_R);
if ((x & _CTYPE_SWM) != 0)
return ((x & _CTYPE_SWM) >> _CTYPE_SWS);
return ((x & _CTYPE_R) != 0 ? 1 : -1);
}
#pragma weak _scrwidth = scrwidth
/*
* This is a Solaris extension. It never returns a negative width, even for
* non-printable characters. It is used internally by the printf
--- 43,79 ----
#include "lint.h"
#include <wchar.h>
#include "_ctype.h"
#include "runetype.h"
+ #include "localeimpl.h"
#undef wcwidth
int
! 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(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
/*
* This is a Solaris extension. It never returns a negative width, even for
* non-printable characters. It is used internally by the printf