/* NOTE: No support for tied ISA */
I32 items = AvFILLp(av) + 1;
while (items--) {
- SV* sv = *svp++;
- HV* basestash = gv_stashsv(sv, FALSE);
+ SV* const sv = *svp++;
+ HV* const basestash = gv_stashsv(sv, FALSE);
if (!basestash) {
if (ckWARN(WARN_MISC))
Perl_warner(aTHX_ packWARN(WARN_SYNTAX),
HV *stash = Nullhv;
HV *name_stash;
- if (SvGMAGICAL(sv))
- mg_get(sv) ;
+ SvGETMAGIC(sv);
if (SvROK(sv)) {
sv = SvRV(sv);
XS(XS_UNIVERSAL_isa)
{
dXSARGS;
- SV *sv;
- const char *name;
if (items != 2)
Perl_croak(aTHX_ "Usage: UNIVERSAL::isa(reference, kind)");
+ else {
+ SV * const sv = ST(0);
+ const char *name;
- sv = ST(0);
-
- if (SvGMAGICAL(sv))
- mg_get(sv);
+ SvGETMAGIC(sv);
- if (!SvOK(sv) || !(SvROK(sv) || (SvPOK(sv) && SvCUR(sv))
- || (SvGMAGICAL(sv) && SvPOKp(sv) && SvCUR(sv))))
- XSRETURN_UNDEF;
+ if (!SvOK(sv) || !(SvROK(sv) || (SvPOK(sv) && SvCUR(sv))
+ || (SvGMAGICAL(sv) && SvPOKp(sv) && SvCUR(sv))))
+ XSRETURN_UNDEF;
- name = SvPV_nolen_const(ST(1));
+ name = SvPV_nolen_const(ST(1));
- ST(0) = boolSV(sv_derived_from(sv, name));
- XSRETURN(1);
+ ST(0) = boolSV(sv_derived_from(sv, name));
+ XSRETURN(1);
+ }
}
XS(XS_UNIVERSAL_can)
sv = ST(0);
- if (SvGMAGICAL(sv))
- mg_get(sv);
+ SvGETMAGIC(sv);
if (!SvOK(sv) || !(SvROK(sv) || (SvPOK(sv) && SvCUR(sv))
|| (SvGMAGICAL(sv) && SvPOKp(sv) && SvCUR(sv))))
}
if (pkg) {
- GV *gv = gv_fetchmethod_autoload(pkg, name, FALSE);
+ GV * const gv = gv_fetchmethod_autoload(pkg, name, FALSE);
if (gv && isGV(gv))
rv = sv_2mortal(newRV((SV*)GvCV(gv)));
}
gvp = pkg ? (GV**)hv_fetch(pkg,"VERSION",7,FALSE) : Null(GV**);
- if (gvp && isGV(gv = *gvp) && SvOK(sv = GvSV(gv))) {
- SV *nsv = sv_newmortal();
+ if (gvp && isGV(gv = *gvp) && (sv = GvSV(gv)) && SvOK(sv)) {
+ SV * const nsv = sv_newmortal();
sv_setsv(nsv, sv);
sv = nsv;
if ( !sv_derived_from(sv, "version"))
if (undef) {
if (pkg) {
- const char *name = HvNAME_get(pkg);
+ const char * const name = HvNAME_get(pkg);
Perl_croak(aTHX_
"%s does not define $%s::VERSION--version check failed",
name, name);
if ( !sv_derived_from(req, "version")) {
/* req may very well be R/O, so create a new object */
- SV *nsv = sv_newmortal();
+ SV * const nsv = sv_newmortal();
sv_setsv(nsv, req);
req = nsv;
upg_version(req);
{
SV *vs = ST(1);
SV *rv;
- const char *classname;
-
- /* get the class if called as an object method */
- if ( sv_isobject(ST(0)) ) {
- classname = HvNAME(SvSTASH(SvRV(ST(0))));
- }
- else {
- classname = (char *)SvPV_nolen(ST(0));
- }
+ const char * const classname =
+ sv_isobject(ST(0)) /* get the class if called as an object method */
+ ? HvNAME(SvSTASH(SvRV(ST(0))))
+ : (char *)SvPV_nolen(ST(0));
if ( items == 1 ) {
/* no parameter provided */
else {
/* create empty object */
vs = sv_newmortal();
- sv_setpv(vs,"");
+ sv_setpvn(vs,"",0);
}
}
else if ( items == 3 ) {
if (items < 1)
Perl_croak(aTHX_ "Usage: version::boolean(lobj, ...)");
SP -= items;
- {
- SV * lobj = Nullsv;
-
- if (sv_derived_from(ST(0), "version")) {
- lobj = SvRV(ST(0));
- }
- else
- Perl_croak(aTHX_ "lobj is not of type version");
-
- {
- SV *rs;
- rs = newSViv( vcmp(lobj,new_version(newSVpvn("0",1))) );
- PUSHs(sv_2mortal(rs));
- }
-
- PUTBACK;
- return;
- }
+ if (sv_derived_from(ST(0), "version")) {
+ SV * const lobj = SvRV(ST(0));
+ SV * const rs = newSViv( vcmp(lobj,new_version(newSVpvn("0",1))) );
+ PUSHs(sv_2mortal(rs));
+ PUTBACK;
+ return;
+ }
+ else
+ Perl_croak(aTHX_ "lobj is not of type version");
}
XS(XS_version_noop)
if (items != 1)
Perl_croak(aTHX_ "Usage: version::is_alpha(lobj)");
SP -= items;
- {
- SV * lobj = Nullsv;
-
- if (sv_derived_from(ST(0), "version"))
- lobj = ST(0);
- else
- Perl_croak(aTHX_ "lobj is not of type version");
-{
- if ( hv_exists((HV*)SvRV(lobj), "alpha", 5 ) )
- XSRETURN_YES;
- else
- XSRETURN_NO;
-}
+ if (sv_derived_from(ST(0), "version")) {
+ SV * const lobj = ST(0);
+ if ( hv_exists((HV*)SvRV(lobj), "alpha", 5 ) )
+ XSRETURN_YES;
+ else
+ XSRETURN_NO;
PUTBACK;
return;
}
+ else
+ Perl_croak(aTHX_ "lobj is not of type version");
}
XS(XS_version_qv)
SP -= items;
{
SV * ver = ST(0);
- if ( !SvVOK(ver) ) /* only need to do with if not already v-string */
- {
- SV *vs = sv_newmortal();
+ if ( !SvVOK(ver) ) { /* only need to do with if not already v-string */
+ SV * const vs = sv_newmortal();
char *version;
if ( SvNOK(ver) ) /* may get too much accuracy */
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: utf8::is_utf8(sv)");
- {
- const SV *sv = ST(0);
- {
- if (SvUTF8(sv))
- XSRETURN_YES;
- else
- XSRETURN_NO;
- }
+ else {
+ const SV * const sv = ST(0);
+ if (SvUTF8(sv))
+ XSRETURN_YES;
+ else
+ XSRETURN_NO;
}
XSRETURN_EMPTY;
}
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: utf8::valid(sv)");
- {
- SV * sv = ST(0);
- {
- STRLEN len;
- const char *s = SvPV_const(sv,len);
- if (!SvUTF8(sv) || is_utf8_string((const U8*)s,len))
- XSRETURN_YES;
- else
- XSRETURN_NO;
- }
- }
+ else {
+ SV * const sv = ST(0);
+ STRLEN len;
+ const char * const s = SvPV_const(sv,len);
+ if (!SvUTF8(sv) || is_utf8_string((const U8*)s,len))
+ XSRETURN_YES;
+ else
+ XSRETURN_NO;
+ }
XSRETURN_EMPTY;
}
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: utf8::encode(sv)");
- {
- SV * sv = ST(0);
-
- sv_utf8_encode(sv);
- }
+ sv_utf8_encode(ST(0));
XSRETURN_EMPTY;
}
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: utf8::decode(sv)");
- {
- SV * sv = ST(0);
+ else {
+ SV * const sv = ST(0);
const bool RETVAL = sv_utf8_decode(sv);
ST(0) = boolSV(RETVAL);
sv_2mortal(ST(0));
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: utf8::upgrade(sv)");
- {
- SV * sv = ST(0);
+ else {
+ SV * const sv = ST(0);
STRLEN RETVAL;
dXSTARG;
dXSARGS;
if (items < 1 || items > 2)
Perl_croak(aTHX_ "Usage: utf8::downgrade(sv, failok=0)");
- {
- SV * sv = ST(0);
+ else {
+ SV * const sv = ST(0);
const bool failok = (items < 2) ? 0 : (int)SvIV(ST(1));
const bool RETVAL = sv_utf8_downgrade(sv, failok);
XS(XS_Internals_SvREADONLY) /* This is dangerous stuff. */
{
dXSARGS;
- SV *sv = SvRV(ST(0));
+ SV * const sv = SvRV(ST(0));
if (items == 1) {
if (SvREADONLY(sv))
XS(XS_Internals_SvREFCNT) /* This is dangerous stuff. */
{
dXSARGS;
- SV *sv = SvRV(ST(0));
+ SV * const sv = SvRV(ST(0));
if (items == 1)
XSRETURN_IV(SvREFCNT(sv) - 1); /* Minus the ref created for us. */
XS(XS_Internals_hv_clear_placehold)
{
dXSARGS;
- HV *hv = (HV *) SvRV(ST(0));
if (items != 1)
Perl_croak(aTHX_ "Usage: UNIVERSAL::hv_clear_placeholders(hv)");
- hv_clear_placeholders(hv);
- XSRETURN(0);
+ else {
+ HV * const hv = (HV *) SvRV(ST(0));
+ hv_clear_placeholders(hv);
+ XSRETURN(0);
+ }
}
XS(XS_Regexp_DESTROY)
bool details = FALSE;
if (items > 1) {
- SV **svp;
-
+ SV * const *svp;
for (svp = MARK + 2; svp <= SP; svp += 2) {
- SV **varp = svp;
- SV **valp = svp + 1;
+ SV * const * const varp = svp;
+ SV * const * const valp = svp + 1;
STRLEN klen;
- const char *key = SvPV_const(*varp, klen);
+ const char * const key = SvPV_const(*varp, klen);
switch (*key) {
case 'i':
if (gv && (io = GvIO(gv))) {
dTARGET;
- AV* av = PerlIO_get_layers(aTHX_ input ?
+ AV* const av = PerlIO_get_layers(aTHX_ input ?
IoIFP(io) : IoOFP(io));
I32 i;
- I32 last = av_len(av);
+ const I32 last = av_len(av);
I32 nitem = 0;
for (i = last; i >= 0; i -= 3) {
- SV **namsvp;
- SV **argsvp;
- SV **flgsvp;
- bool namok, argok, flgok;
-
- namsvp = av_fetch(av, i - 2, FALSE);
- argsvp = av_fetch(av, i - 1, FALSE);
- flgsvp = av_fetch(av, i, FALSE);
+ SV * const * const namsvp = av_fetch(av, i - 2, FALSE);
+ SV * const * const argsvp = av_fetch(av, i - 1, FALSE);
+ SV * const * const flgsvp = av_fetch(av, i, FALSE);
- namok = namsvp && *namsvp && SvPOK(*namsvp);
- argok = argsvp && *argsvp && SvPOK(*argsvp);
- flgok = flgsvp && *flgsvp && SvIOK(*flgsvp);
+ const bool namok = namsvp && *namsvp && SvPOK(*namsvp);
+ const bool argok = argsvp && *argsvp && SvPOK(*argsvp);
+ const bool flgok = flgsvp && *flgsvp && SvIOK(*flgsvp);
if (details) {
- XPUSHs(namok ?
- newSVpv(SvPVX_const(*namsvp), 0) : &PL_sv_undef);
- XPUSHs(argok ?
- newSVpv(SvPVX_const(*argsvp), 0) : &PL_sv_undef);
+ XPUSHs(namok
+ ? newSVpvn(SvPVX_const(*namsvp), SvCUR(*namsvp))
+ : &PL_sv_undef);
+ XPUSHs(argok
+ ? newSVpvn(SvPVX_const(*argsvp), SvCUR(*argsvp))
+ : &PL_sv_undef);
if (flgok)
XPUSHi(SvIVX(*flgsvp));
else
XPUSHs(&PL_sv_undef);
nitem++;
if (flgok) {
- IV flags = SvIVX(*flgsvp);
+ const IV flags = SvIVX(*flgsvp);
if (flags & PERLIO_F_UTF8) {
XPUSHs(newSVpvn("utf8", 4));
{
dXSARGS;
if (SvROK(ST(0))) {
- const HV *hv = (HV *) SvRV(ST(0));
+ const HV * const hv = (HV *) SvRV(ST(0));
if (items == 1 && SvTYPE(hv) == SVt_PVHV) {
if (HvREHASH(hv))
XSRETURN_YES;