X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-perl/blobdiff_plain/f9952aec1cf6c64a5681308eea817b6113a37433..fcd15e0b7a3d0f0ca2f30953573f8d1f6b8e8bd2:/mpstuff.c diff --git a/mpstuff.c b/mpstuff.c index e048ff1..9881edc 100644 --- a/mpstuff.c +++ b/mpstuff.c @@ -94,12 +94,23 @@ mp *mp_readsv(mp *m, SV *sv, STRLEN *off, int radix) return (m); } +int group_writesv(group *g, ge *x, SV *sv) +{ + mptext_svctx c; + int rc; + STRLEN len; + sv_setpvn(sv, "", 0); + c.sv = sv; + rc = G_WRITE(g, x, &mptext_svops, &c); + return (rc); +} + int mp_writesv(mp *m, SV *sv, int radix) { mptext_svctx c; int rc; STRLEN len; - SvPV(sv, len); + sv_setpvn(sv, "", 0); c.sv = sv; rc = mp_write(m, radix, &mptext_svops, &c); return (rc); @@ -107,8 +118,7 @@ int mp_writesv(mp *m, SV *sv, int radix) /* --- Conversion to and from SVs --- */ -mp *mp_fromsv(SV *sv, const char *what, const char *ty, - int radix, int keep, ...) +mp *mp_fromsv(SV *sv, const char *what, int radix, int keep, ...) { mp *m; if (SvROK(sv)) { @@ -119,7 +129,7 @@ mp *mp_fromsv(SV *sv, const char *what, const char *ty, SV *t = sv_newmortal(); va_start(ap, keep); sv_vsetpvfn(t, what, strlen(what), &ap, 0, 0, 0); - croak("%s is not of type %s", SvPVX(t), ty); + croak("%s is not of type Catacomb::MP", SvPVX(t)); } if (m && keep) MP_COPY(m); @@ -129,7 +139,7 @@ mp *mp_fromsv(SV *sv, const char *what, const char *ty, else m = mp_readsv(MP_NEW, sv, 0, radix); if (m && !keep) - RET(m, ty); /* Kill temporary later */ + RET_MP(m); /* Kill temporary later */ } return (m); }