aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ss
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2003-04-11 12:56:27 -0400
committerTheodore Ts'o <tytso@mit.edu>2003-04-11 12:56:27 -0400
commit9d51b6191bded9ee65176c6acc6a68264c311593 (patch)
tree8f8f1d23fb5c1a98ac846dfb1a4790661f8492f9 /lib/ss
parent417781aff16157a8e8a31d63f235bd7e6c48feeb (diff)
downloadandroid_external_e2fsprogs-9d51b6191bded9ee65176c6acc6a68264c311593.tar.gz
android_external_e2fsprogs-9d51b6191bded9ee65176c6acc6a68264c311593.tar.bz2
android_external_e2fsprogs-9d51b6191bded9ee65176c6acc6a68264c311593.zip
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.
Diffstat (limited to 'lib/ss')
-rw-r--r--lib/ss/ChangeLog7
-rw-r--r--lib/ss/get_readline.c37
2 files changed, 39 insertions, 5 deletions
diff --git a/lib/ss/ChangeLog b/lib/ss/ChangeLog
index fe59b6a1..59f0941c 100644
--- a/lib/ss/ChangeLog
+++ b/lib/ss/ChangeLog
@@ -1,3 +1,10 @@
+2003-04-11 root <tytso@mit.edu>
+
+ * 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 <tytso@mit.edu>
* 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 55b8b47a..d9499e6d 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;