summaryrefslogtreecommitdiff
path: root/ext/-test-/num2int
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-18 15:21:04 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-18 15:21:04 +0000
commitf4aff7feb18bac8f15494ac36c5027d216aac5f8 (patch)
treed1a55cf0aa40b87df3707d78c7a26c5c41117a1d /ext/-test-/num2int
parentbd377449f01c033b6fd2c8c880611c1777c8e87d (diff)
num2ll and num2ull
* ext/-test-/num2int/num2int.c (print_num2ll, print_num2ull): define only if long long is available, and use long long printf modifier checked by configure. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/-test-/num2int')
-rw-r--r--ext/-test-/num2int/num2int.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/ext/-test-/num2int/num2int.c b/ext/-test-/num2int/num2int.c
index 5230896..fb1ea96 100644
--- a/ext/-test-/num2int/num2int.c
+++ b/ext/-test-/num2int/num2int.c
@@ -72,13 +72,14 @@ print_num2ulong(VALUE obj, VALUE num)
return Qnil;
}
+#ifdef HAVE_LONG_LONG
static VALUE
print_num2ll(VALUE obj, VALUE num)
{
char buf[128];
VALUE str;
- sprintf(buf, "%lld", NUM2LL(num));
+ sprintf(buf, "%"PRI_LL_PREFIX"d", NUM2LL(num));
str = rb_str_new_cstr(buf);
rb_io_write(rb_stdout, str);
return Qnil;
@@ -90,12 +91,12 @@ print_num2ull(VALUE obj, VALUE num)
char buf[128];
VALUE str;
- sprintf(buf, "%llu", NUM2ULL(num));
+ sprintf(buf, "%"PRI_LL_PREFIX"u", NUM2ULL(num));
str = rb_str_new_cstr(buf);
rb_io_write(rb_stdout, str);
return Qnil;
}
-
+#endif
void
Init_num2int(void)
@@ -111,7 +112,9 @@ Init_num2int(void)
rb_define_singleton_method(cNum2int, "print_num2long", print_num2long, 1);
rb_define_singleton_method(cNum2int, "print_num2ulong", print_num2ulong, 1);
+#ifdef HAVE_LONG_LONG
rb_define_singleton_method(cNum2int, "print_num2ll", print_num2ll, 1);
rb_define_singleton_method(cNum2int, "print_num2ull", print_num2ull, 1);
+#endif
}