1
0
forked from aniani/vim

patch 8.2.4439: accepting "iso8859" 'encoding' as "iso-8859-"

Problem:    Accepting "iso8859" 'encoding' as "iso-8859-".
Solution:   use "iso8859" as "iso-8859-1".
This commit is contained in:
Bram Moolenaar 2022-02-22 12:34:28 +00:00
parent ca0c1caa36
commit 1349bd712c
3 changed files with 29 additions and 1 deletions

View File

@ -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},
@ -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] = '-';

View File

@ -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)

View File

@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4439,
/**/
4438,
/**/