* 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/trunk@7781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2005-01-16 22:09:29 +00:00
parent e84ce31a9e
commit 4d2f38b777
7 changed files with 39 additions and 24 deletions

View File

@ -1,6 +1,21 @@
Mon Jan 17 07:08:51 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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 <eban@ruby-lang.org> Mon Jan 17 00:09:42 2005 WATANABE Hirofumi <eban@ruby-lang.org>
* 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 <nobu@ruby-lang.org> Sat Jan 15 14:57:22 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>

View File

@ -19,6 +19,7 @@ static VALUE mReadline;
#define COMPLETION_PROC "completion_proc" #define COMPLETION_PROC "completion_proc"
#define COMPLETION_CASE_FOLD "completion_case_fold" #define COMPLETION_CASE_FOLD "completion_case_fold"
static ID completion_proc, completion_case_fold;
#ifndef READLINE_42_OR_LATER #ifndef READLINE_42_OR_LATER
# define rl_filename_completion_function filename_completion_function # define rl_filename_completion_function filename_completion_function
@ -87,7 +88,7 @@ readline_s_set_completion_proc(self, proc)
rb_secure(4); rb_secure(4);
if (!rb_respond_to(proc, rb_intern("call"))) if (!rb_respond_to(proc, rb_intern("call")))
rb_raise(rb_eArgError, "argument must respond to `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 static VALUE
@ -95,7 +96,7 @@ readline_s_get_completion_proc(self)
VALUE self; VALUE self;
{ {
rb_secure(4); rb_secure(4);
return rb_iv_get(mReadline, COMPLETION_PROC); return rb_attr_get(mReadline, completion_proc);
} }
static VALUE static VALUE
@ -104,7 +105,7 @@ readline_s_set_completion_case_fold(self, val)
VALUE val; VALUE val;
{ {
rb_secure(4); rb_secure(4);
return rb_iv_set(mReadline, COMPLETION_CASE_FOLD, val); return rb_ivar_set(mReadline, completion_case_fold, val);
} }
static VALUE static VALUE
@ -112,7 +113,7 @@ readline_s_get_completion_case_fold(self)
VALUE self; VALUE self;
{ {
rb_secure(4); rb_secure(4);
return rb_iv_get(mReadline, COMPLETION_CASE_FOLD); return rb_attr_get(mReadline, completion_case_fold);
} }
static char ** static char **
@ -126,11 +127,11 @@ readline_attempted_completion_function(text, start, end)
int case_fold; int case_fold;
int i, matches; int i, matches;
proc = rb_iv_get(mReadline, COMPLETION_PROC); proc = rb_attr_get(mReadline, completion_proc);
if (NIL_P(proc)) if (NIL_P(proc))
return NULL; return NULL;
rl_attempted_completion_over = 1; 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)); ary = rb_funcall(proc, rb_intern("call"), 1, rb_tainted_str_new2(text));
if (TYPE(ary) != T_ARRAY) if (TYPE(ary) != T_ARRAY)
ary = rb_Array(ary); ary = rb_Array(ary);
@ -697,6 +698,9 @@ Init_readline()
using_history(); using_history();
completion_proc = rb_intern(COMPLETION_PROC);
completion_case_fold = rb_intern(COMPLETION_CASE_FOLD);
mReadline = rb_define_module("Readline"); mReadline = rb_define_module("Readline");
rb_define_module_function(mReadline, "readline", rb_define_module_function(mReadline, "readline",
readline_readline, -1); readline_readline, -1);

View File

@ -22,7 +22,7 @@ module IRB
_set_last_value(value) _set_last_value(value)
@workspace.evaluate self, "_ = IRB.CurrentContext.last_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 @eval_history_values.push @line_no, @last_value
@workspace.evaluate self, "__ = IRB.CurrentContext.instance_eval{@eval_history_values}" @workspace.evaluate self, "__ = IRB.CurrentContext.instance_eval{@eval_history_values}"
end end
@ -33,7 +33,7 @@ module IRB
attr_reader :eval_history attr_reader :eval_history
def eval_history=(no) def eval_history=(no)
if no if no
if @eval_history if (@eval_history ||= nil)
@eval_history_values.size(no) @eval_history_values.size(no)
else else
@eval_history_values = History.new(no) @eval_history_values = History.new(no)

View File

@ -203,6 +203,7 @@ module IRB
def CE.def_extend_command(cmd_name, load_file, *aliases) def CE.def_extend_command(cmd_name, load_file, *aliases)
Context.module_eval %[ Context.module_eval %[
def #{cmd_name}(*opts, &b) def #{cmd_name}(*opts, &b)
Context.module_eval {remove_method(:#{cmd_name})}
require "#{load_file}" require "#{load_file}"
send :#{cmd_name}, *opts, &b send :#{cmd_name}, *opts, &b
end end

View File

@ -97,7 +97,7 @@ module IRB
} }
} }
@CONF[:PROMPT_MODE] = :DEFAULT @CONF[:PROMPT_MODE] = (STDIN.tty? ? :DEFAULT : :NULL)
@CONF[:AUTO_INDENT] = false @CONF[:AUTO_INDENT] = false
@CONF[:CONTEXT_MODE] = 3 # use binding in function on TOPLEVEL_BINDING @CONF[:CONTEXT_MODE] = 3 # use binding in function on TOPLEVEL_BINDING
@ -123,11 +123,11 @@ module IRB
@CONF[:MATH_MODE] = true @CONF[:MATH_MODE] = true
when "-d" when "-d"
$DEBUG = true $DEBUG = true
when "-r" when /^-r(.+)?/
opt = ARGV.shift opt = $1 || ARGV.shift
@CONF[:LOAD_MODULES].push opt if opt @CONF[:LOAD_MODULES].push opt if opt
when "-I" when /^-I(.+)?/
opt = ARGV.shift opt = $1 || ARGV.shift
$LOAD_PATH.push opt if opt $LOAD_PATH.push opt if opt
when /^-K(.)/ when /^-K(.)/
$KCODE = $1 $KCODE = $1

View File

@ -10,7 +10,6 @@
# #
# #
autoload :Tempfile, "tempfile"
autoload :Kconv, "kconv" autoload :Kconv, "kconv"
module IRB module IRB
@ -126,15 +125,12 @@ module IRB
end end
def real_load(path, priv) def real_load(path, priv)
tmp_base = path.tr("./:", "___") src = self.String(File.read(path))
lc_file = Tempfile.new(tmp_base) if priv
File.foreach(path) do |line| eval("self", TOPLEVEL_BINDING).extend(Module.new {eval(src, nil, path)})
line = self.String(line) else
lc_file.print(line) eval(src, TOPLEVEL_BINDING, path)
end end
lc_file.close
toplevel_load lc_file.path, priv
lc_file.close(true)
end end
private :real_load private :real_load

View File

@ -116,7 +116,6 @@ class SLex
def create_subnode(chrs, preproc = nil, postproc = nil) def create_subnode(chrs, preproc = nil, postproc = nil)
if chrs.empty? if chrs.empty?
if @postproc if @postproc
p node
SLex.fail ErrNodeAlreadyExists SLex.fail ErrNodeAlreadyExists
else else
print "Warn: change abstract node to real node\n" if SLex.debug? print "Warn: change abstract node to real node\n" if SLex.debug?