summaryrefslogtreecommitdiff
path: root/dev-libs/libedit
diff options
context:
space:
mode:
Diffstat (limited to 'dev-libs/libedit')
-rw-r--r--dev-libs/libedit/Manifest14
-rw-r--r--dev-libs/libedit/files/libedit-20100424.3.0-bsd.patch13
-rw-r--r--dev-libs/libedit/files/libedit-20110709.3.0-weak-reference.patch20
-rw-r--r--dev-libs/libedit/files/libedit-20120311-3.0-el_fn_sh_complete.patch258
-rw-r--r--dev-libs/libedit/files/libedit-20170329.3.1-el_fn_sh_complete.patch249
-rw-r--r--dev-libs/libedit/files/libedit-20170329.3.1-ncursesprivate.patch10
-rw-r--r--dev-libs/libedit/files/libedit-20170329.3.1-tinfo.patch30
-rw-r--r--dev-libs/libedit/files/libedit-ncursesprivate.patch13
-rw-r--r--dev-libs/libedit/libedit-20130712.3.1.ebuild49
-rw-r--r--dev-libs/libedit/libedit-20170329.3.1.ebuild54
-rw-r--r--dev-libs/libedit/metadata.xml16
11 files changed, 726 insertions, 0 deletions
diff --git a/dev-libs/libedit/Manifest b/dev-libs/libedit/Manifest
new file mode 100644
index 000000000000..824c4d54e2ef
--- /dev/null
+++ b/dev-libs/libedit/Manifest
@@ -0,0 +1,14 @@
+AUX libedit-20100424.3.0-bsd.patch 724 SHA256 2226e17f65b2486c45964867a1ed4a699c1861089b7a1501bccc83d28bca6c45 SHA512 67e0316db39b581b40dcfc15cfc308398d7865d29adc31e43159a30d8b94f50b486aa5da2a9599154138c1c8ae56fa9f6dca663eff174559f8896f50f973eefb WHIRLPOOL 1eaff78933c8628e3c6796c5bfefff8771db8aa50cd1d7a0a68762b219613f50e2ffdc6afe317712038707d9ea8ef35a6661371d2ee098e301e914cf2eced0d8
+AUX libedit-20110709.3.0-weak-reference.patch 651 SHA256 f4bbf2b49d158966b8ccb8556928b22af3690e7d91d5e3062842b6c9587641be SHA512 6f905d4254be6a11a135315346e41579e30c496d7d28caef1daa89079574be081c092d653034fd89a1ce84495f1566ef85d50b274cb87b249b4706e954c40420 WHIRLPOOL 20cd81c562a4d9c054712ff0233ccd3c36f65e56e61061979b60f538e6add55298bba6f42025e1f2146f6d83d14e82cda10e298453b9ca0631c1a5f0fcea6bb8
+AUX libedit-20120311-3.0-el_fn_sh_complete.patch 7724 SHA256 8fb2844923c3750c9b833ad4f9dfd15f78e0bb917b0d8fb98d3e0ffb7f1037fb SHA512 c62490079ff73a14310c6840d379d950699cd178e5e4a15231a79ea06600ba7bb805630e032d5d49ea5479e4919514ee79b035bf7d00e20b6e8512c84920bba3 WHIRLPOOL 1d0737e628f663edf8734d93aec6e0d33ba8e17e4893be33805c731a343701106778979fcaa8ccb7d227b78402b1a715d78a7102178a6871392f421d40e8b17a
+AUX libedit-20170329.3.1-el_fn_sh_complete.patch 6942 SHA256 06a8475988b82886f034666cac5bc3333d69bf9fc0760aec44b3b6e42e4bd72f SHA512 7715cbaaf38c09f62a885cc66edc416b26ae49cef627a7d22a256b787d7ad3784f90e49e906dead009ad86576894c25a839a96dfe26ab9d2ee5e0a8cba71732d WHIRLPOOL cf0cccc18c05a9b70e4897ecc70352afa30a5cb7bd7e9de0bd3e902623d828ece8327b394cee05170eb422d0aac70c7fb937d0cb6166c80614b5971de0748baf
+AUX libedit-20170329.3.1-ncursesprivate.patch 438 SHA256 c25a3d73307e7afd8ccc43cf7fda9f355eb6f80344ee08fa22258166b7106edc SHA512 aa2b52b36050413941892eaf66fe7b66e992c14cda29ee2733e8359b5990eed9537fb0422fd3704b32a70f1b9e350a0b0f06aaff9a55bb89b764d57a6f0dbef1 WHIRLPOOL 10fc3e8448166c54de5ce918fa1951f0a8b240d40e224dce760a8611b2fca848ac24b5a739ad3d4cf14c93105862af6a7c67faaf33f65bfbcaaa9d78ae87bf36
+AUX libedit-20170329.3.1-tinfo.patch 954 SHA256 211062669540b5ea986e6a3eae08264122144a16c4ccd7cc0ec59ef1f2e634c9 SHA512 e03cef80831c8982705e9ba3448a379e48a443b3b09b4c6f6be56ca2d0ac594f4569b76739551cc945bef27fc0fac2ffea3ad532355933a528753338f4094172 WHIRLPOOL 4ce60bb51edd11adb700ae2159dfe0da9fc79a1b02eece7d5083e0e4ea4e9f2d95bf837e5d6962e78d46bd9e451b41d771cd6c9bfb258864dfc868a887e5757c
+AUX libedit-ncursesprivate.patch 497 SHA256 e1fc9f5c3ffe5e5ba4117bc6b1c615e6f3e5ef82dfcebece16aaa5d571abb8a1 SHA512 41175b20f7b925e347db008d5e8a535b8326cd2c010a67b9db3a59131fce77a7791b7940e7eea9d68e82dbd3731efaa503d4bd218d78b29f946152dd56bd9b14 WHIRLPOOL df6b644fdaa70ec62997c2bd353ad757e6aafda7c17b4926ad3044d4f1d02deb379bd84946f5cea08c63eb4ba346752949f5b0a1577bc046dbbb4c4221fdf239
+DIST libedit-20130712-3.1.tar.gz 483857 SHA256 5d9b1a9dd66f1fe28bbd98e4d8ed1a22d8da0d08d902407dcc4a0702c8d88a37 SHA512 9fb3173a65ea2cd2ffa9af0666aa3e227b7d6be26f3e84f30ea3449b0c80fc5e91b618e939f7047bf885b96689ede93733f7eba614d4fdd1a4baff3f130b432e WHIRLPOOL 550553af1cf3bbd863ef4ce86ef5fd7adf257a7f5946ad186a104c5920d0f58216c135d496d52fd2d6ad51a1fb954bb87719d731aa0eebf6980d1c15345d6034
+DIST libedit-20170329-3.1.tar.gz 508504 SHA256 91f2d90fbd2a048ff6dad7131d9a39e690fd8a8fd982a353f1333dd4017dd4be SHA512 597ed2282240be6dc3c4a7bb8b4ade31fe16ebfeb2229e3aec58643a65882653cc91deb300343d1b1cc588959dbf95698122c4005e47dfb947efa3e6b134bb82 WHIRLPOOL ae0cc1e6e514bee7cda1a13ccd0c7f7673d4de775a9fe26ee9c32f08d43f3866ba8d9d3f4871ea15d517635be375d5989bbf36e59f00884ece517777c94c3273
+EBUILD libedit-20130712.3.1.ebuild 1279 SHA256 a8ac9099478189bd0c3bfb5f8bb17552a19c2e53065e3f96f7b7bee7b14261e6 SHA512 8367e733991a2c31573c6b207930ed95c58210f598e0be19910051bc386c148db00bbc41830084fb9eab878dc0413fef738c2399896b4f62e09fa153cddcf3a8 WHIRLPOOL b32a5ef844e97f0d38e72ad07c87a8cf2989950a9ce3d73aaaa6634f7246c0ae203a2de5f5239f00950e6393ce4ef8e7833877a3271423113e4ad0370ea8206c
+EBUILD libedit-20170329.3.1.ebuild 1297 SHA256 0244ba76cdbe31bbd26ce5d37b23c94fffe379a1f5f474920ca159b148c0929b SHA512 db81cf30017908a452131fe432890a3481177d2d0b90064c367aaa30919d974254ccb7115034c28f3d231cd27c88fce38958adadba211547e18d9d0546da3ad2 WHIRLPOOL db04a7f00bbb8749849061f95f51a5c4e82fa5b70cee61f39f7833a7b01602ef82545abcd05920f0fdfe318df75d6cc780374b3b5b93f582d4bcd6067aeacc23
+MISC ChangeLog 3334 SHA256 34d4702268521c106b89baf446d58af2541440f39273204b1e61746508fab1fd SHA512 f1491fe54f4d1c4ca9af69393938c408253047f4f048569088407366f5190b70226f72e291802e3d26181e0b9b6316b5fe1bfc97e2f076170f0cfb06b9993852 WHIRLPOOL 3b50a31acf8dc682cc10cd72370508cb4f0b750a83e2875eccbb7ddf05c56e2fa707b41c70b2f00149d6ad248af974120057b24b0ec66559ddeade1dcc001ccb
+MISC ChangeLog-2015 12459 SHA256 8899d2e3f79b28e7461b5494c28985207b746ee7ff4ae32de57a3d0514ecb3dd SHA512 133e1e6395632f7319e393ecdc75ae7f2252c8b0e7713f02be5498ed1f0ad1bec68f1f3f9ae58e447f3d9a0647aca0d6f2f0daaec8ac01cc3c345fa440b49e0c WHIRLPOOL c07b42492f6c1745974a77f77b5c79ebfdbb0d3bec6943e978e8c998337011c77ff674a0aacf68c12ac27006efae32ea2b287623afd964f3e0654a73fc93aee7
+MISC metadata.xml 636 SHA256 ec3560e3314a6a4b29d2786e993a52e900d30f36bb2248f2842d8a4b1399db81 SHA512 c335a652424f91f1ae79f907870bcd826cee21365b594353b3c52fb7fef51f637e9a65275c11f033b6bd7b6d918733904efc320b547999ee5b88a7b36ccb9389 WHIRLPOOL 753aa219f31fcade9ab32787ec1528b2e4ac195a9058baad7612fa8c1773375701b37dc1761e9ef86107697245c51414f18ad9cc0d3484d403e205969007c1f5
diff --git a/dev-libs/libedit/files/libedit-20100424.3.0-bsd.patch b/dev-libs/libedit/files/libedit-20100424.3.0-bsd.patch
new file mode 100644
index 000000000000..e230a76d709f
--- /dev/null
+++ b/dev-libs/libedit/files/libedit-20100424.3.0-bsd.patch
@@ -0,0 +1,13 @@
+diff --git a/src/chartype.h b/src/chartype.h
+index c35825c..be5aac0 100644
+--- a/src/chartype.h
++++ b/src/chartype.h
+@@ -44,7 +44,7 @@
+ * supports non-BMP code points without requiring UTF-16, but nothing
+ * seems to actually advertise this properly, despite Unicode 3.1 having
+ * been around since 2001... */
+-#if !defined(__NetBSD__) && !defined(__sun) && !(defined(__APPLE__) && defined(__MACH__))
++#if !defined(__NetBSD__) && !defined(__sun) && !(defined(__APPLE__) && defined(__MACH__)) && !defined(__DragonFly__) && !defined(__FreeBSD__)
+ #ifndef __STDC_ISO_10646__
+ /* In many places it is assumed that the first 127 code points are ASCII
+ * compatible, so ensure wchar_t indeed does ISO 10646 and not some other
diff --git a/dev-libs/libedit/files/libedit-20110709.3.0-weak-reference.patch b/dev-libs/libedit/files/libedit-20110709.3.0-weak-reference.patch
new file mode 100644
index 000000000000..a4399593d636
--- /dev/null
+++ b/dev-libs/libedit/files/libedit-20110709.3.0-weak-reference.patch
@@ -0,0 +1,20 @@
+--- libedit-20110709-3.0/src/vi.c.old 2011-07-11 18:21:16.000000000 +0000
++++ libedit-20110709-3.0/src/vi.c 2011-07-11 18:24:29.000000000 +0000
+@@ -918,7 +918,7 @@
+ * NB: posix implies that we should enter insert mode, however
+ * this is against historical precedent...
+ */
+-#ifdef __weak_reference
++#if defined(__weak_reference) && defined(__NetBSD__)
+ __weakref_visible char *my_get_alias_text(const char *)
+ __weak_reference(get_alias_text);
+ #endif
+@@ -926,7 +926,7 @@
+ /*ARGSUSED*/
+ vi_alias(EditLine *el, Int c)
+ {
+-#ifdef __weak_reference
++#if defined(__weak_reference) && defined(__NetBSD__)
+ char alias_name[3];
+ char *alias_text;
+
diff --git a/dev-libs/libedit/files/libedit-20120311-3.0-el_fn_sh_complete.patch b/dev-libs/libedit/files/libedit-20120311-3.0-el_fn_sh_complete.patch
new file mode 100644
index 000000000000..b0b157a24fda
--- /dev/null
+++ b/dev-libs/libedit/files/libedit-20120311-3.0-el_fn_sh_complete.patch
@@ -0,0 +1,258 @@
+Port the el_fn_sh_complete from FreeBSD.
+This function is required by FreeBSD-9.0's sh.
+So that we can drop the bundled version in FreeBSD-9.0
+
+diff -uNr libedit-20120311-3.0/src/filecomplete.c libedit-20120311-3.0.freebsd/src/filecomplete.c
+--- libedit-20120311-3.0/src/filecomplete.c 2012-03-11 09:54:58.000000000 +0000
++++ libedit-20120311-3.0.freebsd/src/filecomplete.c 2012-04-23 12:14:25.000000000 +0000
+@@ -56,6 +56,9 @@
+
+ static const Char break_chars[] = { ' ', '\t', '\n', '"', '\\', '\'', '`', '@',
+ '$', '>', '<', '=', ';', '|', '&', '{', '(', '\0' };
++/* Tilde is deliberately omitted here, we treat it specially. */
++static const Char extra_quote_chars[] = { ')', '}', '*', '?', '[', '$', '\0' };
++
+
+
+ /********************************/
+@@ -411,10 +414,14 @@
+ char **(*attempted_completion_function)(const char *, int, int),
+ const Char *word_break, const Char *special_prefixes,
+ const char *(*app_func)(const char *), size_t query_items,
+- int *completion_type, int *over, int *point, int *end)
++ int *completion_type, int *over, int *point, int *end,
++ const char *(*find_word_start_func)(const char *, const char *),
++ char *(*dequoting_func)(const char *),
++ char *(*quoting_func)(const char *))
+ {
+ const TYPE(LineInfo) *li;
+ Char *temp;
++ char *dequoted_temp;
+ char **matches;
+ const Char *ctemp;
+ size_t len;
+@@ -435,17 +442,28 @@
+
+ /* We now look backwards for the start of a filename/variable word */
+ li = FUN(el,line)(el);
++ if (find_word_start_func)
++ ctemp = ct_decode_string(find_word_start_func(ct_encode_string(li->buffer,&el->el_scratch), ct_encode_string(li->cursor,&el->el_scratch)),&el->el_scratch);
++ else {
+ ctemp = li->cursor;
+ while (ctemp > li->buffer
+ && !Strchr(word_break, ctemp[-1])
+ && (!special_prefixes || !Strchr(special_prefixes, ctemp[-1]) ) )
+ ctemp--;
++ }
+
+ len = (size_t)(li->cursor - ctemp);
+ temp = el_malloc((len + 1) * sizeof(*temp));
+ (void)Strncpy(temp, ctemp, len);
+ temp[len] = '\0';
+
++ if (dequoting_func) {
++ dequoted_temp = dequoting_func(ct_encode_string(temp,&el->el_scratch));
++ if (dequoted_temp == NULL)
++ return retval;
++ } else
++ dequoted_temp = NULL;
++
+ /* these can be used by function called in completion_matches() */
+ /* or (*attempted_completion_function)() */
+ if (point != 0)
+@@ -456,14 +474,14 @@
+ if (attempted_completion_function) {
+ int cur_off = (int)(li->cursor - li->buffer);
+ matches = (*attempted_completion_function)(
+- ct_encode_string(temp, &el->el_scratch),
++ dequoted_temp? dequoted_temp : ct_encode_string(temp, &el->el_scratch),
+ cur_off - (int)len, cur_off);
+ } else
+ matches = 0;
+ if (!attempted_completion_function ||
+ (over != NULL && !*over && !matches))
+ matches = completion_matches(
+- ct_encode_string(temp, &el->el_scratch), complet_func);
++ dequoted_temp? dequoted_temp : ct_encode_string(temp, &el->el_scratch), complet_func);
+
+ if (over != NULL)
+ *over = 0;
+@@ -478,9 +496,19 @@
+ * possible matches if there is possible completion.
+ */
+ if (matches[0][0] != '\0') {
++ char *quoted_match;
++ if (quoting_func) {
++ quoted_match = quoting_func(matches[0]);
++ if (quoted_match == NULL)
++ goto free_matches;
++ } else
++ quoted_match = NULL;
++
+ el_deletestr(el, (int) len);
+ FUN(el,insertstr)(el,
+- ct_decode_string(matches[0], &el->el_scratch));
++ ct_decode_string(quoted_match? quoted_match : matches[0], &el->el_scratch));
++
++ free(quoted_match);
+ }
+
+ if (what_to_do == '?')
+@@ -553,12 +581,14 @@
+ retval = CC_NORM;
+ }
+
++free_matches:
+ /* free elements of array and the array itself */
+ for (i = 0; matches[i]; i++)
+ el_free(matches[i]);
+ el_free(matches);
+ matches = NULL;
+ }
++ el_free(dequoted_temp);
+ el_free(temp);
+ return retval;
+ }
+@@ -572,5 +602,102 @@
+ {
+ return (unsigned char)fn_complete(el, NULL, NULL,
+ break_chars, NULL, NULL, (size_t)100,
+- NULL, NULL, NULL, NULL);
++ NULL, NULL, NULL, NULL,
++ NULL, NULL, NULL);
++}
++
++static const char *
++sh_find_word_start(const char *buffer, const char *cursor)
++{
++ const char *word_start = buffer;
++
++ while (buffer < cursor) {
++ if (*buffer == '\\')
++ buffer++;
++ else if (Strchr(break_chars, *buffer))
++ word_start = buffer + 1;
++
++ buffer++;
++ }
++
++ return word_start;
++}
++
++
++static char *
++sh_quote(const char *str)
++{
++ const char *src;
++ int extra_len = 0;
++ char *quoted_str, *dst;
++
++ if (*str == '-' || *str == '+')
++ extra_len += 2;
++ for (src = str; *src != '\0'; src++)
++ if (Strchr(break_chars, *src) ||
++ Strchr(extra_quote_chars, *src))
++ extra_len++;
++
++ quoted_str = malloc(sizeof(*quoted_str) *
++ (strlen(str) + extra_len + 1));
++ if (quoted_str == NULL)
++ return NULL;
++
++ dst = quoted_str;
++ if (*str == '-' || *str == '+')
++ *dst++ = '.', *dst++ = '/';
++ for (src = str; *src != '\0'; src++) {
++ if (Strchr(break_chars, *src) ||
++ Strchr(extra_quote_chars, *src))
++ *dst++ = '\\';
++ *dst++ = *src;
++ }
++ *dst = '\0';
++
++ return quoted_str;
++}
++
++
++static char *
++sh_dequote(const char *str)
++{
++ char *dequoted_str, *dst;
++
++ /* save extra space to replace \~ with ./~ */
++ dequoted_str = malloc(sizeof(*dequoted_str) * (strlen(str) + 1 + 1));
++ if (dequoted_str == NULL)
++ return NULL;
++
++ dst = dequoted_str;
++
++ /* dequote \~ at start as ./~ */
++ if (*str == '\\' && str[1] == '~') {
++ str++;
++ *dst++ = '.';
++ *dst++ = '/';
++ }
++
++ while (*str) {
++ if (*str == '\\')
++ str++;
++ if (*str)
++ *dst++ = *str++;
++ }
++ *dst = '\0';
++
++ return dequoted_str;
++}
++
++
++/*
++ * completion function using sh quoting rules; for key binding
++ */
++/* ARGSUSED */
++unsigned char
++_el_fn_sh_complete(EditLine *el, int ch __attribute__((__unused__)))
++{
++ return (unsigned char)fn_complete(el, NULL, NULL,
++ break_chars, NULL, NULL, 100,
++ NULL, NULL, NULL, NULL,
++ sh_find_word_start, sh_dequote, sh_quote);
+ }
+diff -uNr libedit-20120311-3.0/src/filecomplete.h libedit-20120311-3.0.freebsd/src/filecomplete.h
+--- libedit-20120311-3.0/src/filecomplete.h 2010-04-22 19:13:17.000000000 +0000
++++ libedit-20120311-3.0.freebsd/src/filecomplete.h 2012-04-23 12:04:12.000000000 +0000
+@@ -35,7 +35,10 @@
+ char *(*)(const char *, int),
+ char **(*)(const char *, int, int),
+ const Char *, const Char *, const char *(*)(const char *), size_t,
+- int *, int *, int *, int *);
++ int *, int *, int *, int *,
++ const char *(*)(const char *, const char *),
++ char *(*)(const char *),
++ char *(*)(const char *));
+
+ void fn_display_match_list(EditLine *, char **, size_t, size_t);
+ char *fn_tilde_expand(const char *);
+Binary files libedit-20120311-3.0/src/filecomplete.o and libedit-20120311-3.0.freebsd/src/filecomplete.o differ
+diff -uNr libedit-20120311-3.0/src/histedit.h libedit-20120311-3.0.freebsd/src/histedit.h
+--- libedit-20120311-3.0/src/histedit.h 2011-08-02 06:52:08.000000000 +0000
++++ libedit-20120311-3.0.freebsd/src/histedit.h 2012-04-23 11:44:33.000000000 +0000
+@@ -113,6 +113,7 @@
+ int el_set(EditLine *, int, ...);
+ int el_get(EditLine *, int, ...);
+ unsigned char _el_fn_complete(EditLine *, int);
++unsigned char _el_fn_sh_complete(EditLine *, int);
+
+ /*
+ * el_set/el_get parameters
+diff -ur libedit-20120311-3.0/src/readline.c libedit-20120311-3.0.freebsd/src/readline.c
+--- libedit-20120311-3.0/src/readline.c 2012-03-11 09:54:58.000000000 +0000
++++ libedit-20120311-3.0.freebsd/src/readline.c 2012-04-23 12:20:11.000000000 +0000
+@@ -1773,7 +1773,7 @@
+ _rl_completion_append_character_function,
+ (size_t)rl_completion_query_items,
+ &rl_completion_type, &rl_attempted_completion_over,
+- &rl_point, &rl_end);
++ &rl_point, &rl_end, NULL, NULL, NULL);
+
+
+ }
diff --git a/dev-libs/libedit/files/libedit-20170329.3.1-el_fn_sh_complete.patch b/dev-libs/libedit/files/libedit-20170329.3.1-el_fn_sh_complete.patch
new file mode 100644
index 000000000000..c54f27600e34
--- /dev/null
+++ b/dev-libs/libedit/files/libedit-20170329.3.1-el_fn_sh_complete.patch
@@ -0,0 +1,249 @@
+--- libedit-20170329-3.1/src/filecomplete.c 2017-03-29 21:15:04.000000000 +0300
++++ libedit-20170329-3.1/src/filecomplete.c 2017-05-21 02:23:16.000000000 +0300
+@@ -51,6 +51,7 @@
+ #include "filecomplete.h"
+
+ static const wchar_t break_chars[] = L" \t\n\"\\'`@$><=;|&{(";
++static const wchar_t extra_quote_chars[] = L")}*?[$\0";
+
+ /********************************/
+ /* completion functions */
+@@ -405,10 +406,14 @@
+ char **(*attempted_completion_function)(const char *, int, int),
+ const wchar_t *word_break, const wchar_t *special_prefixes,
+ const char *(*app_func)(const char *), size_t query_items,
+- int *completion_type, int *over, int *point, int *end)
++ int *completion_type, int *over, int *point, int *end,
++ const char *(*find_word_start_func)(const char *, const char *),
++ char *(*dequoting_func)(const char *),
++ char *(*quoting_func)(const char *))
+ {
+ const LineInfoW *li;
+ wchar_t *temp;
++ char *dequoted_temp;
+ char **matches;
+ const wchar_t *ctemp;
+ size_t len;
+@@ -429,17 +434,28 @@
+
+ /* We now look backwards for the start of a filename/variable word */
+ li = el_wline(el);
++ if (find_word_start_func)
++ ctemp = ct_decode_string(find_word_start_func(ct_encode_string(li->buffer,&el->el_scratch), ct_encode_string(li->cursor,&el->el_scratch)),&el->el_scratch);
++ else {
+ ctemp = li->cursor;
+ while (ctemp > li->buffer
+ && !wcschr(word_break, ctemp[-1])
+ && (!special_prefixes || !wcschr(special_prefixes, ctemp[-1]) ) )
+ ctemp--;
++ }
+
+ len = (size_t)(li->cursor - ctemp);
+ temp = el_malloc((len + 1) * sizeof(*temp));
+ (void)wcsncpy(temp, ctemp, len);
+ temp[len] = '\0';
+
++ if (dequoting_func) {
++ dequoted_temp = dequoting_func(ct_encode_string(temp,&el->el_scratch));
++ if (dequoted_temp == NULL)
++ return retval;
++ } else
++ dequoted_temp = NULL;
++
+ /* these can be used by function called in completion_matches() */
+ /* or (*attempted_completion_function)() */
+ if (point != NULL)
+@@ -450,14 +466,14 @@
+ if (attempted_completion_function) {
+ int cur_off = (int)(li->cursor - li->buffer);
+ matches = (*attempted_completion_function)(
+- ct_encode_string(temp, &el->el_scratch),
++ dequoted_temp? dequoted_temp : ct_encode_string(temp, &el->el_scratch),
+ cur_off - (int)len, cur_off);
+ } else
+ matches = NULL;
+ if (!attempted_completion_function ||
+ (over != NULL && !*over && !matches))
+ matches = completion_matches(
+- ct_encode_string(temp, &el->el_scratch), complet_func);
++ dequoted_temp? dequoted_temp : ct_encode_string(temp, &el->el_scratch), complet_func);
+
+ if (over != NULL)
+ *over = 0;
+@@ -472,9 +488,18 @@
+ * possible matches if there is possible completion.
+ */
+ if (matches[0][0] != '\0') {
++ char *quoted_match;
++ if (quoting_func) {
++ quoted_match = quoting_func(matches[0]);
++ if (quoted_match == NULL)
++ goto free_matches;
++ } else
++ quoted_match = NULL;
++
+ el_deletestr(el, (int) len);
+ el_winsertstr(el,
+- ct_decode_string(matches[0], &el->el_scratch));
++ ct_decode_string(quoted_match? quoted_match : matches[0], &el->el_scratch));
++ free(quoted_match);
+ }
+
+
+@@ -545,12 +570,14 @@
+ retval = CC_NORM;
+ }
+
++free_matches:
+ /* free elements of array and the array itself */
+ for (i = 0; matches[i]; i++)
+ el_free(matches[i]);
+ el_free(matches);
+ matches = NULL;
+ }
++ el_free(dequoted_temp);
+ el_free(temp);
+ return retval;
+ }
+@@ -564,5 +591,102 @@
+ {
+ return (unsigned char)fn_complete(el, NULL, NULL,
+ break_chars, NULL, NULL, (size_t)100,
+- NULL, NULL, NULL, NULL);
++ NULL, NULL, NULL, NULL,
++ NULL, NULL, NULL);
++}
++
++static const char *
++sh_find_word_start(const char *buffer, const char *cursor)
++{
++ const char *word_start = buffer;
++
++ while (buffer < cursor) {
++ if (*buffer == '\\')
++ buffer++;
++ else if (strchr(break_chars, *buffer))
++ word_start = buffer + 1;
++
++ buffer++;
++ }
++
++ return word_start;
++}
++
++
++static char *
++sh_quote(const char *str)
++{
++ const char *src;
++ int extra_len = 0;
++ char *quoted_str, *dst;
++
++ if (*str == '-' || *str == '+')
++ extra_len += 2;
++ for (src = str; *src != '\0'; src++)
++ if (strchr(break_chars, *src) ||
++ strchr(extra_quote_chars, *src))
++ extra_len++;
++
++ quoted_str = malloc(sizeof(*quoted_str) *
++ (strlen(str) + extra_len + 1));
++ if (quoted_str == NULL)
++ return NULL;
++
++ dst = quoted_str;
++ if (*str == '-' || *str == '+')
++ *dst++ = '.', *dst++ = '/';
++ for (src = str; *src != '\0'; src++) {
++ if (strchr(break_chars, *src) ||
++ strchr(extra_quote_chars, *src))
++ *dst++ = '\\';
++ *dst++ = *src;
++ }
++ *dst = '\0';
++
++ return quoted_str;
++}
++
++
++static char *
++sh_dequote(const char *str)
++{
++ char *dequoted_str, *dst;
++
++ /* save extra space to replace \~ with ./~ */
++ dequoted_str = malloc(sizeof(*dequoted_str) * (strlen(str) + 1 + 1));
++ if (dequoted_str == NULL)
++ return NULL;
++
++ dst = dequoted_str;
++
++ /* dequote \~ at start as ./~ */
++ if (*str == '\\' && str[1] == '~') {
++ str++;
++ *dst++ = '.';
++ *dst++ = '/';
++ }
++
++ while (*str) {
++ if (*str == '\\')
++ str++;
++ if (*str)
++ *dst++ = *str++;
++ }
++ *dst = '\0';
++
++ return dequoted_str;
++}
++
++
++/*
++ * completion function using sh quoting rules; for key binding
++ */
++/* ARGSUSED */
++unsigned char
++_el_fn_sh_complete(EditLine *el, int ch __attribute__((__unused__)))
++{
++ return (unsigned char)fn_complete(el, NULL, NULL,
++ break_chars, NULL, NULL, 100,
++ NULL, NULL, NULL, NULL,
++ sh_find_word_start, sh_dequote, sh_quote);
+ }
+
+--- libedit-20170329-3.1/src/readline.c 2017-03-29 21:15:04.000000000 +0300
++++ libedit-20170329-3.1/src/readline.c 2017-05-21 02:24:57.000000000 +0300
+@@ -1869,7 +1869,7 @@
+ _rl_completion_append_character_function,
+ (size_t)rl_completion_query_items,
+ &rl_completion_type, &rl_attempted_completion_over,
+- &rl_point, &rl_end);
++ &rl_point, &rl_end, NULL, NULL, NULL);
+
+
+ }
+
+--- libedit-20170329-3.1/src/histedit.h 2017-03-29 21:08:21.000000000 +0300
++++ libedit-20170329-3.1/src/histedit.h 2017-05-21 02:32:04.000000000 +0300
+@@ -113,6 +113,7 @@
+ int el_set(EditLine *, int, ...);
+ int el_get(EditLine *, int, ...);
+ unsigned char _el_fn_complete(EditLine *, int);
++unsigned char _el_fn_sh_complete(EditLine *, int);
+
+ /*
+ * el_set/el_get parameters
+
+--- libedit-20170329-3.1/src/filecomplete.h 2017-03-29 21:08:21.000000000 +0300
++++ libedit-20170329-3.1/src/filecomplete.h 2017-05-21 02:32:27.000000000 +0300
+@@ -35,7 +35,10 @@
+ char *(*)(const char *, int),
+ char **(*)(const char *, int, int),
+ const wchar_t *, const wchar_t *, const char *(*)(const char *), size_t,
+- int *, int *, int *, int *);
++ int *, int *, int *, int *,
++ const char *(*)(const char *, const char *),
++ char *(*)(const char *),
++ char *(*)(const char *));
+
+ void fn_display_match_list(EditLine *, char **, size_t, size_t);
+ char *fn_tilde_expand(const char *);
diff --git a/dev-libs/libedit/files/libedit-20170329.3.1-ncursesprivate.patch b/dev-libs/libedit/files/libedit-20170329.3.1-ncursesprivate.patch
new file mode 100644
index 000000000000..1d5432fac0be
--- /dev/null
+++ b/dev-libs/libedit/files/libedit-20170329.3.1-ncursesprivate.patch
@@ -0,0 +1,10 @@
+--- libedit-20170329-3.1/libedit.pc.in 2017-03-29 21:08:21.000000000 +0300
++++ libedit-20170329-3.1/libedit.pc.in 2017-05-21 01:28:55.000000000 +0300
+@@ -7,5 +7,6 @@
+ Description: command line editor library provides generic line editing, history, and tokenization functions.
+ Version: @VERSION@
+ Requires:
+-Libs: -L${libdir} -ledit @LIBS@
++Libs: -L${libdir} -ledit
++Libs.private: @LIBS@
+ Cflags: -I${includedir} -I${includedir}/editline
diff --git a/dev-libs/libedit/files/libedit-20170329.3.1-tinfo.patch b/dev-libs/libedit/files/libedit-20170329.3.1-tinfo.patch
new file mode 100644
index 000000000000..e52b2559aa75
--- /dev/null
+++ b/dev-libs/libedit/files/libedit-20170329.3.1-tinfo.patch
@@ -0,0 +1,30 @@
+From 7aa660fd9d446567d3280765ba2a50a46b2a9159 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Mon, 12 Jun 2017 21:36:54 +0200
+Subject: [PATCH] configure: Support -ltinfo as split in newer ncurses
+
+The newer versions of ncurses support building terminfo routines
+as a split -ltinfo library. Account for that by adding this library
+to the search list.
+---
+ configure.ac | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index 9a571b2..5d714b5 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -49,7 +49,9 @@ EL_MANTYPE
+ AC_CHECK_LIB(ncurses, tgetent,,
+ [AC_CHECK_LIB(curses, tgetent,,
+ [AC_CHECK_LIB(termcap, tgetent,,
+- [AC_MSG_ERROR([libncurses, libcurses, or libtermcap is required!])]
++ [AC_CHECK_LIB(tinfo, tgetent,,
++ [AC_MSG_ERROR([libncurses, libcurses, libtermcap or libtinfo is required!])]
++ )]
+ )]
+ )]
+ )
+--
+2.13.1
+
diff --git a/dev-libs/libedit/files/libedit-ncursesprivate.patch b/dev-libs/libedit/files/libedit-ncursesprivate.patch
new file mode 100644
index 000000000000..0af9b1b882a3
--- /dev/null
+++ b/dev-libs/libedit/files/libedit-ncursesprivate.patch
@@ -0,0 +1,13 @@
+Index: libedit-20110709-3.0/libedit.pc.in
+===================================================================
+--- libedit-20110709-3.0.orig/libedit.pc.in
++++ libedit-20110709-3.0/libedit.pc.in
+@@ -7,6 +7,7 @@ Name: libedit
+ Description: command line editor library provides generic line editing, history, and tokenization functions.
+ Version: @VERSION@
+ Requires:
+-Libs: -L${libdir} -ledit @LIBS@
++Libs: -L${libdir} -ledit
++Libs.private: @LIBS@
+ Cflags: -I${includedir} -I${includedir}/editline
+
diff --git a/dev-libs/libedit/libedit-20130712.3.1.ebuild b/dev-libs/libedit/libedit-20130712.3.1.ebuild
new file mode 100644
index 000000000000..8f62738565c4
--- /dev/null
+++ b/dev-libs/libedit/libedit-20130712.3.1.ebuild
@@ -0,0 +1,49 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit eutils toolchain-funcs versionator base multilib-minimal
+
+MY_PV=$(get_major_version)-$(get_after_major_version)
+MY_P=${PN}-${MY_PV}
+
+DESCRIPTION="BSD replacement for libreadline"
+HOMEPAGE="http://www.thrysoee.dk/editline/"
+SRC_URI="http://www.thrysoee.dk/editline/${MY_P}.tar.gz"
+
+LICENSE="BSD-2"
+SLOT="0"
+KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
+IUSE="static-libs"
+
+DEPEND=">=sys-libs/ncurses-5.9-r3[static-libs?,${MULTILIB_USEDEP}]
+ !<=sys-freebsd/freebsd-lib-6.2_rc1"
+
+RDEPEND=${DEPEND}
+
+S="${WORKDIR}/${MY_P}"
+
+PATCHES=(
+ "${FILESDIR}/${PN}-ncursesprivate.patch"
+ "${FILESDIR}/${PN}-20100424.3.0-bsd.patch"
+ "${FILESDIR}/${PN}-20110709.3.0-weak-reference.patch"
+ "${FILESDIR}/${PN}-20120311-3.0-el_fn_sh_complete.patch"
+ )
+
+multilib_src_configure() {
+ ECONF_SOURCE="${S}" econf \
+ $(use_enable static-libs static) \
+ --enable-widec \
+ --enable-fast-install
+}
+
+multilib_src_install() {
+ emake DESTDIR="${D}" install
+ gen_usr_ldscript -a edit
+}
+
+multilib_src_install_all() {
+ einstalldocs
+ prune_libtool_files --all
+}
diff --git a/dev-libs/libedit/libedit-20170329.3.1.ebuild b/dev-libs/libedit/libedit-20170329.3.1.ebuild
new file mode 100644
index 000000000000..bb9cfbd59ae9
--- /dev/null
+++ b/dev-libs/libedit/libedit-20170329.3.1.ebuild
@@ -0,0 +1,54 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="6"
+inherit autotools multilib-minimal toolchain-funcs
+
+MY_PV=${PV/./-}
+MY_P=${PN}-${MY_PV}
+
+DESCRIPTION="BSD replacement for libreadline"
+HOMEPAGE="http://thrysoee.dk/editline/"
+SRC_URI="http://thrysoee.dk/editline/${MY_P}.tar.gz"
+
+LICENSE="BSD-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
+IUSE="static-libs"
+
+DEPEND=">=sys-libs/ncurses-5.9-r3[static-libs?,${MULTILIB_USEDEP}]
+ !<=sys-freebsd/freebsd-lib-6.2_rc1"
+
+RDEPEND=${DEPEND}
+
+S="${WORKDIR}/${MY_P}"
+
+PATCHES=(
+ "${FILESDIR}/${P}-ncursesprivate.patch"
+ "${FILESDIR}/${P}-el_fn_sh_complete.patch"
+ "${FILESDIR}/${P}-tinfo.patch"
+)
+
+src_prepare() {
+ default
+ eautoreconf
+}
+
+multilib_src_configure() {
+ ECONF_SOURCE="${S}" econf \
+ $(use_enable static-libs static) \
+ --enable-widec \
+ --enable-fast-install
+}
+
+multilib_src_install() {
+ emake DESTDIR="${D}" install
+ gen_usr_ldscript -a edit
+}
+
+multilib_src_install_all() {
+ einstalldocs
+ find "${D}" -name '*.la' -delete || die
+ # file collission with sys-libs/readline
+ rm "${ED%/}/usr/share/man/man3/history.3" || die
+}
diff --git a/dev-libs/libedit/metadata.xml b/dev-libs/libedit/metadata.xml
new file mode 100644
index 000000000000..21c15532409c
--- /dev/null
+++ b/dev-libs/libedit/metadata.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+</maintainer>
+<longdescription>
+GNU Readline is cool, but BSD Readline is cooler :)
+Thus here is libedit by the NetBSD folks!
+The glibc/bsdlibc stuff comes from the debian tarball, thanks to them too :)
+The patch is handcrafted with a few ideas from libedit.sf.net and a few ideas
+from the debian package. This patch aims to be as small as possible (so as
+to make future cvs snapshots cake).
+</longdescription>
+</pkgmetadata>