diff options
author | Tatsuya Kinoshita <tats@debian.org> | 2013-07-30 11:14:54 +0000 |
---|---|---|
committer | Tatsuya Kinoshita <tats@debian.org> | 2013-07-30 11:14:54 +0000 |
commit | e3d3c53ac3c3b8f7c8ab227427ea9ff147f9036f (patch) | |
tree | 88966004acc26ea238b5414bd569b86aac1b569d /main.c | |
parent | Merge branch 'feature/debian-version' (diff) | |
parent | Merge branch 'master' into bug/sort-dump-links (diff) | |
download | w3m-e3d3c53ac3c3b8f7c8ab227427ea9ff147f9036f.tar.gz w3m-e3d3c53ac3c3b8f7c8ab227427ea9ff147f9036f.zip |
Merge branch 'bug/sort-dump-links'
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -1269,6 +1269,12 @@ dump_extra(Buffer *buf) #endif } +static int +cmp_anchor_hseq(const void *a, const void *b) +{ + return (*((const Anchor **) a))->hseq - (*((const Anchor **) b))->hseq; +} + static void do_dump(Buffer *buf) { @@ -1289,15 +1295,20 @@ do_dump(Buffer *buf) int i; saveBuffer(buf, stdout, FALSE); if (displayLinkNumber && buf->href) { + int nanchor = buf->href->nanchor; printf("\nReferences:\n\n"); - for (i = 0; i < buf->href->nanchor; i++) { - ParsedURL pu; + Anchor **in_order = New_N(Anchor *, buf->href->nanchor); + for (i = 0; i < nanchor; i++) + in_order[i] = buf->href->anchors + i; + qsort(in_order, nanchor, sizeof(Anchor *), cmp_anchor_hseq); + for (i = 0; i < nanchor; i++) { + ParsedURL pu; char *url; - if (buf->href->anchors[i].slave) + if (in_order[i]->slave) continue; - parseURL2(buf->href->anchors[i].url, &pu, baseURL(buf)); + parseURL2(in_order[i]->url, &pu, baseURL(buf)); url = url_decode2(parsedURL2Str(&pu)->ptr, Currentbuf); - printf("[%d] %s\n", buf->href->anchors[i].hseq + 1, url); + printf("[%d] %s\n", in_order[i]->hseq + 1, url); } } } |