summaryrefslogtreecommitdiff
path: root/sys-apps/sed
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /sys-apps/sed
reinit the tree, so we can have metadata
Diffstat (limited to 'sys-apps/sed')
-rw-r--r--sys-apps/sed/Manifest13
-rw-r--r--sys-apps/sed/files/sed-4.1.5-alloca.patch14
-rw-r--r--sys-apps/sed/files/sed-4.3-dfa-segv-1.patch175
-rw-r--r--sys-apps/sed/files/sed-4.3-dfa-segv-2.patch112
-rw-r--r--sys-apps/sed/files/sed-4.3-dfa-segv-3.patch146
-rw-r--r--sys-apps/sed/metadata.xml11
-rw-r--r--sys-apps/sed/sed-4.2.2.ebuild63
-rw-r--r--sys-apps/sed/sed-4.3-r1.ebuild62
-rw-r--r--sys-apps/sed/sed-4.4.ebuild61
9 files changed, 657 insertions, 0 deletions
diff --git a/sys-apps/sed/Manifest b/sys-apps/sed/Manifest
new file mode 100644
index 000000000000..3d7c66a28771
--- /dev/null
+++ b/sys-apps/sed/Manifest
@@ -0,0 +1,13 @@
+AUX sed-4.1.5-alloca.patch 413 SHA256 9b371d7e3db5f6955536b4c4a23739b7d84448b9865046f0cc3bd3903a04009a SHA512 dccdad774cbf1eb71744b9d1a49ce45e6c6197ffed66448b6de9302dc88d46246b52a6cbed95a5b86511f19a735a710af177003732d54ca01baa84ef21734d29 WHIRLPOOL a7c81b9229bb62946618053993c35db26a7f06d03880a499916aed28fcab9308b7038f6a90ba84e2f86caaef0383cf8daf59d5759f5de0c6b840f9cbbc6561b3
+AUX sed-4.3-dfa-segv-1.patch 6180 SHA256 08c109a3deaee657b7c0aaffc4ebc74d8b1ee592a28a6e848c6f06b3d1fcd994 SHA512 467a36bc863ee2bed90b8e87f0023b67615c606dea4376bc8da72356f13871a51f82e73965f1f17975d76b7768dfe20ad2d4b7373a2c208257981d8235b61e7b WHIRLPOOL 1b0df74d07893e7666f19ddbadb666b7821d31aa37fca6381e04303b25d78f894aba7ed7e19d1d422ba779e528e8ff91a1fbba7965f4f23f353fd9a524f7d7f3
+AUX sed-4.3-dfa-segv-2.patch 3797 SHA256 b0aa5ec7815a7f0102330f9d154e2a4b9bf77c73f85fa692aab204ed7f832470 SHA512 d346f71e4899d5bde9127f86428a8ab1ee149aee28247e6e04ff940eb9ee90392f81d3d61b525cef5f1c3e871ee4295b4168edcd00d802edfc3f8a2725a39072 WHIRLPOOL 8ab3a8c3d469593bd91739d85defd9eca44610e24d75171e038da01bcc829c93c3b014897ae8035b436bffc807b497eb1f5401c14ade7f9fc1021972f365613b
+AUX sed-4.3-dfa-segv-3.patch 5334 SHA256 cfed3226c7b487a3ecd0dd10605d271f3569764645b78c9911af359bb3c7f1bb SHA512 270a4917addf899d03b32fe544816d2132063ca113229cd1b5b72dacd1ebb6f087fea5cc362ceda3237966074cf542883f12e3f1d2da4b045a7f158f50017ccb WHIRLPOOL 0474a41c42cfb414534b793289d76d3023f3281f616dfdfed49a43e0d204789217df0ad986762b233b32937693c0a6899c37892a51b5533b727dcf7b66decaed
+DIST sed-4.2.2.tar.bz2 1059414 SHA256 f048d1838da284c8bc9753e4506b85a1e0cc1ea8999d36f6995bcb9460cddbd7 SHA512 dbbb0bb348fac54612d29182c09c88bda7096dea03bd94f03c580c24146e65a06db12808c6a1a9adc94548fa3843511e3e80b251cb07142110cf149eab23f573 WHIRLPOOL d816657c51a2718c2b309455facaff50c9da08b79d20985ab1d61faa5b42bffa0b33ea7d3368a8cdaa6079891cfc27cdab38788563c8323081580b4478c7e2b5
+DIST sed-4.3.tar.xz 1167168 SHA256 47c20d8841ce9e7b6ef8037768aac44bc2937fff1c265b291c824004d56bd0aa SHA512 4d76a099cf7115763b79b45be5c96338750baa47e34c36075f714e022614397aa9240099d6d009e69aa4d06b6cfc14dcc0f8313442a1465f448b36fb6874a26d WHIRLPOOL dc8ea635d7cd30fa73b163078ed7e48d3f85aaf37041b432f3c1579d556a41cb0afa2c8468f67a4474d7274578850b698b60933f6b4b3d041ee4f77ace344035
+DIST sed-4.4.tar.xz 1181664 SHA256 cbd6ebc5aaf080ed60d0162d7f6aeae58211a1ee9ba9bb25623daa6cd942683b SHA512 4e1b0a7403913f1e25047eb2292a0a9b3488b15b4463ce2803e05eaecbc2da19f477a18e6a70c992461c38ced90774415091aa2d8ce85cb74e391610d9eedb70 WHIRLPOOL 2437887adb4ec36ea884b319e6cfd16eed9890277665989aecd3726eea98cf3bf403c04c60a02700b7b4968018cfe48296d82b169317d354cee620bce70b5ec9
+EBUILD sed-4.2.2.ebuild 1715 SHA256 c596074758c3146f176b586352c5fe0f6f1c8af8499a484dfaf0f9ea5cb1c769 SHA512 512f3f3da20b8f556c9d0c65ff31a8c6876bc22f4075831dd3d147d856232f8e97293119dceec902534bc74478e4aaa83bcc0ef87737ae98879beb18bfdb82ae WHIRLPOOL 65f963489396743a8ef106854a488516cc4d9c77065d5d1c81d9ad058afb003323d18d744aa8476bfb273a35c5a0102b369016ad9334e49374429205c2b81fe6
+EBUILD sed-4.3-r1.ebuild 1483 SHA256 8f245bb552fd6e17b1ca417963f4238e88dbc16f706d648c774c9f9952ee396b SHA512 df98241b8a8f1b1d2bd2ba906fba4ae23d8fd3d1a4a09a129fde9f07261f306863078d27daee401085500be15536b1d87724c75d8382bae7673d6b3d0f75b7a5 WHIRLPOOL 990b196d433a0b28d56014e5b296fd6468b69cfc8df595c7d69bf69bd27d40695227f43dacf0395b77bb03a72c110e01e002077fd35cdaad8bcd1c03ba494e56
+EBUILD sed-4.4.ebuild 1443 SHA256 5f8327a368a5832854b89c69c80155ce6a1bf9b2e4d91f46d10ad49568c56a6e SHA512 cb5a40e371063b96b4c7f514944f8da502a83a526718214bf296a62dc1870def5074a1d91d99679011c2ea1619b85b3049f5ee6c77cf1ab911101b7c839bcfaa WHIRLPOOL 295b3365e98212bfdd91c3e0fe3dfe34b951585368a7e3e9baf9ff698515f64916232f560f0afc2b2ba24136b6e9b47fb77beedd86318417cccb219ccb28eba0
+MISC ChangeLog 4136 SHA256 3679cc29efbbc5e3171afd37fcb9fd6389941e57a8f3ee4bd3d4286d7168de34 SHA512 99db0b0302479b429d41184a5e6a146ad2eff5ded383073f7c100b2bc8ff5f3c73701cea8e62fd3c71e2f67076ffdd97e4f500a4ac356f9b8c0cf9f8b6b558aa WHIRLPOOL c8402c0bef4e4014364aca64ff79cfe4bb2a4ac898ef248bc8849737619dd6998575e828c88a9827cdc671a347141f40d930238ed0710bf627468ade040aa777
+MISC ChangeLog-2015 16503 SHA256 4ea4cf5813c3e62b75043c34314486e774f96cab7bffb94e11a90303f9140f82 SHA512 40c7fcca90187b31b54045a09fdc7ea6b8581ec37f88eb05e3df41ecb2d49d2ddffab1c84c0faacfae5151a148ee2d22d51acd3629225aa64b6596f401a8a669 WHIRLPOOL 5e9ba487e404f2be4cb200b8dc4e870e9846e4752b4bca683bad1fac63af55a582bfbcd001e9b7254320cdcc8ca88ef2ab2d3cb29fc28f39a93943bb8d298f7b
+MISC metadata.xml 323 SHA256 4574efa0a4c0db71c699957b59632b3212209a654e0bbcee1d6448b0b16074c5 SHA512 ec3a11f7aafded3d4b5e12680358f39dbeb166f96af51eae8dafb21b186024ddb9b5b9ba36bde626be01b1938fd6f4bbcb58f0f8bad2208a84d44eaadc95652e WHIRLPOOL d00ccb5adec759d4fb86b9e919d7f2a942edcf455b2e6681f4b299448396127a39b8f81e690bd873f678452ebcaf90e8a76c3789db7cc4269f4da303c15201be
diff --git a/sys-apps/sed/files/sed-4.1.5-alloca.patch b/sys-apps/sed/files/sed-4.1.5-alloca.patch
new file mode 100644
index 000000000000..89679c5362e3
--- /dev/null
+++ b/sys-apps/sed/files/sed-4.1.5-alloca.patch
@@ -0,0 +1,14 @@
+fix building on BSD systems which often do not have alloca.h
+
+--- sed-4.1.5/lib/regex_internal.h
++++ sed-4.1.5/lib/regex_internal.h
+@@ -410,7 +410,9 @@ static unsigned int re_string_context_at
+ #define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx))
+ #define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx))
+
++#ifdef HAVE_ALLOCA_H
+ #include <alloca.h>
++#endif
+
+ #ifndef _LIBC
+ # if HAVE_ALLOCA
diff --git a/sys-apps/sed/files/sed-4.3-dfa-segv-1.patch b/sys-apps/sed/files/sed-4.3-dfa-segv-1.patch
new file mode 100644
index 000000000000..f82adc712533
--- /dev/null
+++ b/sys-apps/sed/files/sed-4.3-dfa-segv-1.patch
@@ -0,0 +1,175 @@
+fix from upstream gnulib (fudged to apply to sed-4.3)
+
+From 823b5cb589366f7c8742503af980803afad0978f Mon Sep 17 00:00:00 2001
+From: Paul Eggert <eggert@cs.ucla.edu>
+Date: Sun, 8 Jan 2017 12:44:29 -0800
+Subject: [PATCH] dfa: fix reallocation bug when matching newlines
+
+Problem reported for sed by S. Gilles (Bug#25390).
+* lib/dfa.c (realloc_trans_if_necessary): Move earlier.
+(dfastate): Reallocate before moving any newline transition ...
+(build_state): ... instead of reallocating here, where it is too late.
+---
+ ChangeLog | 8 +++++
+ lib/dfa.c | 114 ++++++++++++++++++++++++++++++--------------------------------
+ 2 files changed, 63 insertions(+), 59 deletions(-)
+
+diff --git a/lib/dfa.c b/lib/dfa.c
+index 8276db160a4b..141888a978fa 100644
+--- a/lib/dfa.c
++++ b/lib/dfa.c
+@@ -2574,6 +2574,40 @@ dfaanalyze (struct dfa *d, bool searchflag)
+ free (merged.elems);
+ }
+
++/* Make sure D's state arrays are large enough to hold NEW_STATE. */
++static void
++realloc_trans_if_necessary (struct dfa *d, state_num new_state)
++{
++ state_num oldalloc = d->tralloc;
++ if (oldalloc <= new_state)
++ {
++ state_num **realtrans = d->trans ? d->trans - 2 : NULL;
++ ptrdiff_t newalloc1 = realtrans ? d->tralloc + 2 : 0;
++ realtrans = xpalloc (realtrans, &newalloc1, new_state - oldalloc + 1,
++ -1, sizeof *realtrans);
++ realtrans[0] = realtrans[1] = NULL;
++ d->trans = realtrans + 2;
++ ptrdiff_t newalloc = d->tralloc = newalloc1 - 2;
++ d->fails = xnrealloc (d->fails, newalloc, sizeof *d->fails);
++ d->success = xnrealloc (d->success, newalloc, sizeof *d->success);
++ d->newlines = xnrealloc (d->newlines, newalloc, sizeof *d->newlines);
++ if (d->localeinfo.multibyte)
++ {
++ realtrans = d->mb_trans ? d->mb_trans - 2 : NULL;
++ realtrans = xnrealloc (realtrans, newalloc1, sizeof *realtrans);
++ if (oldalloc == 0)
++ realtrans[0] = realtrans[1] = NULL;
++ d->mb_trans = realtrans + 2;
++ }
++ for (; oldalloc < newalloc; oldalloc++)
++ {
++ d->trans[oldalloc] = NULL;
++ d->fails[oldalloc] = NULL;
++ if (d->localeinfo.multibyte)
++ d->mb_trans[oldalloc] = NULL;
++ }
++ }
++}
+
+ /* Return the transition out of state s of d for the input character uc,
+ updating the slots in trans accordingly.
+@@ -2810,20 +2844,25 @@ dfastate (state_num s, struct dfa *d, unsigned char uc, state_num trans[])
+ }
+
+ /* Set the transitions for each character in the label. */
++ state_num maxstate = -1;
+ for (i = 0; i < NOTCHAR; i++)
+ if (tstbit (i, label))
+- switch (d->syntax.sbit[i])
+- {
+- case CTX_NEWLINE:
+- trans[i] = state_newline;
+- break;
+- case CTX_LETTER:
+- trans[i] = state_letter;
+- break;
+- default:
+- trans[i] = state;
+- break;
+- }
++ {
++ switch (d->syntax.sbit[i])
++ {
++ case CTX_NEWLINE:
++ trans[i] = state_newline;
++ break;
++ case CTX_LETTER:
++ trans[i] = state_letter;
++ break;
++ default:
++ trans[i] = state;
++ break;
++ }
++ if (maxstate < trans[i])
++ maxstate = trans[i];
++ }
+
+ #ifdef DEBUG
+ fprintf (stderr, "trans table %td", s);
+@@ -2840,6 +2879,9 @@ dfastate (state_num s, struct dfa *d, unsigned char uc, state_num trans[])
+ free (follows.elems);
+ free (tmp.elems);
+
++ /* Reallocate now, to reallocate any newline transition properly. */
++ realloc_trans_if_necessary (d, maxstate);
++
+ /* Keep the newline transition in a special place so we can use it as
+ a sentinel. */
+ if (tstbit (d->syntax.eolbyte, label))
+@@ -2851,42 +2893,6 @@ dfastate (state_num s, struct dfa *d, unsigned char uc, state_num trans[])
+ return trans[uc];
+ }
+
+-/* Make sure D's state arrays are large enough to hold NEW_STATE. */
+-static void
+-realloc_trans_if_necessary (struct dfa *d, state_num new_state)
+-{
+- state_num oldalloc = d->tralloc;
+- if (oldalloc <= new_state)
+- {
+- state_num **realtrans = d->trans ? d->trans - 2 : NULL;
+- ptrdiff_t newalloc, newalloc1;
+- newalloc1 = realtrans ? d->tralloc + 2 : 0;
+- realtrans = xpalloc (realtrans, &newalloc1, new_state - oldalloc + 1,
+- -1, sizeof *realtrans);
+- realtrans[0] = realtrans[1] = NULL;
+- d->trans = realtrans + 2;
+- d->tralloc = newalloc = newalloc1 - 2;
+- d->fails = xnrealloc (d->fails, newalloc, sizeof *d->fails);
+- d->success = xnrealloc (d->success, newalloc, sizeof *d->success);
+- d->newlines = xnrealloc (d->newlines, newalloc, sizeof *d->newlines);
+- if (d->localeinfo.multibyte)
+- {
+- realtrans = d->mb_trans ? d->mb_trans - 2 : NULL;
+- realtrans = xnrealloc (realtrans, newalloc1, sizeof *realtrans);
+- if (oldalloc == 0)
+- realtrans[0] = realtrans[1] = NULL;
+- d->mb_trans = realtrans + 2;
+- }
+- for (; oldalloc < newalloc; oldalloc++)
+- {
+- d->trans[oldalloc] = NULL;
+- d->fails[oldalloc] = NULL;
+- if (d->localeinfo.multibyte)
+- d->mb_trans[oldalloc] = NULL;
+- }
+- }
+-}
+-
+ /* Calculate the transition table for a new state derived from state s
+ for a compiled dfa d after input character uc, and return the new
+ state number. */
+@@ -2932,18 +2939,7 @@ build_state (state_num s, struct dfa *d, unsigned char uc)
+ if (ACCEPTS_IN_CONTEXT (d->states[s].context, CTX_NONE, s, *d))
+ d->success[s] |= CTX_NONE;
+
+- s = dfastate (s, d, uc, trans);
+-
+- /* Now go through the new transition table, and make sure that the trans
+- and fail arrays are allocated large enough to hold a pointer for the
+- largest state mentioned in the table. */
+- state_num maxstate = -1;
+- for (int i = 0; i < NOTCHAR; i++)
+- if (maxstate < trans[i])
+- maxstate = trans[i];
+- realloc_trans_if_necessary (d, maxstate);
+-
+- return s;
++ return dfastate (s, d, uc, trans);
+ }
+
+ /* Multibyte character handling sub-routines for dfaexec. */
+--
+2.11.0
+
diff --git a/sys-apps/sed/files/sed-4.3-dfa-segv-2.patch b/sys-apps/sed/files/sed-4.3-dfa-segv-2.patch
new file mode 100644
index 000000000000..4e4fb2c648cc
--- /dev/null
+++ b/sys-apps/sed/files/sed-4.3-dfa-segv-2.patch
@@ -0,0 +1,112 @@
+fix from upstream gnulib (fudged to apply to sed-4.3)
+
+From aff55692da81f702ccbc461ad4f896b23c398638 Mon Sep 17 00:00:00 2001
+From: Norihiro Tanaka <noritnk@kcn.ne.jp>
+Date: Mon, 9 Jan 2017 07:46:13 +0900
+Subject: [PATCH] dfa: simplify transition table allocation
+
+* src/dfa.c (realloc_trans_if_necessary): Remove second argument.
+Its value is derived from other variable. Update callers.
+(dfastate): Remove calculation of max number of state.
+---
+ lib/dfa.c | 44 ++++++++++++++++++++------------------------
+ 1 file changed, 20 insertions(+), 24 deletions(-)
+
+diff --git a/lib/dfa.c b/lib/dfa.c
+index 141888a978fa..bda4602b1094 100644
+--- a/lib/dfa.c
++++ b/lib/dfa.c
+@@ -2576,14 +2576,14 @@ dfaanalyze (struct dfa *d, bool searchflag)
+
+ /* Make sure D's state arrays are large enough to hold NEW_STATE. */
+ static void
+-realloc_trans_if_necessary (struct dfa *d, state_num new_state)
++realloc_trans_if_necessary (struct dfa *d)
+ {
+ state_num oldalloc = d->tralloc;
+- if (oldalloc <= new_state)
++ if (oldalloc < d->sindex)
+ {
+ state_num **realtrans = d->trans ? d->trans - 2 : NULL;
+ ptrdiff_t newalloc1 = realtrans ? d->tralloc + 2 : 0;
+- realtrans = xpalloc (realtrans, &newalloc1, new_state - oldalloc + 1,
++ realtrans = xpalloc (realtrans, &newalloc1, d->sindex - oldalloc,
+ -1, sizeof *realtrans);
+ realtrans[0] = realtrans[1] = NULL;
+ d->trans = realtrans + 2;
+@@ -2825,6 +2825,9 @@ dfastate (state_num s, struct dfa *d, unsigned char uc, state_num trans[])
+ state_letter = state_index (d, &follows, CTX_LETTER);
+ else
+ state_letter = state;
++
++ /* Reallocate now, to reallocate any newline transition properly. */
++ realloc_trans_if_necessary (d);
+ }
+
+ /* If we are a searching matcher, the default transition is to a state
+@@ -2847,22 +2850,18 @@ dfastate (state_num s, struct dfa *d, unsigned char uc, state_num trans[])
+ state_num maxstate = -1;
+ for (i = 0; i < NOTCHAR; i++)
+ if (tstbit (i, label))
+- {
+- switch (d->syntax.sbit[i])
+- {
+- case CTX_NEWLINE:
+- trans[i] = state_newline;
+- break;
+- case CTX_LETTER:
+- trans[i] = state_letter;
+- break;
+- default:
+- trans[i] = state;
+- break;
+- }
+- if (maxstate < trans[i])
+- maxstate = trans[i];
+- }
++ switch (d->syntax.sbit[i])
++ {
++ case CTX_NEWLINE:
++ trans[i] = state_newline;
++ break;
++ case CTX_LETTER:
++ trans[i] = state_letter;
++ break;
++ default:
++ trans[i] = state;
++ break;
++ }
+
+ #ifdef DEBUG
+ fprintf (stderr, "trans table %td", s);
+@@ -2879,9 +2878,6 @@ dfastate (state_num s, struct dfa *d, unsigned char uc, state_num trans[])
+ free (follows.elems);
+ free (tmp.elems);
+
+- /* Reallocate now, to reallocate any newline transition properly. */
+- realloc_trans_if_necessary (d, maxstate);
+-
+ /* Keep the newline transition in a special place so we can use it as
+ a sentinel. */
+ if (tstbit (d->syntax.eolbyte, label))
+@@ -3042,7 +3038,7 @@ transit_state (struct dfa *d, state_num s, unsigned char const **pp,
+
+ separate_contexts = state_separate_contexts (&d->mb_follows);
+ s2 = state_index (d, &d->mb_follows, separate_contexts ^ CTX_ANY);
+- realloc_trans_if_necessary (d, s2);
++ realloc_trans_if_necessary (d);
+
+ d->mb_trans[s][d->states[s1].mb_trindex] = s2;
+
+@@ -3137,7 +3133,7 @@ dfaexec_main (struct dfa *d, char const *begin, char *end, bool allow_nl,
+ }
+
+ if (!d->tralloc)
+- realloc_trans_if_necessary (d, 0);
++ realloc_trans_if_necessary (d);
+
+ s = s1 = 0;
+ p = mbp = (unsigned char const *) begin;
+--
+2.11.0
+
diff --git a/sys-apps/sed/files/sed-4.3-dfa-segv-3.patch b/sys-apps/sed/files/sed-4.3-dfa-segv-3.patch
new file mode 100644
index 000000000000..d85022f754f0
--- /dev/null
+++ b/sys-apps/sed/files/sed-4.3-dfa-segv-3.patch
@@ -0,0 +1,146 @@
+fix from upstream gnulib (fudged to apply to sed-4.3)
+
+From 7c345c68cdf62737ccc4a9d0ba2cd921fae850fa Mon Sep 17 00:00:00 2001
+From: Norihiro Tanaka <noritnk@kcn.ne.jp>
+Date: Mon, 9 Jan 2017 08:21:21 +0900
+Subject: [PATCH] dfa: melt down dfastate into build_state
+
+* src/dfa.c (dfastate): Remove it.
+(build_state): Insert content of dfastate() to bottom.
+---
+ lib/dfa.c | 97 +++++++++++++++++++++++++++++----------------------------------
+ 1 file changed, 45 insertions(+), 52 deletions(-)
+
+diff --git a/lib/dfa.c b/lib/dfa.c
+index bda4602b1094..6896ed320a7b 100644
+--- a/lib/dfa.c
++++ b/lib/dfa.c
+@@ -2609,8 +2609,10 @@ realloc_trans_if_necessary (struct dfa *d)
+ }
+ }
+
+-/* Return the transition out of state s of d for the input character uc,
+- updating the slots in trans accordingly.
++/*
++ Calculate the transition table for a new state derived from state s
++ for a compiled dfa d after input character uc, and return the new
++ state number.
+
+ Do not worry about all possible input characters; calculate just the group
+ of positions that match uc. Label it with the set of characters that
+@@ -2639,8 +2641,9 @@ realloc_trans_if_necessary (struct dfa *d)
+ If after comparing with every group there are characters remaining in C,
+ create a new group labeled with the characters of C and insert this
+ position in that group. */
++
+ static state_num
+-dfastate (state_num s, struct dfa *d, unsigned char uc, state_num trans[])
++build_state (state_num s, struct dfa *d, unsigned char uc)
+ {
+ leaf_set group; /* Positions that match the input char. */
+ charclass label; /* The group's label. */
+@@ -2652,6 +2655,45 @@ dfastate (state_num s, struct dfa *d, unsigned char uc, state_num trans[])
+ fprintf (stderr, "build state %td\n", s);
+ #endif
+
++ /* A pointer to the new transition table, and the table itself. */
++ state_num **ptrans = (ACCEPTING (s, *d) ? d->fails : d->trans) + s;
++ state_num *trans = *ptrans;
++
++ if (!trans)
++ {
++ /* MAX_TRCOUNT is an arbitrary upper limit on the number of
++ transition tables that can exist at once, other than for
++ initial states. Often-used transition tables are quickly
++ rebuilt, whereas rarely-used ones are cleared away. */
++ if (MAX_TRCOUNT <= d->trcount)
++ {
++ for (state_num i = d->min_trcount; i < d->tralloc; i++)
++ {
++ free (d->trans[i]);
++ free (d->fails[i]);
++ d->trans[i] = d->fails[i] = NULL;
++ }
++ d->trcount = 0;
++ }
++
++ d->trcount++;
++ *ptrans = trans = xmalloc (NOTCHAR * sizeof *trans);
++
++ /* Fill transition table with a default value which means that the
++ transited state has not been calculated yet. */
++ for (int i = 0; i < NOTCHAR; i++)
++ trans[i] = -2;
++ }
++
++ /* Set up the success bits for this state. */
++ d->success[s] = 0;
++ if (ACCEPTS_IN_CONTEXT (d->states[s].context, CTX_NEWLINE, s, *d))
++ d->success[s] |= CTX_NEWLINE;
++ if (ACCEPTS_IN_CONTEXT (d->states[s].context, CTX_LETTER, s, *d))
++ d->success[s] |= CTX_LETTER;
++ if (ACCEPTS_IN_CONTEXT (d->states[s].context, CTX_NONE, s, *d))
++ d->success[s] |= CTX_NONE;
++
+ group.elems = xnmalloc (d->nleaves, sizeof *group.elems);
+ group.nelem = 0;
+
+@@ -2889,55 +2931,6 @@ dfastate (state_num s, struct dfa *d, unsigned char uc, state_num trans[])
+ return trans[uc];
+ }
+
+-/* Calculate the transition table for a new state derived from state s
+- for a compiled dfa d after input character uc, and return the new
+- state number. */
+-
+-static state_num
+-build_state (state_num s, struct dfa *d, unsigned char uc)
+-{
+- /* A pointer to the new transition table, and the table itself. */
+- state_num **ptrans = (ACCEPTING (s, *d) ? d->fails : d->trans) + s;
+- state_num *trans = *ptrans;
+-
+- if (!trans)
+- {
+- /* MAX_TRCOUNT is an arbitrary upper limit on the number of
+- transition tables that can exist at once, other than for
+- initial states. Often-used transition tables are quickly
+- rebuilt, whereas rarely-used ones are cleared away. */
+- if (MAX_TRCOUNT <= d->trcount)
+- {
+- for (state_num i = d->min_trcount; i < d->tralloc; i++)
+- {
+- free (d->trans[i]);
+- free (d->fails[i]);
+- d->trans[i] = d->fails[i] = NULL;
+- }
+- d->trcount = 0;
+- }
+-
+- d->trcount++;
+- *ptrans = trans = xmalloc (NOTCHAR * sizeof *trans);
+-
+- /* Fill transition table with a default value which means that the
+- transited state has not been calculated yet. */
+- for (int i = 0; i < NOTCHAR; i++)
+- trans[i] = -2;
+- }
+-
+- /* Set up the success bits for this state. */
+- d->success[s] = 0;
+- if (ACCEPTS_IN_CONTEXT (d->states[s].context, CTX_NEWLINE, s, *d))
+- d->success[s] |= CTX_NEWLINE;
+- if (ACCEPTS_IN_CONTEXT (d->states[s].context, CTX_LETTER, s, *d))
+- d->success[s] |= CTX_LETTER;
+- if (ACCEPTS_IN_CONTEXT (d->states[s].context, CTX_NONE, s, *d))
+- d->success[s] |= CTX_NONE;
+-
+- return dfastate (s, d, uc, trans);
+-}
+-
+ /* Multibyte character handling sub-routines for dfaexec. */
+
+ /* Consume a single byte and transit state from 's' to '*next_state'.
+--
+2.11.0
+
diff --git a/sys-apps/sed/metadata.xml b/sys-apps/sed/metadata.xml
new file mode 100644
index 000000000000..b738f8c54a01
--- /dev/null
+++ b/sys-apps/sed/metadata.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>base-system@gentoo.org</email>
+ <name>Gentoo Base System</name>
+</maintainer>
+<upstream>
+ <remote-id type="sourceforge">sed</remote-id>
+</upstream>
+</pkgmetadata>
diff --git a/sys-apps/sed/sed-4.2.2.ebuild b/sys-apps/sed/sed-4.2.2.ebuild
new file mode 100644
index 000000000000..7c91a5f00047
--- /dev/null
+++ b/sys-apps/sed/sed-4.2.2.ebuild
@@ -0,0 +1,63 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit eutils flag-o-matic toolchain-funcs
+
+DESCRIPTION="Super-useful stream editor"
+HOMEPAGE="http://sed.sourceforge.net/"
+SRC_URI="mirror://gnu/sed/${P}.tar.bz2"
+
+LICENSE="GPL-3"
+SLOT="0"
+KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+IUSE="acl nls selinux static"
+
+RDEPEND="acl? ( virtual/acl )
+ nls? ( virtual/libintl )
+ selinux? ( sys-libs/libselinux )"
+DEPEND="${RDEPEND}
+ nls? ( sys-devel/gettext )"
+
+src_bootstrap_sed() {
+ # make sure system-sed works #40786
+ export NO_SYS_SED=""
+ if ! type -p sed > /dev/null ; then
+ NO_SYS_SED="!!!"
+ ./bootstrap.sh || die "couldnt bootstrap"
+ cp sed/sed "${T}"/ || die "couldnt copy"
+ export PATH="${PATH}:${T}"
+ make clean || die "couldnt clean"
+ fi
+}
+
+src_prepare() {
+ epatch "${FILESDIR}"/${PN}-4.1.5-alloca.patch
+
+ # don't use sed before bootstrap if we have to recover a broken host sed
+ src_bootstrap_sed
+ # this has to be after the bootstrap portion
+ sed -i \
+ -e '/docdir =/s:=.*/doc:= $(datadir)/doc/'${PF}'/html:' \
+ doc/Makefile.in || die "sed html doc"
+}
+
+src_configure() {
+ local myconf=()
+ if use userland_GNU; then
+ myconf+=( --exec-prefix="${EPREFIX}" )
+ else
+ myconf+=( --program-prefix=g )
+ fi
+
+ # Should be able to drop this hack in next release. #333887
+ tc-is-cross-compiler && export gl_cv_func_working_acl_get_file=yes
+ export ac_cv_search_setfilecon=$(usex selinux -lselinux)
+ export ac_cv_header_selinux_{context,selinux}_h=$(usex selinux)
+ use static && append-ldflags -static
+ econf \
+ $(use_enable acl) \
+ $(use_enable nls) \
+ "${myconf[@]}"
+}
diff --git a/sys-apps/sed/sed-4.3-r1.ebuild b/sys-apps/sed/sed-4.3-r1.ebuild
new file mode 100644
index 000000000000..fcc30b064a0e
--- /dev/null
+++ b/sys-apps/sed/sed-4.3-r1.ebuild
@@ -0,0 +1,62 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="5"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+DESCRIPTION="Super-useful stream editor"
+HOMEPAGE="http://sed.sourceforge.net/"
+SRC_URI="mirror://gnu/sed/${P}.tar.xz"
+
+LICENSE="GPL-3"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+IUSE="acl nls selinux static"
+
+RDEPEND="acl? ( virtual/acl )
+ nls? ( virtual/libintl )
+ selinux? ( sys-libs/libselinux )"
+DEPEND="${RDEPEND}
+ nls? ( sys-devel/gettext )"
+
+PATCHES=(
+ "${FILESDIR}"/${P}-dfa-segv-{1,2,3}.patch
+)
+
+src_bootstrap_sed() {
+ # make sure system-sed works #40786
+ export NO_SYS_SED=""
+ if ! type -p sed > /dev/null ; then
+ NO_SYS_SED="!!!"
+ ./bootstrap.sh || die "couldnt bootstrap"
+ cp sed/sed "${T}"/ || die "couldnt copy"
+ export PATH="${PATH}:${T}"
+ make clean || die "couldnt clean"
+ fi
+}
+
+src_prepare() {
+ epatch "${PATCHES[@]}"
+
+ # don't use sed before bootstrap if we have to recover a broken host sed
+ src_bootstrap_sed
+}
+
+src_configure() {
+ local myconf=()
+ if use userland_GNU; then
+ myconf+=( --exec-prefix="${EPREFIX}" )
+ else
+ myconf+=( --program-prefix=g )
+ fi
+
+ export ac_cv_search_setfilecon=$(usex selinux -lselinux)
+ export ac_cv_header_selinux_{context,selinux}_h=$(usex selinux)
+ use static && append-ldflags -static
+ myconf+=(
+ $(use_enable acl)
+ $(use_enable nls)
+ )
+ econf "${myconf[@]}"
+}
diff --git a/sys-apps/sed/sed-4.4.ebuild b/sys-apps/sed/sed-4.4.ebuild
new file mode 100644
index 000000000000..fcae761846b0
--- /dev/null
+++ b/sys-apps/sed/sed-4.4.ebuild
@@ -0,0 +1,61 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="5"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+DESCRIPTION="Super-useful stream editor"
+HOMEPAGE="http://sed.sourceforge.net/"
+SRC_URI="mirror://gnu/sed/${P}.tar.xz"
+
+LICENSE="GPL-3"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+IUSE="acl nls selinux static"
+
+RDEPEND="acl? ( virtual/acl )
+ nls? ( virtual/libintl )
+ selinux? ( sys-libs/libselinux )"
+DEPEND="${RDEPEND}
+ nls? ( sys-devel/gettext )"
+
+#PATCHES=(
+#)
+
+src_bootstrap_sed() {
+ # make sure system-sed works #40786
+ export NO_SYS_SED=""
+ if ! type -p sed > /dev/null ; then
+ NO_SYS_SED="!!!"
+ ./bootstrap.sh || die "couldnt bootstrap"
+ cp sed/sed "${T}"/ || die "couldnt copy"
+ export PATH="${PATH}:${T}"
+ make clean || die "couldnt clean"
+ fi
+}
+
+src_prepare() {
+ #epatch "${PATCHES[@]}"
+
+ # don't use sed before bootstrap if we have to recover a broken host sed
+ src_bootstrap_sed
+}
+
+src_configure() {
+ local myconf=()
+ if use userland_GNU; then
+ myconf+=( --exec-prefix="${EPREFIX}" )
+ else
+ myconf+=( --program-prefix=g )
+ fi
+
+ export ac_cv_search_setfilecon=$(usex selinux -lselinux)
+ export ac_cv_header_selinux_{context,selinux}_h=$(usex selinux)
+ use static && append-ldflags -static
+ myconf+=(
+ $(use_enable acl)
+ $(use_enable nls)
+ )
+ econf "${myconf[@]}"
+}