From 22f2b6a44d670039c7dca399e665ad115bd8436d Mon Sep 17 00:00:00 2001 From: Linnnus Date: Mon, 12 Feb 2024 16:39:22 +0100 Subject: feat: Change suffixes when converting --- src/strutil.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/strutil.h') diff --git a/src/strutil.h b/src/strutil.h index 03f8294..f00acb3 100644 --- a/src/strutil.h +++ b/src/strutil.h @@ -23,4 +23,13 @@ char *joinpath(struct arena *a, const char *path_a, const char *path_b); // Returns boolean indicating if `haystack` ends with `needle`. bool endswith(const char *haystack, const char *needle); +// Replaces the last occurence of `suffix` with `with`. +// Does NOT check that `orig` ends with `suffix`. +// Result is allocated in arena. +char *replace_suffix(struct arena *a, const char *orig, const char *suffix, const char *with); + +// Replace all occurences of `rep` in `orig` with `with`. +// Result is allocated in arena. +char *replace(struct arena *a, const char *orig, const char *rep, const char *with); + #endif -- cgit v1.2.3