summaryrefslogtreecommitdiffstats
path: root/main/busybox/sed-performance.patch
blob: e6c8f78de7a6bdc3ec69921e6b4e8ec3f7394bf5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From b0e9b72915a87121aabf21d4e382e16e0a9a5175 Mon Sep 17 00:00:00 2001
From: Denys Vlasenko <vda.linux@googlemail.com>
Date: Sun, 21 Jul 2013 20:09:44 +0000
Subject: sed: fix matching of newlines by $

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
---
diff --git a/editors/sed.c b/editors/sed.c
index e625a09..3a0d917 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)
 		next = index_of_next_unescaped_regexp_delim(delimiter, ++pos);
 		temp = copy_parsing_escapes(pos, next);
 		*regex = xzalloc(sizeof(regex_t));
-		xregcomp(*regex, temp, G.regex_type|REG_NEWLINE);
+		xregcomp(*regex, temp, G.regex_type);
 		free(temp);
 		/* Move position to next character after last delimiter */
 		pos += (next+1);
diff --git a/testsuite/sed.tests b/testsuite/sed.tests
index 468565f..2af1e4c 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" \
 	"sed 's/ *$/_/g'" \
 	"qwerty_\n" "" "qwerty\n"
 
+testing "sed /\$_in_regex/ should not match newlines, only end-of-line" \
+	"sed ': testcont; /\\\\$/{ =; N; b testcont }'" \
+	"\
+this is a regular line
+2
+line with \\
+continuation
+more regular lines
+5
+line with \\
+continuation
+" \
+	"" "\
+this is a regular line
+line with \\
+continuation
+more regular lines
+line with \\
+continuation
+"
+
 # testing "description" "commands" "result" "infile" "stdin"
 
 exit $FAILCOUNT
--
cgit v0.9.1