summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-19 01:38:38 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-19 01:38:38 +0000
commit964171ebfaf84e79f61ef45f2f11e9cd7b22d2a5 (patch)
treebd48f71ca2ef6a9f00c4774cec5d925f46e320b4
parent2bf189db24db4d328063637c456d2792c0cd47e6 (diff)
* ext/readline/readline.c (readline_s_set_completion_append_character):
accept nil. [ruby-core:03765] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--ext/readline/readline.c13
-rw-r--r--test/readline/test_readline.rb9
3 files changed, 23 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 9df43f2f05..4817f97713 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Nov 19 10:32:36 2004 Shugo Maeda <shugo@ruby-lang.org>
+
+ * ext/readline/readline.c (readline_s_set_completion_append_character):
+ accept nil. [ruby-core:03765]
+
Fri Nov 19 00:59:31 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (str_gsub): internal buffer should not be listed by
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index 8812524a67..e3a1dcbf02 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -204,11 +204,16 @@ readline_s_set_completion_append_character(self, str)
{
#ifdef READLINE_21_OR_LATER
rb_secure(4);
- SafeStringValue(str);
- if (NIL_P(str) || RSTRING(str)->len == 0) {
+ if (NIL_P(str)) {
rl_completion_append_character = '\0';
- } else {
- rl_completion_append_character = RSTRING(str)->ptr[0];
+ }
+ else {
+ SafeStringValue(str);
+ if (RSTRING(str)->len == 0) {
+ rl_completion_append_character = '\0';
+ } else {
+ rl_completion_append_character = RSTRING(str)->ptr[0];
+ }
}
return self;
diff --git a/test/readline/test_readline.rb b/test/readline/test_readline.rb
index f41f3584cb..80c007c063 100644
--- a/test/readline/test_readline.rb
+++ b/test/readline/test_readline.rb
@@ -38,6 +38,15 @@ class TestReadline < Test::Unit::TestCase
end
end
+ def test_completion_append_character
+ Readline.completion_append_character = nil
+ assert_equal(nil, Readline.completion_append_character)
+ Readline.completion_append_character = "x"
+ assert_equal("x", Readline.completion_append_character)
+ Readline.completion_append_character = "xyz"
+ assert_equal("x", Readline.completion_append_character)
+ end
+
private
def replace_stdio(stdin, stdout)