From: Vincent Pit Date: Sat, 25 Apr 2015 01:37:03 +0000 (-0300) Subject: Factor the error messages in a separate helper function X-Git-Tag: v0.15~20 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Fautovivification.git;a=commitdiff_plain;h=f188eeceb45dd21b7a80346a1f57c06d7d192080 Factor the error messages in a separate helper function --- diff --git a/autovivification.xs b/autovivification.xs index 4392275..4f7a212 100644 --- a/autovivification.xs +++ b/autovivification.xs @@ -710,6 +710,16 @@ static OP *a_pp_rv2hv(pTHX) { /* ... pp_deref (aelem,helem,rv2sv,padsv) .................................. */ +static void a_cannot_vivify(pTHX_ UV flags) { +#define a_cannot_vivify(F) a_cannot_vivify(aTHX_ (F)) + if (flags & A_HINT_STRICT) + croak("Reference vivification forbidden"); + else if (flags & A_HINT_WARN) + warn("Reference was vivified"); + else /* A_HINT_STORE */ + croak("Can't vivify reference"); +} + static OP *a_pp_deref(pTHX) { dA_MAP_THX; const a_op_info *oi; @@ -726,14 +736,8 @@ static OP *a_pp_deref(pTHX) { if (flags & (A_HINT_NOTIFY|A_HINT_STORE)) { SPAGAIN; - if (a_undef(TOPs)) { - if (flags & A_HINT_STRICT) - croak("Reference vivification forbidden"); - else if (flags & A_HINT_WARN) - warn("Reference was vivified"); - else /* A_HINT_STORE */ - croak("Can't vivify reference"); - } + if (a_undef(TOPs)) + a_cannot_vivify(flags); } return o;