[hackers] [sbase] sed: Fix parsing bug in find_delim || Pieter Kockx
commit 4b9c6645f548fc65c86c7980dffcb074182423da
Author: Pieter Kockx <pieterkockx_AT_gmail.com>
AuthorDate: Sun Oct 22 02:09:46 2017 +0200
Commit: Michael Forney <mforney_AT_mforney.org>
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
_AT_@ -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 ; }
Received on Sat Nov 11 2017 - 04:29:43 CET
This archive was generated by hypermail 2.3.0
: Sat Nov 11 2017 - 04:36:23 CET