summaryrefslogtreecommitdiffstats
path: root/main/busybox
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2009-08-17 07:05:50 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2009-08-17 07:05:50 +0000
commit299cbbf9570c47636c7b122b59e8791253f77898 (patch)
tree7668476683869151dd8615ece64e6653a5087ad5 /main/busybox
parent7e3b2cc9e568654a69a3bc2fa72cfba2bd6eca8d (diff)
downloadaports-299cbbf9570c47636c7b122b59e8791253f77898.tar.bz2
aports-299cbbf9570c47636c7b122b59e8791253f77898.tar.xz
main/busybox: sed fix
Diffstat (limited to 'main/busybox')
-rw-r--r--main/busybox/APKBUILD4
-rw-r--r--main/busybox/busybox-sed-3.patch120
2 files changed, 123 insertions, 1 deletions
diff --git a/main/busybox/APKBUILD b/main/busybox/APKBUILD
index d5e7a5b5..1ec62774 100644
--- a/main/busybox/APKBUILD
+++ b/main/busybox/APKBUILD
@@ -1,7 +1,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=busybox
pkgver=1.14.3
-pkgrel=1
+pkgrel=2
pkgdesc="Size optimized toolbox of many common UNIX utilities"
url=http://busybox.net
license="GPL-2"
@@ -12,6 +12,7 @@ source="http://busybox.net/downloads/$pkgname-$pkgver.tar.bz2
$pkgname-1.11.1-bb.patch
0001-install-compat-fix-for-mode-of-created-files.patch
bb-tar-numeric-owner.patch
+ busybox-sed-3.patch
busyboxconfig"
build() {
@@ -48,4 +49,5 @@ md5sums="d170bf5f97a41aec3a505eab690d5699 busybox-1.14.3.tar.bz2
4c0f3b486eaa0674961b7ddcd0c60a9b busybox-1.11.1-bb.patch
73d39c57483084298c7e46bdbbbea8d1 0001-install-compat-fix-for-mode-of-created-files.patch
0b5b2d7db201f90cd08f4a3164ee29a1 bb-tar-numeric-owner.patch
+b75c3f419f8392dfdadd92aa24fdba8c busybox-sed-3.patch
0be49dc673a849b5bf5e670db8c8c7b6 busyboxconfig"
diff --git a/main/busybox/busybox-sed-3.patch b/main/busybox/busybox-sed-3.patch
new file mode 100644
index 00000000..f916ce29
--- /dev/null
+++ b/main/busybox/busybox-sed-3.patch
@@ -0,0 +1,120 @@
+diff -d -urpN busybox.2/editors/sed.c busybox.3/editors/sed.c
+--- busybox.2/editors/sed.c 2009-08-08 01:40:42.000000000 +0200
++++ busybox.3/editors/sed.c 2009-08-17 01:32:00.000000000 +0200
+@@ -589,7 +589,7 @@ static void pipe_putc(char c)
+
+ static void do_subst_w_backrefs(char *line, char *replace)
+ {
+- int i,j;
++ int i, j;
+
+ /* go through the replacement string */
+ for (i = 0; replace[i]; i++) {
+@@ -624,23 +624,24 @@ static void do_subst_w_backrefs(char *li
+ }
+ }
+
+-static int do_subst_command(sed_cmd_t *sed_cmd, char **line)
++static int do_subst_command(sed_cmd_t *sed_cmd, char **line_p)
+ {
+- char *oldline = *line;
++ char *line = *line_p;
+ int altered = 0;
+ unsigned match_count = 0;
+ regex_t *current_regex;
+
++ current_regex = sed_cmd->sub_match;
+ /* Handle empty regex. */
+- if (sed_cmd->sub_match == NULL) {
++ if (!current_regex) {
+ current_regex = G.previous_regex_ptr;
+ if (!current_regex)
+ bb_error_msg_and_die("no previous regexp");
+- } else
+- G.previous_regex_ptr = current_regex = sed_cmd->sub_match;
++ }
++ G.previous_regex_ptr = current_regex;
+
+ /* Find the first match */
+- if (REG_NOMATCH == regexec(current_regex, oldline, 10, G.regmatch, 0))
++ if (REG_NOMATCH == regexec(current_regex, line, 10, G.regmatch, 0))
+ return 0;
+
+ /* Initialize temporary output buffer. */
+@@ -657,7 +658,7 @@ static int do_subst_command(sed_cmd_t *s
+ The match_count check is so not to break
+ echo "hi" | busybox sed 's/^/!/g' */
+ if (!G.regmatch[0].rm_so && !G.regmatch[0].rm_eo && match_count) {
+- pipe_putc(*oldline++);
++ pipe_putc(*line++);
+ continue;
+ }
+
+@@ -669,35 +670,41 @@ static int do_subst_command(sed_cmd_t *s
+ && (sed_cmd->which_match != match_count)
+ ) {
+ for (i = 0; i < G.regmatch[0].rm_eo; i++)
+- pipe_putc(*oldline++);
++ pipe_putc(*line++);
+ continue;
+ }
+
+ /* print everything before the match */
+ for (i = 0; i < G.regmatch[0].rm_so; i++)
+- pipe_putc(oldline[i]);
++ pipe_putc(line[i]);
+
+ /* then print the substitution string */
+- do_subst_w_backrefs(oldline, sed_cmd->string);
++ do_subst_w_backrefs(line, sed_cmd->string);
+
+ /* advance past the match */
+- oldline += G.regmatch[0].rm_eo;
++ line += G.regmatch[0].rm_eo;
+ /* flag that something has changed */
+ altered++;
+
+ /* if we're not doing this globally, get out now */
+ if (sed_cmd->which_match)
+ break;
+- } while (*oldline && (regexec(current_regex, oldline, 10, G.regmatch, 0) != REG_NOMATCH));
+
+- /* Copy rest of string into output pipeline */
++ if (*line == '\0')
++ break;
++//maybe (G.regmatch[0].rm_eo ? REG_NOTBOL : 0) instead of unconditional REG_NOTBOL?
++ } while (regexec(current_regex, line, 10, G.regmatch, REG_NOTBOL) != REG_NOMATCH);
+
+- while (*oldline)
+- pipe_putc(*oldline++);
+- pipe_putc(0);
++ /* Copy rest of string into output pipeline */
++ while (1) {
++ char c = *line++;
++ pipe_putc(c);
++ if (c == '\0')
++ break;
++ }
+
+- free(*line);
+- *line = G.pipeline.buf;
++ free(*line_p);
++ *line_p = G.pipeline.buf;
+ return altered;
+ }
+
+diff -d -urpN busybox.2/testsuite/sed.tests busybox.3/testsuite/sed.tests
+--- busybox.2/testsuite/sed.tests 2009-08-08 01:40:44.000000000 +0200
++++ busybox.3/testsuite/sed.tests 2009-08-17 01:29:01.000000000 +0200
+@@ -241,4 +241,11 @@ testing "sed 2d;2,1p (gnu compat)" \
+ "third\n" "" \
+ "first\nsecond\nthird\nfourth\n"
+
++# Regex means: "match / at BOL or nothing, then one or more not-slashes".
++# The bug was that second slash in /usr/lib was treated as "at BOL" too.
++testing "sed beginning (^) matches only once" \
++ "sed 's,\(^/\|\)[^/][^/]*,>\0<,g'" \
++ ">/usr</>lib<\n" "" \
++ "/usr/lib\n"
++
+ exit $FAILCOUNT