]> git.ipfire.org Git - thirdparty/readline.git/commitdiff
fix to history search so it doesn't change the offset in the history list; fix to...
authorChet Ramey <chet.ramey@case.edu>
Tue, 28 Jan 2025 19:56:36 +0000 (14:56 -0500)
committerChet Ramey <chet.ramey@case.edu>
Tue, 28 Jan 2025 19:56:36 +0000 (14:56 -0500)
22 files changed:
complete.c
config.h.in
configure
configure.ac
display.c
doc/history.3
doc/history.texi
doc/hstech.texi
doc/hsuser.texi
doc/readline.3
doc/rlman.texi
doc/rltech.texi
doc/rluser.texi
doc/rluserman.texi
doc/version.texi
histexpand.c
rlprivate.h
rltty.c
rlwinsize.h
signals.c
terminal.c
util.c

index 473f04db5b93c6adb3b7d9dff347497b505d9a5a..79026de6f8c389bb577423be2f2ff1a8e0beefcf 100644 (file)
@@ -3066,7 +3066,10 @@ _rl_export_completions (char **matches, char *text, int start, int end)
   fprintf (rl_outstream, "%s\n", text);
   fprintf (rl_outstream, "%d:%d\n", start, end);       /* : because it's not a radix character */
   for (i = 0; i < len; i++)
-    fprintf (rl_outstream, "%s\n", matches[i]);
+    {
+      print_filename (matches[i], matches[i], 0);
+      fprintf (rl_outstream, "\n");
+    }
   fflush (rl_outstream);
 }
 
index dd0a9561864cfde7cfc8f21932348ccc656e6197..06a7e47731720e0e083dc4c056123a4a580a97a9 100644 (file)
 /* Define if you have the tcgetattr function.  */
 #undef HAVE_TCGETATTR
 
+/* Define if you have the tcgetwinsize function.  */
+#undef HAVE_TCGETWINSIZE
+
+/* Define if you have the tcsetwinsize function.  */
+#undef HAVE_TCSETWINSIZE
+
 /* Define if you have the towlower function.  */
 #undef HAVE_TOWLOWER
 
index eb2c1bfb32174a69fa52506d170d19e53140ed27..f3e20c5bc3fb2115334ccdbc1f50275c6a6ecb25 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac for Readline 8.3, version 2.101.
+# From configure.ac for Readline 8.3, version 2.102.
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.72 for readline 8.3.
 #
@@ -5266,6 +5266,18 @@ if test "x$ac_cv_func_tcgetattr" = xyes
 then :
   printf "%s\n" "#define HAVE_TCGETATTR 1" >>confdefs.h
 
+fi
+ac_fn_c_check_func "$LINENO" "tcgetwinsize" "ac_cv_func_tcgetwinsize"
+if test "x$ac_cv_func_tcgetwinsize" = xyes
+then :
+  printf "%s\n" "#define HAVE_TCGETWINSIZE 1" >>confdefs.h
+
+fi
+ac_fn_c_check_func "$LINENO" "tcsetwinsize" "ac_cv_func_tcsetwinsize"
+if test "x$ac_cv_func_tcsetwinsize" = xyes
+then :
+  printf "%s\n" "#define HAVE_TCSETWINSIZE 1" >>confdefs.h
+
 fi
 ac_fn_c_check_func "$LINENO" "vsnprintf" "ac_cv_func_vsnprintf"
 if test "x$ac_cv_func_vsnprintf" = xyes
@@ -6872,13 +6884,6 @@ printf "%s\n" "not found" >&6; }
 fi
 
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for struct dirent.d_ino" >&5
-printf %s "checking for struct dirent.d_ino... " >&6; }
-if test ${bash_cv_dirent_has_d_ino+y}
-then :
-  printf %s "(cached) " >&6
-else case e in #(
-  e)
 
 ac_fn_c_check_member "$LINENO" "struct dirent" "d_ino" "ac_cv_member_struct_dirent_d_ino" "
 #include <stdio.h>
@@ -6907,31 +6912,11 @@ then :
 
 printf "%s\n" "#define HAVE_STRUCT_DIRENT_D_INO 1" >>confdefs.h
 
-bash_cv_dirent_has_d_ino=yes
-else case e in #(
-  e) bash_cv_dirent_has_d_ino=no ;;
-esac
-fi
 
