mirror of
https://github.com/sheumann/hush.git
synced 2024-12-22 14:30:31 +00:00
wget: smallish optimization
This commit is contained in:
parent
6a1d661036
commit
3469c185e5
@ -509,7 +509,7 @@ int wget_main(int argc, char **argv)
|
|||||||
|
|
||||||
static void parse_url(char *src_url, struct host_info *h)
|
static void parse_url(char *src_url, struct host_info *h)
|
||||||
{
|
{
|
||||||
char *url, *p, *cp, *sp, *up, *pp;
|
char *url, *p, *sp;
|
||||||
|
|
||||||
/* h->allocated = */ url = xstrdup(src_url);
|
/* h->allocated = */ url = xstrdup(src_url);
|
||||||
|
|
||||||
@ -542,8 +542,8 @@ static void parse_url(char *src_url, struct host_info *h)
|
|||||||
if (!sp) {
|
if (!sp) {
|
||||||
h->path = "";
|
h->path = "";
|
||||||
} else if (*sp == '/') {
|
} else if (*sp == '/') {
|
||||||
*sp++ = '\0';
|
*sp = '\0';
|
||||||
h->path = sp;
|
h->path = sp + 1;
|
||||||
} else { // '#' or '?'
|
} else { // '#' or '?'
|
||||||
// http://busybox.net?login=john@doe is a valid URL
|
// http://busybox.net?login=john@doe is a valid URL
|
||||||
// memmove converts to:
|
// memmove converts to:
|
||||||
@ -554,35 +554,35 @@ static void parse_url(char *src_url, struct host_info *h)
|
|||||||
h->path = sp;
|
h->path = sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
up = strrchr(h->host, '@');
|
sp = strrchr(h->host, '@');
|
||||||
if (up != NULL) {
|
|
||||||
h->user = h->host;
|
|
||||||
*up++ = '\0';
|
|
||||||
h->host = up;
|
|
||||||
} else
|
|
||||||
h->user = NULL;
|
h->user = NULL;
|
||||||
|
if (sp != NULL) {
|
||||||
|
h->user = h->host;
|
||||||
|
*sp = '\0';
|
||||||
|
h->host = sp + 1;
|
||||||
|
}
|
||||||
|
|
||||||
pp = h->host;
|
sp = h->host;
|
||||||
|
|
||||||
#if ENABLE_FEATURE_WGET_IP6_LITERAL
|
#if ENABLE_FEATURE_WGET_IP6_LITERAL
|
||||||
if (h->host[0] == '[') {
|
if (sp[0] == '[') {
|
||||||
char *ep;
|
char *ep;
|
||||||
|
|
||||||
ep = h->host + 1;
|
ep = sp + 1;
|
||||||
while (*ep == ':' || isxdigit(*ep))
|
while (*ep == ':' || isxdigit(*ep))
|
||||||
ep++;
|
ep++;
|
||||||
if (*ep == ']') {
|
if (*ep == ']') {
|
||||||
h->host++;
|
h->host++;
|
||||||
*ep = '\0';
|
*ep = '\0';
|
||||||
pp = ep + 1;
|
sp = ep + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cp = strchr(pp, ':');
|
p = strchr(sp, ':');
|
||||||
if (cp != NULL) {
|
if (p != NULL) {
|
||||||
*cp++ = '\0';
|
*p = '\0';
|
||||||
h->port = htons(xatou16(cp));
|
h->port = htons(xatou16(p + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user