summaryrefslogtreecommitdiff
path: root/hv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-09-01 07:24:59 +0100
committerNicholas Clark <nick@ccl4.org>2010-09-01 07:24:59 +0100
commita77ac40c5b8111e15c16279ce494e3aafde2b18e (patch)
tree75b6529b640b986b0f19390367d1d4b6b5d91604 /hv.c
parent5230ff8e57b55d2bb859cf3281ebffac412f7686 (diff)
downloadperl-a77ac40c5b8111e15c16279ce494e3aafde2b18e.tar.gz
Refactor Perl_store_cop_label() to avoid exposing struct refcounted_he *.
Instead pass in a COP, as suggested by Ben Morrow. Also add length and flags parameters, and remove the comment suggesting this change. The underlying storage mechanism can honour length and UTF8/not, so there is no harm in exposing this one level higher.
Diffstat (limited to 'hv.c')
-rw-r--r--hv.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/hv.c b/hv.c
index d29c49cd40..d8ba456745 100644
--- a/hv.c
+++ b/hv.c
@@ -2970,16 +2970,20 @@ Perl_fetch_cop_label(pTHX_ struct refcounted_he *const chain, STRLEN *len,
return chain->refcounted_he_data + 1;
}
-/* As newSTATEOP currently gets passed plain char* labels, we will only provide
- that interface. Once it works out how to pass in length and UTF-8 ness, this
- function will need superseding. */
-struct refcounted_he *
-Perl_store_cop_label(pTHX_ struct refcounted_he *const chain, const char *label)
+void
+Perl_store_cop_label(pTHX_ COP *const cop, const char *label, STRLEN len,
+ U32 flags)
{
PERL_ARGS_ASSERT_STORE_COP_LABEL;
- return refcounted_he_new_common(chain, ":", 1, HVrhek_PV, HVrhek_PV,
- label, strlen(label));
+ if (flags & ~(SVf_UTF8))
+ Perl_croak(aTHX_ "panic: store_cop_label illegal flag bits 0x%" UVxf,
+ (UV)flags);
+
+ cop->cop_hints_hash
+ = refcounted_he_new_common(cop->cop_hints_hash, ":", 1, HVrhek_PV,
+ flags & SVf_UTF8 ? HVrhek_PV_UTF8 : HVrhek_PV,
+ label, len);
}
/*