mirror of
https://github.com/tmux/tmux.git
synced 2025-09-04 23:56:58 +00:00
Restore utf8proc code.
This commit is contained in:
1
tmux.h
1
tmux.h
@ -3343,6 +3343,7 @@ int utf8_cstrhas(const char *, const struct utf8_data *);
|
|||||||
char *osdep_get_name(int, char *);
|
char *osdep_get_name(int, char *);
|
||||||
char *osdep_get_cwd(int);
|
char *osdep_get_cwd(int);
|
||||||
struct event_base *osdep_event_init(void);
|
struct event_base *osdep_event_init(void);
|
||||||
|
|
||||||
/* utf8-combined.c */
|
/* utf8-combined.c */
|
||||||
int utf8_has_zwj(const struct utf8_data *);
|
int utf8_has_zwj(const struct utf8_data *);
|
||||||
int utf8_is_zwj(const struct utf8_data *);
|
int utf8_is_zwj(const struct utf8_data *);
|
||||||
|
9
utf8.c
9
utf8.c
@ -409,6 +409,10 @@ utf8_width(struct utf8_data *ud, int *width)
|
|||||||
*width = 2;
|
*width = 2;
|
||||||
return (UTF8_DONE);
|
return (UTF8_DONE);
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_UTF8PROC
|
||||||
|
*width = utf8proc_wcwidth(wc);
|
||||||
|
log_debug("utf8proc_wcwidth(%05X) returned %d", (u_int)wc, *width);
|
||||||
|
#else
|
||||||
*width = wcwidth(wc);
|
*width = wcwidth(wc);
|
||||||
log_debug("wcwidth(%05X) returned %d", (u_int)wc, *width);
|
log_debug("wcwidth(%05X) returned %d", (u_int)wc, *width);
|
||||||
if (*width < 0) {
|
if (*width < 0) {
|
||||||
@ -418,6 +422,7 @@ utf8_width(struct utf8_data *ud, int *width)
|
|||||||
*/
|
*/
|
||||||
*width = (wc >= 0x80 && wc <= 0x9f) ? 0 : 1;
|
*width = (wc >= 0x80 && wc <= 0x9f) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (*width >= 0 && *width <= 0xff)
|
if (*width >= 0 && *width <= 0xff)
|
||||||
return (UTF8_DONE);
|
return (UTF8_DONE);
|
||||||
return (UTF8_ERROR);
|
return (UTF8_ERROR);
|
||||||
@ -427,7 +432,11 @@ utf8_width(struct utf8_data *ud, int *width)
|
|||||||
enum utf8_state
|
enum utf8_state
|
||||||
utf8_towc(const struct utf8_data *ud, wchar_t *wc)
|
utf8_towc(const struct utf8_data *ud, wchar_t *wc)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_UTF8PROC
|
||||||
|
switch (utf8proc_mbtowc(wc, ud->data, ud->size)) {
|
||||||
|
#else
|
||||||
switch (mbtowc(wc, ud->data, ud->size)) {
|
switch (mbtowc(wc, ud->data, ud->size)) {
|
||||||
|
#endif
|
||||||
case -1:
|
case -1:
|
||||||
log_debug("UTF-8 %.*s, mbtowc() %d", (int)ud->size, ud->data,
|
log_debug("UTF-8 %.*s, mbtowc() %d", (int)ud->size, ud->data,
|
||||||
errno);
|
errno);
|
||||||
|
Reference in New Issue
Block a user