bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* [PATCH] readline: Support libedit.
@ 2013-10-15 20:13 Mats Erik Andersson
  2013-10-16 20:08 ` Ludovic Courtès
  0 siblings, 1 reply; 8+ messages in thread
From: Mats Erik Andersson @ 2013-10-15 20:13 UTC (permalink / raw
  To: bug-gnulib

[-- Attachment #1: Type: text/plain, Size: 381 bytes --]

Hello there,

I would like to see the module readline to access also libedit,
should libreadline be missing on a particular system. The patch
contained here successfully links against libedit on NetBSD and
Debian GNU/kFreeBSD. Likewise, it still behaves correctly with
libreadline on GNU/Linux, FreeBSD, DragonFlyBSD, OpenBSD, and
OpenSolaris.

Best regards,
  Mats Erik Andersson

[-- Attachment #2: 0001-readline-Support-libedit.patch --]
[-- Type: text/x-diff, Size: 6388 bytes --]

>From 21ac3c7a026b2b4be04bdbe62e0f7d1b0e1a0245 Mon Sep 17 00:00:00 2001
From: Mats Erik Andersson <gnu@gisladisker.se>
Date: Tue, 15 Oct 2013 22:02:26 +0200
Subject: [PATCH] readline: Support libedit.

Allow libedit as an alternate source of readline().
Debian and NetBSD benefit from this extension.
* m4/readline.m4: Make libedit into a second choice,
should libreadline be missing.
* modules/readline: Update conditions to accept libedit.
---
 ChangeLog        |   18 +++++++++++++++++
 lib/readline.h   |    2 ++
 m4/readline.m4   |   58 +++++++++++++++++++++++++++++++++++++++++++++++++-----
 modules/readline |    4 ++--
 4 filer ändrade, 75 tillägg(+), 7 borttagningar(-)

diff --git a/ChangeLog b/ChangeLog
index c70f1fe..b6a0cb7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2013-10-15  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	readline: Support libedit.
+	Look for readline() in libedit, if it does not exist
+	within libreadline.
+	* lib/readline.h [HAVE_EDITLINE_READLINE_H]:
+	Include <editline/readline.h>.
+	* m4/readline.m4 (gl_FUNC_READLINE): Check for libedit,
+	and headers <editline/readline.h>, <editline/history.h>.
+	Check for readline in libedit.
+	(HAVE_LIBREADLINE, HAVE_LIBEDIT): New macros, stating that
+	readline exists in libreadline, or in libedit.  The macro
+	HAVE_READLINE still indicates the existence of readline().
+	(LIBEDIT, LTLIBEDIT): New local variables.
+	* modules/readline (Depends-on): Expand condition for `getline'
+	to also test gl_cv_lib_edit.
+	(configure.ac): Add test on gl_cv_lib_edit.
+
 2013-10-14  Paul Eggert  <eggert@cs.ucla.edu>
 
 	acl: allow cross-compilation to Gentoo
diff --git a/lib/readline.h b/lib/readline.h
index af91e10..f3e0853 100644
--- a/lib/readline.h
+++ b/lib/readline.h
@@ -23,6 +23,8 @@
    <stdio.h> itself. */
 # include <stdio.h>
 # include <readline/readline.h>
