From: Chet Ramey Date: Mon, 5 Aug 2019 14:24:27 +0000 (-0400) Subject: commit readline-20190805 snapshot X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31547b4ea4a1a904e1b08e2bc4b4ebd5042aedaa;p=thirdparty%2Freadline.git commit readline-20190805 snapshot --- diff --git a/CHANGELOG b/CHANGELOG index c080eca..cfe97b3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -[Readline-specific changelog. Descriptions of changes to the source are +\[Readline-specific changelog. Descriptions of changes to the source are found in the bash changelog.] 6/9 @@ -1360,3 +1360,7 @@ readline.pc.in to support the recommended `#include '. Report and fix from Andrea Bolognani + 5/13 + ---- +configure.ac + - hpux: add -DTGETENT_BROKEN to LOCAL_CFLAGS diff --git a/aclocal.m4 b/aclocal.m4 index a366597..c42dbf3 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -10,6 +10,7 @@ AC_DEFUN(BASH_C_LONG_LONG, ac_cv_c_long_long=yes else AC_TRY_RUN([ +#include int main() { @@ -33,6 +34,7 @@ AC_DEFUN(BASH_C_LONG_DOUBLE, ac_cv_c_long_double=yes else AC_TRY_RUN([ +#include int main() { @@ -136,6 +138,7 @@ typedef int (*_bashfunc)(const char *, ...); #else typedef int (*_bashfunc)(); #endif +#include main() { _bashfunc pf; @@ -193,6 +196,7 @@ AC_CACHE_VAL(bash_cv_under_sys_siglist, #ifdef HAVE_UNISTD_H #include #endif +#include #ifndef UNDER_SYS_SIGLIST_DECLARED extern char *_sys_siglist[]; #endif @@ -220,6 +224,7 @@ AC_CACHE_VAL(bash_cv_sys_siglist, #ifdef HAVE_UNISTD_H #include #endif +#include #if !HAVE_DECL_SYS_SIGLIST extern char *sys_siglist[]; #endif @@ -275,6 +280,7 @@ AC_CACHE_VAL(bash_cv_dup2_broken, [AC_TRY_RUN([ #include #include +#include main() { int fd1, fd2, fl; @@ -337,6 +343,7 @@ AC_CACHE_VAL(bash_cv_opendir_not_robust, # include # endif #endif /* HAVE_DIRENT_H */ +#include main() { DIR *dir; @@ -516,6 +523,7 @@ AC_TRY_RUN([ #include #include #include +#include main() { #ifdef HAVE_QUAD_T @@ -585,6 +593,7 @@ AC_CACHE_VAL(bash_cv_getenv_redef, #ifdef HAVE_UNISTD_H # include #endif +#include #ifndef __STDC__ # ifndef const # define const @@ -788,6 +797,7 @@ AC_CACHE_VAL(bash_cv_func_sigsetjmp, #include #include #include +#include main() { @@ -883,6 +893,7 @@ AC_CACHE_VAL(bash_cv_printf_a_format, [AC_TRY_RUN([ #include #include +#include int main() @@ -1243,6 +1254,7 @@ AC_CACHE_VAL(bash_cv_pgrp_pipe, #ifdef HAVE_UNISTD_H # include #endif +#include main() { # ifdef GETPGRP_VOID @@ -1307,6 +1319,7 @@ AC_CACHE_VAL(bash_cv_must_reinstall_sighandlers, #ifdef HAVE_UNISTD_H #include #endif +#include typedef RETSIGTYPE sigfunc(); @@ -1420,6 +1433,7 @@ AC_CACHE_VAL(bash_cv_sys_named_pipes, #ifdef HAVE_UNISTD_H #include #endif +#include /* Add more tests in here as appropriate. */ main() @@ -1653,6 +1667,7 @@ AC_CACHE_VAL(bash_cv_unusable_rtsigs, [AC_TRY_RUN([ #include #include +#include #ifndef NSIG # define NSIG 64 @@ -1836,6 +1851,7 @@ AC_CACHE_VAL(ac_cv_rl_version, [AC_TRY_RUN([ #include #include +#include extern int rl_gnu_readline_p; @@ -2040,6 +2056,7 @@ AC_DEFUN([BASH_FUNC_SNPRINTF], AC_CACHE_CHECK([for standard-conformant snprintf], [bash_cv_func_snprintf], [AC_TRY_RUN([ #include +#include main() { diff --git a/bind.c b/bind.c index 2a1e012..b6970df 100644 --- a/bind.c +++ b/bind.c @@ -361,7 +361,7 @@ int rl_generic_bind (int type, const char *keyseq, char *data, Keymap map) { char *keys; - int keys_len, prevkey; + int keys_len, prevkey, ic; register int i; KEYMAP_ENTRY k; Keymap prevmap; @@ -394,7 +394,6 @@ rl_generic_bind (int type, const char *keyseq, char *data, Keymap map) for (i = 0; i < keys_len; i++) { unsigned char uc = keys[i]; - int ic; if (i > 0) prevkey = ic; @@ -545,6 +544,7 @@ rl_translate_keyseq (const char *seq, char *array, int *len) { i++; /* seq[i] == '-' */ /* XXX - obey convert-meta setting, convert to key seq */ + /* XXX - doesn't yet handle \M-\C-n if convert-meta is on */ if (_rl_convert_meta_chars_to_ascii) { array[l++] = ESC; /* ESC is meta-prefix */ diff --git a/configure b/configure index c9b7ade..b4c8460 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.ac for Readline 8.0, version 2.85. +# From configure.ac for Readline 8.0, version 2.86. # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for readline 8.0. # @@ -6807,6 +6807,7 @@ esac case "$host_os" in isc*) LOCAL_CFLAGS=-Disc386 ;; +hpux*) LOCAL_CFLAGS=-DTGETENT_BROKEN ;; esac # shared library configuration section diff --git a/configure.ac b/configure.ac index b73e37b..5f56b44 100644 --- a/configure.ac +++ b/configure.ac @@ -5,7 +5,7 @@ dnl report bugs to chet@po.cwru.edu dnl dnl Process this file with autoconf to produce a configure script. -# Copyright (C) 1987-2018 Free Software Foundation, Inc. +# Copyright (C) 1987-2019 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -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.0, version 2.85]) +AC_REVISION([for Readline 8.0, version 2.86]) AC_INIT(readline, 8.0, bug-readline@gnu.org) @@ -215,6 +215,7 @@ esac case "$host_os" in isc*) LOCAL_CFLAGS=-Disc386 ;; +hpux*) LOCAL_CFLAGS=-DTGETENT_BROKEN ;; esac # shared library configuration section diff --git a/display.c b/display.c index 4c6cc00..5129654 100644 --- a/display.c +++ b/display.c @@ -76,6 +76,8 @@ static void redraw_prompt PARAMS((char *)); static char *expand_prompt PARAMS((char *, int, int *, int *, int *, int *)); +#define DEFAULT_LINE_BUFFER_SIZE 1024 + /* State of visible and invisible lines. */ struct line_state { @@ -219,7 +221,7 @@ static int msg_bufsiz = 0; static int forced_display; /* Default and initial buffer size. Can grow. */ -static int line_size = 1024; +static int line_size = DEFAULT_LINE_BUFFER_SIZE; /* Variables to keep track of the expanded prompt string, which may include invisible characters. */ @@ -574,11 +576,6 @@ rl_expand_prompt (char *prompt) { /* The prompt spans multiple lines. */ t = ++p; - local_prompt = expand_prompt (p, PMT_MULTILINE, - &prompt_visible_length, - &prompt_last_invisible, - &prompt_invis_chars_first_line, - &prompt_physical_chars); c = *t; *t = '\0'; /* The portion of the prompt string up to and including the final newline is now null-terminated. */ @@ -588,6 +585,12 @@ rl_expand_prompt (char *prompt) (int *)NULL, (int *)NULL); *t = c; + + local_prompt = expand_prompt (p, PMT_MULTILINE, + &prompt_visible_length, + &prompt_last_invisible, + &prompt_invis_chars_first_line, + &prompt_physical_chars); local_prompt_len = local_prompt ? strlen (local_prompt) : 0; return (prompt_prefix_length); } @@ -603,6 +606,9 @@ init_line_structures (int minsize) { register int n; + if (minsize <= _rl_screenwidth) /* XXX - for gdb */ + minsize = _rl_screenwidth + 1; + if (invisible_line == 0) /* initialize it */ { if (line_size < minsize) @@ -680,6 +686,9 @@ rl_redisplay (void) init_line_structures (0); rl_on_new_line (); } + else if (line_size <= _rl_screenwidth) + init_line_structures (_rl_screenwidth + 1); + /* Draw the line into the buffer. */ cpos_buffer_position = -1; diff --git a/doc/rltech.texi b/doc/rltech.texi index 1523139..ff8bd04 100644 --- a/doc/rltech.texi +++ b/doc/rltech.texi @@ -1753,7 +1753,7 @@ Set Readline's idea of the terminal size to @var{rows} rows and or equal to 0, Readline's idea of that terminal dimension is unchanged. This is intended to tell Readline the physical dimensions of the terminal, and is used internally to calculate the maximum number of characters that -may appear on the screen. +may appear on a single line and on the screen. @end deftypefun If an application does not want to install a @code{SIGWINCH} handler, but diff --git a/doc/rluser.texi b/doc/rluser.texi index 41f1da4..080090b 100644 --- a/doc/rluser.texi +++ b/doc/rluser.texi @@ -1178,11 +1178,11 @@ Move back to the start of the current or previous word. Words are composed of letters and digits. @ifset BashFeatures -@item shell-forward-word () +@item shell-forward-word (M-C-f) Move forward to the end of the next word. Words are delimited by non-quoted shell metacharacters. -@item shell-backward-word () +@item shell-backward-word (M-C-b) Move back to the start of the current or previous word. Words are delimited by non-quoted shell metacharacters. @end ifset @@ -1432,7 +1432,7 @@ Kill the word behind point. Word boundaries are the same as @code{backward-word}. @ifset BashFeatures -@item shell-kill-word () +@item shell-kill-word (M-C-d) Kill from point to the end of the current word, or if between words, to the end of the next word. Word boundaries are the same as @code{shell-forward-word}. @@ -1442,6 +1442,14 @@ Kill the word behind point. Word boundaries are the same as @code{shell-backward-word}. @end ifset +@item shell-transpose-words (M-C-t) +Drag the word before point past the word after point, +moving point past that word as well. +If the insertion point is at the end of the line, this transposes +the last two words on the line. +Word boundaries are the same as @code{shell-forward-word} and +@code{shell-backward-word}. + @item unix-word-rubout (C-w) Kill the word behind point, using white space as a word boundary. The killed text is saved on the kill-ring. diff --git a/histfile.c b/histfile.c index aa34fe2..dea8972 100644 --- a/histfile.c +++ b/histfile.c @@ -375,9 +375,11 @@ read_history_range (const char *filename, int from, int to) } has_timestamps = HIST_TIMESTAMP_START (buffer); - history_multiline_entries += has_timestamps && history_write_timestamps; + history_multiline_entries += has_timestamps && history_write_timestamps; /* Skip lines until we are at FROM. */ + if (has_timestamps) + last_ts = buffer; for (line_start = line_end = buffer; line_end < bufend && current_line < from; line_end++) if (*line_end == '\n') { @@ -386,7 +388,18 @@ read_history_range (const char *filename, int from, int to) line. We should check more extensively here... */ if (HIST_TIMESTAMP_START(p) == 0) current_line++; + else + last_ts = p; line_start = p; + /* If we are at the last line (current_line == from) but we have + timestamps (has_timestamps), then line_start points to the + text of the last command, and we need to skip to its end. */ + if (current_line >= from && has_timestamps) + { + for (line_end = p; line_end < bufend && *line_end != '\n'; line_end++) + ; + line_start = (*line_end == '\n') ? line_end + 1 : line_end; + } } /* If there are lines left to gobble, then gobble them now. */ diff --git a/input.c b/input.c index a557330..0090e97 100644 --- a/input.c +++ b/input.c @@ -635,9 +635,7 @@ _rl_read_mbchar (char *mbchar, int size) mb_len = 0; while (mb_len < size) { - RL_SETSTATE(RL_STATE_MOREINPUT); - c = rl_read_key (); - RL_UNSETSTATE(RL_STATE_MOREINPUT); + c = (mb_len == 0) ? _rl_bracketed_read_key () : rl_read_key (); if (c < 0) break; diff --git a/isearch.c b/isearch.c index d6c5904..951fce5 100644 --- a/isearch.c +++ b/isearch.c @@ -297,6 +297,7 @@ _rl_isearch_fini (_rl_search_cxt *cxt) rl_clear_message (); } +/* XXX - we could use _rl_bracketed_read_mbstring () here. */ int _rl_search_getchar (_rl_search_cxt *cxt) { diff --git a/kill.c b/kill.c index cf8ca93..6a2e0c6 100644 --- a/kill.c +++ b/kill.c @@ -1,6 +1,6 @@ /* kill.c -- kill ring management. */ -/* Copyright (C) 1994-2017 Free Software Foundation, Inc. +/* Copyright (C) 1994-2019 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. @@ -668,8 +668,7 @@ rl_yank_last_arg (int count, int key) /* Having read the special escape sequence denoting the beginning of a `bracketed paste' sequence, read the rest of the pasted input until the - closing sequence and insert the pasted text as a single unit without - interpretation. */ + closing sequence and return the pasted text. */ char * _rl_bracketed_text (size_t *lenp) { @@ -715,6 +714,10 @@ _rl_bracketed_text (size_t *lenp) return (buf); } +/* Having read the special escape sequence denoting the beginning of a + `bracketed paste' sequence, read the rest of the pasted input until the + closing sequence and insert the pasted text as a single unit without + interpretation. */ int rl_bracketed_paste_begin (int count, int key) { @@ -729,6 +732,96 @@ rl_bracketed_paste_begin (int count, int key) return (retval); } +int +_rl_read_bracketed_paste_prefix (int c) +{ + char pbuf[BRACK_PASTE_SLEN+1], *pbpref; + int key, ind, j; + + pbpref = BRACK_PASTE_PREF; /* XXX - debugging */ + if (c != pbpref[0]) + return (0); + pbuf[ind = 0] = c; + while (ind < BRACK_PASTE_SLEN-1 && + (RL_ISSTATE (RL_STATE_INPUTPENDING|RL_STATE_MACROINPUT) == 0) && + _rl_pushed_input_available () == 0 && + _rl_input_queued (0)) + { + key = rl_read_key (); /* XXX - for now */ + if (key < 0) + break; + pbuf[++ind] = key; + if (pbuf[ind] != pbpref[ind]) + break; + } + + if (ind < BRACK_PASTE_SLEN-1) /* read incomplete sequence */ + { + while (ind >= 0) + _rl_unget_char (pbuf[ind--]); + return (key < 0 ? key : 0); + } + return (key < 0 ? key : 1); +} + +/* Get a character from wherever we read input, handling input in bracketed + paste mode. If we don't have or use bracketed paste mode, this can be + used in place of rl_read_key(). */ +int +_rl_bracketed_read_key () +{ + int c, r; + char *pbuf; + size_t pblen; + + RL_SETSTATE(RL_STATE_MOREINPUT); + c = rl_read_key (); + RL_UNSETSTATE(RL_STATE_MOREINPUT); + + if (c < 0) + return -1; + + /* read pasted data with bracketed-paste mode enabled. */ + if (_rl_enable_bracketed_paste && c == ESC && (r = _rl_read_bracketed_paste_prefix (c)) == 1) + { + pbuf = _rl_bracketed_text (&pblen); + if (pblen == 0) + { + xfree (pbuf); + return 0; /* XXX */ + } + c = (unsigned char)pbuf[0]; + if (pblen > 1) + { + while (--pblen > 0) + _rl_unget_char ((unsigned char)pbuf[pblen]); + } + xfree (pbuf); + } + + return c; +} + +/* Get a character from wherever we read input, handling input in bracketed + paste mode. If we don't have or use bracketed paste mode, this can be + used in place of rl_read_key(). */ +int +_rl_bracketed_read_mbstring (char *mb, int mlen) +{ + int c, r; + + c = _rl_bracketed_read_key (); + if (c < 0) + return -1; + +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + c = _rl_read_mbstring (c, mb, mlen); +#endif + + return c; +} + /* A special paste command for Windows users. */ #if defined (_WIN32) #include diff --git a/misc.c b/misc.c index 5e79793..e6b42eb 100644 --- a/misc.c +++ b/misc.c @@ -138,9 +138,7 @@ _rl_arg_dispatch (_rl_arg_cxt cxt, int c) } else { - RL_SETSTATE(RL_STATE_MOREINPUT); - key = rl_read_key (); - RL_UNSETSTATE(RL_STATE_MOREINPUT); + key = _rl_bracketed_read_key (); rl_restore_prompt (); rl_clear_message (); RL_UNSETSTATE(RL_STATE_NUMERICARG); @@ -589,6 +587,7 @@ int rl_get_previous_history (int count, int key) { HIST_ENTRY *old_temp, *temp; + int had_saved_line; if (count < 0) return (rl_get_next_history (-count, key)); @@ -601,6 +600,7 @@ rl_get_previous_history (int count, int key) _rl_history_saved_point = (rl_point == rl_end) ? -1 : rl_point; /* If we don't have a line saved, then save this one. */ + had_saved_line = _rl_saved_line_for_history != 0; rl_maybe_save_line (); /* If the current line has changed, save the changes. */ @@ -624,7 +624,8 @@ rl_get_previous_history (int count, int key) if (temp == 0) { - _rl_free_saved_history_line (); + if (had_saved_line == 0) + _rl_free_saved_history_line (); rl_ding (); } else diff --git a/rlprivate.h b/rlprivate.h index 38e1dc7..76631d7 100644 --- a/rlprivate.h +++ b/rlprivate.h @@ -309,7 +309,10 @@ extern int _rl_search_getchar PARAMS((_rl_search_cxt *)); #define BRACK_PASTE_INIT "\033[?2004h" #define BRACK_PASTE_FINI "\033[?2004l\r" +extern int _rl_read_bracketed_paste_prefix PARAMS((int)); extern char *_rl_bracketed_text PARAMS((size_t *)); +extern int _rl_bracketed_read_key PARAMS((void)); +extern int _rl_bracketed_read_mbstring PARAMS((char *, int)); /* macro.c */ extern void _rl_with_macro_input PARAMS((char *)); diff --git a/support/shobj-conf b/support/shobj-conf index 7920f1b..95fa1ae 100644 --- a/support/shobj-conf +++ b/support/shobj-conf @@ -402,18 +402,15 @@ hpux11*) SHLIB_STATUS=unsupported # If you are using the HP ANSI C compiler, you can uncomment and use - # this code (I have not tested it) -# SHOBJ_STATUS=supported -# SHLIB_STATUS=supported -# + # this code from michael.osipov@siemens.com (I have not tested it) # SHOBJ_CFLAGS='+z' -# SHOBJ_LD='ld' -# SHOBJ_LDFLAGS='-b +s +h $@' +# SHOBJ_LD='$(CC)' +# SHOBJ_LDFLAGS='-b -Wl,+s -Wl,+h,$@' # -# SHLIB_XLDFLAGS='+b $(libdir)' -# SHLIB_LIBSUFF='sl' +# SHLIB_XLDFLAGS='-Wl,+b,$(libdir)' +# SHLIB_LIBSUFF='so' # SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' - +# SHLIB_LIBS='$(TERMCAP_LIB)' ;; sysv4*-*gcc*) diff --git a/terminal.c b/terminal.c index e557389..fa00438 100644 --- a/terminal.c +++ b/terminal.c @@ -483,7 +483,11 @@ _rl_init_terminal_io (const char *terminal_name) tgetent_ret = tgetent (term_buffer, term); } +#ifdef TGETENT_BROKEN + if (tgetent_ret < 0) +#else if (tgetent_ret <= 0) +#endif { FREE (term_string_buffer); FREE (term_buffer); diff --git a/text.c b/text.c index 43aa4d9..ff6ab68 100644 --- a/text.c +++ b/text.c @@ -1,6 +1,6 @@ /* text.c -- text handling commands for readline. */ -/* Copyright (C) 1987-2017 Free Software Foundation, Inc. +/* Copyright (C) 1987-2019 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. @@ -1722,10 +1722,7 @@ _rl_char_search (int count, int fdir, int bdir) { int c; - RL_SETSTATE(RL_STATE_MOREINPUT); - c = rl_read_key (); - RL_UNSETSTATE(RL_STATE_MOREINPUT); - + c = _rl_bracketed_read_key (); if (c < 0) return 1; diff --git a/vi_mode.c b/vi_mode.c index 836371c..dd4c3e8 100644 --- a/vi_mode.c +++ b/vi_mode.c @@ -1,7 +1,7 @@ /* vi_mode.c -- A vi emulation mode for Bash. Derived from code written by Jeff Sparkes (jsparkes@bnr.ca). */ -/* Copyright (C) 1987-2018 Free Software Foundation, Inc. +/* Copyright (C) 1987-2019 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. @@ -1316,13 +1316,7 @@ rl_domove_read_callback (_rl_vimotion_cxt *m) static int rl_vi_domove_getchar (_rl_vimotion_cxt *m) { - int c; - - RL_SETSTATE(RL_STATE_MOREINPUT); - c = rl_read_key (); - RL_UNSETSTATE(RL_STATE_MOREINPUT); - - return c; + return (_rl_bracketed_read_key ()); } #if defined (READLINE_CALLBACKS) @@ -2000,21 +1994,7 @@ _rl_vi_change_char (int count, int c, char *mb) static int _rl_vi_callback_getchar (char *mb, int mlen) { - int c; - - RL_SETSTATE(RL_STATE_MOREINPUT); - c = rl_read_key (); - RL_UNSETSTATE(RL_STATE_MOREINPUT); - - if (c < 0) - return -1; - -#if defined (HANDLE_MULTIBYTE) - if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) - c = _rl_read_mbstring (c, mb, mlen); -#endif - - return c; + return (_rl_bracketed_read_mbstring (mb, mlen)); } #if defined (READLINE_CALLBACKS) @@ -2137,6 +2117,34 @@ rl_vi_overstrike_delete (int count, int key) return (0); } +/* Read bracketed paste mode pasted text and insert it in overwrite mode */ +static int +rl_vi_overstrike_bracketed_paste (int count, int key) +{ + int r; + char *pbuf; + size_t pblen; + + pbuf = _rl_bracketed_text (&pblen); + if (pblen == 0) + { + xfree (pbuf); + return 0; + } + r = pblen; + while (--r >= 0) + _rl_unget_char ((unsigned char)pbuf[r]); + xfree (pbuf); + + while (_rl_pushed_input_available ()) + { + key = rl_read_key (); + r = rl_vi_overstrike (1, key); + } + + return r; +} + int rl_vi_replace (int count, int key) { @@ -2179,6 +2187,9 @@ rl_vi_replace (int count, int key) _rl_vi_last_key_before_insert = key; _rl_keymap = vi_replace_map; + if (_rl_enable_bracketed_paste) + rl_bind_keyseq_if_unbound (BRACK_PASTE_PREF, rl_vi_overstrike_bracketed_paste); + return (0); }