Added conditional compilation and Const namespace with OS name
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user