Skip to content

Commit

Permalink
* numeric.c (rb_num2long): Returns a long.
Browse files Browse the repository at this point in the history
  (rb_num2ulong): Returns a unsigned long.

* bignum.c (rb_big2long): Returns a long.
  (rb_big2ulong): Returns a unsigned long.

* include/ruby/intern.h: Follow above changes.

* include/ruby/ruby.h: Follow above changes.
  (rb_num2long_inline): No need to cast.
  (rb_num2ulong_inline): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
akr committed Apr 18, 2014
1 parent 07cad43 commit a6024cd
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
14 changes: 14 additions & 0 deletions ChangeLog
@@ -1,3 +1,17 @@
Sat Apr 19 00:32:07 2014 Tanaka Akira <akr@fsij.org>

* numeric.c (rb_num2long): Returns a long.
(rb_num2ulong): Returns a unsigned long.

* bignum.c (rb_big2long): Returns a long.
(rb_big2ulong): Returns a unsigned long.

* include/ruby/intern.h: Follow above changes.

* include/ruby/ruby.h: Follow above changes.
(rb_num2long_inline): No need to cast.
(rb_num2ulong_inline): Ditto.

Sat Apr 19 00:17:20 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>

* string.c (SHARABLE_SUBSTRING_P): predicate if substring can be
Expand Down
4 changes: 2 additions & 2 deletions bignum.c
Expand Up @@ -4962,7 +4962,7 @@ big2ulong(VALUE x, const char *type)
return num;
}

VALUE
unsigned long
rb_big2ulong(VALUE x)
{
unsigned long num = big2ulong(x, "unsigned long");
Expand All @@ -4979,7 +4979,7 @@ rb_big2ulong(VALUE x)
rb_raise(rb_eRangeError, "bignum out of range of unsigned long");
}

SIGNED_VALUE
long
rb_big2long(VALUE x)
{
unsigned long num = big2ulong(x, "long");
Expand Down
4 changes: 2 additions & 2 deletions include/ruby/intern.h
Expand Up @@ -102,9 +102,9 @@ VALUE rb_str_to_inum(VALUE, int, int);
VALUE rb_cstr2inum(const char*, int);
VALUE rb_str2inum(VALUE, int);
VALUE rb_big2str(VALUE, int);
SIGNED_VALUE rb_big2long(VALUE);
long rb_big2long(VALUE);
#define rb_big2int(x) rb_big2long(x)
VALUE rb_big2ulong(VALUE);
unsigned long rb_big2ulong(VALUE);
#define rb_big2uint(x) rb_big2ulong(x)
#if HAVE_LONG_LONG
LONG_LONG rb_big2ll(VALUE);
Expand Down
8 changes: 4 additions & 4 deletions include/ruby/ruby.h
Expand Up @@ -592,15 +592,15 @@ NORETURN(void rb_insecure_operation(void));
VALUE rb_errinfo(void);
void rb_set_errinfo(VALUE);

SIGNED_VALUE rb_num2long(VALUE);
VALUE rb_num2ulong(VALUE);
long rb_num2long(VALUE);
unsigned long rb_num2ulong(VALUE);
static inline long
rb_num2long_inline(VALUE x)
{
if (FIXNUM_P(x))
return FIX2LONG(x);
else
return (long)rb_num2long(x);
return rb_num2long(x);
}
#define NUM2LONG(x) rb_num2long_inline(x)
static inline unsigned long
Expand All @@ -609,7 +609,7 @@ rb_num2ulong_inline(VALUE x)
if (FIXNUM_P(x))
return (unsigned long)FIX2LONG(x);
else
return (unsigned long)rb_num2ulong(x);
return rb_num2ulong(x);
}
#define NUM2ULONG(x) rb_num2ulong_inline(x)
#if SIZEOF_INT < SIZEOF_LONG
Expand Down
4 changes: 2 additions & 2 deletions numeric.c
Expand Up @@ -2030,7 +2030,7 @@ out_of_range_float(char (*pbuf)[24], VALUE val)
LONG_MIN <= (n): \
LONG_MIN_MINUS_ONE < (n))

SIGNED_VALUE
long
rb_num2long(VALUE val)
{
again:
Expand Down Expand Up @@ -2100,7 +2100,7 @@ rb_num2ulong_internal(VALUE val, int *wrap_p)
}
}

VALUE
unsigned long
rb_num2ulong(VALUE val)
{
return rb_num2ulong_internal(val, NULL);
Expand Down

0 comments on commit a6024cd

Please sign in to comment.