commit 4b9c6645f548fc65c86c7980dffcb074182423da
Author: Pieter Kockx <[email protected]>
AuthorDate: Sun Oct 22 02:09:46 2017 +0200
Commit: Michael Forney <[email protected]>
CommitDate: Fri Nov 10 18:19:32 2017 -0800
sed: Fix parsing bug in find_delim
's/[[x=]//' was parsed as 's/[[=x]//' which (correctly)
raises an error because the "second delimiter is missing", here =].
The two got mixed up because the parser didn't return to
the "inside bracket"-state after encountering an opening bracket
while inside the bracket expression.
diff --git a/sed.c b/sed.c
index 259b654..532361f 100644
--- a/sed.c
+++ b/sed.c
@@ -551,6 +551,7 @@ find_delim(char *s, Rune delim, int do_brackets)
r == '.' ||
r == '=') ) {
state = CLASS_INSIDE ; c = r; }
else if (state == INSIDE_OPENING && r == ']' ) {
state = OUTSIDE ; }
+ else if (state == INSIDE_OPENING ) {
state = BRACKETS_INSIDE ; }
else if (state == BRACKETS_INSIDE && r == '[' ) {
state = INSIDE_OPENING ; }
else if (state == BRACKETS_INSIDE && r == ']' ) {
state = OUTSIDE ; }
else if (state == OUTSIDE && escape ) {
escape = 0 ; }