summaryrefslogtreecommitdiff
path: root/pad.c
diff options
context:
space:
mode:
authorBrian Fraser <fraserbn@gmail.com>2011-06-11 14:39:00 -0300
committerFather Chrysostomos <sprout@cpan.org>2011-07-12 21:46:53 -0700
commit5b16296c0d0bd2ff7c79725138f13c698d8afd16 (patch)
treebc72e99763c433465432188ed60112dcfce30f0e /pad.c
parentbc9b26cad0a33f1ceccd0800a90bd774b4fc4578 (diff)
downloadperl-5b16296c0d0bd2ff7c79725138f13c698d8afd16.tar.gz
Added sv_eq_pvn_flags to pad.c, which will be used by later commits.
Diffstat (limited to 'pad.c')
-rw-r--r--pad.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/pad.c b/pad.c
index 450fe2ee6f..1a8ff62e60 100644
--- a/pad.c
+++ b/pad.c
@@ -169,6 +169,47 @@ void pad_peg(const char* s) {
#endif
/*
+This is basically sv_eq_flags() in sv.c, but we avoid the magic
+and bytes checking.
+*/
+
+STATIC I32
+sv_eq_pvn_flags(pTHX_ const SV *sv, const char* pv, const I32 pvlen, const U32 flags) {
+ if ( (SvUTF8(sv) & SVf_UTF8 ) != (flags & SVf_UTF8) ) {
+ const char *pv1 = SvPVX_const(sv);
+ STRLEN cur1 = SvCUR(sv);
+ const char *pv2 = pv;
+ STRLEN cur2 = pvlen;
+ if (PL_encoding) {
+ SV* svrecode = NULL;
+ if (SvUTF8(sv)) {
+ svrecode = newSVpvn(pv2, cur2);
+ sv_recode_to_utf8(svrecode, PL_encoding);
+ pv2 = SvPV_const(svrecode, cur2);
+ }
+ else {
+ svrecode = newSVpvn(pv1, cur1);
+ sv_recode_to_utf8(svrecode, PL_encoding);
+ pv1 = SvPV_const(svrecode, cur1);
+ }
+ SvREFCNT_dec(svrecode);
+ }
+ if (flags & SVf_UTF8)
+ return (bytes_cmp_utf8(
+ (const U8*)pv1, cur1,
+ (const U8*)pv2, cur2) == 0);
+ else
+ return (bytes_cmp_utf8(
+ (const U8*)pv2, cur2,
+ (const U8*)pv1, cur1) == 0);
+ }
+ else
+ return ((SvPVX_const(sv) == pv)
+ || memEQ(SvPVX_const(sv), pv, pvlen));
+}
+
+
+/*
=for apidoc Am|PADLIST *|pad_new|int flags
Create a new padlist, updating the global variables for the