diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2013-07-21 22:09:44 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2013-07-21 22:09:44 +0200 |
| commit | b0e9b72915a87121aabf21d4e382e16e0a9a5175 (patch) | |
| tree | f260550026cd79fa5ac59ebe0fa7ff769f0a6d94 | |
| parent | 26cd90c7fd32f2ef252acb146f8b9152e55346ec (diff) | |
| download | busybox-w32-b0e9b72915a87121aabf21d4e382e16e0a9a5175.tar.gz busybox-w32-b0e9b72915a87121aabf21d4e382e16e0a9a5175.tar.bz2 busybox-w32-b0e9b72915a87121aabf21d4e382e16e0a9a5175.zip | |
sed: fix matching of newlines by $
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | editors/sed.c | 2 | ||||
| -rwxr-xr-x | testsuite/sed.tests | 21 |
2 files changed, 22 insertions, 1 deletions
diff --git a/editors/sed.c b/editors/sed.c index e625a0965..3a0d917aa 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
| @@ -330,7 +330,7 @@ static int get_address(const char *my_str, int *linenum, regex_t ** regex) | |||
| 330 | next = index_of_next_unescaped_regexp_delim(delimiter, ++pos); | 330 | next = index_of_next_unescaped_regexp_delim(delimiter, ++pos); |
| 331 | temp = copy_parsing_escapes(pos, next); | 331 | temp = copy_parsing_escapes(pos, next); |
| 332 | *regex = xzalloc(sizeof(regex_t)); | 332 | *regex = xzalloc(sizeof(regex_t)); |
| 333 | xregcomp(*regex, temp, G.regex_type|REG_NEWLINE); | 333 | xregcomp(*regex, temp, G.regex_type); |
| 334 | free(temp); | 334 | free(temp); |
| 335 | /* Move position to next character after last delimiter */ | 335 | /* Move position to next character after last delimiter */ |
| 336 | pos += (next+1); | 336 | pos += (next+1); |
diff --git a/testsuite/sed.tests b/testsuite/sed.tests index 468565f47..2af1e4c97 100755 --- a/testsuite/sed.tests +++ b/testsuite/sed.tests | |||
| @@ -310,6 +310,27 @@ testing "sed zero chars match/replace logic must not falsely trigger here 2" \ | |||
| 310 | "sed 's/ *$/_/g'" \ | 310 | "sed 's/ *$/_/g'" \ |
| 311 | "qwerty_\n" "" "qwerty\n" | 311 | "qwerty_\n" "" "qwerty\n" |
| 312 | 312 | ||
| 313 | testing "sed /\$_in_regex/ should not match newlines, only end-of-line" \ | ||
| 314 | "sed ': testcont; /\\\\$/{ =; N; b testcont }'" \ | ||
| 315 | "\ | ||
| 316 | this is a regular line | ||
| 317 | 2 | ||
| 318 | line with \\ | ||
| 319 | continuation | ||
| 320 | more regular lines | ||
| 321 | 5 | ||
| 322 | line with \\ | ||
| 323 | continuation | ||
| 324 | " \ | ||
| 325 | "" "\ | ||
| 326 | this is a regular line | ||
| 327 | line with \\ | ||
| 328 | continuation | ||
| 329 | more regular lines | ||
| 330 | line with \\ | ||
| 331 | continuation | ||
| 332 | " | ||
| 333 | |||
| 313 | # testing "description" "commands" "result" "infile" "stdin" | 334 | # testing "description" "commands" "result" "infile" "stdin" |
| 314 | 335 | ||
| 315 | exit $FAILCOUNT | 336 | exit $FAILCOUNT |