- ;;
-esac
 fi
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_dirent_has_d_ino" >&5
-printf "%s\n" "$bash_cv_dirent_has_d_ino" >&6; }
-if test $bash_cv_dirent_has_d_ino = yes; then
-printf "%s\n" "#define HAVE_STRUCT_DIRENT_D_INO 1" >>confdefs.h
-
-fi
 
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for struct dirent.d_fileno" >&5
-printf %s "checking for struct dirent.d_fileno... " >&6; }
-if test ${bash_cv_dirent_has_d_fileno+y}
-then :
-  printf %s "(cached) " >&6
-else case e in #(
-  e)
 
 ac_fn_c_check_member "$LINENO" "struct dirent" "d_fileno" "ac_cv_member_struct_dirent_d_fileno" "
 #include <stdio.h>
@@ -6960,22 +6945,9 @@ then :
 
 printf "%s\n" "#define HAVE_STRUCT_DIRENT_D_FILENO 1" >>confdefs.h
 
-bash_cv_dirent_has_d_fileno=yes
-else case e in #(
-  e) bash_cv_dirent_has_d_fileno=no ;;
-esac
-fi
 
- ;;
-esac
 fi
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_dirent_has_d_fileno" >&5
-printf "%s\n" "$bash_cv_dirent_has_d_fileno" >&6; }
-if test $bash_cv_dirent_has_d_fileno = yes; then
-printf "%s\n" "#define HAVE_STRUCT_DIRENT_D_FILENO 1" >>confdefs.h
-
-fi
 
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for struct timeval in sys/time.h and time.h" >&5
 printf %s "checking for struct timeval in sys/time.h and time.h... " >&6; }
index 1783dae872fe418400ad0fe7360297f651a65577..b270ab7d3d3228d97f10cdffa18b67fc87ed10f5 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.3, version 2.101])
+AC_REVISION([for Readline 8.3, version 2.102])
 
 AC_INIT(readline, 8.3, bug-readline@gnu.org)
 
@@ -151,8 +151,9 @@ AC_HEADER_STAT
 AC_HEADER_DIRENT
 
 AC_CHECK_FUNCS(fcntl gettimeofday kill lstat pselect readlink select setitimer)
-AC_CHECK_FUNCS(fnmatch memmove putenv setenv setlocale \
-               strcasecmp strpbrk sysconf tcgetattr vsnprintf)
+AC_CHECK_FUNCS(fnmatch memmove putenv setenv setlocale strcasecmp \
+               strpbrk sysconf tcgetattr tcgetwinsize tcsetwinsize \
+               vsnprintf)
 AC_CHECK_FUNCS(isascii isxdigit)
 AC_CHECK_FUNCS(getpwent getpwnam getpwuid)
 
index f0023692bb3f5cad4a09d6e9d4d491b5feff44d9..dcc5e806d07210c9e69513a7d4fc211dd0ad8fa7 100644 (file)
--- a/display.c
+++ b/display.c
@@ -1489,7 +1489,7 @@ rl_redisplay (void)
                 but the buffer position needs to be adjusted to account
                 for invisible characters. */
              if ((mb_cur_max == 1 || rl_byte_oriented) && cursor_linenum == prompt_last_screen_line)
-               _rl_last_c_pos = physpos + WRAP_OFFSET (cursor_linenum, wrap_offset);;
+               _rl_last_c_pos = physpos + WRAP_OFFSET (cursor_linenum, wrap_offset);
            }
 
          /* Now we move the cursor to where it needs to be.  First, make
@@ -1502,28 +1502,53 @@ rl_redisplay (void)
             invisible character in the prompt string. */
          /* XXX - why not use local_prompt_len? */
          nleft = prompt_visible_length + wrap_offset;
