sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

commit 4b9c6645f548fc65c86c7980dffcb074182423da
parent a0a87917044cc6e485539e30a594bf924029f1c5
Author: Pieter Kockx <pieterkockx@gmail.com>
Date:   Sun, 22 Oct 2017 02:09:46 +0200

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.

Diffstat:
Msed.c | 1+
1 file changed, 1 insertion(+), 0 deletions(-)

diff --git 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 ; }