aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-04-20 04:00:03 -0400
committerDenys Vlasenko <vda.linux@googlemail.com>2010-04-20 04:00:03 -0400
commitf2c16edf99486a0ce2ca57f111831668e77d0fd1 (patch)
tree67789d2c4afa727c52db4573b26b50d6c5253ac5 /editors
parent96a18332316568ebccaa186ffb519b48c4310714 (diff)
downloadbusybox-w32-f2c16edf99486a0ce2ca57f111831668e77d0fd1.tar.gz
busybox-w32-f2c16edf99486a0ce2ca57f111831668e77d0fd1.tar.bz2
busybox-w32-f2c16edf99486a0ce2ca57f111831668e77d0fd1.zip
sed: fix nested {} case
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors')
-rw-r--r--editors/sed.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/editors/sed.c b/editors/sed.c
index 302a15605..30ab8c9fb 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -936,7 +936,15 @@ static void process_files(void)
936 /* Skip blocks of commands we didn't match */ 936 /* Skip blocks of commands we didn't match */
937 if (sed_cmd->cmd == '{') { 937 if (sed_cmd->cmd == '{') {
938 if (sed_cmd->invert ? matched : !matched) { 938 if (sed_cmd->invert ? matched : !matched) {
939 while (sed_cmd->cmd != '}') { 939 unsigned nest_cnt = 0;
940 while (1) {
941 if (sed_cmd->cmd == '{')
942 nest_cnt++;
943 if (sed_cmd->cmd == '}') {
944 nest_cnt--;
945 if (nest_cnt == 0)
946 break;
947 }
940 sed_cmd = sed_cmd->next; 948 sed_cmd = sed_cmd->next;
941 if (!sed_cmd) 949 if (!sed_cmd)
942 bb_error_msg_and_die("unterminated {"); 950 bb_error_msg_and_die("unterminated {");