[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 Sat, Sep 22, 2001 at 05:26:05PM -0400, Justin Moore wrote:
>
> /***************************************************************************
> + PERL-like split. Takes a string of characters to split on, a buffer to
> + split, and an array of pointers to return. Can set a max size on the
It returns an int. It may fill/write an array of pointers.
> + number of chunks into which you can split the buffer.
> +
> + NOTE: This WILL change the original buffer, so if you want an original
> + copy of it, make it before you pass it to this function.
Can you please remove this restriction.
> +
> + Return the number of sub-elements found.
> +***************************************************************************/
> +int split(char *toks, char *buf, char **args, int max_args)
Can you please add some consts. Yes I know that const isn't used much
in freeciv. But this method is more like the str* method.
> +{
> + int i;
> + int nfound;
> + int len;
> + char *my_toks;
> +
> + if((buf[0] == '#') || (buf[0] == '\n')) /* Comment or blank line */
> + return 0;
The handling of comments should be in this general purpose method.
> +
> + /* Remove all leading whitespace and toks.
Please mention this in the header.
What about memory management? Who allocates the space for args? The
caller or split? It looks like args are currently pointers to buf. I
don't like this.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"Python is executable pseudocode. Perl is executable line noise"
-- Bruce Eckel
- [Freeciv-Dev] [RFC PATCH] init_techs, Arien Malec, 2001/09/19
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Gregory Berkolaiko, 2001/09/20
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Arien Malec, 2001/09/20
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Justin Moore, 2001/09/20
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Reinier Post, 2001/09/20
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Justin Moore, 2001/09/22
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Raimar Falke, 2001/09/22
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs), Justin Moore, 2001/09/22
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs),
Raimar Falke <=
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs), Justin Moore, 2001/09/23
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs), Raimar Falke, 2001/09/24
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs), Justin Moore, 2001/09/24
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs), Raimar Falke, 2001/09/25
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs), Justin Moore, 2001/09/26
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs), Raimar Falke, 2001/09/26
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs), Justin Moore, 2001/09/26
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs), Ross W. Wetmore, 2001/09/26
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs), Raimar Falke, 2001/09/27
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs), Ross W. Wetmore, 2001/09/27
|
|