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

ruby-changes:52516

From: hsbt <ko1@a...>
Date: Thu, 13 Sep 2018 16:40:44 +0900 (JST)
Subject: [ruby-changes:52516] hsbt:r64719: Move half-baked-1.9 branch to tags.

hsbt	2018-09-13 16:00:29 +0900 (Thu, 13 Sep 2018)

  New Revision: 64719

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64719

  Log:
    Move half-baked-1.9 branch to tags.

  Added directories:
    tags/half-baked-1.9/
  Removed directories:
    branches/half-baked-1.9/
Index: half-baked-1.9/math.c
===================================================================
--- half-baked-1.9/math.c	(revision 64718)
+++ half-baked-1.9/math.c	(nonexistent)
@@ -1,545 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/half-baked-1.9/math.c#L0
-/**********************************************************************
-
-  math.c -
-
-  $Author$
-  $Date$
-  created at: Tue Jan 25 14:12:56 JST 1994
-
-  Copyright (C) 1993-2003 Yukihiro Matsumoto
-
-**********************************************************************/
-
-#include "ruby.h"
-#include <math.h>
-#include <errno.h>
-
-VALUE rb_mMath;
-
-#define Need_Float(x) (x) = rb_Float(x)
-#define Need_Float2(x,y) do {\
-    Need_Float(x);\
-    Need_Float(y);\
-} while (0)
-
-static void
-domain_check(double x, char *msg)
-{
-    while(1) {
-	if (errno) {
-	    rb_sys_fail(msg);
-	}
-	if (isnan(x)) {
-#if defined(EDOM)
-	    errno = EDOM;
-#elif define(ERANGE)
-	    errno = ERANGE;
-#endif
-	    continue;
-	}
-	break;
-    }
-}
-
-
-/*
- *  call-seq:
- *     Math.atan2(y, x)  => float
- *  
- *  Computes the arc tangent given <i>y</i> and <i>x</i>. Returns
- *  -PI..PI.
- *     
- */
-
-static VALUE
-math_atan2(VALUE obj, VALUE y, VALUE x)
-{
-    Need_Float2(y, x);
-    return rb_float_new(atan2(RFLOAT(y)->value, RFLOAT(x)->value));
-}
-
-
-/*
- *  call-seq:
- *     Math.cos(x)    => float
- *  
- *  Computes the cosine of <i>x</i> (expressed in radians). Returns
- *  -1..1.
- */
-
-static VALUE
-math_cos(VALUE obj, VALUE x)
-{
-    Need_Float(x);
-    return rb_float_new(cos(RFLOAT(x)->value));
-}
-
-/*
- *  call-seq:
- *     Math.sin(x)    => float
- *  
- *  Computes the sine of <i>x</i> (expressed in radians). Returns
- *  -1..1.
- */
-
-static VALUE
-math_sin(VALUE obj, VALUE x)
-{
-    Need_Float(x);
-
-    return rb_float_new(sin(RFLOAT(x)->value));
-}
-
-
-/*
- *  call-seq:
- *     Math.tan(x)    => float
- *  
- *  Returns the tangent of <i>x</i> (expressed in radians).
- */
-
-static VALUE
-math_tan(VALUE obj, VALUE x)
-{
-    Need_Float(x);
-
-    return rb_float_new(tan(RFLOAT(x)->value));
-}
-
-/*
- *  call-seq:
- *     Math.acos(x)    => float
- *  
- *  Computes the arc cosine of <i>x</i>. Returns 0..PI.
- */
-
-static VALUE
-math_acos(VALUE obj, VALUE x)
-{
-    double d;
-
-    Need_Float(x);
-    errno = 0;
-    d = acos(RFLOAT(x)->value);
-    domain_check(d, "acos");
-    return rb_float_new(d);
-}
-
-/*
- *  call-seq:
- *     Math.asin(x)    => float
- *  
- *  Computes the arc sine of <i>x</i>. Returns 0..PI.
- */
-
-static VALUE
-math_asin(VALUE obj, VALUE x)
-{
-    double d;
-
-    Need_Float(x);
-    errno = 0;
-    d = asin(RFLOAT(x)->value);
-    domain_check(d, "asin");
-    return rb_float_new(d);
-}
-
-/*
- *  call-seq:
- *     Math.atan(x)    => float
- *  
- *  Computes the arc tangent of <i>x</i>. Returns -{PI/2} .. {PI/2}.
- */
-
-static VALUE
-math_atan(VALUE obj, VALUE x)
-{
-    Need_Float(x);
-    return rb_float_new(atan(RFLOAT(x)->value));
-}
-
-#ifndef HAVE_COSH
-double
-cosh(double x)
-{
-    return (exp(x) + exp(-x)) / 2;
-}
-#endif
-
-/*
- *  call-seq:
- *     Math.cosh(x)    => float
- *  
- *  Computes the hyperbolic cosine of <i>x</i> (expressed in radians).
- */
-
-static VALUE
-math_cosh(VALUE obj, VALUE x)
-{
-    Need_Float(x);
-    
-    return rb_float_new(cosh(RFLOAT(x)->value));
-}
-
-#ifndef HAVE_SINH
-double
-sinh(double x)
-{
-    return (exp(x) - exp(-x)) / 2;
-}
-#endif
-
-/*
- *  call-seq:
- *     Math.sinh(x)    => float
- *  
- *  Computes the hyperbolic sine of <i>x</i> (expressed in
- *  radians).
- */
-
-static VALUE
-math_sinh(VALUE obj, VALUE x)
-{
-    Need_Float(x);
-    return rb_float_new(sinh(RFLOAT(x)->value));
-}
-
-#ifndef HAVE_TANH
-double
-tanh(double x)
-{
-    return sinh(x) / cosh(x);
-}
-#endif
-
-/*
- *  call-seq:
- *     Math.tanh()    => float
- *  
- *  Computes the hyperbolic tangent of <i>x</i> (expressed in
- *  radians).
- */
-
-static VALUE
-math_tanh(VALUE obj, VALUE x)
-{
-    Need_Float(x);
-    return rb_float_new(tanh(RFLOAT(x)->value));
-}
-
-/*
- *  call-seq:
- *     Math.acosh(x)    => float
- *  
- *  Computes the inverse hyperbolic cosine of <i>x</i>.
- */
-
-static VALUE
-math_acosh(VALUE obj, VALUE x)
-{
-    double d;
-
-    Need_Float(x);
-    errno = 0;
-    d = acosh(RFLOAT(x)->value);
-    domain_check(d, "acosh");
-    return rb_float_new(d);
-}
-
-/*
- *  call-seq:
- *     Math.asinh(x)    => float
- *  
- *  Computes the inverse hyperbolic sine of <i>x</i>.
- */
-
-static VALUE
-math_asinh(VALUE obj, VALUE x)
-{
-    Need_Float(x);
-    return rb_float_new(asinh(RFLOAT(x)->value));
-}
-
-/*
- *  call-seq:
- *     Math.atanh(x)    => float
- *  
- *  Computes the inverse hyperbolic tangent of <i>x</i>.
- */
-
-static VALUE
-math_atanh(VALUE obj, VALUE x)
-{
-    double d;
-
-    Need_Float(x);
-    errno = 0;
-    d = atanh(RFLOAT(x)->value);
-    domain_check(d, "atanh");
-    return rb_float_new(d);
-}
-
-/*
- *  call-seq:
- *     Math.exp(x)    => float
- *  
- *  Returns e**x.
- */
-
-static VALUE
-math_exp(VALUE obj, VALUE x)
-{
-    Need_Float(x);
-    return rb_float_new(exp(RFLOAT(x)->value));
-}
-
-#if defined __CYGWIN__
-# include <cygwin/version.h>
-# if CYGWIN_VERSION_DLL_MAJOR < 1005
-#  define nan(x) nan()
-# endif
-# define log(x) ((x) < 0.0 ? nan("") : log(x))
-# define log10(x) ((x) < 0.0 ? nan("") : log10(x))
-#endif
-
-/*
- *  call-seq:
- *     Math.log(numeric)    => float
- *     Math.log(num,base)   => float
- *  
- *  Returns the natural logarithm of <i>numeric</i>.
- *  If additional second argument is given, it will be the base
- *  of logarithm.
- */
-
-static VALUE
-math_log(int argc, VALUE *argv)
-{
-    VALUE x, base;
-    double d;
-
-    rb_scan_args(argc, argv, "11", &x, &base);
-    Need_Float(x);
-    errno = 0;
-    d = log(RFLOAT(x)->value);
-    if (!NIL_P(base)) {
-	Need_Float(base);
-	d /= log(RFLOAT(base)->value);
-    }
-    domain_check(d, "log");
-    return rb_float_new(d);
-}
-
-#ifndef log2
-#ifndef HAVE_LOG2
-double
-log2(double x)
-{
-    return log10(x)/log10(2.0);
-}
-#else
-extern double log2(double);
-#endif
-#endif
-
-/*
- *  call-seq:
- *     Math.log2(numeric)    => float
- *  
- *  Returns the base 2 logarithm of <i>numeric</i>.
- */
-
-static VALUE
-math_log2(VALUE obj, VALUE x)
-{
-    double d;
-
-    Need_Float(x);
-    errno = 0;
-    d = log2(RFLOAT(x)->value);
-    if (errno) {
-	rb_sys_fail("log2");
-    }
-    return rb_float_new(d);
-}
-
-/*
- *  call-seq:
- *     Math.log10(numeric)    => float
- *  
- *  Returns the base 10 logarithm of <i>numeric</i>.
- */
-
-static VALUE
-math_log10(VALUE obj, VALUE x)
-{
-    double d;
-
-    Need_Float(x);
-    errno = 0;
-    d = log10(RFLOAT(x)->value);
-    domain_check(d, "log10");
-    return rb_float_new(d);
-}
-
-/*
- *  call-seq:
- *     Math.sqrt(numeric)    => float
- *  
- *  Returns the non-negative square root of <i>numeric</i>.
- */
-
-static VALUE
-math_sqrt(VALUE obj, VALUE x)
-{
-    double d;
-
-    Need_Float(x);
-    errno = 0;
-    d = sqrt(RFLOAT(x)->value);
-    domain_check(d, "sqrt");
-    return rb_float_new(d);
-}
-
-/*
- *  call-seq:
- *     Math.frexp(numeric)    => [ fraction, exponent ]
- *  
- *  Returns a two-element array containing the normalized fraction (a
- *  <code>Float</code>) and exponent (a <code>Fixnum</code>) of
- *  <i>numeric</i>.
- *     
- *     fraction, exponent = Math.frexp(1234)   #=> [0.6025390625, 11]
- *     fraction * 2**exponent                  #=> 1234.0
- */
-
-static VALUE
-math_frexp(VALUE obj, VALUE x)
-{
-    double d;
-    int exp;
-
-    Need_Float(x);
-    
-    d = frexp(RFLOAT(x)->value, &exp);
-    return rb_assoc_new(rb_float_new(d), INT2NUM(exp));
-}
-
-/*
- *  call-seq:
- *     Math.ldexp(flt, int) -> float
- *  
- *  Returns the value of <i>flt</i>*(2**<i>int</i>).
- *     
- *     fraction, exponent = Math.frexp(1234)
- *     Math.ldexp(fraction, exponent)   #=> 1234.0
- */
-
-static VALUE
-math_ldexp(VALUE obj, VALUE x, VALUE n)
-{
-    Need_Float(x);
-    return rb_float_new(ldexp(RFLOAT(x)->value, NUM2INT(n)));
-}
-
-/*
- *  call-seq:
- *     Math.hypot(x, y)    => float
- *  
- *  Returns sqrt(x**2 + y**2), the hypotenuse of a right-angled triangle
- *  with sides <i>x</i> and <i>y</i>.
- *     
- *     Math.hypot(3, 4)   #=> 5.0
- */
-
-static VALUE
-math_hypot(VALUE obj, VALUE x, VALUE y)
-{
-    Need_Float2(x, y);
-    return rb_float_new(hypot(RFLOAT(x)->value, RFLOAT(y)->value));
-}
-
-/*
- * call-seq:
- *    Math.erf(x)  => float
- *
- *  Calculates the error function of x.
- */
-
-static VALUE
-math_erf(VALUE obj, VALUE x)
-{
-    Need_Float(x);
-    return rb_float_new(erf(RFLOAT(x)->value));
-}
-
-/*
- * call-seq:
- *    Math.erfc(x)  => float
- *
- *  Calculates the complementary error function of x.
- */
-
-static VALUE
-math_erfc(VALUE obj, VALUE x)
-{
-    Need_Float(x);
-    return rb_float_new(erfc(RFLOAT(x)->value));
-}
-
-/*
- *  The <code>Math</code> module contains module functions for basic
- *  trigonometric and transcendental functions. See class
- *  <code>Float</code> for a list of constants that
- *  define Ruby's floating point accuracy.
- */     
-
-
-void
-Init_Math(void)
-{
-    rb_mMath = rb_define_module("Math");
-
-#ifdef M_PI
-    rb_define_const(rb_mMath, "PI", rb_float_new(M_PI));
-#else
-    rb_define_const(rb_mMath, "PI", rb_float_new(atan(1.0)*4.0));
-#endif
-
-#ifdef M_E
-    rb_define_const(rb_mMath, "E", rb_float_new(M_E));
-#else
-    rb_define_const(rb_mMath, "E", rb_float_new(exp(1.0)));
-#endif
-
-    rb_define_module_function(rb_mMath, "atan2", math_atan2, 2);
-    rb_define_module_function(rb_mMath, "cos", math_cos, 1);
-    rb_define_module_function(rb_mMath, "sin", math_sin, 1);
-    rb_define_module_function(rb_mMath, "tan", math_tan, 1);
-
-    rb_define_module_function(rb_mMath, "acos", math_acos, 1);
-    rb_define_module_function(rb_mMath, "asin", math_asin, 1);
-    rb_define_module_function(rb_mMath, "atan", math_atan, 1);
-
-    rb_define_module_function(rb_mMath, "cosh", math_cosh, 1);
-    rb_define_module_function(rb_mMath, "sinh", math_sinh, 1);
-    rb_define_module_function(rb_mMath, "tanh", math_tanh, 1);
-
-    rb_define_module_function(rb_mMath, "acosh", math_acosh, 1);
-    rb_define_module_function(rb_mMath, "asinh", math_asinh, 1);
-    rb_define_module_function(rb_mMath, "atanh", math_atanh, 1);
-
-    rb_define_module_function(rb_mMath, "exp", math_exp, 1);
-    rb_define_module_function(rb_mMath, "log", math_log, -1);
-    rb_define_module_function(rb_mMath, "log2", math_log2, 1);
-    rb_define_module_function(rb_mMath, "log10", math_log10, 1);
-    rb_define_module_function(rb_mMath, "sqrt", math_sqrt, 1);
-
-    rb_define_module_function(rb_mMath, "frexp", math_frexp, 1);
-    rb_define_module_function(rb_mMath, "ldexp", math_ldexp, 2);
-
-    rb_define_module_function(rb_mMath, "hypot", math_hypot, 2);
-
-    rb_define_module_function(rb_mMath, "erf",  math_erf,  1);
-    rb_define_module_function(rb_mMath, "erfc", math_erfc, 1);
-}

