Revision: 936
http://vcs.pcre.org/viewvc?view=rev&revision=936
Author: ph10
Date: 2012-02-25 17:02:23 +0000 (Sat, 25 Feb 2012)
Log Message:
-----------
Add support for linking pcretest with libedit instead of libreadline.
Modified Paths:
--------------
code/trunk/ChangeLog
code/trunk/README
code/trunk/configure.ac
code/trunk/pcretest.c
Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog 2012-02-25 14:57:36 UTC (rev 935)
+++ code/trunk/ChangeLog 2012-02-25 17:02:23 UTC (rev 936)
@@ -57,7 +57,10 @@
13. (*COMMIT) is now correctly confined to within a recursive subpattern call.
+14. It is now possible to link pcretest with libedit as an alternative to
+ libreadline.
+
Version 8.30 04-February-2012
-----------------------------
Modified: code/trunk/README
===================================================================
--- code/trunk/README 2012-02-25 14:57:36 UTC (rev 935)
+++ code/trunk/README 2012-02-25 17:02:23 UTC (rev 936)
@@ -326,16 +326,17 @@
The default value is 20K.
. It is possible to compile pcretest so that it links with the libreadline
- library, by specifying
+ or libedit libraries, by specifying, respectively,
- --enable-pcretest-libreadline
+ --enable-pcretest-libreadline or --enable-pcretest-libedit
If this is done, when pcretest's input is from a terminal, it reads it using
the readline() function. This provides line-editing and history facilities.
Note that libreadline is GPL-licenced, so if you distribute a binary of
- pcretest linked in this way, there may be licensing issues.
+ pcretest linked in this way, there may be licensing issues. These can be
+ avoided by linking with libedit instead.
- Setting this option causes the -lreadline option to be added to the pcretest
+ Enabling libreadline causes the -lreadline option to be added to the pcretest
build. In many operating environments with a sytem-installed readline
library this is sufficient. However, in some environments (e.g. if an
unmodified distribution version of readline is in use), it may be necessary
@@ -880,4 +881,4 @@
Philip Hazel
Email local part: ph10
Email domain: cam.ac.uk
-Last updated: 20 January 2012
+Last updated: 25 February 2012
Modified: code/trunk/configure.ac
===================================================================
--- code/trunk/configure.ac 2012-02-25 14:57:36 UTC (rev 935)
+++ code/trunk/configure.ac 2012-02-25 17:02:23 UTC (rev 936)
@@ -233,6 +233,12 @@
[pcregrep buffer size (default=20480)]),
, with_pcregrep_bufsize=20480)
+# Handle --enable-pcretest-libedit
+AC_ARG_ENABLE(pcretest-libedit,
+ AS_HELP_STRING([--enable-pcretest-libedit],
+ [link pcretest with libedit]),
+ , enable_pcretest_libedit=no)
+
# Handle --enable-pcretest-libreadline
AC_ARG_ENABLE(pcretest-libreadline,
AS_HELP_STRING([--enable-pcretest-libreadline],
@@ -534,33 +540,44 @@
# Check for the availabiity of libreadline
-AC_CHECK_HEADERS([readline/readline.h], [HAVE_READLINE_H=1])
-AC_CHECK_HEADERS([readline/history.h], [HAVE_HISTORY_H=1])
-AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lreadline"],
- [unset ac_cv_lib_readline_readline;
- AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-ltinfo"],
- [unset ac_cv_lib_readline_readline;
- AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lcurses"],
- [unset ac_cv_lib_readline_readline;
- AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lncurses"],
- [unset ac_cv_lib_readline_readline;
- AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lncursesw"],
- [unset ac_cv_lib_readline_readline;
- AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-ltermcap"],
- [LIBREADLINE=""],
- [-ltermcap])],
- [-lncursesw])],
- [-lncurses])],
- [-lcurses])],
- [-ltinfo])])
-AC_SUBST(LIBREADLINE)
-if test -n "$LIBREADLINE"; then
- if test "$LIBREADLINE" != "-lreadline"; then
- echo "-lreadline needs $LIBREADLINE"
- LIBREADLINE="-lreadline $LIBREADLINE"
- fi
+if test "$enable_pcretest_libreadline" = "yes"; then
+ AC_CHECK_HEADERS([readline/readline.h], [HAVE_READLINE_H=1])
+ AC_CHECK_HEADERS([readline/history.h], [HAVE_HISTORY_H=1])
+ AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lreadline"],
+ [unset ac_cv_lib_readline_readline;
+ AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-ltinfo"],
+ [unset ac_cv_lib_readline_readline;
+ AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lcurses"],
+ [unset ac_cv_lib_readline_readline;
+ AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lncurses"],
+ [unset ac_cv_lib_readline_readline;
+ AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lncursesw"],
+ [unset ac_cv_lib_readline_readline;
+ AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-ltermcap"],
+ [LIBREADLINE=""],
+ [-ltermcap])],
+ [-lncursesw])],
+ [-lncurses])],
+ [-lcurses])],
+ [-ltinfo])])
+ AC_SUBST(LIBREADLINE)
+ if test -n "$LIBREADLINE"; then
+ if test "$LIBREADLINE" != "-lreadline"; then
+ echo "-lreadline needs $LIBREADLINE"
+ LIBREADLINE="-lreadline $LIBREADLINE"
+ fi
+ fi
fi
+
+# Check for the availability of libedit
+
+if test "$enable_pcretest_libedit" = "yes"; then
+ AC_CHECK_HEADERS([editline/readline.h], [HAVE_EDITLINE_READLINE_H=1],
+ [AC_CHECK_HEADERS([readline/readline.h], [HAVE_READLINE_READLINE_H=1])])
+ AC_CHECK_LIB([edit], [readline], [LIBEDIT="-ledit"])
+fi
+
# This facilitates -ansi builds under Linux
dnl AC_DEFINE([_GNU_SOURCE], [], [Enable GNU extensions in glibc])
@@ -646,7 +663,11 @@
pcregrep is three times this number, because it allows for the buffering of
"before" and "after" lines.])
-if test "$enable_pcretest_libreadline" = "yes"; then
+if test "$enable_pcretest_libedit" = "yes"; then
+ AC_DEFINE([SUPPORT_LIBEDIT], [], [
+ Define to allow pcretest to be linked with libedit.])
+ LIBREADLINE="$LIBEDIT"
+elif test "$enable_pcretest_libreadline" = "yes"; then
AC_DEFINE([SUPPORT_LIBREADLINE], [], [
Define to allow pcretest to be linked with libreadline.])
fi
@@ -810,6 +831,23 @@
# Similarly for --enable-pcretest-readline
+if test "$enable_pcretest_libedit" = "yes"; then
+ if test "$enable_pcretest_libreadline" = "yes"; then
+ echo "** Cannot use both --enable-pcretest-libedit and --enable-pcretest-readline"
+ exit 1
+ fi
+ if test "$HAVE_EDITLINE_READLINE_H" != "1" -a \
+ "$HAVE_READLINE_READLINE_H" != "1"; then
+ echo "** Cannot --enable-pcretest-libedit because neither editline/readline.h"
+ echo "** nor readline/readline.h was found."
+ exit 1
+ fi
+ if test -z "$LIBEDIT"; then
+ echo "** Cannot --enable-pcretest-libedit because libedit library was not found."
+ exit 1
+ fi
+fi
+
if test "$enable_pcretest_libreadline" = "yes"; then
if test "$HAVE_READLINE_H" != "1"; then
echo "** Cannot --enable-pcretest-readline because readline/readline.h was not found."
@@ -887,6 +925,7 @@
Buffer size for pcregrep ........ : ${with_pcregrep_bufsize}
Link pcregrep with libz ......... : ${enable_pcregrep_libz}
Link pcregrep with libbz2 ....... : ${enable_pcregrep_libbz2}
+ Link pcretest with libedit ...... : ${enable_pcretest_libedit}
Link pcretest with libreadline .. : ${enable_pcretest_libreadline}
EOF
Modified: code/trunk/pcretest.c
===================================================================
--- code/trunk/pcretest.c 2012-02-25 14:57:36 UTC (rev 935)
+++ code/trunk/pcretest.c 2012-02-25 17:02:23 UTC (rev 936)
@@ -59,15 +59,27 @@
#include <locale.h>
#include <errno.h>
-#ifdef SUPPORT_LIBREADLINE
+/* Both libreadline and libedit are optionally supported. The user-supplied
+original patch uses readline/readline.h for libedit, but in at least one system
+it is installed as editline/readline.h, so the configuration code now looks for
+that first, falling back to readline/readline.h. */
+
+#if defined(SUPPORT_LIBREADLINE) || defined(SUPPORT_LIBEDIT)
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
+#if defined(SUPPORT_LIBREADLINE)
#include <readline/readline.h>
#include <readline/history.h>
+#else
+#if defined(HAVE_EDITLINE_READLINE_H)
+#include <editline/readline.h>
+#else
+#include <readline/readline.h>
#endif
+#endif
+#endif
-
/* A number of things vary for Windows builds. Originally, pcretest opened its
input and output without "b"; then I was told that "b" was needed in some
environments, so it was added for release 5.0 to both the input and output. (It
@@ -1292,11 +1304,11 @@
{
int dlen;
- /* If libreadline support is required, use readline() to read a line if the
- input is a terminal. Note that readline() removes the trailing newline, so
- we must put it back again, to be compatible with fgets(). */
+ /* If libreadline or libedit support is required, use readline() to read a
+ line if the input is a terminal. Note that readline() removes the trailing
+ newline, so we must put it back again, to be compatible with fgets(). */
-#ifdef SUPPORT_LIBREADLINE
+#if defined(SUPPORT_LIBREADLINE) || defined(SUPPORT_LIBEDIT)
if (isatty(fileno(f)))
{
size_t len;
@@ -2112,7 +2124,7 @@
{
printf("Usage: pcretest [options] [<input file> [<output file>]]\n\n");
printf("Input and output default to stdin and stdout.\n");
-#ifdef SUPPORT_LIBREADLINE
+#if defined(SUPPORT_LIBREADLINE) || defined(SUPPORT_LIBEDIT)
printf("If input is a terminal, readline() is used to read from it.\n");
#else
printf("This version of pcretest is not linked with readline().\n");