diff options
| -rw-r--r-- | meta/recipes-core/busybox/busybox-1.21.1/busybox-sed-fix-sed-clusternewline-testcase.patch | 262 | ||||
| -rw-r--r-- | meta/recipes-core/busybox/busybox_1.21.1.bb | 4 |
2 files changed, 265 insertions, 1 deletions
diff --git a/meta/recipes-core/busybox/busybox-1.21.1/busybox-sed-fix-sed-clusternewline-testcase.patch b/meta/recipes-core/busybox/busybox-1.21.1/busybox-sed-fix-sed-clusternewline-testcase.patch new file mode 100644 index 0000000000..1894037422 --- /dev/null +++ b/meta/recipes-core/busybox/busybox-1.21.1/busybox-sed-fix-sed-clusternewline-testcase.patch | |||
| @@ -0,0 +1,262 @@ | |||
| 1 | From 6394bcf17925715db042cfb24f5886b1bed1dfc9 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Jackie Huang <jackie.huang@windriver.com> | ||
| 3 | Date: Thu, 31 Oct 2013 14:36:31 +0800 | ||
| 4 | Subject: [PATCH] sed: fix "sed clusternewline" and "autoinsert newline" testcase | ||
| 5 | |||
| 6 | Upstream-Status: Backport [busybox.net] | ||
| 7 | |||
| 8 | Signed-off-by: Jackie Huang <jackie.huang@windriver.com> | ||
| 9 | --- | ||
| 10 | editors/sed.c | 135 ++++++++++++++++++++++++++-------------------------- | ||
| 11 | testsuite/sed.tests | 4 -- | ||
| 12 | 2 files changed, 68 insertions(+), 71 deletions(-) | ||
| 13 | |||
| 14 | diff --git a/editors/sed.c b/editors/sed.c | ||
| 15 | index f8ca5d3..98478b4 100644 | ||
| 16 | --- a/editors/sed.c | ||
| 17 | +++ b/editors/sed.c | ||
| 18 | @@ -845,37 +845,79 @@ static void append(char *s) | ||
| 19 | llist_add_to_end(&G.append_head, xstrdup(s)); | ||
| 20 | } | ||
| 21 | |||
| 22 | -static void flush_append(void) | ||
| 23 | +/* Output line of text. */ | ||
| 24 | +/* Note: | ||
| 25 | + * The tricks with NO_EOL_CHAR and last_puts_char are there to emulate gnu sed. | ||
| 26 | + * Without them, we had this: | ||
| 27 | + * echo -n thingy >z1 | ||
| 28 | + * echo -n again >z2 | ||
| 29 | + * >znull | ||
| 30 | + * sed "s/i/z/" z1 z2 znull | hexdump -vC | ||
| 31 | + * output: | ||
| 32 | + * gnu sed 4.1.5: | ||
| 33 | + * 00000000 74 68 7a 6e 67 79 0a 61 67 61 7a 6e |thzngy.agazn| | ||
| 34 | + * bbox: | ||
| 35 | + * 00000000 74 68 7a 6e 67 79 61 67 61 7a 6e |thzngyagazn| | ||
| 36 | + */ | ||
| 37 | +enum { | ||
| 38 | + NO_EOL_CHAR = 1, | ||
| 39 | + LAST_IS_NUL = 2, | ||
| 40 | +}; | ||
| 41 | +static void puts_maybe_newline(char *s, FILE *file, char *last_puts_char, char last_gets_char) | ||
| 42 | +{ | ||
| 43 | + char lpc = *last_puts_char; | ||
| 44 | + | ||
| 45 | + /* Need to insert a '\n' between two files because first file's | ||
| 46 | + * last line wasn't terminated? */ | ||
| 47 | + if (lpc != '\n' && lpc != '\0') { | ||
| 48 | + fputc('\n', file); | ||
| 49 | + lpc = '\n'; | ||
| 50 | + } | ||
| 51 | + fputs(s, file); | ||
| 52 | + | ||
| 53 | + /* 'x' - just something which is not '\n', '\0' or NO_EOL_CHAR */ | ||
| 54 | + if (s[0]) | ||
| 55 | + lpc = 'x'; | ||
| 56 | + | ||
| 57 | + /* had trailing '\0' and it was last char of file? */ | ||
| 58 | + if (last_gets_char == LAST_IS_NUL) { | ||
| 59 | + fputc('\0', file); | ||
| 60 | + lpc = 'x'; /* */ | ||
| 61 | + } else | ||
| 62 | + /* had trailing '\n' or '\0'? */ | ||
| 63 | + if (last_gets_char != NO_EOL_CHAR) { | ||
| 64 | + fputc(last_gets_char, file); | ||
| 65 | + lpc = last_gets_char; | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + if (ferror(file)) { | ||
| 69 | + xfunc_error_retval = 4; /* It's what gnu sed exits with... */ | ||
| 70 | + bb_error_msg_and_die(bb_msg_write_error); | ||
| 71 | + } | ||
| 72 | + *last_puts_char = lpc; | ||
| 73 | +} | ||
| 74 | + | ||
| 75 | +static void flush_append(char *last_puts_char, char last_gets_char) | ||
| 76 | { | ||
| 77 | char *data; | ||
| 78 | |||
| 79 | /* Output appended lines. */ | ||
| 80 | while ((data = (char *)llist_pop(&G.append_head))) { | ||
| 81 | - fprintf(G.nonstdout, "%s\n", data); | ||
| 82 | + puts_maybe_newline(data, G.nonstdout, last_puts_char, last_gets_char); | ||
| 83 | free(data); | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 87 | -static void add_input_file(FILE *file) | ||
| 88 | -{ | ||
| 89 | - G.input_file_list = xrealloc_vector(G.input_file_list, 2, G.input_file_count); | ||
| 90 | - G.input_file_list[G.input_file_count++] = file; | ||
| 91 | -} | ||
| 92 | - | ||
| 93 | /* Get next line of input from G.input_file_list, flushing append buffer and | ||
| 94 | * noting if we ran out of files without a newline on the last line we read. | ||
| 95 | */ | ||
| 96 | -enum { | ||
| 97 | - NO_EOL_CHAR = 1, | ||
| 98 | - LAST_IS_NUL = 2, | ||
| 99 | -}; | ||
| 100 | -static char *get_next_line(char *gets_char) | ||
| 101 | +static char *get_next_line(char *gets_char, char *last_puts_char, char last_gets_char) | ||
| 102 | { | ||
| 103 | char *temp = NULL; | ||
| 104 | int len; | ||
| 105 | char gc; | ||
| 106 | |||
| 107 | - flush_append(); | ||
| 108 | + flush_append(last_puts_char, last_gets_char); | ||
| 109 | |||
| 110 | /* will be returned if last line in the file | ||
| 111 | * doesn't end with either '\n' or '\0' */ | ||
| 112 | @@ -919,54 +961,6 @@ static char *get_next_line(char *gets_char) | ||
| 113 | return temp; | ||
| 114 | } | ||
| 115 | |||
| 116 | -/* Output line of text. */ | ||
| 117 | -/* Note: | ||
| 118 | - * The tricks with NO_EOL_CHAR and last_puts_char are there to emulate gnu sed. | ||
| 119 | - * Without them, we had this: | ||
| 120 | - * echo -n thingy >z1 | ||
| 121 | - * echo -n again >z2 | ||
| 122 | - * >znull | ||
| 123 | - * sed "s/i/z/" z1 z2 znull | hexdump -vC | ||
| 124 | - * output: | ||
| 125 | - * gnu sed 4.1.5: | ||
| 126 | - * 00000000 74 68 7a 6e 67 79 0a 61 67 61 7a 6e |thzngy.agazn| | ||
| 127 | - * bbox: | ||
| 128 | - * 00000000 74 68 7a 6e 67 79 61 67 61 7a 6e |thzngyagazn| | ||
| 129 | - */ | ||
| 130 | -static void puts_maybe_newline(char *s, FILE *file, char *last_puts_char, char last_gets_char) | ||
| 131 | -{ | ||
| 132 | - char lpc = *last_puts_char; | ||
| 133 | - | ||
| 134 | - /* Need to insert a '\n' between two files because first file's | ||
| 135 | - * last line wasn't terminated? */ | ||
| 136 | - if (lpc != '\n' && lpc != '\0') { | ||
| 137 | - fputc('\n', file); | ||
| 138 | - lpc = '\n'; | ||
| 139 | - } | ||
| 140 | - fputs(s, file); | ||
| 141 | - | ||
| 142 | - /* 'x' - just something which is not '\n', '\0' or NO_EOL_CHAR */ | ||
| 143 | - if (s[0]) | ||
| 144 | - lpc = 'x'; | ||
| 145 | - | ||
| 146 | - /* had trailing '\0' and it was last char of file? */ | ||
| 147 | - if (last_gets_char == LAST_IS_NUL) { | ||
| 148 | - fputc('\0', file); | ||
| 149 | - lpc = 'x'; /* */ | ||
| 150 | - } else | ||
| 151 | - /* had trailing '\n' or '\0'? */ | ||
| 152 | - if (last_gets_char != NO_EOL_CHAR) { | ||
| 153 | - fputc(last_gets_char, file); | ||
| 154 | - lpc = last_gets_char; | ||
| 155 | - } | ||
| 156 | - | ||
| 157 | - if (ferror(file)) { | ||
| 158 | - xfunc_error_retval = 4; /* It's what gnu sed exits with... */ | ||
| 159 | - bb_error_msg_and_die(bb_msg_write_error); | ||
| 160 | - } | ||
| 161 | - *last_puts_char = lpc; | ||
| 162 | -} | ||
| 163 | - | ||
| 164 | #define sed_puts(s, n) (puts_maybe_newline(s, G.nonstdout, &last_puts_char, n)) | ||
| 165 | |||
| 166 | static int beg_match(sed_cmd_t *sed_cmd, const char *pattern_space) | ||
| 167 | @@ -989,7 +983,7 @@ static void process_files(void) | ||
| 168 | int substituted; | ||
| 169 | |||
| 170 | /* Prime the pump */ | ||
| 171 | - next_line = get_next_line(&next_gets_char); | ||
| 172 | + next_line = get_next_line(&next_gets_char, &last_puts_char, '\n' /*last_gets_char*/); | ||
| 173 | |||
| 174 | /* Go through every line in each file */ | ||
| 175 | again: | ||
| 176 | @@ -1003,7 +997,7 @@ static void process_files(void) | ||
| 177 | |||
| 178 | /* Read one line in advance so we can act on the last line, | ||
| 179 | * the '$' address */ | ||
| 180 | - next_line = get_next_line(&next_gets_char); | ||
| 181 | + next_line = get_next_line(&next_gets_char, &last_puts_char, last_gets_char); | ||
| 182 | linenum++; | ||
| 183 | |||
| 184 | /* For every line, go through all the commands */ | ||
| 185 | @@ -1176,6 +1170,7 @@ static void process_files(void) | ||
| 186 | /* Append line to linked list to be printed later */ | ||
| 187 | case 'a': | ||
| 188 | append(sed_cmd->string); | ||
| 189 | + last_gets_char = '\n'; | ||
| 190 | break; | ||
| 191 | |||
| 192 | /* Insert text before this line */ | ||
| 193 | @@ -1222,7 +1217,7 @@ static void process_files(void) | ||
| 194 | free(pattern_space); | ||
| 195 | pattern_space = next_line; | ||
| 196 | last_gets_char = next_gets_char; | ||
| 197 | - next_line = get_next_line(&next_gets_char); | ||
| 198 | + next_line = get_next_line(&next_gets_char, &last_puts_char, last_gets_char); | ||
| 199 | substituted = 0; | ||
| 200 | linenum++; | ||
| 201 | break; | ||
| 202 | @@ -1258,7 +1253,7 @@ static void process_files(void) | ||
| 203 | pattern_space[len] = '\n'; | ||
| 204 | strcpy(pattern_space + len+1, next_line); | ||
| 205 | last_gets_char = next_gets_char; | ||
| 206 | - next_line = get_next_line(&next_gets_char); | ||
| 207 | + next_line = get_next_line(&next_gets_char, &last_puts_char, last_gets_char); | ||
| 208 | linenum++; | ||
| 209 | break; | ||
| 210 | } | ||
| 211 | @@ -1362,7 +1357,7 @@ static void process_files(void) | ||
| 212 | |||
| 213 | /* Delete and such jump here. */ | ||
| 214 | discard_line: | ||
| 215 | - flush_append(); | ||
| 216 | + flush_append(&last_puts_char, last_gets_char); | ||
| 217 | free(pattern_space); | ||
| 218 | |||
| 219 | goto again; | ||
| 220 | @@ -1403,6 +1398,12 @@ static void add_cmd_block(char *cmdstr) | ||
| 221 | free(sv); | ||
| 222 | } | ||
| 223 | |||
| 224 | +static void add_input_file(FILE *file) | ||
| 225 | +{ | ||
| 226 | + G.input_file_list = xrealloc_vector(G.input_file_list, 2, G.input_file_count); | ||
| 227 | + G.input_file_list[G.input_file_count++] = file; | ||
| 228 | +} | ||
| 229 | + | ||
| 230 | int sed_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | ||
| 231 | int sed_main(int argc UNUSED_PARAM, char **argv) | ||
| 232 | { | ||
| 233 | diff --git a/testsuite/sed.tests b/testsuite/sed.tests | ||
| 234 | index 468565f..e26483c 100755 | ||
| 235 | --- a/testsuite/sed.tests | ||
| 236 | +++ b/testsuite/sed.tests | ||
| 237 | @@ -135,10 +135,8 @@ testing "sed empty file plus cat" "sed -e 's/nohit//' input -" "one\ntwo" \ | ||
| 238 | "" "one\ntwo" | ||
| 239 | testing "sed cat plus empty file" "sed -e 's/nohit//' input -" "one\ntwo" \ | ||
| 240 | "one\ntwo" "" | ||
| 241 | -test x"$SKIP_KNOWN_BUGS" = x"" && { | ||
| 242 | testing "sed append autoinserts newline" "sed -e '/woot/a woo' -" \ | ||
| 243 | "woot\nwoo\n" "" "woot" | ||
| 244 | -} | ||
| 245 | testing "sed insert doesn't autoinsert newline" "sed -e '/woot/i woo' -" \ | ||
| 246 | "woo\nwoot" "" "woot" | ||
| 247 | testing "sed print autoinsert newlines" "sed -e 'p' -" "one\none" "" "one" | ||
| 248 | @@ -154,11 +152,9 @@ testing "sed selective matches insert newline" \ | ||
| 249 | testing "sed selective matches noinsert newline" \ | ||
| 250 | "sed -ne 's/woo/bang/p' input -" "a bang\nb bang" "a woo\nb woo" \ | ||
| 251 | "c no\nd no" | ||
| 252 | -test x"$SKIP_KNOWN_BUGS" = x"" && { | ||
| 253 | testing "sed clusternewline" \ | ||
| 254 | "sed -e '/one/a 111' -e '/two/i 222' -e p input -" \ | ||
| 255 | "one\none\n111\n222\ntwo\ntwo" "one" "two" | ||
| 256 | -} | ||
| 257 | testing "sed subst+write" \ | ||
| 258 | "sed -e 's/i/z/' -e 'woutputw' input -; $ECHO -n X; cat outputw" \ | ||
| 259 | "thzngy\nagaznXthzngy\nagazn" "thingy" "again" | ||
| 260 | -- | ||
| 261 | 1.8.3 | ||
| 262 | |||
diff --git a/meta/recipes-core/busybox/busybox_1.21.1.bb b/meta/recipes-core/busybox/busybox_1.21.1.bb index 85d3208974..8b91e6329d 100644 --- a/meta/recipes-core/busybox/busybox_1.21.1.bb +++ b/meta/recipes-core/busybox/busybox_1.21.1.bb | |||
| @@ -32,7 +32,9 @@ SRC_URI = "http://www.busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \ | |||
| 32 | file://inetd.conf \ | 32 | file://inetd.conf \ |
| 33 | file://inetd \ | 33 | file://inetd \ |
| 34 | file://login-utilities.cfg \ | 34 | file://login-utilities.cfg \ |
| 35 | file://busybox-list-suid-and-non-suid-app-configs.patch" | 35 | file://busybox-list-suid-and-non-suid-app-configs.patch \ |
| 36 | file://busybox-sed-fix-sed-clusternewline-testcase.patch \ | ||
| 37 | " | ||
| 36 | 38 | ||
| 37 | SRC_URI[tarball.md5sum] = "795394f83903b5eec6567d51eebb417e" | 39 | SRC_URI[tarball.md5sum] = "795394f83903b5eec6567d51eebb417e" |
| 38 | SRC_URI[tarball.sha256sum] = "cd5be0912ec856110ae12c76c3ec9cd5cba1df45b5a9da2b095b8284d1481303" | 40 | SRC_URI[tarball.sha256sum] = "cd5be0912ec856110ae12c76c3ec9cd5cba1df45b5a9da2b095b8284d1481303" |
