1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-23 17:33:50 +03:00

xmllint: Support libreadline without history

This commit is contained in:
Nick Wellnhofer 2024-06-16 21:16:43 +02:00
parent 5fca9498fd
commit 3848802723
5 changed files with 38 additions and 27 deletions

View File

@ -45,9 +45,9 @@ The following options disable or enable code modules and relevant symbols:
--with-c14n Canonical XML 1.0 support (on)
--with-catalog XML Catalogs support (on)
--with-debug debugging module and shell (on)
--with-history history support for shell (off)
--with-readline[=DIR] use readline in DIR (for shell history)
--with-debug debugging module (on)
--with-history history support for xmllint shell (off)
--with-readline[=DIR] use readline in DIR for shell (on)
--with-html HTML parser (on)
--with-http HTTP support (off)
--with-iconv[=DIR] iconv support (on)

View File

@ -68,11 +68,11 @@ AC_ARG_WITH(c14n,
AC_ARG_WITH(catalog,
[ --with-catalog XML Catalogs support (on)])
AC_ARG_WITH(debug,
[ --with-debug debugging module and shell (on)])
[ --with-debug debugging module (on)])
AC_ARG_WITH(history,
[ --with-history history support for shell (off)])
[ --with-history history support for xmllint shell (off)])
AC_ARG_WITH(readline,
[ --with-readline[[=DIR]] use readline in DIR (for shell history)])
[ --with-readline[[=DIR]] use readline in DIR for shell (on)])
AC_ARG_WITH(html,
[ --with-html HTML parser (on)])
AC_ARG_WITH(http,
@ -796,10 +796,12 @@ AC_SUBST(WITH_THREADS)
AC_SUBST(WITH_THREAD_ALLOC)
dnl
dnl xmllint shell history
dnl xmllint shell
dnl
if test "$with_history" = "yes" && test "$with_readline" != "no"; then
echo Enabling xmllint shell history
if test "$with_readline" != "no"; then
_cppflags=$CPPFLAGS
_libs=$LIBS
dnl check for terminal library. this is a very cool solution
dnl from octave's configure.in
unset tcap
@ -808,21 +810,11 @@ if test "$with_history" = "yes" && test "$with_readline" != "no"; then
test -n "$tcap" && break
done
_cppflags=$CPPFLAGS
_libs=$LIBS
if test "$with_readline" != "" && test "$with_readline" != "yes"; then
RDL_DIR=$with_readline
CPPFLAGS="${CPPFLAGS} -I$RDL_DIR/include"
LIBS="${LIBS} -L$RDL_DIR/lib"
fi
AC_CHECK_HEADER(readline/history.h,
AC_CHECK_LIB(history, append_history,[
RDL_LIBS="-lhistory"
if test "x${RDL_DIR}" != "x"; then
RDL_CFLAGS="-I$RDL_DIR/include"
RDL_LIBS="-L$RDL_DIR/lib $RDL_LIBS"
fi
AC_DEFINE([HAVE_LIBHISTORY], [], [Define if history library is there (-lhistory)])]))
AC_CHECK_HEADER(readline/readline.h,
AC_CHECK_LIB(readline, readline,[
RDL_LIBS="-lreadline $RDL_LIBS $tcap"
@ -831,6 +823,19 @@ if test "$with_history" = "yes" && test "$with_readline" != "no"; then
RDL_LIBS="-L$RDL_DIR/lib $RDL_LIBS"
fi
AC_DEFINE([HAVE_LIBREADLINE], [], [Define if readline library is there (-lreadline)])], , $tcap))
if test "$with_history" = "yes"; then
echo Enabling xmllint shell history
AC_CHECK_HEADER(readline/history.h,
AC_CHECK_LIB(history, append_history,[
RDL_LIBS="-lhistory"
if test "x${RDL_DIR}" != "x"; then
RDL_CFLAGS="-I$RDL_DIR/include"
RDL_LIBS="-L$RDL_DIR/lib $RDL_LIBS"
fi
AC_DEFINE([HAVE_LIBHISTORY], [], [Define if history library is there (-lhistory)])]))
fi
CPPFLAGS=$_cppflags
LIBS=$_libs
fi

View File

@ -408,11 +408,11 @@ want_thread_alloc = threads_dep.found()
### xmllint shell history
xmllint_deps = []
if want_history == true and want_readline == true
if want_readline == true
termlib_lib = ['ncurses', 'curses', 'termcap', 'terminfo', 'termlib']
foreach tl : termlib_lib
termlib_dep = cc.find_library(tl)
termlib_dep = cc.find_library(tl, required: false)
if (
termlib_dep.found()
and cc.has_function('tputs', dependencies: termlib_dep)
@ -423,17 +423,19 @@ if want_history == true and want_readline == true
endif
endforeach
history_dep = dependency('history', required: false)
if history_dep.found()
xmllint_deps += history_dep
config_h.set10('HAVE_LIBHISTORY', true)
endif
readline_dep = dependency('readline', required: false)
if readline_dep.found()
xmllint_deps += readline_dep
config_h.set10('HAVE_LIBREADLINE', true)
endif
if want_history == true
history_dep = dependency('history', required: false)
if history_dep.found()
xmllint_deps += history_dep
config_h.set10('HAVE_LIBHISTORY', true)
endif
endif
endif
### crypto

View File

@ -1067,9 +1067,11 @@ xmllintShellReadline(char *prompt) {
/* Get a line from the user. */
line_read = readline (prompt);
#ifdef HAVE_LIBHISTORY
/* If the line has any text in it, save it on the history. */
if (line_read && *line_read)
add_history (line_read);
#endif
return (line_read);
#else

View File

@ -64,9 +64,11 @@ xmlShellReadline(const char *prompt) {
/* Get a line from the user. */
line_read = readline (prompt);
#ifdef HAVE_LIBHISTORY
/* If the line has any text in it, save it on the history. */
if (line_read && *line_read)
add_history (line_read);
#endif
return (line_read);
#else