Add wcwidth(3) and wcswidth(3).
This commit is contained in:
parent
25b4125840
commit
07fd50d5c6
|
@ -260,7 +260,9 @@ wchar/wcstoll.o \
|
||||||
wchar/wcstol.o \
|
wchar/wcstol.o \
|
||||||
wchar/wcstoull.o \
|
wchar/wcstoull.o \
|
||||||
wchar/wcstoul.o \
|
wchar/wcstoul.o \
|
||||||
|
wchar/wcswidth.o \
|
||||||
wchar/wcsxfrm.o \
|
wchar/wcsxfrm.o \
|
||||||
|
wchar/wcwidth.o \
|
||||||
wchar/wmemchr.o \
|
wchar/wmemchr.o \
|
||||||
wchar/wmemcmp.o \
|
wchar/wmemcmp.o \
|
||||||
wchar/wmemcpy.o \
|
wchar/wmemcpy.o \
|
||||||
|
|
|
@ -133,7 +133,9 @@ long long wcstoll(const wchar_t* __restrict, wchar_t** __restrict, int);
|
||||||
long wcstol(const wchar_t* __restrict, wchar_t** __restrict, int);
|
long wcstol(const wchar_t* __restrict, wchar_t** __restrict, int);
|
||||||
unsigned long long wcstoull(const wchar_t* __restrict, wchar_t** __restrict, int);
|
unsigned long long wcstoull(const wchar_t* __restrict, wchar_t** __restrict, int);
|
||||||
unsigned long wcstoul(const wchar_t* __restrict, wchar_t** __restrict, int);
|
unsigned long wcstoul(const wchar_t* __restrict, wchar_t** __restrict, int);
|
||||||
|
int wcswidth(const wchar_t*, size_t);
|
||||||
size_t wcsxfrm(wchar_t* __restrict, const wchar_t* __restrict, size_t);
|
size_t wcsxfrm(wchar_t* __restrict, const wchar_t* __restrict, size_t);
|
||||||
|
int wcwidth(wchar_t);
|
||||||
wchar_t* wmemchr(const wchar_t*, wchar_t, size_t);
|
wchar_t* wmemchr(const wchar_t*, wchar_t, size_t);
|
||||||
int wmemcmp(const wchar_t*, const wchar_t*, size_t);
|
int wmemcmp(const wchar_t*, const wchar_t*, size_t);
|
||||||
wchar_t* wmemcpy(wchar_t* __restrict, const wchar_t* __restrict, size_t);
|
wchar_t* wmemcpy(wchar_t* __restrict, const wchar_t* __restrict, size_t);
|
||||||
|
@ -158,9 +160,7 @@ int vswprintf(wchar_t* __restrict, size_t, const wchar_t* __restrict, va_list);
|
||||||
int vswscanf(const wchar_t* __restrict, const wchar_t* __restrict, va_list);
|
int vswscanf(const wchar_t* __restrict, const wchar_t* __restrict, va_list);
|
||||||
int vwprintf(const wchar_t* __restrict, va_list);
|
int vwprintf(const wchar_t* __restrict, va_list);
|
||||||
int vwscanf(const wchar_t* __restrict, va_list);
|
int vwscanf(const wchar_t* __restrict, va_list);
|
||||||
int wcswidth(const wchar_t*, size_t);
|
|
||||||
int wctob(wint_t);
|
int wctob(wint_t);
|
||||||
int wcwidth(wchar_t);
|
|
||||||
int wprintf(const wchar_t* __restrict, ...);
|
int wprintf(const wchar_t* __restrict, ...);
|
||||||
int wscanf(const wchar_t* __restrict, ...);
|
int wscanf(const wchar_t* __restrict, ...);
|
||||||
long double wcstold(const wchar_t* __restrict, wchar_t** __restrict);
|
long double wcstold(const wchar_t* __restrict, wchar_t** __restrict);
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
|
||||||
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
|
License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
wchar/wcswidth.cpp
|
||||||
|
Number of column positions of a wide-character string.
|
||||||
|
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
|
extern "C" int wcswidth(const wchar_t* wcs, size_t n)
|
||||||
|
{
|
||||||
|
int result = 0;
|
||||||
|
for ( size_t i = 0; i < n && wcs[n]; i++ )
|
||||||
|
{
|
||||||
|
int columns = wcwidth(wcs[n]);
|
||||||
|
if ( columns < 0 )
|
||||||
|
return -1;
|
||||||
|
result += columns;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
|
||||||
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
|
License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
wchar/wcwidth.cpp
|
||||||
|
Number of column positions of a wide-character code.
|
||||||
|
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include <wchar.h>
|
||||||
|
#include <wctype.h>
|
||||||
|
|
||||||
|
extern "C" int wcwidth(wchar_t wc)
|
||||||
|
{
|
||||||
|
if ( !wc )
|
||||||
|
return 0;
|
||||||
|
if ( !iswprint(wc) )
|
||||||
|
return -1;
|
||||||
|
// TODO: Implement multi-column wide characters.
|
||||||
|
return 1;
|
||||||
|
}
|
Loading…
Reference in New Issue