Ticket #2320 (closed defect: fixed)
regexp replace only transforms the first occurence correctly
Reported by: | ply | Owned by: | andrew_b |
---|---|---|---|
Priority: | major | Milestone: | 4.7.4 |
Component: | mcedit | Version: | 4.7.3 |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Branch state: | Votes for changeset: | committed-master committed-stable |
Description
If the replacement string contains references to parenthesized substrings (\1, \2, ...), the first occurence is transformed correctly, but subsequent ones are replaced by the result from the first occurence. A comment at editcmd.c:1838 says
/* don't process string each time */
thus skips calling mc_search_prepare_replace_str more than once per search. This makes regexp replace fairly unusable.
Attachments
Change History
comment:2 Changed 14 years ago by ply
To reproduce:
Create a file containing foo bar baz.
Do a replace with search string (\w+) and replacement string "\1".
The expected result is that each word will be quoted with double quotes.
Instead, the file will turn into "foo" "foo" "foo".
This feature used to work in 4.7.0.1.
comment:4 Changed 14 years ago by andrew_b
- Keywords stable-candidate added
I've attached a patch. I'll create a branch today at evening.
comment:5 Changed 14 years ago by andrew_b
- Owner set to andrew_b
- Status changed from new to accepted
- severity changed from no branch to on review
Created 2320_regexp_replace branch. Parent branch is master.
changeset:3b4f38fa10b37254e251b43d4c6a0942c244beb8
comment:8 Changed 14 years ago by slavazanko
- Votes for changeset changed from angel_il to angel_il slavazanko
- severity changed from on review to approved
comment:9 Changed 14 years ago by andrew_b
- Status changed from accepted to testing
- Votes for changeset changed from angel_il slavazanko to committed-master committed-stable
- Resolution set to fixed
- severity changed from approved to merged
Merged to master.
changeset:6598729ce56bef4c02f3c2ab293bb2a5c95402b6
Cherry-picked to 4.7.0-stable.
changeset:5f512ac3b303739338c3d9db916d81c8f9c116e8
Would you provide the step-by-step description how to reproduce this bug? What you expect and what you get?