diff options
-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 | |||
@@ -623,25 +623,25 @@ _single_transform_name_to_slist (struct transform *tr, | |||
623 | if (rc == 0) | 623 | if (rc == 0) |
624 | { | 624 | { |
625 | struct replace_segm *segm; | 625 | struct replace_segm *segm; |
626 | 626 | ||
627 | disp = rmp[0].rm_eo; | 627 | disp = rmp[0].rm_eo; |
628 | 628 | ||
629 | if (rmp[0].rm_so) | ||
630 | if (transform_append (tr, slist, input, rmp[0].rm_so)) | ||
631 | return 1; | ||
632 | |||
633 | nmatches++; | 629 | nmatches++; |
634 | if (tf->match_number && nmatches < tf->match_number) | 630 | if (tf->match_number && nmatches < tf->match_number) |
635 | { | 631 | { |
636 | if (transform_append (tr, slist, input, disp)) | 632 | if (transform_append (tr, slist, input, disp)) |
637 | return 1; | 633 | return 1; |
638 | input += disp; | 634 | input += disp; |
639 | continue; | 635 | continue; |
640 | } | 636 | } |
641 | 637 | ||
638 | if (rmp[0].rm_so) | ||
639 | if (transform_append (tr, slist, input, rmp[0].rm_so)) | ||
640 | return 1; | ||
641 | |||
642 | for (segm = tf->repl_head; segm; segm = segm->next) | 642 | for (segm = tf->repl_head; segm; segm = segm->next) |
643 | { | 643 | { |
644 | switch (segm->type) | 644 | switch (segm->type) |
645 | { | 645 | { |
646 | case segm_literal: /* Literal segment */ | 646 | case segm_literal: /* Literal segment */ |
647 | if (case_ctl == ctl_stop) | 647 | if (case_ctl == ctl_stop) |
diff --git a/tests/sed.at b/tests/sed.at index 0f432c5..39dd99d 100644 --- a/tests/sed.at +++ b/tests/sed.at | |||
@@ -6,18 +6,25 @@ | |||
6 | AT_SETUP([sed]) | 6 | AT_SETUP([sed]) |
7 | AT_DATA([smapd.conf], | 7 | AT_DATA([smapd.conf], |
8 | [idle-timeout 10 | 8 | [idle-timeout 10 |
9 | module sed sed | 9 | module sed sed |
10 | database dequote sed 's/<(.*)>/\1/g' | 10 | database dequote sed 's/<(.*)>/\1/g' |
11 | database default sed 's/ok-(.*)/\1/' | 11 | database default sed 's/ok-(.*)/\1/' |
12 | database n sed 's/s/@/2' | ||
13 | database g sed 's/s/@/2g' | ||
14 | dispatch map eq n database n | ||
15 | dispatch map eq g database g | ||
12 | dispatch key like <*> transform key dequote | 16 | dispatch key like <*> transform key dequote |
13 | dispatch default database default | 17 | dispatch default database default |
14 | ]) | 18 | ]) |
15 | AT_CHECK([smaptest -c smapd.conf test ok-word test word test '<ok-word>' | 19 | AT_CHECK([smaptest -c smapd.conf test ok-word test word test '<ok-word>' n password g passwords |
16 | ], | 20 | ], |
17 | [0], | 21 | [0], |
18 | [test ok-word: OK word | 22 | [test ok-word: OK word |
19 | test word: NOTFOUND | 23 | test word: NOTFOUND |
20 | test <ok-word>: OK word | 24 | test <ok-word>: OK word |
25 | n password: OK pas@word | ||
26 | g passwords: OK pas@word@ | ||
21 | ]) | 27 | ]) |
28 | |||
22 | AT_CLEANUP | 29 | AT_CLEANUP |
23 | 30 | ||