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 | |
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.
-rw-r--r-- | modules/sed/transform.c | 8 | ||||
-rw-r--r-- | tests/sed.at | 9 |
2 files changed, 12 insertions, 5 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 @@ -628,6 +628,2 @@ _single_transform_name_to_slist (struct transform *tr, - if (rmp[0].rm_so) - if (transform_append (tr, slist, input, rmp[0].rm_so)) - return 1; - nmatches++; @@ -641,2 +637,6 @@ _single_transform_name_to_slist (struct transform *tr, + 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) diff --git a/tests/sed.at b/tests/sed.at index 0f432c5..39dd99d 100644 --- a/tests/sed.at +++ b/tests/sed.at @@ -11,2 +11,6 @@ database dequote sed 's/<(.*)>/\1/g' database default sed 's/ok-(.*)/\1/' +database n sed 's/s/@/2' +database g sed 's/s/@/2g' +dispatch map eq n database n +dispatch map eq g database g dispatch key like <*> transform key dequote @@ -14,3 +18,3 @@ dispatch default database default ]) -AT_CHECK([smaptest -c smapd.conf test ok-word test word test '<ok-word>' +AT_CHECK([smaptest -c smapd.conf test ok-word test word test '<ok-word>' n password g passwords ], @@ -20,3 +24,6 @@ test word: NOTFOUND test <ok-word>: OK word +n password: OK pas@word +g passwords: OK pas@word@ ]) + AT_CLEANUP |