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.
This commit is contained in:
parent
a0a8791704
commit
4b9c6645f5
1
sed.c
1
sed.c
|
@ -551,6 +551,7 @@ find_delim(char *s, Rune delim, int do_brackets)
|
||||||
r == '.' ||
|
r == '.' ||
|
||||||
r == '=') ) { state = CLASS_INSIDE ; c = r; }
|
r == '=') ) { state = CLASS_INSIDE ; c = r; }
|
||||||
else if (state == INSIDE_OPENING && r == ']' ) { state = OUTSIDE ; }
|
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 = INSIDE_OPENING ; }
|
||||||
else if (state == BRACKETS_INSIDE && r == ']' ) { state = OUTSIDE ; }
|
else if (state == BRACKETS_INSIDE && r == ']' ) { state = OUTSIDE ; }
|
||||||
else if (state == OUTSIDE && escape ) { escape = 0 ; }
|
else if (state == OUTSIDE && escape ) { escape = 0 ; }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user