On 3/24/15 10:50 AM, Glenn Golden wrote:
> From history.3, readline 6.3.006:
>
> HIST_ENTRY * next_history (void)
>
> Move the current history offset forward to the next history entry,
> and return the a pointer to that entry. If there is no next entry,
> return a NULL pointer.
>
> This leaves unstated what happens to the value of 'offset' if there
> is "no next entry", and it seems there is no simple 'right' answer.
>
> From experiments (via perl Term::ReadLine::Gnu) the actual behavior w.r.t
> the value of 'offset' after the call completes seems to be
>
> offset = (offset < history_length) ? offset+1 : offset;
>
> which means that there are really two relevant forms of "no next entry" upon
> calling next_history():
>
> Case 1: offset == history_length-1
>
> Case 2: offset > history_length-1
Yes, this is a good summary. The last entry in the history list
(the_history[history_length]) is always NULL, or should be if you use
add_history to insert history entries.
I guess the shortest way to express the situation is something like
"if this function returns NULL, the history offset is at the end of
the history."
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU [email protected] http://cnswww.cns.cwru.edu/~chet/
_______________________________________________
Bug-readline mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-readline