X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=src%2Fhtml-url.c;h=523f5e0dab1aa82f1431f7752be20742c356f4ec;hp=02092e5a31023a1322d8b05f787d0028ff4bc964;hb=e095cc064eb72ca0cee6d41622e39e7ea3f211a6;hpb=75c6ca0f5d1cc9baf604ed44f1a7b68a0373357d diff --git a/src/html-url.c b/src/html-url.c index 02092e5a..523f5e0d 100644 --- a/src/html-url.c +++ b/src/html-url.c @@ -335,13 +335,27 @@ append_url (const char *link_uri, int position, int size, else if (link_has_scheme) newel->link_complete_p = 1; - if (ctx->tail) + /* Append the new URL maintaining the order by position. */ + if (ctx->head == NULL) + ctx->head = newel; + else { - ctx->tail->next = newel; - ctx->tail = newel; + struct urlpos *it, *prev = NULL; + + it = ctx->head; + while (it && position > it->pos) + { + prev = it; + it = it->next; + } + + newel->next = it; + + if (prev) + prev->next = newel; + else + ctx->head = newel; } - else - ctx->tail = ctx->head = newel; return newel; } @@ -668,7 +682,7 @@ get_urls_html (const char *file, const char *url, bool *meta_disallow_follow, DEBUGP (("Loaded %s (size %s).\n", file, number_to_static_string (fm->length))); ctx.text = fm->content; - ctx.head = ctx.tail = NULL; + ctx.head = NULL; ctx.base = NULL; ctx.parent_base = url ? url : opt.base_href; ctx.document_file = file;