diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-15 00:59:32 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-15 00:59:32 +0000 |
commit | 3948372201e912e455211d4d5eb14e7c670da0b1 (patch) | |
tree | 6d11b5bf45018086da23558fa653f8777f1b4852 /spec | |
parent | c7fa2bf56820dc06c6771852380d5d3fe6157896 (diff) | |
download | ruby-3948372201e912e455211d4d5eb14e7c670da0b1.tar.gz |
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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec')
-rw-r--r-- | spec/rubyspec/optional/capi/ext/fixnum_spec.c | 8 | ||||
-rw-r--r-- | spec/rubyspec/optional/capi/ext/range_spec.c | 2 | ||||
-rw-r--r-- | spec/rubyspec/optional/capi/ext/st_spec.c | 26 |
3 files changed, 23 insertions, 13 deletions
diff --git a/spec/rubyspec/optional/capi/ext/fixnum_spec.c b/spec/rubyspec/optional/capi/ext/fixnum_spec.c index 78d452f936..c3a207b387 100644 --- a/spec/rubyspec/optional/capi/ext/fixnum_spec.c +++ b/spec/rubyspec/optional/capi/ext/fixnum_spec.c @@ -17,15 +17,15 @@ static VALUE fixnum_spec_FIX2UINT(VALUE self, VALUE value) { #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 diff --git a/spec/rubyspec/optional/capi/ext/range_spec.c b/spec/rubyspec/optional/capi/ext/range_spec.c index 46ee88a85d..6dc2d579fd 100644 --- a/spec/rubyspec/optional/capi/ext/range_spec.c +++ b/spec/rubyspec/optional/capi/ext/range_spec.c @@ -34,7 +34,7 @@ VALUE range_spec_rb_range_beg_len(VALUE self, VALUE range, VALUE begpv, VALUE le 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)); diff --git a/spec/rubyspec/optional/capi/ext/st_spec.c b/spec/rubyspec/optional/capi/ext/st_spec.c index ea2d81964d..f743a4396f 100644 --- a/spec/rubyspec/optional/capi/ext/st_spec.c +++ b/spec/rubyspec/optional/capi/ext/st_spec.c @@ -13,31 +13,37 @@ extern "C" { #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) { 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 |