+#elif defined HAVE_EDITLINE_READLINE_H
+# include <editline/readline.h>
 #else
 /* Prints a prompt PROMPT and then reads and returns a single line of
    text from the user.  If PROMPT is NULL or the empty string, no
diff --git a/m4/readline.m4 b/m4/readline.m4
index dfc48a0..b734ed1 100644
--- a/m4/readline.m4
+++ b/m4/readline.m4
@@ -1,4 +1,4 @@
-# readline.m4 serial 10
+# readline.m4 serial 11
 dnl Copyright (C) 2005-2006, 2009-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -17,6 +17,14 @@ AC_DEFUN([gl_FUNC_READLINE],
   dnl INCREADLINE accordingly.
   AC_LIB_LINKFLAGS_BODY([readline])
 
+  dnl Likewise for libedit.
+  AC_LIB_LINKFLAGS_BODY([edit])
+
+  dnl The headers are needed to distinguish alternate
+  dnl implementations, so check for them now.
+  AC_CHECK_HEADERS([readline/readline.h readline/history.h \
+                    editline/readline.h editline/history.h])
+
   dnl Add $INCREADLINE to CPPFLAGS before performing the following checks,
   dnl because if the user has installed libreadline and not disabled its use
   dnl via --without-libreadline-prefix, he wants to use it. The AC_LINK_IFELSE
@@ -24,7 +32,7 @@ AC_DEFUN([gl_FUNC_READLINE],
   am_save_CPPFLAGS="$CPPFLAGS"
   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCREADLINE])
 
-  AC_CACHE_CHECK([for readline], [gl_cv_lib_readline], [
+  AC_CACHE_CHECK([for libreadline], [gl_cv_lib_readline], [
     gl_cv_lib_readline=no
     am_save_LIBS="$LIBS"
     dnl On some systems, -lreadline doesn't link without an additional
@@ -53,8 +61,40 @@ AC_DEFUN([gl_FUNC_READLINE],
     LIBS="$am_save_LIBS"
   ])
 
+  dnl Check whether libedit exists and works.
+  dnl The readline emulation comes in two flavours:
+  dnl
+  dnl  * original by NetBSD offers <readline/readline.h>,
+  dnl  * while Debian's variant uses <editline/readline.h>.
+  dnl
+  CPPFLAGS="$am_save_CPPFLAGS"
+  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCEDIT])
+
+  AC_CACHE_CHECK([for libedit], [gl_cv_lib_edit], [
+    gl_cv_lib_edit=no
+    am_save_LIBS="$LIBS"
+    LIBS="$am_save_LIBS $LIBEDIT"
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
+#ifdef HAVE_READLINE_READLINE_H
+# include <readline/readline.h>
+#elif defined HAVE_EDITLINE_READLINE_H
+# include <editline/readline.h>
+#endif]],
+          [[readline((char*)0);]])],
+        [gl_cv_lib_edit="yes"])
+    LIBS="$am_save_LIBS"
+  ])
+
+  dnl Is the function readline() located by now?
+  if test "$gl_cv_lib_readline" != no ||
+     test "$gl_cv_lib_edit" != no; then
+    AC_DEFINE([HAVE_READLINE], [1], [Define if you have the readline function.])
+  fi
+
+  dnl Unravel dependency on implementation.  Prefer libreadline
+  dnl over libedit.
   if test "$gl_cv_lib_readline" != no; then
-    AC_DEFINE([HAVE_READLINE], [1], [Define if you have the readline library.])
+    AC_DEFINE([HAVE_LIBREADLINE], [1], [Define if you have the readline library.])
     extra_lib=`echo "$gl_cv_lib_readline" | sed -n -e 's/yes, requires //p'`
     if test -n "$extra_lib"; then
       LIBREADLINE="$LIBREADLINE $extra_lib"
@@ -62,17 +102,25 @@ AC_DEFUN([gl_FUNC_READLINE],
     fi
     AC_MSG_CHECKING([how to link with libreadline])
     AC_MSG_RESULT([$LIBREADLINE])
+  elif test "$gl_cv_lib_edit" != no; then
+    AC_DEFINE([HAVE_LIBEDIT], [1], [Define if you have the edit library.])
+
+    dnl We have a working replacement for libreadline, so use it.
+    LIBREADLINE="$LIBEDIT"
+    LTLIBREADLINE="$LTLIBEDIT"
+    AC_MSG_CHECKING([how to link with libedit])
+    AC_MSG_RESULT([$LIBEDIT])
   else
     dnl If $LIBREADLINE didn't lead to a usable library, we don't
     dnl need $INCREADLINE either.
     CPPFLAGS="$am_save_CPPFLAGS"
     LIBREADLINE=
     LTLIBREADLINE=
+    LIBEDIT=
+    LTLIBEDIT=
   fi
   AC_SUBST([LIBREADLINE])
   AC_SUBST([LTLIBREADLINE])
-
-  AC_CHECK_HEADERS([readline/readline.h readline/history.h])
 ])
 
 # Prerequisites of lib/readline.c.
diff --git a/modules/readline b/modules/readline
index 9cee3bb..a334c43 100644
--- a/modules/readline
+++ b/modules/readline
@@ -8,11 +8,11 @@ m4/readline.m4
 
 Depends-on:
 havelib
-getline         [test "$gl_cv_lib_readline" = no]
+getline         [test "$gl_cv_lib_readline" = no && test "$gl_cv_lib_edit" = no]
 
 configure.ac:
 gl_FUNC_READLINE
-if test "$gl_cv_lib_readline" = no; then
+if test "$gl_cv_lib_readline" = no && test "$gl_cv_lib_edit" = no; then
   AC_LIBOBJ([readline])
   gl_PREREQ_READLINE
 fi
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] readline: Support libedit.
  2013-10-15 20:13 [PATCH] readline: Support libedit Mats Erik Andersson
@ 2013-10-16 20:08 ` Ludovic Courtès
  2013-10-16 21:26   ` Eric Blake
  2013-10-16 21:31   ` Mats Erik Andersson
  0 siblings, 2 replies; 8+ messages in thread
From: Ludovic Courtès @ 2013-10-16 20:08 UTC (permalink / raw
  To: bug-gnulib

Mats Erik Andersson <gnu@gisladisker.se> skribis:

> I would like to see the module readline to access also libedit,
> should libreadline be missing on a particular system. The patch
> contained here successfully links against libedit on NetBSD and
> Debian GNU/kFreeBSD. Likewise, it still behaves correctly with
> libreadline on GNU/Linux, FreeBSD, DragonFlyBSD, OpenBSD, and
> OpenSolaris.

Isn’t libedit supposed to be a clone of Readline just for the sake of
avoiding the GPL?

Why not let its maintainers fix it, if they really want it to behave
like a drop-in replacement?

Thanks,
Ludo’.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] readline: Support libedit.
  2013-10-16 20:08 ` Ludovic Courtès
@ 2013-10-16 21:26   ` Eric Blake
  2013-10-16 21:50     ` Ludovic Courtès
                       ` (2 more replies)
  2013-10-16 21:31   ` Mats Erik Andersson
  1 sibling, 3 replies; 8+ messages in thread
From: Eric Blake @ 2013-10-16 21:26 UTC (permalink / raw
  To: Ludovic Courtès, bug-gnulib, Mats Erik Andersson

[-- Attachment #1: Type: text/plain, Size: 2586 bytes --]

On 10/16/2013 02:08 PM, Ludovic Courtès wrote:
> Mats Erik Andersson <gnu@gisladisker.se> skribis:
> 
>> I would like to see the module readline to access also libedit,
>> should libreadline be missing on a particular system. The patch
>> contained here successfully links against libedit on NetBSD and
>> Debian GNU/kFreeBSD. Likewise, it still behaves correctly with
>> libreadline on GNU/Linux, FreeBSD, DragonFlyBSD, OpenBSD, and
>> OpenSolaris.
> 
> Isn’t libedit supposed to be a clone of Readline just for the sake of
> avoiding the GPL?
> 
> Why not let its maintainers fix it, if they really want it to behave
> like a drop-in replacement?

libedit does NOT support history; as such, it is only a drop-in
replacement for a subset of the full power of GNU readline.  It may
indeed be an appropriate use for gnulib's readline module (which
fortunately only guarantees a subset of libreadline that happens to be
met by libedit), but I'm not sure if we would be setting a poor
precedent by making it easier to shift away from GPL over to BSD
licensing, as the BSD license does not guarantee the same set of freedoms.

In at least the case of libvirt, at one point in the past [1], the virsh
binary had a licensing violation by linking to both libreadline (GPLv3+)
and a libvirt.so containing virtualbox code (LGPLv2-only) at the same
time (those two licenses are incompatible).  One of the ideas for fixing
the problem was to use libedit instead of libreadline (because BSD
licensing of libedit would have allowed a GPLv2 virsh), but it fell flat
because libedit provided too few functions for what virsh was trying to
use.  The license violation was solved in another manner [2] by moving
virtualbox code out of libvirt.so and into the libvirtd daemon
executable, leaving libvirt.so to be LGPLv2+ rather than LGPLv2-only,
where virsh is then GPLv3 when using readline.
[1]https://www.redhat.com/archives/libvir-list/2013-May/msg00030.html
[2]https://www.redhat.com/archives/libvir-list/2013-May/msg01074.html

Oh, and while on the topic of license interactions: gnutls recently
started linking against nettle, but nettle links against gmp which is
now LGPLv3+; thus, even though the code base of gnutls still claims to
use LGPLv2+, gnutls can no longer be linked into programs that are
[L]GPLv2-only, at least not without forking a version of gmp from its
LGPLv2+ days.
https://bugzilla.redhat.com/show_bug.cgi?id=986347

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] readline: Support libedit.
  2013-10-16 20:08 ` Ludovic Courtès
  2013-10-16 21:26   ` Eric Blake
@ 2013-10-16 21:31   ` Mats Erik Andersson
  2013-10-16 22:03     ` Ludovic Courtès
  1 sibling, 1 reply; 8+ messages in thread
From: Mats Erik Andersson @ 2013-10-16 21:31 UTC (permalink / raw
  To: bug-gnulib

onsdag den 16 oktober 2013 klockan 22:08 skrev Ludovic Courtès detta:
> Mats Erik Andersson <gnu@gisladisker.se> skribis:
> 
> > I would like to see the module readline to access also libedit,
> > should libreadline be missing on a particular system. The patch
> > contained here successfully links against libedit on NetBSD and
> > Debian GNU/kFreeBSD. Likewise, it still behaves correctly with
> > libreadline on GNU/Linux, FreeBSD, DragonFlyBSD, OpenBSD, and
> > OpenSolaris.
> 
> Isn???t libedit supposed to be a clone of Readline just for the sake of
> avoiding the GPL?

No! Debian presently offers libreadline6, libedit2, and libeditline0.
The runtime packages of these are, in the same order, 158 kB, 72 kB,
and 11 kB in size. It is true that libedit originates in NetBSD, but I
do not see the relevance of this fact to gnulib. On the other hand,
DragonFlyBSD, FreeBSD, and OpenBSD bring libreadline by default, so
the argument against GPL seems void in this setting.

The module "readline" (not authored by me) offers a crippled readline(),
which is hardly more than getline() in its abilities, every time it
cannot locate libreadline. I personally find it superior, could that
module access the function readline() in more libraries than the heavy
weight champion libreadline.

My patch is in all essence only improving the m4 script to be better
informed of the alternatives.

I can add, that in the GNU Inetutils project, the module "readline"
is useless precisely of the above reason.

Regards,
  Mats Erik Andersson


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] readline: Support libedit.
  2013-10-16 21:26   ` Eric Blake
@ 2013-10-16 21:50     ` Ludovic Courtès
  2013-10-17  9:19     ` Mats Erik Andersson
  2013-10-17 22:39     ` Karl Berry
  2 siblings, 0 replies; 8+ messages in thread
From: Ludovic Courtès @ 2013-10-16 21:50 UTC (permalink / raw
  To: Eric Blake; +Cc: Mats Erik Andersson, bug-gnulib

Eric Blake <eblake@redhat.com> skribis:

> On 10/16/2013 02:08 PM, Ludovic Courtès wrote:
>> Mats Erik Andersson <gnu@gisladisker.se> skribis:
>> 
>>> I would like to see the module readline to access also libedit,
>>> should libreadline be missing on a particular system. The patch
>>> contained here successfully links against libedit on NetBSD and
>>> Debian GNU/kFreeBSD. Likewise, it still behaves correctly with
>>> libreadline on GNU/Linux, FreeBSD, DragonFlyBSD, OpenBSD, and
>>> OpenSolaris.
>> 
>> Isn’t libedit supposed to be a clone of Readline just for the sake of
>> avoiding the GPL?
>> 
>> Why not let its maintainers fix it, if they really want it to behave
>> like a drop-in replacement?
>
> libedit does NOT support history; as such, it is only a drop-in
> replacement for a subset of the full power of GNU readline.  It may
> indeed be an appropriate use for gnulib's readline module (which
> fortunately only guarantees a subset of libreadline that happens to be
> met by libedit), but I'm not sure if we would be setting a poor
> precedent by making it easier to shift away from GPL over to BSD
> licensing, as the BSD license does not guarantee the same set of freedoms.

Indeed.

[...]

> Oh, and while on the topic of license interactions: gnutls recently
> started linking against nettle, but nettle links against gmp which is
> now LGPLv3+; thus, even though the code base of gnutls still claims to
> use LGPLv2+, gnutls can no longer be linked into programs that are
> [L]GPLv2-only, at least not without forking a version of gmp from its
> LGPLv2+ days.
> https://bugzilla.redhat.com/show_bug.cgi?id=986347

Not to mention the use of v3+ Gnulib modules:
<http://thread.gmane.org/gmane.comp.encryption.gpg.gnutls.devel/6869>.

Ludo’.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] readline: Support libedit.
  2013-10-16 21:31   ` Mats Erik Andersson
@ 2013-10-16 22:03     ` Ludovic Courtès
  0 siblings, 0 replies; 8+ messages in thread
From: Ludovic Courtès @ 2013-10-16 22:03 UTC (permalink / raw
  To: bug-gnulib

Mats Erik Andersson <gnu@gisladisker.se> skribis:

> I can add, that in the GNU Inetutils project, the module "readline"
> is useless precisely of the above reason.

Given that Inetutils is unlikely to be used on non-GNU systems, what
about supporting just Readline?

Thanks,
Ludo’.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] readline: Support libedit.
  2013-10-16 21:26   ` Eric Blake
  2013-10-16 21:50     ` Ludovic Courtès
@ 2013-10-17  9:19     ` Mats Erik Andersson
  2013-10-17 22:39     ` Karl Berry
  2 siblings, 0 replies; 8+ messages in thread
From: Mats Erik Andersson @ 2013-10-17  9:19 UTC (permalink / raw
  To: bug-gnulib

onsdag den 16 oktober 2013 klockan 15:26 skrev Eric Blake detta:
> On 10/16/2013 02:08 PM, Ludovic Courtès wrote:
> > 
> > Isn???t libedit supposed to be a clone of Readline just for the sake of
> > avoiding the GPL?
> > 
> > Why not let its maintainers fix it, if they really want it to behave
> > like a drop-in replacement?
> 
> libedit does NOT support history; as such, it is only a drop-in

This cannot be be true. How come our inetutils-ftp gives history
using add_history() when building on my GNU/kFreeBSD system where
libedit is used? Or, do you mean some persistent history file kept
in the user's home directory?

Regards,
  Mats Erik Andersson


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] readline: Support libedit.
  2013-10-16 21:26   ` Eric Blake
  2013-10-16 21:50     ` Ludovic Courtès
  2013-10-17  9:19     ` Mats Erik Andersson
@ 2013-10-17 22:39     ` Karl Berry
  2 siblings, 0 replies; 8+ messages in thread
From: Karl Berry @ 2013-10-17 22:39 UTC (permalink / raw
  To: bug-gnulib

     a licensing violation by linking to both libreadline (GPLv3+)
     and a libvirt.so containing virtualbox code (LGPLv2-only) at the same
     time (those two licenses are incompatible).  

For the record ... as far as I know, LGPLv2, both -only and -later, is
compatible with GPLv-anything (in contrast to LGPLv-anything), due to
the conversion clause.  I quote from
http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html:

  3. You may opt to apply the terms of the ordinary GNU General Public
  License instead of this License to a given copy of the Library.  To do
  this, you must alter all the notices that refer to this License, so
  that they refer to the ordinary GNU General Public License, version 2,
  instead of to this License.  (If a newer version than version 2 of the
  ordinary GNU General Public License has appeared, then you can specify
  that version instead if you wish.)  [...]

k


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-10-17 22:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-15 20:13 [PATCH] readline: Support libedit Mats Erik Andersson
2013-10-16 20:08 ` Ludovic Courtès
2013-10-16 21:26   ` Eric Blake
2013-10-16 21:50     ` Ludovic Courtès
2013-10-17  9:19     ` Mats Erik Andersson
2013-10-17 22:39     ` Karl Berry
2013-10-16 21:31   ` Mats Erik Andersson
2013-10-16 22:03     ` Ludovic Courtès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).