From: Vincent Pit Date: Sat, 16 May 2009 07:34:05 +0000 (+0200) Subject: Freshen Util.xs X-Git-Tag: v0.06~19 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=c803f32528475ddf0f1713bbe666b6157020f5d1;p=perl%2Fmodules%2FScalar-Vec-Util.git Freshen Util.xs --- diff --git a/Util.xs b/Util.xs index 8c03e45..8f6345b 100644 --- a/Util.xs +++ b/Util.xs @@ -6,7 +6,8 @@ #include "perl.h" #include "XSUB.h" -#define __PACKAGE__ "Scalar::Vec::Util" +#define __PACKAGE__ "Scalar::Vec::Util" +#define __PACKAGE_LEN__ (sizeof(__PACKAGE__)-1) #include "bitvect.h" @@ -20,7 +21,7 @@ PROTOTYPES: ENABLE BOOT: { - HV *stash = gv_stashpv(__PACKAGE__, 1); + HV *stash = gv_stashpvn(__PACKAGE__, __PACKAGE_LEN__, 1); newCONSTSUB(stash, "SVU_PP", newSVuv(0)); newCONSTSUB(stash, "SVU_SIZE", newSVuv(SVU_SIZE)); } @@ -31,15 +32,15 @@ PREINIT: size_t s, l, n, o; char f, *v; CODE: - if (!SvOK(sv) || !SvOK(ss) || !SvOK(sl) || !SvOK(sf)) { + if (!SvOK(sv) || !SvOK(ss) || !SvOK(sl) || !SvOK(sf)) croak(svu_error_invarg); - } l = SvUV(sl); - if (!l) { XSRETURN(0); } + if (!l) + XSRETURN(0); s = SvUV(ss); f = SvTRUE(sf); - if (SvTYPE(sv) < SVt_PV) { SvUPGRADE(sv, SVt_PV); } + SvUPGRADE(sv, SVt_PV); n = BV_SIZE(s + l); o = SvLEN(sv); @@ -49,9 +50,8 @@ CODE: } else { v = SvPVX(sv); } - if (SvCUR(sv) < n) { + if (SvCUR(sv) < n) SvCUR_set(sv, n); - } bv_fill(v, s, l, f); @@ -63,16 +63,16 @@ PREINIT: size_t fs, ts, l, lf = 0, n, o; char *t, *f; CODE: - if (!SvOK(sf) || !SvOK(sfs) || !SvOK(st) || !SvOK(sts) || !SvOK(sl)) { + if (!SvOK(sf) || !SvOK(sfs) || !SvOK(st) || !SvOK(sts) || !SvOK(sl)) croak(svu_error_invarg); - } l = SvUV(sl); - if (!l) { XSRETURN(0); } + if (!l) + XSRETURN(0); fs = SvUV(sfs); ts = SvUV(sts); - if (SvTYPE(sf) < SVt_PV) { SvUPGRADE(sf, SVt_PV); } - if (SvTYPE(st) < SVt_PV) { SvUPGRADE(st, SVt_PV); } + SvUPGRADE(sf, SVt_PV); + SvUPGRADE(st, SVt_PV); n = BV_SIZE(ts + l); o = SvLEN(st); @@ -82,9 +82,8 @@ CODE: } else { t = SvPVX(st); } - if (SvCUR(st) < n) { + if (SvCUR(st) < n) SvCUR_set(st, n); - } f = SvPVX(sf); /* We do it there in case st == sf. */ n = BV_SIZE(fs + l); @@ -112,15 +111,14 @@ PREINIT: size_t s1, s2, l, o, n; char *v1, *v2; CODE: - if (!SvOK(sv1) || !SvOK(ss1) || !SvOK(sv2) || !SvOK(ss2) || !SvOK(sl)) { + if (!SvOK(sv1) || !SvOK(ss1) || !SvOK(sv2) || !SvOK(ss2) || !SvOK(sl)) croak(svu_error_invarg); - } l = SvUV(sl); s1 = SvUV(ss1); s2 = SvUV(ss2); - if (SvTYPE(sv1) < SVt_PV) { SvUPGRADE(sv1, SVt_PV); } - if (SvTYPE(sv2) < SVt_PV) { SvUPGRADE(sv2, SVt_PV); } + SvUPGRADE(sv1, SVt_PV); + SvUPGRADE(sv2, SVt_PV); n = BV_SIZE(s1 + l); o = SvLEN(sv1);