Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2001:
[Freeciv-Dev] Re: new natural names patch (PR#1127)
Home

[Freeciv-Dev] Re: new natural names patch (PR#1127)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: new natural names patch (PR#1127)
From: Chris Richards <chrisr@xxxxxxxxxxxxxxxx>
Date: 22 Dec 2001 00:44:19 -0600

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;
> +}


[Prev in Thread] Current Thread [Next in Thread]