On Oct 23, 2011, at 3:19 PM, s...@apache.org wrote:

>         else if (r->content_type) {
>             const char **type = provider->types;
>             AP_DEBUG_ASSERT(type != NULL);
>             while (*type) {
> -                if (strcmp(*type, r->content_type) == 0) {
> +                /* Handle 'content-type;charset=...' correctly */
> +                size_t len = strcspn(r->content_type, "; \t");
> +                if (strlen(*type) == len
> +                    && strncmp(*type, r->content_type, len) == 0) {
>                     match = 1;
>                     break;
>                 }
>                 type++;
>             }

Wouldn't this be faster as

        else if (r->content_type) {
+           /* Handle 'content-type;charset=...' correctly */
+           size_t len = strcspn(r->content_type, "; \t");
            const char **type = provider->types;
            AP_DEBUG_ASSERT(type != NULL);
            while (*type) {
+                if ((strncmp(*type, r->content_type, len) == 0) &&
+                    (*type[len] == '\0')) {
                    match = 1;
                    break;
                }
                type++;
            }

or am I just trying to outwit the compiler?

....Roy

Reply via email to