[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-readline] Minor bone to pick regarding the doc for next_history

From: Chet Ramey
Subject: Re: [Bug-readline] Minor bone to pick regarding the doc for next_history()
Date: Mon, 06 Apr 2015 13:54:26 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

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."

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]