Re: Upcoming GLib changes



Should I add functions to GRegex for matching patterns in
GStrings, not just in gchar*s?

Basically, add the following to the GRegex library:
gint g_regex_match(GRegex * regex, GString * string);
gint g_regex_match_next(GRegex * regex, GString * string);
GList  * g_regex_split(gchar * pattern, GString * string, 
                       gchar * options, gint max_pieces);
GSList * g_regex_split_gslist(gchar * pattern, GString * string, 
                              gchar * options, gint max_pieces);
gchar * g_regex_split_next(GRegex * regex, GString * string);
gchar * g_regex_replace(GRegex * regex, GString * string, 
                        GString * replacement);
gchar * g_regex_replace_e(GRegex * regex, GString * string, 
                          GRegexEvalCallback eval, gpointer user_data);


GRegex lives at:
http://dev.cgibuilder.com/scottw/code/g_regex/

I know that GRegex isn't in Glib currently, but I suspect that it 
soon will be.

Regards,
scottwimer

On 1 Jul 1999, Owen Taylor wrote:

> 
> Trog <trog@gtk.org> writes:
> 
> > On 30-Jun-99 Tim Janik wrote:
> > > On Wed, 30 Jun 1999, Trog wrote:
> > > 
> > >> 
> > >> > GString
> > 
> > I don't disagree with anything you've said, given the position you
> > are saying it from. I do, however, disagree with your position. It is
> > desirable to use strings as a mechanism for reducing (or eliminating)
> > buffer overflow problems. That is why most people do a strings
> > implementation. GLib does not provide that - and your position is
> > that it shouldn't aim to. This, unfortunately, also makes the strings
> > implemenation virtually worthless, as I don't think that anyone will
> > use it as a consequence of that position.
> 
> The current GString implementation is meant to be used where buffer
> overflows are a problem - when one is taking bits of strings, adding
> characters, etc.  When you are just passing around strings, overflow
> is not a problem, so one might as well pass a char *.
> 
> There are a few missing functions that we need to add to make GString
> really useful - the one I tend to miss is:
> 
>  g_string_insert_n (GString *string, gchar *new, gint n);
>  
> But I don't think we need to wrap every single thing that you can do
> with a char * with a GString.  The conversions are easy enough.
> 
> Conversion from GString => gchar *
>   
>  string->str
> 
> Conversion from gchar * => GString
> 
>  g_string_new (str);
> 
> > Even gtk+ hardly uses the current implementation.
> 
> It's not like GTK+ is very heavy on string manipulation.
> A lot (though not all) of the places that could 
> benefit from GString do use it.
> 
> Regards,
>                                         Owen
> 
> 
> -- 
>          To unsubscribe: mail gtk-devel-list-request@redhat.com with 
>                        "unsubscribe" as the Subject.
> 

--
Scott Wimer
Play:   scottw@cgibuilder.com        www.cgibuilder.com
Work:   scottw@corp.earthlink.net    www.earthlink.net



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]