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

ruby-changes:51954

From: nobu <ko1@a...>
Date: Fri, 3 Aug 2018 16:17:25 +0900 (JST)
Subject: [ruby-changes:51954] nobu:r64169 (trunk): random.c: moved domain error

nobu	2018-08-03 16:17:20 +0900 (Fri, 03 Aug 2018)

  New Revision: 64169

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

  Log:
    random.c: moved domain error
    
    * random.c (rand_range): moved call of domain_error(), not to
      raise an exception in range_values().

  Modified files:
    trunk/random.c
Index: random.c
===================================================================
--- random.c	(revision 64168)
+++ random.c	(revision 64169)
@@ -1164,7 +1164,7 @@ range_values(VALUE vmax, VALUE *begp, VA https://github.com/ruby/ruby/blob/trunk/random.c#L1164
 
     if (!rb_range_values(vmax, begp, &end, exclp)) return Qfalse;
     if (endp) *endp = end;
-    if (NIL_P(end)) domain_error();
+    if (NIL_P(end)) return Qnil;
     if (!rb_respond_to(end, id_minus)) return Qfalse;
     r = rb_funcallv(end, id_minus, 1, begp);
     if (NIL_P(r)) return Qfalse;
@@ -1252,6 +1252,7 @@ rand_range(VALUE obj, rb_random_t* rnd, https://github.com/ruby/ruby/blob/trunk/random.c#L1252
 
     if ((v = vmax = range_values(range, &beg, &end, &excl)) == Qfalse)
 	return Qfalse;
+    if (NIL_P(v)) domain_error();
     if (!RB_TYPE_P(vmax, T_FLOAT) && (v = rb_check_to_int(vmax), !NIL_P(v))) {
 	long max;
 	vmax = v;

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

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