Whamcloud - gitweb
Use the SS_READLINE_PATH environment variable to control the search
authorTheodore Ts'o <tytso@mit.edu>
Fri, 11 Apr 2003 16:56:27 +0000 (12:56 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 11 Apr 2003 16:56:27 +0000 (12:56 -0400)
for a suitable readine library.  As a default, try using libreadline,
libedit, and libeditline.

debian/changelog
lib/ss/ChangeLog
lib/ss/get_readline.c

index d26fe06..60699ed 100644 (file)
@@ -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 <tytso@mit.edu>  Thu, 10 Apr 2003 00:15:08 -0400
+ -- Theodore Y. Ts'o <tytso@mit.edu>  Fri, 11 Apr 2003 12:55:34 -0400
 
 e2fsprogs (1.32+1.33-WIP-2003.03.30-2) unstable; urgency=low
 
index fe59b6a..59f0941 100644 (file)
@@ -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, 
index 55b8b47..d9499e6 100644 (file)
@@ -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;