util/UriUtil: make variables more local

This commit is contained in:
Max Kellermann 2015-11-06 09:43:44 +01:00
parent c880099deb
commit 7640d333f4

View File

@ -74,8 +74,6 @@ uri_get_suffix(const char *uri, UriSuffixBuffer &buffer)
static const char *
verify_uri_segment(const char *p)
{
const char *q;
unsigned dots = 0;
while (*p == '.') {
++p;
@ -85,7 +83,7 @@ verify_uri_segment(const char *p)
if (dots <= 2 && (*p == 0 || *p == '/'))
return nullptr;
q = strchr(p + 1, '/');
const char *q = strchr(p + 1, '/');
return q != nullptr ? q : "";
}
@ -109,8 +107,7 @@ uri_safe_local(const char *uri)
std::string
uri_remove_auth(const char *uri)
{
const char *auth, *slash, *at;
const char *auth;
if (memcmp(uri, "http://", 7) == 0)
auth = uri + 7;
else if (memcmp(uri, "https://", 8) == 0)
@ -121,11 +118,11 @@ uri_remove_auth(const char *uri)
/* unrecognized URI */
return std::string();
slash = strchr(auth, '/');
const char *slash = strchr(auth, '/');
if (slash == nullptr)
slash = auth + strlen(auth);
at = (const char *)memchr(auth, '@', slash - auth);
const char *at = (const char *)memchr(auth, '@', slash - auth);
if (at == nullptr)
/* no auth info present, do nothing */
return std::string();