From d9de8b611be6de529d66f4dd5de14d5e2624cdc4 Mon Sep 17 00:00:00 2001 From: Christian Hofstaedtler Date: Tue, 12 Jan 2016 21:21:05 +0100 Subject: [PATCH] Replace readline with libedit --- .travis.yml | 1 + build-scripts/debian-dnsdist/control.in | 2 +- configure.ac | 2 +- m4/ax_lib_readline.m4 | 107 --------------------- m4/pdns_check_libedit.m4 | 9 ++ m4/pdns_check_readline.m4 | 12 --- pdns/Makefile.am | 5 +- pdns/dnsdist-console.cc | 11 ++- pdns/dnsdist.cc | 4 +- pdns/dnsdistdist/Makefile.am | 4 +- pdns/dnsdistdist/configure.ac | 2 +- pdns/dnsdistdist/m4/ax_lib_readline.m4 | 1 - pdns/dnsdistdist/m4/pdns_check_libedit.m4 | 1 + pdns/dnsdistdist/m4/pdns_check_readline.m4 | 1 - 14 files changed, 27 insertions(+), 135 deletions(-) delete mode 100644 m4/ax_lib_readline.m4 create mode 100644 m4/pdns_check_libedit.m4 delete mode 100644 m4/pdns_check_readline.m4 delete mode 120000 pdns/dnsdistdist/m4/ax_lib_readline.m4 create mode 120000 pdns/dnsdistdist/m4/pdns_check_libedit.m4 delete mode 120000 pdns/dnsdistdist/m4/pdns_check_readline.m4 diff --git a/.travis.yml b/.travis.yml index 569ee69498..24e271db58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,6 +23,7 @@ before_script: - sudo apt-get -qq --no-install-recommends install libboost-all-dev liblua5.1-dev + libedit-dev - cd .. - wget https://xs.powerdns.com/tmp/libsodium_1.0.2-1_amd64.deb - sudo dpkg -i libsodium_1.0.2-1_amd64.deb diff --git a/build-scripts/debian-dnsdist/control.in b/build-scripts/debian-dnsdist/control.in index 6063179614..c222bc5dbc 100644 --- a/build-scripts/debian-dnsdist/control.in +++ b/build-scripts/debian-dnsdist/control.in @@ -3,7 +3,7 @@ Section: net Priority: optional Maintainer: PowerDNS Autobuilder Origin: PowerDNS -Build-Depends: debhelper (>= 9), dh-systemd (>= 1.5), autotools-dev, libboost-dev, liblua5.2-dev @LIBSODIUMDEV@ +Build-Depends: debhelper (>= 9), dh-systemd (>= 1.5), autotools-dev, libboost-dev, libedit-dev, liblua5.2-dev @LIBSODIUMDEV@ Standards-Version: 3.9.5 Homepage: http://dnsdist.org diff --git a/configure.ac b/configure.ac index ddb21de674..6f827490ee 100644 --- a/configure.ac +++ b/configure.ac @@ -112,7 +112,7 @@ AX_CHECK_OPENSSL([ ] ) -PDNS_CHECK_READLINE +PDNS_CHECK_LIBEDIT PDNS_CHECK_RAGEL PDNS_CHECK_LIBSODIUM PDNS_CHECK_CLOCK_GETTIME diff --git a/m4/ax_lib_readline.m4 b/m4/ax_lib_readline.m4 deleted file mode 100644 index 056f25c2a0..0000000000 --- a/m4/ax_lib_readline.m4 +++ /dev/null @@ -1,107 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_lib_readline.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_LIB_READLINE -# -# DESCRIPTION -# -# Searches for a readline compatible library. If found, defines -# `HAVE_LIBREADLINE'. If the found library has the `add_history' function, -# sets also `HAVE_READLINE_HISTORY'. Also checks for the locations of the -# necessary include files and sets `HAVE_READLINE_H' or -# `HAVE_READLINE_READLINE_H' and `HAVE_READLINE_HISTORY_H' or -# 'HAVE_HISTORY_H' if the corresponding include files exists. -# -# The libraries that may be readline compatible are `libedit', -# `libeditline' and `libreadline'. Sometimes we need to link a termcap -# library for readline to work, this macro tests these cases too by trying -# to link with `libtermcap', `libcurses' or `libncurses' before giving up. -# -# Here is an example of how to use the information provided by this macro -# to perform the necessary includes or declarations in a C file: -# -# #ifdef HAVE_LIBREADLINE -# # if defined(HAVE_READLINE_READLINE_H) -# # include -# # elif defined(HAVE_READLINE_H) -# # include -# # else /* !defined(HAVE_READLINE_H) */ -# extern char *readline (); -# # endif /* !defined(HAVE_READLINE_H) */ -# char *cmdline = NULL; -# #else /* !defined(HAVE_READLINE_READLINE_H) */ -# /* no readline */ -# #endif /* HAVE_LIBREADLINE */ -# -# #ifdef HAVE_READLINE_HISTORY -# # if defined(HAVE_READLINE_HISTORY_H) -# # include -# # elif defined(HAVE_HISTORY_H) -# # include -# # else /* !defined(HAVE_HISTORY_H) */ -# extern void add_history (); -# extern int write_history (); -# extern int read_history (); -# # endif /* defined(HAVE_READLINE_HISTORY_H) */ -# /* no history */ -# #endif /* HAVE_READLINE_HISTORY */ -# -# LICENSE -# -# Copyright (c) 2008 Ville Laurikari -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 6 - -AU_ALIAS([VL_LIB_READLINE], [AX_LIB_READLINE]) -AC_DEFUN([AX_LIB_READLINE], [ - AC_CACHE_CHECK([for a readline compatible library], - ax_cv_lib_readline, [ - ORIG_LIBS="$LIBS" - for readline_lib in readline edit editline; do - for termcap_lib in "" termcap curses ncurses; do - if test -z "$termcap_lib"; then - TRY_LIB="-l$readline_lib" - else - TRY_LIB="-l$readline_lib -l$termcap_lib" - fi - LIBS="$ORIG_LIBS $TRY_LIB" - AC_TRY_LINK_FUNC(readline, ax_cv_lib_readline="$TRY_LIB") - if test -n "$ax_cv_lib_readline"; then - break - fi - done - if test -n "$ax_cv_lib_readline"; then - break - fi - done - if test -z "$ax_cv_lib_readline"; then - ax_cv_lib_readline="no" - fi - LIBS="$ORIG_LIBS" - ]) - - if test "$ax_cv_lib_readline" != "no"; then - LIBS="$LIBS $ax_cv_lib_readline" - AC_DEFINE(HAVE_LIBREADLINE, 1, - [Define if you have a readline compatible library]) - AC_CHECK_HEADERS(readline.h readline/readline.h) - AC_CACHE_CHECK([whether readline supports history], - ax_cv_lib_readline_history, [ - ax_cv_lib_readline_history="no" - AC_TRY_LINK_FUNC(add_history, ax_cv_lib_readline_history="yes") - ]) - if test "$ax_cv_lib_readline_history" = "yes"; then - AC_DEFINE(HAVE_READLINE_HISTORY, 1, - [Define if your readline library has \`add_history']) - AC_CHECK_HEADERS(history.h readline/history.h) - fi - fi -])dnl diff --git a/m4/pdns_check_libedit.m4 b/m4/pdns_check_libedit.m4 new file mode 100644 index 0000000000..0d42407df2 --- /dev/null +++ b/m4/pdns_check_libedit.m4 @@ -0,0 +1,9 @@ +AC_DEFUN([PDNS_CHECK_LIBEDIT], [ + PKG_CHECK_MODULES(LIBEDIT, libedit, [], [ + AS_IF([test "$1" = "mandatory"],[ + AS_IF([test x"$LIBEDIT_LIBS" = "x"],[ + AC_MSG_ERROR([libedit support is mandatory]) + ]) + ]) + ]) +]) diff --git a/m4/pdns_check_readline.m4 b/m4/pdns_check_readline.m4 deleted file mode 100644 index ad5f9750a5..0000000000 --- a/m4/pdns_check_readline.m4 +++ /dev/null @@ -1,12 +0,0 @@ -AC_DEFUN([PDNS_CHECK_READLINE], [ - OLD_LIBS="$LIBS" - LIBS="" - AX_LIB_READLINE - AC_SUBST([READLINE_LIBS], [$LIBS]) - LIBS="$OLD_LIBS" - AS_IF([test "$1" = "mandatory"],[ - AS_IF([test x"$READLINE_LIBS" = "x"],[ - AC_MSG_ERROR([readline support is mandatory]) - ]) - ]) -]) diff --git a/pdns/Makefile.am b/pdns/Makefile.am index a3ccfafa9b..c0915d9e19 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -3,7 +3,8 @@ JSON11_LIBS = -L$(top_srcdir)/ext/json11 -ljson11 AM_CPPFLAGS += \ -I$(top_srcdir)/ext/json11 \ $(YAHTTP_CFLAGS) \ - $(MBEDTLS_CFLAGS) + $(MBEDTLS_CFLAGS) \ + $(LIBEDIT_CFLAGS) AM_CXXFLAGS = \ -DSYSCONFDIR=\"$(sysconfdir)\" \ @@ -647,7 +648,7 @@ dnsdist_LDFLAGS = \ dnsdist_LDADD = \ $(LUA_LIBS) \ - $(READLINE_LIBS) \ + $(LIBEDIT_LIBS) \ $(RT_LIBS) \ $(YAHTTP_LIBS) \ $(LIBSODIUM_LIBS) diff --git a/pdns/dnsdist-console.cc b/pdns/dnsdist-console.cc index e5aa6e2829..e964aeba55 100644 --- a/pdns/dnsdist-console.cc +++ b/pdns/dnsdist-console.cc @@ -1,7 +1,7 @@ #include "dnsdist.hh" #include "sodcrypto.hh" -#include -#include +#include +#include #include #include "dolog.hh" @@ -233,9 +233,10 @@ char** my_completion( const char * text , int start, int end) char **matches=0; if (start == 0) matches = rl_completion_matches ((char*)text, &my_generator); - else - rl_bind_key('\t',rl_abort); - + + // skip default filename completion. + rl_attempted_completion_over = 1; + return matches; } } diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 5a064ffd6a..60ed5f9eb8 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -27,8 +27,8 @@ #include #include #include "dolog.hh" -#include -#include +#include +#include #include "dnsname.hh" #include "dnswriter.hh" #include "base64.hh" diff --git a/pdns/dnsdistdist/Makefile.am b/pdns/dnsdistdist/Makefile.am index 68c998fe67..d508fc0a60 100644 --- a/pdns/dnsdistdist/Makefile.am +++ b/pdns/dnsdistdist/Makefile.am @@ -1,4 +1,4 @@ -AM_CPPFLAGS = -I pdns $(LUA_CFLAGS) $(YAHTTP_CFLAGS) $(BOOST_CPPFLAGS) $(SANITIZER_FLAGS) -O3 -Wall -pthread -DSYSCONFDIR=\"${sysconfdir}\" +AM_CPPFLAGS = -I pdns $(LUA_CFLAGS) $(LIBEDIT_CFLAGS) $(YAHTTP_CFLAGS) $(BOOST_CPPFLAGS) $(SANITIZER_FLAGS) -O3 -Wall -pthread -DSYSCONFDIR=\"${sysconfdir}\" ACLOCAL_AMFLAGS = -I m4 @@ -72,7 +72,7 @@ dnsdist_LDFLAGS = \ dnsdist_LDADD = \ $(LUA_LIBS) \ - $(READLINE_LIBS) \ + $(LIBEDIT_LIBS) \ $(RT_LIBS) \ $(YAHTTP_LIBS) \ $(LIBSODIUM_LIBS) \ diff --git a/pdns/dnsdistdist/configure.ac b/pdns/dnsdistdist/configure.ac index 5c374224e4..7e30b440c5 100644 --- a/pdns/dnsdistdist/configure.ac +++ b/pdns/dnsdistdist/configure.ac @@ -7,7 +7,7 @@ AC_PROG_CC AC_PROG_CXX PDNS_CHECK_LIBSODIUM AC_PROG_LIBTOOL -PDNS_CHECK_READLINE([mandatory]) +PDNS_CHECK_LIBEDIT([mandatory]) PDNS_CHECK_CLOCK_GETTIME BOOST_REQUIRE([1.35]) BOOST_FOREACH diff --git a/pdns/dnsdistdist/m4/ax_lib_readline.m4 b/pdns/dnsdistdist/m4/ax_lib_readline.m4 deleted file mode 120000 index e42b3b9ada..0000000000 --- a/pdns/dnsdistdist/m4/ax_lib_readline.m4 +++ /dev/null @@ -1 +0,0 @@ -../../../m4/ax_lib_readline.m4 \ No newline at end of file diff --git a/pdns/dnsdistdist/m4/pdns_check_libedit.m4 b/pdns/dnsdistdist/m4/pdns_check_libedit.m4 new file mode 120000 index 0000000000..e8ffe5eae5 --- /dev/null +++ b/pdns/dnsdistdist/m4/pdns_check_libedit.m4 @@ -0,0 +1 @@ +../../../m4/pdns_check_libedit.m4 \ No newline at end of file diff --git a/pdns/dnsdistdist/m4/pdns_check_readline.m4 b/pdns/dnsdistdist/m4/pdns_check_readline.m4 deleted file mode 120000 index 69fca2574b..0000000000 --- a/pdns/dnsdistdist/m4/pdns_check_readline.m4 +++ /dev/null @@ -1 +0,0 @@ -../../../m4/pdns_check_readline.m4 \ No newline at end of file -- 2.47.2