#include "bitvect.h"
-STATIC void svu_validate_uv(pTHX_ SV *sv, size_t *offset, const char *desc) {
-#define svu_validate_uv(S, O, D) svu_validate_uv(aTHX_ (S), (O), (D))
+STATIC size_t svu_validate_uv(pTHX_ SV *sv, const char *desc) {
+#define svu_validate_uv(S, D) svu_validate_uv(aTHX_ (S), (D))
IV i;
if (SvOK(sv) && SvIOK(sv)) {
if (SvIsUV(sv))
- *offset = SvUVX(sv);
+ return SvUVX(sv);
else {
i = SvIVX(sv);
- if (i < 0)
- goto fail;
- *offset = i;
+ if (i >= 0)
+ return i;
}
} else {
i = SvIV(sv);
- if (i < 0)
- goto fail;
- *offset = i;
+ if (i >= 0)
+ return i;
}
- return;
-
-fail:
- *offset = 0;
croak("Invalid negative %s", desc ? desc : "integer");
+ return 0;
}
/* --- XS ------------------------------------------------------------------ */
size_t s, l, n, o;
char f, *v;
CODE:
- svu_validate_uv(sl, &l, "length");
+ l = svu_validate_uv(sl, "length");
if (!l)
XSRETURN(0);
- svu_validate_uv(ss, &s, "offset");
+ s = svu_validate_uv(ss, "offset");
f = SvTRUE(sf);
SvUPGRADE(sv, SVt_PV);
size_t fs, ts, l, lf = 0, n, o;
char *t, *f;
CODE:
- svu_validate_uv(sl, &l, "length");
+ l = svu_validate_uv(sl, "length");
if (!l)
XSRETURN(0);
- svu_validate_uv(sfs, &fs, "offset");
- svu_validate_uv(sts, &ts, "offset");
+ fs = svu_validate_uv(sfs, "offset");
+ ts = svu_validate_uv(sts, "offset");
SvUPGRADE(sf, SVt_PV);
SvUPGRADE(st, SVt_PV);
size_t s1, s2, l, o, n;
char *v1, *v2;
CODE:
- svu_validate_uv(sl, &l, "length");
+ l = svu_validate_uv(sl, "length");
if (!l)
XSRETURN_YES;
- svu_validate_uv(ss1, &s1, "offset");
- svu_validate_uv(ss2, &s2, "offset");
+ s1 = svu_validate_uv(ss1, "offset");
+ s2 = svu_validate_uv(ss2, "offset");
SvUPGRADE(sv1, SVt_PV);
SvUPGRADE(sv2, SVt_PV);