Issue #155 - Check bytevectors for deep equality

This commit is contained in:
Justin Ethier 2017-01-24 20:54:29 -05:00
parent 0e5a8685bd
commit 2ce541ed4b
2 changed files with 14 additions and 0 deletions

View file

@ -7,6 +7,7 @@ Features
Bug Fixes Bug Fixes
- Thanks to Koz Ross, `equal?` has been updated to check bytevectors for deep equality.
- Display characters such as `#\space` correctly when output via `write`. - Display characters such as `#\space` correctly when output via `write`.
- Thanks for Seth Alves, removed unnecessary include of `ck_string.h` which is not provided in older versions of `libck`. - Thanks for Seth Alves, removed unnecessary include of `ck_string.h` which is not provided in older versions of `libck`.

View file

@ -588,6 +588,19 @@ int equal(object x, object y)
return 1; return 1;
} }
return 0; return 0;
case bytevector_tag:
if (is_object_type(y) &&
type_of(y) == bytevector_tag &&
((bytevector) x)->len == ((bytevector) y)->len) {
int i;
for (i = 0; i < ((bytevector) x)->len; i++) {
if (((bytevector)x)->data[i] != ((bytevector)y)->data[i]) {
return 0;
}
}
return 1;
}
return 0;
default: default:
return x == y; return x == y;
} }