-         if (cursor_linenum == prompt_last_screen_line && wrap_offset > 0 &&
-             _rl_last_c_pos > 0 && local_prompt &&
-             _rl_last_c_pos < PROMPT_ENDING_INDEX)
+         if (cursor_linenum == prompt_last_screen_line)
            {
-             int pmt_offset;
-
-             _rl_cr ();
-             if (modmark)
-               _rl_output_some_chars ("*", 1);
-
-             /* If the number of characters in local_prompt is greater than
-                the screen width, the prompt wraps. We only want to print the
-                portion after the line wrap. */
-             pmt_offset = local_prompt_newlines[cursor_linenum];
-             if (cursor_linenum > 0 && pmt_offset > 0 && nleft > pmt_offset)
-               _rl_output_some_chars (local_prompt + pmt_offset, nleft - pmt_offset);
-             else
-               _rl_output_some_chars (local_prompt, nleft);
-             if (mb_cur_max > 1 && rl_byte_oriented == 0)
-               _rl_last_c_pos = _rl_col_width (local_prompt, 0, nleft, 1) - wrap_offset + modmark;
+             int pmt_offset = local_prompt_newlines ? local_prompt_newlines[cursor_linenum] : 0;
+             int curline_invchars = local_prompt_invis_chars ? local_prompt_invis_chars[cursor_linenum] : wrap_offset;
+             int cursor_bufpos;
+
+             /* cursor_bufpos is where the portion of the prompt that appears
+                on the current screen line begins in the buffer. It is a
+                buffer position, an index into curline
+                (local_prompt + pmt_offset) */
+             cursor_bufpos = pmt_offset;
+             if (mb_cur_max == 1 || rl_byte_oriented)
+               cursor_bufpos += _rl_last_c_pos;
              else
-               _rl_last_c_pos = nleft + modmark;       /* buffer position */
+               cursor_bufpos += _rl_last_c_pos + curline_invchars;
+
+             if (local_prompt && local_prompt_invis_chars[cursor_linenum] &&
+                   _rl_last_c_pos > 0 &&
+                   cursor_bufpos <= prompt_last_invisible)
+               {
+                 _rl_cr ();
+                 if (modmark)
+                   _rl_output_some_chars ("*", 1);
+
+                 /* If the number of characters in local_prompt is greater
+                    than the screen width, the prompt wraps. We only want to
+                    print the portion after the line wrap. */
+
+                 /* Make sure we set _rl_last_c_pos based on the number of
+                    characters we actually output, since we start at column 0. */
+                 if (cursor_linenum > 0 && pmt_offset > 0 && nleft > pmt_offset)
+                   _rl_output_some_chars (local_prompt + pmt_offset, nleft - pmt_offset);
+                 else
+                   {
+                     _rl_output_some_chars (local_prompt, nleft);
+                     pmt_offset = 0;           /* force for calculation below */
+                   }
+       
+                 if (mb_cur_max > 1 && rl_byte_oriented == 0)
+                   /* Start width calculation where we started output. */
+                   _rl_last_c_pos = _rl_col_width (local_prompt, pmt_offset, nleft, 1) - WRAP_OFFSET(cursor_linenum, wrap_offset) + modmark;
+                 else
+                   /* Index into invisible_line+inv_lbreaks[cursor_linenum],
+                      since that's what we use in the call to
+                      _rl_move_cursor_relative below. */
+                   _rl_last_c_pos = nleft + modmark - inv_lbreaks[cursor_linenum];     /* buffer position */
+               }
            }
 
          /* Where on that line?  And where does that line start
index 514d6f8c82602abab44225549d1846c4959ef283..53be12014358a2e4ab808860b449070d9f40aa55 100644 (file)
@@ -6,9 +6,9 @@
 .\"    Case Western Reserve University
 .\"    chet.ramey@case.edu
 .\"
-.\"    Last Change: Fri Nov 29 18:17:58 EST 2024
+.\"    Last Change: Tue Dec 31 13:35:52 EST 2024
 .\"
-.TH HISTORY 3 "2024 November 29" "GNU History 8.3"
+.TH HISTORY 3 "2024 December 31" "GNU History 8.3"
 .\"
 .ie \n(.g \{\
 .ds ' \(aq
@@ -79,8 +79,8 @@
 .SH NAME
 history \- GNU History Library
 .SH COPYRIGHT
-.if t The GNU History Library is Copyright \(co 1989-2024 by the Free Software Foundation, Inc.
-.if n The GNU History Library is Copyright (C) 1989-2024 by the Free Software Foundation, Inc.
+.if t The GNU History Library is Copyright \(co 1989-2025 by the Free Software Foundation, Inc.
+.if n The GNU History Library is Copyright (C) 1989-2025 by the Free Software Foundation, Inc.
 .SH DESCRIPTION
 Many programs read input from the user a line at a time.
 The GNU
@@ -495,7 +495,8 @@ The history list will contain only \fImax\fP entries at a time.
 .F1 int unstifle_history "void"
 Stop stifling the history.  This returns the previously-set
 maximum number of history entries (as set by \fBstifle_history()\fP).
-history was stifled.  The value is positive if the history was
+history was stifled.
+The value is positive if the history was
 stifled, negative if it wasn't.
 .PP
 .F1 int history_is_stifled "void"
index 247e2081303380eda7e2d56daf55568487a337ec..e78773e2a4b2a91a857b6faab73bf50f6fb3b34c 100644 (file)
@@ -1,4 +1,4 @@
-\input texinfo    @c -*-texinfo-*-
+c\input texinfo    @c -*-texinfo-*-
 @c %**start of header (This is for running Texinfo on a region.)
 @setfilename history.info
 @settitle GNU History Library
@@ -12,7 +12,7 @@ This document describes the GNU History library
 a programming tool that provides a consistent user interface for
 recalling lines of previously typed input.
 
-Copyright @copyright{} 1988--2024 Free Software Foundation, Inc.
+Copyright @copyright{} 1988--2025 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
index c1c15b0a626196b4788ac0c478b3d28aaf36fee1..82ff77c7a9a076569a705c1a86fd8fecad159161 100644 (file)
@@ -1,7 +1,7 @@
 @ignore
 This file documents the user interface to the GNU History library.
 
-Copyright (C) 1988-2024 Free Software Foundation, Inc.
+Copyright (C) 1988-2025 Free Software Foundation, Inc.
 Authored by Brian Fox and Chet Ramey.
 
 Permission is granted to make and distribute verbatim copies of this manual
@@ -36,7 +36,7 @@ For information on the interactive use of @sc{gnu} History,
 * Introduction to History::    What is the GNU History library for?
 * History Storage::            How information is stored.
 * History Functions::          Functions that you can use.
-* History Variables::          Variables that control behaviour.
+* History Variables::          Variables that control behavior.
 * History Programming Example::        Example of using the GNU History Library.
 @end menu
 
index 04b25d1437145348765d2c63a290b8aa43e04dfc..5bce1c3d2e6af394a756a451f0f2b601719f448c 100644 (file)
@@ -1,7 +1,7 @@
 @ignore
 This file documents the user interface to the GNU History library.
 
-Copyright (C) 1988--2024 Free Software Foundation, Inc.
+Copyright (C) 1988--2025 Free Software Foundation, Inc.
 Authored by Brian Fox and Chet Ramey.
 
 Permission is granted to make and distribute verbatim copies of this manual
@@ -504,6 +504,8 @@ It may be omitted if the word designator begins with a @samp{^}, @samp{$},
 @samp{*}, @samp{-}, or @samp{%}.
 Words are numbered from the beginning of the line,
 with the first word being denoted by 0 (zero).
+That first word is usually the command word, and the arguments begin
+with the second word.
 Words are inserted into the current line separated by single spaces.
 
 @need 0.75
@@ -515,7 +517,7 @@ designates the preceding command.
 When you type this, the preceding command is repeated in toto.
 
 @item !!:$
-designates the last argument of the preceding command.
+designates the last word of the preceding command.
 This may be shortened to @code{!$}.
 
 @item !fi:2
index 3a66a9c7c9aa7d0faf3e943a2de62f79f974bd83..3c1ef4838062772d7f14b5491b3847a438612635 100644 (file)
@@ -6,9 +6,9 @@
 .\"    Case Western Reserve University
 .\"    chet.ramey@case.edu
 .\"
-.\"    Last Change: Fri Nov 29 18:17:27 EST 2024
+.\"    Last Change: Mon Dec 30 11:27:47 EST 2024
 .\"
-.TH READLINE 3 "2024 November 29" "GNU Readline 8.3"
+.TH READLINE 3 "2024 December 30" "GNU Readline 8.3"
 .\"
 .ie \n(.g \{\
 .ds ' \(aq
@@ -60,8 +60,8 @@ readline \- get a line from a user with editing
 \fBreadline\fP (\fIconst char *prompt\fP);
 .fi
 .SH COPYRIGHT
-.if n Readline is Copyright (C) 1989\-2024 Free Software Foundation,  Inc.
-.if t Readline is Copyright \(co 1989\-2024 Free Software Foundation, Inc.
+.if n Readline is Copyright (C) 1989\-2025 Free Software Foundation,  Inc.
+.if t Readline is Copyright \(co 1989\-2025 Free Software Foundation, Inc.
 .SH DESCRIPTION
 .LP
 .B readline
@@ -1248,7 +1248,7 @@ Negative arguments have no effect.
 .TP
 .B transpose\-words (M\-t)
 Drag the word before point past the word after point,
-moving point over that word as well.
+moving point past that word as well.
 If point is at the end of the line, this transposes
 the last two words on the line.
 .TP
@@ -1438,7 +1438,7 @@ the number of matches \fIN\fP;
 the word being completed;
 .IP \(bu
 \fIS\fP:\fIE\fP,
-where S and E are the start and end offsets of the word
+where \fIS\fP and \fIE\fP are the start and end offsets of the word
 in the \fBreadline\fP line buffer; then
 .IP \(bu
 each match, one per line
index d016c76259a71b724c8cde16c9cb33fdf1a980c6..904970935cf92e6738f55ec8fd1d986e8a2051e3 100644 (file)
@@ -13,7 +13,7 @@ This manual describes the GNU Readline Library
 consistency of user interface across discrete programs which provide
 a command line interface.
 
-Copyright @copyright{} 1988--2024 Free Software Foundation, Inc.
+Copyright @copyright{} 1988--2025 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
index dadca6a6ddff31cbcd221ca100b49db57fa3c842..c8965ef640499e9b40fe1442dfec8166cd532d79 100644 (file)
@@ -7,7 +7,7 @@ This document describes the GNU Readline Library, a utility for aiding
 in the consistency of user interface across discrete programs that need
 to provide a command line interface.
 
-Copyright (C) 1988--2024 Free Software Foundation, Inc.
+Copyright (C) 1988--2025 Free Software Foundation, Inc.
 
 Permission is granted to make and distribute verbatim copies of
 this manual provided the copyright notice and this permission notice
@@ -58,7 +58,7 @@ in your own programs, this section is for you.
 
 Many programs provide a command line interface, such as @code{mail},
 @code{ftp}, and @code{sh}.
-For such programs, the default behaviour of Readline is sufficient.
+For such programs, the default behavior of Readline is sufficient.
 This section describes how to use Readline in
 the simplest way possible, perhaps to replace calls in your code to
 @code{fgets()}.
@@ -149,7 +149,7 @@ rl_gets ()
 @}
 @end example
 
-This function gives the user the default behaviour of @key{TAB}
+This function gives the user the default behavior of @key{TAB}
 completion: filename completion.
 If you do not want Readline to
 complete filenames, you can change the binding of the @key{TAB} key
@@ -768,7 +768,7 @@ The caller should free @var{keymap}.
 
 @deftypefun void rl_free_keymap (Keymap keymap)
 Free all storage associated with @var{keymap}.
-This calls @code{rl_discard_keymap} to free subordindate
+This calls @code{rl_discard_keymap} to free subordinate
 keymaps and macros.
 @end deftypefun
 
@@ -1168,7 +1168,7 @@ displaying a new message in the message area with @code{rl_message()}.
 @deftypefun void rl_restore_prompt (void)
 Restore the local Readline prompt display state saved by the most
 recent call to @code{rl_save_prompt}.
-if you called @code{rl_save_prompt} to save the prompt before a call
+If you called @code{rl_save_prompt} to save the prompt before a call
 to @code{rl_message}, you should call this function before the
 corresponding call to @code{rl_clear_message}.
 @end deftypefun
index 757661bad3125ce89d19c0bd1d80aca59c2c3234..27078b5e01324379c6aa042a6fae1bc5872eda02 100644 (file)
@@ -11,7 +11,7 @@ use these features.  There is a document entitled "readline.texinfo"
 which contains both end-user and programmer documentation for the
 GNU Readline Library.
 
-Copyright (C) 1988--2024 Free Software Foundation, Inc.
+Copyright (C) 1988--2025 Free Software Foundation, Inc.
 
 Authored by Brian Fox and Chet Ramey.
 
@@ -466,9 +466,10 @@ A sample value might be @samp{\e[01;33m}.
 
 @item active-region-end-color
 @vindex active-region-end-color
-A string variable that "undoes" the effects of @code{active-region-start-color}
-and restores "normal" terminal display appearance after displaying text
-in the active region.
+A string variable that ``undoes''
+the effects of @code{active-region-start-color}
+and restores ``normal''
+terminal display appearance after displaying text in the active region.
 This string must not take up any physical character positions on the display,
 so it should consist only of terminal escape sequences.
 It is output to the terminal after displaying the text in the active region.
@@ -703,7 +704,7 @@ are saved.
 If set to a value less than zero, the number of history entries is not
 limited.
 @ifset BashFeatures
-By default, Bash sets the the maximum number of history entries to
+By default, Bash sets the maximum number of history entries to
 the value of the @code{HISTSIZE} shell variable.
 @end ifset
 @ifclear BashFeatures
@@ -1055,7 +1056,7 @@ The eight-bit character whose value is the hexadecimal value @var{HH}
 When entering the text of a macro, single or double quotes must
 be used to indicate a macro definition.
 Unquoted text is assumed to be a function name.
-Tthe backslash escapes described above are expanded
+The backslash escapes described above are expanded
 in the macro body.
 Backslash will quote any other character in the macro text,
 including @samp{"} and @samp{'}.
@@ -1188,7 +1189,7 @@ binding, variable assignment, and conditional syntax.
 
 @example
 @page
-# This file controls the behaviour of line input editing for
+# This file controls the behavior of line input editing for
 # programs that use the GNU Readline library.  Existing
 # programs include FTP, Bash, and GDB.
 #
@@ -1316,10 +1317,13 @@ In the following descriptions, @dfn{point} refers to the current cursor
 position, and @dfn{mark} refers to a cursor position saved by the
 @code{set-mark} command.
 The text between the point and mark is referred to as the @dfn{region}.
-Readline has the concept of an @emph{active region}:
+Readline
+has the concept of an @emph{active region}:
 when the region is active,
 Readline redisplay highlights the region using the
-value of the @code{active-region-start-color} variable.
+value of the
+@code{active-region-start-color}
+variable.
 The @code{enable-active-region} variable turns this on and off.
 Several commands set the region to active; those are noted below.
 
@@ -1806,7 +1810,7 @@ the number of matches @var{N};
 the word being completed;
 @item
 @var{S}:@var{E},
-where S and E are the start and end offsets of the word
+where @var{S} and @var{E} are the start and end offsets of the word
 in the Readline line buffer; then
 @item
 each match, one per line
@@ -2057,7 +2061,7 @@ Expand the line by performing shell word expansions.
 This performs alias and history expansion,
 $'@var{string}' and $"@var{string}" quoting,
 tilde expansion, parameter and variable expansion, arithmetic expansion,
-command and proces substitution,
+command and process substitution,
 word splitting, and quote removal.  
 An explicit argument suppresses command and process substitution.
 
index 51255cacbc6d503d359c4a84bf46d8005ea6e7a0..6265c63c5d632b0265c2f40c0cdcd21388aba897 100644 (file)
@@ -12,7 +12,7 @@ This manual describes the end user interface of the GNU Readline Library
 consistency of user interface across discrete programs which provide
 a command line interface.
 
-Copyright @copyright{} 1988--2024 Free Software Foundation, Inc.
+Copyright @copyright{} 1988--2025 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
index 5353622c31ce57ab35c50f2d5c7c4a6aa69c59fe..9faa386904d9d848392c5c088d0138ffb63b904b 100644 (file)
@@ -1,11 +1,11 @@
 @ignore
-Copyright (C) 1988-2024 Free Software Foundation, Inc. 
+Copyright (C) 1988-2025 Free Software Foundation, Inc. 
 @end ignore
 
 @set EDITION 8.3
 @set VERSION 8.3
 
-@set UPDATED 29 November 2024
-@set UPDATED-MONTH November 2024
+@set UPDATED 30 December 2024
+@set UPDATED-MONTH December 2024
 
-@set LASTCHANGE Fri Nov 29 18:18:20 EST 2024
+@set LASTCHANGE Mon Dec 30 11:27:03 EST 2024
index 068feccd1c29cb66b8bcef45445f949e534d92bd..fc0008e890c85e68a6dba97f067b55f21ab27db7 100644 (file)
@@ -141,7 +141,7 @@ get_history_event (const char *string, int *caller_index, int delimiting_quote)
   register char c;
   HIST_ENTRY *entry;
   int which, sign, local_index, substring_okay;
-  int search_flags;
+  int search_flags, old_offset;
   char *temp;
 
   /* The event can be specified in a number of ways.
@@ -251,9 +251,10 @@ get_history_event (const char *string, int *caller_index, int delimiting_quote)
 
   *caller_index = i;
 
+  old_offset = history_offset;         /* XXX */
 #define FAIL_SEARCH() \
   do { \
-    history_offset = history_length; xfree (temp) ; return (char *)NULL; \
+    history_offset = old_offset; xfree (temp) ; return (char *)NULL; \
   } while (0)
 
   /* If there is no search string, try to use the previous search string,
@@ -282,7 +283,7 @@ get_history_event (const char *string, int *caller_index, int delimiting_quote)
          entry = current_history ();
          if (entry == 0)
            FAIL_SEARCH ();
-         history_offset = history_length;
+         history_offset = old_offset;  /* XXX - was history_length */
        
          /* If this was a substring search, then remember the
             string that we matched for word substitution. */
