Matthew White <[email protected]> writes:

> +void
> +clean_metalink_string (char **str)
> +{
> +  int c;
> +  size_t len;
> +  char *new, *beg, *end;
> +
> +  if (!str || !*str)
> +    return;
> +
> +  beg = *str;
> +
> +  while ((c = *beg) && (c == '\n' || c == '\r' || c == '\t' || c == ' '))
> +    beg++;
> +
> +  end = beg;
> +
> +  /* To not truncate a string containing spaces, search the first '\r'
> +     or '\n' which ipotetically marks the end of the string.  */
> +  while ((c = *end) && (c != '\r') && (c != '\n'))
> +    end++;
> +
> +  /* If we are at the end of the string, search the first legit
> +     character going backward.  */
> +  if (*end == '\0')
> +    while ((c = *(end - 1)) && (c == '\n' || c == '\r' || c == '\t' || c == 
> ' '))
> +      end--;
> +
> +  len = end - beg;
> +
> +  new = xmemdup0 (beg, len);

ACK

Giuseppe

Reply via email to