summaryrefslogtreecommitdiff
path: root/source/base/base_string.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/base/base_string.c')
-rw-r--r--source/base/base_string.c77
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 @@
1internal umm 1internal b32
2skip_whitespaces(string *buffer) 2is_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
11internal b8 7internal b32
12compare_string_struct(string c1, string c2) 8is_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
32internal b8 13internal b32
33compare_string(char *c1, char *c2) 14is_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; 19internal 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 **/ 24internal b32
57internal u64 25is_slash(u8 point)
58parse_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}