lib/readline/doc/{history.3,hstech.texi}
- history_expansion: change description to note new const first arg
+
+ 1/21
+ ----
+lib/readline/input.c
+ - rl_gather_tyi: move call to rl_input_available_hook to the top,
+ giving it first shot. There's still no way for it to set chars_avail.
+ Conditionalize the rest of the input methods based on whether the
+ result == -1.
+
+lib/readline/rl_private.h
+ - move the decision making about RL_TIMEOUT_USE_SELECT/RL_TIMEOUT_USE_SIGALRM
+ here from input.c
+
+ 1/23
+ ----
+trap.c
+ - restore_default_signal: if we have a signal that's not trapped, but
+ is a signal that is set to SIG_ASYNCSIG, POSIX interp 751 requires
+ the shell to allow it to be reset to the default, even though it
+ wasn't already trapped
+
+subst.c
+ - do_assignment_internal: don't allocate new memory for NAME, just
+ modify and restore it in place
#include <signal.h>
#include <stdio.h>
+#include <stdlib.h>
extern const char * const sys_siglist[];
typedef void sighandler();
-main(argc, argv)
-int argc;
-char **argv;
+int
+main(int argc, char **argv)
{
- register int i;
+ int i;
sighandler *h;
for (i = 1; i < NSIG; i++) {
#include <sys/types.h>
#include <signal.h>
#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
-extern char *strrchr();
static char *signames[NSIG];
char *progname;
-void sigstat();
+void sigstat(int);
+void init_signames(void);
+int
main(argc, argv)
int argc;
char **argv;
printf("%s: signal is trapped (?)\n", signame);
}
+void
init_signames()
{
register int i;
different input source, it should set the hook appropriately.
Readline queries for available input when implementing intra-key-sequence
timeouts during input and incremental searches.
+This function must return zero if there is no input available, and non-zero
+if input is available.
This may use an application-specific timeout before returning a value;
Readline uses the value passed to @code{rl_set_keyboard_input_timeout()}
or the value of the user-settable @var{keyseq-timeout} variable.
@set EDITION 8.2
@set VERSION 8.2
-@set UPDATED 19 January 2023
+@set UPDATED 21 January 2023
@set UPDATED-MONTH January 2023
-@set LASTCHANGE Thu Jan 19 17:22:06 EST 2023
+@set LASTCHANGE Sat Jan 21 17:10:44 EST 2023
/* Readline timeouts */
-/* I don't know how to set a timeout for _getch() in MinGW32, so we use
- SIGALRM. */
-#if (defined (HAVE_PSELECT) || defined (HAVE_SELECT)) && !defined (__MINGW32__)
-# define RL_TIMEOUT_USE_SELECT
-#else
-# define RL_TIMEOUT_USE_SIGALRM
-#endif
+/* We now define RL_TIMEOUT_USE_SELECT or RL_TIMEOUT_USE_SIGALRM in rlprivate.h */
int rl_set_timeout (unsigned int, unsigned int);
int rl_timeout_remaining (unsigned int *, unsigned int *);
input = 0;
tty = fileno (rl_instream);
+ /* Move this up here to give it first shot, but it can't set chars_avail */
+ /* XXX - need rl_chars_available_hook? */
+ if (rl_input_available_hook)
+ {
+ result = (*rl_input_available_hook) ();
+ if (result == 0)
+ result = -1;
+ }
+
#if defined (HAVE_PSELECT) || defined (HAVE_SELECT)
- FD_ZERO (&readfds);
- FD_ZERO (&exceptfds);
- FD_SET (tty, &readfds);
- FD_SET (tty, &exceptfds);
- USEC_TO_TIMEVAL (_keyboard_input_timeout, timeout);
+ if (result == -1)
+ {
+ FD_ZERO (&readfds);
+ FD_ZERO (&exceptfds);
+ FD_SET (tty, &readfds);
+ FD_SET (tty, &exceptfds);
+ USEC_TO_TIMEVAL (_keyboard_input_timeout, timeout);
#if defined (RL_TIMEOUT_USE_SELECT)
- result = _rl_timeout_select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout, NULL);
+ result = _rl_timeout_select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout, NULL);
#else
- result = select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout);
+ result = select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout);
#endif
- if (result <= 0)
- return 0; /* Nothing to read. */
+ if (result <= 0)
+ return 0; /* Nothing to read. */
+ }
#endif
- result = -1;
- errno = 0;
#if defined (FIONREAD)
- result = ioctl (tty, FIONREAD, &chars_avail);
- if (result == -1 && errno == EIO)
- return -1;
if (result == -1)
- chars_avail = 0;
-#endif
-
- if (result == -1 && rl_input_available_hook)
{
- result = (*rl_input_available_hook) ();
- if (result == 0)
- result = -1;
+ errno = 0;
+ result = ioctl (tty, FIONREAD, &chars_avail);
+ if (result == -1 && errno == EIO)
+ return -1;
+ if (result == -1)
+ chars_avail = 0;
}
+#endif
#if defined (O_NDELAY)
if (result == -1)
#if defined (__MINGW32__)
/* Use getch/_kbhit to check for available console input, in the same way
that we read it normally. */
- chars_avail = isatty (tty) ? _kbhit () : 0;
- result = 0;
+ if (result == -1)
+ {
+ chars_avail = isatty (tty) ? _kbhit () : 0;
+ result = 0;
+ }
#endif
/* If there's nothing available, don't waste time trying to read
/* This should only be called if RL_TIMEOUT_USE_SELECT is defined. */
-#if defined (HAVE_PSELECT) || defined (HAVE_SELECT)
+#if defined (RL_TIMEOUT_USE_SELECT)
int
_rl_timeout_select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timeval *timeout, const sigset_t *sigmask)
{
extern int _rl_timeout_init (void);
extern int _rl_timeout_handle_sigalrm (void);
-#if defined (_POSIXSELECT_H_) && !defined (__MINGW32__) && (defined (HAVE_SELECT) || defined (HAVE_PSELECT))
+
+#if defined (_POSIXSELECT_H_)
/* use as a sentinel for fd_set, struct timeval, and sigset_t definitions */
+
+#if defined (__MINGW32__)
+# define RL_TIMEOUT_USE_SIGALRM
+#elif defined (HAVE_SELECT) || defined (HAVE_PSELECT)
+# define RL_TIMEOUT_USE_SELECT
+#elif defined (_MSC_VER)
+/* can't use select/pselect or SIGALRM, so no timeouts */
+#else
+# define RL_TIMEOUT_USE_SIGALRM
+#endif
+
+#endif
+#if defined (RL_TIMEOUT_USE_SELECT)
extern int _rl_timeout_select (int, fd_set *, fd_set *, fd_set *, const struct timeval *, const sigset_t *);
#endif
char *t;
int ni;
#endif
- const char *string;
+ char *string;
if (word == 0 || word->word == 0)
return 0;
appendop = assign_list = aflags = 0;
string = word->word;
offset = assignment (string, 0);
- name = savestring (string);
+ name = string;
value = (char *)NULL;
if (name[offset] == '=')
name[offset - 1] = '\0';
}
-#define ASSIGN_RETURN(r) do { FREE (value); free (name); return (r); } while (0)
+#define ASSIGN_RETURN(r) \
+do \
+{ \
+ FREE (value); \
+ if (appendop) name[offset - 1] = '+'; \
+ name[offset] = '='; \
+ return (r); \
+} while (0)
if (appendop)
aflags |= ASS_APPEND;
#if defined (ARRAY_VARS)
+ /* could use strchr, since variable names can't yet contain multibyte characters */
if (t = mbschr (name, LBRACK))
{
if (assign_list)
if (sigmodes[sig] & SIG_HARD_IGNORE)
return;
+ /* Even if the signal is not trapped, POSIX interp 751 requires that we
+ allow `trap - SIGINT' to reset the signal disposition for SIGINT to
+ SIG_DFL. */
+ if ((sigmodes[sig] & (SIG_TRAPPED|SIG_ASYNCSIG|SIG_NO_TRAP)) == SIG_ASYNCSIG)
+ {
+ original_signals[sig] = SIG_DFL; /* XXX */
+ set_signal_handler (sig, SIG_DFL);
+ change_signal (sig, (char *)DEFAULT_SIG);
+ return;
+ }
+
/* If we aren't trapping this signal, don't bother doing anything else. */
/* We special-case SIGCHLD and IMPOSSIBLE_TRAP_HANDLER (see above) as a
sentinel to determine whether or not disposition is reset to the default