bigint.c (mrb_bint_copy): allow dup operation for bigints.
MODIFY
include/mruby/internal.h
include/mruby/internal.h
@@ -182,6 +182,7 @@ mrb_float mrb_bint_as_float(mrb_state *mrb, mrb_value x);
mrb_int mrb_bint_as_int(mrb_state *mrb, mrb_value x);
mrb_int mrb_bint_cmp(mrb_state *mrb, mrb_value x, mrb_value y);
void mrb_gc_free_bint(mrb_state *mrb, struct RBasic *x);
+void mrb_bint_copy(mrb_state *mrb, mrb_value x, mrb_value y);
#endif
#endif /* MRUBY_INTERNAL_H */

MODIFY
mrbgems/mruby-bigint/core/bigint.c
mrbgems/mruby-bigint/core/bigint.c
@@ -23,7 +23,6 @@ mpz_init(mrb_state *mrb, mpz_t *s)
s->sz=2;
}
-#if 0
static void
mpz_init_set(mrb_state *mrb, mpz_t *s, mpz_t *t)
{
@@ -34,7 +33,6 @@ mpz_init_set(mrb_state *mrb, mpz_t *s, mpz_t *t)
s->sn = t->sn;
s->sz = t->sz;
}
-#endif
static void
mpz_set_int(mrb_state *mrb, mpz_t *y, mrb_int v)
@@ -1450,3 +1448,11 @@ mrb_bint_rshift(mrb_state *mrb, mrb_value x, mrb_int width)
}
return bint_norm(mrb, b2);
}
+
+void
+mrb_bint_copy(mrb_state *mrb, mrb_value x, mrb_value y)
+{
+ struct RBigint *b = RBIGINT(x);
+ struct RBigint *b2 = RBIGINT(y);
+ mpz_init_set(mrb, &b->mp, &b2->mp);
+}

MODIFY
src/class.c
src/class.c
@@ -2737,6 +2737,11 @@ init_copy(mrb_state *mrb, mrb_value dest, mrb_value obj)
case MRB_TT_ISTRUCT:
mrb_istruct_copy(dest, obj);
break;
+#ifdef MRB_USE_BIGINT
+ case MRB_TT_BIGINT:
+ mrb_bint_copy(mrb, dest, obj);
+ break;
+#endif
default:
break;

bigint.c (mrb_bint_copy): allow dup operation for bigints.