summaryrefslogtreecommitdiff
path: root/source/base/base_string.c
diff options
context:
space:
mode:
authornasr <nsrddyn@gmail.com>2026-03-13 22:31:21 +0100
committernasr <nsrddyn@gmail.com>2026-03-13 22:31:21 +0100
commit444bfa2f41143aff7490e4fa21565947565b7d30 (patch)
tree696b06d40140c85805d171597e37deb8290ead73 /source/base/base_string.c
parent3913d1778318cd0c6bfb871148d38abb33ec7fd3 (diff)
cleanup: generalisation
Diffstat (limited to 'source/base/base_string.c')
-rw-r--r--source/base/base_string.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/source/base/base_string.c b/source/base/base_string.c
new file mode 100644
index 0000000..cb2d71d
--- /dev/null
+++ b/source/base/base_string.c
@@ -0,0 +1,73 @@
1internal umm
2skip_whitespaces(string *buffer)
3{
4 s32 index = 0;
5 while (buffer->size > index)
6 {
7 ++index;
8 }
9}
10
11internal b8
12compare_string_struct(string c1, string c2)
13{
14 if (c1.size != c2.size)
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}
31
32internal b8
33compare_string(char *c1, char *c2)
34{
35 if (sizeof(*c1) != sizeof(*c2))
36 {
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
53 return 0;
54}
55
56/** NOTE(nasr): Helper function to parse strings to int using ascii codes **/
57internal u64
58parse_u64(char *buf, umm len)
59{
60 u64 value = 0;
61
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
72 return value;
73}