[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl5-changes
Subject:    Change 33599: Integrate:
From:       Nicholas Clark <nwc10+p5p4 () colon ! colondot ! net>
Date:       2008-03-29 15:45:03
Message-ID: 20080329154503.D49A450006 () mx ! activestate ! com
[Download RAW message or body]

Change 33599 by nicholas@mouse-mill on 2008/03/29 15:41:22

	Integrate:
	[ 33579]
	Don't call S_utf8_mg_pos_cache_update(), and hence don't even create
	the magic for the UTF-8 cache, if the UTF-8 caching is disabled.
	
	[ 33580]
	The offset for pos is stored as bytes, and converted to (Unicode)
	character position when read, if needed. The code for setting pos
	inside subst was incorrectly converting to character position before
	storing the value. This code appears to have been buggy since it was
	added in 2000 in change 7562.

Affected files ...

... //depot/maint-5.10/perl/pp_ctl.c#8 integrate
... //depot/maint-5.10/perl/sv.c#8 integrate
... //depot/maint-5.10/perl/t/op/subst.t#2 integrate

Differences ...

==== //depot/maint-5.10/perl/pp_ctl.c#8 (text) ====
Index: perl/pp_ctl.c
--- perl/pp_ctl.c#7~33157~	2008-01-31 13:43:37.000000000 -0800
+++ perl/pp_ctl.c	2008-03-29 08:41:22.000000000 -0700
@@ -285,7 +285,6 @@
     { /* Update the pos() information. */
 	SV * const sv = cx->sb_targ;
 	MAGIC *mg;
-	I32 i;
 	SvUPGRADE(sv, SVt_PVMG);
 	if (!(mg = mg_find(sv, PERL_MAGIC_regex_global))) {
 #ifdef PERL_OLD_COPY_ON_WRITE
@@ -295,10 +294,7 @@
 	    mg = sv_magicext(sv, NULL, PERL_MAGIC_regex_global, &PL_vtbl_mglob,
 			     NULL, 0);
 	}
-	i = m - orig;
-	if (DO_UTF8(sv))
-	    sv_pos_b2u(sv, &i);
-	mg->mg_len = i;
+	mg->mg_len = m - orig;
     }
     if (old != rx)
 	(void)ReREFCNT_inc(rx);

==== //depot/maint-5.10/perl/sv.c#8 (text) ====
Index: perl/sv.c
--- perl/sv.c#7~33167~	2008-02-01 06:04:12.000000000 -0800
+++ perl/sv.c	2008-03-29 08:41:22.000000000 -0700
@@ -5612,7 +5612,8 @@
 	boffset = real_boffset;
     }
 
-    S_utf8_mg_pos_cache_update(aTHX_ sv, mgp, boffset, uoffset, send - start);
+    if (PL_utf8cache)
+	utf8_mg_pos_cache_update(sv, mgp, boffset, uoffset, send - start);
     return boffset;
 }
 
@@ -5958,7 +5959,8 @@
     }
     *offsetp = len;
 
-    S_utf8_mg_pos_cache_update(aTHX_ sv, &mg, byte, len, blen);
+    if (PL_utf8cache)
+	utf8_mg_pos_cache_update(sv, &mg, byte, len, blen);
 }
 
 /*

==== //depot/maint-5.10/perl/t/op/subst.t#2 (xtext) ====
Index: perl/t/op/subst.t
--- perl/t/op/subst.t#1~32694~	2007-12-22 01:23:09.000000000 -0800
+++ perl/t/op/subst.t	2008-03-29 08:41:22.000000000 -0700
@@ -7,7 +7,7 @@
 }
 
 require './test.pl';
-plan( tests => 136 );
+plan( tests => 139 );
 
 $x = 'foo';
 $_ = "x";
@@ -583,3 +583,11 @@
     is($want,$_,"RT#17542");
 }
 
+{
+    my @tests = ('ABC', "\xA3\xA4\xA5", "\x{410}\x{411}\x{412}");
+    foreach (@tests) {
+	my $id = ord $_;
+	s/./pos/ge;
+	is($_, "012", "RT#52104: $id");
+    }
+}
End of Patch.
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic