This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: Remove obsolete comment
[perl5.git] / mg.h
diff --git a/mg.h b/mg.h
index de673d4..0f2fa29 100644 (file)
--- a/mg.h
+++ b/mg.h
@@ -33,11 +33,13 @@ struct magic {
 
 #define MGf_TAINTEDDIR 1        /* PERL_MAGIC_envelem only */
 #define MGf_MINMATCH   1        /* PERL_MAGIC_regex_global only */
+#define MGf_REQUIRE_GV 1        /* PERL_MAGIC_checkcall only */
 #define MGf_REFCOUNTED 2
 #define MGf_GSKIP      4       /* skip further GETs until after next SET */
 #define MGf_COPY       8       /* has an svt_copy  MGVTBL entry */
 #define MGf_DUP     0x10       /* has an svt_dup   MGVTBL entry */
 #define MGf_LOCAL   0x20       /* has an svt_local MGVTBL entry */
+#define MGf_BYTES   0x40        /* PERL_MAGIC_regex_global only */
 
 #define MgTAINTEDDIR(mg)       (mg->mg_flags & MGf_TAINTEDDIR)
 #define MgTAINTEDDIR_on(mg)    (mg->mg_flags |= MGf_TAINTEDDIR)
@@ -57,6 +59,19 @@ struct magic {
 #define SvTIED_obj(sv,mg) \
     ((mg)->mg_obj ? (mg)->mg_obj : sv_2mortal(newRV(sv)))
 
+#if defined(PERL_CORE) || defined(PERL_EXT)
+# define MgBYTEPOS(mg,sv,pv,len) S_MgBYTEPOS(aTHX_ mg,sv,pv,len)
+/* assumes get-magic and stringification have already occurred */
+# define MgBYTEPOS_set(mg,sv,pv,off) (                  \
+    assert_((mg)->mg_type == PERL_MAGIC_regex_global)    \
+    SvPOK(sv) && !SvGMAGICAL(sv)                          \
+       ? (mg)->mg_len = (off), (mg)->mg_flags |= MGf_BYTES \
+       : ((mg)->mg_len = DO_UTF8(sv)                        \
+           ? (SSize_t)utf8_length((U8 *)(pv), (U8 *)(pv)+(off)) \
+           : (SSize_t)(off),                                     \
+          (mg)->mg_flags &= ~MGf_BYTES))
+#endif
+
 #define whichsig(pv) whichsig_pv(pv)
 
 /*