Skip Menu |

This queue is for tickets about the Term-ReadLine-Gnu CPAN distribution.

Maintainer(s)' notes

When you report a bug, please provide the following information;

- output of
	perl -V
	perl Makefile.PL verbose
	make test TEST_VERBOSE=1
	perl -Mblib t/00checkver.t
	echo $TERM
- terminal emulator which you are using
- compiler which is used to compile the GNU Readline Library (libreadline.a) if you can know.
Read INSTALL in the distribution for more details.

Report information
The Basics
Id: 103018
Status: resolved
Priority: 0/
Queue: Term-ReadLine-Gnu

People
Owner: Nobody in particular
Requestors: gdg [...] zplane.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: history_set_pos(): Incorrect expectation or bug?
Date: Sun, 22 Mar 2015 22:39:51 -0600
To: bug-Term-ReadLine-Gnu [...] rt.cpan.org
From: Glenn Golden <gdg [...] zplane.com>
Hello Hiroo, Please see attached script. Detailed explanatory comments, version info, and so on therein. Thanks, Glenn

Message body is not shown because sender requested not to inline it.

Hi, I think it is an incorrect expectation as far as I read GNU History Library Manual. http://cnswww.cns.cwru.edu/php/chet/readline/history.html ----------- 3.4 Moving Around the History List These functions allow the current index into the history list to be set or changed. Function: int history_set_pos (int pos) Set the current history offset to pos, an absolute index into the list. Returns 1 on success, 0 if pos is less than zero or greater than the number of history entries. ----------- You need to use functions described in "2.3.2 History List Management". Regards,
Subject: Re: [rt.cpan.org #103018] history_set_pos(): Incorrect expectation or bug?
Date: Mon, 23 Mar 2015 10:01:29 -0600
To: Hiroo_HAYASHI via RT <bug-Term-ReadLine-Gnu [...] rt.cpan.org>
From: Glenn Golden <gdg [...] zplane.com>
Hi Hiroo, Thanks for your quick response. Hiroo_HAYASHI via RT <bug-Term-ReadLine-Gnu@rt.cpan.org> [2015-03-23 11:18:20 -0400]: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=103018 > > > I think it is an incorrect expectation as far as I read GNU History Library > Manual. > > http://cnswww.cns.cwru.edu/php/chet/readline/history.html >
I read that too, before submitting the report. But with all due respect -- and not trying to be a troll about this, just want to obtain a clear understanding -- but neither that section of the readline doc nor your response above addresses the question that I posed: "If this is not a bug, then a reasonable question seems to be: What is the intended purpose of history_set_pos()?" I simply don't understand what purpose could be served by that function if -- as it seems from the example -- it does not modify the behavior of subsequent readline() calls? The doc says that "these functions allow the current index into the history list to be set or changed". But the subsequent call to readline() after history_set_pos() behaves exactly as though the index was not changed. So what purpose does the function serve? I'm probably missing something obvious, but would appreciate a patient explanation if you have time. If not, no problem, I will take it up on the readline mailing list. Thanks for your time in any case, Glenn P.S. I should have mentioned in my report that I was able to obtain the functionality I was seeking by stepping thru the history list one entry at a time (starting from the most recent) and then using remove_history(k) followed by history_set_pos(k-1), to achieve the desired effect, i.e. pruning off a given number of entries from the end of the list. But I still don't understand why history_set_pos() alone is not sufficient, given its documented behavior.
Hi, Show quoted text
> "If this is not a bug, then a reasonable question seems to be: What is > the intended purpose of history_set_pos()?"
As I cited, the manual says it is for "2.3.4 Moving Around the History List". Show quoted text
> -- as it seems from the example -- it does not modify the behavior of > subsequent readline() calls?
You overlook one point, add_history() is called after readline() in readline method in Term-ReadLine-Gnu (unless you disable it explicitly by using MinLine() method). The behavior is defined by Term::ReadLine. It is a right behavior that add_history() set the pointer to the tail of the list. I hope this helps you.
Subject: Re: [rt.cpan.org #103018] history_set_pos(): Incorrect expectation or bug?
Date: Tue, 24 Mar 2015 15:58:36 -0600
To: Hiroo_HAYASHI via RT <bug-Term-ReadLine-Gnu [...] rt.cpan.org>
From: Glenn Golden <gdg [...] zplane.com>
Hiroo_HAYASHI via RT <bug-Term-ReadLine-Gnu@rt.cpan.org> [2015-03-24 12:42:57 -0400]: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=103018 > > > As I cited, the manual says it is for "2.3.4 Moving Around the History List". >
I did read all of the readline doc carefully before posting the ticket. The problem is that it is not at all clear from the entirety of the readline doc what "moving around the history list" might mean. One entirely reasonable interpretation of "moving around" is that when you "move" the 'offset' pointer, it "moves" (i.e. redefines) the location at which readline() will insert the next history line. Why does that seem like a reasonable interpretation? Because the documentation for the 'offset' member tells the reader that: int offset; /* The location pointer within this array */ Given that 'offset' is "the location pointer within the array", it does not seem foolish to interpret that to mean that adjusting the value of 'offset' adjusts the location of the logical end of the array; hence the expectation that a subsequent call to readline() will place the new history line after the newly adjusted value of 'offset'. That turns out not to be correct, no argument about that. But given the doc, it does not seem an unreasonable interpretation. Show quoted text
> > You overlook one point, add_history() is called after readline() in > readline method in Term-ReadLine-Gnu (unless you disable it explicitly > by using MinLine() method). >
No, I didn't overlook that, I was aware of it. See below. Show quoted text
> > The behavior is defined by Term::ReadLine. >
Yes, and the doc for add_history() says: "Place string at the end of the history list", but does not define what is meant by "the end of the list". In view of the above definition of 'offset', one could reasonably assume that it means "Place string at the position following the one specified by 'offset'". After all, 'offset' is "the location pointer within the array". Show quoted text
> > It is a right behavior that add_history() set the pointer to the tail of > the list. >
If by "pointer" you mean the 'offset' member of HISTORY_STATE struct, then what you say above is not correct: add_history() does not touch the offset pointer at all; it leaves it exactly as it was before the call. What add_history() does is use the variable history_length as though it were an offset into the pointer array, then places the new item at at that location. Then it increments history_length. But it does not "set the pointer to the tail of the list". Show quoted text
> > I hope this helps you. >
Despite the fact that we have disagreed on the clarity of the readline documentation (which is certainly not your responsibility) I sincerely thank you for your time in responding! I will bring this doc issue up on the readline mailing list and not annoy you any further with it. Thanks again, Glenn
Subject: Re: [rt.cpan.org #103018] history_set_pos(): Incorrect expectation or bug?
Date: Tue, 24 Mar 2015 16:08:03 -0600
To: Hiroo_HAYASHI via RT <bug-Term-ReadLine-Gnu [...] rt.cpan.org>
From: Glenn Golden <gdg [...] zplane.com>
Attached is an example showing that add_history() behaves as I described in the previous message. It does not behave as you suggested: Show quoted text
> > It is a right behavior that add_history() set the pointer to the tail > of the list. >

Message body is not shown because sender requested not to inline it.