in GNU sed, `echo foo | sed -e '/bar/{b};d'` is valid, but in busybox
sed would fail with unmatched {.

Signed-off-by: Jeremy Drake <[email protected]>
---
In strict posix, not even semicolon terminates a label, but busybox seems
to mostly follow GNU.

I'm not sure about the 'style' of this fix, there might be a more
idiomatic way to do this.

 editors/sed.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/editors/sed.c b/editors/sed.c
index de411fbf4..6563c270c 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -133,7 +133,7 @@ typedef struct sed_cmd_s {
        char cmd;               /* The command char: abcdDgGhHilnNpPqrstwxy:={} 
*/
 } sed_cmd_t;

-static const char semicolon_whitespace[] ALIGN1 = "; \n\r\t\v";
+#define semicolon_whitespace "; \n\r\t\v"

 struct globals {
        /* options */
@@ -613,7 +613,7 @@ static const char *parse_cmd_args(sed_cmd_t *sed_cmd, const 
char *cmdstr)
                int length;

                cmdstr = skip_whitespace(cmdstr);
-               length = strcspn(cmdstr, semicolon_whitespace);
+               length = strcspn(cmdstr, semicolon_whitespace "}");
                if (length) {
                        sed_cmd->string = xstrndup(cmdstr, length);
                        cmdstr += length;
-- 
2.48.1.windows.1

_______________________________________________
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox

Reply via email to