Ap |void |pregfree2 |NN REGEXP* prog
EXp |REGEXP*|reg_temp_copy |NN REGEXP* r
Ap |void |regfree_internal|NULLOK REGEXP * const r
-Ap |char * |reg_stringify |NN MAGIC *mg|NULLOK STRLEN *lp|NULLOK U32 *flags|NULLOK I32 *haseval
#if defined(USE_ITHREADS)
Ap |void* |regdupe_internal|NN REGEXP * const r|NN CLONE_PARAMS* param
#endif
#define reg_temp_copy Perl_reg_temp_copy
#endif
#define regfree_internal Perl_regfree_internal
-#define reg_stringify Perl_reg_stringify
#if defined(USE_ITHREADS)
#define regdupe_internal Perl_regdupe_internal
#endif
#define reg_temp_copy(a) Perl_reg_temp_copy(aTHX_ a)
#endif
#define regfree_internal(a) Perl_regfree_internal(aTHX_ a)
-#define reg_stringify(a,b,c,d) Perl_reg_stringify(aTHX_ a,b,c,d)
#if defined(USE_ITHREADS)
#define regdupe_internal(a,b) Perl_regdupe_internal(aTHX_ a,b)
#endif
Perl_pregfree2
Perl_reg_temp_copy
Perl_regfree_internal
-Perl_reg_stringify
Perl_regdupe_internal
Perl_pregcomp
Perl_re_compile
#define CALLREG_INTUIT_STRING(prog) \
CALL_FPTR(RX_ENGINE(prog)->checkstr)(aTHX_ (prog))
-#define CALLREG_AS_STR(mg,lp,flags,haseval) \
- Perl_reg_stringify(aTHX_ (mg), (lp), (flags), (haseval))
-#define CALLREG_STRINGIFY(mg,lp,flags) CALLREG_AS_STR(mg,lp,flags,0)
-
#define CALLREGFREE(prog) \
Perl_pregfree(aTHX_ (prog))
__attribute__nonnull__(pTHX_1);
PERL_CALLCONV void Perl_regfree_internal(pTHX_ REGEXP * const r);
-PERL_CALLCONV char * Perl_reg_stringify(pTHX_ MAGIC *mg, STRLEN *lp, U32 *flags, I32 *haseval)
- __attribute__nonnull__(pTHX_1);
-
#if defined(USE_ITHREADS)
PERL_CALLCONV void* Perl_regdupe_internal(pTHX_ REGEXP * const r, CLONE_PARAMS* param)
__attribute__nonnull__(pTHX_1)
#endif /* USE_ITHREADS */
-/*
- reg_stringify()
-
- converts a regexp embedded in a MAGIC struct to its stringified form,
- caching the converted form in the struct and returns the cached
- string.
-
- If lp is nonnull then it is used to return the length of the
- resulting string
-
- If flags is nonnull and the returned string contains UTF8 then
- (*flags & 1) will be true.
-
- If haseval is nonnull then it is used to return whether the pattern
- contains evals.
-
- Normally called via macro:
-
- CALLREG_STRINGIFY(mg,&len,&utf8);
-
- And internally with
-
- CALLREG_AS_STR(mg,&lp,&flags,&haseval)
-
- See sv_2pv_flags() in sv.c for an example of internal usage.
-
- */
#ifndef PERL_IN_XSUB_RE
-char *
-Perl_reg_stringify(pTHX_ MAGIC *mg, STRLEN *lp, U32 *flags, I32 *haseval ) {
- dVAR;
- const REGEXP * const re = (REGEXP *)mg->mg_obj;
- if (haseval)
- *haseval = RX_SEEN_EVALS(re);
- if (flags)
- *flags = RX_UTF8(re) ? 1 : 0;
- if (lp)
- *lp = RX_WRAPLEN(re);
- return RX_WRAPPED(re);
-}
-
/*
- regnext - dig the "next" pointer out of a node
*/
len = 7;
retval = buffer = savepvn("NULLREF", len);
} else if (SvTYPE(referent) == SVt_REGEXP) {
- char *str = NULL;
- I32 haseval = 0;
- U32 flags = 0;
- struct magic temp;
- /* FIXME - get rid of this cast away of const, or work out
- how to do it better. */
- temp.mg_obj = (SV *)referent;
- assert(temp.mg_obj);
- (str) = CALLREG_AS_STR(&temp,lp,&flags,&haseval);
- if (flags & 1)
- SvUTF8_on(sv);
- else
- SvUTF8_off(sv);
- PL_reginterp_cnt += haseval;
- return str;
+ const REGEXP * const re = (REGEXP *)referent;
+ I32 seen_evals = 0;
+
+ assert(re);
+
+ /* If the regex is UTF-8 we want the containing scalar to
+ have an UTF-8 flag too */
+ if (RX_UTF8(re))
+ SvUTF8_on(sv);
+ else
+ SvUTF8_off(sv);
+
+ if ((seen_evals = RX_SEEN_EVALS(re)))
+ PL_reginterp_cnt += seen_evals;
+
+ if (lp)
+ *lp = RX_WRAPLEN(re);
+
+ return RX_WRAPPED(re);
} else {
const char *const typestr = sv_reftype(referent, 0);
const STRLEN typelen = strlen(typestr);