index 23cf8d31d5741097f65379bb405e6340065eb884..ac1de28c77e3abec7f0860774b55008ffe745dc6 100644 (file)
@@ -640,6 +640,7 @@ extern int _rl_history_search_pos;
 
 /* signals.c */
 extern int volatile _rl_caught_signal;
+extern int volatile _rl_handling_signal;
 
 extern _rl_sigcleanup_func_t *_rl_sigcleanup;
 extern void *_rl_sigcleanarg;
diff --git a/rltty.c b/rltty.c
index a4ad94c93b71663044afafd0b3baf2fd4f4603f4..9681775aca8c391179542f26c437214c2cbdde70 100644 (file)
--- a/rltty.c
+++ b/rltty.c
@@ -80,15 +80,25 @@ static int ksrflow;
 #endif
 
 /* Dummy call to force a backgrounded readline to stop before it tries
-   to get the tty settings. */
+   to get the tty settings. But we use the information to set our idea
+   of the screen size if we're in a signal handling context, since it
+   doesn't make sense to waste it. */
 static void
 set_winsize (int tty)
 {
-#if defined (TIOCGWINSZ)
+#if defined (TIOCGWINSZ) || defined (HAVE_TCGETWINSIZE)
   struct winsize w;
-
-  if (ioctl (tty, TIOCGWINSZ, &w) == 0)
-      (void) ioctl (tty, TIOCSWINSZ, &w);
+  
+  if (_rl_tcgetwinsize (tty, &w) == 0)
+    {
+      (void) _rl_tcsetwinsize (tty, &w);
+      /* We restrict this to the case where we're running a signal handler
+        and executing after a SIGTSTP. We can relax it later. */
+#if defined (SIGTSTP)
+      if (RL_ISSTATE (RL_STATE_SIGHANDLER) && _rl_handling_signal == SIGTSTP && rl_prefer_env_winsize == 0)
+       _rl_set_screen_size (w.ws_row, w.ws_col);       /* don't waste the info */
+#endif
+    }
 #endif /* TIOCGWINSZ */
 }
 
