[libvirt] [PATCH] tools: Work around ancient readline

Michal Privoznik posted 1 patch 6 years, 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/f7deea5242372fa5f3cf141a6860e976aa60c19a.1511458654.git.mprivozn@redhat.com
tools/vsh.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
[libvirt] [PATCH] tools: Work around ancient readline
Posted by Michal Privoznik 6 years, 4 months ago
My latest commit of a785186446de785d uncovered a problem we fixed
in 9eb23fe2 but then reverted in 834c5720e443. Turns out, some
systems (I'm looking at you OS X) have ancient readline with
broken header file.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---

Pushed as build breaker.

 tools/vsh.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/tools/vsh.c b/tools/vsh.c
index 472438ead..e878119b9 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -2892,6 +2892,7 @@ vshReadlineInit(vshControl *ctl)
     int ret = -1;
     char *histsize_env = NULL;
     const char *histsize_str = NULL;
+    const char *break_characters = " \t\n\\`@$><=;|&{(";
 
     /* Opaque data for autocomplete callbacks. */
     autoCompleteOpaque = ctl;
@@ -2900,12 +2901,20 @@ vshReadlineInit(vshControl *ctl)
      * Work around ancient readline 4.1 (hello Mac OS X),
      * which declared it as 'char *' instead of 'const char *'.
      */
+# if defined(RL_READLINE_VERSION) && RL_READLINE_VERSION > 0x0402
     rl_readline_name = ctl->name;
+# else
+    rl_readline_name = (char *) ctl->name;
+# endif
 
     /* Tell the completer that we want a crack first. */
     rl_attempted_completion_function = vshReadlineCompletion;
 
-    rl_basic_word_break_characters = " \t\n\\`@$><=;|&{(";
+# if defined(RL_READLINE_VERSION) && RL_READLINE_VERSION > 0x0402
+    rl_basic_word_break_characters = break_characters;
+# else
+    rl_basic_word_break_characters = (char *) break_characters;
+# endif
 
     if (virAsprintf(&histsize_env, "%s_HISTSIZE", ctl->env_prefix) < 0)
         goto cleanup;
-- 
2.13.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list