Skip to content

Instantly share code, notes, and snippets.

@nobu
Created September 4, 2009 05:48
Show Gist options
  • Save nobu/180753 to your computer and use it in GitHub Desktop.
Save nobu/180753 to your computer and use it in GitHub Desktop.
decimal.diff
#!/bin/sh
{
echo '/* extracted from "numeric.c" and "bignum.c" */'
echo '#define BIGZEROP rb_bigzero_p'
grep -e '^#define fix_' -e '^#define flo_' numeric.c
} > ${1-ext/decimal}/inum19.h
patch -p0 <<'END_OF_PATCH'
Index: bignum.c
===================================================================
--- bignum.c (revision 24748)
+++ bignum.c (working copy)
@@ -1394,5 +1394,5 @@ rb_big_eql(VALUE x, VALUE y)
*/
-static VALUE
+VALUE
rb_big_uminus(VALUE x)
{
@@ -3132,5 +3132,5 @@ rb_big_aref(VALUE x, VALUE y)
*/
-static VALUE
+VALUE
rb_big_hash(VALUE x)
{
@@ -3206,5 +3206,5 @@ rb_big_size(VALUE big)
*/
-static VALUE
+VALUE
rb_big_odd_p(VALUE num)
{
@@ -3222,5 +3222,5 @@ rb_big_odd_p(VALUE num)
*/
-static VALUE
+VALUE
rb_big_even_p(VALUE num)
{
Index: numeric.c
===================================================================
--- numeric.c (revision 24748)
+++ numeric.c (working copy)
@@ -543,5 +543,6 @@ rb_float_new(double d)
*/
-static VALUE
+#define flo_to_s rb_float_to_s
+VALUE
flo_to_s(VALUE flt)
{
@@ -2117,5 +2118,6 @@ fix_to_s(int argc, VALUE *argv, VALUE x)
*/
-static VALUE
+#define fix_plus rb_fix_plus
+VALUE
fix_plus(VALUE x, VALUE y)
{
@@ -2150,5 +2152,6 @@ fix_plus(VALUE x, VALUE y)
*/
-static VALUE
+#define fix_minus rb_fix_minus
+VALUE
fix_minus(VALUE x, VALUE y)
{
@@ -2188,5 +2191,6 @@ fix_minus(VALUE x, VALUE y)
*/
-static VALUE
+#define fix_mul rb_fix_mul
+VALUE
fix_mul(VALUE x, VALUE y)
{
@@ -2338,5 +2342,6 @@ fix_divide(VALUE x, VALUE y, ID op)
*/
-static VALUE
+#define fix_div rb_fix_div
+VALUE
fix_div(VALUE x, VALUE y)
{
@@ -2351,5 +2356,6 @@ fix_div(VALUE x, VALUE y)
*/
-static VALUE
+#define fix_idiv rb_fix_idiv
+VALUE
fix_idiv(VALUE x, VALUE y)
{
@@ -2397,5 +2403,7 @@ fix_mod(VALUE x, VALUE y)
* See <code>Numeric#divmod</code>.
*/
-static VALUE
+
+#define fix_divmod rb_fix_divmod
+VALUE
fix_divmod(VALUE x, VALUE y)
{
@@ -2426,5 +2434,6 @@ fix_divmod(VALUE x, VALUE y)
}
-static VALUE
+#define int_pow rb_int_pow
+VALUE
int_pow(long x, unsigned long y)
{
@@ -2476,5 +2485,6 @@ int_pow(long x, unsigned long y)
*/
-static VALUE
+#define fix_pow rb_fix_pow
+VALUE
fix_pow(VALUE x, VALUE y)
{
@@ -2544,5 +2554,6 @@ fix_pow(VALUE x, VALUE y)
*/
-static VALUE
+#define fix_equal rb_fix_equal
+VALUE
fix_equal(VALUE x, VALUE y)
{
@@ -2569,5 +2580,6 @@ fix_equal(VALUE x, VALUE y)
*/
-static VALUE
+#define fix_cmp rb_fix_cmp
+VALUE
fix_cmp(VALUE x, VALUE y)
{
@@ -3125,5 +3137,6 @@ fix_zero_p(VALUE num)
*/
-static VALUE
+#define fix_odd_p rb_fix_odd_p
+VALUE
fix_odd_p(VALUE num)
{
@@ -3141,5 +3154,6 @@ fix_odd_p(VALUE num)
*/
-static VALUE
+#define fix_even_p rb_fix_even_p
+VALUE
fix_even_p(VALUE num)
{
Index: include/ruby/intern.h
===================================================================
--- include/ruby/intern.h (revision 24748)
+++ include/ruby/intern.h (working copy)
@@ -109,4 +109,5 @@ double rb_big2dbl(VALUE);
VALUE rb_big_cmp(VALUE, VALUE);
VALUE rb_big_eq(VALUE, VALUE);
+VALUE rb_big_uminus(VALUE);
VALUE rb_big_plus(VALUE, VALUE);
VALUE rb_big_minus(VALUE, VALUE);
@@ -121,4 +122,7 @@ VALUE rb_big_xor(VALUE, VALUE);
VALUE rb_big_lshift(VALUE, VALUE);
VALUE rb_big_rshift(VALUE, VALUE);
+VALUE rb_big_hash(VALUE);
+VALUE rb_big_odd_p(VALUE);
+VALUE rb_big_even_p(VALUE);
/* rational.c */
VALUE rb_rational_raw(VALUE, VALUE);
@@ -440,7 +444,18 @@ VALUE rb_num_coerce_cmp(VALUE, VALUE, ID
VALUE rb_num_coerce_relop(VALUE, VALUE, ID);
VALUE rb_float_new(double);
+VALUE rb_float_to_s(VALUE);
VALUE rb_num2fix(VALUE);
VALUE rb_fix2str(VALUE, int);
VALUE rb_dbl_cmp(double, double);
+VALUE rb_fix_pow(VALUE, VALUE);
+VALUE rb_fix_mul(VALUE, VALUE);
+VALUE rb_fix_plus(VALUE, VALUE);
+VALUE rb_fix_minus(VALUE, VALUE);
+VALUE rb_fix_divmod(VALUE, VALUE);
+VALUE rb_fix_div(VALUE, VALUE);
+VALUE rb_fix_idiv(VALUE, VALUE);
+VALUE rb_fix_odd_p(VALUE);
+VALUE rb_fix_cmp(VALUE, VALUE);
+VALUE rb_fix_equal(VALUE, VALUE);
/* object.c */
int rb_eql(VALUE, VALUE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment