Show 45 quoted lines
>
> Christian Couder <christian.couder@gmail.com> writes:
>
> > +static bool match_one_url(const struct url_info *pi, const struct url_info *ui)
> > +{
> > + const char *pat = pi->url;
> > + const char *url = ui->url;
> > + char *p_str, *u_str;
> > + bool res;
> > +
> > + /*
> > + * Schemes must match exactly. They are case-folded by
> > + * url_normalize(), so strncmp() suffices.
> > + */
> > + if (pi->scheme_len != ui->scheme_len || strncmp(pat, url, pi->scheme_len))
> > + return false;
> > +
> > + /*
> > + * Ports must match exactly. url_normalize() strips default
> > + * ports (like 443 for https), so length and content
> > + * comparisons are sufficient.
> > + */
> > + if (pi->port_len != ui->port_len ||
> > + strncmp(pat + pi->port_off, url + ui->port_off, pi->port_len))
> > + return false;
> > +
> > + /*
> > + * Match host and path separately to prevent a '*' in the host
> > + * portion of the pattern from matching across the '/'
> > + * boundary into the path. Use WM_PATHNAME for the host so '*'
> > + * cannot cross '/' there, and 0 for the path so '*' can still
> > + * match multi-level paths.
> > + */
> > +
> > + p_str = xstrndup(pat + pi->host_off, pi->host_len);
> > + u_str = xstrndup(url + ui->host_off, ui->host_len);
> > + res = !wildmatch(p_str, u_str, WM_PATHNAME);
> > + free(p_str);
> > + free(u_str);
> > +
> > + if (!res)
>
> I feel it's a bit confusing your negating the result from wildmatch()
> to negate it here again? Maybe keep using the int return value, or
> rename the variable to 'matches' ?