forked from aniani/vim
patch 9.1.1184: Unnecessary use of vim_tolower() in vim_strnicmp_asc()
Problem: Unnecessary use of vim_tolower() in vim_strnicmp_asc(). Solution: Use TOLOWER_ASC() instead (zeertzjq). It was passing *s1 and *s2 to vim_tolower(). When char is signed, which is the case on most platforms, c < 0x80 is always true, so it already behaves the same as TOLOWER_ASC(). closes: #16826 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
62f19541f4
commit
b7dc5d3b61
@@ -598,12 +598,10 @@ vim_strnicmp(char *s1, char *s2, size_t len)
|
|||||||
vim_strnicmp_asc(char *s1, char *s2, size_t len)
|
vim_strnicmp_asc(char *s1, char *s2, size_t len)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int save_cmp_flags = cmp_flags;
|
|
||||||
|
|
||||||
cmp_flags |= CMP_KEEPASCII; // compare by ASCII value, ignoring locale
|
|
||||||
while (len > 0)
|
while (len > 0)
|
||||||
{
|
{
|
||||||
i = vim_tolower(*s1) - vim_tolower(*s2);
|
i = TOLOWER_ASC(*s1) - TOLOWER_ASC(*s2);
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
break; // this character is different
|
break; // this character is different
|
||||||
if (*s1 == NUL)
|
if (*s1 == NUL)
|
||||||
@@ -612,7 +610,6 @@ vim_strnicmp_asc(char *s1, char *s2, size_t len)
|
|||||||
++s2;
|
++s2;
|
||||||
--len;
|
--len;
|
||||||
}
|
}
|
||||||
cmp_flags = save_cmp_flags;
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -704,6 +704,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1184,
|
||||||
/**/
|
/**/
|
||||||
1183,
|
1183,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user