Skip to content

Commit b201339

Browse files
dlejaychrisbra
authored andcommitted
patch 9.1.1574: Dead code in mbyte.c
Problem: Dead code in mbyte.c Solution: Delete the dead wcwidth()/iswprint() code (Damien Lejay) These library calls have been disabled since patch 6.2.446 (2002) due to display issues with Hebrew. They are also non-portable: wcwidth() is a POSIX function and not available on MSVC or other non-POSIX platforms. Keeping this code path adds complexity without benefit. closes: #17811 Signed-off-by: Damien Lejay <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 1f6faff commit b201339

2 files changed

Lines changed: 3 additions & 35 deletions

File tree

src/mbyte.c

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,6 @@
120120
# include <wchar.h>
121121
#endif
122122

123-
#if 0
124-
// This has been disabled, because several people reported problems with the
125-
// wcwidth() and iswprint() library functions, esp. for Hebrew.
126-
# ifdef __STDC_ISO_10646__
127-
# define USE_WCHAR_FUNCTIONS
128-
# endif
129-
#endif
130-
131123
static int dbcs_char2len(int c);
132124
static int dbcs_char2bytes(int c, char_u *buf);
133125
static int dbcs_ptr2len(char_u *p);
@@ -1593,11 +1585,7 @@ utf_char2cells(int c)
15931585
#ifdef FEAT_EVAL
15941586
// Use the value from setcellwidths() at 0x80 and higher, unless the
15951587
// character is not printable.
1596-
if (c >= 0x80 &&
1597-
# ifdef USE_WCHAR_FUNCTIONS
1598-
wcwidth(c) >= 1 &&
1599-
# endif
1600-
vim_isprintc(c))
1588+
if (c >= 0x80 && vim_isprintc(c))
16011589
{
16021590
int n = cw_value(c);
16031591
if (n != 0)
@@ -1607,25 +1595,10 @@ utf_char2cells(int c)
16071595

16081596
if (c >= 0x100)
16091597
{
1610-
#ifdef USE_WCHAR_FUNCTIONS
1611-
int n;
1612-
1613-
/*
1614-
* Assume the library function wcwidth() works better than our own
1615-
* stuff. It should return 1 for ambiguous width chars!
1616-
*/
1617-
n = wcwidth(c);
1618-
1619-
if (n < 0)
1620-
return 6; // unprintable, displays <xxxx>
1621-
if (n > 1)
1622-
return n;
1623-
#else
16241598
if (!utf_printable(c))
16251599
return 6; // unprintable, displays <xxxx>
16261600
if (intable(doublewidth, sizeof(doublewidth), c))
16271601
return 2;
1628-
#endif
16291602
if (p_emoji && intable(emoji_wide, sizeof(emoji_wide), c))
16301603
return 2;
16311604
}
@@ -2712,12 +2685,6 @@ utf_iscomposing(int c)
27122685
int
27132686
utf_printable(int c)
27142687
{
2715-
#ifdef USE_WCHAR_FUNCTIONS
2716-
/*
2717-
* Assume the iswprint() library function works better than our own stuff.
2718-
*/
2719-
return iswprint(c);
2720-
#else
27212688
// Sorted list of non-overlapping intervals.
27222689
// 0xd800-0xdfff is reserved for UTF-16, actually illegal.
27232690
static struct interval nonprint[] =
@@ -2728,7 +2695,6 @@ utf_printable(int c)
27282695
};
27292696

27302697
return !intable(nonprint, sizeof(nonprint), c);
2731-
#endif
27322698
}
27332699

27342700
// Sorted list of non-overlapping intervals of all Emoji characters,

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,8 @@ static char *(features[]) =
719719

720720
static int included_patches[] =
721721
{ /* Add new patch number below this line */
722+
/**/
723+
1574,
722724
/**/
723725
1573,
724726
/**/

0 commit comments

Comments
 (0)