1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/readline/readline.c

(readline_s_get_completion_append_character): uses locale
  encoding but not ASCII-8BIT.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kouji 2008-12-12 16:13:11 +00:00
parent 75fbac3b0d
commit 8b123714e2
2 changed files with 15 additions and 10 deletions

View file

@ -602,15 +602,14 @@ static VALUE
readline_s_get_completion_append_character(VALUE self)
{
#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
VALUE str;
char buf[1];
rb_secure(4);
if (rl_completion_append_character == '\0')
return Qnil;
str = rb_str_new(0, 1);
RSTRING_PTR(str)[0] = rl_completion_append_character;
return str;
buf[0] = (char) rl_completion_append_character;
return rb_locale_str_new(buf, 1);
#else
rb_notimplement();
return Qnil; /* not reached */

View file

@ -166,12 +166,18 @@ class TestReadline < Test::Unit::TestCase
def test_completion_append_character
begin
Readline.completion_append_character = "x"
assert_equal("x", Readline.completion_append_character)
Readline.completion_append_character = "xyz"
assert_equal("x", Readline.completion_append_character)
Readline.completion_append_character = nil
assert_equal(nil, Readline.completion_append_character)
enc = Encoding.default_internal || Encoding.find("locale")
data_expected = [
["x", "x"],
["xyx", "x"],
[" ", " "],
["\t", "\t"],
]
data_expected.each do |(data, expected)|
Readline.completion_append_character = data
assert_equal(expected, Readline.completion_append_character)
assert_equal(enc, Readline.completion_append_character.encoding)
end
Readline.completion_append_character = ""
assert_equal(nil, Readline.completion_append_character)
rescue NotImplementedError