[Libguestfs] [PATCH 2/4] Mac OS X: implement readline functions.

Richard W.M. Jones rjones at redhat.com
Sun Mar 21 19:34:52 UTC 2010


-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top
-------------- next part --------------
>From 86da1108bccaefdfec04f5ec868569cf658050b7 Mon Sep 17 00:00:00 2001
From: Richard Jones <rich at koneko.home.annexia.org>
Date: Sun, 21 Mar 2010 19:15:40 +0000
Subject: [PATCH 2/4] Mac OS X: implement readline functions.

OS X has an older version of readline with some differences
in the names of functions.
---
 configure.ac     |    7 ++++++-
 fish/fish.c      |    4 ++++
 src/generator.ml |   15 ++++++++++++---
 3 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index cfad704..086b00c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -440,7 +440,12 @@ AS_IF([test "x$with_readline" != xno],
          AC_MSG_FAILURE(
              [--with-readline was given, but test for readline failed])
          fi
-        ], -lncurses)])
+        ], -lncurses)
+     old_LIBS="$LIBS"
+     LIBS="$LIBS $LIBREADLINE"
+     AC_CHECK_FUNCS([append_history completion_matches rl_completion_matches])
+     LIBS="$old_LIBS"
+    ])
 
 dnl For i18n.
 AM_GNU_GETTEXT([external])
diff --git a/fish/fish.c b/fish/fish.c
index 32d6f9f..2411f72 100644
--- a/fish/fish.c
+++ b/fish/fish.c
@@ -1304,7 +1304,11 @@ cleanup_readline (void)
     }
     close (fd);
 
+#ifdef HAVE_APPEND_HISTORY
     (void) append_history (nr_history_lines, histfile);
+#else
+    (void) write_history (histfile);
+#endif
   }
 #endif
 }
diff --git a/src/generator.ml b/src/generator.ml
index ba883ea..551b6bc 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -7459,7 +7459,16 @@ generator (const char *text, int state)
 
 #endif /* HAVE_LIBREADLINE */
 
-char **do_completion (const char *text, int start, int end)
+#ifdef HAVE_RL_COMPLETION_MATCHES
+#define RL_COMPLETION_MATCHES rl_completion_matches
+#else
+#ifdef HAVE_COMPLETION_MATCHES
+#define RL_COMPLETION_MATCHES completion_matches
+#endif
+#endif /* else just fail if we don't have either symbol */
+
+char **
+do_completion (const char *text, int start, int end)
 {
   char **matches = NULL;
 
@@ -7467,9 +7476,9 @@ char **do_completion (const char *text, int start, int end)
   rl_completion_append_character = ' ';
 
   if (start == 0)
-    matches = rl_completion_matches (text, generator);
+    matches = RL_COMPLETION_MATCHES (text, generator);
   else if (complete_dest_paths)
-    matches = rl_completion_matches (text, complete_dest_paths_generator);
+    matches = RL_COMPLETION_MATCHES (text, complete_dest_paths_generator);
 #endif
 
   return matches;
-- 
1.6.4.1



More information about the Libguestfs mailing list