changeset 6989:5f2c92da4d9c

readline: update to 8.1 patch level 7 Add upstream patches for readline. * readline-3-fd_set.patch: Remove hunk that is part of readline-0-004. * dist-files.mk: Update list with new patches.
author Markus Mützel <markus.muetzel@gmx.de>
date Fri, 01 Dec 2023 19:47:25 +0100
parents 8cffc9e9e770
children c7a8a72e7547
files dist-files.mk src/readline-0-001-fix-crash-when-readline-is-star.patch src/readline-0-001-upstream.patch src/readline-0-002-avoid-possible-crash-when-tryin.patch src/readline-0-003-fix-typo-when-specifying-readli.patch src/readline-0-004-fix-compilation-on-systems-that.patch src/readline-0-005-fix-for-callback-signal-handlin.patch src/readline-0-006-fix-for-callback-signal-handlin.patch src/readline-0-007-display-newline-if-readline-is-.patch src/readline-3-fd_set.patch
diffstat 10 files changed, 344 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/dist-files.mk	Wed Nov 29 18:39:44 2023 +0100
+++ b/dist-files.mk	Fri Dec 01 19:47:25 2023 +0100
@@ -661,7 +661,13 @@
   randrproto.mk \
   rapidjson-1-prettywriter.patch \
   rapidjson.mk \
-  readline-0-001-upstream.patch \
+  readline-0-001-fix-crash-when-readline-is-star.patch \
+  readline-0-002-avoid-possible-crash-when-tryin.patch \
+  readline-0-003-fix-typo-when-specifying-readli.patch \
+  readline-0-004-fix-compilation-on-systems-that.patch \
+  readline-0-005-fix-for-callback-signal-handlin.patch \
+  readline-0-006-fix-for-callback-signal-handlin.patch \
+  readline-0-007-display-newline-if-readline-is-.patch \
   readline-1-display.patch \
   readline-1-fixes.patch \
   readline-1-sigwinch.patch \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/readline-0-001-fix-crash-when-readline-is-star.patch	Fri Dec 01 19:47:25 2023 +0100
