From: Chet Ramey Date: Mon, 3 Aug 2015 20:49:12 +0000 (-0400) Subject: commit readline-20150731 snapshot X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4973413dca2010ef8d286c33f9ad05cb347304a3;p=thirdparty%2Freadline.git commit readline-20150731 snapshot --- diff --git a/callback.c b/callback.c index 0fc3f90..ec48b76 100644 --- a/callback.c +++ b/callback.c @@ -161,6 +161,36 @@ rl_callback_read_char () CALLBACK_READ_RETURN (); } #if defined (VI_MODE) + /* States that can occur while in state VIMOTION have to be checked + before RL_STATE_VIMOTION */ + else if (RL_ISSTATE (RL_STATE_CHARSEARCH)) + { + int k; + + k = _rl_callback_data->i2; + + eof = (*_rl_callback_func) (_rl_callback_data); + /* If the function `deregisters' itself, make sure the data is + cleaned up. */ + if (_rl_callback_func == 0) /* XXX - just sanity check */ + { + if (_rl_callback_data) + { + _rl_callback_data_dispose (_rl_callback_data); + _rl_callback_data = 0; + } + } + + /* Messy case where vi motion command can be char search */ + if (RL_ISSTATE (RL_STATE_VIMOTION)) + { + _rl_vi_domove_motion_cleanup (k, _rl_vimvcxt); + _rl_internal_char_cleanup (); + CALLBACK_READ_RETURN (); + } + + _rl_internal_char_cleanup (); + } else if (RL_ISSTATE (RL_STATE_VIMOTION)) { eof = _rl_vi_domove_callback (_rl_vimvcxt); @@ -311,6 +341,8 @@ rl_callback_sigcleanup () } else if (RL_ISSTATE (RL_STATE_MULTIKEY)) RL_UNSETSTATE (RL_STATE_MULTIKEY); + if (RL_ISSTATE (RL_STATE_CHARSEARCH)) + RL_UNSETSTATE (RL_STATE_CHARSEARCH); _rl_callback_func = 0; } diff --git a/display.c b/display.c index c6b14fb..4353d6e 100644 --- a/display.c +++ b/display.c @@ -83,8 +83,8 @@ struct line_state int *lbreaks; int lbsize; #if defined (HANDLE_MULTIBYTE) - int *wrapped_line; int wbsize; + int *wrapped_line; #endif }; diff --git a/history.h b/history.h index 779a573..b79e51f 100644 --- a/history.h +++ b/history.h @@ -91,6 +91,13 @@ extern void add_history_time PARAMS((const char *)); elements are numbered from 0. */ extern HIST_ENTRY *remove_history PARAMS((int)); +/* Allocate a history entry consisting of STRING and TIMESTAMP and return + a pointer to it. */ +extern HIST_ENTRY *alloc_history_entry PARAMS((char *, char *)); + +/* Copy the history entry H, but not the (opaque) data pointer */ +extern HIST_ENTRY *copy_history_entry PARAMS((HIST_ENTRY *)); + /* Free the history entry H and return any application-specific data associated with it. */ extern histdata_t free_history_entry PARAMS((HIST_ENTRY *)); @@ -241,6 +248,7 @@ extern char **history_tokenize PARAMS((const char *)); extern int history_base; extern int history_length; extern int history_max_entries; +extern int history_offset; extern int history_lines_read_from_file; extern int history_lines_written_to_file; diff --git a/readline.c b/readline.c index 0a54dc3..ce72501 100644 --- a/readline.c +++ b/readline.c @@ -916,8 +916,10 @@ _rl_dispatch_subseq (key, map, got_subseq) default) or a timeout determined by the value of `keyseq-timeout' */ /* _rl_keyseq_timeout specified in milliseconds; _rl_input_queued takes microseconds, so multiply by 1000 */ - if (rl_editing_mode == vi_mode && key == ESC && map == vi_insertion_keymap - && _rl_input_queued ((_rl_keyseq_timeout > 0) ? _rl_keyseq_timeout*1000 : 0) == 0) + if (rl_editing_mode == vi_mode && key == ESC && map == vi_insertion_keymap && + (RL_ISSTATE (RL_STATE_INPUTPENDING|RL_STATE_MACROINPUT) == 0) && + _rl_pushed_input_available () == 0 && + _rl_input_queued ((_rl_keyseq_timeout > 0) ? _rl_keyseq_timeout*1000 : 0) == 0) return (_rl_dispatch (ANYOTHERKEY, FUNCTION_TO_KEYMAP (map, key))); #endif @@ -954,7 +956,7 @@ _rl_dispatch_subseq (key, map, got_subseq) /* Tentative inter-character timeout for potential multi-key sequences? If no input within timeout, abort sequence and act as if we got non-matching input. */ - /* _rl_keyseq_timeout specified in milliseconds; _rl_input_queued + /* _rl_keyseq_timeout specified in milliseconds; _rl_input_queued[B takes microseconds, so multiply by 1000 */ if (_rl_keyseq_timeout > 0 && (RL_ISSTATE (RL_STATE_INPUTPENDING|RL_STATE_MACROINPUT) == 0) && diff --git a/readline.h b/readline.h index e1773fa..8d71f9a 100644 --- a/readline.h +++ b/readline.h @@ -870,7 +870,8 @@ extern int rl_inhibit_completion; #define RL_STATE_VIMOTION 0x0100000 /* reading vi motion arg */ #define RL_STATE_MULTIKEY 0x0200000 /* reading multiple-key command */ #define RL_STATE_VICMDONCE 0x0400000 /* entered vi command mode at least once */ -#define RL_STATE_REDISPLAYING 0x0800000 /* updating terminal display */ +#define RL_STATE_CHARSEARCH 0x0800000 /* vi mode char search */ +#define RL_STATE_REDISPLAYING 0x1000000 /* updating terminal display */ #define RL_STATE_DONE 0x1000000 /* done; accepted line */ @@ -883,8 +884,8 @@ struct readline_state { int point; int end; int mark; - char *buffer; int buflen; + char *buffer; UNDO_LIST *ul; char *prompt; @@ -899,9 +900,10 @@ struct readline_state { int edmode; char *kseq; int kseqlen; + + int pendingin; FILE *inf; FILE *outf; - int pendingin; char *macro; /* signal state */ diff --git a/rlprivate.h b/rlprivate.h index 9b859f9..8064f9f 100644 --- a/rlprivate.h +++ b/rlprivate.h @@ -125,10 +125,11 @@ typedef struct __rl_keyseq_context int flags; int subseq_arg; int subseq_retval; /* XXX */ - Keymap dmap; + int okey; + Keymap dmap; Keymap oldmap; - int okey; + struct __rl_keyseq_context *ocxt; int childval; } _rl_keyseq_cxt; @@ -427,6 +428,7 @@ extern int _rl_vi_textmod_command PARAMS((int)); extern int _rl_vi_motion_command PARAMS((int)); extern void _rl_vi_done_inserting PARAMS((void)); extern int _rl_vi_domove_callback PARAMS((_rl_vimotion_cxt *)); +extern int _rl_vi_domove_motion_cleanup PARAMS((int, _rl_vimotion_cxt *)); /************************************************************************* * Undocumented private variables * diff --git a/vi_mode.c b/vi_mode.c index cae80ca..dcde2fb 100644 --- a/vi_mode.c +++ b/vi_mode.c @@ -1096,28 +1096,55 @@ static int rl_domove_motion_callback (m) _rl_vimotion_cxt *m; { - int c, save, r; - int old_end; + int c; _rl_vi_last_motion = c = m->motion; /* Append a blank character temporarily so that the motion routines - work right at the end of the line. */ - old_end = rl_end; + work right at the end of the line. Original value of rl_end is saved + as m->end. */ rl_line_buffer[rl_end++] = ' '; rl_line_buffer[rl_end] = '\0'; _rl_dispatch (c, _rl_keymap); - /* Remove the blank that we added. */ - rl_end = old_end; +#if defined (READLINE_CALLBACKS) + if (RL_ISSTATE (RL_STATE_CALLBACK)) + { + /* Messy case where char search can be vi motion command; see rest of + details in callback.c. vi_char_search and callback_char_search just + set and unset the CHARSEARCH state. This is where any vi motion + command that needs to set its own state should be handled, with any + corresponding code to manage that state in callback.c */ + if (RL_ISSTATE (RL_STATE_CHARSEARCH)) + return 0; + else + return (_rl_vi_domove_motion_cleanup (c, m)); + } +#endif + + return (_rl_vi_domove_motion_cleanup (c, m)); +} + +int +_rl_vi_domove_motion_cleanup (c, m) + int c; + _rl_vimotion_cxt *m; +{ + int r; + + /* Remove the blank that we added in rl_domove_motion_callback. */ + rl_end = m->end; rl_line_buffer[rl_end] = '\0'; if (rl_point > rl_end) rl_point = rl_end; /* No change in position means the command failed. */ if (rl_mark == rl_point) - return (-1); + { + RL_UNSETSTATE (RL_STATE_VIMOTION); + return (-1); + } /* rl_vi_f[wW]ord () leaves the cursor on the first character of the next word. If we are not at the end of the line, and we are on a @@ -1625,7 +1652,10 @@ _rl_vi_callback_char_search (data) #endif if (c <= 0) - return -1; + { + RL_UNSETSTATE (RL_STATE_CHARSEARCH); + return -1; + } #if !defined (HANDLE_MULTIBYTE) _rl_vi_last_search_char = c; @@ -1633,6 +1663,7 @@ _rl_vi_callback_char_search (data) _rl_callback_func = 0; _rl_want_redisplay = 1; + RL_UNSETSTATE (RL_STATE_CHARSEARCH); #if defined (HANDLE_MULTIBYTE) return (_rl_char_search_internal (data->count, _rl_cs_dir, _rl_vi_last_search_mbchar, _rl_vi_last_search_mblen)); @@ -1697,7 +1728,9 @@ rl_vi_char_search (count, key) { _rl_callback_data = _rl_callback_data_alloc (count); _rl_callback_data->i1 = _rl_cs_dir; + _rl_callback_data->i2 = key; _rl_callback_func = _rl_vi_callback_char_search; + RL_SETSTATE (RL_STATE_CHARSEARCH); return (0); } #endif