According to the man page, "~ is substituted with the match", but prior to
this commit it was substituted with the entire source string up to the end
of the matching region.
-s /o/_~/, prior to this commit: foo -> f_foo
-s /o/_~/, after this commit: foo -> f_oo
Reported by: Carlo Teubner
SVN-Revision: 3643
for (i = 0, j = 0; rule->result[i] != '\0'; ++i) {
if (rule->result[i] == '~') {
realloc_strncat(result, rule->result + j, i - j);
- realloc_strncat(result, name, matches[0].rm_eo);
+ realloc_strncat(result,
+ name + matches[0].rm_so,
+ matches[0].rm_eo - matches[0].rm_so);
j = i + 1;
continue;
}