From 166b1754a9b2046d678f59dedea7a3d693067047 Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Fri, 17 Jan 2025 11:48:12 +0100 Subject: [PATCH] patch 9.1.1025: wrong return type of blob2str() Problem: wrong return type of blob2str() Solution: update return to list of string (Yegappan Lakshmanan) closes: #16461 Signed-off-by: Yegappan Lakshmanan Signed-off-by: Christian Brabandt --- runtime/doc/builtin.txt | 4 ++-- src/evalfunc.c | 2 +- src/testdir/test_vim9_builtin.vim | 17 +++++++++++++++++ src/version.c | 2 ++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index d60d61f0d0..1837661bd5 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -1,4 +1,4 @@ -*builtin.txt* For Vim version 9.1. Last change: 2025 Jan 16 +*builtin.txt* For Vim version 9.1. Last change: 2025 Jan 17 VIM REFERENCE MANUAL by Bram Moolenaar @@ -72,7 +72,7 @@ base64_encode({blob}) String base64 encode the bytes in {blob} bindtextdomain({package}, {path}) Bool bind text domain to specified path blob2list({blob}) List convert {blob} into a list of numbers -blob2str({blob} [, {options}]) String convert {blob} into a list of strings +blob2str({blob} [, {options}]) List convert {blob} into a list of strings browse({save}, {title}, {initdir}, {default}) String put up a file requester browsedir({title}, {initdir}) String put up a directory requester diff --git a/src/evalfunc.c b/src/evalfunc.c index 2b630cafc2..8886088561 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -1847,7 +1847,7 @@ static funcentry_T global_functions[] = {"blob2list", 1, 1, FEARG_1, arg1_blob, ret_list_number, f_blob2list}, {"blob2str", 1, 2, FEARG_1, arg2_blob_dict, - ret_string, f_blob2str}, + ret_list_string, f_blob2str}, {"browse", 4, 4, 0, arg4_browse, ret_string, f_browse}, {"browsedir", 2, 2, 0, arg2_string, diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index c82608b465..cfaf0ace21 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -357,6 +357,16 @@ def Test_blob2list() v9.CheckSourceDefAndScriptFailure(['blob2list(10)'], ['E1013: Argument 1: type mismatch, expected blob but got number', 'E1238: Blob required for argument 1']) enddef +def Test_blob2str() + 0z6162->blob2str()->assert_equal(["ab"]) + blob2str(0z)->assert_equal([]) + + var l: list = blob2str(0zC2ABC2BB) + assert_equal(["«»"], l) + + v9.CheckSourceDefAndScriptFailure(['blob2str("ab")'], ['E1013: Argument 1: type mismatch, expected blob but got string', 'E1238: Blob required for argument 1']) +enddef + def Test_browse() CheckFeature browse @@ -4325,6 +4335,13 @@ def Test_state() assert_equal('', state('a')) enddef +def Test_str2blob() + ["ab"]->str2blob()->assert_equal(0z6162) + str2blob([""])->assert_equal(0z) + + v9.CheckSourceDefAndScriptFailure(['str2blob("ab")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) +enddef + def Test_str2float() str2float("1.00")->assert_equal(1.00) str2float("2e-2")->assert_equal(0.02) diff --git a/src/version.c b/src/version.c index b002210866..93f94c1364 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1025, /**/ 1024, /**/