httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject Re: [PATCH] PR#4524 and bare content-types
Date Fri, 04 Jun 1999 16:58:23 GMT
On Thu, 3 Jun 1999, Rodent of Unusual Size wrote:

> +/*
> + * Examine a field value (such as a media-/content-type) string and return
> + * it sans any parameters; e.g., strip off any ';charset=foo' and the like.
> + */
> +API_EXPORT(char *) ap_field_noparm(pool *p, const char *intype)
> +{
> +    char *type;
> +    const char *line;
> +    char *work;
> +
> +    line = intype;
> +    type = ap_getword(p, &line, ';');
> +    work = &type[strlen(type)];
> +    while ((work >= type) && (ap_isspace(*work) || (*work == '\0'))) {
> +	work--;
> +    }
> +    *++work = '\0';
> +    return type;
> +}
> +

I'd be a lot happier with this implementation:

API_EXPORT(const char *) ap_field_noparm(pool *p, const char *intype)
{
    const char *semi;

    semi = strchr(intype, ';');
    if (semi) {
	while (semi > intype && ap_isspace(semi[-1])) {
	    --semi;
	}
	return ap_pstrndup(p, intype, semi - intype);
    }
    return intype;
}

Although it still seems like the wrong way to do it... the right way
would be to have a routine ap_compare_content_type which didn't require
any memory allocation.

Dean


Mime
View raw message