summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>2000-12-12 18:49:45 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>2000-12-12 18:49:45 +0000
commit8a8183332d9a42d93d66e4028ccb28fd2bda82d8 (patch)
tree579d84502ac9b8d59b7d6a48fe28d27700370008 /sv.c
parent360eb788a3c30916019278c140e3ebfb207f591f (diff)
downloadperl-8a8183332d9a42d93d66e4028ccb28fd2bda82d8.tar.gz
Fix for Tk, and upgrading shared SVs.
p4raw-id: //depot/perlio@8091
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/sv.c b/sv.c
index c6b718c995..e29d1b40cf 100644
--- a/sv.c
+++ b/sv.c
@@ -1620,6 +1620,9 @@ Perl_sv_2uv(pTHX_ register SV *sv)
return SvUV(tmpstr);
return PTR2UV(SvRV(sv));
}
+ if (SvREADONLY(sv) && SvFAKE(sv)) {
+ sv_force_normal(sv);
+ }
if (SvREADONLY(sv) && !SvOK(sv)) {
if (ckWARN(WARN_UNINITIALIZED))
report_uninit();
@@ -1782,6 +1785,9 @@ Perl_sv_2nv(pTHX_ register SV *sv)
return SvNV(tmpstr);
return PTR2NV(SvRV(sv));
}
+ if (SvREADONLY(sv) && SvFAKE(sv)) {
+ sv_force_normal(sv);
+ }
if (SvREADONLY(sv) && !SvOK(sv)) {
if (ckWARN(WARN_UNINITIALIZED))
report_uninit();
@@ -2385,7 +2391,7 @@ void
Perl_sv_utf8_upgrade(pTHX_ register SV *sv)
{
char *s, *t;
- bool hibit;
+ int hibit = FALSE;
if (!sv || !SvPOK(sv) || SvUTF8(sv))
return;
@@ -2393,12 +2399,22 @@ Perl_sv_utf8_upgrade(pTHX_ register SV *sv)
/* This function could be much more efficient if we had a FLAG in SVs
* to signal if there are any hibit chars in the PV.
*/
- for (s = t = SvPVX(sv), hibit = FALSE; t < SvEND(sv) && !hibit; t++)
- if (*t & 0x80)
+ for (s = t = SvPVX(sv); t < SvEND(sv) && !hibit; t++) {
+ if (*t & 0x80) {
hibit = TRUE;
+ break;
+ }
+ }
if (hibit) {
- STRLEN len = SvCUR(sv) + 1; /* Plus the \0 */
+ STRLEN len;
+ if (SvREADONLY(sv) && SvFAKE(sv)) {
+ Perl_warn(aTHX_ "%d s=%p t=%p e=%p",(int)hibit,s,t,SvEND(sv));
+ sv_dump(sv);
+ sv_force_normal(sv);
+ s = SvPVX(sv);
+ }
+ len = SvCUR(sv) + 1; /* Plus the \0 */
SvPVX(sv) = (char*)bytes_to_utf8((U8*)s, &len);
SvCUR(sv) = len - 1;
SvLEN(sv) = len; /* No longer know the real size. */