[Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Fri, Oct 05, 2001 at 04:36:58PM -0400, Justin Moore wrote:
>
> Wow. Ya disappear for a week or two and come back to a flamefest
> between Ross and Raimar. But I can't really say that I'm surprised. :)
>
> > > >> split should treat the buffer it was handed as working memory, return
> > > >> pointers into the parsed string elements, and let the caller deal with
> > > >> ALL memory issues.
> > > >
> > > >Ok since there is so much resistance: we implement the strdup/free in
> > > >split if it turns out that every caller of split will copy the string
> > > >because it is needed later. Ok?
> > >
> > > A better way is to just implement split to take a buffer and do its
> > > splitting thing in a reasonable and efficient manner.
> >
> > There should be a big fat comment about the lifetime of the result and
> > memory issues if split() is be done this way.
>
> I'll comment split to indicate that is has strtok-like changing of the
> buffer you pass to it. As for the whitespace issue, for sake of speed and
> coding simplicity, I'm going with Raimar's suggestion for enums that get
> passed to split. Hence, the current (final) API is:
>
> int split(const char *toks, char *buf, char *args[], int max_args,
> int handle_whitespace);
s/toks/delimeters/
s/args/tokens/ or s/args/items/
> where handle_whitespace could be
>
> #define REMOVE_NO_WHITESPACE 0x0
> #define REMOVE_PADDING_WHITESPACE 0x1
> #define REMOVE_SPLIT_WHITESPACE 0x2
REMOVE and SPLIT? Isn't this SPLIT_ON_WHITESPACE?
Overall it isn't a true enum.
> unless someone has better ideas for names. (And, no, I can't believe I
> just asked an open question like that.)
;)
> I'll work on the server parsing stuff when I get a chance. I plan to
> overhaul the basic framework, and people can take it from there as to how
> specific functions will be implemented.
I will wait with the inclusion of the split method till there is a
user.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"Despite all the medical advances of the 20th century, the mortality
rate remains unchanged at 1 death per person."
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs), Justin Moore, 2001/10/05
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs),
Raimar Falke <=
- [Freeciv-Dev] Server Overhaul (was Re: Re: Split patch), Justin Moore, 2001/10/18
- [Freeciv-Dev] Re: Server Overhaul (was Re: Re: Split patch), Raimar Falke, 2001/10/19
- [Freeciv-Dev] Re: Server Overhaul (was Re: Re: Split patch), Justin Moore, 2001/10/19
- [Freeciv-Dev] Re: Server Overhaul (was Re: Re: Split patch), Raimar Falke, 2001/10/19
- [Freeciv-Dev] Re: Server Overhaul (was Re: Re: Split patch), Arien Malec, 2001/10/19
- [Freeciv-Dev] Re: Server Overhaul (was Re: Re: Split patch), Justin Moore, 2001/10/19
- [Freeciv-Dev] Re: Server Overhaul (was Re: Re: Split patch), Raimar Falke, 2001/10/22
- [Freeciv-Dev] Re: Server Overhaul (was Re: Re: Split patch), Daniel Sjölie, 2001/10/22
- [Freeciv-Dev] Re: Server Overhaul (was Re: Re: Split patch), Daniel L Speyer, 2001/10/22
- [Freeciv-Dev] Re: Server Overhaul (was Re: Re: Split patch), Justin Moore, 2001/10/22
|
|