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 65987 - There is no g_strreplace() function in glib.
There is no g_strreplace() function in glib.
Status: RESOLVED WONTFIX
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
: 665763 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2001-12-02 19:40 UTC by Jarred Keuch
Modified: 2014-05-10 20:32 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
proposed patch (1.17 KB, patch)
2004-08-18 14:26 UTC, Tim-Philipp Müller
none Details | Review
new patch (2.49 KB, patch)
2004-08-19 09:14 UTC, Tim-Philipp Müller
none Details | Review

Description Jarred Keuch 2001-12-02 19:40:59 UTC
There should be a g_strreplace() function in the glib library.  Kudos to
Elliot!  Those are the types of functions that need to be in a decent
string handling library.  For instance, I'm developing a database
application that needs to replace ' with '' in the query before submitting
it to the database.  The following should be included in gstrfuncs.c.  This
may not be the most efficient way to write it, but it works for me and will
benefit from any improvements to g_strjoinv or g_strsplit.

gchar *
g_strreplace (gchar * string, gchar * search, gchar * replace)
{
	return (g_strjoinv (replace, g_strsplit (string, search, -1)));
}

PS - Keep up the good work!  Thanks!
Comment 1 Tim-Philipp Müller 2004-08-18 14:26:46 UTC
Created attachment 30701 [details] [review]
proposed patch 

Patch implements g_strreplace() as suggested (without the leak and with some
parameter checking though).

Cheers
 -Tim
Comment 2 Tim-Philipp Müller 2004-08-19 09:14:47 UTC
Created attachment 30743 [details] [review]
new patch

Forgot to put prototype into header file; patch also adds a couple of simple
tests now.

Cheers
 -Tim
Comment 3 Matthias Clasen 2004-08-26 16:59:08 UTC
I'm not convinced this kind of oneline function adds sufficient benefit. I'd
rather see a more general regexp api which would include string replacement.
Comment 4 Sébastien Wilmet 2014-05-10 20:32:41 UTC
*** Bug 665763 has been marked as a duplicate of this bug. ***