fix a bug in handling $+[0] and unicode
authorDavid Mitchell <davem@iabyn.com>
Fri, 7 Sep 2012 12:32:11 +0000 (13:32 +0100)
committerDavid Mitchell <davem@iabyn.com>
Sat, 8 Sep 2012 14:42:07 +0000 (15:42 +0100)
commit3de645a82921698b4886d748e3a5a5ed98752f42
tree87d9216d355c745485a442812319a421310a23b0
parent6f1854a1fe246f8633ccd4d455563cb4210ceb39
fix a bug in handling $+[0] and unicode

The code to decide what substring of a pattern target to copy for the
sake of $1, $& etc, would, in the absence of $&, only copy the minimum
range needed to cover $1,$2,...., which might be a shorter range than
what $& covers. This is fine most of the time, but, when calculating
$+[0] on a unicode string, it needs a copy of the whole part of the string
covered by $&, since it needs to convert the byte offest into a char
offset.
So to fix this, always copy as a minimum, the $& range.
I suppose we could be more clever about this: detect the presence
of @+ in the code, only do it for UTF8 etc; but this is simple
and non-fragile.
regexec.c
t/re/re_tests