ruby-changes:47798
From: nobu <ko1@a...>
Date: Fri, 15 Sep 2017 09:59:39 +0900 (JST)
Subject: [ruby-changes:47798] nobu:r59916 (trunk): rubyspec: fix types
nobu 2017-09-15 09:59:32 +0900 (Fri, 15 Sep 2017) New Revision: 59916 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59916 Log: rubyspec: fix types * spec/rubyspec/optional/capi/ext/fixnum_spec.c: FIX2INT and FXI2UINT return long, in spite of their names. * spec/rubyspec/optional/capi/ext/range_spec.c: err is int. * spec/rubyspec/optional/capi/ext/st_spec.c: st_index_t is larger than int. Modified files: trunk/spec/rubyspec/optional/capi/ext/fixnum_spec.c trunk/spec/rubyspec/optional/capi/ext/range_spec.c trunk/spec/rubyspec/optional/capi/ext/st_spec.c Index: spec/rubyspec/optional/capi/ext/range_spec.c =================================================================== --- spec/rubyspec/optional/capi/ext/range_spec.c (revision 59915) +++ spec/rubyspec/optional/capi/ext/range_spec.c (revision 59916) @@ -34,7 +34,7 @@ VALUE range_spec_rb_range_beg_len(VALUE https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/ext/range_spec.c#L34 long begp = FIX2LONG(begpv); long lenp = FIX2LONG(lenpv); long len = FIX2LONG(lenv); - long err = FIX2LONG(errv); + int err = FIX2INT(errv); VALUE ary = rb_ary_new(); VALUE res = rb_range_beg_len(range, &begp, &lenp, len, err); rb_ary_store(ary, 0, LONG2FIX(begp)); Index: spec/rubyspec/optional/capi/ext/fixnum_spec.c =================================================================== --- spec/rubyspec/optional/capi/ext/fixnum_spec.c (revision 59915) +++ spec/rubyspec/optional/capi/ext/fixnum_spec.c (revision 59916) @@ -17,15 +17,15 @@ static VALUE fixnum_spec_FIX2UINT(VALUE https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/ext/fixnum_spec.c#L17 #ifdef HAVE_RB_FIX2UINT static VALUE fixnum_spec_rb_fix2uint(VALUE self, VALUE value) { - unsigned int i = rb_fix2uint(value); - return UINT2NUM(i); + unsigned long i = rb_fix2uint(value); + return ULONG2NUM(i); } #endif #ifdef HAVE_RB_FIX2INT static VALUE fixnum_spec_rb_fix2int(VALUE self, VALUE value) { - int i = rb_fix2int(value); - return INT2NUM(i); + long i = rb_fix2int(value); + return LONG2NUM(i); } #endif Index: spec/rubyspec/optional/capi/ext/st_spec.c =================================================================== --- spec/rubyspec/optional/capi/ext/st_spec.c (revision 59915) +++ spec/rubyspec/optional/capi/ext/st_spec.c (revision 59916) @@ -13,31 +13,37 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/ext/st_spec.c#L13 #endif #ifdef HAVE_RB_ST +# if SIZEOF_LONG == SIZEOF_VOIDP +# define ST2NUM(x) ULONG2NUM(x) +#else +# define ST2NUM(x) ULL2NUM(x) +#endif + VALUE st_spec_st_init_numtable(VALUE self) { st_table *tbl = st_init_numtable(); - int entries = tbl->num_entries; + st_index_t entries = tbl->num_entries; st_free_table(tbl); - return INT2FIX(entries); + return ST2NUM(entries); } VALUE st_spec_st_init_numtable_with_size(VALUE self) { st_table *tbl = st_init_numtable_with_size(128); - int entries = tbl->num_entries; + st_index_t entries = tbl->num_entries; st_free_table(tbl); - return INT2FIX(entries); + return ST2NUM(entries); } VALUE st_spec_st_insert(VALUE self) { - int entries; + st_index_t entries; st_table *tbl = st_init_numtable_with_size(128); st_insert(tbl, 1, 1); entries = tbl->num_entries; st_free_table(tbl); - return INT2FIX(entries); + return ST2NUM(entries); } static int sum(st_data_t key, st_data_t value, st_data_t arg) { - *(int*)arg += value; + *(int*)arg += (int)value; return ST_CONTINUE; } @@ -58,7 +64,11 @@ VALUE st_spec_st_lookup(VALUE self) { https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/ext/st_spec.c#L64 st_insert(tbl, 2, 4); st_lookup(tbl, (st_data_t)7, &result); st_free_table(tbl); - return INT2FIX(result); +#if SIZEOF_LONG == SIZEOF_VOIDP + return ULONG2NUM(result); +#else + return ULL2NUM(result); +#endif } #endif -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/