mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
Use wcwidth if available and applicable.
(If wchar_t is not Unicode, then it is not applicable.)
This commit is contained in:
parent
4a5af7fd26
commit
86ed79deaf
@ -168,7 +168,7 @@ AC_HEADER_STDC
|
|||||||
AC_HEADER_SYS_WAIT
|
AC_HEADER_SYS_WAIT
|
||||||
AC_HEADER_TIME
|
AC_HEADER_TIME
|
||||||
|
|
||||||
AC_CHECK_HEADERS(wctype.h)
|
AC_CHECK_HEADERS(wctype.h wchar.h)
|
||||||
AC_CHECK_HEADERS(fcntl.h limits.h time.h unistd.h)
|
AC_CHECK_HEADERS(fcntl.h limits.h time.h unistd.h)
|
||||||
AC_CHECK_HEADERS(sigaction.h)
|
AC_CHECK_HEADERS(sigaction.h)
|
||||||
AC_CHECK_HEADERS(arpa/inet.h)
|
AC_CHECK_HEADERS(arpa/inet.h)
|
||||||
@ -279,7 +279,7 @@ AC_FUNC_MMAP
|
|||||||
AC_FUNC_STRFTIME
|
AC_FUNC_STRFTIME
|
||||||
AC_CHECK_FUNCS(cfmakeraw gethostbyaddr herror strerror)
|
AC_CHECK_FUNCS(cfmakeraw gethostbyaddr herror strerror)
|
||||||
AC_CHECK_FUNCS(popen uname access chmod alarm timegm mremap)
|
AC_CHECK_FUNCS(popen uname access chmod alarm timegm mremap)
|
||||||
AC_CHECK_FUNCS(strcasecmp strncasecmp strcasestr strstr strchr strrchr)
|
AC_CHECK_FUNCS(strcasecmp strncasecmp strcasestr strstr strchr strrchr wcwidth)
|
||||||
AC_CHECK_FUNCS(memmove bcopy stpcpy strdup index isdigit mempcpy memrchr)
|
AC_CHECK_FUNCS(memmove bcopy stpcpy strdup index isdigit mempcpy memrchr)
|
||||||
AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
|
AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
|
||||||
AC_CHECK_FUNCS(getifaddrs getpwnam inet_pton inet_ntop)
|
AC_CHECK_FUNCS(getifaddrs getpwnam inet_pton inet_ntop)
|
||||||
|
@ -10,6 +10,9 @@
|
|||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#if HAVE_WCHAR_H
|
||||||
|
#include <wchar.h>
|
||||||
|
#endif
|
||||||
#if HAVE_WCTYPE_H
|
#if HAVE_WCTYPE_H
|
||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
#endif
|
#endif
|
||||||
@ -547,7 +550,6 @@ invalid_arg:
|
|||||||
/*
|
/*
|
||||||
* Find out number of standard terminal collumns needed for displaying symbol
|
* Find out number of standard terminal collumns needed for displaying symbol
|
||||||
* (glyph) which represents Unicode character c.
|
* (glyph) which represents Unicode character c.
|
||||||
* TODO: Use wcwidth when it is available.
|
|
||||||
*
|
*
|
||||||
* @return 2 for double-width glyph, 1 for others.
|
* @return 2 for double-width glyph, 1 for others.
|
||||||
* TODO: May be extended to return 0 for zero-width glyphs
|
* TODO: May be extended to return 0 for zero-width glyphs
|
||||||
@ -556,6 +558,10 @@ invalid_arg:
|
|||||||
inline int
|
inline int
|
||||||
unicode_to_cell(unicode_val_T c)
|
unicode_to_cell(unicode_val_T c)
|
||||||
{
|
{
|
||||||
|
#if __STDC_ISO_10646__ && HAVE_WCWIDTH
|
||||||
|
if (wcwidth(c) >= 2)
|
||||||
|
return 2;
|
||||||
|
#else /* !__STDC_ISO_10646 || !HAVE_WCWIDTH */
|
||||||
if (c >= 0x1100
|
if (c >= 0x1100
|
||||||
&& (c <= 0x115f /* Hangul Jamo */
|
&& (c <= 0x115f /* Hangul Jamo */
|
||||||
|| c == 0x2329
|
|| c == 0x2329
|
||||||
@ -571,6 +577,7 @@ unicode_to_cell(unicode_val_T c)
|
|||||||
|| (c >= 0x20000 && c <= 0x2fffd)
|
|| (c >= 0x20000 && c <= 0x2fffd)
|
||||||
|| (c >= 0x30000 && c <= 0x3fffd)))
|
|| (c >= 0x30000 && c <= 0x3fffd)))
|
||||||
return 2;
|
return 2;
|
||||||
|
#endif /* !__STDC_ISO_10646 || !HAVE_WCWIDTH */
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user