diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-05-06 15:06:00 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-05-06 15:06:00 +0000 |
commit | 1d3d27b42d1371ba6242ec217ca803f107ceb9eb (patch) | |
tree | 8d7e184fd63610124717df8dec31e719901965ad /ext/readline | |
parent | 94df732f8b69356626130e0ec8b2dbc9340082ef (diff) |
forgot some checkins.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/readline')
-rw-r--r-- | ext/readline/extconf.rb | 3 | ||||
-rw-r--r-- | ext/readline/readline.c | 24 |
2 files changed, 18 insertions, 9 deletions
diff --git a/ext/readline/extconf.rb b/ext/readline/extconf.rb index 7db62745f3..431ed213bb 100644 --- a/ext/readline/extconf.rb +++ b/ext/readline/extconf.rb @@ -9,5 +9,8 @@ have_library("ncurses", "tgetnum") or if have_header("readline/readline.h") and have_header("readline/history.h") and have_library("readline", "readline") + if have_func("rl_filename_completion_function") + $CFLAGS += "-DREADLINE_42_OR_LATER" + end create_makefile("readline") end diff --git a/ext/readline/readline.c b/ext/readline/readline.c index 02b29796af..765a00280c 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -1,5 +1,5 @@ /* readline.c -- GNU Readline module - Copyright (C) 1997-1998 Shugo Maeda */ + Copyright (C) 1997-2001 Shugo Maeda */ #include <stdio.h> #include <readline/readline.h> @@ -15,6 +15,11 @@ static VALUE mReadline; #define COMPLETION_PROC "completion_proc" #define COMPLETION_CASE_FOLD "completion_case_fold" +#ifndef READLINE_42_OR_LATER +# define rl_filename_completion_function filename_completion_function +# define rl_username_completion_function username_completion_function +#endif + static int readline_event() { @@ -33,7 +38,7 @@ readline_readline(argc, argv, self) char *buff; if (rb_scan_args(argc, argv, "02", &tmp, &add_hist) > 0) { - prompt = STR2CSTR(tmp); + prompt = StringValuePtr(tmp); } buff = readline(prompt); if (RTEST(add_hist) && buff) { @@ -190,6 +195,7 @@ hist_set(self, index, str) VALUE str; { HISTORY_STATE *state; + VALUE s = str; int i; state = history_get_history_state(); @@ -197,7 +203,7 @@ hist_set(self, index, str) if (i < 0 || i > state->length - 1) { rb_raise(rb_eIndexError, "Invalid index"); } - replace_history_entry(i, STR2CSTR(str), NULL); + replace_history_entry(i, StringValuePtr(s), NULL); return str; } @@ -206,7 +212,7 @@ hist_push(self, str) VALUE self; VALUE str; { - add_history(STR2CSTR(str)); + add_history(StringValuePtr(str)); return self; } @@ -220,7 +226,7 @@ hist_push_method(argc, argv, self) while (argc--) { str = *argv++; - add_history(STR2CSTR(str)); + add_history(StringValuePtr(str)); } return self; } @@ -321,8 +327,8 @@ filename_completion_proc_call(self, str) char **matches; int i; - matches = completion_matches(STR2CSTR(str), - filename_completion_function); + matches = completion_matches(StringValuePtr(str), + rl_filename_completion_function); if (matches) { result = rb_ary_new(); for (i = 0; matches[i]; i++) { @@ -348,8 +354,8 @@ username_completion_proc_call(self, str) char **matches; int i; - matches = completion_matches(STR2CSTR(str), - username_completion_function); + matches = completion_matches(StringValuePtr(str), + rl_username_completion_function); if (matches) { result = rb_ary_new(); for (i = 0; matches[i]; i++) { |