diff options
author | Denys Vlasenko | 2010-04-20 04:00:03 -0400 |
---|---|---|
committer | Denys Vlasenko | 2010-04-20 04:00:03 -0400 |
commit | f2c16edf99486a0ce2ca57f111831668e77d0fd1 (patch) | |
tree | 67789d2c4afa727c52db4573b26b50d6c5253ac5 /editors/sed.c | |
parent | 96a18332316568ebccaa186ffb519b48c4310714 (diff) | |
download | busybox-f2c16edf99486a0ce2ca57f111831668e77d0fd1.zip busybox-f2c16edf99486a0ce2ca57f111831668e77d0fd1.tar.gz |
sed: fix nested {} case
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors/sed.c')
-rw-r--r-- | editors/sed.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/editors/sed.c b/editors/sed.c index 302a156..30ab8c9 100644 --- a/editors/sed.c +++ b/editors/sed.c @@ -936,7 +936,15 @@ static void process_files(void) /* Skip blocks of commands we didn't match */ if (sed_cmd->cmd == '{') { if (sed_cmd->invert ? matched : !matched) { - while (sed_cmd->cmd != '}') { + unsigned nest_cnt = 0; + while (1) { + if (sed_cmd->cmd == '{') + nest_cnt++; + if (sed_cmd->cmd == '}') { + nest_cnt--; + if (nest_cnt == 0) + break; + } sed_cmd = sed_cmd->next; if (!sed_cmd) bb_error_msg_and_die("unterminated {"); |