summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorportix <none@none>2012-05-02 21:24:13 +0200
committerportix <none@none>2012-05-02 21:24:13 +0200
commit10b9f164ec97cbfc1b9e3f345007320d4ec03e55 (patch)
tree7e1b7cc067bc45ca9a57753c5bb92659a08ad394 /src/util.c
parentd3d8fc701841fab001e55b3a4ee9deb69b419e3e (diff)
downloaddwb-10b9f164ec97cbfc1b9e3f345007320d4ec03e55.zip
Use g_regex_replace_literal in util_string_replace; always replace referer
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/util.c b/src/util.c
index 8c0ffb4b..6259aef1 100644
--- a/src/util.c
+++ b/src/util.c
@@ -37,12 +37,12 @@ util_get_temp_filename(const char *prefix) {
return cache_path;
}
char *
-util_string_replace(const char *haystack, const char *needle, const char *replacemant) {
- char **token;
+util_string_replace(const char *haystack, const char *needle, const char *replacement) {
char *ret = NULL;
- if ( haystack && needle && (token = g_regex_split_simple(needle, haystack, 0, 0)) && g_strcmp0(token[0], haystack)) {
- ret = g_strconcat(token[0], replacemant, token[1], NULL);
- g_strfreev(token);
+ if ( haystack && needle) { //&& (token = g_regex_split_simple(needle, haystack, 0, 0)) && g_strcmp0(token[0], haystack)) {
+ GRegex *regex = g_regex_new(needle, 0, 0, NULL);
+ ret = g_regex_replace_literal(regex, haystack, -1, 0, replacement, 0, NULL);
+ g_regex_unref(regex);
}
return ret;
}/*}}}*/