diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2021-08-28 09:13:05 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2021-08-28 09:57:26 +0300 |
commit | 193eb8f81d8fbf7b1f3bd2b93f60882e56325d72 (patch) | |
tree | fda45c8c526ad7d513a8138b1c0445f5a258255e /src | |
parent | 93082d6eb84a086b02c7a8607f2553d5d9d0a93c (diff) | |
download | tar-193eb8f81d8fbf7b1f3bd2b93f60882e56325d72.tar.gz |
transform: fix replacement of particular pattern instance
This fixes handling of expressions like 's/s/@/2'
Fix suggested by Anthony Heading.
* src/transform.c (_single_transform_name_to_obstack): Avoid duplicating
initial prefix if replace is not needed.
Diffstat (limited to 'src')
-rw-r--r-- | src/transform.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/transform.c b/src/transform.c index 2b602353..2cc927e8 100644 --- a/src/transform.c +++ b/src/transform.c @@ -493,9 +493,6 @@ _single_transform_name_to_obstack (struct transform *tf, char *input) disp = rmp[0].rm_eo; - if (rmp[0].rm_so) - obstack_grow (&stk, input, rmp[0].rm_so); - nmatches++; if (tf->match_number && nmatches < tf->match_number) { @@ -504,6 +501,9 @@ _single_transform_name_to_obstack (struct transform *tf, char *input) continue; } + if (rmp[0].rm_so) + obstack_grow (&stk, input, rmp[0].rm_so); + for (segm = tf->repl_head; segm; segm = segm->next) { switch (segm->type) |