From: Denys Vlasenko Date: Mon, 2 May 2011 22:52:22 +0000 (+0200) Subject: sed: support \r in s command X-Git-Tag: 1_19_0~152 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6a0abcc02f0773f32f2d31b3532eec1b11e1f67d;p=oweals%2Fbusybox.git sed: support \r in s command function old new delta copy_parsing_escapes 65 91 +26 Signed-off-by: Denys Vlasenko --- diff --git a/editors/sed.c b/editors/sed.c index 9e27e3e18..11c476321 100644 --- a/editors/sed.c +++ b/editors/sed.c @@ -218,8 +218,9 @@ static char *copy_parsing_escapes(const char *string, int len) char *dest = xmalloc(len + 1); parse_escapes(dest, string, len, 'n', '\n'); - /* GNU sed also recognizes \t */ + /* GNU sed also recognizes \t and \r */ parse_escapes(dest, dest, strlen(dest), 't', '\t'); + parse_escapes(dest, dest, strlen(dest), 'r', '\r'); return dest; } diff --git a/testsuite/sed.tests b/testsuite/sed.tests index 395372ae6..e9d0ed601 100755 --- a/testsuite/sed.tests +++ b/testsuite/sed.tests @@ -287,6 +287,9 @@ testing "sed -i with address modifies all files, not only first" \ "cp input input2; sed -i -e '1s/foo/bar/' input input2 && cat input input2; rm input2" \ "bar\nbar\n" "foo\n" "" +testing "sed understands \r" \ + "sed 's/r/\r/'" \ + "\rrr\n" "" "rrr\n" # testing "description" "arguments" "result" "infile" "stdin"