Skip to content

Commit 2e154d8

Browse files
zeertzjqchrisbra
authored andcommitted
patch 9.1.1558: str2blob() treats NULL string and empty string differently
Problem: str2blob() treats NULL string and empty string differently Solution: Treats a NULL string the same as an empty string (zeertzjq). closes: #17778 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 0d9160e commit 2e154d8

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/strings.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1407,7 +1407,7 @@ f_str2blob(typval_T *argvars, typval_T *rettv)
14071407
char_u *str = li->li_tv.vval.v_string;
14081408

14091409
if (str == NULL)
1410-
continue;
1410+
str = (char_u *)"";
14111411

14121412
if (to_encoding != NULL)
14131413
{

src/testdir/test_functions.vim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4411,13 +4411,17 @@ func Test_str2blob()
44114411
call assert_equal(0z, str2blob([""]))
44124412
call assert_equal(0z, str2blob([]))
44134413
call assert_equal(0z, str2blob(test_null_list()))
4414-
call assert_equal(0z, str2blob([test_null_string(), test_null_string()]))
4414+
call assert_equal(0z, str2blob([test_null_string()]))
4415+
call assert_equal(0z0A, str2blob([test_null_string(), test_null_string()]))
44154416
call assert_fails("call str2blob('')", 'E1211: List required for argument 1')
44164417
call assert_equal(0z61, str2blob(["a"]))
44174418
call assert_equal(0z6162, str2blob(["ab"]))
44184419
call assert_equal(0z610062, str2blob(["a\nb"]))
44194420
call assert_equal(0z61620A6364, str2blob(["ab", "cd"]))
44204421
call assert_equal(0z0A, str2blob(["", ""]))
4422+
call assert_equal(0z610A62, str2blob(["a", "b"]))
4423+
call assert_equal(0z610A0A62, str2blob(["a", "", "b"]))
4424+
call assert_equal(0z610A0A62, str2blob(["a", test_null_string(), "b"]))
44214425

44224426
call assert_equal(0zC2ABC2BB, str2blob(["«»"]))
44234427
call assert_equal(0zC59DC59F, str2blob(["ŝş"]))

src/version.c

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

720720
static int included_patches[] =
721721
{ /* Add new patch number below this line */
722+
/**/
723+
1558,
722724
/**/
723725
1557,
724726
/**/

0 commit comments

Comments
 (0)