Added conditional compilation and Const namespace with OS name

This commit is contained in:
Krzosa Karol
2022-10-08 10:02:50 +02:00
parent ed98572547
commit 15e4ebd682
13 changed files with 201 additions and 129 deletions

View File

@@ -476,9 +476,22 @@ struct String_Replace {
String replace;
};
// function String
// string_replace(String string, Array<String_Replace> pairs){
// for(int i = 0; i < string.len; i++){
function String
string_replace(Arena *arena, String string, Array<String_Replace> pairs){
Scratch scratch(arena);
String_Builder builder = {scratch};
for(int i = 0; i < string.len; i++){
For(pairs){
String current = string_skip(string, i);
current = string_get_prefix(current, it.find.len);
if(current == it.find){
builder.append_data(it.replace.str, it.replace.len);
i += it.find.len;
continue;
}
}
// }
// }
builder.append_data(string.str + i, 1);
}
return string_flatten(arena, &builder);
}