mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 9.1.0514: Vim9: issue with comparing objects recursively
Problem: Vim9: issue with comparing objects recursively (Yinzuo Jiang) Solution: only set recursive == TRUE, when called from tv_equal(), not from typeval_compare_object(), refactor code into object_equal() function (LemonBoy) The recursive flag in tv_equal should be set only when the caller is tv_equal, meaning that the comparison depth is > 1. The comparison predicates for other object types are all following this rule, except for the object one, and that may cause some weird issues like causing the max depth limit not to be initialized in some cases. closes: #15076 Signed-off-by: LemonBoy <thatlemon@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
549ecc8636
commit
7b29cc97d6
@@ -3841,6 +3841,34 @@ object_len(object_T *obj)
|
||||
return tv_to_number(&rettv);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return TRUE when two objects have exactly the same values.
|
||||
*/
|
||||
int
|
||||
object_equal(
|
||||
object_T *o1,
|
||||
object_T *o2,
|
||||
int ic, // ignore case for strings
|
||||
int recursive) // TRUE when used recursively
|
||||
{
|
||||
class_T *cl1, *cl2;
|
||||
|
||||
if (o1 == o2)
|
||||
return TRUE;
|
||||
|
||||
cl1 = o1->obj_class;
|
||||
cl2 = o2->obj_class;
|
||||
|
||||
if (cl1 != cl2 || cl1 == NULL || cl2 == NULL)
|
||||
return FALSE;
|
||||
|
||||
for (int i = 0; i < cl1->class_obj_member_count; ++i)
|
||||
if (!tv_equal((typval_T *)(o1 + 1) + i, (typval_T *)(o2 + 1) + i, ic, recursive))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a textual representation of object "obj"
|
||||
*/
|
||||
|
Reference in New Issue
Block a user