Subject: [PERL] tr///s bug
Message-Id: <
19980110155333D.inaba@st.rim.or.jp>
p4raw-id: //depot/win32/perl@613
register I32 ch;
register I32 matches = 0;
register I32 squash = op->op_private & OPpTRANS_SQUASH;
+ register U8 *p;
STRLEN len;
if (SvREADONLY(sv) && !(op->op_private & OPpTRANS_COUNTONLY))
}
else {
d = s;
+ p = send;
while (s < send) {
if ((ch = tbl[*s]) >= 0) {
*d = ch;
- if (matches++ && squash) {
- if (d[-1] == *d)
+ matches++;
+ if (squash) {
+ if (p == d - 1 && *p == *d)
matches--;
else
- d++;
+ p = d++;
}
else
d++;
# $RCSfile: s.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:22 $
-print "1..67\n";
+print "1..68\n";
$x = 'foo';
$_ = "x";
eval 's{foo} # this is a comment, not a delimiter
{bar};';
print @? ? "not ok 67\n" : "ok 67\n";
+
+# check if squashing works at the end of string
+$_="baacbaa";
+tr/a/b/s;
+print $_ eq "bbcbb" ? "ok 68\n" : "not ok 68 # `$_' ne `bbcbb'\n";
+