diff options
author | portix <none@none> | 2012-05-02 21:24:13 +0200 |
---|---|---|
committer | portix <none@none> | 2012-05-02 21:24:13 +0200 |
commit | 10b9f164ec97cbfc1b9e3f345007320d4ec03e55 (patch) | |
tree | 7e1b7cc067bc45ca9a57753c5bb92659a08ad394 /src/util.c | |
parent | d3d8fc701841fab001e55b3a4ee9deb69b419e3e (diff) | |
download | dwb-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.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -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; }/*}}}*/ |