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: new methods

Readline::basic_word_break_characters,
	Readline::basic_word_break_characters=,
	Readline::completer_word_break_characters,
	Readline::completer_word_break_characters=,
	Readline::basic_quote_characters,
	Readline::basic_quote_characters=,
	Readline::completer_quote_characters,
	Readline::completer_quote_characters=,
	Readline::filename_quote_characters,
	Readline::filename_quote_characters=.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1924 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
shugo 2001-12-19 08:02:55 +00:00
parent ee87eb1367
commit a76e21e612
2 changed files with 234 additions and 0 deletions

View file

@ -1,3 +1,17 @@
Wed Dec 19 16:58:29 2001 Shugo Maeda <shugo@ruby-lang.org>
* ext/readline/readline.c: new methods
Readline::basic_word_break_characters,
Readline::basic_word_break_characters=,
Readline::completer_word_break_characters,
Readline::completer_word_break_characters=,
Readline::basic_quote_characters,
Readline::basic_quote_characters=,
Readline::completer_quote_characters,
Readline::completer_quote_characters=,
Readline::filename_quote_characters,
Readline::filename_quote_characters=.
Wed Dec 19 14:05:00 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_mod_define_method): define_method should follow

View file

@ -221,6 +221,206 @@ readline_s_get_completion_append_character(self)
#endif /* READLINE_21_OR_LATER */
}
static VALUE
readline_s_set_basic_word_break_characters(self, str)
VALUE self, str;
{
#ifdef READLINE_21_OR_LATER
static char *basic_word_break_characters = NULL;
char *s;
StringValue(str);
if (basic_word_break_characters == NULL) {
basic_word_break_characters =
ALLOC_N(char, RSTRING(str)->len + 1);
}
else {
REALLOC_N(basic_word_break_characters, char, RSTRING(str)->len + 1);
}
strncpy(basic_word_break_characters,
RSTRING(str)->ptr, RSTRING(str)->len);
basic_word_break_characters[RSTRING(str)->len] = '\0';
rl_basic_word_break_characters = basic_word_break_characters;
return self;
#else
rb_notimplement();
#endif /* READLINE_21_OR_LATER */
}
static VALUE
readline_s_get_basic_word_break_characters(self, str)
VALUE self, str;
{
#ifdef READLINE_21_OR_LATER
if (rl_basic_word_break_characters == NULL)
return Qnil;
return rb_str_new2(rl_basic_word_break_characters);
#else
rb_notimplement();
#endif /* READLINE_21_OR_LATER */
}
static VALUE
readline_s_set_completer_word_break_characters(self, str)
VALUE self, str;
{
#ifdef READLINE_21_OR_LATER
static char *completer_word_break_characters = NULL;
char *s;
StringValue(str);
if (completer_word_break_characters == NULL) {
completer_word_break_characters =
ALLOC_N(char, RSTRING(str)->len + 1);
}
else {
REALLOC_N(completer_word_break_characters, char, RSTRING(str)->len + 1);
}
strncpy(completer_word_break_characters,
RSTRING(str)->ptr, RSTRING(str)->len);
completer_word_break_characters[RSTRING(str)->len] = '\0';
rl_completer_word_break_characters = completer_word_break_characters;
return self;
#else
rb_notimplement();
#endif /* READLINE_21_OR_LATER */
}
static VALUE
readline_s_get_completer_word_break_characters(self, str)
VALUE self, str;
{
#ifdef READLINE_21_OR_LATER
if (rl_completer_word_break_characters == NULL)
return Qnil;
return rb_str_new2(rl_completer_word_break_characters);
#else
rb_notimplement();
#endif /* READLINE_21_OR_LATER */
}
static VALUE
readline_s_set_basic_quote_characters(self, str)
VALUE self, str;
{
#ifdef READLINE_21_OR_LATER
static char *basic_quote_characters = NULL;
char *s;
StringValue(str);
if (basic_quote_characters == NULL) {
basic_quote_characters =
ALLOC_N(char, RSTRING(str)->len + 1);
}
else {
REALLOC_N(basic_quote_characters, char, RSTRING(str)->len + 1);
}
strncpy(basic_quote_characters,
RSTRING(str)->ptr, RSTRING(str)->len);
basic_quote_characters[RSTRING(str)->len] = '\0';
rl_basic_quote_characters = basic_quote_characters;
return self;
#else
rb_notimplement();
#endif /* READLINE_21_OR_LATER */
}
static VALUE
readline_s_get_basic_quote_characters(self, str)
VALUE self, str;
{
#ifdef READLINE_21_OR_LATER
if (rl_basic_quote_characters == NULL)
return Qnil;
return rb_str_new2(rl_basic_quote_characters);
#else
rb_notimplement();
#endif /* READLINE_21_OR_LATER */
}
static VALUE
readline_s_set_completer_quote_characters(self, str)
VALUE self, str;
{
#ifdef READLINE_21_OR_LATER
static char *completer_quote_characters = NULL;
char *s;
StringValue(str);
if (completer_quote_characters == NULL) {
completer_quote_characters =
ALLOC_N(char, RSTRING(str)->len + 1);
}
else {
REALLOC_N(completer_quote_characters, char, RSTRING(str)->len + 1);
}
strncpy(completer_quote_characters,
RSTRING(str)->ptr, RSTRING(str)->len);
completer_quote_characters[RSTRING(str)->len] = '\0';
rl_completer_quote_characters = completer_quote_characters;
return self;
#else
rb_notimplement();
#endif /* READLINE_21_OR_LATER */
}
static VALUE
readline_s_get_completer_quote_characters(self, str)
VALUE self, str;
{
#ifdef READLINE_21_OR_LATER
if (rl_completer_quote_characters == NULL)
return Qnil;
return rb_str_new2(rl_completer_quote_characters);
#else
rb_notimplement();
#endif /* READLINE_21_OR_LATER */
}
static VALUE
readline_s_set_filename_quote_characters(self, str)
VALUE self, str;
{
#ifdef READLINE_21_OR_LATER
static char *filename_quote_characters = NULL;
char *s;
StringValue(str);
if (filename_quote_characters == NULL) {
filename_quote_characters =
ALLOC_N(char, RSTRING(str)->len + 1);
}
else {
REALLOC_N(filename_quote_characters, char, RSTRING(str)->len + 1);
}
strncpy(filename_quote_characters,
RSTRING(str)->ptr, RSTRING(str)->len);
filename_quote_characters[RSTRING(str)->len] = '\0';
rl_filename_quote_characters = filename_quote_characters;
return self;
#else
rb_notimplement();
#endif /* READLINE_21_OR_LATER */
}
static VALUE
readline_s_get_filename_quote_characters(self, str)
VALUE self, str;
{
#ifdef READLINE_21_OR_LATER
if (rl_filename_quote_characters == NULL)
return Qnil;
return rb_str_new2(rl_filename_quote_characters);
#else
rb_notimplement();
#endif /* READLINE_21_OR_LATER */
}
static VALUE
rb_remove_history(index)
int index;
@ -476,6 +676,26 @@ Init_readline()
readline_s_set_completion_append_character, 1);
rb_define_singleton_method(mReadline, "completion_append_character",
readline_s_get_completion_append_character, 0);
rb_define_singleton_method(mReadline, "basic_word_break_characters=",
readline_s_set_basic_word_break_characters, 1);
rb_define_singleton_method(mReadline, "basic_word_break_characters",
readline_s_get_basic_word_break_characters, 0);
rb_define_singleton_method(mReadline, "completer_word_break_characters=",
readline_s_set_completer_word_break_characters, 1);
rb_define_singleton_method(mReadline, "completer_word_break_characters",
readline_s_get_completer_word_break_characters, 0);
rb_define_singleton_method(mReadline, "basic_quote_characters=",
readline_s_set_basic_quote_characters, 1);
rb_define_singleton_method(mReadline, "basic_quote_characters",
readline_s_get_basic_quote_characters, 0);
rb_define_singleton_method(mReadline, "completer_quote_characters=",
readline_s_set_completer_quote_characters, 1);
rb_define_singleton_method(mReadline, "completer_quote_characters",
readline_s_get_completer_quote_characters, 0);
rb_define_singleton_method(mReadline, "filename_quote_characters=",
readline_s_set_filename_quote_characters, 1);
rb_define_singleton_method(mReadline, "filename_quote_characters",
readline_s_get_filename_quote_characters, 0);
histary = rb_obj_alloc(rb_cObject);
rb_extend_object(histary, rb_mEnumerable);