Skip to content

Commit d5afc74

Browse files
committed
patch 9.1.1223: wrong translation used for encoding failures
Problem: wrong translation for encoding failures because of using literal "from" and "to" in the resulting error message (RestorerZ) Solution: use separate error messages for errors "from" and "to" encoding errors. fixes: #16898 closes: #16918 Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 8ac0f73 commit d5afc74

6 files changed

Lines changed: 15 additions & 10 deletions

File tree

runtime/doc/builtin.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ blob2str({blob} [, {options}]) *blob2str()*
13111311
encoding. The value is a |String|. See
13121312
|encoding-names| for the supported values
13131313
(plus the special value "none").
1314-
*E1515*
1314+
*E1515* *E1516*
13151315
When current 'encoding' is "utf-8", an error is given and an
13161316
empty List is returned if an invalid byte sequence is
13171317
encountered in {blob}. To suppress this validation and get

runtime/doc/tags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4589,6 +4589,7 @@ E1512 options.txt /*E1512*
45894589
E1513 message.txt /*E1513*
45904590
E1514 options.txt /*E1514*
45914591
E1515 builtin.txt /*E1515*
4592+
E1516 builtin.txt /*E1516*
45924593
E152 helphelp.txt /*E152*
45934594
E153 helphelp.txt /*E153*
45944595
E154 helphelp.txt /*E154*

src/errors.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3660,5 +3660,7 @@ EXTERN char e_winfixbuf_cannot_go_to_buffer[]
36603660
INIT(= N_("E1513: Cannot switch buffer. 'winfixbuf' is enabled"));
36613661
EXTERN char e_invalid_return_type_from_findfunc[]
36623662
INIT(= N_("E1514: 'findfunc' did not return a List type"));
3663-
EXTERN char e_str_encoding_failed[]
3664-
INIT(= N_("E1515: Unable to convert %s '%s' encoding"));
3663+
EXTERN char e_str_encoding_from_failed[]
3664+
INIT(= N_("E1515: Unable to convert from '%s' encoding"));
3665+
EXTERN char e_str_encoding_to_failed[]
3666+
INIT(= N_("E1516: Unable to convert to '%s' encoding"));

src/strings.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,7 @@ f_blob2str(typval_T *argvars, typval_T *rettv)
13391339
vim_free(str);
13401340
if (converted_str == NULL)
13411341
{
1342-
semsg(_(e_str_encoding_failed), "from", from_encoding);
1342+
semsg(_(e_str_encoding_from_failed), from_encoding);
13431343
goto done;
13441344
}
13451345
}
@@ -1348,7 +1348,7 @@ f_blob2str(typval_T *argvars, typval_T *rettv)
13481348
{
13491349
if (!utf_valid_string(converted_str, NULL))
13501350
{
1351-
semsg(_(e_str_encoding_failed), "from", p_enc);
1351+
semsg(_(e_str_encoding_from_failed), p_enc);
13521352
vim_free(converted_str);
13531353
goto done;
13541354
}
@@ -1414,7 +1414,7 @@ f_str2blob(typval_T *argvars, typval_T *rettv)
14141414
str = convert_string(str, p_enc, to_encoding);
14151415
if (str == NULL)
14161416
{
1417-
semsg(_(e_str_encoding_failed), "to", to_encoding);
1417+
semsg(_(e_str_encoding_to_failed), to_encoding);
14181418
goto done;
14191419
}
14201420
}

src/testdir/test_functions.vim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4422,10 +4422,10 @@ func Test_str2blob()
44224422

44234423
call assert_fails("call str2blob(['abc'], [])", 'E1206: Dictionary required for argument 2')
44244424
call assert_fails("call str2blob(['abc'], {'encoding': []})", 'E730: Using a List as a String')
4425-
call assert_fails("call str2blob(['abc'], {'encoding': 'ab12xy'})", 'E1515: Unable to convert to ''ab12xy'' encoding')
4426-
call assert_fails("call str2blob(['ŝş'], {'encoding': 'latin1'})", 'E1515: Unable to convert to ''latin1'' encoding')
4427-
call assert_fails("call str2blob(['அஇ'], {'encoding': 'latin1'})", 'E1515: Unable to convert to ''latin1'' encoding')
4428-
call assert_fails("call str2blob(['🁰🁳'], {'encoding': 'latin1'})", 'E1515: Unable to convert to ''latin1'' encoding')
4425+
call assert_fails("call str2blob(['abc'], {'encoding': 'ab12xy'})", 'E1516: Unable to convert to ''ab12xy'' encoding')
4426+
call assert_fails("call str2blob(['ŝş'], {'encoding': 'latin1'})", 'E1516: Unable to convert to ''latin1'' encoding')
4427+
call assert_fails("call str2blob(['அஇ'], {'encoding': 'latin1'})", 'E1516: Unable to convert to ''latin1'' encoding')
4428+
call assert_fails("call str2blob(['🁰🁳'], {'encoding': 'latin1'})", 'E1516: Unable to convert to ''latin1'' encoding')
44294429
END
44304430
call v9.CheckLegacyAndVim9Success(lines)
44314431
endfunc

src/version.c

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

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
1223,
707709
/**/
708710
1222,
709711
/**/

0 commit comments

Comments
 (0)