--- threads-shared-1.23/shared.xs 2008-06-30 11:17:45.000000000 -0700
+++ threads-shared-1.23-fix/shared.xs 2008-06-30 11:19:49.000000000 -0700
@@ -875,7 +875,9 @@
STRLEN len = mg->mg_len;
assert ( mg->mg_ptr != 0 );
if (mg->mg_len == HEf_SVKEY) {
- key = SvPVutf8((SV *)mg->mg_ptr, len);
+ key = SvPV((SV *) mg->mg_ptr, len);
+ if (SvUTF8((SV *) mg->mg_ptr))
+ len = -len;
}
SHARED_CONTEXT;
svp = hv_fetch((HV*) saggregate, key, len, 0);
@@ -925,8 +927,11 @@
char *key = mg->mg_ptr;
STRLEN len = mg->mg_len;
assert ( mg->mg_ptr != 0 );
- if (mg->mg_len == HEf_SVKEY)
- key = SvPVutf8((SV *)mg->mg_ptr, len);
+ if (mg->mg_len == HEf_SVKEY) {
+ key = SvPV((SV *) mg->mg_ptr, len);
+ if (SvUTF8((SV *) mg->mg_ptr))
+ len = -len;
+ }
SHARED_CONTEXT;
svp = hv_fetch((HV*) saggregate, key, len, 1);
}
@@ -956,8 +961,11 @@
char *key = mg->mg_ptr;
STRLEN len = mg->mg_len;
assert ( mg->mg_ptr != 0 );
- if (mg->mg_len == HEf_SVKEY)
- key = SvPVutf8((SV *)mg->mg_ptr, len);
+ if (mg->mg_len == HEf_SVKEY) {
+ key = SvPV((SV *) mg->mg_ptr, len);
+ if (SvUTF8((SV *) mg->mg_ptr))
+ len = -len;
+ }
SHARED_CONTEXT;
hv_delete((HV*) saggregate, key, len, G_DISCARD);
}
@@ -1275,7 +1283,9 @@
exists = av_exists((AV*) sobj, SvIV(index));
} else {
STRLEN len;
- char *key = SvPVutf8(index, len);
+ char *key = SvPV(index,len);
+ if (SvUTF8(index))
+ len = -len;
SHARED_EDIT;
exists = hv_exists((HV*) sobj, key, len);
}
@@ -1297,9 +1307,11 @@
hv_iterinit((HV*) sobj);
entry = hv_iternext((HV*) sobj);
if (entry) {
+ I32 utf8 = HeKWASUTF8(entry);
key = hv_iterkey(entry,&len);
CALLER_CONTEXT;
- ST(0) = sv_2mortal(newSVpvn_utf8(key, len, 1));
+ ST(0) = sv_2mortal(newSVpvn(key, len));
+ if (utf8) SvUTF8_on(ST(0));
} else {
CALLER_CONTEXT;
ST(0) = &PL_sv_undef;
@@ -1323,9 +1335,11 @@
SHARED_CONTEXT;
entry = hv_iternext((HV*) sobj);
if (entry) {
+ I32 utf8 = HeKWASUTF8(entry);
key = hv_iterkey(entry,&len);
CALLER_CONTEXT;
- ST(0) = sv_2mortal(newSVpvn_utf8(key, len, 1));
+ ST(0) = sv_2mortal(newSVpvn(key, len));
+ if (utf8) SvUTF8_on(ST(0));
} else {
CALLER_CONTEXT;
ST(0) = &PL_sv_undef;