GNOME Bugzilla – Bug 665763
String Replace Functions
Last modified: 2014-05-10 20:32:41 UTC
Added String Replace Functions in gstrfunc called g_strreplace and g_strnreplace both take original string, search string, replace string, all of which are untouched. g_strnreplace takes an gint also, and only replaces the first n occurrences of the search string. Returns a newly allocated string.
Created attachment 203039 [details] [review] Patch to add functionality
Created attachment 203821 [details] [review] Fixed a bug in the initial code
Review of attachment 203821 [details] [review]: I think it is better implemented using GString. Also you need to list the new function in the docs/glib/glib-section.txt file to make them show up in the docs. ::: glib/gstrfuncs.c @@ +2803,3 @@ + * find: the null-terminiated string to find + * replace: the null-terminated string to replace find with + * the api doc blob format is not correct (parameters need a @ infront src -> @src) @@ +2806,3 @@ + * Returns a newly allocated string with all finds replace with replace + * + * find: the null-terminiated string to find imho the docs us Returns: a null ... also mention that it is a newly allocated string and better use the gir-annotations @@ +2808,3 @@ + * Return value: a null-terminiated string + * + * replace: the null-terminated string to replace find with This is wrong. @@ +2824,3 @@ + } +return retval; + please fix indentation and make code look like the other code in the library
Created attachment 203923 [details] [review] Fixed problems brought up by Stefan Sauer, streamlined the code a little I like the idea of GString, i'll do that separately, since if this patch is accepted, i can use these functions in the GString function
*** This bug has been marked as a duplicate of bug 65987 ***