diff options
| author | nasr <nsrddyn@gmail.com> | 2026-04-16 17:10:02 +0200 |
|---|---|---|
| committer | nasr <nsrddyn@gmail.com> | 2026-04-16 17:10:02 +0200 |
| commit | 8ea6a3c8621287d11296b8300029f32a27743d9a (patch) | |
| tree | cd12aa5fcd3e058fa74b45705c7b82524658d444 /source/base/base_string.c | |
| parent | f430bfe8f71430032bec689bf0bbdc94ac409c22 (diff) | |
feature(checkpoint): checkpoint cleaning up base library
Diffstat (limited to 'source/base/base_string.c')
| -rw-r--r-- | source/base/base_string.c | 77 |
1 files changed, 17 insertions, 60 deletions
diff --git a/source/base/base_string.c b/source/base/base_string.c index cb2d71d..986fde5 100644 --- a/source/base/base_string.c +++ b/source/base/base_string.c | |||
| @@ -1,73 +1,30 @@ | |||
| 1 | internal umm | 1 | internal b32 |
| 2 | skip_whitespaces(string *buffer) | 2 | is_alpha(u8 point) |
| 3 | { | 3 | { |
| 4 | s32 index = 0; | 4 | return ((point >= 'a' && point <= 'z') || (point >= 'A' && point <= 'Z') || (point == '_')); |
| 5 | while (buffer->size > index) | ||
| 6 | { | ||
| 7 | ++index; | ||
| 8 | } | ||
| 9 | } | 5 | } |
| 10 | 6 | ||
| 11 | internal b8 | 7 | internal b32 |
| 12 | compare_string_struct(string c1, string c2) | 8 | is_digit(u8 point) |
| 13 | { | 9 | { |
| 14 | if (c1.size != c2.size) | 10 | return (point >= '0' && point <= '9'); |
| 15 | { | ||
| 16 | return -1; | ||
| 17 | } | ||
| 18 | |||
| 19 | for (s32 index = 0; | ||
| 20 | index < c1.size; | ||
| 21 | ++index) | ||
| 22 | { | ||
| 23 | if (c1.Data[index] != c2.Data[index]) | ||
| 24 | { | ||
| 25 | return -1; | ||
| 26 | } | ||
| 27 | } | ||
| 28 | |||
| 29 | return 0; | ||
| 30 | } | 11 | } |
| 31 | 12 | ||
| 32 | internal b8 | 13 | internal b32 |
| 33 | compare_string(char *c1, char *c2) | 14 | is_alpha_num(u8 point) |
| 34 | { | 15 | { |
| 35 | if (sizeof(*c1) != sizeof(*c2)) | 16 | return (is_alpha(point) || is_digit(point)); |
| 36 | { | 17 | } |
| 37 | return -1; | ||
| 38 | } | ||
| 39 | |||
| 40 | for ( | ||
| 41 | u64 word_idx = 0; | ||
| 42 | word_idx <= sizeof(*c1); | ||
| 43 | ++word_idx) | ||
| 44 | { | ||
| 45 | if (*c1 != *c2) | ||
| 46 | { | ||
| 47 | return -1; | ||
| 48 | } | ||
| 49 | ++c1; | ||
| 50 | ++c2; | ||
| 51 | } | ||
| 52 | 18 | ||
| 53 | return 0; | 19 | internal b32 is_whitespace(u8 point) |
| 20 | { | ||
| 21 | return (point == '\n' || point == '\r' || point == ' ' || point == '\t'); | ||
| 54 | } | 22 | } |
| 55 | 23 | ||
| 56 | /** NOTE(nasr): Helper function to parse strings to int using ascii codes **/ | 24 | internal b32 |
| 57 | internal u64 | 25 | is_slash(u8 point) |
| 58 | parse_u64(char *buf, umm len) | ||
| 59 | { | 26 | { |
| 60 | u64 value = 0; | 27 | return (point == '/' || point == '\\'); |
| 28 | } | ||
| 61 | 29 | ||
| 62 | for (umm buffer_idx = 0; buffer_idx < len; ++buffer_idx) | ||
| 63 | { | ||
| 64 | char c = buf[buffer_idx]; | ||
| 65 | if (c < '0' || c > '9') | ||
| 66 | { | ||
| 67 | break; | ||
| 68 | } | ||
| 69 | value = value * 10 + (c - '0'); | ||
| 70 | } | ||
| 71 | 30 | ||
| 72 | return value; | ||
| 73 | } | ||
