diff options
author | Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> | 2021-11-30 16:07:34 +0000 |
---|---|---|
committer | Paul Evans <leonerd@leonerd.org.uk> | 2021-11-30 17:31:00 +0000 |
commit | a64a1b916a4d7dc71f19c660f970fb7e942c2735 (patch) | |
tree | a88b40e2d0607ebfa891aa53c0e94786f1b0d1cd /builtin.c | |
parent | 6a2e756f8693f753bad68e1827d8eee014636c86 (diff) | |
download | perl-a64a1b916a4d7dc71f19c660f970fb7e942c2735.tar.gz |
builtin.c: Fix C++ compilation errors
C++ does not allow `goto` across initalisations of variables that are
in scope at the label, so just get rid of the `goto`.
An alternative would be to start a new scope after the first `goto`,
so that the variables aren't in scope any more at the label, but I
think this is neater.
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -48,6 +48,8 @@ XS(XS_builtin_isbool) XSRETURN_NO; } +static const char builtin_not_recognised[] = "'%" SVf "' is not recognised as a builtin function"; + XS(XS_builtin_import); XS(XS_builtin_import) { @@ -65,22 +67,19 @@ XS(XS_builtin_import) for(int i = 1; i < items; i++) { SV *sym = ST(i); - if(strEQ(SvPV_nolen(sym), "import")) goto unavailable; + if(strEQ(SvPV_nolen(sym), "import")) + Perl_croak(aTHX_ builtin_not_recognised, sym); SV *ampname = sv_2mortal(Perl_newSVpvf(aTHX_ "&%" SVf, SVfARG(sym))); SV *fqname = sv_2mortal(Perl_newSVpvf(aTHX_ "builtin::%" SVf, SVfARG(sym))); CV *cv = get_cv(SvPV_nolen(fqname), SvUTF8(fqname) ? SVf_UTF8 : 0); - if(!cv) goto unavailable; + if(!cv) + Perl_croak(aTHX_ builtin_not_recognised, sym); PADOFFSET off = pad_add_name_sv(ampname, padadd_STATE, 0, 0); SvREFCNT_dec(PL_curpad[off]); PL_curpad[off] = SvREFCNT_inc(cv); - continue; - -unavailable: - Perl_croak(aTHX_ - "'%" SVf "' is not recognised as a builtin function", sym); } intro_my(); |