diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2021-08-28 10:35:30 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2021-08-28 10:35:30 +0300 |
commit | 2fc8e8f157b33051af12fa6f432401bcffd01b15 (patch) | |
tree | 9e294486c47b232fd35d04845ae1aa168bd6f308 /modules | |
parent | 46d7e555623b61e9e4b33e14a682d8d9fc9c9b1a (diff) | |
download | smap-master.tar.gz smap-master.tar.bz2 |
* modules/sed/transform.c (_single_transform_name_to_slist): Avoid
duplicating initial prefix if replace is not needed.
* tests/sed.at: Add new testcases.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/sed/transform.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/modules/sed/transform.c b/modules/sed/transform.c index 67e0de8..ec7983f 100644 --- a/modules/sed/transform.c +++ b/modules/sed/transform.c @@ -623,25 +623,25 @@ _single_transform_name_to_slist (struct transform *tr, if (rc == 0) { struct replace_segm *segm; disp = rmp[0].rm_eo; - if (rmp[0].rm_so) - if (transform_append (tr, slist, input, rmp[0].rm_so)) - return 1; - nmatches++; if (tf->match_number && nmatches < tf->match_number) { if (transform_append (tr, slist, input, disp)) return 1; input += disp; continue; } + if (rmp[0].rm_so) + if (transform_append (tr, slist, input, rmp[0].rm_so)) + return 1; + for (segm = tf->repl_head; segm; segm = segm->next) { switch (segm->type) { case segm_literal: /* Literal segment */ if (case_ctl == ctl_stop) |