From dc4d23a7e54df022cdd956c26ee3f8fb5e25c5c9 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 16 Jan 2005 22:09:29 +0000 Subject: * ext/readline/readline.c: suppress warnings. * lib/irb/extend-command.rb (IRB::ContextExtender.def_extend_command): ditto. * lib/irb/ext/history.rb (IRB::Context::set_last_value): ditto. * lib/irb/ext/history.rb (IRB::Context::eval_history): ditto. * lib/irb/locale.rb (IRB::Locale::real_load): ditto. * lib/irb/slex.rb (SLex::Node::create_subnode): remove garbage. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 17 ++++++++++++++++- ext/readline/readline.c | 16 ++++++++++------ lib/irb/ext/history.rb | 4 ++-- lib/irb/extend-command.rb | 1 + lib/irb/init.rb | 10 +++++----- lib/irb/locale.rb | 14 +++++--------- lib/irb/slex.rb | 1 - 7 files changed, 39 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9b26fa07de..2886baca38 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,21 @@ +Mon Jan 17 07:08:51 2005 Nobuyoshi Nakada + + * ext/readline/readline.c: suppress warnings. + + * lib/irb/extend-command.rb (IRB::ContextExtender.def_extend_command): + ditto. + + * lib/irb/ext/history.rb (IRB::Context::set_last_value): ditto. + + * lib/irb/ext/history.rb (IRB::Context::eval_history): ditto. + + * lib/irb/locale.rb (IRB::Locale::real_load): ditto. + + * lib/irb/slex.rb (SLex::Node::create_subnode): remove garbage. + Mon Jan 17 00:09:42 2005 WATANABE Hirofumi - * lib/uri/common.rb (PORT): typo fix. fixed: [ruby-core:04256] + * lib/uri/common.rb (PORT): typo fix. fixed: [ruby-core:04256] Sat Jan 15 14:57:22 2005 Nobuyoshi Nakada diff --git a/ext/readline/readline.c b/ext/readline/readline.c index e3a1dcbf02..4c7b08f514 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -19,6 +19,7 @@ static VALUE mReadline; #define COMPLETION_PROC "completion_proc" #define COMPLETION_CASE_FOLD "completion_case_fold" +static ID completion_proc, completion_case_fold; #ifndef READLINE_42_OR_LATER # define rl_filename_completion_function filename_completion_function @@ -87,7 +88,7 @@ readline_s_set_completion_proc(self, proc) rb_secure(4); if (!rb_respond_to(proc, rb_intern("call"))) rb_raise(rb_eArgError, "argument must respond to `call'"); - return rb_iv_set(mReadline, COMPLETION_PROC, proc); + return rb_ivar_set(mReadline, completion_proc, proc); } static VALUE @@ -95,7 +96,7 @@ readline_s_get_completion_proc(self) VALUE self; { rb_secure(4); - return rb_iv_get(mReadline, COMPLETION_PROC); + return rb_attr_get(mReadline, completion_proc); } static VALUE @@ -104,7 +105,7 @@ readline_s_set_completion_case_fold(self, val) VALUE val; { rb_secure(4); - return rb_iv_set(mReadline, COMPLETION_CASE_FOLD, val); + return rb_ivar_set(mReadline, completion_case_fold, val); } static VALUE @@ -112,7 +113,7 @@ readline_s_get_completion_case_fold(self) VALUE self; { rb_secure(4); - return rb_iv_get(mReadline, COMPLETION_CASE_FOLD); + return rb_attr_get(mReadline, completion_case_fold); } static char ** @@ -126,11 +127,11 @@ readline_attempted_completion_function(text, start, end) int case_fold; int i, matches; - proc = rb_iv_get(mReadline, COMPLETION_PROC); + proc = rb_attr_get(mReadline, completion_proc); if (NIL_P(proc)) return NULL; rl_attempted_completion_over = 1; - case_fold = RTEST(rb_iv_get(mReadline, COMPLETION_CASE_FOLD)); + case_fold = RTEST(rb_attr_get(mReadline, completion_case_fold)); ary = rb_funcall(proc, rb_intern("call"), 1, rb_tainted_str_new2(text)); if (TYPE(ary) != T_ARRAY) ary = rb_Array(ary); @@ -697,6 +698,9 @@ Init_readline() using_history(); + completion_proc = rb_intern(COMPLETION_PROC); + completion_case_fold = rb_intern(COMPLETION_CASE_FOLD); + mReadline = rb_define_module("Readline"); rb_define_module_function(mReadline, "readline", readline_readline, -1); diff --git a/lib/irb/ext/history.rb b/lib/irb/ext/history.rb index d40a62e959..55cd56de2f 100644 --- a/lib/irb/ext/history.rb +++ b/lib/irb/ext/history.rb @@ -22,7 +22,7 @@ module IRB _set_last_value(value) @workspace.evaluate self, "_ = IRB.CurrentContext.last_value" - if @eval_history #and !@eval_history_values.equal?(llv) + if (@eval_history ||= nil) #and !@eval_history_values.equal?(llv) @eval_history_values.push @line_no, @last_value @workspace.evaluate self, "__ = IRB.CurrentContext.instance_eval{@eval_history_values}" end @@ -33,7 +33,7 @@ module IRB attr_reader :eval_history def eval_history=(no) if no - if @eval_history + if (@eval_history ||= nil) @eval_history_values.size(no) else @eval_history_values = History.new(no) diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb index cfb2c7c4be..5477ef6bf4 100644 --- a/lib/irb/extend-command.rb +++ b/lib/irb/extend-command.rb @@ -200,6 +200,7 @@ module IRB def CE.def_extend_command(cmd_name, load_file, *aliases) Context.module_eval %[ def #{cmd_name}(*opts, &b) + Context.module_eval {remove_method(:#{cmd_name})} require "#{load_file}" send :#{cmd_name}, *opts, &b end diff --git a/lib/irb/init.rb b/lib/irb/init.rb index 37cdb313e6..ea206c9da5 100644 --- a/lib/irb/init.rb +++ b/lib/irb/init.rb @@ -97,7 +97,7 @@ module IRB } } - @CONF[:PROMPT_MODE] = :DEFAULT + @CONF[:PROMPT_MODE] = (STDIN.tty? ? :DEFAULT : :NULL) @CONF[:AUTO_INDENT] = false @CONF[:CONTEXT_MODE] = 3 # use binding in function on TOPLEVEL_BINDING @@ -123,11 +123,11 @@ module IRB @CONF[:MATH_MODE] = true when "-d" $DEBUG = true - when "-r" - opt = ARGV.shift + when /^-r(.+)?/ + opt = $1 || ARGV.shift @CONF[:LOAD_MODULES].push opt if opt - when "-I" - opt = ARGV.shift + when /^-I(.+)?/ + opt = $1 || ARGV.shift $LOAD_PATH.push opt if opt when /^-K(.)/ $KCODE = $1 diff --git a/lib/irb/locale.rb b/lib/irb/locale.rb index b2c90e38e2..351406c2da 100644 --- a/lib/irb/locale.rb +++ b/lib/irb/locale.rb @@ -10,7 +10,6 @@ # # -autoload :Tempfile, "tempfile" autoload :Kconv, "kconv" module IRB @@ -126,15 +125,12 @@ module IRB end def real_load(path, priv) - tmp_base = path.tr("./:", "___") - lc_file = Tempfile.new(tmp_base) - File.foreach(path) do |line| - line = self.String(line) - lc_file.print(line) + src = self.String(File.read(path)) + if priv + eval("self", TOPLEVEL_BINDING).extend(Module.new {eval(src, nil, path)}) + else + eval(src, TOPLEVEL_BINDING, path) end - lc_file.close - toplevel_load lc_file.path, priv - lc_file.close(true) end private :real_load diff --git a/lib/irb/slex.rb b/lib/irb/slex.rb index c0943f6e33..f729721a58 100644 --- a/lib/irb/slex.rb +++ b/lib/irb/slex.rb @@ -116,7 +116,6 @@ class SLex def create_subnode(chrs, preproc = nil, postproc = nil) if chrs.empty? if @postproc - p node SLex.fail ErrNodeAlreadyExists else print "Warn: change abstract node to real node\n" if SLex.debug? -- cgit v1.2.3