ruby-changes:9144
From: kouji <ko1@a...>
Date: Sat, 13 Dec 2008 01:14:09 +0900 (JST)
Subject: [ruby-changes:9144] Ruby:r20680 (trunk): * ext/readline/readline.c
kouji 2008-12-13 01:13:11 +0900 (Sat, 13 Dec 2008) New Revision: 20680 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20680 Log: * ext/readline/readline.c (readline_s_get_completion_append_character): uses locale encoding but not ASCII-8BIT. Modified files: trunk/ext/readline/readline.c trunk/test/readline/test_readline.rb Index: ext/readline/readline.c =================================================================== --- ext/readline/readline.c (revision 20679) +++ ext/readline/readline.c (revision 20680) @@ -602,15 +602,14 @@ 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 */ Index: test/readline/test_readline.rb =================================================================== --- test/readline/test_readline.rb (revision 20679) +++ test/readline/test_readline.rb (revision 20680) @@ -166,12 +166,18 @@ 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/