Bug #6456

[readline] Readline.point when history edited

Added by Nobuhiro IMAI almost 2 years ago. Updated about 1 year ago.

[ruby-dev:45655]
Status:Third Party's Issue
Priority:Normal
Assignee:Kouji Takao
Category:ext
Target version:-
ruby -v:ruby 2.0.0dev (2012-05-19 trunk 35705) [x86_64-linux] Backport:

Description

=begin
以下のように、履歴をたどって編集した時に Readline.point の値がおかしくなるようです。

require "readline"

RUBYDESCRIPTION # => "ruby 2.0.0dev (2012-05-19 trunk 35705) [x8664-linux]"
Readline::VERSION # => "6.2"

IO.pipe do |r, w|
Readline.input = r
w << "123\n\cP456\n\cP\n"
Readline.readline("", true) # => "123"
Readline.point # => 3
Readline.readline("", true) # => "123456"
Readline.point # => 3
Readline.readline("", true) # => "123456"
Readline.point # => 6
end
# >> 123
# >> 123456
# >> 123456
=end

History

#1 Updated by Yusuke Endoh almost 2 years ago

  • Status changed from Open to Assigned
  • Assignee set to Kouji Takao

#2 Updated by Masaki Matsushita about 1 year ago

  • Status changed from Assigned to Third Party's Issue

Readline.pointの実体はGNU readlineの変数rl_pointですが、次のようなコードで検証したところ

#include
#include
#include
#include

int
main() {
const char *prompt = "> ";
char *line = NULL;

while (line = readline(prompt)) {
    add_history(line);
    printf("%d: \"%s\"\n", rl_point, line);
    free(line);
}

clear_history();

return EXIT_SUCCESS;

}

% ./a.out

hoge
4: "hoge"
hogefuga # 履歴から"hoge"を復元し"fuga"を追記
4: "hogefuga"
hogefuga # 履歴から"hogefuga"を復元
8: "hogefuga"

以上のような挙動を示したので、GNU readline側の仕様ないしバグではないかと思われます。

Also available in: Atom PDF