Property changes on: half-baked-1.9/math.c
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-LF
\ No newline at end of property
Deleted: svn:keywords
## -1 +0,0 ##
-Author Date Id Revision
\ No newline at end of property
Index: half-baked-1.9/range.c
===================================================================
--- half-baked-1.9/range.c	(revision 64718)
+++ half-baked-1.9/range.c	(nonexistent)
@@ -1,810 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/half-baked-1.9/range.c#L0
-/**********************************************************************
-
-  range.c -
-
-  $Author$
-  $Date$
-  created at: Thu Aug 19 17:46:47 JST 1993
-
-  Copyright (C) 1993-2003 Yukihiro Matsumoto
-
-**********************************************************************/
-
-#include "ruby.h"
-
-VALUE rb_cRange;
-static ID id_cmp, id_succ, id_beg, id_end, id_excl;
-
-#define EXCL(r) RTEST(rb_ivar_get((r), id_excl))
-#define SET_EXCL(r,v) rb_ivar_set((r), id_excl, (v) ? Qtrue : Qfalse)
-
-static VALUE
-range_failed(void)
-{
-    rb_raise(rb_eArgError, "bad value for range");
-    return Qnil;		/* dummy */
-}
-
-static VALUE
-range_check(VALUE *args)
-{
-    return rb_funcall(args[0], id_cmp, 1, args[1]);
-}
-
-static void
-range_init(VALUE range, VALUE beg, VALUE end, int exclude_end)
-{
-    VALUE args[2];
-
-    args[0] = beg;
-    args[1] = end;
-    
-    if (!FIXNUM_P(beg) || !FIXNUM_P(end)) {
-	VALUE v;
-
-	v = rb_rescue(range_check, (VALUE)args, range_failed, 0);
-	if (NIL_P(v))
-	    range_failed();
-    }
-
-    SET_EXCL(range, exclude_end);
-    rb_ivar_set(range, id_beg, beg);
-    rb_ivar_set(range, id_end, end);
-}
-
-VALUE
-rb_range_new(VALUE beg, VALUE end, int exclude_end)
-{
-    VALUE range = rb_obj_alloc(rb_cRange);
-
-    range_init(range, beg, end, exclude_end);
-    return range;
-}
-
-/*
- *  call-seq:
- *     Range.new(start, end, exclusive=false)    => range
- *  
- *  Constructs a range using the given <i>start</i> and <i>end</i>. If the third
- *  parameter is omitted or is <code>false</code>, the <i>range</i> will include
- *  the end object; otherwise, it will be excluded.
- */
-
-static VALUE
-range_initialize(int argc, VALUE *argv, VALUE range)
-{
-    VALUE beg, end, flags;
-    
-    rb_scan_args(argc, argv, "21", &beg, &end, &flags);
-    /* Ranges are immutable, so that they should be initialized only once. */
-    if (rb_ivar_defined(range, id_beg)) {
-	rb_name_error(rb_intern("initialize"), "`initialize' called twice");
-    }
-    range_init(range, beg, end, RTEST(flags));
-    return Qnil;
-}
-
-
-/*
- *  call-seq:
- *     rng.exclude_end?    => true or false
- *  
- *  Returns <code>true</code> if <i>rng</i> excludes its end value.
- */
-
-static VALUE
-range_exclude_end_p(VALUE range)
-{
-    return EXCL(range) ? Qtrue : Qfalse;
-}
-
-
-/*
- *  call-seq:
- *     rng == obj    => true or false
- *  
- *  Returns <code>true</code> only if <i>obj</i> is a Range, has equivalent
- *  beginning and end items (by comparing them with <code>==</code>), and has
- *  the same #exclude_end? setting as <i>rng</t>.
- *     
- *    (0..2) == (0..2)            #=> true
- *    (0..2) == Range.new(0,2)    #=> true
- *    (0..2) == (0...2)           #=> false
- *     
- */
-
-static VALUE
-range_eq(VALUE range, VALUE obj)
-{
-    if (range == obj)
-	return Qtrue;
-    if (!rb_obj_is_instance_of(obj, rb_obj_class(range)))
-	return Qfalse;
-
-    if (!rb_equal(rb_ivar_get(range, id_beg), rb_ivar_get(obj, id_beg)))
-	return Qfalse;
-    if (!rb_equal(rb_ivar_get(range, id_end), rb_ivar_get(obj, id_end)))
-	return Qfalse;
-
-    if (EXCL(range) != EXCL(obj))
-	return Qfalse;
-
-    return Qtrue;
-}
-
-static int
-r_lt(VALUE a, VALUE b)
-{
-    VALUE r = rb_funcall(a, id_cmp, 1, b);
-
-    if (NIL_P(r))
-	return Qfalse;
-    if (rb_cmpint(r, a, b) < 0)
-	return Qtrue;
-    return Qfalse;
-}
-
-static int
-r_le(VALUE a, VALUE b)
-{
-    int c;
-    VALUE r = rb_funcall(a, id_cmp, 1, b);
-
-    if (NIL_P(r))
-	return Qfalse;
-    c = rb_cmpint(r, a, b);
-    if (c == 0)
-	return INT2FIX(0);
-    if (c < 0)
-	return Qtrue;
-    return Qfalse;
-}
-
-
-/*
- *  call-seq:
- *     rng.eql?(obj)    => true or false
- *  
- *  Returns <code>true</code> only if <i>obj</i> is a Range, has equivalent
- *  beginning and end items (by comparing them with #eql?), and has the same
- *  #exclude_end? setting as <i>rng</i>.
- *     
- *    (0..2) == (0..2)            #=> true
- *    (0..2) == Range.new(0,2)    #=> true
- *    (0..2) == (0...2)           #=> false
- *     
- */
-
-static VALUE
-range_eql(VALUE range, VALUE obj)
-{
-    if (range == obj)
-	return Qtrue;
-    if (!rb_obj_is_instance_of(obj, rb_obj_class(range)))
-	return Qfalse;
-
-    if (!rb_eql(rb_ivar_get(range, id_beg), rb_ivar_get(obj, id_beg)))
-	return Qfalse;
-    if (!rb_eql(rb_ivar_get(range, id_end), rb_ivar_get(obj, id_end)))
-	return Qfalse;
-
-    if (EXCL(range) != EXCL(obj))
-	return Qfalse;
-
-    return Qtrue;
-}
-
-/*
- * call-seq:
- *   rng.hash    => fixnum
- *
- * Generate a hash value such that two ranges with the same start and
- * end points, and the same value for the "exclude end" flag, generate
- * the same hash value.
- */
-
-static VALUE
-range_hash(VALUE range)
-{
-    long hash = EXCL(range);
-    VALUE v;
-
-    v = rb_hash(rb_ivar_get(range, id_beg));
-    hash ^= v << 1;
-    v = rb_hash(rb_ivar_get(range, id_end));
-    hash ^= v << 9;
-    hash ^= EXCL(range) << 24;
-
-    return LONG2FIX(hash);
-}
-
-static VALUE
-str_step(VALUE arg)
-{
-    VALUE *args = (VALUE *)arg;
-
-    return rb_str_upto(args[0], args[1], EXCL(args[2]));
-}
-
-static void
-range_each_func(VALUE range, VALUE (*func) (VALUE, void *), VALUE v, VALUE e,
-		void *arg)
-{
-    int c;
-
-    if (EXCL(range)) {
-	while (r_lt(v, e)) {
-	    (*func) (v, arg);
-	    v = rb_funcall(v, id_succ, 0, 0);
-	}
-    }
-    else {
-	while (RTEST(c = r_le(v, e))) {
-	    (*func) (v, arg);
-	    if (c == INT2FIX(0))
-		break;
-	    v = rb_funcall(v, id_succ, 0, 0);
-	}
-    }
-}
-
-static VALUE
-step_i(VALUE i, void *arg)
-{
-    long *iter = (long *)arg;
-
-    iter[0]--;
-    if (iter[0] == 0) {
-	rb_yield(i);
-	iter[0] = iter[1];
-    }
-    return Qnil;
-}
-
-/*
- *  call-seq:
- *     rng.step(n=1) {| obj | block }    => rng
- *  
- *  Iterates over <i>rng</i>, passing each <i>n</i>th element to the block. If
- *  the range contains numbers or strings, natural ordering is used.  Otherwise
- *  <code>step</code> invokes <code>succ</code> to iterate through range
- *  elements. The following code uses class <code>Xs</code>, which is defined
- *  in the class-level documentation.
- *     
- *     range = Xs.new(1)..Xs.new(10)
- *     range.step(2) {|x| puts x}
- *     range.step(3) {|x| puts x}
- *     
- *  <em>produces:</em>
- *     
- *      1 x
- *      3 xxx
- *      5 xxxxx
- *      7 xxxxxxx
- *      9 xxxxxxxxx
- *      1 x
- *      4 xxxx
- *      7 xxxxxxx
- *     10 xxxxxxxxxx
- */
-
-
-static VALUE
-range_step(int argc, VALUE *argv, VALUE range)
-{
-    VALUE b, e, step;
-    long unit;
-
-    RETURN_ENUMERATOR(range, argc, argv);
-
-    b = rb_ivar_get(range, id_beg);
-    e = rb_ivar_get(range, id_end);
-    if (rb_scan_args(argc, argv, "01", &step) == 0) {
-	step = INT2FIX(1);
-    }
-
-    unit = NUM2LONG(step);
-    if (unit < 0) {
-	rb_raise(rb_eArgError, "step can't be negative");
-    } 
-    if (unit == 0)
-	rb_raise(rb_eArgError, "step can't be 0");
-    if (FIXNUM_P(b) && FIXNUM_P(e)) { /* fixnums are special */
-	long end = FIX2LONG(e);
-	long i;
-
-	if (!EXCL(range))
-	    end += 1;
-	for (i = FIX2LONG(b); i < end; i += unit) {
-	    rb_yield(LONG2NUM(i));
-	}
-    }
-    else {
-	VALUE tmp = rb_check_string_type(b);
-
-	if (!NIL_P(tmp)) {
-	    VALUE args[5];
-	    long iter[2];
-
-	    b = tmp;
-	    args[0] = b;
-	    args[1] = e;
-	    args[2] = range;
-	    iter[0] = 1;
-	    iter[1] = unit;
-	    rb_iterate(str_step, (VALUE)args, step_i, (VALUE)iter);
-	}
-	else if (rb_obj_is_kind_of(b, rb_cNumeric)) {
-	    ID c = rb_intern(EXCL(range) ? "<" : "<=");
-
-	    if (rb_equal(step, INT2FIX(0)))
-		rb_raise(rb_eArgError, "step can't be 0");
-	    while (RTEST(rb_funcall(b, c, 1, e))) {
-		rb_yield(b);
-		b = rb_funcall(b, '+', 1, step);
-	    }
-	}
-	else {
-	    long args[2];
-
-	    if (!rb_respond_to(b, id_succ)) {
-		rb_raise(rb_eTypeError, "can't iterate from %s",
-			 rb_obj_classname(b));
-	    }
-	    args[0] = 1;
-	    args[1] = unit;
-	    range_each_func(range, step_i, b, e, args);
-	}
-    }
-    return range;
-}
-
-static VALUE
-each_i(VALUE v, void *arg)
-{
-    rb_yield(v);
-    return Qnil;
-}
-
-/*
- *  call-seq:
- *     rng.each {| i | block } => rng
- *  
- *  Iterates over the elements <i>rng</i>, passing each in turn to the
- *  block. You can only iterate if the start object of the range
- *  supports the +succ+ (... truncated)

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

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