index d198fcf87232f68fba0e26ee218b5d4f2a4dec05..3d1c97fcefa34f55d91a936442a2ccf83f3d499f 100644 (file)
@@ -55,4 +55,7 @@
 #  define tcflow(fd, action)   ioctl(fd, TCXONC, action)
 #endif
 
+extern int _rl_tcgetwinsize (int, struct winsize *);
+extern void _rl_tcsetwinsize (int, struct winsize *);
+
 #endif /* _RL_WINSIZE_H */
index 1cdb762981465e744baf32522e25eb89a2f81b39..8c4f3fad20380b23ba75419d5ebff0157692466d 100644 (file)
--- a/signals.c
+++ b/signals.c
@@ -88,6 +88,7 @@ int rl_catch_sigwinch = 0;    /* for the readline state struct in readline.c */
 
 /* Private variables. */
 int volatile _rl_caught_signal = 0;    /* should be sig_atomic_t, but that requires including <signal.h> everywhere */
+int volatile _rl_handling_signal = 0;
 
 /* If non-zero, print characters corresponding to received signals as long as
    the user has indicated his desire to do so (_rl_echo_control_chars). */
@@ -133,6 +134,7 @@ _rl_signal_handler (int sig)
   if (sig == SIGWINCH)
     {
       RL_SETSTATE(RL_STATE_SIGHANDLER);
+      _rl_handling_signal = SIGWINCH;
 
       rl_resize_terminal ();
       /* XXX - experimental for now */
@@ -142,6 +144,7 @@ _rl_signal_handler (int sig)
       if (rl_signal_event_hook)
        (*rl_signal_event_hook) ();
 
+      _rl_handling_signal = 0;
       RL_UNSETSTATE(RL_STATE_SIGHANDLER);
     }
   else
