diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-09-09 04:42:36 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-09-09 04:42:36 -0400 |
| commit | bc032de1dfc8ad03ed7d6ab0471140f393c74532 (patch) | |
| tree | 90a7ad62399b79dbb43007aad0bd881a3daf5da8 /builtins/text.c | |
| parent | d3509e964a854ece528f46d682fdc997c5668e15 (diff) | |
Add Text$compare_values()
Diffstat (limited to 'builtins/text.c')
| -rw-r--r-- | builtins/text.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/builtins/text.c b/builtins/text.c index 784da410..6fedd82e 100644 --- a/builtins/text.c +++ b/builtins/text.c @@ -905,22 +905,26 @@ PUREFUNC public int32_t Text$compare(const Text_t *a, const Text_t *b) return 0; } -PUREFUNC public bool Text$equal(const Text_t *a, const Text_t *b) +PUREFUNC public bool Text$equal_values(Text_t a, Text_t b) { - if (a == b) return true; - - if (a->length != b->length || (a->hash != 0 && b->hash != 0 && a->hash != b->hash)) + if (a.length != b.length || (a.hash != 0 && b.hash != 0 && a.hash != b.hash)) return false; - int64_t len = a->length; + int64_t len = a.length; text_iter_t a_state = {0, 0}, b_state = {0, 0}; for (int64_t i = 0; i < len; i++) { - int32_t ai = _get_grapheme(*a, &a_state, i); - int32_t bi = _get_grapheme(*b, &b_state, i); + int32_t ai = _get_grapheme(a, &a_state, i); + int32_t bi = _get_grapheme(b, &b_state, i); if (ai != bi) return false; } return true; } +PUREFUNC public bool Text$equal(const Text_t *a, const Text_t *b) +{ + if (a == b) return true; + return Text$equal_values(*a, *b); +} + PUREFUNC public bool Text$equal_ignoring_case(Text_t a, Text_t b) { if (a.length != b.length) |
