From: Chet Ramey Date: Tue, 29 Mar 2022 15:50:11 +0000 (-0400) Subject: new configure option to link with shared curses/termcap library X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=24b84cce31c1c30340c9840a91974d7945769897;p=thirdparty%2Freadline.git new configure option to link with shared curses/termcap library --- diff --git a/CHANGELOG b/CHANGELOG index a18c96d..c025bcd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1440,3 +1440,11 @@ history.pc.in configure.ac,MANIFEST,Makefile.in - support for creating history.pc + + 3/29/2022 + --------- +configure.ac + - new option: --with-shared-termcap-library: use to force the shared + readline library to be linked against a shared termcap/curses library + that configure finds. If the argument begins with `-l', use that + library instead; updated INSTALL accordingly diff --git a/CHANGES b/CHANGES index dbba486..cbdf93d 100644 --- a/CHANGES +++ b/CHANGES @@ -77,10 +77,7 @@ g. There is a new option: `enable-active-region'. This separates control of h. rl_completer_word_break_characters is now `const char *' like rl_basic_word_break_characters. -i. The non-incremental history searches now leave the current history offset - at the position of the last matching history entry, like incremental search. - -j. Readline looks in $LS_COLORS for a custom filename extension +i. Readline looks in $LS_COLORS for a custom filename extension (*.readline-colored-completion-prefix) and uses that as the default color for the common prefix displayed when `colored-completion-prefix' is set. diff --git a/INSTALL b/INSTALL index 73960ee..293ef70 100644 --- a/INSTALL +++ b/INSTALL @@ -164,18 +164,40 @@ operates. Optional Features ================= -The readline `configure' recognizes a single `--with-PACKAGE' option: +The readline `configure' recognizes two `--with-PACKAGE' options: `--with-curses' This tells readline that it can find the termcap library functions (tgetent, et al.) in the curses library, rather than a separate termcap library. Readline uses the termcap functions, but does not - link with the termcap or curses library itself, allowing applications - which link with readline the to choose an appropriate library. - This option tells readline to link the example programs with the - curses library rather than libtermcap. + usually link with the termcap or curses library itself, allowing + applications which link with readline the to choose an appropriate + library. This option tells readline to link the example programs with + the curses library rather than libtermcap. + +`--with-shared-termcap-library' + This tells the readline build process to link the shared version of + libreadline against a shared version of the curses or termcap library + (see the description of SHLIB_LIBS below under `Shared Libraries'). + This relieves the application of having to link with curses or termcap + itself, but does not allow the application to choose which library to + use. This is only effective on systems that build shared libraries (see + below; the default for shared libraries is `yes'). + +`configure' also recognizes several `--enable-FEATURE' options: -`configure' also recognizes two `--enable-FEATURE' options: +`--enable-bracketed-paste-default' + Enable bracketed paste by default, so the initial value of the + `enable-bracketed-paste' Readline variable is `on'. The default + is `yes'. + +`--enable-install-examples' + Install the readline example programs as part of `make install'. + +`--enable-multibyte' + Build with support for multibyte characters enabled on systems with the + necessary framework (locale definitions, C library functions, etc.). The + default is `yes'. `--enable-shared' Build the shared libraries by default on supported platforms. The @@ -184,11 +206,6 @@ The readline `configure' recognizes a single `--with-PACKAGE' option: `--enable-static' Build the static libraries by default. The default is `yes'. -`--enable-bracketed-paste-default' - Enable bracketed paste by default, so the initial value of the - `enable-bracketed-paste' Readline variable is `on'. The default - is `yes'. - Shared Libraries ================ @@ -199,7 +216,8 @@ shared versions of the readline and history libraries to be built on supported platforms. If `configure' is given the `--enable-shared' option, it will attempt -to build the shared libraries by default on supported platforms. +to build the shared libraries by default on supported platforms. This +option is enabled by default. Configure calls the script support/shobj-conf to test whether or not shared library creation is supported and to generate the values diff --git a/NEWS b/NEWS index 1b289ae..d130c0e 100644 --- a/NEWS +++ b/NEWS @@ -33,10 +33,7 @@ g. There is a new option: `enable-active-region'. This separates control of h. rl_completer_word_break_characters is now `const char *' like rl_basic_word_break_characters. -i. The non-incremental history searches now leave the current history offset - at the position of the last matching history entry, like incremental search. - -j. Readline looks in $LS_COLORS for a custom filename extension +i. Readline looks in $LS_COLORS for a custom filename extension (*.readline-colored-completion-prefix) and uses that as the default color for the common prefix displayed when `colored-completion-prefix' is set. diff --git a/configure b/configure index 9e36204..03175cf 100644 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.ac for Readline 8.2, version 2.95. +# From configure.ac for Readline 8.2, version 2.96. # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.71 for readline 8.2. # @@ -752,6 +752,7 @@ ac_subst_files='' ac_user_opts=' enable_option_checking with_curses +with_shared_termcap_library enable_multibyte enable_shared enable_static @@ -1405,6 +1406,9 @@ Optional Packages: --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-curses use the curses library instead of the termcap library + --enable-shared-termcap-library + link the readline shared library against the + termcap/curses shared library [[default=NO]] Some influential environment variables: CC C compiler command @@ -2986,6 +2990,7 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac opt_curses=no +opt_shared_termcap_lib=no # Check whether --with-curses was given. @@ -2995,6 +3000,13 @@ then : fi +# Check whether --with-shared-termcap-library was given. +if test ${with_shared_termcap_library+y} +then : + withval=$with_shared_termcap_library; opt_shared_termcap_lib=$withval +fi + + if test "$opt_curses" = "yes"; then prefer_curses=yes fi @@ -7318,6 +7330,10 @@ then : fi fi +case "$opt_shared_termcap_lib" in +[Yy][Ee][Ss]) SHARED_TERMCAP="$TERMCAP_LIB" ;; +-l*) SHARED_TERMCAP="$opt_shared_termcap_lib" ;; +esac case "$TERMCAP_LIB" in -ltinfo) TERMCAP_PKG_CONFIG_LIB=tinfo ;; @@ -7810,10 +7826,10 @@ if test -f ${srcdir}/support/shobj-conf; then printf %s "checking configuration for building shared libraries... " >&6; } eval `TERMCAP_LIB=$TERMCAP_LIB ${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" -c ${host_cpu} -o ${host_os} -v ${host_vendor}` -# case "$SHLIB_LIBS" in -# *curses*|*termcap*|*termlib*) ;; -# *) SHLIB_LIBS="$SHLIB_LIBS $TERMCAP_LIB" ;; -# esac + case "$SHLIB_LIBS" in + *curses*|*termcap*|*termlib*|*tinfo*) ;; + *) SHLIB_LIBS="$SHLIB_LIBS $SHARED_TERMCAP" ;; + esac diff --git a/configure.ac b/configure.ac index 720cd10..0a83d5b 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ dnl Process this file with autoconf to produce a configure script. # You should have received a copy of the GNU General Public License # along with this program. If not, see . -AC_REVISION([for Readline 8.2, version 2.95]) +AC_REVISION([for Readline 8.2, version 2.96]) AC_INIT(readline, 8.2, bug-readline@gnu.org) @@ -39,9 +39,11 @@ AC_CANONICAL_BUILD dnl configure defaults opt_curses=no +opt_shared_termcap_lib=no dnl arguments to configure AC_ARG_WITH(curses, AS_HELP_STRING([--with-curses], [use the curses library instead of the termcap library]), opt_curses=$withval) +AC_ARG_WITH(shared-termcap-library, AS_HELP_STRING([--enable-shared-termcap-library], [link the readline shared library against the termcap/curses shared library [[default=NO]]]), opt_shared_termcap_lib=$withval) if test "$opt_curses" = "yes"; then prefer_curses=yes @@ -210,6 +212,10 @@ fi if test "$TERMCAP_LIB" = "-lncurses"; then AC_CHECK_HEADERS(ncurses/termcap.h) fi +case "$opt_shared_termcap_lib" in +[[Yy]][[Ee]][[Ss]]) SHARED_TERMCAP="$TERMCAP_LIB" ;; +-l*) SHARED_TERMCAP="$opt_shared_termcap_lib" ;; +esac case "$TERMCAP_LIB" in -ltinfo) TERMCAP_PKG_CONFIG_LIB=tinfo ;; @@ -240,10 +246,12 @@ if test -f ${srcdir}/support/shobj-conf; then AC_MSG_CHECKING(configuration for building shared libraries) eval `TERMCAP_LIB=$TERMCAP_LIB ${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" -c ${host_cpu} -o ${host_os} -v ${host_vendor}` -# case "$SHLIB_LIBS" in -# *curses*|*termcap*|*termlib*) ;; -# *) SHLIB_LIBS="$SHLIB_LIBS $TERMCAP_LIB" ;; -# esac + # SHARED_TERMCAP is set only if opt_shared_termcap_library is set + case "$SHLIB_LIBS" in + *curses*|*tinfo*) ;; + *termcap*|*termlib*) ;; # common aliases + *) SHLIB_LIBS="$SHLIB_LIBS $SHARED_TERMCAP" ;; + esac AC_SUBST(SHOBJ_CC) AC_SUBST(SHOBJ_CFLAGS) diff --git a/doc/readline.3 b/doc/readline.3 index b61d542..912718d 100644 --- a/doc/readline.3 +++ b/doc/readline.3 @@ -6,9 +6,9 @@ .\" Case Western Reserve University .\" chet.ramey@case.edu .\" -.\" Last Change: Thu Feb 10 10:58:32 EST 2022 +.\" Last Change: Fri Mar 11 10:14:10 EST 2022 .\" -.TH READLINE 3 "2022 February 10" "GNU Readline 8.2" +.TH READLINE 3 "2022 March 11" "GNU Readline 8.2" .\" .\" File Name macro. This used to be `.PN', for Path Name, .\" but Sun doesn't seem to like that very much. @@ -489,13 +489,11 @@ The active region shows the text inserted by bracketed-paste and any matching text found by incremental and non-incremental history searches. .TP .B enable\-bracketed\-paste (On) -When set to \fBOn\fP, readline will configure the terminal in a way -that will enable it to insert each paste into the editing buffer as a -single string of characters, instead of treating each character as if -it had been read from the keyboard -and executing any editing commands -bound to key sequences appearing in the pasted text. -This will prevent pasted characters from being interpreted as editing commands. +When set to \fBOn\fP, readline configures the terminal to insert each +paste into the editing buffer as a single string of characters, instead +of treating each character as if it had been read from the keyboard. +This prevents readline from executing any editing commands bound to key +sequences appearing in the pasted text. .TP .B enable\-keypad (Off) When set to \fBOn\fP, readline will try to enable the application diff --git a/doc/rluser.texi b/doc/rluser.texi index deaff14..0921d24 100644 --- a/doc/rluser.texi +++ b/doc/rluser.texi @@ -588,13 +588,12 @@ The default is @samp{On}. @item enable-bracketed-paste @vindex enable-bracketed-paste -When set to @samp{On}, Readline will configure the terminal in a way -that will enable it to insert each paste into the editing buffer as a -single string of characters, instead of treating each character as if -it had been read from the keyboard -and executing any editing commands -bound to key sequences appearing in the pasted text. -This will prevent pasted characters from being interpreted as editing commands. +When set to @samp{On}, Readline configures the terminal to insert each +paste into the editing buffer as a single string of characters, instead +of treating each character as if it had been read from the keyboard. +This is called putting the terminal into @dfn{bracketed paste mode}; +it prevents Readline from executing any editing commands bound to key +sequences appearing in the pasted text. The default is @samp{On}. @item enable-keypad diff --git a/doc/version.texi b/doc/version.texi index 42ead15..cd3f8d8 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -5,7 +5,7 @@ Copyright (C) 1988-2022 Free Software Foundation, Inc. @set EDITION 8.2 @set VERSION 8.2 -@set UPDATED 18 February 2022 -@set UPDATED-MONTH February 2022 +@set UPDATED 11 March 2022 +@set UPDATED-MONTH March 2022 -@set LASTCHANGE Fri Feb 18 11:12:48 EST 2022 +@set LASTCHANGE Fri Mar 11 10:13:51 EST 2022 diff --git a/nls.c b/nls.c index fd093b6..8447c10 100644 --- a/nls.c +++ b/nls.c @@ -1,6 +1,6 @@ /* nls.c -- skeletal internationalization code. */ -/* Copyright (C) 1996-2021 Free Software Foundation, Inc. +/* Copyright (C) 1996-2022 Free Software Foundation, Inc. This file is part of the GNU Readline Library (Readline), a library for reading lines of text with interactive input and history editing. @@ -53,6 +53,7 @@ #include "readline.h" #include "rlshell.h" #include "rlprivate.h" +#include "xmalloc.h" static int utf8locale (char *); diff --git a/readline.c b/readline.c index 888612c..7198450 100644 --- a/readline.c +++ b/readline.c @@ -240,6 +240,9 @@ char *_rl_comment_begin; /* Keymap holding the function currently being executed. */ Keymap rl_executing_keymap; +/* The function currently being executed. */ +rl_command_func_t *_rl_executing_func; + /* Keymap we're currently using to dispatch. */ Keymap _rl_dispatching_keymap; @@ -489,7 +492,11 @@ readline_internal_teardown (int eof) /* We don't want to do this if we executed functions that call history_set_pos to set the history offset to the line containing the non-incremental search string. */ +#if HISTORY_SEARCH_SETS_HISTPOS if (entry && rl_undo_list && _rl_history_search_pos != where_history ()) +#else + if (entry && rl_undo_list) +#endif { temp = savestring (the_line); rl_revert_line (1, 0); @@ -679,6 +686,8 @@ readline_internal_charloop (void) rl_executing_keymap = _rl_command_to_execute->map; rl_executing_key = _rl_command_to_execute->key; + _rl_executing_func = _rl_command_to_execute->func; + rl_dispatching = 1; RL_SETSTATE(RL_STATE_DISPATCHING); r = (*(_rl_command_to_execute->func)) (_rl_command_to_execute->count, _rl_command_to_execute->key); @@ -900,6 +909,8 @@ _rl_dispatch_subseq (register int key, Keymap map, int got_subseq) rl_executing_keymap = map; rl_executing_key = key; + _rl_executing_func = func; + RESIZE_KEYSEQ_BUFFER(); rl_executing_keyseq[rl_key_sequence_length++] = key; rl_executing_keyseq[rl_key_sequence_length] = '\0'; diff --git a/rlprivate.h b/rlprivate.h index 70ff01c..24ceb3a 100644 --- a/rlprivate.h +++ b/rlprivate.h @@ -381,6 +381,8 @@ extern void _rl_end_executing_keyseq (void); extern void _rl_add_executing_keyseq (int); extern void _rl_del_executing_keyseq (void); +extern rl_command_func_t *_rl_executing_func; + /* rltty.c */ extern int _rl_disable_tty_signals (void); extern int _rl_restore_tty_signals (void); diff --git a/search.c b/search.c index 2245166..898ffe7 100644 --- a/search.c +++ b/search.c @@ -84,17 +84,6 @@ static int _rl_nsearch_dispatch (_rl_search_cxt *, int); static void make_history_line_current (HIST_ENTRY *entry) { - /* At this point, rl_undo_list points to a private search string list. */ - if (rl_undo_list && rl_undo_list != (UNDO_LIST *)entry->data) - rl_free_undo_list (); - - /* This will need to free the saved undo list associated with the original - (pre-search) line buffer. */ - if (_rl_saved_line_for_history) - _rl_free_saved_history_line (); - - rl_maybe_save_line (); - /* Now we create a new undo list with a single insert for this text. WE DON'T CHANGE THE ORIGINAL HISTORY ENTRY UNDO LIST */ _rl_replace_text (entry->line, 0, rl_end); @@ -107,6 +96,8 @@ make_history_line_current (HIST_ENTRY *entry) current editing buffer. */ rl_free_undo_list (); #endif + + /* XXX - free the saved line for history here? */ } /* Search the history list for STRING starting at absolute history position @@ -195,6 +186,7 @@ noninc_dosearch (char *string, int dir, int flags) history_set_pos (oldpos); make_history_line_current (entry); + /* make_history_line_current used to do this. */ _rl_free_saved_history_line (); if (_rl_enable_active_region && ((flags & SF_PATTERN) == 0) && ind > 0 && ind < rl_end) @@ -525,9 +517,12 @@ static int rl_history_search_internal (int count, int dir) { HIST_ENTRY *temp; - int ret, oldpos, newcol; + UNDO_LIST *origlist; + int ret, oldpos, newcol, had_saved_line, origpos; char *t; + origpos = where_history (); + had_saved_line = _rl_saved_line_for_history != 0; rl_maybe_save_line (); /* This will either be restored from the saved line or set from the found history line. */ @@ -563,6 +558,7 @@ rl_history_search_internal (int count, int dir) /* If we didn't find anything at all, return. */ if (temp == 0) { + /* XXX - check had_saved_line here? */ rl_maybe_unsave_line (); rl_ding (); /* If you don't want the saved history line (last match) to show up @@ -585,11 +581,27 @@ rl_history_search_internal (int count, int dir) /* Copy the line we found into the current line buffer. */ make_history_line_current (temp); + /* Free the saved history line corresponding to the search string */ + if (had_saved_line == 0) + _rl_free_saved_history_line (); + +#if HISTORY_SEARCH_SETS_HISTPOS + /* XXX - can't make this work the way I want it to yet. Too much assumes + that rl_undo_list corresponds to the current history entry's undo list, + especially the stuff in maybe_save_line and especially maybe_replace_line. + Leaving it commented out for now. */ + /* Make sure we set the current history position to the last line found so we can do things like operate-and-get-next from here. This is similar to how incremental search behaves. */ - rl_maybe_replace_line (); - history_set_pos (_rl_history_search_pos); /* XXX */ + origlist = rl_undo_list; + rl_undo_list = 0; /* XXX - was (UNDO_LIST *)temp->data */ + if (_rl_history_search_pos < origpos) + rl_get_previous_history (origpos - _rl_history_search_pos, 0); + else + rl_get_next_history (_rl_history_search_pos - origpos, 0); + rl_undo_list = origlist; +#endif /* decide where to put rl_point -- need to change this for pattern search */ if (_rl_history_search_flags & ANCHORED_SEARCH)