bb sed 'N' broken

Timo Teras timo.teras at iki.fi
Sun Jul 21 08:19:23 UTC 2013


On Fri, 19 Jul 2013 09:02:23 +0300
Timo Teras <timo.teras at iki.fi> wrote:

> I "accidentally" noticed that some sed scripts perl configure does
> take a long time with bb sed, but works fast with gnu sed. So I
> tracked the issue down.
> 
> Basically:
> sed -n -e ': testcont; /\\$/{ =; N; b testcont }'
> 
> With the input:
> --cut--
> this is a regular line
> 
> and line with \
> continuations 
> 
> more regular lines
> 
> --cut--
> 
> I expect to only get one output, '3' which the line number of the line
> having the trailing '\' that should match. And this is what I indeed
> get with GNU sed.

The following fixes it. Seems GNU sed has GNU extension flags to set
REG_NEWLINE if wanted, but it defaults off.

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);



More information about the busybox mailing list