@@ -0,0 +1,38 @@
+From 7274faabe97ce53d6b464272d7e6ab6c1392837b Mon Sep 17 00:00:00 2001
+From: Chet Ramey <chet.ramey@case.edu>
+Date: Wed, 5 Oct 2022 10:41:16 -0400
+Subject: [PATCH 1/7] Readline-8.2 patch 1: fix crash when readline is started
+ with an invalid locale specification
+
+---
+ nls.c        |   4 ++++
+ patchlevel   |   2 +-
+ 2 files changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/nls.c b/nls.c
+index 5c6a13b..8c027d6 100644
+--- a/nls.c
++++ b/nls.c
+@@ -141,6 +141,10 @@ _rl_init_locale (void)
+   if (lspec == 0)
+     lspec = "";
+   ret = setlocale (LC_CTYPE, lspec);	/* ok, since it does not change locale */
++  if (ret == 0 || *ret == 0)
++    ret = setlocale (LC_CTYPE, (char *)NULL);
++  if (ret == 0 || *ret == 0)
++    ret = RL_DEFAULT_LOCALE;
+ #else
+   ret = (lspec == 0 || *lspec == 0) ? RL_DEFAULT_LOCALE : lspec;
+ #endif
+diff --git a/patchlevel b/patchlevel
+index d8c9df7..fdf4740 100644
+--- a/patchlevel
++++ b/patchlevel
+@@ -1,3 +1,3 @@
+ # Do not edit -- exists only for use by patch
+ 
+-0
++1
+-- 
+2.38.0.windows.1
+
--- a/src/readline-0-001-upstream.patch	Wed Nov 29 18:39:44 2023 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-			   READLINE PATCH REPORT
-			   =====================
-
-Readline-Release: 8.2
-Patch-ID: readline82-001
-
-Bug-Reported-by:	Kan-Ru Chen <koster@debian.org>
-Bug-Reference-ID:
-Bug-Reference-URL:	https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1021109
-
-Bug-Description:
-
-Starting a readline application with an invalid locale specification for
-LC_ALL/LANG/LC_CTYPE can cause it crash on the first call to readline.
-
-diff -ur a/nls.c b/nls.c
---- a/nls.c	2022-08-15 09:38:51.000000000 -0400
-+++ b/nls.c	2021-01-18 2022-10-05 09:23:22.000000000 -0400
-@@ -142,4 +142,8 @@
-     lspec = "";
-   ret = setlocale (LC_CTYPE, lspec);	/* ok, since it does not change locale */
-+  if (ret == 0 || *ret == 0)
-+    ret = setlocale (LC_CTYPE, (char *)NULL);
-+  if (ret == 0 || *ret == 0)
-+    ret = RL_DEFAULT_LOCALE;
- #else
-   ret = (lspec == 0 || *lspec == 0) ? RL_DEFAULT_LOCALE : lspec;
-
-diff -ur a/patchlevel b/patchlevel
---- a/patchlevel	2013-11-15 08:11:11.000000000 -0500
-+++ b/patchlevel	2014-03-21 08:28:40.000000000 -0400
-***************
-@@ -1,3 +1,3 @@
- # Do not edit -- exists only for use by patch
- 
--0
-+1
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/readline-0-002-avoid-possible-crash-when-tryin.patch	Fri Dec 01 19:47:25 2023 +0100
@@ -0,0 +1,41 @@
+From 83de95eaba5debdf544d0ef43cf88de3bc5cd7dd Mon Sep 17 00:00:00 2001
+From: Chet Ramey <chet.ramey@case.edu>
+Date: Fri, 17 Nov 2023 16:00:59 -0500
+Subject: [PATCH 2/7] Readline-8.2 patch 2: avoid possible crash when trying to
+ zero out a line buffer that's potentially not null-terminated
+
+---
+ display.c  | 7 ++-----
+ patchlevel | 2 +-
+ 2 files changed, 3 insertions(+), 6 deletions(-)
+
+diff --git a/display.c b/display.c
+index c1135ec..ad573f9 100644
+--- a/display.c
++++ b/display.c
+@@ -2683,11 +2683,8 @@ rl_forced_update_display (void)
+   register char *temp;
+ 
+   if (visible_line)
+-    {
+-      temp = visible_line;
+-      while (*temp)
+-	*temp++ = '\0';
+-    }
++    memset (visible_line, 0, line_size);
++
+   rl_on_new_line ();
+   forced_display++;
+   (*rl_redisplay_function) ();
+diff --git a/patchlevel b/patchlevel
+index fdf4740..7cbda82 100644
+--- a/patchlevel
++++ b/patchlevel
+@@ -1,3 +1,3 @@
+ # Do not edit -- exists only for use by patch
+ 
+-1
++2
+-- 
+2.38.0.windows.1
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/readline-0-003-fix-typo-when-specifying-readli.patch	Fri Dec 01 19:47:25 2023 +0100
@@ -0,0 +1,36 @@
+From ba77167d33ba8eca87f1315c39f4181cc1e7aeae Mon Sep 17 00:00:00 2001
+From: Chet Ramey <chet.ramey@case.edu>
+Date: Fri, 17 Nov 2023 16:01:56 -0500
+Subject: [PATCH 3/7] Readline-8.2 patch 3: fix typo when specifying readline's
+ custom color prefix
+
+---
+ colors.c   | 2 +-
+ patchlevel | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/colors.c b/colors.c
+index dba81a2..4212c64 100644
+--- a/colors.c
++++ b/colors.c
+@@ -73,7 +73,7 @@
+ static bool is_colored (enum indicator_no type);
+ static void restore_default_color (void);
+ 
+-#define RL_COLOR_PREFIX_EXTENSION	"readline-colored-completion-prefix"
++#define RL_COLOR_PREFIX_EXTENSION	".readline-colored-completion-prefix"
+ 
+ COLOR_EXT_TYPE *_rl_color_ext_list = 0;
+ 
+diff --git a/patchlevel b/patchlevel
+index 7cbda82..ce3e355 100644
+--- a/patchlevel
++++ b/patchlevel
+@@ -1,3 +1,3 @@
+ # Do not edit -- exists only for use by patch
+ 
+-2
++3
+-- 
+2.38.0.windows.1
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/readline-0-004-fix-compilation-on-systems-that.patch	Fri Dec 01 19:47:25 2023 +0100
@@ -0,0 +1,55 @@
+From c59116b15d95a94a9a2dd8ce5fe08850e004411a Mon Sep 17 00:00:00 2001
+From: Chet Ramey <chet.ramey@case.edu>
+Date: Fri, 17 Nov 2023 16:02:46 -0500
+Subject: [PATCH 4/7] Readline-8.2 patch 4: fix compilation on systems that
+ provide select or pselect but not both
+
+---
+ input.c    | 6 ++++--
+ patchlevel | 2 +-
+ 2 files changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/input.c b/input.c
+index 6f038d4..68d418c 100644
+--- a/input.c
++++ b/input.c
+@@ -151,7 +151,9 @@ int rl_timeout_remaining (unsigned int *, unsigned int *);
+ 
+ int _rl_timeout_init (void);
+ int _rl_timeout_sigalrm_handler (void);
++#if defined (RL_TIMEOUT_USE_SELECT)
+ int _rl_timeout_select (int, fd_set *, fd_set *, fd_set *, const struct timeval *, const sigset_t *);
++#endif
+ 
+ static void _rl_timeout_handle (void);
+ #if defined (RL_TIMEOUT_USE_SIGALRM)
+@@ -248,7 +250,7 @@ rl_gather_tyi (void)
+   register int tem, result;
+   int chars_avail, k;
+   char input;
+-#if defined(HAVE_SELECT)
++#if defined (HAVE_PSELECT) || defined (HAVE_SELECT)
+   fd_set readfds, exceptfds;
+   struct timeval timeout;
+ #endif
+@@ -805,7 +807,7 @@ rl_getc (FILE *stream)
+   int result;
+   unsigned char c;
+   int fd;
+-#if defined (HAVE_PSELECT)
++#if defined (HAVE_PSELECT) || defined (HAVE_SELECT)
+   sigset_t empty_set;
+   fd_set readfds;
+ #endif
+diff --git a/patchlevel b/patchlevel
+index ce3e355..626a945 100644
+--- a/patchlevel
++++ b/patchlevel
+@@ -1,3 +1,3 @@
+ # Do not edit -- exists only for use by patch
+ 
+-3
++4
+-- 
+2.38.0.windows.1
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/readline-0-005-fix-for-callback-signal-handlin.patch	Fri Dec 01 19:47:25 2023 +0100
@@ -0,0 +1,40 @@
+From 37ec317397e442ee8616b3b2aa81bfb8dde71a06 Mon Sep 17 00:00:00 2001
+From: Chet Ramey <chet.ramey@case.edu>
+Date: Fri, 17 Nov 2023 16:04:13 -0500
+Subject: [PATCH 5/7] Readline-8.2 patch 5: fix for callback signal handling
+ when a signal arrives after readline checks but before it restores the
+ application's signal handlers
+
+---
+ callback.c | 5 ++++-
+ patchlevel | 2 +-
+ 2 files changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/callback.c b/callback.c
+index 69df77d..7209ec3 100644
+--- a/callback.c
++++ b/callback.c
+@@ -115,7 +115,10 @@ rl_callback_handler_install (const char *prompt, rl_vcpfunc_t *linefunc)
+ #define CALLBACK_READ_RETURN() \
+   do { \
+     if (rl_persistent_signal_handlers == 0) \
+-      rl_clear_signals (); \
++      { \
++        rl_clear_signals (); \
++        if (_rl_caught_signal) _rl_signal_handler (_rl_caught_signal); \
++      } \
+     return; \
+   } while (0)
+ #else
+diff --git a/patchlevel b/patchlevel
+index 626a945..e0ba09d 100644
+--- a/patchlevel
++++ b/patchlevel
+@@ -1,3 +1,3 @@
+ # Do not edit -- exists only for use by patch
+ 
+-4
++5
+-- 
+2.38.0.windows.1
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/readline-0-006-fix-for-callback-signal-handlin.patch	Fri Dec 01 19:47:25 2023 +0100
@@ -0,0 +1,88 @@
+From 93a6afa50f953246f7c0f93b219a1e4010ba704b Mon Sep 17 00:00:00 2001
+From: Chet Ramey <chet.ramey@case.edu>
+Date: Fri, 17 Nov 2023 16:05:13 -0500
+Subject: [PATCH 6/7] Readline-8.2 patch 6: fix for callback signal handling
+ when a signal arrives before readline calls rl_getc and handling it changes
+ callback state
+
+---
+ input.c    | 28 +++++++++++++++++++++++++++-
+ patchlevel |  2 +-
+ 2 files changed, 28 insertions(+), 2 deletions(-)
+
+diff --git a/input.c b/input.c
+index 68d418c..f68fcac 100644
+--- a/input.c
++++ b/input.c
+@@ -804,7 +804,7 @@ rl_read_key (void)
+ int
+ rl_getc (FILE *stream)
+ {
+-  int result;
++  int result, ostate, osig;
+   unsigned char c;
+   int fd;
+ #if defined (HAVE_PSELECT) || defined (HAVE_SELECT)
+@@ -815,8 +815,22 @@ rl_getc (FILE *stream)
+   fd = fileno (stream);
+   while (1)
+     {
++      osig = _rl_caught_signal;
++      ostate = rl_readline_state;
++
+       RL_CHECK_SIGNALS ();
+ 
++#if defined (READLINE_CALLBACKS)
++      /* Do signal handling post-processing here, but just in callback mode
++	 for right now because the signal cleanup can change some of the
++	 callback state, and we need to either let the application have a
++	 chance to react or abort some current operation that gets cleaned
++	 up by rl_callback_sigcleanup(). If not, we'll just run through the
++	 loop again. */
++      if (osig != 0 && (ostate & RL_STATE_CALLBACK))
++	goto postproc_signal;
++#endif
++
+       /* We know at this point that _rl_caught_signal == 0 */
+ 
+ #if defined (__MINGW32__)
+@@ -880,6 +894,9 @@ rl_getc (FILE *stream)
+ /* fprintf(stderr, "rl_getc: result = %d errno = %d\n", result, errno); */
+ 
+ handle_error:
++      osig = _rl_caught_signal;
++      ostate = rl_readline_state;
++
+       /* If the error that we received was EINTR, then try again,
+ 	 this is simply an interrupted system call to read ().  We allow
+ 	 the read to be interrupted if we caught SIGHUP, SIGTERM, or any
+@@ -920,8 +937,17 @@ handle_error:
+         RL_CHECK_SIGNALS ();
+ #endif  /* SIGALRM */
+ 
++postproc_signal:
++      /* POSIX says read(2)/pselect(2)/select(2) don't return EINTR for any
++	 reason other than being interrupted by a signal, so we can safely
++	 call the application's signal event hook. */
+       if (rl_signal_event_hook)
+ 	(*rl_signal_event_hook) ();
++#if defined (READLINE_CALLBACKS)
++      else if (osig == SIGINT && (ostate & RL_STATE_CALLBACK) && (ostate & (RL_STATE_ISEARCH|RL_STATE_NSEARCH|RL_STATE_NUMERICARG)))
++        /* just these cases for now */
++        _rl_abort_internal ();
++#endif
+     }
+ }
+ 
+diff --git a/patchlevel b/patchlevel
+index e0ba09d..6ebd6a5 100644
+--- a/patchlevel
++++ b/patchlevel
+@@ -1,3 +1,3 @@
+ # Do not edit -- exists only for use by patch
+ 
+-5
++6
+-- 
+2.38.0.windows.1
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/readline-0-007-display-newline-if-readline-is-.patch	Fri Dec 01 19:47:25 2023 +0100
@@ -0,0 +1,39 @@
+From bfe9c573a9e376323929c80b2b71c59727fab0cc Mon Sep 17 00:00:00 2001
+From: Chet Ramey <chet.ramey@case.edu>
+Date: Fri, 17 Nov 2023 16:06:49 -0500
+Subject: [PATCH 7/7] Readline-8.2 patch 7: display newline if readline is
+ called without a prompt string and return is typed on a single empty line
+
+---
+ display.c  | 4 ++--
+ patchlevel | 2 +-
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/display.c b/display.c
+index ad573f9..803d4ce 100644
+--- a/display.c
++++ b/display.c
+@@ -3338,9 +3338,9 @@ _rl_update_final (void)
+       puts_face (&last_line[_rl_screenwidth - 1 + woff],
+ 		 &last_face[_rl_screenwidth - 1 + woff], 1);
+     }
+-  _rl_vis_botlin = 0;
+-  if (botline_length > 0 || _rl_last_c_pos > 0)
++  if ((_rl_vis_botlin == 0 && botline_length == 0) || botline_length > 0 || _rl_last_c_pos > 0)
+     rl_crlf ();
++  _rl_vis_botlin = 0;
+   fflush (rl_outstream);
+   rl_display_fixed++;
+ }
+diff --git a/patchlevel b/patchlevel
+index 6ebd6a5..e340b58 100644
+--- a/patchlevel
++++ b/patchlevel
+@@ -1,3 +1,3 @@
+ # Do not edit -- exists only for use by patch
+ 
+-6
++7
+-- 
+2.38.0.windows.1
+
--- a/src/readline-3-fd_set.patch	Wed Nov 29 18:39:44 2023 +0100
+++ b/src/readline-3-fd_set.patch	Fri Dec 01 19:47:25 2023 +0100
@@ -1,20 +1,6 @@
 Guard functions that use types that aren't available on all platforms with
 pre-processor conditions.
 
-diff -urN readline-8.2/input.c.orig readline-8.2/input.c
---- readline-8.2/input.c.orig	2022-11-12 17:54:14.800371248 +0100
-+++ readline-8.2/input.c	2022-11-12 17:58:13.327167979 +0100
-@@ -151,7 +151,9 @@
- 
- int _rl_timeout_init (void);
- int _rl_timeout_sigalrm_handler (void);
-+#if defined (HAVE_PSELECT) || defined (HAVE_SELECT)
- int _rl_timeout_select (int, fd_set *, fd_set *, fd_set *, const struct timeval *, const sigset_t *);
-+#endif
- 
- static void _rl_timeout_handle (void);
- #if defined (RL_TIMEOUT_USE_SIGALRM)
-
 diff -urN readline-8.2/rlprivate.h.orig readline-8.2/rlprivate.h
 --- readline-8.2/rlprivate.h.orig	2022-08-12 00:35:16.000000000 +0200
 +++ readline-8.2/rlprivate.h	2022-11-12 17:43:54.266291863 +0100