summaryrefslogtreecommitdiff
path: root/delta.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-13 03:19:40 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-13 03:19:40 -0300
commitebdd2cc8fb3c26f803fc7291fa402f85b54addcf (patch)
treeb020684349484f72b94940344a21240ef74271ef /delta.c
parent3fd43e0f89eb6cd36b8a3433ed2f5be5f522165b (diff)
downloadeeshow-ebdd2cc8fb3c26f803fc7291fa402f85b54addcf.tar.gz
eeshow-ebdd2cc8fb3c26f803fc7291fa402f85b54addcf.tar.bz2
eeshow-ebdd2cc8fb3c26f803fc7291fa402f85b54addcf.zip
eeshow/delta.c (obj_eq): optionally recurse into sub-sheets
Diffstat (limited to 'delta.c')
-rw-r--r--delta.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/delta.c b/delta.c
index b9a9473..cde89c0 100644
--- a/delta.c
+++ b/delta.c
@@ -221,7 +221,8 @@ match:
* fields individually.
*/
-static bool obj_eq(const struct sch_obj *a, const struct sch_obj *b)
+static bool obj_eq(const struct sch_obj *a, const struct sch_obj *b,
+ bool recurse)
{
if (a->type != b->type)
return 0;
@@ -277,7 +278,11 @@ static bool obj_eq(const struct sch_obj *a, const struct sch_obj *b)
return 0;
if (strcmp(a->u.sheet.file, b->u.sheet.file))
return 0;
- return sheet_fields_eq(a->u.sheet.fields, b->u.sheet.fields);
+ if (!sheet_fields_eq(a->u.sheet.fields, b->u.sheet.fields))
+ return 0;
+ if (!recurse)
+ return 1;
+ return sheet_eq(a->u.sheet.sheet, b->u.sheet.sheet);
default:
abort();
}
@@ -299,7 +304,7 @@ bool sheet_eq(const struct sheet *a, const struct sheet *b)
obj_a = a->objs;
obj_b = b->objs;
while (obj_a && obj_b) {
- if (!obj_eq(obj_a, obj_b))
+ if (!obj_eq(obj_a, obj_b, 1))
return 0;
obj_a = obj_a->next;
obj_b = obj_b->next;
@@ -348,7 +353,7 @@ void delta(const struct sheet *a, const struct sheet *b,
while (objs_a) {
next_a = objs_a->next;
for (obj_b = &objs_b; *obj_b; obj_b = &(*obj_b)->next)
- if (obj_eq(objs_a, *obj_b)) {
+ if (obj_eq(objs_a, *obj_b, 0)) {
struct sch_obj *tmp = *obj_b;
add_obj(res_ab, objs_a);