From 9d51b6191bded9ee65176c6acc6a68264c311593 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 11 Apr 2003 12:56:27 -0400 Subject: [PATCH] Use the SS_READLINE_PATH environment variable to control the search for a suitable readine library. As a default, try using libreadline, libedit, and libeditline. --- debian/changelog | 4 +++- lib/ss/ChangeLog | 7 +++++++ lib/ss/get_readline.c | 37 ++++++++++++++++++++++++++++++++----- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/debian/changelog b/debian/changelog index d26fe06..60699ed 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,8 +5,10 @@ e2fsprogs (1.32+1.33-WIP-2003.03.30-3) unstable; urgency=low * Change the sectoin of com_err-dev, ss-dev, uuid-dev, libblkid-dev, e2fslibs-dev to libdevel * Add libblkid1-udeb package for the Debian Installer. + * Use the SS_READLINE_PATH environment variable to control the search + for a suitable readine library. - -- Theodore Y. Ts'o Thu, 10 Apr 2003 00:15:08 -0400 + -- Theodore Y. Ts'o Fri, 11 Apr 2003 12:55:34 -0400 e2fsprogs (1.32+1.33-WIP-2003.03.30-2) unstable; urgency=low diff --git a/lib/ss/ChangeLog b/lib/ss/ChangeLog index fe59b6a..59f0941 100644 --- a/lib/ss/ChangeLog +++ b/lib/ss/ChangeLog @@ -1,3 +1,10 @@ +2003-04-11 root + + * get_readline.c (DEFAULT_LIBPATH): Use the SS_READLINE_PATH + environment variable to control the search for a suitable + readine library. As a default, try using libreadline, + libedit, and libeditline. + 2003-03-30 Theodore Ts'o * pager.c, listen.c, requests.c, list_rqs.c, ct_c.awk, prompt.c, diff --git a/lib/ss/get_readline.c b/lib/ss/get_readline.c index 55b8b47..d9499e6 100644 --- a/lib/ss/get_readline.c +++ b/lib/ss/get_readline.c @@ -35,17 +35,44 @@ static void ss_release_readline(ss_data *info) #endif } +/* Libraries we will try to use for readline/editline functionality */ +#define DEFAULT_LIBPATH "libreadline.so.4:libreadline.so:libedit.so.2:libedit.so:libeditline.so.0:libeditline.so" + void ss_get_readline(int sci_idx) { #ifdef HAVE_DLOPEN - void *handle; + void *handle = NULL; ss_data *info = ss_info(sci_idx); - const char **t; + const char **t, *libpath = 0; + char *tmp, *cp, *next; char **(**completion_func)(const char *, int, int); - if (info->readline_handle || - getenv("SS_NO_READLINE") || - ((handle = dlopen("libreadline.so", RTLD_NOW)) == NULL)) + if (info->readline_handle) + return; + + libpath = getenv("SS_READLINE_PATH"); + if (!libpath) + libpath = DEFAULT_LIBPATH; + if (*libpath == 0 || !strcmp(libpath, "none")) + return; + + tmp = malloc(strlen(libpath)+1); + if (!tmp) + return; + strcpy(tmp, libpath); + for (cp = tmp; cp; cp = next) { + next = strchr(cp, ':'); + if (next) + *next++ = 0; + if (*cp == 0) + continue; + if ((handle = dlopen(cp, RTLD_NOW))) { + /* printf("Using %s for readline library\n", cp); */ + break; + } + } + free(tmp); + if (!handle) return; info->readline_handle = handle; -- 1.8.3.1