Ignore:
Timestamp:
Jan 21, 2018, 12:10:09 AM (6 years ago)
Author:
coas-nagasima
Message:

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

Location:
EcnlProtoTool/trunk/mruby-1.3.0
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-enum-ext/mrblib/enum.rb

    r321 r331  
    5959  def take(n)
    6060    raise TypeError, "no implicit conversion of #{n.class} into Integer" unless n.respond_to?(:to_int)
    61     raise ArgumentError, "attempt to take negative size" if n < 0
    62 
    63     n = n.to_int
    64     ary = []
    65     self.each do |*val|
    66       break if ary.size >= n
     61    i = n.to_int
     62    raise ArgumentError, "attempt to take negative size" if i < 0
     63    ary = []
     64    return ary if i == 0
     65    self.each do |*val|
    6766      ary << val.__svalue
     67      i -= 1
     68      break if i == 0
    6869    end
    6970    ary
     
    124125      block.call(ary.dup) if ary.size == n
    125126    end
     127    nil
    126128  end
    127129
     
    154156    end
    155157    block.call(ary) unless ary.empty?
     158    nil
    156159  end
    157160
     
    215218  # If the enumerable is empty, the first form returns <code>nil</code>, and the
    216219  # second form returns an empty array.
    217   def first(n=NONE)
    218     if n == NONE
     220  def first(*args)
     221    case args.length
     222    when 0
    219223      self.each do |*val|
    220224        return val.__svalue
    221225      end
    222226      return nil
     227    when 1
     228      n = args[0]
     229      raise TypeError, "no implicit conversion of #{n.class} into Integer" unless n.respond_to?(:to_int)
     230      i = n.to_int
     231      raise ArgumentError, "attempt to take negative size" if i < 0
     232      ary = []
     233      return ary if i == 0
     234      self.each do |*val|
     235        ary << val.__svalue
     236        i -= 1
     237        break if i == 0
     238      end
     239      ary
    223240    else
    224       a = []
    225       i = 0
    226       self.each do |*val|
    227         break if n<=i
    228         a.push val.__svalue
    229         i += 1
    230       end
    231       a
     241      raise ArgumentError, "wrong number of arguments (given #{args.length}, expected 0..1)"
    232242    end
    233243  end
     
    385395        first = false
    386396      else
     397        val = val.__svalue
    387398        if block
    388           max = val.__svalue if block.call(*val, max) > 0
    389           min = val.__svalue if block.call(*val, min) < 0
     399          max = val if block.call(val, max) > 0
     400          min = val if block.call(val, min) < 0
    390401        else
    391           val = val.__svalue
    392402          max = val if (val <=> max) > 0
    393403          min = val if (val <=> min) < 0
     
    574584  #
    575585
    576   def cycle(n=nil, &block)
    577     return to_enum(:cycle, n) if !block && n.nil?
    578 
    579     ary = []
    580     if n.nil?
    581       self.each do|*val|
    582         ary.push val
    583         block.call(*val)
    584       end
    585       loop do
    586         ary.each do|e|
    587           block.call(*e)
    588         end
    589       end
     586  def cycle(nv = nil, &block)
     587    return to_enum(:cycle, nv) unless block
     588
     589    n = nil
     590
     591    if nv.nil?
     592      n = -1
    590593    else
    591       raise TypeError, "no implicit conversion of #{n.class} into Integer" unless n.respond_to?(:to_int)
    592 
    593       n = n.to_int
    594       self.each do|*val|
    595         ary.push val
    596       end
    597       count = 0
    598       while count < n
    599         ary.each do|e|
    600           block.call(*e)
    601         end
    602         count += 1
    603       end
    604     end
     594      unless nv.respond_to?(:to_int)
     595        raise TypeError, "no implicit conversion of #{nv.class} into Integer"
     596      end
     597      n = nv.to_int
     598      unless n.kind_of?(Integer)
     599        raise TypeError, "no implicit conversion of #{nv.class} into Integer"
     600      end
     601      return nil if n <= 0
     602    end
     603
     604    ary = []
     605    each do |*i|
     606      ary.push(i)
     607      yield(*i)
     608    end
     609    return nil if ary.empty?
     610
     611    while n < 0 || 0 < (n -= 1)
     612      ary.each do |i|
     613        yield(*i)
     614      end
     615    end
     616
     617    nil
    605618  end
    606619
Note: See TracChangeset for help on using the changeset viewer.