diff options
| author | Mel <mel@rnrd.eu> | 2025-08-05 22:49:40 +0200 |
|---|---|---|
| committer | Mel <mel@rnrd.eu> | 2025-08-05 22:49:40 +0200 |
| commit | c2c84f4d15d964fb663f390046b1d17441145c61 (patch) | |
| tree | a1724e49fefe143fd82404ffb1a0891ad6bc9755 /boot/common.c | |
| parent | 1d277d507498d8f3649684e7ff0ad2c3a19792a4 (diff) | |
| download | catskill-c2c84f4d15d964fb663f390046b1d17441145c61.tar.zst catskill-c2c84f4d15d964fb663f390046b1d17441145c61.zip | |
Add core library for catskill transpiled source, output defined types in transpiler
Signed-off-by: Mel <mel@rnrd.eu>
Diffstat (limited to 'boot/common.c')
| -rw-r--r-- | boot/common.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/boot/common.c b/boot/common.c index 6a95bb6..4f9c2ad 100644 --- a/boot/common.c +++ b/boot/common.c @@ -8,6 +8,9 @@ * SPDX-License-Identifier: MPL-2.0 */ +// TODO: merge our common library with `boot/runtime/core.c` +// to avoid implementing a semi-standard library twice! + #pragma once #include <math.h> @@ -239,6 +242,22 @@ string_length(struct String s) return s.length; } +bool +string_equals(const struct String a, const struct String b) +{ + if (string_length(a) != string_length(b)) return false; + if (string_length(a) == 0) return true; + return memcmp(a.data, b.data, a.length) == 0; +} + +bool +string_equals_c_str(const struct String a, const ascii* b) +{ + uint b_length = strlen(b); + if (string_length(a) != b_length) return false; + if (string_length(a) == 0) return true; + return memcmp(a.data, b, a.length) == 0; +} void string_print(struct String s) { |
