1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-26 05:35:21 +02:00

eeshow/delta.c (obj_eq): optionally recurse into sub-sheets

This commit is contained in:
Werner Almesberger 2016-08-13 03:19:40 -03:00
parent 174a57d6c5
commit dd952eabf1

View File

@ -221,7 +221,8 @@ match:
* fields individually. * 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) if (a->type != b->type)
return 0; return 0;
@ -277,7 +278,11 @@ static bool obj_eq(const struct sch_obj *a, const struct sch_obj *b)
return 0; return 0;
if (strcmp(a->u.sheet.file, b->u.sheet.file)) if (strcmp(a->u.sheet.file, b->u.sheet.file))
return 0; 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: default:
abort(); abort();
} }
@ -299,7 +304,7 @@ bool sheet_eq(const struct sheet *a, const struct sheet *b)
obj_a = a->objs; obj_a = a->objs;
obj_b = b->objs; obj_b = b->objs;
while (obj_a && obj_b) { while (obj_a && obj_b) {
if (!obj_eq(obj_a, obj_b)) if (!obj_eq(obj_a, obj_b, 1))
return 0; return 0;
obj_a = obj_a->next; obj_a = obj_a->next;
obj_b = obj_b->next; obj_b = obj_b->next;
@ -348,7 +353,7 @@ void delta(const struct sheet *a, const struct sheet *b,
while (objs_a) { while (objs_a) {
next_a = objs_a->next; next_a = objs_a->next;
for (obj_b = &objs_b; *obj_b; obj_b = &(*obj_b)->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; struct sch_obj *tmp = *obj_b;
add_obj(res_ab, objs_a); add_obj(res_ab, objs_a);