mirror of
https://github.com/mirror/wget.git
synced 2025-03-31 06:30:12 +08:00
[svn] In uri_merge, skip separators appropriate for the scheme when looking
for end of path.
This commit is contained in:
parent
9feafc0d78
commit
cfec85440d
@ -1,3 +1,9 @@
|
|||||||
|
2005-07-03 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
|
* url.c (path_end): Skip separators appropriate for the scheme.
|
||||||
|
(strpbrk_or_eos): Remove gcc-specific version, as the optimization
|
||||||
|
it tried to perform no longer applies.
|
||||||
|
|
||||||
2005-07-02 Hrvoje Niksic <hniksic@xemacs.org>
|
2005-07-02 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
* host.c: Don't include "connect.h" now that we no longer have
|
* host.c: Don't include "connect.h" now that we no longer have
|
||||||
|
41
src/url.c
41
src/url.c
@ -576,26 +576,7 @@ static void split_path (const char *, char **, char **);
|
|||||||
|
|
||||||
/* Like strpbrk, with the exception that it returns the pointer to the
|
/* Like strpbrk, with the exception that it returns the pointer to the
|
||||||
terminating zero (end-of-string aka "eos") if no matching character
|
terminating zero (end-of-string aka "eos") if no matching character
|
||||||
is found.
|
is found. */
|
||||||
|
|
||||||
Although I normally balk at Gcc-specific optimizations, it probably
|
|
||||||
makes sense here: glibc has optimizations that detect strpbrk being
|
|
||||||
called with literal string as ACCEPT and inline the search. That
|
|
||||||
optimization is defeated if strpbrk is hidden within the call to
|
|
||||||
another function. (And no, making strpbrk_or_eos inline doesn't
|
|
||||||
help because the check for literal accept is in the
|
|
||||||
preprocessor.) */
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
|
||||||
|
|
||||||
#define strpbrk_or_eos(s, accept) ({ \
|
|
||||||
char *SOE_p = strpbrk (s, accept); \
|
|
||||||
if (!SOE_p) \
|
|
||||||
SOE_p = strchr (s, '\0'); \
|
|
||||||
SOE_p; \
|
|
||||||
})
|
|
||||||
|
|
||||||
#else /* not __GNUC__ or old gcc */
|
|
||||||
|
|
||||||
static inline char *
|
static inline char *
|
||||||
strpbrk_or_eos (const char *s, const char *accept)
|
strpbrk_or_eos (const char *s, const char *accept)
|
||||||
@ -605,7 +586,6 @@ strpbrk_or_eos (const char *s, const char *accept)
|
|||||||
p = strchr (s, '\0');
|
p = strchr (s, '\0');
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
#endif /* not __GNUC__ or old gcc */
|
|
||||||
|
|
||||||
/* Turn STR into lowercase; return true if a character was actually
|
/* Turn STR into lowercase; return true if a character was actually
|
||||||
changed. */
|
changed. */
|
||||||
@ -1605,14 +1585,19 @@ path_simplify (char *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Return the length of URL's path. Path is considered to be
|
/* Return the length of URL's path. Path is considered to be
|
||||||
terminated by one of '?', ';', '#', or by the end of the
|
terminated by one or more of the ?query or ;params or #fragment,
|
||||||
string. */
|
depending on the scheme. */
|
||||||
|
|
||||||
static int
|
static const char *
|
||||||
path_length (const char *url)
|
path_end (const char *url)
|
||||||
{
|
{
|
||||||
const char *q = strpbrk_or_eos (url, "?;#");
|
enum url_scheme scheme = url_scheme (url);
|
||||||
return q - url;
|
const char *seps;
|
||||||
|
if (scheme == SCHEME_INVALID)
|
||||||
|
scheme = SCHEME_HTTP; /* use http semantics for rel links */
|
||||||
|
/* +2 to ignore the first two separators ':' and '/' */
|
||||||
|
seps = init_seps (scheme) + 2;
|
||||||
|
return strpbrk_or_eos (url, seps);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find the last occurrence of character C in the range [b, e), or
|
/* Find the last occurrence of character C in the range [b, e), or
|
||||||
@ -1651,7 +1636,7 @@ uri_merge (const char *base, const char *link)
|
|||||||
return xstrdup (link);
|
return xstrdup (link);
|
||||||
|
|
||||||
/* We may not examine BASE past END. */
|
/* We may not examine BASE past END. */
|
||||||
end = base + path_length (base);
|
end = path_end (base);
|
||||||
linklength = strlen (link);
|
linklength = strlen (link);
|
||||||
|
|
||||||
if (!*link)
|
if (!*link)
|
||||||
|
Loading…
Reference in New Issue
Block a user