"hv_store doesn't insert a key with the raw utf8 on a tied hash");
}
+{
+ my $strtab = strtab();
+ is (ref $strtab, 'HASH', "The shared string table quacks like a hash");
+ eval {
+ $strtab->{wibble}++;
+ };
+ my $prefix = "Cannot modify shared string table in hv_";
+ my $what = $prefix . 'fetch';
+ like ($@, qr/^$what/,$what);
+ eval {
+ XS::APItest::Hash::store($strtab, 'Boom!', 1)
+ };
+ $what = $prefix . 'store';
+ like ($@, qr/^$what/, $what);
+ if (0) {
+ A::B->method();
+ }
+ # DESTROY should be in there.
+ eval {
+ delete $strtab->{DESTROY};
+ };
+ $what = $prefix . 'delete';
+ like ($@, qr/^$what/, $what);
+ # I can't work out how to get to the code that flips the wasutf8 flag on
+ # the hash key without some ikcy XS
+}
exit;
################################ The End ################################
#define HV_MAX_LENGTH_BEFORE_SPLIT 14
+static const char *const S_strtab_error
+ = "Cannot modify shared string table in hv_%s";
+
STATIC void
S_more_he(pTHX)
{
unshare_hek (HeKEY_hek(entry));
HeKEY_hek(entry) = new_hek;
}
+ else if (hv == PL_strtab) {
+ /* PL_strtab is usually the only hash without HvSHAREKEYS,
+ so putting this test here is cheap */
+ if (flags & HVhek_FREEKEY)
+ Safefree(key);
+ Perl_croak(aTHX_ S_strtab_error,
+ action & HV_FETCH_LVALUE ? "fetch" : "store");
+ }
else
HeKFLAGS(entry) = masked_flags;
if (masked_flags & HVhek_ENABLEHVKFLAGS)
bad API design. */
if (HvSHAREKEYS(hv))
HeKEY_hek(entry) = share_hek_flags(key, klen, hash, flags);
+ else if (hv == PL_strtab) {
+ /* PL_strtab is usually the only hash without HvSHAREKEYS, so putting
+ this test here is cheap */
+ if (flags & HVhek_FREEKEY)
+ Safefree(key);
+ Perl_croak(aTHX_ S_strtab_error,
+ action & HV_FETCH_LVALUE ? "fetch" : "store");
+ }
else /* gotta do the real thing */
HeKEY_hek(entry) = save_hek_flags(key, klen, hash, flags);
HeVAL(entry) = val;
if ((HeKFLAGS(entry) ^ masked_flags) & HVhek_UTF8)
continue;
+ if (hv == PL_strtab) {
+ if (k_flags & HVhek_FREEKEY)
+ Safefree(key);
+ Perl_croak(aTHX_ S_strtab_error, "delete");
+ }
+
/* if placeholder is here, it's already been deleted.... */
if (HeVAL(entry) == &PL_sv_placeholder)
{