Commit bb8a0580 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

urlmon: Reduce indention in are_equal_simple and move it.

parent f38e0be5
......@@ -428,104 +428,6 @@ static inline BOOL is_hierarchical_uri(const WCHAR **ptr, const parse_data *data
return FALSE;
}
/* Checks if the two Uri's are logically equivalent. It's a simple
* comparison, since they are both of type Uri, and it can access
* the properties of each Uri directly without the need to go
* through the "IUri_Get*" interface calls.
*/
static BOOL are_equal_simple(const Uri *a, const Uri *b) {
if(a->scheme_type == b->scheme_type) {
const BOOL known_scheme = a->scheme_type != URL_SCHEME_UNKNOWN;
const BOOL are_hierarchical =
(a->authority_start > -1 && b->authority_start > -1);
if(a->scheme_type == URL_SCHEME_FILE) {
if(a->canon_len == b->canon_len)
return !StrCmpIW(a->canon_uri, b->canon_uri);
}
/* Only compare the scheme names (if any) if their unknown scheme types. */
if(!known_scheme) {
if((a->scheme_start > -1 && b->scheme_start > -1) &&
(a->scheme_len == b->scheme_len)) {
/* Make sure the schemes are the same. */
if(StrCmpNW(a->canon_uri+a->scheme_start, b->canon_uri+b->scheme_start, a->scheme_len))
return FALSE;
} else if(a->scheme_len != b->scheme_len)
/* One of the Uri's has a scheme name, while the other doesn't. */
return FALSE;
}
/* If they have a userinfo component, perform case sensitive compare. */
if((a->userinfo_start > -1 && b->userinfo_start > -1) &&
(a->userinfo_len == b->userinfo_len)) {
if(StrCmpNW(a->canon_uri+a->userinfo_start, b->canon_uri+b->userinfo_start, a->userinfo_len))
return FALSE;
} else if(a->userinfo_len != b->userinfo_len)
/* One of the Uri's had a userinfo, while the other one doesn't. */
return FALSE;
/* Check if they have a host name. */
if((a->host_start > -1 && b->host_start > -1) &&
(a->host_len == b->host_len)) {
/* Perform a case insensitive compare if they are a known scheme type. */
if(known_scheme) {
if(StrCmpNIW(a->canon_uri+a->host_start, b->canon_uri+b->host_start, a->host_len))
return FALSE;
} else if(StrCmpNW(a->canon_uri+a->host_start, b->canon_uri+b->host_start, a->host_len))
return FALSE;
} else if(a->host_len != b->host_len)
/* One of the Uri's had a host, while the other one didn't. */
return FALSE;
if(a->has_port && b->has_port) {
if(a->port != b->port)
return FALSE;
} else if(a->has_port || b->has_port)
/* One had a port, while the other one didn't. */
return FALSE;
/* Windows is weird with how it handles paths. For example
* One URI could be "http://google.com" (after canonicalization)
* and one could be "http://google.com/" and the IsEqual function
* would still evaluate to TRUE, but, only if they are both hierarchical
* URIs.
*/
if((a->path_start > -1 && b->path_start > -1) &&
(a->path_len == b->path_len)) {
if(StrCmpNW(a->canon_uri+a->path_start, b->canon_uri+b->path_start, a->path_len))
return FALSE;
} else if(are_hierarchical && a->path_len == -1 && b->path_len == 0) {
if(*(a->canon_uri+a->path_start) != '/')
return FALSE;
} else if(are_hierarchical && b->path_len == 1 && a->path_len == 0) {
if(*(b->canon_uri+b->path_start) != '/')
return FALSE;
} else if(a->path_len != b->path_len)
return FALSE;
/* Compare the query strings of the two URIs. */
if((a->query_start > -1 && b->query_start > -1) &&
(a->query_len == b->query_len)) {
if(StrCmpNW(a->canon_uri+a->query_start, b->canon_uri+b->query_start, a->query_len))
return FALSE;
} else if(a->query_len != b->query_len)
return FALSE;
if((a->fragment_start > -1 && b->fragment_start > -1) &&
(a->fragment_len == b->fragment_len)) {
if(StrCmpNW(a->canon_uri+a->fragment_start, b->canon_uri+b->fragment_start, a->fragment_len))
return FALSE;
} else if(a->fragment_len != b->fragment_len)
return FALSE;
/* If we get here, the two URIs are equivalent. */
return TRUE;
}
return FALSE;
}
/* Computes the size of the given IPv6 address.
* Each h16 component is 16 bits. If there is an IPv4 address, it's
* 32 bits. If there's an elision it can be 16 to 128 bits, depending
......@@ -3963,6 +3865,102 @@ static HRESULT validate_components(const UriBuilder *builder, parse_data *data,
return S_OK;
}
/* Checks if the two Uri's are logically equivalent. It's a simple
* comparison, since they are both of type Uri, and it can access
* the properties of each Uri directly without the need to go
* through the "IUri_Get*" interface calls.
*/
static BOOL are_equal_simple(const Uri *a, const Uri *b) {
const BOOL known_scheme = a->scheme_type != URL_SCHEME_UNKNOWN;
const BOOL are_hierarchical = a->authority_start > -1 && b->authority_start > -1;
if(a->scheme_type != b->scheme_type)
return FALSE;
if(a->scheme_type == URL_SCHEME_FILE) {
if(a->canon_len == b->canon_len)
return !StrCmpIW(a->canon_uri, b->canon_uri);
}
/* Only compare the scheme names (if any) if their unknown scheme types. */
if(!known_scheme) {
if((a->scheme_start > -1 && b->scheme_start > -1) &&
(a->scheme_len == b->scheme_len)) {
/* Make sure the schemes are the same. */
if(StrCmpNW(a->canon_uri+a->scheme_start, b->canon_uri+b->scheme_start, a->scheme_len))
return FALSE;
} else if(a->scheme_len != b->scheme_len)
/* One of the Uri's has a scheme name, while the other doesn't. */
return FALSE;
}
/* If they have a userinfo component, perform case sensitive compare. */
if((a->userinfo_start > -1 && b->userinfo_start > -1) &&
(a->userinfo_len == b->userinfo_len)) {
if(StrCmpNW(a->canon_uri+a->userinfo_start, b->canon_uri+b->userinfo_start, a->userinfo_len))
return FALSE;
} else if(a->userinfo_len != b->userinfo_len)
/* One of the Uri's had a userinfo, while the other one doesn't. */
return FALSE;
/* Check if they have a host name. */
if((a->host_start > -1 && b->host_start > -1) &&
(a->host_len == b->host_len)) {
/* Perform a case insensitive compare if they are a known scheme type. */
if(known_scheme) {
if(StrCmpNIW(a->canon_uri+a->host_start, b->canon_uri+b->host_start, a->host_len))
return FALSE;
} else if(StrCmpNW(a->canon_uri+a->host_start, b->canon_uri+b->host_start, a->host_len))
return FALSE;
} else if(a->host_len != b->host_len)
/* One of the Uri's had a host, while the other one didn't. */
return FALSE;
if(a->has_port && b->has_port) {
if(a->port != b->port)
return FALSE;
} else if(a->has_port || b->has_port)
/* One had a port, while the other one didn't. */
return FALSE;
/* Windows is weird with how it handles paths. For example
* One URI could be "http://google.com" (after canonicalization)
* and one could be "http://google.com/" and the IsEqual function
* would still evaluate to TRUE, but, only if they are both hierarchical
* URIs.
*/
if((a->path_start > -1 && b->path_start > -1) &&
(a->path_len == b->path_len)) {
if(StrCmpNW(a->canon_uri+a->path_start, b->canon_uri+b->path_start, a->path_len))
return FALSE;
} else if(are_hierarchical && a->path_len == -1 && b->path_len == 0) {
if(*(a->canon_uri+a->path_start) != '/')
return FALSE;
} else if(are_hierarchical && b->path_len == 1 && a->path_len == 0) {
if(*(b->canon_uri+b->path_start) != '/')
return FALSE;
} else if(a->path_len != b->path_len)
return FALSE;
/* Compare the query strings of the two URIs. */
if((a->query_start > -1 && b->query_start > -1) &&
(a->query_len == b->query_len)) {
if(StrCmpNW(a->canon_uri+a->query_start, b->canon_uri+b->query_start, a->query_len))
return FALSE;
} else if(a->query_len != b->query_len)
return FALSE;
if((a->fragment_start > -1 && b->fragment_start > -1) &&
(a->fragment_len == b->fragment_len)) {
if(StrCmpNW(a->canon_uri+a->fragment_start, b->canon_uri+b->fragment_start, a->fragment_len))
return FALSE;
} else if(a->fragment_len != b->fragment_len)
return FALSE;
/* If we get here, the two URIs are equivalent. */
return TRUE;
}
static void convert_to_dos_path(const WCHAR *path, DWORD path_len,
WCHAR *output, DWORD *output_len)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment