After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 665763 - String Replace Functions
String Replace Functions
Status: RESOLVED DUPLICATE of bug 65987
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2011-12-08 03:01 UTC by Kevin Anthony
Modified: 2014-05-10 20:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to add functionality (3.32 KB, patch)
2011-12-08 03:02 UTC, Kevin Anthony
none Details | Review
Fixed a bug in the initial code (3.41 KB, patch)
2011-12-19 03:08 UTC, Kevin Anthony
needs-work Details | Review
Fixed problems brought up by Stefan Sauer, streamlined the code a little (3.97 KB, patch)
2011-12-20 01:51 UTC, Kevin Anthony
none Details | Review

Description Kevin Anthony 2011-12-08 03:01:32 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.
Comment 1 Kevin Anthony 2011-12-08 03:02:17 UTC
Created attachment 203039 [details] [review]
Patch to add functionality
Comment 2 Kevin Anthony 2011-12-19 03:08:02 UTC
Created attachment 203821 [details] [review]
Fixed a bug in the initial code
Comment 3 Stefan Sauer (gstreamer, gtkdoc dev) 2011-12-19 22:58:27 UTC
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
Comment 4 Kevin Anthony 2011-12-20 01:51:01 UTC
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
Comment 5 Sébastien Wilmet 2014-05-10 20:32:41 UTC

*** This bug has been marked as a duplicate of bug 65987 ***