]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - Magic.xs
Correctly propagate the errors thrown when variable destruction happens at compile...
[perl/modules/Variable-Magic.git] / Magic.xs
index 3ec0b6fed0db8342fc010d9d91d51631bbbce645..735683c600e192599122ac3d8785809a5fcb68d4 100644 (file)
--- a/Magic.xs
+++ b/Magic.xs
@@ -104,6 +104,10 @@ STATIC SV *vmg_clone(pTHX_ SV *sv, tTHX owner) {
 # define SvRV_const(sv) SvRV((SV *) sv)
 #endif
 
+#ifndef SvREFCNT_inc_simple_void
+# define SvREFCNT_inc_simple_void(sv) SvREFCNT_inc(sv)
+#endif
+
 #ifndef mPUSHu
 # define mPUSHu(U) PUSHs(sv_2mortal(newSVuv(U)))
 #endif
@@ -633,9 +637,9 @@ STATIC SV *vmg_data_new(pTHX_ SV *ctor, SV *sv, SV **args, I32 items) {
  SPAGAIN;
  nsv = POPs;
 #if VMG_HAS_PERL(5, 8, 3)
- SvREFCNT_inc(nsv);    /* Or it will be destroyed in FREETMPS */
+ SvREFCNT_inc_simple_void(nsv); /* Or it will be destroyed in FREETMPS */
 #else
- nsv = sv_newref(nsv); /* Workaround some bug in SvREFCNT_inc() */
+ nsv = sv_newref(nsv);          /* Workaround some bug in SvREFCNT_inc() */
 #endif
  PUTBACK;
 
@@ -1018,7 +1022,7 @@ STATIC U32 vmg_svt_len(pTHX_ SV *sv, MAGIC *mg) {
  svr = POPs;
  ret = SvOK(svr) ? (U32) SvUV(svr) : len;
  if (t == SVt_PVAV)
-   --ret;
+  --ret;
  PUTBACK;
 
  FREETMPS;
@@ -1052,7 +1056,7 @@ STATIC int vmg_svt_free(pTHX_ SV *sv, MAGIC *mg) {
  w = vmg_wizard_mgwiz(mg->mg_ptr);
 
  /* So that it survives the temp cleanup below */
- SvREFCNT_inc(sv);
+ SvREFCNT_inc_simple_void(sv);
 
 #if !VMG_HAS_PERL_MAINT(5, 11, 0, 32686)
  /* The previous magic tokens were freed but the magic chain wasn't updated, so
@@ -1094,8 +1098,16 @@ STATIC int vmg_svt_free(pTHX_ SV *sv, MAGIC *mg) {
 #endif
 
  has_err = SvTRUE(ERRSV);
- if (IN_PERL_COMPILETIME && !had_err && has_err)
-  ++PL_error_count;
+ if (IN_PERL_COMPILETIME && !had_err && has_err) {
+  if (PL_errors)
+   sv_catsv(PL_errors, ERRSV);
+  else
+   Perl_warn(aTHX_ "%s", SvPV_nolen(ERRSV));
+#ifdef PL_parser
+  if (PL_parser)
+#endif
+   ++PL_error_count;
+ }
 
  SPAGAIN;
  svr = POPs;