--- configure.ac.orig 2012-02-04 13:55:18.000000000 +0100 +++ configure.ac 2012-02-13 23:39:18.830982041 +0100 @@ -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], @@ -561,6 +567,9 @@ fi fi +# Check for the availabiity of libedit +AC_CHECK_LIB([edit], [readline], [LIBEDIT="-ledit"]) + # This facilitates -ansi builds under Linux dnl AC_DEFINE([_GNU_SOURCE], [], [Enable GNU extensions in glibc]) @@ -646,7 +655,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 +823,21 @@ # 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_READLINE_H" != "1"; then + echo "** Cannot --enable-pcretest-libedit because readline/readline.h was not 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 +915,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 --- pcretest.c.orig 2012-02-13 22:23:04.086983835 +0100 +++ pcretest.c 2012-02-13 22:32:10.960985908 +0100 @@ -59,13 +59,15 @@ #include #include -#ifdef SUPPORT_LIBREADLINE +#if defined(SUPPORT_LIBREADLINE) || defined(SUPPORT_LIBEDIT) #ifdef HAVE_UNISTD_H #include #endif #include +#if defined(SUPPORT_LIBREADLINE) #include #endif +#endif /* A number of things vary for Windows builds. Originally, pcretest opened its @@ -1280,7 +1282,7 @@ 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; @@ -2096,7 +2098,7 @@ { printf("Usage: pcretest [options] [ []]\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");