refactor: remove unused USE_WCHAR_FUNCTIONS #18618

USE_WCHAR_FUNCTIONS is never defined and we don't trust libc wchar
functions anyway.
This commit is contained in:
Lewis Russell 2022-05-21 04:31:32 +01:00 committed by GitHub
parent afa99f42b3
commit 4c97e17d38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -473,27 +473,12 @@ static bool intable(const struct interval *table, size_t n_items, int c)
int utf_char2cells(int c) int utf_char2cells(int c)
{ {
if (c >= 0x100) { if (c >= 0x100) {
#ifdef USE_WCHAR_FUNCTIONS
//
// Assume the library function wcwidth() works better than our own
// stuff. It should return 1 for ambiguous width chars!
//
int n = wcwidth(c);
if (n < 0) {
return 6; // unprintable, displays <xxxx>
}
if (n > 1) {
return n;
}
#else
if (!utf_printable(c)) { if (!utf_printable(c)) {
return 6; // unprintable, displays <xxxx> return 6; // unprintable, displays <xxxx>
} }
if (intable(doublewidth, ARRAY_SIZE(doublewidth), c)) { if (intable(doublewidth, ARRAY_SIZE(doublewidth), c)) {
return 2; return 2;
} }
#endif
if (p_emoji && intable(emoji_width, ARRAY_SIZE(emoji_width), c)) { if (p_emoji && intable(emoji_width, ARRAY_SIZE(emoji_width), c)) {
return 2; return 2;
} }
@ -1061,12 +1046,6 @@ bool utf_iscomposing(int c)
*/ */
bool utf_printable(int c) bool utf_printable(int c)
{ {
#ifdef USE_WCHAR_FUNCTIONS
/*
* Assume the iswprint() library function works better than our own stuff.
*/
return iswprint(c);
#else
// Sorted list of non-overlapping intervals. // Sorted list of non-overlapping intervals.
// 0xd800-0xdfff is reserved for UTF-16, actually illegal. // 0xd800-0xdfff is reserved for UTF-16, actually illegal.
static struct interval nonprint[] = static struct interval nonprint[] =
@ -1077,7 +1056,6 @@ bool utf_printable(int c)
}; };
return !intable(nonprint, ARRAY_SIZE(nonprint), c); return !intable(nonprint, ARRAY_SIZE(nonprint), c);
#endif
} }
/* /*