summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-04-09 21:33:22 +0200
committerBram Moolenaar <Bram@vim.org>2020-04-09 21:33:22 +0200
commit7b293c730b07d1586688e622b8d9cbbb4a52379b (patch)
tree0f90c26a7a77364ad11f2488536d79fa977d2bc1
parent9c8bb7c0e251be2cca409055bd415266f57f013a (diff)
downloadvim-git-7b293c730b07d1586688e622b8d9cbbb4a52379b.tar.gz
patch 8.2.0539: comparing two NULL list failsv8.2.0539
Problem: Comparing two NULL list fails. Solution: Change the order of comparing two lists.
-rw-r--r--src/list.c7
-rw-r--r--src/testdir/test_assert.vim3
-rw-r--r--src/version.c2
3 files changed, 10 insertions, 2 deletions
diff --git a/src/list.c b/src/list.c
index 9fe538414..451e58591 100644
--- a/src/list.c
+++ b/src/list.c
@@ -368,12 +368,15 @@ list_equal(
{
listitem_T *item1, *item2;
- if (l1 == NULL || l2 == NULL)
- return FALSE;
if (l1 == l2)
return TRUE;
if (list_len(l1) != list_len(l2))
return FALSE;
+ if (list_len(l1) == 0)
+ // empty and NULL list are considered equal
+ return TRUE;
+ if (l1 == NULL || l2 == NULL)
+ return FALSE;
range_list_materialize(l1);
range_list_materialize(l2);
diff --git a/src/testdir/test_assert.vim b/src/testdir/test_assert.vim
index 1b1f9e515..762f12ff5 100644
--- a/src/testdir/test_assert.vim
+++ b/src/testdir/test_assert.vim
@@ -36,6 +36,9 @@ func Test_assert_equal()
call assert_equal(0, assert_equal(4, n))
let l = [1, 2, 3]
call assert_equal(0, assert_equal([1, 2, 3], l))
+ call assert_equal(test_null_list(), test_null_list())
+ call assert_equal(test_null_list(), [])
+ call assert_equal([], test_null_list())
let s = 'foo'
call assert_equal(1, assert_equal('bar', s))
diff --git a/src/version.c b/src/version.c
index 0c147cce9..2bba57d7d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -739,6 +739,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 539,
+/**/
538,
/**/
537,