From 45102a167a8b3a101072f8ec62927158ccaa7027 Mon Sep 17 00:00:00 2001 From: Pieter Kockx Date: Sun, 22 Oct 2017 02:09:46 +0200 Subject: [PATCH] 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. --- sed.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sed.c b/sed.c index 6cfd121..4585f17 100644 --- a/sed.c +++ b/sed.c @@ -549,6 +549,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 ; } -- 2.13.5