Skip to content

Commit 3317d5e

Browse files
committed
patch 8.0.0552: toupper and tolower don't work properly for Turkish
Problem: Toupper and tolower don't work properly for Turkish when 'casemap' is empty. (Bjorn Linse) Solution: Check the 'casemap' options when deciding how to upper/lower case.
1 parent d34f9b1 commit 3317d5e

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

src/charset.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ vim_isfilec_or_wc(int c)
960960
}
961961

962962
/*
963-
* return TRUE if 'c' is a printable character
963+
* Return TRUE if 'c' is a printable character.
964964
* Assume characters above 0x100 are printable (multi-byte), except for
965965
* Unicode.
966966
*/
@@ -1717,7 +1717,7 @@ vim_toupper(int c)
17171717
{
17181718
if (c <= '@')
17191719
return c;
1720-
if (c >= 0x80)
1720+
if (c >= 0x80 || !(cmp_flags & CMP_KEEPASCII))
17211721
{
17221722
if (enc_utf8)
17231723
return utf_toupper(c);
@@ -1741,7 +1741,7 @@ vim_tolower(int c)
17411741
{
17421742
if (c <= '@')
17431743
return c;
1744-
if (c >= 0x80)
1744+
if (c >= 0x80 || !(cmp_flags & CMP_KEEPASCII))
17451745
{
17461746
if (enc_utf8)
17471747
return utf_tolower(c);

src/testdir/test_normal.vim

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,26 @@ fun! Test_normal30_changecase()
16031603
norm! V~
16041604
call assert_equal('THIS IS A simple test: äüöss', getline('.'))
16051605

1606+
" Turkish ASCII turns to multi-byte.
1607+
try
1608+
lang tr_TR.UTF-8
1609+
set casemap=
1610+
call setline(1, 'iI')
1611+
1normal gUU
1612+
call assert_equal("\u0130I", getline(1))
1613+
call assert_equal("\u0130I", toupper("iI"))
1614+
1615+
call setline(1, 'iI')
1616+
1normal guu
1617+
call assert_equal("i\u0131", getline(1))
1618+
call assert_equal("i\u0131", tolower("iI"))
1619+
1620+
lang en_US.UTF-8
1621+
catch /E197:/
1622+
" can't use Turkish locale
1623+
throw 'Skipped: Turkish locale not available'
1624+
endtry
1625+
16061626
" clean up
16071627
bw!
16081628
endfunc

src/version.c

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

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
552,
767769
/**/
768770
551,
769771
/**/

0 commit comments

Comments
 (0)