perl/perl-5.8.8-U34297_C28006.patch

27 lines
705 B
Diff
Raw Normal View History

2006-07-14 00:50:57 +00:00
--- perl-5.8.8/pp.c.U34297_C28006 2006-07-13 12:40:37.000000000 -0400
+++ perl-5.8.8/pp.c 2006-07-13 13:03:19.000000000 -0400
@@ -2949,7 +2949,22 @@
dSP; dTARGET;
SV *sv = TOPs;
- if (DO_UTF8(sv))
+ if (SvAMAGIC(sv)) {
+ /* For an overloaded scalar, we can't know in advance if it's going to
+ be UTF-8 or not. Also, we can't call sv_len_utf8 as it likes to
+ cache the length. Maybe that should be a documented feature of it.
+ */
+ STRLEN len;
+ const char *const p = SvPV_const(sv, len);
+
+ if (DO_UTF8(sv)) {
+ SETi(utf8_length((U8*)p, (U8*)p + len));
+ }
+ else
+ SETi(len);
+
+ }
+ else if (DO_UTF8(sv))
SETi(sv_len_utf8(sv));
else
SETi(sv_len(sv));