]> git.vpit.fr Git - perl/modules/autovivification.git/commitdiff
Factor the error messages in a separate helper function
authorVincent Pit <vince@profvince.com>
Sat, 25 Apr 2015 01:37:03 +0000 (22:37 -0300)
committerVincent Pit <vince@profvince.com>
Sat, 25 Apr 2015 01:37:03 +0000 (22:37 -0300)
autovivification.xs

index 43922752149c3457518c1b0f65f8fc8c211e9c81..4f7a212baa2a829bdf3bd7a95b4cb216920bab3d 100644 (file)
@@ -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;