Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use isupper+tolower instead of islower+toupper (diffutils ver2.7) #1351

Merged
merged 1 commit into from May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions Src/diffutils/src/util.c
Expand Up @@ -482,10 +482,10 @@ line_cmp (char const *s1, size_t len1, char const *s2, size_t len2)

if (ignore_case_flag)
{
if (islower (c1))
c1 = (unsigned char)toupper (c1);
if (islower (c2))
c2 = (unsigned char)toupper (c2);
if (isupper (c1))
c1 = (unsigned char)tolower (c1);
if (isupper(c2))
c2 = (unsigned char)tolower (c2);
}

if (ignore_eol_diff)
Expand Down
6 changes: 3 additions & 3 deletions Src/stringdiffs.cpp
Expand Up @@ -560,7 +560,7 @@ stringdiffs::Hash(const String & str, int begin, int end, unsigned h) const
}
else
{
ch = static_cast<unsigned>(_totupper(ch));
ch = static_cast<unsigned>(_totlower(ch));
h += HASH(h, ch);
}
}
Expand Down Expand Up @@ -609,7 +609,7 @@ stringdiffs::caseMatch(TCHAR ch1, TCHAR ch2) const
if (m_case_sensitive)
return ch1==ch2;
else
return _totupper(ch1)==_totupper(ch2);
return _totlower(ch1)==_totlower(ch2);
}

/**
Expand Down Expand Up @@ -773,7 +773,7 @@ matchchar(const TCHAR *ch1, const TCHAR *ch2, size_t len, bool casitive)
return memcmp(ch1, ch2, len * sizeof(TCHAR)) == 0;
for (size_t i = 0; i < len; ++i)
{
if (_totupper(ch1[i]) != _totupper(ch2[i]))
if (_totlower(ch1[i]) != _totlower(ch2[i]))
return false;
}
return true;
Expand Down