[Freeciv-Dev] Re: new natural names patch (PR#1127)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Since the operation is destructive already, why not memmove the
contents to the beginning of the input address? As it stands, the
return param has to save off an additional pointer or strdup the value
anyway--no re-using the input param. So it is more like,
trim-and-copy than just trim.
Secondly, passing in a string that is str[0] = '\0' will blow-up your
reverse processing--you'll underrun your buffer with the str--;.
Cheers,
cjr
> /**************************************************************************
> + This strips leading and trailing whitespace from a string.
> +
> + Surely this capability is provided by some other source???
> +**************************************************************************/
> +static char* strip_space(char* str)
> +{
> + char* start;
> + while(isspace(*str)) {
> + str++;
> + }
> + start = str;
> + while(*str) {
> + str++;
> + }
> + str--;
> + while(isspace(*str)) {
> + *str = 0;
> + str--;
> + }
> + return start;
> +}
- [Freeciv-Dev] new natural names patch (PR#1127), jdorje, 2001/12/21
- [Freeciv-Dev] Re: new natural names patch (PR#1127), Gregory Berkolaiko, 2001/12/21
- [Freeciv-Dev] Re: new natural names patch (PR#1127), Jason Short, 2001/12/21
- [Freeciv-Dev] Re: new natural names patch (PR#1127),
Chris Richards <=
- [Freeciv-Dev] Re: new natural names patch (PR#1127), Jason Short, 2001/12/22
- [Freeciv-Dev] Re: new natural names patch (PR#1127), Erik Sigra, 2001/12/22
- [Freeciv-Dev] Re: new natural names patch (PR#1127), Gregory Berkolaiko, 2001/12/22
- [Freeciv-Dev] Re: new natural names patch (PR#1127), Chris Richards, 2001/12/22
- [Freeciv-Dev] Re: new natural names patch (PR#1127), Erik Sigra, 2001/12/23
- [Freeciv-Dev] Re: new natural names patch (PR#1127), Petr Baudis, 2001/12/23
- [Freeciv-Dev] Re: new natural names patch (PR#1127), Erik Sigra, 2001/12/23
- [Freeciv-Dev] Re: new natural names patch (PR#1127), Petr Baudis, 2001/12/23
- [Freeciv-Dev] Re: new natural names patch (PR#1127), Erik Sigra, 2001/12/23
- [Freeciv-Dev] Re: new natural names patch (PR#1127), Jason Short, 2001/12/23
|
|