This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Optimize [^\n] into \N
[perl5.git] / scope.h
diff --git a/scope.h b/scope.h
index 38da244..f8df5b4 100644 (file)
--- a/scope.h
+++ b/scope.h
@@ -235,15 +235,12 @@ scope has the given name. Name must be a literal string.
 #define SAVEPARSER(p) save_pushptr((p), SAVEt_PARSER)
 
 #ifdef USE_ITHREADS
-#  define SAVECOPSTASH(c)      (SAVEPPTR(CopSTASHPV(c)), \
-                                SAVEI32(CopSTASH_len(c)))
-#  define SAVECOPSTASH_FREE(c) (SAVESHAREDPV(CopSTASHPV(c)), \
-                                SAVEI32(CopSTASH_len(c)))
+#  define SAVECOPSTASH_FREE(c) SAVEIV((c)->cop_stashoff)
 #  define SAVECOPFILE(c)       SAVEPPTR(CopFILE(c))
 #  define SAVECOPFILE_FREE(c)  SAVESHAREDPV(CopFILE(c))
 #else
-#  define SAVECOPSTASH(c)      SAVESPTR(CopSTASH(c))
-#  define SAVECOPSTASH_FREE(c) SAVECOPSTASH(c) /* XXX not refcounted */
+#  /* XXX not refcounted */
+#  define SAVECOPSTASH_FREE(c) SAVESPTR(CopSTASH(c))
 #  define SAVECOPFILE(c)       SAVESPTR(CopFILEGV(c))
 #  define SAVECOPFILE_FREE(c)  SAVEGENERICSV(CopFILEGV(c))
 #endif
@@ -272,7 +269,21 @@ scope has the given name. Name must be a literal string.
 
 #define save_freesv(op)                save_pushptr((void *)(op), SAVEt_FREESV)
 #define save_mortalizesv(op)   save_pushptr((void *)(op), SAVEt_MORTALIZESV)
-#define save_freeop(op)                save_pushptr((void *)(op), SAVEt_FREEOP)
+#if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
+# define save_freeop(op)                    \
+    ({                                       \
+      OP * const _o = (OP *)(op);             \
+      _o->op_savefree = 1;                     \
+      save_pushptr((void *)(_o), SAVEt_FREEOP); \
+    })
+#else
+# define save_freeop(op)                       \
+    (                                           \
+      PL_Xpv = (XPV *)(op),                      \
+      ((OP *)PL_Xpv)->op_savefree = 1,            \
+      save_pushptr((void *)(PL_Xpv), SAVEt_FREEOP) \
+    )
+#endif
 #define save_freepv(pv)                save_pushptr((void *)(pv), SAVEt_FREEPV)
 #define save_op()              save_pushptr((void *)(PL_op), SAVEt_OP)
 
@@ -280,8 +291,8 @@ scope has the given name. Name must be a literal string.
  * Local variables:
  * c-indentation-style: bsd
  * c-basic-offset: 4
- * indent-tabs-mode: t
+ * indent-tabs-mode: nil
  * End:
  *
- * ex: set ts=8 sts=4 sw=4 noet:
+ * ex: set ts=8 sts=4 sw=4 et:
  */