package/busybox: add upstream sed patch, bump release number
[openwrt.git] / package / busybox / patches / 000-upstream-sed.patch
1 diff -urpN busybox-1.16.1/editors/sed.c busybox-1.16.1-sed/editors/sed.c
2 --- busybox-1.16.1/editors/sed.c        2010-03-28 13:43:35.000000000 -0400
3 +++ busybox-1.16.1-sed/editors/sed.c    2010-04-20 13:33:26.301975462 -0400
4 @@ -936,7 +936,15 @@ static void process_files(void)
5                 /* Skip blocks of commands we didn't match */
6                 if (sed_cmd->cmd == '{') {
7                         if (sed_cmd->invert ? matched : !matched) {
8 -                               while (sed_cmd->cmd != '}') {
9 +                               unsigned nest_cnt = 0;
10 +                               while (1) {
11 +                                       if (sed_cmd->cmd == '{')
12 +                                               nest_cnt++;
13 +                                       if (sed_cmd->cmd == '}') {
14 +                                               nest_cnt--;
15 +                                               if (nest_cnt == 0)
16 +                                                       break;
17 +                                       }
18                                         sed_cmd = sed_cmd->next;
19                                         if (!sed_cmd)
20                                                 bb_error_msg_and_die("unterminated {");
21 @@ -1031,7 +1039,7 @@ static void process_files(void)
22                 case 'c':
23                         /* Only triggers on last line of a matching range. */
24                         if (!sed_cmd->in_match)
25 -                               sed_puts(sed_cmd->string, NO_EOL_CHAR);
26 +                               sed_puts(sed_cmd->string, '\n');
27                         goto discard_line;
28  
29                 /* Read file, append contents to output */
30 diff -urpN busybox-1.16.1/testsuite/sed.tests busybox-1.16.1-sed/testsuite/sed.tests
31 --- busybox-1.16.1/testsuite/sed.tests  2010-03-19 22:58:07.000000000 -0400
32 +++ busybox-1.16.1-sed/testsuite/sed.tests      2010-04-20 13:33:26.301975462 -0400
33 @@ -248,4 +248,14 @@ testing "sed beginning (^) matches only 
34         ">/usr</>lib<\n" "" \
35         "/usr/lib\n"
36  
37 +testing "sed c" \
38 +       "sed 'crepl'" \
39 +       "repl\nrepl\n" "" \
40 +       "first\nsecond\n"
41 +
42 +testing "sed nested {}s" \
43 +       "sed '/asd/ { p; /s/ { s/s/c/ }; p; q }'" \
44 +       "qwe\nasd\nacd\nacd\n" "" \
45 +       "qwe\nasd\nzxc\n"
46 +
47  exit $FAILCOUNT