From 10729c7b2a211181e0eb87697993fd10f7a614da Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Mon, 13 Mar 2017 09:51:39 -0400 Subject: [PATCH] commit bash-20170303 snapshot --- CWRU/CWRU.chlog | 53 +++++ builtins/shopt.def | 6 + doc/bash.1 | 12 +- doc/bashref.texi | 2 + doc/version.texi | 6 +- execute_cmd.c | 5 +- lib/glob/sm_loop.c | 6 +- lib/glob/smatch.c | 40 +++- lib/readline/bind.c | 10 +- lib/readline/complete.c | 176 +++++---------- lib/readline/display.c | 431 +++++++++++++++++++++++------------- lib/readline/emacs_keymap.c | 2 +- lib/readline/histexpand.c | 66 ++---- lib/readline/histfile.c | 41 +--- lib/readline/history.c | 76 +++---- lib/readline/histsearch.c | 22 +- lib/readline/kill.c | 94 +++----- lib/readline/readline.c | 82 +++---- lib/readline/vi_keymap.c | 2 +- lib/readline/vi_mode.c | 265 ++++++++-------------- lib/readline/xmalloc.c | 12 +- lib/tilde/shell.c | 7 +- lib/tilde/tilde.c | 43 ++-- shell.c | 2 +- subst.c | 5 +- tests/RUN-ONE-TEST | 2 +- 26 files changed, 717 insertions(+), 751 deletions(-) diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 71bc07b7..d03f44fa 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -13309,3 +13309,56 @@ subst.c *contains_dollar_at gets set to 1 and the word is inappropriately split + 3/1 + --- +subst.c + - expand_word_list_internal: if a variable assignment fails (e.g., due + to a readonly variable) in a non-interactive posix mode shell, don't + abort the shell if the assignment is being performed by the command + builtin, even if it's something like `command eval v=1'. Fixes + RedHat bug https://bugzilla.redhat.com/show_bug.cgi?id=1389838 + (reported by Denys Vlasenko) + + 3/3 + --- +builtins/shopt.def + - set_compatibility_level: make sure that changing the compatibility + level sets or modifies BASH_COMPAT. Fixes bug reported by + Stephane Chazelas + +lib/glob/smatch.c + - is_cclass: broke into two functions: is_valid_cclass and cclass_test, + for future expansion. No functionality change + +lib/glob/sm_loop.c + - BRACKMATCH: when testing a character against a character class name, + use the unfolded (original) character, since we're not performing a + comparison. This is what glibc does. Fixes bug reported by + Lukáš BaÅinka + + 3/4 + --- +doc/{bash.1,bashref.texi} + - note that the arguments to -eq and the rest of the arithmetic + operators are evaluated as expressions when using [[. Report from + Rob la Lau + + + 3/7 + --- +lib/readline/display.c + - update_line: completely rewrote the code that handles line wrapping + in the presence of multibyte/double-width characters; punts toa + dumb update in cases where the number of screen positions doesn't + match + - update_line: in one case, where we are deleting characters from the + line, if we are writing a non-space into the last screen character + position, note that we are no longer using a space as a placeholder + for a line wrap where there is a multi-width character that won't + fit on the screen line (wrapped_line[current_line+1] = 0) + + 3/10 + ---- +lib/readline/readline.c + - bind_arrow_keys_internal: add default key bindings for control- + arrow keys, suggested by Per Bothner diff --git a/builtins/shopt.def b/builtins/shopt.def index 716f7c84..1ad2b74d 100644 --- a/builtins/shopt.def +++ b/builtins/shopt.def @@ -596,6 +596,7 @@ set_compatibility_level (option_name, mode) int mode; { int ind; + char *rhs; /* If we're setting something, redo some of the work we did above in toggle_shopt(). Unset everything and reset the appropriate option @@ -624,6 +625,11 @@ set_compatibility_level (option_name, mode) else shell_compatibility_level = DEFAULT_COMPAT_LEVEL; + /* Make sure the current compatibility level is reflected in BASH_COMPAT */ + rhs = itos (shell_compatibility_level); + bind_variable ("BASH_COMPAT", rhs, 0); + free (rhs); + return 0; } diff --git a/doc/bash.1 b/doc/bash.1 index 644ec502..50a2e2b5 100644 --- a/doc/bash.1 +++ b/doc/bash.1 @@ -5,12 +5,12 @@ .\" Case Western Reserve University .\" chet.ramey@case.edu .\" -.\" Last Change: Thu Feb 9 15:46:36 EST 2017 +.\" Last Change: Sat Mar 4 13:06:51 EST 2017 .\" .\" bash_builtins, strip all but Built-Ins section .if \n(zZ=1 .ig zZ .if \n(zY=1 .ig zY -.TH BASH 1 "2017 February 9" "GNU Bash 4.4" +.TH BASH 1 "2017 March 4" "GNU Bash 4.4" .\" .\" There's some problem with having a `@' .\" in a tagged paragraph with the BSD man macros. @@ -4566,6 +4566,14 @@ greater than, or greater than or equal to \fIarg2\fP, respectively. and .I arg2 may be positive or negative integers. +When used with the \fB[[\fP command, +.I Arg1 +and +.I Arg2 +are evaluated as arithmetic expressions (see +.SM +.B "ARITHMETIC EVALUATION" +above). .PD .SH "SIMPLE COMMAND EXPANSION" When a simple command is executed, the shell performs the following diff --git a/doc/bashref.texi b/doc/bashref.texi index fb15067a..36256b0d 100644 --- a/doc/bashref.texi +++ b/doc/bashref.texi @@ -6803,6 +6803,8 @@ is equal to, not equal to, less than, less than or equal to, greater than, or greater than or equal to @var{arg2}, respectively. @var{Arg1} and @var{arg2} may be positive or negative integers. +When used with the @code{[[} command, @var{Arg1} and @var{Arg2} +are evaluated as arithmetic expressions (@pxref{Shell Arithmetic}). @end table @node Shell Arithmetic diff --git a/doc/version.texi b/doc/version.texi index 96373ff3..a21380fe 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -2,10 +2,10 @@ Copyright (C) 1988-2017 Free Software Foundation, Inc. @end ignore -@set LASTCHANGE Thu Feb 9 15:46:16 EST 2017 +@set LASTCHANGE Sat Mar 4 13:06:24 EST 2017 @set EDITION 4.4 @set VERSION 4.4 -@set UPDATED 9 February 2017 -@set UPDATED-MONTH February 2017 +@set UPDATED 4 March 2017 +@set UPDATED-MONTH March 2017 diff --git a/execute_cmd.c b/execute_cmd.c index 9c4572de..360987b8 100644 --- a/execute_cmd.c +++ b/execute_cmd.c @@ -4387,10 +4387,7 @@ run_builtin: } result = builtin_status (result); if (builtin_is_special) -{ -itrace("special builtin failed with flags = %d", simple_command->flags); - special_builtin_failed = 1; -} + special_builtin_failed = 1; /* XXX - take command builtin into account? */ } /* In POSIX mode, if there are assignment statements preceding a special builtin, they persist after the builtin diff --git a/lib/glob/sm_loop.c b/lib/glob/sm_loop.c index aadb1190..a8eb35ee 100644 --- a/lib/glob/sm_loop.c +++ b/lib/glob/sm_loop.c @@ -361,8 +361,10 @@ BRACKMATCH (p, test, flags) int brcnt, forcecoll; INT pc; CHAR *savep; + U_CHAR orig_test; - test = FOLD (test); + orig_test = test; + test = FOLD (orig_test); savep = p; @@ -427,7 +429,7 @@ BRACKMATCH (p, test, flags) { bcopy (p + 1, ccname, (close - p - 1) * sizeof (CHAR)); *(ccname + (close - p - 1)) = L('\0'); - pc = IS_CCLASS (test, (XCHAR *)ccname); + pc = IS_CCLASS (orig_test, (XCHAR *)ccname); } if (pc == -1) pc = 0; diff --git a/lib/glob/smatch.c b/lib/glob/smatch.c index f6bb09b7..78287d31 100644 --- a/lib/glob/smatch.c +++ b/lib/glob/smatch.c @@ -144,25 +144,33 @@ static char const *const cclass_name[] = #define N_CHAR_CLASS (sizeof(cclass_name) / sizeof (cclass_name[0])) -static int -is_cclass (c, name) - int c; +static enum char_class +is_valid_cclass (name) const char *name; { - enum char_class char_class = CC_NO_CLASS; - int i, result; + enum char_class ret; + int i; + + ret = CC_NO_CLASS; for (i = 1; i < N_CHAR_CLASS; i++) { if (STREQ (name, cclass_name[i])) { - char_class = (enum char_class)i; + ret = (enum char_class)i; break; } } - if (char_class == 0) - return -1; + return ret; +} + +static int +cclass_test (c, char_class) + int c; + enum char_class char_class; +{ + int result; switch (char_class) { @@ -215,6 +223,22 @@ is_cclass (c, name) return result; } + +static int +is_cclass (c, name) + int c; + const char *name; +{ + enum char_class char_class; + int result; + + char_class = is_valid_cclass (name); + if (char_class == CC_NO_CLASS) + return -1; + + result = cclass_test (c, char_class); + return (result); +} /* Now include `sm_loop.c' for single-byte characters. */ /* The result of FOLD is an `unsigned char' */ diff --git a/lib/readline/bind.c b/lib/readline/bind.c index 4fa9e622..cd4bab8b 100644 --- a/lib/readline/bind.c +++ b/lib/readline/bind.c @@ -176,8 +176,7 @@ rl_bind_key_in_map (int key, rl_command_func_t *function, Keymap map) } /* Bind key sequence KEYSEQ to DEFAULT_FUNC if KEYSEQ is unbound. Right - now, this is always used to attempt to bind the arrow keys, hence the - check for rl_vi_movement_mode. */ + now, this is always used to attempt to bind the arrow keys. */ int rl_bind_key_if_unbound_in_map (int key, rl_command_func_t *default_func, Keymap kmap) { @@ -199,15 +198,15 @@ rl_bind_key_if_unbound (int key, rl_command_func_t *default_func) } /* Make KEY do nothing in the currently selected keymap. - Returns non-zero in case of error. */ + Returns non-zero in case of error. This is not the same as self-insert; + this makes it a dead key. */ int rl_unbind_key (int key) { return (rl_bind_key (key, (rl_command_func_t *)NULL)); } -/* Make KEY do nothing in MAP. - Returns non-zero in case of error. */ +/* Make KEY do nothing in MAP. Returns non-zero in case of error. */ int rl_unbind_key_in_map (int key, Keymap map) { @@ -231,6 +230,7 @@ rl_unbind_function_in_map (rl_command_func_t *func, Keymap map) return rval; } +/* Unbind all keys bound to COMMAND, which is a bindable command name, in MAP */ int rl_unbind_command_in_map (const char *command, Keymap map) { diff --git a/lib/readline/complete.c b/lib/readline/complete.c index 5a4bb40b..13241d13 100644 --- a/lib/readline/complete.c +++ b/lib/readline/complete.c @@ -1,6 +1,6 @@ /* complete.c -- filename completion for readline. */ -/* Copyright (C) 1987-2015 Free Software Foundation, Inc. +/* Copyright (C) 1987-2017 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. @@ -198,15 +198,6 @@ int _rl_completion_prefix_display_length = 0; matches. If < 0 or > _rl_screenwidth, it is ignored. */ int _rl_completion_columns = -1; -/* Global variables available to applications using readline. */ - -#if defined (VISIBLE_STATS) -/* Non-zero means add an additional character to each filename displayed - during listing completion iff rl_filename_completion_desired which helps - to indicate the type of file being listed. */ -int rl_visible_stats = 0; -#endif /* VISIBLE_STATS */ - #if defined (COLOR_SUPPORT) /* Non-zero means to use colors to indicate file type when listing possible completions. The colors used are taken from $LS_COLORS, if set. */ @@ -227,6 +218,15 @@ int _rl_skip_completed_text = 0; cycle of possible completions instead of the last. */ int _rl_menu_complete_prefix_first = 0; +/* Global variables available to applications using readline. */ + +#if defined (VISIBLE_STATS) +/* Non-zero means add an additional character to each filename displayed + during listing completion iff rl_filename_completion_desired which helps + to indicate the type of file being listed. */ +int rl_visible_stats = 0; +#endif /* VISIBLE_STATS */ + /* If non-zero, then this is the address of a function to call when completing on a directory name. The function is called with the address of a string (the current directory name) as an arg. */ @@ -422,8 +422,7 @@ static int _rl_complete_display_matches_interrupt = 0; that does the initial simple matching selection algorithm (see rl_completion_matches ()). The default is to do filename completion. */ int -rl_complete (ignore, invoking_key) - int ignore, invoking_key; +rl_complete (int ignore, int invoking_key) { rl_completion_invoking_key = invoking_key; @@ -441,16 +440,14 @@ rl_complete (ignore, invoking_key) /* List the possible completions. See description of rl_complete (). */ int -rl_possible_completions (ignore, invoking_key) - int ignore, invoking_key; +rl_possible_completions (int ignore, int invoking_key) { rl_completion_invoking_key = invoking_key; return (rl_complete_internal ('?')); } int -rl_insert_completions (ignore, invoking_key) - int ignore, invoking_key; +rl_insert_completions (int ignore, int invoking_key) { rl_completion_invoking_key = invoking_key; return (rl_complete_internal ('*')); @@ -462,8 +459,7 @@ rl_insert_completions (ignore, invoking_key) an application-specific completion function to honor the show-all-if-ambiguous readline variable. */ int -rl_completion_mode (cfunc) - rl_command_func_t *cfunc; +rl_completion_mode (rl_command_func_t *cfunc) { if (rl_last_func == cfunc && !completion_changed_buffer) return '?'; @@ -483,16 +479,14 @@ rl_completion_mode (cfunc) /* Reset readline state on a signal or other event. */ void -_rl_reset_completion_state () +_rl_reset_completion_state (void) { rl_completion_found_quote = 0; rl_completion_quote_character = 0; } static void -_rl_complete_sigcleanup (sig, ptr) - int sig; - void *ptr; +_rl_complete_sigcleanup (int sig, void *ptr) { if (sig == SIGINT) /* XXX - for now */ { @@ -504,8 +498,7 @@ _rl_complete_sigcleanup (sig, ptr) /* Set default values for readline word completion. These are the variables that application completion functions can change or inspect. */ static void -set_completion_defaults (what_to_do) - int what_to_do; +set_completion_defaults (int what_to_do) { /* Only the completion entry function can change these. */ rl_filename_completion_desired = 0; @@ -523,8 +516,7 @@ set_completion_defaults (what_to_do) /* The user must press "y" or "n". Non-zero return means "y" pressed. */ static int -get_y_or_n (for_pager) - int for_pager; +get_y_or_n (int for_pager) { int c; @@ -557,8 +549,7 @@ get_y_or_n (for_pager) } static int -_rl_internal_pager (lines) - int lines; +_rl_internal_pager (int lines) { int i; @@ -575,8 +566,7 @@ _rl_internal_pager (lines) } static int -path_isdir (filename) - const char *filename; +path_isdir (const char *filename) { struct stat finfo; @@ -593,8 +583,7 @@ path_isdir (filename) `%' for character special devices `#' for block special devices */ static int -stat_char (filename) - char *filename; +stat_char (char *filename) { struct stat finfo; int character, r; @@ -678,29 +667,28 @@ stat_char (filename) #if defined (COLOR_SUPPORT) static int -colored_stat_start (filename) - const char *filename; +colored_stat_start (const char *filename) { _rl_set_normal_color (); return (_rl_print_color_indicator (filename)); } static void -colored_stat_end () +colored_stat_end (void) { _rl_prep_non_filename_text (); _rl_put_indicator (&_rl_color_indicator[C_CLR_TO_EOL]); } static int -colored_prefix_start () +colored_prefix_start (void) { _rl_set_normal_color (); return (_rl_print_prefix_color ()); } static void -colored_prefix_end () +colored_prefix_end (void) { colored_stat_end (); /* for now */ } @@ -715,8 +703,7 @@ colored_prefix_end () for the previous slash and return the portion following that. If there's no previous slash, we just return what we were passed. */ static char * -printable_part (pathname) - char *pathname; +printable_part (char *pathname) { char *temp, *x; @@ -750,8 +737,7 @@ printable_part (pathname) /* Compute width of STRING when displayed on screen by print_filename */ static int -fnwidth (string) - const char *string; +fnwidth (const char *string) { int width, pos; #if defined (HANDLE_MULTIBYTE) @@ -803,10 +789,7 @@ fnwidth (string) #define ELLIPSIS_LEN 3 static int -fnprint (to_print, prefix_bytes, real_pathname) - const char *to_print; - int prefix_bytes; - const char *real_pathname; +fnprint (const char *to_print, int prefix_bytes, const char *real_pathname) { int printed_len, w; const char *s; @@ -932,9 +915,7 @@ fnprint (to_print, prefix_bytes, real_pathname) filenames. Return the number of characters we output. */ static int -print_filename (to_print, full_pathname, prefix_bytes) - char *to_print, *full_pathname; - int prefix_bytes; +print_filename (char *to_print, char *full_pathname, int prefix_bytes) { int printed_len, extension_char, slen, tlen; char *s, c, *new_full_pathname, *dn; @@ -1051,10 +1032,7 @@ print_filename (to_print, full_pathname, prefix_bytes) } static char * -rl_quote_filename (s, rtype, qcp) - char *s; - int rtype; - char *qcp; +rl_quote_filename (char *s, int rtype, char *qcp) { char *r; @@ -1082,8 +1060,7 @@ rl_quote_filename (s, rtype, qcp) the value of the delimiter character that caused a word break. */ char -_rl_find_completion_word (fp, dp) - int *fp, *dp; +_rl_find_completion_word (int *fp, int *dp) { int scan, end, found_quote, delimiter, pass_next, isbrk; char quote_char, *brkchars; @@ -1215,11 +1192,7 @@ _rl_find_completion_word (fp, dp) } static char ** -gen_completion_matches (text, start, end, our_func, found_quote, quote_char) - char *text; - int start, end; - rl_compentry_func_t *our_func; - int found_quote, quote_char; +gen_completion_matches (char *text, int start, int end, rl_compentry_func_t *our_func, int found_quote, int quote_char) { char **matches; @@ -1263,8 +1236,7 @@ gen_completion_matches (text, start, end, our_func, found_quote, quote_char) /* Filter out duplicates in MATCHES. This frees up the strings in MATCHES. */ static char ** -remove_duplicate_matches (matches) - char **matches; +remove_duplicate_matches (char **matches) { char *lowest_common; int i, j, newlen; @@ -1324,10 +1296,7 @@ remove_duplicate_matches (matches) /* Find the common prefix of the list of matches, and put it into matches[0]. */ static int -compute_lcd_of_matches (match_list, matches, text) - char **match_list; - int matches; - const char *text; +compute_lcd_of_matches (char **match_list, int matches, const char *text) { register int i, c1, c2, si; int low; /* Count of max-matched characters. */ @@ -1483,9 +1452,7 @@ compute_lcd_of_matches (match_list, matches, text) } static int -postprocess_matches (matchesp, matching_filenames) - char ***matchesp; - int matching_filenames; +postprocess_matches (char ***matchesp, int matching_filenames) { char *t, **matches, **temp_matches; int nmatch, i; @@ -1539,7 +1506,7 @@ postprocess_matches (matchesp, matching_filenames) } static int -complete_get_screenwidth () +complete_get_screenwidth (void) { int cols; char *envcols; @@ -1560,9 +1527,7 @@ complete_get_screenwidth () of strings, in argv format, LEN is the number of strings in MATCHES, and MAX is the length of the longest string in MATCHES. */ void -rl_display_match_list (matches, len, max) - char **matches; - int len, max; +rl_display_match_list (char **matches, int len, int max) { int count, limit, printed_len, lines, cols; int i, j, k, l, common_length, sind; @@ -1719,8 +1684,7 @@ rl_display_match_list (matches, len, max) and ask the user if he wants to see the list if there are more matches than RL_COMPLETION_QUERY_ITEMS. */ static void -display_matches (matches) - char **matches; +display_matches (char **matches) { int len, max, i; char *temp; @@ -1786,11 +1750,9 @@ display_matches (matches) rl_display_fixed = 1; } +/* qc == pointer to quoting character, if any */ static char * -make_quoted_replacement (match, mtype, qc) - char *match; - int mtype; - char *qc; /* Pointer to quoting character, if any */ +make_quoted_replacement (char *match, int mtype, char *qc) { int should_quote, do_replace; char *replacement; @@ -1832,10 +1794,7 @@ make_quoted_replacement (match, mtype, qc) } static void -insert_match (match, start, mtype, qc) - char *match; - int start, mtype; - char *qc; +insert_match (char *match, int start, int mtype, char *qc) { char *replacement, *r; char oqc; @@ -1892,9 +1851,7 @@ insert_match (match, start, mtype, qc) value of _rl_complete_mark_symlink_dirs, but may be modified by an application's completion function). */ static int -append_to_match (text, delimiter, quote_char, nontrivial_match) - char *text; - int delimiter, quote_char, nontrivial_match; +append_to_match (char *text, int delimiter, int quote_char, int nontrivial_match) { char temp_string[4], *filename, *fn; int temp_string_index, s; @@ -1961,10 +1918,7 @@ append_to_match (text, delimiter, quote_char, nontrivial_match) } static void -insert_all_matches (matches, point, qc) - char **matches; - int point; - char *qc; +insert_all_matches (char **matches, int point, char *qc) { int i; char *rp; @@ -2000,8 +1954,7 @@ insert_all_matches (matches, point, qc) } void -_rl_free_match_list (matches) - char **matches; +_rl_free_match_list (char **matches) { register int i; @@ -2023,17 +1976,14 @@ _rl_free_match_list (matches) `@' means to do standard completion, and list all possible completions if there is more than one and partial completion is not possible. */ int -rl_complete_internal (what_to_do) - int what_to_do; +rl_complete_internal (int what_to_do) { char **matches; rl_compentry_func_t *our_func; int start, end, delimiter, found_quote, i, nontrivial_lcd; char *text, *saved_line_buffer; char quote_char; -#if 1 int tlen, mlen; -#endif RL_SETSTATE(RL_STATE_COMPLETING); @@ -2208,9 +2158,7 @@ rl_complete_internal (what_to_do) when there are no more matches. */ char ** -rl_completion_matches (text, entry_function) - const char *text; - rl_compentry_func_t *entry_function; +rl_completion_matches (const char *text, rl_compentry_func_t *entry_function) { register int i; @@ -2278,9 +2226,7 @@ rl_completion_matches (text, entry_function) TEXT contains a partial username preceded by a random character (usually `~'). */ char * -rl_username_completion_function (text, state) - const char *text; - int state; +rl_username_completion_function (const char *text, int state) { #if defined (__WIN32__) || defined (__OPENNT) return (char *)NULL; @@ -2342,11 +2288,7 @@ rl_username_completion_function (text, state) _rl_completion_case_map is set, make `-' and `_' equivalent. CONVFN is the possibly-converted directory entry; FILENAME is what the user typed. */ static int -complete_fncmp (convfn, convlen, filename, filename_len) - const char *convfn; - int convlen; - const char *filename; - int filename_len; +complete_fncmp (const char *convfn, int convlen, const char *filename, int filename_len) { register char *s1, *s2; int d, len; @@ -2474,9 +2416,7 @@ complete_fncmp (convfn, convlen, filename, filename_len) because of all the pathnames that must be followed when looking up the completion for a command. */ char * -rl_filename_completion_function (text, state) - const char *text; - int state; +rl_filename_completion_function (const char *text, int state) { static DIR *directory = (DIR *)NULL; static char *filename = (char *)NULL; @@ -2704,8 +2644,7 @@ rl_filename_completion_function (text, state) hit the end of the match list, we restore the original unmatched text, ring the bell, and reset the counter to zero. */ int -rl_old_menu_complete (count, invoking_key) - int count, invoking_key; +rl_old_menu_complete (int count, invoking_key) { rl_compentry_func_t *our_func; int matching_filenames, found_quote; @@ -2826,9 +2765,17 @@ rl_old_menu_complete (count, invoking_key) return (0); } +/* The current version of menu completion. + The differences between this function and the original are: + +1. It honors the maximum number of completions variable (completion-query-items) +2. It appends to the word as usual if there is only one match +3. It displays the common prefix if there is one, and makes it the first menu + choice if the menu-complete-display-prefix option is enabled +*/ + int -rl_menu_complete (count, ignore) - int count, ignore; +rl_menu_complete (int count, int ignore) { rl_compentry_func_t *our_func; int matching_filenames, found_quote; @@ -3000,8 +2947,7 @@ rl_menu_complete (count, ignore) } int -rl_backward_menu_complete (count, key) - int count, key; +rl_backward_menu_complete (int count, key) { /* Positive arguments to backward-menu-complete translate into negative arguments for menu-complete, and vice versa. */ diff --git a/lib/readline/display.c b/lib/readline/display.c index 99813b98..9bc8294a 100644 --- a/lib/readline/display.c +++ b/lib/readline/display.c @@ -1,6 +1,6 @@ /* display.c -- readline redisplay facility. */ -/* Copyright (C) 1987-2015 Free Software Foundation, Inc. +/* Copyright (C) 1987-2017 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. @@ -158,9 +158,6 @@ rl_voidfunc_t *rl_redisplay_function = rl_redisplay; /* What YOU turn on when you have handled all redisplay yourself. */ int rl_display_fixed = 0; -int _rl_suppress_redisplay = 0; -int _rl_want_redisplay = 0; - /* The stuff that gets printed out before the actual text of the line. This is usually pointing to rl_prompt. */ char *rl_display_prompt = (char *)NULL; @@ -177,6 +174,10 @@ int _rl_vi_cmd_modestr_len; /* Pseudo-global variables declared here. */ +/* Hints for other parts of readline to give to the display engine. */ +int _rl_suppress_redisplay = 0; +int _rl_want_redisplay = 0; + /* The visible cursor position. If you print some text, adjust this. */ /* NOTE: _rl_last_c_pos is used as a buffer index when not in a locale supporting multibyte characters, and an absolute cursor position when @@ -185,14 +186,24 @@ int _rl_vi_cmd_modestr_len; int _rl_last_c_pos = 0; int _rl_last_v_pos = 0; -static int cpos_adjusted; -static int cpos_buffer_position; -static int displaying_prompt_first_line; -static int prompt_multibyte_chars; - -/* Number of lines currently on screen minus 1. */ +/* Number of physical lines consumed by the current line buffer currently + on screen minus 1. */ int _rl_vis_botlin = 0; +/* This is a hint update_line gives to rl_redisplay that it has adjusted the + value of _rl_last_c_pos *and* taken the presence of any invisible chars in + the prompt into account. rl_redisplay notes this and does not do the + adjustment itself. */ +static int cpos_adjusted; + +/* The index into the line buffer corresponding to the cursor position */ +static int cpos_buffer_position; + +/* A flag to note when we're displaying the first line of the prompt */ +static int displaying_prompt_first_line; +/* The number of multibyte characters in the prompt, if any */ +static int prompt_multibyte_chars; + static int _rl_inv_botlin = 0; /* Variables used only in this file. */ @@ -215,7 +226,11 @@ static int line_size = 1024; static char *local_prompt, *local_prompt_prefix; static int local_prompt_len; -static int prompt_visible_length, prompt_prefix_length; +static int prompt_prefix_length; +/* Number of chars in the buffer that contribute to visible chars on the screen. + This might be different from the number of physical chars in the presence + of multibyte characters */ +static int prompt_visible_length; /* The number of invisible characters in the line currently being displayed on the screen. */ @@ -241,6 +256,12 @@ static int prompt_last_screen_line; static int prompt_physical_chars; +/* An array of indexes into the prompt string where we will break physical + screen lines. It's easier to compute in expand_prompt and use later in + rl_redisplay instead of having rl_redisplay try to guess about invisible + characters in the prompt or use heuristics about where they are. */ +static int *local_prompt_newlines; + /* set to a non-zero value by rl_redisplay if we are marking modified history lines and the current line is so marked. */ static int modmark; @@ -263,8 +284,7 @@ static int saved_physical_chars; /* Return a string indicating the editing mode, for use in the prompt. */ static char * -prompt_modestr (lenp) - int *lenp; +prompt_modestr (int *lenp) { if (rl_editing_mode == emacs_mode) { @@ -292,7 +312,8 @@ prompt_modestr (lenp) index of the last invisible character in the returned string. NIFLP, if non-zero, is a place to store the number of invisible characters in the first prompt line. The previous are used as byte counts -- indexes - into a character buffer. */ + into a character buffer. *VLP gets the number of physical characters in + the expanded prompt (visible length) */ /* Current implementation: \001 (^A) start non-visible characters @@ -305,19 +326,16 @@ prompt_modestr (lenp) PMT_MULTILINE caller indicates that this is part of a multiline prompt */ -static int *local_prompt_newlines; - +/* This approximates the number of lines the prompt will take when displayed */ #define APPROX_DIV(n, d) (((n) < (d)) ? 1 : ((n) / (d)) + 1) static char * -expand_prompt (pmt, flags, lp, lip, niflp, vlp) - char *pmt; - int flags; - int *lp, *lip, *niflp, *vlp; +expand_prompt (char *pmt, int flags, int *lp, int *lip, int *niflp, int *vlp) { char *r, *ret, *p, *igstart, *nprompt, *ms; int l, rl, last, ignoring, ninvis, invfl, invflset, ind, pind, physchars; int mlen, newlines, newlines_guess, bound; + int mb_cur_max; /* We only expand the mode string for the last line of a multiline prompt (a prompt with embedded newlines). */ @@ -332,28 +350,44 @@ expand_prompt (pmt, flags, lp, lip, niflp, vlp) else nprompt = pmt; - /* Short-circuit if we can. */ - if ((MB_CUR_MAX <= 1 || rl_byte_oriented) && strchr (nprompt, RL_PROMPT_START_IGNORE) == 0) - { - r = (nprompt == pmt) ? savestring (pmt) : nprompt; + mb_cur_max = MB_CUR_MAX; - if (lp) - *lp = strlen (r); - if (lip) - *lip = 0; - if (niflp) - *niflp = 0; - if (vlp) - *vlp = lp ? *lp : strlen (r); - return r; + if (_rl_screenwidth == 0) + _rl_get_screen_size (0, 0); /* avoid division by zero */ + + /* Short-circuit if we can. We can do this if we are treating the prompt as + a sequence of bytes and there are no invisible characters in the prompt + to deal with. Since we populate local_prompt_newlines, we have to run + through the rest of the function if this prompt looks like it's going to + be longer than one screen line. */ + if ((mb_cur_max <= 1 || rl_byte_oriented) && strchr (nprompt, RL_PROMPT_START_IGNORE) == 0) + { + l = strlen (nprompt); + if (l < (_rl_screenwidth > 0 ? _rl_screenwidth : 80)) + { + r = (nprompt == pmt) ? savestring (pmt) : nprompt; + if (lp) + *lp = l; + if (lip) + *lip = 0; + if (niflp) + *niflp = 0; + if (vlp) + *vlp = l; + + local_prompt_newlines = (int *) xrealloc (local_prompt_newlines, sizeof (int) * 2); + local_prompt_newlines[0] = 0; + local_prompt_newlines[1] = -1; + + return r; + } } l = strlen (nprompt); /* XXX */ r = ret = (char *)xmalloc (l + 1); - if (_rl_screenwidth == 0) - _rl_get_screen_size (0, 0); /* avoid division by zero */ - + /* Guess at how many screen lines the prompt will take to size the array that + keeps track of where the line wraps happen */ newlines_guess = (_rl_screenwidth > 0) ? APPROX_DIV(l, _rl_screenwidth) : APPROX_DIV(l, 80); local_prompt_newlines = (int *) xrealloc (local_prompt_newlines, sizeof (int) * (newlines_guess + 1)); local_prompt_newlines[newlines = 0] = 0; @@ -361,9 +395,9 @@ expand_prompt (pmt, flags, lp, lip, niflp, vlp) local_prompt_newlines[rl] = -1; rl = physchars = 0; /* mode string now part of nprompt */ - invfl = 0; /* invisible chars in first line of prompt */ - invflset = 0; /* we only want to set invfl once */ - igstart = 0; + invfl = 0; /* invisible chars in first line of prompt */ + invflset = 0; /* we only want to set invfl once */ + igstart = 0; /* we're not ignoring any characters yet */ for (ignoring = last = ninvis = 0, p = nprompt; p && *p; p++) { @@ -385,7 +419,7 @@ expand_prompt (pmt, flags, lp, lip, niflp, vlp) else { #if defined (HANDLE_MULTIBYTE) - if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + if (mb_cur_max > 1 && rl_byte_oriented == 0) { pind = p - nprompt; ind = _rl_find_next_mbchar (nprompt, pind, 1, MB_FIND_NONZERO); @@ -424,20 +458,23 @@ expand_prompt (pmt, flags, lp, lip, niflp, vlp) invfl = ninvis; invflset = 1; } -#if 0 - if (physchars >= ((newlines + 1) * _rl_screenwidth) && local_prompt_newlines[newlines+1] == -1) - local_prompt_newlines[++newlines] = r - ret; -#else + if (physchars >= (bound = (newlines + 1) * _rl_screenwidth) && local_prompt_newlines[newlines+1] == -1) { int new; if (physchars > bound) /* should rarely happen */ - new = _rl_find_prev_mbchar (r, r - ret, MB_FIND_ANY); + { +#if defined (HANDLE_MULTIBYTE) + if (mb_cur_max > 1 && rl_byte_oriented == 0) + new = _rl_find_prev_mbchar (r, r - ret, MB_FIND_ANY); + else +#endif + new = r - ret - (physchars - bound); /* XXX */ + } else new = r - ret; local_prompt_newlines[++newlines] = new; } -#endif } } @@ -463,8 +500,7 @@ expand_prompt (pmt, flags, lp, lip, niflp, vlp) /* Just strip out RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE from PMT and return the rest of PMT. */ char * -_rl_strip_prompt (pmt) - char *pmt; +_rl_strip_prompt (char *pmt) { char *ret; @@ -473,7 +509,7 @@ _rl_strip_prompt (pmt) } void -_rl_reset_prompt () +_rl_reset_prompt (void) { rl_visible_prompt_length = rl_expand_prompt (rl_prompt); } @@ -489,15 +525,20 @@ _rl_reset_prompt () * prompt_visible_length = number of visible characters in local_prompt * prompt_prefix_length = number of visible characters in local_prompt_prefix * + * It also tries to keep track of the number of invisible characters in the + * prompt string, and where they are. + * * This function is called once per call to readline(). It may also be * called arbitrarily to expand the primary prompt. * * The return value is the number of visible characters on the last line - * of the (possibly multi-line) prompt. + * of the (possibly multi-line) prompt. In this case, multi-line means + * there are embedded newlines in the prompt string itself, not that the + * number of physical characters exceeds the screen width and the prompt + * wraps. */ int -rl_expand_prompt (prompt) - char *prompt; +rl_expand_prompt (char *prompt) { char *p, *t; int c; @@ -555,8 +596,7 @@ rl_expand_prompt (prompt) increased. If the lines have already been allocated, this ensures that they can hold at least MINSIZE characters. */ static void -init_line_structures (minsize) - int minsize; +init_line_structures (int minsize) { register int n; @@ -603,9 +643,9 @@ init_line_structures (minsize) line_structures_initialized = 1; } -/* Basic redisplay algorithm. */ +/* Basic redisplay algorithm. See comments inline. */ void -rl_redisplay () +rl_redisplay (void) { register int in, out, c, linenum, cursor_linenum; register char *line; @@ -666,6 +706,10 @@ rl_redisplay () one passed to readline()), use the values we have already expanded. If not, use what's already in rl_display_prompt. WRAP_OFFSET is the number of non-visible characters in the prompt string. */ + /* This is where we output the characters in the prompt before the last + newline, if any. If there aren't any embedded newlines, we don't + write anything. Copy the last line of the prompt string into the line in + any case */ if (rl_display_prompt == rl_prompt || local_prompt) { if (local_prompt_prefix && forced_display) @@ -770,7 +814,10 @@ rl_redisplay () /* inv_lbreaks[i] is where line i starts in the buffer. */ inv_lbreaks[newlines = 0] = 0; /* lpos is a physical cursor position, so it needs to be adjusted by the - number of invisible characters in the prompt, per line */ + number of invisible characters in the prompt, per line. We compute + the line breaks in the prompt string in expand_prompt, taking invisible + characters into account, and if lpos exceeds the screen width, we copy + the data in the loop below. */ lpos = prompt_physical_chars + modmark; #if defined (HANDLE_MULTIBYTE) @@ -780,8 +827,8 @@ rl_redisplay () /* prompt_invis_chars_first_line is the number of invisible characters in the first physical line of the prompt. - wrap_offset - prompt_invis_chars_first_line is the number of invis - chars on the second (or, more generally, last) line. */ + wrap_offset - prompt_invis_chars_first_line is usually the number of + invis chars on the second (or, more generally, last) line. */ /* This is zero-based, used to set the newlines */ prompt_lines_estimate = lpos / _rl_screenwidth; @@ -792,13 +839,6 @@ rl_redisplay () { temp = 0; - /* fix from Darin Johnson for prompt string with - invisible characters that is longer than the screen width. The - prompt_invis_chars_first_line variable could be made into an array - saying how many invisible characters there are per line, but that's - probably too much work for the benefit gained. How many people have - prompts that exceed two physical lines? - Additional logic fix from Edward Catmur */ /* first copy the linebreaks array we computed in expand_prompt */ while (local_prompt_newlines[newlines+1] != -1) { @@ -816,8 +856,9 @@ rl_redisplay () prompt_last_screen_line = newlines; /* Draw the rest of the line (after the prompt) into invisible_line, keeping - track of where the cursor is (cpos_buffer_position), the number of the line containing - the cursor (lb_linenum), the last line number (lb_botlin and inv_botlin). + track of where the cursor is (cpos_buffer_position), the number of the + line containing the cursor (lb_linenum), the last line number (lb_botlin + and inv_botlin). It maintains an array of line breaks for display (inv_lbreaks). This handles expanding tabs for display and displaying meta characters. */ lb_linenum = 0; @@ -1082,8 +1123,8 @@ rl_redisplay () /* update_line potentially changes _rl_last_c_pos, but doesn't take invisible characters into account, since _rl_last_c_pos - is an absolute cursor position in a multibyte locale. See - if compensating here is the right thing, or if we have to + is an absolute cursor position in a multibyte locale. We + choose to (mostly) compensate for that here, rather than change update_line itself. There are several cases in which update_line adjusts _rl_last_c_pos itself (so it can pass _rl_move_cursor_relative accurate values); it communicates @@ -1099,6 +1140,9 @@ rl_redisplay () cpos_adjusted == 0 && _rl_last_c_pos != o_cpos && _rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - prompt_invis_chars_first_line)) + /* This assumes that all the invisible characters are split + between the first and last lines of the prompt, if the + prompt consumes more than two lines. It's usually right */ _rl_last_c_pos -= (wrap_offset-prompt_invis_chars_first_line); /* If this is the line with the prompt, we might need to @@ -1168,6 +1212,9 @@ rl_redisplay () _rl_last_c_pos += wrap_offset; } + /* Now we move the cursor to where it needs to be. First, make + sure we are on the correct line (cursor_linenum). */ + /* We have to reprint the prompt if it contains invisible characters, since it's not generally OK to just reprint the characters from the current cursor position. But we @@ -1209,9 +1256,10 @@ rl_redisplay () position that doesn't take invisible characters in the prompt into account. We use a fudge factor to compensate. */ - /* Since _rl_backspace() doesn't know about invisible characters in the - prompt, and there's no good way to tell it, we compensate for - those characters here and call _rl_backspace() directly. */ + /* Since _rl_backspace() doesn't know about invisible characters in + the prompt, and there's no good way to tell it, we compensate for + those characters here and call _rl_backspace() directly if + necessary */ if (wrap_offset && cursor_linenum == 0 && nleft < _rl_last_c_pos) { /* TX == new physical cursor position in multibyte locale. */ @@ -1236,7 +1284,7 @@ rl_redisplay () _rl_move_cursor_relative (nleft, &invisible_line[pos]); } } - else /* Do horizontal scrolling. */ + else /* Do horizontal scrolling. Much simpler */ { #define M_OFFSET(margin, offset) ((margin) == 0 ? offset : 0) int lmargin, ndisp, nleft, phys_c_pos, t; @@ -1374,9 +1422,7 @@ new: eddie> Oh, my little buggy says to me, as lurgid as Could be made even smarter, but this works well enough */ static void -update_line (old, new, current_line, omax, nmax, inv_botlin) - register char *old, *new; - int current_line, omax, nmax, inv_botlin; +update_line (char *old, char *new, int current_line, int omax, int nmax, int inv_botlin) { register char *ofd, *ols, *oe, *nfd, *nls, *ne; int temp, lendiff, wsatend, od, nd, twidth, o_cpos; @@ -1401,52 +1447,132 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode && _rl_last_v_pos == current_line - 1) { + /* We're going to wrap around by writing the first character of NEW to + the screen and dealing with changes to what's visible by modifying + OLD to match it. Complicated by the presence of multi-width + characters at the end of the line or beginning of the new one. */ #if defined (HANDLE_MULTIBYTE) if (mb_cur_max > 1 && rl_byte_oriented == 0) { wchar_t wc; mbstate_t ps; - int tempwidth, bytes; + int oldwidth, newwidth; + int oldbytes, newbytes; size_t ret; /* This fixes only double-column characters, but if the wrapped character consumes more than three columns, spaces will be inserted in the string buffer. */ - if (current_line < line_state_visible->wbsize && line_state_visible->wrapped_line[current_line] > 0) - _rl_clear_to_eol (line_state_visible->wrapped_line[current_line]); + /* XXX remember that we are working on the invisible line right now; + we don't swap visible and invisible until just before rl_redisplay + returns */ + /* This will remove the extra placeholder space we added with + _rl_wrapped_multicolumn */ + if (current_line < line_state_invisible->wbsize && line_state_invisible->wrapped_line[current_line] > 0) + _rl_clear_to_eol (line_state_invisible->wrapped_line[current_line]); + /* 1. how many screen positions does first char in old consume? */ memset (&ps, 0, sizeof (mbstate_t)); - ret = mbrtowc (&wc, new, mb_cur_max, &ps); + ret = mbrtowc (&wc, old, mb_cur_max, &ps); + oldbytes = ret; if (MB_INVALIDCH (ret)) { - tempwidth = 1; - ret = 1; + oldwidth = 1; + oldbytes = 1; } else if (MB_NULLWCH (ret)) - tempwidth = 0; + oldwidth = 0; else - tempwidth = WCWIDTH (wc); + oldwidth = WCWIDTH (wc); - if (tempwidth > 0) + /* 2. how many screen positions does the first char in new consume? */ + memset (&ps, 0, sizeof (mbstate_t)); + ret = mbrtowc (&wc, new, mb_cur_max, &ps); + newbytes = ret; + if (MB_INVALIDCH (ret)) { - int count, i; - bytes = ret; - for (count = 0; count < bytes; count++) - putc (new[count], rl_outstream); - _rl_last_c_pos = tempwidth; - _rl_last_v_pos++; - memset (&ps, 0, sizeof (mbstate_t)); - ret = mbrtowc (&wc, old, mb_cur_max, &ps); - if (ret != 0 && bytes != 0) + newwidth = 1; + newbytes = 1; + } + else if (MB_NULLWCH (ret)) + newwidth = 0; + else + newwidth = WCWIDTH (wc); + + /* 3. if the new width is less than the old width, we need to keep + going in new until we have consumed at least that many screen + positions, and figure out how many bytes that will take */ + while (newbytes < nmax && newwidth < oldwidth) + { + ret = mbrtowc (&wc, new+newbytes, mb_cur_max, &ps); + if (MB_INVALIDCH (ret)) { - if (MB_INVALIDCH (ret)) - ret = 1; - memmove (old+bytes, old+ret, strlen (old+ret)); - memcpy (old, new, bytes); + newwidth += 1; + newbytes += 1; + } + else if (MB_NULLWCH (ret)) + break; + else + { + newwidth += WCWIDTH (wc); + newbytes += ret; + } + } + /* 4. If the new width is more than the old width, keep going in old + until we have consumed exactly that many screen positions, and + figure out how many bytes that will take. This is an optimization */ + while (oldbytes < omax && oldwidth < newwidth) + { + ret = mbrtowc (&wc, old+oldbytes, mb_cur_max, &ps); + if (MB_INVALIDCH (ret)) + { + oldwidth += 1; + oldbytes += 1; + } + else if (MB_NULLWCH (ret)) + break; + else + { + oldwidth += WCWIDTH (wc); + oldbytes += ret; + } + } + /* 5. write the first newbytes of new, which takes newwidth. This is + where the screen wrapping takes place, and we are now writing + characters onto the new line. We need to fix up old so it + accurately reflects what is on the screen after the + _rl_output_some_chars below. */ + if (newwidth > 0) + { + int count, i, j; + char *optr; + + _rl_output_some_chars (new, newbytes); + _rl_last_c_pos = newwidth; + _rl_last_v_pos++; + + /* 5a. If the number of screen positions doesn't match, punt + and do a dumb update. */ + if (newwidth != oldwidth) + { + ne = new + nmax; + nd = newbytes; + nfd = new + nd; + goto dumb_update; + } + if (oldbytes != 0 && newbytes != 0) + { + /* We have written as many bytes from new as we need to + consume the first character of old. Fix up `old' so it + reflects the new screen contents */ + memmove (old+newbytes, old+oldbytes, strlen (old+oldbytes)); + memcpy (old, new, newbytes); + j = newbytes - oldbytes; + + omax += j; /* Fix up indices if we copy data from one line to another */ - omax += bytes - ret; for (i = current_line+1; i <= inv_botlin+1; i++) - vis_lbreaks[i] += bytes - ret; + vis_lbreaks[i] += j; } } else @@ -1491,6 +1617,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) memset (&ps_new, 0, sizeof(mbstate_t)); memset (&ps_old, 0, sizeof(mbstate_t)); + /* Are the old and new lines the same? */ if (omax == nmax && STREQN (new, old, omax)) { old_offset = omax; @@ -1500,6 +1627,8 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) } else { + /* Go through the line from the beginning and find the first + difference. */ new_offset = old_offset = 0; for (ofd = old, nfd = new; (ofd - old < omax) && *ofd && @@ -1555,6 +1684,8 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) wsatend = 1; /* flag for trailing whitespace */ #if defined (HANDLE_MULTIBYTE) + /* Find the last character that is the same between the two lines. This + bounds the region that needs to change. */ if (mb_cur_max > 1 && rl_byte_oriented == 0) { ols = old + _rl_find_prev_mbchar (old, oe - old, MB_FIND_ANY); @@ -1714,6 +1845,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) nd = lendiff; /* Do a dumb update and return */ +dumb_update: temp = ne - nfd; if (temp > 0) { @@ -1794,6 +1926,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) { /* Non-zero if we're increasing the number of lines. */ int gl = current_line >= _rl_vis_botlin && inv_botlin > _rl_vis_botlin; + /* If col_lendiff is > 0, implying that the new string takes up more screen real estate than the old, but lendiff is < 0, meaning that it takes fewer bytes, we need to just output the characters starting @@ -1948,6 +2081,18 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) _rl_last_c_pos -= wrap_offset; cpos_adjusted = 1; } + +#if 1 + /* If we write a non-space into the last screen column, + remove the note that we added a space to compensate for + a multibyte double-width character that didn't fit, since + it's only valid for what was previously there. */ + /* XXX - watch this */ + if (_rl_last_c_pos == _rl_screenwidth && + line_state_invisible->wrapped_line[current_line+1] && + nfd[bytes_to_insert-1] != ' ') + line_state_invisible->wrapped_line[current_line+1] = 0; +#endif } else _rl_last_c_pos += bytes_to_insert; @@ -2009,7 +2154,7 @@ clear_rest_of_line: /* Tell the update routines that we have moved onto a new (empty) line. */ int -rl_on_new_line () +rl_on_new_line (void) { if (visible_line) visible_line[0] = '\0'; @@ -2025,7 +2170,7 @@ rl_on_new_line () /* Clear all screen lines occupied by the current readline line buffer (visible line) */ int -rl_clear_visible_line () +rl_clear_visible_line (void) { int curr_line; @@ -2053,9 +2198,10 @@ rl_clear_visible_line () /* Tell the update routines that we have moved onto a new line with the prompt already displayed. Code originally from the version of readline distributed with CLISP. rl_expand_prompt must have already been called - (explicitly or implicitly). This still doesn't work exactly right. */ + (explicitly or implicitly). This still doesn't work exactly right; it + should use expand_prompt() */ int -rl_on_new_line_with_prompt () +rl_on_new_line_with_prompt (void) { int prompt_size, i, l, real_screenwidth, newlines; char *prompt_last_line, *lprompt; @@ -2111,7 +2257,7 @@ rl_on_new_line_with_prompt () /* Actually update the display, period. */ int -rl_forced_update_display () +rl_forced_update_display (void) { register char *temp; @@ -2129,7 +2275,7 @@ rl_forced_update_display () /* Redraw only the last line of a multi-line prompt. */ void -rl_redraw_prompt_last_line () +rl_redraw_prompt_last_line (void) { char *t; @@ -2147,9 +2293,7 @@ rl_redraw_prompt_last_line () the movement is being done. DATA is always the visible line or the invisible line */ void -_rl_move_cursor_relative (new, data) - int new; - const char *data; +_rl_move_cursor_relative (int new, const char *data) { register int i; int woff; /* number of invisible chars on current line */ @@ -2306,8 +2450,7 @@ _rl_move_cursor_relative (new, data) /* PWP: move the cursor up or down. */ void -_rl_move_vert (to) - int to; +_rl_move_vert (int to) { register int delta, i; @@ -2347,8 +2490,7 @@ _rl_move_vert (to) /* Physically print C on rl_outstream. This is for functions which know how to optimize the display. Return the number of characters output. */ int -rl_show_char (c) - int c; +rl_show_char (int c) { int n = 1; if (META_CHAR (c) && (_rl_output_meta_chars == 0)) @@ -2375,8 +2517,7 @@ rl_show_char (c) } int -rl_character_len (c, pos) - register int c, pos; +rl_character_len (int c, int pos) { unsigned char uc; @@ -2511,7 +2652,7 @@ rl_message (format, arg1, arg2) /* How to clear things from the "echo-area". */ int -rl_clear_message () +rl_clear_message (void) { rl_display_prompt = rl_prompt; if (msg_saved_prompt) @@ -2524,7 +2665,7 @@ rl_clear_message () } int -rl_reset_line_state () +rl_reset_line_state (void) { rl_on_new_line (); @@ -2533,8 +2674,12 @@ rl_reset_line_state () return 0; } +/* Save all of the variables associated with the prompt and its display. Most + of the complexity is dealing with the invisible characters in the prompt + string and where they are. There are enough of these that I should consider + a struct. */ void -rl_save_prompt () +rl_save_prompt (void) { saved_local_prompt = local_prompt; saved_local_prefix = local_prompt_prefix; @@ -2555,7 +2700,7 @@ rl_save_prompt () } void -rl_restore_prompt () +rl_restore_prompt (void) { FREE (local_prompt); FREE (local_prompt_prefix); @@ -2577,11 +2722,11 @@ rl_restore_prompt () saved_local_length = 0; saved_last_invisible = saved_visible_length = saved_prefix_length = 0; saved_invis_chars_first_line = saved_physical_chars = 0; + saved_local_prompt_newlines = 0; } char * -_rl_make_prompt_for_search (pchar) - int pchar; +_rl_make_prompt_for_search (int pchar) { int len; char *pmt, *p; @@ -2619,8 +2764,7 @@ _rl_make_prompt_for_search (pchar) /* Quick redisplay hack when erasing characters at the end of the line. */ void -_rl_erase_at_end_of_line (l) - int l; +_rl_erase_at_end_of_line (int l) { register int i; @@ -2637,8 +2781,7 @@ _rl_erase_at_end_of_line (l) number of character spaces to clear, but we use a terminal escape sequence if available. */ void -_rl_clear_to_eol (count) - int count; +_rl_clear_to_eol (int count) { #ifndef __MSDOS__ if (_rl_term_clreol) @@ -2652,8 +2795,7 @@ _rl_clear_to_eol (count) /* Clear to the end of the line using spaces. COUNT is the minimum number of character spaces to clear, */ static void -space_to_eol (count) - int count; +space_to_eol (int count) { register int i; @@ -2664,7 +2806,7 @@ space_to_eol (count) } void -_rl_clear_screen () +_rl_clear_screen (void) { #ifndef __DJGPP__ if (_rl_term_clrpag) @@ -2679,9 +2821,7 @@ _rl_clear_screen () /* Insert COUNT characters from STRING to the output stream at column COL. */ static void -insert_some_chars (string, count, col) - char *string; - int count, col; +insert_some_chars (char *string, int count, int col) { open_some_spaces (col); _rl_output_some_chars (string, count); @@ -2691,8 +2831,7 @@ insert_some_chars (string, count, col) ncurses documentation and use either im/ei with explicit spaces, or IC/ic by itself. We assume there will either be ei or we don't need to use it. */ static void -open_some_spaces (col) - int col; +open_some_spaces (int col) { #if !defined (__MSDOS__) && (!defined (__MINGW32__) || defined (NCURSES_VERSION)) char *buffer; @@ -2728,8 +2867,7 @@ open_some_spaces (col) /* Delete COUNT characters from the display line. */ static void -delete_chars (count) - int count; +delete_chars (int count) { if (count > _rl_screenwidth) /* XXX */ return; @@ -2751,7 +2889,7 @@ delete_chars (count) } void -_rl_update_final () +_rl_update_final (void) { int full_lines; @@ -2784,7 +2922,7 @@ _rl_update_final () /* Move to the start of the current line. */ static void -cr () +cr (void) { if (_rl_term_cr) { @@ -2801,8 +2939,7 @@ cr () terminal escape sequences. Called with the cursor at column 0 of the line to draw the prompt on. */ static void -redraw_prompt (t) - char *t; +redraw_prompt (char *t) { char *oldp; @@ -2826,7 +2963,7 @@ redraw_prompt (t) /* Redisplay the current line after a SIGWINCH is received. */ void -_rl_redisplay_after_sigwinch () +_rl_redisplay_after_sigwinch (void) { char *t; @@ -2871,7 +3008,7 @@ _rl_redisplay_after_sigwinch () } void -_rl_clean_up_for_exit () +_rl_clean_up_for_exit (void) { if (_rl_echoing_p) { @@ -2884,7 +3021,7 @@ _rl_clean_up_for_exit () } void -_rl_erase_entire_line () +_rl_erase_entire_line (void) { cr (); _rl_clear_to_eol (0); @@ -2893,7 +3030,7 @@ _rl_erase_entire_line () } void -_rl_ttyflush () +_rl_ttyflush (void) { fflush (rl_outstream); } @@ -2901,7 +3038,7 @@ _rl_ttyflush () /* return the `current display line' of the cursor -- the number of lines to move up to get to the first screen line of the current readline line. */ int -_rl_current_display_line () +_rl_current_display_line (void) { int ret, nleft; @@ -2925,9 +3062,7 @@ _rl_current_display_line () In the case of multibyte characters with stateful encoding, we have to scan from the beginning of the string to take the state into account. */ static int -_rl_col_width (str, start, end, flags) - const char *str; - int start, end, flags; +_rl_col_width (const char *str, int start, int end, int flags) { wchar_t wc; mbstate_t ps; diff --git a/lib/readline/emacs_keymap.c b/lib/readline/emacs_keymap.c index cb6e140a..b5e53f49 100644 --- a/lib/readline/emacs_keymap.c +++ b/lib/readline/emacs_keymap.c @@ -1,6 +1,6 @@ /* emacs_keymap.c -- the keymap for emacs_mode in readline (). */ -/* Copyright (C) 1987-2009 Free Software Foundation, Inc. +/* Copyright (C) 1987-2017 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. diff --git a/lib/readline/histexpand.c b/lib/readline/histexpand.c index b84a6b8a..e9c333d7 100644 --- a/lib/readline/histexpand.c +++ b/lib/readline/histexpand.c @@ -1,6 +1,6 @@ /* histexpand.c -- history expansion. */ -/* Copyright (C) 1989-2015 Free Software Foundation, Inc. +/* Copyright (C) 1989-2017 Free Software Foundation, Inc. This file contains the GNU History Library (History), a set of routines for managing the text of previously typed lines. @@ -132,10 +132,7 @@ static char *search_match; So you might call this function like: line = get_history_event ("!echo:p", &index, 0); */ char * -get_history_event (string, caller_index, delimiting_quote) - const char *string; - int *caller_index; - int delimiting_quote; +get_history_event (const char *string, int *caller_index, int delimiting_quote) { register int i; register char c; @@ -316,9 +313,7 @@ get_history_event (string, caller_index, delimiting_quote) to the closing single quote. FLAGS currently used to allow backslash to escape a single quote (e.g., for bash $'...'). */ static void -hist_string_extract_single_quoted (string, sindex, flags) - char *string; - int *sindex, flags; +hist_string_extract_single_quoted (char *string, int *sindex, int flags) { register int i; @@ -332,8 +327,7 @@ hist_string_extract_single_quoted (string, sindex, flags) } static char * -quote_breaks (s) - char *s; +quote_breaks (char *s) { register char *p, *r; char *ret; @@ -374,9 +368,7 @@ quote_breaks (s) } static char * -hist_error(s, start, current, errtype) - char *s; - int start, current, errtype; +hist_error(char *s, int start, int current, int errtype) { char *temp; const char *emsg; @@ -433,9 +425,7 @@ hist_error(s, start, current, errtype) subst_rhs is allowed to be set to the empty string. */ static char * -get_subst_pattern (str, iptr, delimiter, is_rhs, lenptr) - char *str; - int *iptr, delimiter, is_rhs, *lenptr; +get_subst_pattern (char *str, int *iptr, int delimiter, int is_rhs, int *lenptr) { register int si, i, j, k; char *s; @@ -490,7 +480,7 @@ get_subst_pattern (str, iptr, delimiter, is_rhs, lenptr) } static void -postproc_subst_rhs () +postproc_subst_rhs (void) { char *new; int i, j, new_size; @@ -526,12 +516,9 @@ postproc_subst_rhs () if the `p' modifier was supplied and the caller should just print the returned string. Returns the new index into string in *END_INDEX_PTR, and the expanded specifier in *RET_STRING. */ +/* need current line for !# */ static int -history_expand_internal (string, start, qc, end_index_ptr, ret_string, current_line) - char *string; - int start, qc, *end_index_ptr; - char **ret_string; - char *current_line; /* for !# */ +history_expand_internal (char *string, int start, int qc, int *end_index_ptr, char **ret_string, char *current_line) { int i, n, starting_index; int substitute_globally, subst_bywords, want_quotes, print_only; @@ -908,9 +895,7 @@ history_expand_internal (string, start, qc, end_index_ptr, ret_string, current_l while (0) int -history_expand (hstring, output) - char *hstring; - char **output; +history_expand (char *hstring, char **output) { register int j; int i, r, l, passc, cc, modified, eindex, only_printing, dquote, squote, flag; @@ -1249,9 +1234,7 @@ history_expand (hstring, output) CALLER_INDEX is the offset in SPEC to start looking; it is updated to point to just after the last character parsed. */ static char * -get_history_word_specifier (spec, from, caller_index) - char *spec, *from; - int *caller_index; +get_history_word_specifier (char *spec, char *from, int *caller_index) { register int i = *caller_index; int first, last; @@ -1357,9 +1340,7 @@ get_history_word_specifier (spec, from, caller_index) tokens, so that FIRST = -1 means the next to last token on the line). If LAST is `$' the last arg from STRING is used. */ char * -history_arg_extract (first, last, string) - int first, last; - const char *string; +history_arg_extract (int first, int last, const char *string) { register int i, len; char *result; @@ -1418,9 +1399,7 @@ history_arg_extract (first, last, string) } static int -history_tokenize_word (string, ind) - const char *string; - int ind; +history_tokenize_word (const char *string, int ind) { register int i, j; int delimiter, nestdelim, delimopen; @@ -1570,9 +1549,7 @@ get_word: } static char * -history_substring (string, start, end) - const char *string; - int start, end; +history_substring (const char *string, int start, int end) { register int len; register char *result; @@ -1589,9 +1566,7 @@ history_substring (string, start, end) WIND. The position in the returned array of strings is returned in *INDP. */ static char ** -history_tokenize_internal (string, wind, indp) - const char *string; - int wind, *indp; +history_tokenize_internal (const char *string, int wind, int *indp) { char **result; register int i, start, result_index, size; @@ -1644,17 +1619,14 @@ history_tokenize_internal (string, wind, indp) /* Return an array of tokens, much as the shell might. The tokens are parsed out of STRING. */ char ** -history_tokenize (string) - const char *string; +history_tokenize (const char *string) { return (history_tokenize_internal (string, -1, (int *)NULL)); } /* Free members of WORDS from START to an empty string */ static void -freewords (words, start) - char **words; - int start; +freewords (char **words, int start) { register int i; @@ -1666,9 +1638,7 @@ freewords (words, start) in the history line LINE. Used to save the word matched by the last history !?string? search. */ static char * -history_find_word (line, ind) - char *line; - int ind; +history_find_word (char *line, int ind) { char **words, *s; int i, wind; diff --git a/lib/readline/histfile.c b/lib/readline/histfile.c index 2e69c583..aee760c0 100644 --- a/lib/readline/histfile.c +++ b/lib/readline/histfile.c @@ -1,6 +1,6 @@ /* histfile.c - functions to manipulate the history file. */ -/* Copyright (C) 1989-2016 Free Software Foundation, Inc. +/* Copyright (C) 1989-2017 Free Software Foundation, Inc. This file contains the GNU History Library (History), a set of routines for managing the text of previously typed lines. @@ -143,8 +143,7 @@ static int histfile_restore PARAMS((const char *, const char *)); filename. This only matters when you don't specify the filename to read_history (), or write_history (). */ static char * -history_filename (filename) - const char *filename; +history_filename (const char *filename) { char *return_val; const char *home; @@ -179,8 +178,7 @@ history_filename (filename) } static char * -history_backupfile (filename) - const char *filename; +history_backupfile (const char *filename) { const char *fn; char *ret, linkbuf[PATH_MAX+1]; @@ -208,8 +206,7 @@ history_backupfile (filename) } static char * -history_tempfile (filename) - const char *filename; +history_tempfile (const char *filename) { const char *fn; char *ret, linkbuf[PATH_MAX+1]; @@ -251,8 +248,7 @@ history_tempfile (filename) If FILENAME is NULL, then read from ~/.history. Returns 0 if successful, or errno if not. */ int -read_history (filename) - const char *filename; +read_history (const char *filename) { return (read_history_range (filename, 0, -1)); } @@ -263,9 +259,7 @@ read_history (filename) until the end of the file. If FILENAME is NULL, then read from ~/.history. Returns 0 if successful, or errno if not. */ int -read_history_range (filename, from, to) - const char *filename; - int from, to; +read_history_range (const char *filename, int from, int to) { register char *line_start, *line_end, *p; char *input, *buffer, *bufend, *last_ts; @@ -427,9 +421,7 @@ read_history_range (filename, from, to) /* Save FILENAME to BACK, handling case where FILENAME is a symlink (e.g., ~/.bash_history -> .histfiles/.bash_history.$HOSTNAME) */ static int -histfile_backup (filename, back) - const char *filename; - const char *back; +histfile_backup (const char *filename, const char *back) { #if defined (HAVE_READLINK) char linkbuf[PATH_MAX+1]; @@ -448,9 +440,7 @@ histfile_backup (filename, back) /* Restore ORIG from BACKUP handling case where ORIG is a symlink (e.g., ~/.bash_history -> .histfiles/.bash_history.$HOSTNAME) */ static int -histfile_restore (backup, orig) - const char *backup; - const char *orig; +histfile_restore (const char *backup, const char *orig) { #if defined (HAVE_READLINK) char linkbuf[PATH_MAX+1]; @@ -470,9 +460,7 @@ histfile_restore (backup, orig) If FNAME is NULL, then use ~/.history. Writes a new file and renames it to the original name. Returns 0 on success, errno on failure. */ int -history_truncate_file (fname, lines) - const char *fname; - int lines; +history_truncate_file (const char *fname, int lines) { char *buffer, *filename, *tempname, *bp, *bp1; /* bp1 == bp+1 */ int file, chars_read, rv, orig_lines, exists, r; @@ -625,9 +613,7 @@ history_truncate_file (fname, lines) from the history list to FILENAME. OVERWRITE is non-zero if you wish to replace FILENAME with the entries. */ static int -history_do_write (filename, nelements, overwrite) - const char *filename; - int nelements, overwrite; +history_do_write (const char *filename, int nelements, int overwrite) { register int i; char *output, *tempname, *histname; @@ -773,9 +759,7 @@ mmap_error: /* Append NELEMENT entries to FILENAME. The entries appended are from the end of the list minus NELEMENTs up to the end of the list. */ int -append_history (nelements, filename) - int nelements; - const char *filename; +append_history (int nelements, const char *filename) { return (history_do_write (filename, nelements, HISTORY_APPEND)); } @@ -784,8 +768,7 @@ append_history (nelements, filename) then write the history list to ~/.history. Values returned are as in read_history ().*/ int -write_history (filename) - const char *filename; +write_history (const char *filename) { return (history_do_write (filename, history_length, HISTORY_OVERWRITE)); } diff --git a/lib/readline/history.c b/lib/readline/history.c index ef293c76..67158b14 100644 --- a/lib/readline/history.c +++ b/lib/readline/history.c @@ -1,6 +1,6 @@ /* history.c -- standalone history library */ -/* Copyright (C) 1989-2015 Free Software Foundation, Inc. +/* Copyright (C) 1989-2017 Free Software Foundation, Inc. This file contains the GNU History Library (History), a set of routines for managing the text of previously typed lines. @@ -97,7 +97,7 @@ int history_base = 1; /* Return the current HISTORY_STATE of the history. */ HISTORY_STATE * -history_get_history_state () +history_get_history_state (void) { HISTORY_STATE *state; @@ -115,8 +115,7 @@ history_get_history_state () /* Set the state of the current history array to STATE. */ void -history_set_history_state (state) - HISTORY_STATE *state; +history_set_history_state (HISTORY_STATE *state) { the_history = state->entries; history_offset = state->offset; @@ -129,7 +128,7 @@ history_set_history_state (state) /* Begin a session in which the history functions might be used. This initializes interactive variables. */ void -using_history () +using_history (void) { history_offset = history_length; } @@ -138,7 +137,7 @@ using_history () This just adds up the lengths of the_history->lines and the associated timestamps. */ int -history_total_bytes () +history_total_bytes (void) { register int i, result; @@ -151,7 +150,7 @@ history_total_bytes () /* Returns the magic number which says what history element we are looking at now. In this implementation, it returns history_offset. */ int -where_history () +where_history (void) { return (history_offset); } @@ -159,8 +158,7 @@ where_history () /* Make the current history item be the one at POS, an absolute index. Returns zero if POS is out of range, else non-zero. */ int -history_set_pos (pos) - int pos; +history_set_pos (int pos) { if (pos > history_length || pos < 0 || !the_history) return (0); @@ -172,7 +170,7 @@ history_set_pos (pos) is the actual array of data, and could be bashed or made corrupt easily. The array is terminated with a NULL pointer. */ HIST_ENTRY ** -history_list () +history_list (void) { return (the_history); } @@ -180,7 +178,7 @@ history_list () /* Return the history entry at the current position, as determined by history_offset. If there is no entry there, return a NULL pointer. */ HIST_ENTRY * -current_history () +current_history (void) { return ((history_offset == history_length) || the_history == 0) ? (HIST_ENTRY *)NULL @@ -191,7 +189,7 @@ current_history () a pointer to that entry. If there is no previous entry then return a NULL pointer. */ HIST_ENTRY * -previous_history () +previous_history (void) { return history_offset ? the_history[--history_offset] : (HIST_ENTRY *)NULL; } @@ -200,7 +198,7 @@ previous_history () a pointer to that entry. If there is no next entry then return a NULL pointer. */ HIST_ENTRY * -next_history () +next_history (void) { return (history_offset == history_length) ? (HIST_ENTRY *)NULL : the_history[++history_offset]; } @@ -208,8 +206,7 @@ next_history () /* Return the history entry which is logically at OFFSET in the history array. OFFSET is relative to history_base. */ HIST_ENTRY * -history_get (offset) - int offset; +history_get (int offset) { int local_index; @@ -220,9 +217,7 @@ history_get (offset) } HIST_ENTRY * -alloc_history_entry (string, ts) - char *string; - char *ts; +alloc_history_entry (char *string, char *ts) { HIST_ENTRY *temp; @@ -236,8 +231,7 @@ alloc_history_entry (string, ts) } time_t -history_get_time (hist) - HIST_ENTRY *hist; +history_get_time (HIST_ENTRY *hist) { char *ts; time_t t; @@ -255,7 +249,7 @@ history_get_time (hist) } static char * -hist_inittime () +hist_inittime (void) { time_t t; char ts[64], *ret; @@ -275,8 +269,7 @@ hist_inittime () /* Place STRING at the end of the history list. The data field is set to NULL. */ void -add_history (string) - const char *string; +add_history (const char *string) { HIST_ENTRY *temp; int new_length; @@ -335,8 +328,7 @@ add_history (string) /* Change the time stamp of the most recent history entry to STRING. */ void -add_history_time (string) - const char *string; +add_history_time (const char *string) { HIST_ENTRY *hs; @@ -350,8 +342,7 @@ add_history_time (string) /* Free HIST and return the data so the calling application can free it if necessary and desired. */ histdata_t -free_history_entry (hist) - HIST_ENTRY *hist; +free_history_entry (HIST_ENTRY *hist) { histdata_t x; @@ -365,8 +356,7 @@ free_history_entry (hist) } HIST_ENTRY * -copy_history_entry (hist) - HIST_ENTRY *hist; +copy_history_entry (HIST_ENTRY *hist) { HIST_ENTRY *ret; char *ts; @@ -388,10 +378,7 @@ copy_history_entry (hist) the old entry so you can dispose of the data. In the case of an invalid WHICH, a NULL pointer is returned. */ HIST_ENTRY * -replace_history_entry (which, line, data) - int which; - const char *line; - histdata_t data; +replace_history_entry (int which, const char *line, histdata_t data) { HIST_ENTRY *temp, *old_value; @@ -413,9 +400,7 @@ replace_history_entry (which, line, data) end of the current line first. This can be used to construct multi-line history entries while reading lines from the history file. */ void -_hs_append_history_line (which, line) - int which; - const char *line; +_hs_append_history_line (int which, const char *line) { HIST_ENTRY *hent; size_t newlen, curlen, minlen; @@ -451,9 +436,7 @@ _hs_append_history_line (which, line) WHICH >= 0 means to replace that particular history entry's data, as long as it matches OLD. */ void -_hs_replace_history_data (which, old, new) - int which; - histdata_t *old, *new; +_hs_replace_history_data (int which, histdata_t *old, histdata_t *new) { HIST_ENTRY *entry; register int i, last; @@ -493,8 +476,7 @@ _hs_replace_history_data (which, old, new) element is returned to you so you can free the line, data, and containing structure. */ HIST_ENTRY * -remove_history (which) - int which; +remove_history (int which) { HIST_ENTRY *return_value; register int i; @@ -526,8 +508,7 @@ remove_history (which) } HIST_ENTRY ** -remove_history_range (first, last) - int first, last; +remove_history_range (int first, int last) { HIST_ENTRY **return_value; register int i; @@ -564,8 +545,7 @@ remove_history_range (first, last) /* Stifle the history list, remembering only MAX number of lines. */ void -stifle_history (max) - int max; +stifle_history (int max) { register int i, j; @@ -593,7 +573,7 @@ stifle_history (max) number of history entries. The value is positive if the history was stifled, negative if it wasn't. */ int -unstifle_history () +unstifle_history (void) { if (history_stifled) { @@ -605,13 +585,13 @@ unstifle_history () } int -history_is_stifled () +history_is_stifled (void) { return (history_stifled); } void -clear_history () +clear_history (void) { register int i; diff --git a/lib/readline/histsearch.c b/lib/readline/histsearch.c index ab18f972..b6771fda 100644 --- a/lib/readline/histsearch.c +++ b/lib/readline/histsearch.c @@ -1,6 +1,6 @@ /* histsearch.c -- searching the history list. */ -/* Copyright (C) 1989, 1992-2009 Free Software Foundation, Inc. +/* Copyright (C) 1989, 1992-2009,2017 Free Software Foundation, Inc. This file contains the GNU History Library (History), a set of routines for managing the text of previously typed lines. @@ -64,9 +64,7 @@ static int history_search_internal PARAMS((const char *, int, int)); returned. */ static int -history_search_internal (string, direction, flags) - const char *string; - int direction, flags; +history_search_internal (const char *string, int direction, int flags) { register int i, reverse; register char *line; @@ -198,9 +196,7 @@ history_search_internal (string, direction, flags) } int -_hs_history_patsearch (string, direction, flags) - const char *string; - int direction, flags; +_hs_history_patsearch (const char *string, int direction, int flags) { char *pat; size_t len; @@ -244,18 +240,14 @@ _hs_history_patsearch (string, direction, flags) /* Do a non-anchored search for STRING through the history in DIRECTION. */ int -history_search (string, direction) - const char *string; - int direction; +history_search (const char *string, int direction) { return (history_search_internal (string, direction, NON_ANCHORED_SEARCH)); } /* Do an anchored search for string through the history in DIRECTION. */ int -history_search_prefix (string, direction) - const char *string; - int direction; +history_search_prefix (const char *string, int direction) { return (history_search_internal (string, direction, ANCHORED_SEARCH)); } @@ -264,9 +256,7 @@ history_search_prefix (string, direction) backwards. POS is an absolute index into the history list at which point to begin searching. */ int -history_search_pos (string, dir, pos) - const char *string; - int dir, pos; +history_search_pos (const char *string, int dir, int pos) { int ret, old; diff --git a/lib/readline/kill.c b/lib/readline/kill.c index 289a3989..6875e3a1 100644 --- a/lib/readline/kill.c +++ b/lib/readline/kill.c @@ -1,6 +1,6 @@ /* kill.c -- kill ring management. */ -/* Copyright (C) 1994-2015 Free Software Foundation, Inc. +/* Copyright (C) 1994-2017 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. @@ -78,8 +78,7 @@ static int rl_yank_nth_arg_internal PARAMS((int, int, int)); /* How to say that you only want to save a certain amount of kill material. */ int -rl_set_retained_kills (num) - int num; +rl_set_retained_kills (int num) { return 0; } @@ -89,9 +88,7 @@ rl_set_retained_kills (num) non-zero, and the last command was a kill, the text is appended to the current kill ring slot, otherwise prepended. */ static int -_rl_copy_to_kill_ring (text, append) - char *text; - int append; +_rl_copy_to_kill_ring (char *text, int append) { char *old, *new; int slot; @@ -163,8 +160,7 @@ _rl_copy_to_kill_ring (text, append) last command was not a kill command, then a new slot is made for this kill. */ int -rl_kill_text (from, to) - int from, to; +rl_kill_text (int from, int to) { char *text; @@ -198,8 +194,7 @@ rl_kill_text (from, to) /* Delete the word at point, saving the text in the kill ring. */ int -rl_kill_word (count, key) - int count, key; +rl_kill_word (int count, int key) { int orig_point; @@ -222,17 +217,16 @@ rl_kill_word (count, key) /* Rubout the word before point, placing it on the kill ring. */ int -rl_backward_kill_word (count, ignore) - int count, ignore; +rl_backward_kill_word (int count, int key) { int orig_point; if (count < 0) - return (rl_kill_word (-count, ignore)); + return (rl_kill_word (-count, key)); else { orig_point = rl_point; - rl_backward_word (count, ignore); + rl_backward_word (count, key); if (rl_point != orig_point) rl_kill_text (orig_point, rl_point); @@ -246,17 +240,16 @@ rl_backward_kill_word (count, ignore) /* Kill from here to the end of the line. If DIRECTION is negative, kill back to the line start instead. */ int -rl_kill_line (direction, ignore) - int direction, ignore; +rl_kill_line (int direction, int key) { int orig_point; if (direction < 0) - return (rl_backward_kill_line (1, ignore)); + return (rl_backward_kill_line (1, key)); else { orig_point = rl_point; - rl_end_of_line (1, ignore); + rl_end_of_line (1, key); if (orig_point != rl_point) rl_kill_text (orig_point, rl_point); rl_point = orig_point; @@ -269,13 +262,12 @@ rl_kill_line (direction, ignore) /* Kill backwards to the start of the line. If DIRECTION is negative, kill forwards to the line end instead. */ int -rl_backward_kill_line (direction, ignore) - int direction, ignore; +rl_backward_kill_line (int direction, int key) { int orig_point; if (direction < 0) - return (rl_kill_line (1, ignore)); + return (rl_kill_line (1, key)); else { if (rl_point == 0) @@ -283,7 +275,7 @@ rl_backward_kill_line (direction, ignore) else { orig_point = rl_point; - rl_beg_of_line (1, ignore); + rl_beg_of_line (1, key); if (rl_point != orig_point) rl_kill_text (orig_point, rl_point); if (rl_editing_mode == emacs_mode) @@ -295,8 +287,7 @@ rl_backward_kill_line (direction, ignore) /* Kill the whole line, no matter where point is. */ int -rl_kill_full_line (count, ignore) - int count, ignore; +rl_kill_full_line (int count, int key) { rl_begin_undo_group (); rl_point = 0; @@ -313,8 +304,7 @@ rl_kill_full_line (count, ignore) /* This does what C-w does in Unix. We can't prevent people from using behaviour that they expect. */ int -rl_unix_word_rubout (count, key) - int count, key; +rl_unix_word_rubout (int count, int key) { int orig_point; @@ -346,8 +336,7 @@ rl_unix_word_rubout (count, key) /* This deletes one filename component in a Unix pathname. That is, it deletes backward to directory separator (`/') or whitespace. */ int -rl_unix_filename_rubout (count, key) - int count, key; +rl_unix_filename_rubout (int count, int key) { int orig_point, c; @@ -390,8 +379,7 @@ rl_unix_filename_rubout (count, key) into the line at all, and if you aren't, then you know what you are doing. */ int -rl_unix_line_discard (count, key) - int count, key; +rl_unix_line_discard (int count, int key) { if (rl_point == 0) rl_ding (); @@ -408,8 +396,7 @@ rl_unix_line_discard (count, key) /* Copy the text in the `region' to the kill ring. If DELETE is non-zero, delete the text from the line as well. */ static int -region_kill_internal (delete) - int delete; +region_kill_internal (int delete) { char *text; @@ -427,16 +414,14 @@ region_kill_internal (delete) /* Copy the text in the region to the kill ring. */ int -rl_copy_region_to_kill (count, ignore) - int count, ignore; +rl_copy_region_to_kill (int count, int key) { return (region_kill_internal (0)); } /* Kill the text between the point and mark. */ int -rl_kill_region (count, ignore) - int count, ignore; +rl_kill_region (int count, int key) { int r, npoint; @@ -450,8 +435,7 @@ rl_kill_region (count, ignore) /* Copy COUNT words to the kill ring. DIR says which direction we look to find the words. */ static int -_rl_copy_word_as_kill (count, dir) - int count, dir; +_rl_copy_word_as_kill (int count, int dir) { int om, op, r; @@ -479,8 +463,7 @@ _rl_copy_word_as_kill (count, dir) } int -rl_copy_forward_word (count, key) - int count, key; +rl_copy_forward_word (int count, int key) { if (count < 0) return (rl_copy_backward_word (-count, key)); @@ -489,8 +472,7 @@ rl_copy_forward_word (count, key) } int -rl_copy_backward_word (count, key) - int count, key; +rl_copy_backward_word (int count, int key) { if (count < 0) return (rl_copy_forward_word (-count, key)); @@ -500,8 +482,7 @@ rl_copy_backward_word (count, key) /* Yank back the last killed text. This ignores arguments. */ int -rl_yank (count, ignore) - int count, ignore; +rl_yank (int count, int key) { if (rl_kill_ring == 0) { @@ -519,8 +500,7 @@ rl_yank (count, ignore) delete that text from the line, rotate the index down, and yank back some other text. */ int -rl_yank_pop (count, key) - int count, key; +rl_yank_pop (int count, int key) { int l, n; @@ -552,8 +532,7 @@ rl_yank_pop (count, key) #if defined (VI_MODE) int -rl_vi_yank_pop (count, key) - int count, key; +rl_vi_yank_pop (int count, int key) { int l, n; @@ -587,8 +566,7 @@ rl_vi_yank_pop (count, key) /* Yank the COUNTh argument from the previous history line, skipping HISTORY_SKIP lines before looking for the `previous line'. */ static int -rl_yank_nth_arg_internal (count, ignore, history_skip) - int count, ignore, history_skip; +rl_yank_nth_arg_internal (int count, int key, int history_skip) { register HIST_ENTRY *entry; char *arg; @@ -629,7 +607,7 @@ rl_yank_nth_arg_internal (count, ignore, history_skip) inserts it right *after* rl_point. */ if (rl_editing_mode == vi_mode) { - rl_vi_append_mode (1, ignore); + rl_vi_append_mode (1, key); rl_insert_text (" "); } #endif /* VI_MODE */ @@ -643,18 +621,16 @@ rl_yank_nth_arg_internal (count, ignore, history_skip) /* Yank the COUNTth argument from the previous history line. */ int -rl_yank_nth_arg (count, ignore) - int count, ignore; +rl_yank_nth_arg (int count, int key) { - return (rl_yank_nth_arg_internal (count, ignore, 0)); + return (rl_yank_nth_arg_internal (count, key, 0)); } /* Yank the last argument from the previous history line. This `knows' how rl_yank_nth_arg treats a count of `$'. With an argument, this behaves the same as rl_yank_nth_arg. */ int -rl_yank_last_arg (count, key) - int count, key; +rl_yank_last_arg (int count, int key) { static int history_skip = 0; static int explicit_arg_p = 0; @@ -695,8 +671,7 @@ rl_yank_last_arg (count, key) closing sequence and insert the pasted text as a single unit without interpretation. */ int -rl_bracketed_paste_begin (count, key) - int count, key; +rl_bracketed_paste_begin (int count, int key) { int retval, c; size_t len, cap; @@ -745,8 +720,7 @@ rl_bracketed_paste_begin (count, key) #include int -rl_paste_from_clipboard (count, key) - int count, key; +rl_paste_from_clipboard (int count, int key) { char *data, *ptr; int len; diff --git a/lib/readline/readline.c b/lib/readline/readline.c index 5c512662..e4de5a73 100644 --- a/lib/readline/readline.c +++ b/lib/readline/readline.c @@ -1,7 +1,7 @@ /* readline.c -- a general facility for reading lines of input with emacs style editing and completion. */ -/* Copyright (C) 1987-2016 Free Software Foundation, Inc. +/* Copyright (C) 1987-2017 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. @@ -325,8 +325,7 @@ int _rl_meta_flag = 0; /* Forward declaration */ /* Set up the prompt and expand it. Called from readline() and rl_callback_handler_install (). */ int -rl_set_prompt (prompt) - const char *prompt; +rl_set_prompt (const char *prompt) { FREE (rl_prompt); rl_prompt = prompt ? savestring (prompt) : (char *)NULL; @@ -339,8 +338,7 @@ rl_set_prompt (prompt) /* Read a line of input. Prompt with PROMPT. An empty PROMPT means none. A return value of NULL means that EOF was encountered. */ char * -readline (prompt) - const char *prompt; +readline (const char *prompt) { char *value; #if 0 @@ -401,7 +399,7 @@ readline (prompt) #endif STATIC_CALLBACK void -readline_internal_setup () +readline_internal_setup (void) { char *nprompt; @@ -453,8 +451,7 @@ readline_internal_setup () } STATIC_CALLBACK char * -readline_internal_teardown (eof) - int eof; +readline_internal_teardown (int eof) { char *temp; HIST_ENTRY *entry; @@ -496,7 +493,7 @@ readline_internal_teardown (eof) } void -_rl_internal_char_cleanup () +_rl_internal_char_cleanup (void) { #if defined (VI_MODE) /* In vi mode, when you exit insert mode, the cursor moves back @@ -527,9 +524,9 @@ _rl_internal_char_cleanup () STATIC_CALLBACK int #if defined (READLINE_CALLBACKS) -readline_internal_char () +readline_internal_char (void) #else -readline_internal_charloop () +readline_internal_charloop (void) #endif { static int lastc, eof_found; @@ -651,7 +648,7 @@ readline_internal_charloop () #if defined (READLINE_CALLBACKS) static int -readline_internal_charloop () +readline_internal_charloop (void) { int eof = 1; @@ -665,7 +662,7 @@ readline_internal_charloop () the global rl_outstream. If rl_prompt is non-null, then that is our prompt. */ static char * -readline_internal () +readline_internal (void) { int eof; @@ -675,7 +672,7 @@ readline_internal () } void -_rl_init_line_state () +_rl_init_line_state (void) { rl_point = rl_end = rl_mark = 0; the_line = rl_line_buffer; @@ -683,14 +680,14 @@ _rl_init_line_state () } void -_rl_set_the_line () +_rl_set_the_line (void) { the_line = rl_line_buffer; } #if defined (READLINE_CALLBACKS) _rl_keyseq_cxt * -_rl_keyseq_cxt_alloc () +_rl_keyseq_cxt_alloc (void) { _rl_keyseq_cxt *cxt; @@ -706,14 +703,13 @@ _rl_keyseq_cxt_alloc () } void -_rl_keyseq_cxt_dispose (cxt) - _rl_keyseq_cxt *cxt; +_rl_keyseq_cxt_dispose (_rl_keyseq_cxt *cxt) { xfree (cxt); } void -_rl_keyseq_chain_dispose () +_rl_keyseq_chain_dispose (void) { _rl_keyseq_cxt *cxt; @@ -727,8 +723,7 @@ _rl_keyseq_chain_dispose () #endif static int -_rl_subseq_getchar (key) - int key; +_rl_subseq_getchar (int key) { int k; @@ -745,8 +740,7 @@ _rl_subseq_getchar (key) #if defined (READLINE_CALLBACKS) int -_rl_dispatch_callback (cxt) - _rl_keyseq_cxt *cxt; +_rl_dispatch_callback (_rl_keyseq_cxt *cxt) { int nkey, r; @@ -797,19 +791,14 @@ _rl_dispatch_callback (cxt) If the associated command is really a keymap, then read another key, and dispatch into that map. */ int -_rl_dispatch (key, map) - register int key; - Keymap map; +_rl_dispatch (register int key, Keymap map) { _rl_dispatching_keymap = map; return _rl_dispatch_subseq (key, map, 0); } int -_rl_dispatch_subseq (key, map, got_subseq) - register int key; - Keymap map; - int got_subseq; +_rl_dispatch_subseq (register int key, Keymap map, int got_subseq) { int r, newkey; char *macro; @@ -1026,10 +1015,7 @@ _rl_dispatch_subseq (key, map, got_subseq) } static int -_rl_subseq_result (r, map, key, got_subseq) - int r; - Keymap map; - int key, got_subseq; +_rl_subseq_result (int r, Keymap map, int key, int got_subseq) { Keymap m; int type, nt; @@ -1103,7 +1089,7 @@ _rl_subseq_result (r, map, key, got_subseq) /* Initialize readline (and terminal if not already). */ int -rl_initialize () +rl_initialize (void) { /* If we have never been called before, initialize the terminal and data structures. */ @@ -1151,7 +1137,7 @@ rl_initialize () #if 0 #if defined (__EMX__) static void -_emx_build_environ () +_emx_build_environ (void) { TIB *tibp; PIB *pibp; @@ -1176,7 +1162,7 @@ _emx_build_environ () /* Initialize the entire state of the world. */ static void -readline_initialize_everything () +readline_initialize_everything (void) { #if 0 #if defined (__EMX__) @@ -1261,7 +1247,7 @@ readline_initialize_everything () input editing characters, then bind them to their readline equivalents, iff the characters are not bound to keymaps. */ static void -readline_default_bindings () +readline_default_bindings (void) { if (_rl_bind_stty_chars) rl_tty_set_default_bindings (_rl_keymap); @@ -1270,7 +1256,7 @@ readline_default_bindings () /* Reset the default bindings for the terminal special characters we're interested in back to rl_insert and read the new ones. */ static void -reset_default_bindings () +reset_default_bindings (void) { if (_rl_bind_stty_chars) { @@ -1281,8 +1267,7 @@ reset_default_bindings () /* Bind some common arrow key sequences in MAP. */ static void -bind_arrow_keys_internal (map) - Keymap map; +bind_arrow_keys_internal (Keymap map) { Keymap xkeymap; @@ -1310,6 +1295,11 @@ bind_arrow_keys_internal (map) rl_bind_keyseq_if_unbound ("\033OH", rl_beg_of_line); rl_bind_keyseq_if_unbound ("\033OF", rl_end_of_line); + /* Key bindings for control-arrow keys */ + rl_bind_keyseq_if_unbound ("\033[1;5C", rl_forward_word); + rl_bind_keyseq_if_unbound ("\033[1;5D", rl_backward_word); + rl_bind_keyseq_if_unbound ("\033[3;5~", rl_kill_word); + #if defined (__MINGW32__) rl_bind_keyseq_if_unbound ("\340H", rl_get_previous_history); rl_bind_keyseq_if_unbound ("\340P", rl_get_next_history); @@ -1338,7 +1328,7 @@ bind_arrow_keys_internal (map) the inputrc file a chance to bind them and create `real' keymaps for the arrow key prefix. */ static void -bind_arrow_keys () +bind_arrow_keys (void) { bind_arrow_keys_internal (emacs_standard_keymap); @@ -1353,7 +1343,7 @@ bind_arrow_keys () } static void -bind_bracketed_paste_prefix () +bind_bracketed_paste_prefix (void) { Keymap xkeymap; @@ -1375,8 +1365,7 @@ bind_bracketed_paste_prefix () /* **************************************************************** */ int -rl_save_state (sp) - struct readline_state *sp; +rl_save_state (struct readline_state *sp) { if (sp == 0) return -1; @@ -1416,8 +1405,7 @@ rl_save_state (sp) } int -rl_restore_state (sp) - struct readline_state *sp; +rl_restore_state (struct readline_state *sp) { if (sp == 0) return -1; diff --git a/lib/readline/vi_keymap.c b/lib/readline/vi_keymap.c index e5da2e0f..045258bd 100644 --- a/lib/readline/vi_keymap.c +++ b/lib/readline/vi_keymap.c @@ -1,6 +1,6 @@ /* vi_keymap.c -- the keymap for vi_mode in readline (). */ -/* Copyright (C) 1987-2016 Free Software Foundation, Inc. +/* Copyright (C) 1987-2017 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. diff --git a/lib/readline/vi_mode.c b/lib/readline/vi_mode.c index 074ca7b3..3613d195 100644 --- a/lib/readline/vi_mode.c +++ b/lib/readline/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-2016 Free Software Foundation, Inc. +/* Copyright (C) 1987-2017 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. @@ -63,6 +63,8 @@ #define member(c, s) ((c) ? (char *)strchr ((s), (c)) != (char *)NULL : 0) #endif +/* This is global so other parts of the code can check whether the last + command was a text modification command. */ int _rl_vi_last_command = 'i'; /* default `.' puts you in insert mode */ _rl_vimotion_cxt *_rl_vimvcxt = 0; @@ -146,7 +148,7 @@ static int vi_yank_dispatch PARAMS((_rl_vimotion_cxt *)); static int vidomove_dispatch PARAMS((_rl_vimotion_cxt *)); void -_rl_vi_initialize_line () +_rl_vi_initialize_line (void) { register int i, n; @@ -158,7 +160,7 @@ _rl_vi_initialize_line () } void -_rl_vi_reset_last () +_rl_vi_reset_last (void) { _rl_vi_last_command = 'i'; _rl_vi_last_repeat = 1; @@ -167,8 +169,7 @@ _rl_vi_reset_last () } void -_rl_vi_set_last (key, repeat, sign) - int key, repeat, sign; +_rl_vi_set_last (int key, int repeat, int sign) { _rl_vi_last_command = key; _rl_vi_last_repeat = repeat; @@ -178,8 +179,7 @@ _rl_vi_set_last (key, repeat, sign) /* A convenience function that calls _rl_vi_set_last to save the last command information and enters insertion mode. */ void -rl_vi_start_inserting (key, repeat, sign) - int key, repeat, sign; +rl_vi_start_inserting (int key, int repeat, int sign) { _rl_vi_set_last (key, repeat, sign); rl_vi_insertion_mode (1, key); @@ -187,22 +187,19 @@ rl_vi_start_inserting (key, repeat, sign) /* Is the command C a VI mode text modification command? */ int -_rl_vi_textmod_command (c) - int c; +_rl_vi_textmod_command (int c) { return (member (c, vi_textmod)); } int -_rl_vi_motion_command (c) - int c; +_rl_vi_motion_command (int c) { return (member (c, vi_motion)); } static void -_rl_vi_replace_insert (count) - int count; +_rl_vi_replace_insert (int count) { int nchars; @@ -217,8 +214,7 @@ _rl_vi_replace_insert (count) } static void -_rl_vi_stuff_insert (count) - int count; +_rl_vi_stuff_insert (int count) { rl_begin_undo_group (); while (count--) @@ -230,8 +226,7 @@ _rl_vi_stuff_insert (count) redo a text modification command. The default for _rl_vi_last_command puts you back into insert mode. */ int -rl_vi_redo (count, c) - int count, c; +rl_vi_redo (int count, int c) { int r; @@ -296,16 +291,14 @@ rl_vi_redo (count, c) /* A placeholder for further expansion. */ int -rl_vi_undo (count, key) - int count, key; +rl_vi_undo (int count, int key) { return (rl_undo_command (count, key)); } /* Yank the nth arg from the previous line into this line at point. */ int -rl_vi_yank_arg (count, key) - int count, key; +rl_vi_yank_arg (int count, int key) { /* Readline thinks that the first word on a line is the 0th, while vi thinks the first word on a line is the 1st. Compensate. */ @@ -320,8 +313,7 @@ rl_vi_yank_arg (count, key) /* With an argument, move back that many history lines, else move to the beginning of history. */ int -rl_vi_fetch_history (count, c) - int count, c; +rl_vi_fetch_history (int count, int c) { int wanted; @@ -345,8 +337,7 @@ rl_vi_fetch_history (count, c) /* Search again for the last thing searched for. */ int -rl_vi_search_again (count, key) - int count, key; +rl_vi_search_again (int count, int key) { switch (key) { @@ -363,8 +354,7 @@ rl_vi_search_again (count, key) /* Do a vi style search. */ int -rl_vi_search (count, key) - int count, key; +rl_vi_search (int count, int key) { switch (key) { @@ -387,8 +377,7 @@ rl_vi_search (count, key) /* Completion, from vi's point of view. */ int -rl_vi_complete (ignore, key) - int ignore, key; +rl_vi_complete (int ignore, int key) { if ((rl_point < rl_end) && (!whitespace (rl_line_buffer[rl_point]))) { @@ -414,8 +403,7 @@ rl_vi_complete (ignore, key) /* Tilde expansion for vi mode. */ int -rl_vi_tilde_expand (ignore, key) - int ignore, key; +rl_vi_tilde_expand (int ignore, int key) { rl_tilde_expand (0, key); rl_vi_start_inserting (key, 1, rl_arg_sign); @@ -424,8 +412,7 @@ rl_vi_tilde_expand (ignore, key) /* Previous word in vi mode. */ int -rl_vi_prev_word (count, key) - int count, key; +rl_vi_prev_word (int count, int key) { if (count < 0) return (rl_vi_next_word (-count, key)); @@ -446,8 +433,7 @@ rl_vi_prev_word (count, key) /* Next word in vi mode. */ int -rl_vi_next_word (count, key) - int count, key; +rl_vi_next_word (int count, int key) { if (count < 0) return (rl_vi_prev_word (-count, key)); @@ -467,8 +453,7 @@ rl_vi_next_word (count, key) /* Move to the end of the ?next? word. */ int -rl_vi_end_word (count, key) - int count, key; +rl_vi_end_word (int count, int key) { if (count < 0) { @@ -485,8 +470,7 @@ rl_vi_end_word (count, key) /* Move forward a word the way that 'W' does. */ int -rl_vi_fWord (count, ignore) - int count, ignore; +rl_vi_fWord (int count, int ignore) { while (count-- && rl_point < (rl_end - 1)) { @@ -502,8 +486,7 @@ rl_vi_fWord (count, ignore) } int -rl_vi_bWord (count, ignore) - int count, ignore; +rl_vi_bWord (int count, int ignore) { while (count-- && rl_point > 0) { @@ -526,8 +509,7 @@ rl_vi_bWord (count, ignore) } int -rl_vi_eWord (count, ignore) - int count, ignore; +rl_vi_eWord (int count, int ignore) { while (count-- && rl_point < (rl_end - 1)) { @@ -557,8 +539,7 @@ rl_vi_eWord (count, ignore) } int -rl_vi_fword (count, ignore) - int count, ignore; +rl_vi_fword (int count, int ignore) { while (count-- && rl_point < (rl_end - 1)) { @@ -583,8 +564,7 @@ rl_vi_fword (count, ignore) } int -rl_vi_bword (count, ignore) - int count, ignore; +rl_vi_bword (int count, int ignore) { while (count-- && rl_point > 0) { @@ -623,8 +603,7 @@ rl_vi_bword (count, ignore) } int -rl_vi_eword (count, ignore) - int count, ignore; +rl_vi_eword (int count, int ignore) { while (count-- && rl_point < rl_end - 1) { @@ -648,8 +627,7 @@ rl_vi_eword (count, ignore) } int -rl_vi_insert_beg (count, key) - int count, key; +rl_vi_insert_beg (int count, int key) { rl_beg_of_line (1, key); rl_vi_insert_mode (1, key); @@ -657,8 +635,7 @@ rl_vi_insert_beg (count, key) } static void -_rl_vi_append_forward (key) - int key; +_rl_vi_append_forward (int key) { int point; @@ -681,8 +658,7 @@ _rl_vi_append_forward (key) } int -rl_vi_append_mode (count, key) - int count, key; +rl_vi_append_mode (int count, int key) { _rl_vi_append_forward (key); rl_vi_start_inserting (key, 1, rl_arg_sign); @@ -690,8 +666,7 @@ rl_vi_append_mode (count, key) } int -rl_vi_append_eol (count, key) - int count, key; +rl_vi_append_eol (int count, int key) { rl_end_of_line (1, key); rl_vi_append_mode (1, key); @@ -700,8 +675,7 @@ rl_vi_append_eol (count, key) /* What to do in the case of C-d. */ int -rl_vi_eof_maybe (count, c) - int count, c; +rl_vi_eof_maybe (int count, int c) { return (rl_newline (1, '\n')); } @@ -711,8 +685,7 @@ rl_vi_eof_maybe (count, c) /* Switching from one mode to the other really just involves switching keymaps. */ int -rl_vi_insertion_mode (count, key) - int count, key; +rl_vi_insertion_mode (int count, int key) { _rl_keymap = vi_insertion_keymap; _rl_vi_last_key_before_insert = key; @@ -722,16 +695,14 @@ rl_vi_insertion_mode (count, key) } int -rl_vi_insert_mode (count, key) - int count, key; +rl_vi_insert_mode (int count, int key) { rl_vi_start_inserting (key, 1, rl_arg_sign); return (0); } static void -vi_save_insert_buffer (start, len) - int start, len; +vi_save_insert_buffer (int start, int len) { /* Same code as _rl_vi_save_insert below */ if (len >= vi_insert_buffer_size) @@ -744,7 +715,7 @@ vi_save_insert_buffer (start, len) } static void -_rl_vi_save_replace () +_rl_vi_save_replace (void) { int len, start, end; UNDO_LIST *up; @@ -767,8 +738,7 @@ _rl_vi_save_replace () } static void -_rl_vi_save_insert (up) - UNDO_LIST *up; +_rl_vi_save_insert (UNDO_LIST *up) { int len, start, end; @@ -787,7 +757,7 @@ _rl_vi_save_insert (up) } void -_rl_vi_done_inserting () +_rl_vi_done_inserting (void) { if (_rl_vi_doing_insert) { @@ -822,8 +792,7 @@ _rl_vi_done_inserting () } int -rl_vi_movement_mode (count, key) - int count, key; +rl_vi_movement_mode (int count, int key) { if (rl_point > 0) rl_backward_char (1, key); @@ -844,8 +813,7 @@ rl_vi_movement_mode (count, key) } int -rl_vi_arg_digit (count, c) - int count, c; +rl_vi_arg_digit (int count, int c) { if (c == '0' && rl_numeric_arg == 1 && !rl_explicit_arg) return (rl_beg_of_line (1, c)); @@ -856,8 +824,7 @@ rl_vi_arg_digit (count, c) /* Change the case of the next COUNT characters. */ #if defined (HANDLE_MULTIBYTE) static int -_rl_vi_change_mbchar_case (count) - int count; +_rl_vi_change_mbchar_case (int count) { wchar_t wc; char mb[MB_LEN_MAX+1]; @@ -910,8 +877,7 @@ _rl_vi_change_mbchar_case (count) #endif int -rl_vi_change_case (count, ignore) - int count, ignore; +rl_vi_change_case (int count, int ignore) { int c, p; @@ -957,8 +923,7 @@ rl_vi_change_case (count, ignore) } int -rl_vi_put (count, key) - int count, key; +rl_vi_put (int count, int key) { if (!_rl_uppercase_p (key) && (rl_point + 1 <= rl_end)) rl_point = _rl_find_next_mbchar (rl_line_buffer, rl_point, 1, MB_FIND_NONZERO); @@ -970,8 +935,9 @@ rl_vi_put (count, key) return (0); } +/* Move the cursor back one character. */ static void -_rl_vi_backup () +_rl_vi_backup (void) { if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_NONZERO); @@ -979,8 +945,9 @@ _rl_vi_backup () rl_point--; } +/* Move the cursor back one character if you're at the end of the line */ int -rl_vi_check () +rl_vi_check (void) { if (rl_point && rl_point == rl_end) { @@ -992,9 +959,9 @@ rl_vi_check () return (0); } +/* Move to the character position specified by COUNT */ int -rl_vi_column (count, key) - int count, key; +rl_vi_column (int count, int key) { if (count > rl_end) rl_end_of_line (1, key); @@ -1007,8 +974,7 @@ rl_vi_column (count, key) argument should be aborted, 0 if we should not read any more chars, and 1 if we should continue to read chars. */ static int -_rl_vi_arg_dispatch (c) - int c; +_rl_vi_arg_dispatch (int c) { int key; @@ -1042,7 +1008,7 @@ _rl_vi_arg_dispatch (c) Don't recognize minus sign? Should this do rl_save_prompt/rl_restore_prompt? */ static int -rl_digit_loop1 () +rl_digit_loop1 (void) { int c, r; @@ -1062,10 +1028,12 @@ rl_digit_loop1 () return (0); } +/* This set of functions is basically to handle the commands that take a + motion argument while in callback mode: read the command, read the motion + command modifier, find the extent of the text to affect, and dispatch the + command for execution. */ static void -_rl_mvcxt_init (m, op, key) - _rl_vimotion_cxt *m; - int op, key; +_rl_mvcxt_init (_rl_vimotion_cxt *m, int op, int key) { m->op = op; m->state = m->flags = 0; @@ -1078,8 +1046,7 @@ _rl_mvcxt_init (m, op, key) } static _rl_vimotion_cxt * -_rl_mvcxt_alloc (op, key) - int op, key; +_rl_mvcxt_alloc (int op, int key) { _rl_vimotion_cxt *m; @@ -1089,15 +1056,13 @@ _rl_mvcxt_alloc (op, key) } static void -_rl_mvcxt_dispose (m) - _rl_vimotion_cxt *m; +_rl_mvcxt_dispose (_rl_vimotion_cxt *m) { xfree (m); } static int -rl_domove_motion_callback (m) - _rl_vimotion_cxt *m; +rl_domove_motion_callback (_rl_vimotion_cxt *m) { int c; @@ -1130,9 +1095,7 @@ rl_domove_motion_callback (m) } int -_rl_vi_domove_motion_cleanup (c, m) - int c; - _rl_vimotion_cxt *m; +_rl_vi_domove_motion_cleanup (int c, _rl_vimotion_cxt *m) { int r; @@ -1194,8 +1157,7 @@ _rl_vi_domove_motion_cleanup (c, m) #define RL_VIMOVENUMARG() (RL_ISSTATE (RL_STATE_VIMOTION) && RL_ISSTATE (RL_STATE_NUMERICARG)) static int -rl_domove_read_callback (m) - _rl_vimotion_cxt *m; +rl_domove_read_callback (_rl_vimotion_cxt *m) { int c, save; @@ -1261,8 +1223,7 @@ rl_domove_read_callback (m) } static int -rl_vi_domove_getchar (m) - _rl_vimotion_cxt *m; +rl_vi_domove_getchar (_rl_vimotion_cxt *m) { int c; @@ -1275,8 +1236,7 @@ rl_vi_domove_getchar (m) #if defined (READLINE_CALLBACKS) int -_rl_vi_domove_callback (m) - _rl_vimotion_cxt *m; +_rl_vi_domove_callback (_rl_vimotion_cxt *m) { int c, r; @@ -1289,10 +1249,9 @@ _rl_vi_domove_callback (m) } #endif -/* This code path taken when not in callback mode. */ +/* This code path is taken when not in callback mode. */ int -rl_vi_domove (x, ignore) - int x, *ignore; +rl_vi_domove (int x, int *ignore) { int r; _rl_vimotion_cxt *m; @@ -1310,8 +1269,7 @@ rl_vi_domove (x, ignore) } static int -vi_delete_dispatch (m) - _rl_vimotion_cxt *m; +vi_delete_dispatch (_rl_vimotion_cxt *m) { /* These are the motion commands that do not require adjusting the mark. */ @@ -1324,8 +1282,7 @@ vi_delete_dispatch (m) } int -rl_vi_delete_to (count, key) - int count, key; +rl_vi_delete_to (int count, int key) { int c, r; @@ -1374,8 +1331,7 @@ rl_vi_delete_to (count, key) } static int -vi_change_dispatch (m) - _rl_vimotion_cxt *m; +vi_change_dispatch (_rl_vimotion_cxt *m) { /* These are the motion commands that do not require adjusting the mark. c[wW] are handled by special-case code in rl_vi_domove(), @@ -1414,8 +1370,7 @@ vi_change_dispatch (m) } int -rl_vi_change_to (count, key) - int count, key; +rl_vi_change_to (int count, int key) { int c, r; @@ -1464,8 +1419,7 @@ rl_vi_change_to (count, key) } static int -vi_yank_dispatch (m) - _rl_vimotion_cxt *m; +vi_yank_dispatch (_rl_vimotion_cxt *m) { /* These are the motion commands that do not require adjusting the mark. */ @@ -1483,8 +1437,7 @@ vi_yank_dispatch (m) } int -rl_vi_yank_to (count, key) - int count, key; +rl_vi_yank_to (int count, int key) { int c, r; @@ -1533,8 +1486,7 @@ rl_vi_yank_to (count, key) } static int -vidomove_dispatch (m) - _rl_vimotion_cxt *m; +vidomove_dispatch (_rl_vimotion_cxt *m) { int r; @@ -1560,8 +1512,7 @@ vidomove_dispatch (m) } int -rl_vi_rubout (count, key) - int count, key; +rl_vi_rubout (int count, int key) { int opoint; @@ -1591,8 +1542,7 @@ rl_vi_rubout (count, key) } int -rl_vi_delete (count, key) - int count, key; +rl_vi_delete (int count, int key) { int end; @@ -1627,8 +1577,7 @@ rl_vi_delete (count, key) #define vi_unix_word_boundary(c) (whitespace(c) || ispunct(c)) int -rl_vi_unix_word_rubout (count, key) - int count, key; +rl_vi_unix_word_rubout (int count, int key) { int orig_point; @@ -1678,8 +1627,7 @@ rl_vi_unix_word_rubout (count, key) int -rl_vi_back_to_indent (count, key) - int count, key; +rl_vi_back_to_indent (int count, int key) { rl_beg_of_line (1, key); while (rl_point < rl_end && whitespace (rl_line_buffer[rl_point])) @@ -1688,8 +1636,7 @@ rl_vi_back_to_indent (count, key) } int -rl_vi_first_print (count, key) - int count, key; +rl_vi_first_print (int count, int key) { return (rl_vi_back_to_indent (1, key)); } @@ -1698,8 +1645,7 @@ static int _rl_cs_dir, _rl_cs_orig_dir; #if defined (READLINE_CALLBACKS) static int -_rl_vi_callback_char_search (data) - _rl_callback_generic_arg *data; +_rl_vi_callback_char_search (_rl_callback_generic_arg *data) { int c; #if defined (HANDLE_MULTIBYTE) @@ -1733,8 +1679,7 @@ _rl_vi_callback_char_search (data) #endif int -rl_vi_char_search (count, key) - int count, key; +rl_vi_char_search (int count, int key) { int c; #if defined (HANDLE_MULTIBYTE) @@ -1827,8 +1772,7 @@ rl_vi_char_search (count, key) /* Match brackets */ int -rl_vi_match (ignore, key) - int ignore, key; +rl_vi_match (int ignore, int key) { int count = 1, brack, pos, tmp, pre; @@ -1917,8 +1861,7 @@ rl_vi_match (ignore, key) } int -rl_vi_bracktype (c) - int c; +rl_vi_bracktype (int c) { switch (c) { @@ -1933,9 +1876,7 @@ rl_vi_bracktype (c) } static int -_rl_vi_change_char (count, c, mb) - int count, c; - char *mb; +_rl_vi_change_char (int count, int c, char *mb) { int p; @@ -1966,9 +1907,7 @@ _rl_vi_change_char (count, c, mb) } static int -_rl_vi_callback_getchar (mb, mlen) - char *mb; - int mlen; +_rl_vi_callback_getchar (char *mb, int mlen) { int c; @@ -1989,8 +1928,7 @@ _rl_vi_callback_getchar (mb, mlen) #if defined (READLINE_CALLBACKS) static int -_rl_vi_callback_change_char (data) - _rl_callback_generic_arg *data; +_rl_vi_callback_change_char (_rl_callback_generic_arg *data) { int c; char mb[MB_LEN_MAX]; @@ -2008,8 +1946,7 @@ _rl_vi_callback_change_char (data) #endif int -rl_vi_change_char (count, key) - int count, key; +rl_vi_change_char (int count, int key) { int c; char mb[MB_LEN_MAX]; @@ -2038,8 +1975,7 @@ rl_vi_change_char (count, key) } int -rl_vi_subst (count, key) - int count, key; +rl_vi_subst (int count, int key) { /* If we are redoing, rl_vi_change_to will stuff the last motion char */ if (_rl_vi_redoing == 0) @@ -2049,8 +1985,7 @@ rl_vi_subst (count, key) } int -rl_vi_overstrike (count, key) - int count, key; +rl_vi_overstrike (int count, int key) { if (_rl_vi_doing_insert == 0) { @@ -2068,8 +2003,7 @@ rl_vi_overstrike (count, key) } int -rl_vi_overstrike_delete (count, key) - int count, key; +rl_vi_overstrike_delete (int count, int key) { int i, s; @@ -2099,8 +2033,7 @@ rl_vi_overstrike_delete (count, key) } int -rl_vi_replace (count, key) - int count, key; +rl_vi_replace (int count, int key) { int i; @@ -2146,7 +2079,7 @@ rl_vi_replace (count, key) the previous character. A space matches everything. Word delimiters are space and ;. */ int -rl_vi_possible_completions() +rl_vi_possible_completions (void) { int save_pos = rl_point; @@ -2171,7 +2104,7 @@ rl_vi_possible_completions() /* Functions to save and restore marks. */ static int -_rl_vi_set_mark () +_rl_vi_set_mark (void) { int ch; @@ -2191,8 +2124,7 @@ _rl_vi_set_mark () #if defined (READLINE_CALLBACKS) static int -_rl_vi_callback_set_mark (data) - _rl_callback_generic_arg *data; +_rl_vi_callback_set_mark (_rl_callback_generic_arg *data) { _rl_callback_func = 0; _rl_want_redisplay = 1; @@ -2202,8 +2134,7 @@ _rl_vi_callback_set_mark (data) #endif int -rl_vi_set_mark (count, key) - int count, key; +rl_vi_set_mark (int count, int key) { #if defined (READLINE_CALLBACKS) if (RL_ISSTATE (RL_STATE_CALLBACK)) @@ -2218,7 +2149,7 @@ rl_vi_set_mark (count, key) } static int -_rl_vi_goto_mark () +_rl_vi_goto_mark (void) { int ch; @@ -2249,8 +2180,7 @@ _rl_vi_goto_mark () #if defined (READLINE_CALLBACKS) static int -_rl_vi_callback_goto_mark (data) - _rl_callback_generic_arg *data; +_rl_vi_callback_goto_mark (_rl_callback_generic_arg *data) { _rl_callback_func = 0; _rl_want_redisplay = 1; @@ -2260,8 +2190,7 @@ _rl_vi_callback_goto_mark (data) #endif int -rl_vi_goto_mark (count, key) - int count, key; +rl_vi_goto_mark (int count, int key) { #if defined (READLINE_CALLBACKS) if (RL_ISSTATE (RL_STATE_CALLBACK)) diff --git a/lib/readline/xmalloc.c b/lib/readline/xmalloc.c index c77d7634..5d01d75e 100644 --- a/lib/readline/xmalloc.c +++ b/lib/readline/xmalloc.c @@ -1,6 +1,6 @@ /* xmalloc.c -- safe versions of malloc and realloc */ -/* Copyright (C) 1991-2009 Free Software Foundation, Inc. +/* Copyright (C) 1991-2017 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. @@ -42,8 +42,7 @@ /* **************************************************************** */ static void -memory_error_and_abort (fname) - char *fname; +memory_error_and_abort (char *fname) { fprintf (stderr, "%s: out of virtual memory\n", fname); exit (2); @@ -53,8 +52,7 @@ memory_error_and_abort (fname) to hold BYTES number of bytes. If the memory cannot be allocated, print an error message and abort. */ PTR_T -xmalloc (bytes) - size_t bytes; +xmalloc (size_t bytes) { PTR_T temp; @@ -65,9 +63,7 @@ xmalloc (bytes) } PTR_T -xrealloc (pointer, bytes) - PTR_T pointer; - size_t bytes; +xrealloc (PTR_T pointer, size_t bytes) { PTR_T temp; diff --git a/lib/tilde/shell.c b/lib/tilde/shell.c index fafb8619..9805a924 100644 --- a/lib/tilde/shell.c +++ b/lib/tilde/shell.c @@ -1,7 +1,7 @@ /* shell.c -- tilde utility functions that are normally provided by bash when readline is linked as part of the shell. */ -/* Copyright (C) 1998-2009 Free Software Foundation, Inc. +/* Copyright (C) 1998-2017 Free Software Foundation, Inc. This file is part of the GNU Tilde Library. @@ -49,8 +49,7 @@ extern struct passwd *getpwuid (); #endif /* !HAVE_GETPW_DECLS */ char * -get_env_value (varname) - char *varname; +get_env_value (char *varname) { return ((char *)getenv (varname)); } @@ -58,7 +57,7 @@ get_env_value (varname) /* If we're not using $HOME, assume that the passwd file information won't change while this shell instance is running. */ char * -get_home_dir () +get_home_dir (void) { static char *home_dir = (char *)NULL; struct passwd *entry; diff --git a/lib/tilde/tilde.c b/lib/tilde/tilde.c index 95bc4215..9d0f2961 100644 --- a/lib/tilde/tilde.c +++ b/lib/tilde/tilde.c @@ -1,6 +1,6 @@ /* tilde.c -- Tilde expansion code (~/foo := $HOME/foo). */ -/* Copyright (C) 1988-2009 Free Software Foundation, Inc. +/* Copyright (C) 1988-2017 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. @@ -125,9 +125,7 @@ static char *glue_prefix_and_suffix PARAMS((char *, const char *, int)); the tilde which starts the expansion. Place the length of the text which identified this tilde starter in LEN, excluding the tilde itself. */ static int -tilde_find_prefix (string, len) - const char *string; - int *len; +tilde_find_prefix (const char *string, int *len) { register int i, j, string_len; register char **prefixes; @@ -160,8 +158,7 @@ tilde_find_prefix (string, len) /* Find the end of a tilde expansion in STRING, and return the index of the character which ends the tilde definition. */ static int -tilde_find_suffix (string) - const char *string; +tilde_find_suffix (const char *string) { register int i, j, string_len; register char **suffixes; @@ -189,8 +186,7 @@ tilde_find_suffix (string) /* Return a new string which is the result of tilde expanding STRING. */ char * -tilde_expand (string) - const char *string; +tilde_expand (const char *string) { char *result; int result_size, result_index; @@ -267,9 +263,7 @@ tilde_expand (string) non-null, the index of the end of the prefix into FNAME is returned in the location it points to. */ static char * -isolate_tilde_prefix (fname, lenp) - const char *fname; - int *lenp; +isolate_tilde_prefix (const char *fname, int *lenp) { char *ret; int i; @@ -293,9 +287,7 @@ isolate_tilde_prefix (fname, lenp) function. Right now, it just calls tilde_find_suffix and allocates new memory, but it can be expanded to do different things later. */ char * -tilde_find_word (fname, flags, lenp) - const char *fname; - int flags, *lenp; +tilde_find_word (const char *fname, int flags, int *lenp) { int x; char *r; @@ -323,10 +315,7 @@ tilde_find_word (fname, flags, lenp) /* Return a string that is PREFIX concatenated with SUFFIX starting at SUFFIND. */ static char * -glue_prefix_and_suffix (prefix, suffix, suffind) - char *prefix; - const char *suffix; - int suffind; +glue_prefix_and_suffix (char *prefix, const char *suffix, int suffind) { char *ret; int plen, slen; @@ -344,8 +333,7 @@ glue_prefix_and_suffix (prefix, suffix, suffind) tilde. If there is no expansion, call tilde_expansion_failure_hook. This always returns a newly-allocated string, never static storage. */ char * -tilde_expand_word (filename) - const char *filename; +tilde_expand_word (const char *filename) { char *dirname, *expansion, *username; int user_len; @@ -434,9 +422,7 @@ tilde_expand_word (filename) #undef NULL #include -main (argc, argv) - int argc; - char **argv; +main (int argc, char **argv) { char *result, line[512]; int done = 0; @@ -464,11 +450,10 @@ main (argc, argv) exit (0); } -static void memory_error_and_abort (); +static void memory_error_and_abort (void); static void * -xmalloc (bytes) - size_t bytes; +xmalloc (size_t bytes) { void *temp = (char *)malloc (bytes); @@ -478,9 +463,7 @@ xmalloc (bytes) } static void * -xrealloc (pointer, bytes) - void *pointer; - int bytes; +xrealloc (void *pointer, int bytes) { void *temp; @@ -496,7 +479,7 @@ xrealloc (pointer, bytes) } static void -memory_error_and_abort () +memory_error_and_abort (void) { fprintf (stderr, "readline: out of virtual memory\n"); abort (); diff --git a/shell.c b/shell.c index 9fe8e70a..3588ed8b 100644 --- a/shell.c +++ b/shell.c @@ -1239,7 +1239,7 @@ maybe_make_restricted (name) if (restricted || (STREQ (temp, RESTRICTED_SHELL_NAME))) { #if defined (RBASH_STATIC_PATH_VALUE) - temp_var = bind_variable ("PATH", RBASH_STATIC_PATH_VALUE, 0); + bind_variable ("PATH", RBASH_STATIC_PATH_VALUE, 0); stupidly_hack_special_variables ("PATH"); /* clear hash table */ #endif set_var_read_only ("PATH"); diff --git a/subst.c b/subst.c index 65e7d085..998b850a 100644 --- a/subst.c +++ b/subst.c @@ -10863,11 +10863,12 @@ expand_word_list_internal (list, eflags) tint = do_word_assignment (temp_list->word, 0); this_command_name = savecmd; /* Variable assignment errors in non-interactive shells - running in Posix.2 mode cause the shell to exit. */ + running in Posix.2 mode cause the shell to exit, unless + they are being run by the `command' builtin. */ if (tint == 0) { last_command_exit_value = EXECUTION_FAILURE; - if (interactive_shell == 0 && posixly_correct) + if (interactive_shell == 0 && posixly_correct && executing_command_builtin == 0) exp_jump_to_top_level (FORCE_EOF); else exp_jump_to_top_level (DISCARD); diff --git a/tests/RUN-ONE-TEST b/tests/RUN-ONE-TEST index 554f3d6e..58c375b7 100755 --- a/tests/RUN-ONE-TEST +++ b/tests/RUN-ONE-TEST @@ -1,4 +1,4 @@ -BUILD_DIR=/usr/local/build/bash/bash-current +BUILD_DIR=/usr/local/build/chet/bash/bash-current THIS_SH=$BUILD_DIR/bash PATH=$PATH:$BUILD_DIR