1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
--- 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 <locale.h>
#include <errno.h>
-#ifdef SUPPORT_LIBREADLINE
+#if defined(SUPPORT_LIBREADLINE) || defined(SUPPORT_LIBEDIT)
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <readline/readline.h>
+#if defined(SUPPORT_LIBREADLINE)
#include <readline/history.h>
#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] [<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");
|