@@ -177,6 +180,7 @@ _rl_handle_signal (int sig)
 #endif /* !HAVE_POSIX_SIGNALS */
 
   RL_SETSTATE(RL_STATE_SIGHANDLER);
+  _rl_handling_signal = sig;
 
 #if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS)
   /* Since the signal will not be blocked while we are in the signal
@@ -301,6 +305,7 @@ _rl_handle_signal (int sig)
       rl_reset_after_signal ();      
     }
 
+  _rl_handling_signal = 0;
   RL_UNSETSTATE(RL_STATE_SIGHANDLER);
   SIGHANDLER_RETURN;
 }
index 7003d2a97d99cef0f10335bafd97ce6692643637..2c70553d1c9dcec96f45ec001c5ffa953a652ef5 100644 (file)
@@ -258,6 +258,30 @@ _win_get_screensize (int *swp, int *shp)
 }
 #endif
 
+int
+_rl_tcgetwinsize (int tty, struct winsize *wp)
+{
+#if defined (HAVE_TCGETWINSIZE)
+  return (tcgetwinsize (tty, wp));
+#elif defined (TIOCGWINSZ)
+  return (ioctl (tty, TIOCGWINSZ, wp));
+#else
+  return -1;
+#endif
+}
+
+void
+_rl_tcsetwinsize (int tty, struct winsize *wp)
+{
+#if defined (HAVE_TCGETWINSIZE)
+  tcsetwinsize (tty, wp);
+#elif defined (TIOCGWINSZ)
+  ioctl (tty, TIOCSWINSZ, wp);
+#else
+  ;
+#endif
+}
+
 /* Get readline's idea of the screen size.  TTY is a file descriptor open
    to the terminal.  If IGNORE_ENV is true, we do not pay attention to the
    values of $LINES and $COLUMNS.  The tests for TERM_STRING_BUFFER being
@@ -266,19 +290,19 @@ void
 _rl_get_screen_size (int tty, int ignore_env)
 {
   char *ss;
-#if defined (TIOCGWINSZ)
+#if defined (TIOCGWINSZ) || defined (HAVE_TCGETWINSIZE)
   struct winsize window_size;
-#endif /* TIOCGWINSZ */
+#endif /* TIOCGWINSZ || HAVE_TCGETWINSIZE */
   int wr, wc;
 
   wr = wc = -1;
-#if defined (TIOCGWINSZ)
-  if (ioctl (tty, TIOCGWINSZ, &window_size) == 0)
+#if defined (TIOCGWINSZ) || defined (HAVE_TCGETWINSIZE)
+  if (_rl_tcgetwinsize (tty, &window_size) == 0)
     {
       wc = (int) window_size.ws_col;
       wr = (int) window_size.ws_row;
     }
-#endif /* TIOCGWINSZ */
+#endif /* TIOCGWINSZ || HAVE_TCGETWINSIZE */
 
 #if defined (__EMX__)
   _emx_get_screensize (&wc, &wr);
diff --git a/util.c b/util.c
index d03c899e57002afe4f4837cb73040bdee01aae89..0a5df9b4009e0a6a2832ab8f90767c45f0fc3910 100644 (file)
--- a/util.c
+++ b/util.c
@@ -112,6 +112,7 @@ _rl_abort_internal (void)
   RL_UNSETSTATE (RL_STATE_MULTIKEY);   /* XXX */
 
   rl_last_func = (rl_command_func_t *)NULL;
+  _rl_command_to_execute = 0;
 
   _rl_longjmp (_rl_top_level, 1);
   return (0);