]> git.ipfire.org Git - thirdparty/readline.git/commitdiff
new configure option to link with shared curses/termcap library
authorChet Ramey <chet.ramey@case.edu>
Tue, 29 Mar 2022 15:50:11 +0000 (11:50 -0400)
committerChet Ramey <chet.ramey@case.edu>
Tue, 29 Mar 2022 15:50:11 +0000 (11:50 -0400)
13 files changed:
CHANGELOG
CHANGES
INSTALL
NEWS
configure
configure.ac
doc/readline.3
doc/rluser.texi
doc/version.texi
nls.c
readline.c
rlprivate.h
search.c

index a18c96d68ae8022c33a7aa0c16032bc4018d6674..c025bcd0733bd7fc9af699a1ed09eb4d2d7ec1cf 100644 (file)
--- 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 dbba486615157aaaf96005139641b01bb5dd03b4..cbdf93d4b29d25a81147c4f4e98b50cde3a19543 100644 (file)
--- 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 73960ee2099831a22b71eaf3f1eebacec2b97f79..293ef7061b5cb68d8e1f3f1b0c7728a277b4bcb0 100644 (file)
--- 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 1b289ae71920fa4a9dd688f824f8863d7f691a02..d130c0ebdcb22807b48e497513b404baf561dc3e 100644 (file)
--- 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.
 
index 9e36204a712d79f85005815c19a91d3008c8b566..03175cf5450278fc2afd4f4b8211bb40be063c05 100644 (file)
--- 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
 
 
 
index 720cd108b865d0f7c223e3df37d55bb1c446ed5e..0a83d5b6e8efed58694bef10f4669569b4ed6760 100644 (file)
@@ -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 <http://www.gnu.org/licenses/>.
 
-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)
index b61d5421eda738d5166c13824520ae97a0084a7c..912718d452fe9e00d9e99149ecd706c4f6a3858e 100644 (file)
@@ -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
index deaff14d4ecb4421f3e75caddc3734b177e3f349..0921d24d150ef7bde955be864555e0e519993298 100644 (file)
@@ -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
index 42ead150df73fd185562ec4cdbe9b7e58b5fb5e7..cd3f8d85d4d036536538cddf78a2334f29c2124a 100644 (file)
@@ -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 fd093b6c3e14ea11ae467d505d667582fbe85ca0..8447c10f10317b7838134452428abebf9b5dc989 100644 (file)
--- 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 *);
 
index 888612c6bec6b30aa88da2e072f609a8ea4e0111..719845050967e3f33b64954398b7de37978cde53 100644 (file)
@@ -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';
index 70ff01c2705ea00fa49bfe00d77c9484207449ec..24ceb3a474c0f0292929981fe6daa4b5f6106ab4 100644 (file)
@@ -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);
index 22451663bbe42055e0c8ab9dd94d5d56d81548e5..898ffe7bbb70fbcb080172dce9d3ba33d8c1b90e 100644 (file)
--- 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)