comparison dowa/d_string.c @ 71:75de5903355c

Giagantic changes that update Dowa library to be more align with stb style array and hashmap. Updated Seobeo to be caching on server side instead of file level caching. Deleted bunch of things I don't really use.
author June Park <parkjune1995@gmail.com>
date Sun, 28 Dec 2025 20:34:22 -0800
parents fff1b048dda6
children 4532ce6d9eb8
comparison
equal deleted inserted replaced
70:4bc56e88e1f3 71:75de5903355c
15 buffer[buffer_pos++] = from[i]; 15 buffer[buffer_pos++] = from[i];
16 } 16 }
17 return buffer; 17 return buffer;
18 } 18 }
19 19
20 int32 Dowa_String_Pos_Find(const char *from, const char *value, const size_t from_length, const size_t value_length)
21 {
22 if (value == NULL || from == NULL)
23 return -1;
20 24
25 for (int32 i = 0; i < from_length - value_length; i++)
26 {
27 if (from[i] == value[0])
28 {
29 int32 j = 0;
30 while (j < value_length && value[j] == from[i+j])
31 j++;
21 32
33 if (j == value_length)
34 return i;
35 }
36 }
37 return -1;
38 }
39
40 char *Dowa_String_Find(const char *from, const char *value, const size_t from_length, const size_t value_length)
41 {
42 if (value == NULL || from == NULL)
43 return NULL;
44
45 for (int32 i = 0; i < from_length - value_length; i++)
46 {
47 if (from[i] == value[0])
48 {
49 int32 j = 0;
50 while (j < value_length && value[j] == from[i+j])
51 j++;
52
53 if (j == value_length)
54 return &from[i];
55 }
56 }
57 return NULL;
58 }
59
60 int32 Dowa_String_Pos_Find_Char(const char *from, int c, int32 from_len)
61 {
62 if (!from || from_len == 0)
63 return -1;
64
65 for (int32 i = 0; i < from_len; i++)
66 {
67 if ((int)from[i] == c)
68 return i;
69 }
70 return -1;
71 }
72
73 char *Dowa_String_Find_Char(const char *from, int c, int32 from_len)
74 {
75 if (!from || from_len == 0)
76 return NULL;
77
78 for (int32 i = 0; i < from_len; i++)
79 {
80 if ((int)from[i] == c)
81 return &from[i];
82 }
83 return NULL ;
84 }
85
86 // char **Dowa_String_Split(char *from, char *split_token, int32 from_length, int32 split_token_length)
87 // {
88 // char *current_from = from;
89 // int32 moved = 0;
90 // while (1)
91 // {
92 // int32 next_token = Dowa_String_Pos_Find(
93 // current_from, split_token, from_length - moved, split_token_length
94 // );
95 //
96 // if (next_token == -1)
97 // {
98 // break;
99 // }
100 // char *curr = malloc(sizeof(char) * next_token);
101 // while (i < next_token)
102 // curr[i++] = from[i];
103 // }
104 // }