[前][次][番号順一覧][スレッド一覧]

ruby-changes:14179

From: nobu <ko1@a...>
Date: Sat, 5 Dec 2009 10:18:58 +0900 (JST)
Subject: [ruby-changes:14179] Ruby:r25998 (trunk): * lib/irb/extend-command.rb (def_extend_command): fixed argument

nobu	2009-12-05 10:18:28 +0900 (Sat, 05 Dec 2009)

  New Revision: 25998

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25998

  Log:
    * lib/irb/extend-command.rb (def_extend_command): fixed argument
      number for negative arity.

  Modified files:
    trunk/ChangeLog
    trunk/lib/irb/extend-command.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 25997)
+++ ChangeLog	(revision 25998)
@@ -1,3 +1,8 @@
+Sat Dec  5 10:18:26 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* lib/irb/extend-command.rb (def_extend_command): fixed argument
+	  number for negative arity.
+
 Fri Dec  4 16:50:13 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* parse.y (k_def): adjust the location of method definition to the
Index: lib/irb/extend-command.rb
===================================================================
--- lib/irb/extend-command.rb	(revision 25997)
+++ lib/irb/extend-command.rb	(revision 25998)
@@ -122,28 +122,28 @@
       end
 
       if load_file
-	eval %[
+	line = __LINE__; eval %[
 	  def #{cmd_name}(*opts, &b)
 	    require "#{load_file}"
 	    arity = ExtendCommand::#{cmd_class}.instance_method(:execute).arity
-	    args = (1..arity.abs).map {|i| "arg" + i.to_s }
+	    args = (1..(arity < 0 ? ~arity : arity)).map {|i| "arg" + i.to_s }
 	    args << "*opts" if arity < 0
 	    args << "&block"
 	    args = args.join(", ")
-	    eval %[
+	    line = __LINE__; eval %[
 	      def #{cmd_name}(\#{args})
 		ExtendCommand::#{cmd_class}.execute(irb_context, \#{args})
 	      end
-	    ]
+	    ], nil, __FILE__, line
 	    send :#{cmd_name}, *opts, &b
 	  end
-	]
+	], nil, __FILE__, line
       else
-	eval %[
+	line = __LINE__; eval %[
 	  def #{cmd_name}(*opts, &b)
 	    ExtendCommand::#{cmd_class}.execute(irb_context, *opts, &b)
 	  end
-	]
+	], nil, __FILE__, line
       end
 
       for ali, flag in aliases
@@ -160,7 +160,7 @@
 	  (override == OVERRIDE_PRIVATE_ONLY) && !respond_to?(to) or
 	  (override == NO_OVERRIDE) &&  !respond_to?(to, true)
 	target = self
-	(class<<self;self;end).instance_eval{
+	(class << self; self; end).instance_eval{
 	  if target.respond_to?(to, true) &&
 	      !target.respond_to?(EXCB.irb_original_method_name(to), true)
 	    alias_method(EXCB.irb_original_method_name(to), to)
@@ -177,7 +177,7 @@
     end
 
     def self.extend_object(obj)
-      unless (class<<obj;ancestors;end).include?(EXCB)
+      unless (class << obj; ancestors; end).include?(EXCB)
 	super
 	for ali, com, flg in @ALIASES
 	  obj.install_alias_method(ali, com, flg)
@@ -207,7 +207,7 @@
     end
 
     def self.def_extend_command(cmd_name, load_file, *aliases)
-      Context.module_eval %[
+      line = __LINE__; Context.module_eval %[
         def #{cmd_name}(*opts, &b)
 	  Context.module_eval {remove_method(:#{cmd_name})}
 	  require "#{load_file}"
@@ -216,7 +216,7 @@
 	for ali in aliases
 	  alias_method ali, cmd_name
 	end
-      ]
+      ], __FILE__, line
     end
 
     CE.install_extend_commands

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]