]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1223: wrong translation used for encoding failures v9.1.1223
authorChristian Brabandt <cb@256bit.org>
Tue, 18 Mar 2025 19:55:42 +0000 (20:55 +0100)
committerChristian Brabandt <cb@256bit.org>
Tue, 18 Mar 2025 19:55:42 +0000 (20:55 +0100)
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>
runtime/doc/builtin.txt
runtime/doc/tags
src/errors.h
src/strings.c
src/testdir/test_functions.vim
src/version.c

index bb6f9172e87013e8ed0179e41f8c2e77b7faf8b7..b7791ccb40601b82a155441c907f7f38bfcbe149 100644 (file)
@@ -1311,7 +1311,7 @@ blob2str({blob} [, {options}])                            *blob2str()*
                                encoding.  The value is a |String|.  See
                                |encoding-names| for the supported values
                                (plus the special value "none").
-                                                       *E1515*
+                                                       *E1515* *E1516*
                When current 'encoding' is "utf-8", an error is given and an
                empty List is returned if an invalid byte sequence is
                encountered in {blob}.  To suppress this validation and get
index c25effa3a4e67b77965c6da1abd2ac161367a5e2..8f3fd50344ffbd2d917262fa67f2cbcc0f59c146 100644 (file)
@@ -4589,6 +4589,7 @@ E1512     options.txt     /*E1512*
 E1513  message.txt     /*E1513*
 E1514  options.txt     /*E1514*
 E1515  builtin.txt     /*E1515*
+E1516  builtin.txt     /*E1516*
 E152   helphelp.txt    /*E152*
 E153   helphelp.txt    /*E153*
 E154   helphelp.txt    /*E154*
index a1165056ba1e341c21f1b4959cbd55ba16568e62..ca5ec850e1bf5f291aac1b597a10e65cb8f12cab 100644 (file)
@@ -3660,5 +3660,7 @@ EXTERN char e_winfixbuf_cannot_go_to_buffer[]
        INIT(= N_("E1513: Cannot switch buffer. 'winfixbuf' is enabled"));
 EXTERN char e_invalid_return_type_from_findfunc[]
        INIT(= N_("E1514: 'findfunc' did not return a List type"));
-EXTERN char e_str_encoding_failed[]
-       INIT(= N_("E1515: Unable to convert %s '%s' encoding"));
+EXTERN char e_str_encoding_from_failed[]
+       INIT(= N_("E1515: Unable to convert from '%s' encoding"));
+EXTERN char e_str_encoding_to_failed[]
+       INIT(= N_("E1516: Unable to convert to '%s' encoding"));
index 640ad39a8fa6ca58ca95a4b57955e2dcfa651c6f..d6f1b3823620cc7699585c6f641addcabefb4bf4 100644 (file)
@@ -1339,7 +1339,7 @@ f_blob2str(typval_T *argvars, typval_T *rettv)
            vim_free(str);
            if (converted_str == NULL)
            {
-               semsg(_(e_str_encoding_failed), "from", from_encoding);
+               semsg(_(e_str_encoding_from_failed), from_encoding);
                goto done;
            }
        }
@@ -1348,7 +1348,7 @@ f_blob2str(typval_T *argvars, typval_T *rettv)
        {
            if (!utf_valid_string(converted_str, NULL))
            {
-               semsg(_(e_str_encoding_failed), "from", p_enc);
+               semsg(_(e_str_encoding_from_failed), p_enc);
                vim_free(converted_str);
                goto done;
            }
@@ -1414,7 +1414,7 @@ f_str2blob(typval_T *argvars, typval_T *rettv)
            str = convert_string(str, p_enc, to_encoding);
            if (str == NULL)
            {
-               semsg(_(e_str_encoding_failed), "to", to_encoding);
+               semsg(_(e_str_encoding_to_failed), to_encoding);
                goto done;
            }
        }
index 724fda05c363f3d2268946c628c1127194842dcc..c498ec0a38b7f1760651098c5c6ebcad9a9bd3e9 100644 (file)
@@ -4422,10 +4422,10 @@ func Test_str2blob()
 
     call assert_fails("call str2blob(['abc'], [])", 'E1206: Dictionary required for argument 2')
     call assert_fails("call str2blob(['abc'], {'encoding': []})", 'E730: Using a List as a String')
-    call assert_fails("call str2blob(['abc'], {'encoding': 'ab12xy'})", 'E1515: Unable to convert to ''ab12xy'' encoding')
-    call assert_fails("call str2blob(['ŝş'], {'encoding': 'latin1'})", 'E1515: Unable to convert to ''latin1'' encoding')
-    call assert_fails("call str2blob(['அஇ'], {'encoding': 'latin1'})", 'E1515: Unable to convert to ''latin1'' encoding')
-    call assert_fails("call str2blob(['🁰🁳'], {'encoding': 'latin1'})", 'E1515: Unable to convert to ''latin1'' encoding')
+    call assert_fails("call str2blob(['abc'], {'encoding': 'ab12xy'})", 'E1516: Unable to convert to ''ab12xy'' encoding')
+    call assert_fails("call str2blob(['ŝş'], {'encoding': 'latin1'})", 'E1516: Unable to convert to ''latin1'' encoding')
+    call assert_fails("call str2blob(['அஇ'], {'encoding': 'latin1'})", 'E1516: Unable to convert to ''latin1'' encoding')
+    call assert_fails("call str2blob(['🁰🁳'], {'encoding': 'latin1'})", 'E1516: Unable to convert to ''latin1'' encoding')
   END
   call v9.CheckLegacyAndVim9Success(lines)
 endfunc
index ee5b5ed7f31d4c36e158db6b7a4ec5dab125e4f3..b4f631248c1601dfe0c8f1729b49ec00d6ba466b 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1223,
 /**/
     1222,
 /**/