/* if there are only $0 placeholders we don't need to split the parameters */
if (max_num == 0) {
quoted_param = soup_uri_encode(query, "&");
- uri = util_str_replace("$0", quoted_param, tmpl, -1);
+ uri = util_str_replace("$0", quoted_param, tmpl);
g_free(quoted_param);
return uri;
char *new;
quoted_param = soup_uri_encode(token->str, "&");
- new = util_str_replace((char[]){'$', current_num + '0', '\0'}, quoted_param, uri, -1);
+ new = util_str_replace((char[]){'$', current_num + '0', '\0'}, quoted_param, uri);
g_free(quoted_param);
g_free(uri);
uri = new;
* Replaces appearances of search in string by given replace.
* Returne a new allocated string if search was found.
*/
-char *util_str_replace(const char* search, const char* replace, const char* string, int max_replaces)
+char *util_str_replace(const char* search, const char* replace, const char* string)
{
if (!string) {
return NULL;
}
- char **buf = g_strsplit(string, search, max_replaces + 1);
+ char **buf = g_strsplit(string, search, -1);
char *ret = g_strjoinv(replace, buf);
g_strfreev(buf);
gboolean util_file_append(const char *file, const char *format, ...);
gboolean util_file_prepend(const char *file, const char *format, ...);
char* util_strcasestr(const char* haystack, const char* needle);
-char *util_str_replace(const char* search, const char* replace, const char* string, int max_replaces);
+char *util_str_replace(const char* search, const char* replace, const char* string);
gboolean util_create_tmp_file(const char *content, char **file);
char *util_build_path(const char *path, const char *dir);
char *util_expand(const char *src, int expflags);