diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2016-05-08 13:52:34 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2016-05-08 13:52:34 +0000 |
commit | ea0085fb301e0310bdefcbd93503f59cab8cceb6 (patch) | |
tree | 280646c653950cebbd802aa276efef6205300508 /lib | |
parent | 20caff463c958ba7ab9dd40c68f397ab11849499 (diff) |
Change where_history() to agree with the GNU implementation:
Return 0 for the oldest entry and increment by 1 for each newer,
non-deleted entry.
This fixes the test_where() regression test.
Patch from Bastian Maerkisch <bmaerkisch at web dot de>.
OK czarkoff@.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libedit/readline.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/libedit/readline.c b/lib/libedit/readline.c index 51901891582..0675b16a705 100644 --- a/lib/libedit/readline.c +++ b/lib/libedit/readline.c @@ -1,4 +1,4 @@ -/* $OpenBSD: readline.c,v 1.22 2016/05/08 13:34:35 schwarze Exp $ */ +/* $OpenBSD: readline.c,v 1.23 2016/05/08 13:52:33 schwarze Exp $ */ /* $NetBSD: readline.c,v 1.91 2010/08/28 15:44:59 christos Exp $ */ /*- @@ -1487,9 +1487,12 @@ where_history(void) return 0; curr_num = ev.num; - (void)history(h, &ev, H_FIRST); - off = 1; - while (ev.num != curr_num && history(h, &ev, H_NEXT) == 0) + /* start from the oldest */ + (void)history(h, &ev, H_LAST); + + /* position is zero-based */ + off = 0; + while (ev.num != curr_num && history(h, &ev, H_PREV) == 0) off++; return off; |