Fix reverse iteration in urlOpen

weechat-hashes
Curtis McEnroe 2018-09-08 00:14:15 -04:00
parent bd48cb5e7d
commit 089647b6cd
No known key found for this signature in database
GPG Key ID: CEA2F97ADCFCD77C
1 changed files with 2 additions and 2 deletions

4
url.c
View File

@ -76,8 +76,8 @@ void urlOpen(struct Tag tag, size_t at, size_t to) {
size_t argc = 1; size_t argc = 1;
char *argv[2 + RingLen] = { "open" }; char *argv[2 + RingLen] = { "open" };
size_t tagIndex = 0; size_t tagIndex = 0;
for (size_t i = 0; i < RingLen; ++i) { for (size_t i = RingLen - 1; i < RingLen; --i) {
struct Entry entry = ring.buf[(ring.end - i) & (RingLen - 1)]; struct Entry entry = ring.buf[(ring.end + i) & (RingLen - 1)];
if (!entry.url || entry.tag != tag.id) continue; if (!entry.url || entry.tag != tag.id) continue;
if (tagIndex >= at && tagIndex < to) argv[argc++] = entry.url; if (tagIndex >= at && tagIndex < to) argv[argc++] = entry.url;
tagIndex++; tagIndex++;