Skip to content

Commit

Permalink
patch 8.2.4439: accepting "iso8859" 'encoding' as "iso-8859-"
Browse files Browse the repository at this point in the history
Problem:    Accepting "iso8859" 'encoding' as "iso-8859-".
Solution:   use "iso8859" as "iso-8859-1".
  • Loading branch information
brammool committed Feb 22, 2022
1 parent ca0c1ca commit 1349bd7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/mbyte.c
Expand Up @@ -318,6 +318,7 @@ enc_alias_table[] =
{
{"ansi", IDX_LATIN_1},
{"iso-8859-1", IDX_LATIN_1},
{"iso-8859", IDX_LATIN_1},
{"latin2", IDX_ISO_2},
{"latin3", IDX_ISO_3},
{"latin4", IDX_ISO_4},
Expand Down Expand Up @@ -4523,7 +4524,7 @@ enc_canonize(char_u *enc)
}

// "iso-8859n" -> "iso-8859-n"
if (STRNCMP(p, "iso-8859", 8) == 0 && p[8] != '-')
if (STRNCMP(p, "iso-8859", 8) == 0 && isdigit(p[8]))
{
STRMOVE(p + 9, p + 8);
p[8] = '-';
Expand Down
25 changes: 25 additions & 0 deletions src/testdir/test_options.vim
Expand Up @@ -445,6 +445,31 @@ func Test_set_errors()
call assert_fails('set t_#-&', 'E522:')
endfunc

func Test_set_encoding()
let save_encoding = &encoding

set enc=iso8859-1
call assert_equal('latin1', &enc)
set enc=iso8859_1
call assert_equal('latin1', &enc)
set enc=iso-8859-1
call assert_equal('latin1', &enc)
set enc=iso_8859_1
call assert_equal('latin1', &enc)
set enc=iso88591
call assert_equal('latin1', &enc)
set enc=iso8859
call assert_equal('latin1', &enc)
set enc=iso-8859
call assert_equal('latin1', &enc)
set enc=iso_8859
call assert_equal('latin1', &enc)
call assert_fails('set enc=iso8858', 'E474:')
call assert_equal('latin1', &enc)

let &encoding = save_encoding
endfunc

func CheckWasSet(name)
let verb_cm = execute('verbose set ' .. a:name .. '?')
call assert_match('Last set from.*test_options.vim', verb_cm)
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -750,6 +750,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4439,
/**/
4438,
/**/
Expand Down

0 comments on commit 1349bd7

Please sign in to comment.