From 514049fa8e2404e9159d27e9b52f413b987c82e1 Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Wed, 22 Feb 2017 11:10:10 -0500 Subject: [PATCH] commit bash-20170217 snapshot --- CWRU/CWRU.chlog | 58 +++++++++ MANIFEST | 1 + config-top.h | 4 + doc/bash.1 | 4 +- jobs.c | 11 ++ lib/readline/bind.c | 252 +++++++++++------------------------- lib/readline/callback.c | 20 ++- lib/readline/colors.c | 5 +- lib/readline/compat.c | 29 ++--- lib/readline/funmap.c | 10 +- lib/readline/input.c | 49 +++---- lib/readline/isearch.c | 42 ++---- lib/readline/keymaps.c | 15 +-- lib/readline/macro.c | 35 ++--- lib/readline/mbutil.c | 50 ++----- lib/readline/misc.c | 74 +++++------ lib/readline/nls.c | 19 +-- lib/readline/parens.c | 15 +-- lib/readline/parse-colors.c | 6 +- lib/readline/rltty.c | 101 +++++---------- lib/readline/savestring.c | 5 +- lib/readline/search.c | 69 +++------- lib/readline/shell.c | 16 +-- lib/readline/signals.c | 55 +++----- lib/readline/terminal.c | 69 ++++------ lib/readline/text.c | 172 ++++++++---------------- lib/readline/undo.c | 41 ++---- lib/readline/util.c | 63 ++++----- lib/readline/xfree.c | 5 +- shell.c | 1 + subst.c | 61 +++++++-- tests/dollar-at-star | 5 + tests/dollar-at-star4.sub | 2 + tests/dollar-star8.sub | 21 +++ tests/dollar.right | 32 +++++ tests/exp.right | 6 +- variables.c | 9 +- 37 files changed, 604 insertions(+), 828 deletions(-) create mode 100644 tests/dollar-star8.sub diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 5ab464ec..4d2164a4 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -13165,3 +13165,61 @@ parse.y to the values in tflags when calling shell_getc. Fixes bug reported by Michael Homer , patch was originally contributed by Geir Hauge + + 2/15 + ---- +jobs.c + - bgp_add: if hashed pid collides with bgpids.head index, print a + warning and move to the next index. Attempt to avoid collision + problem reported by Graham Northup + + 2/17 + ---- +subst.c + - process_substitute: call remove_quoted_escapes on the command string + like command substitution does, since the string will be run through + the parser again. Fixes bug reported by David Simmons + + +config-top.h + - STATIC_PATH_VALUE: new config variable, undefined by default + +variables.c + - shell_initialize: if STATIC_PATH_VALUE is defined, use it to set the + PATH variable at shell startup, overriding the environment and any + value for DEFAULT_PATH_VALUE. Based on a suggestion from + Lonnie Abelbeck + + 2/18 + ---- +shell.c + - maybe_make_restricted: clear the hash table before making the PATH + variable read-only by calling stupidly_hack_special_variables. + Suggestion from Lonnie Abelbeck + +subst.c + - expand_string_for_pat: change expansion of WORD in ${param[%[%]][#[#]]word} + to use this new function, initially identical to + expand_string_for_rhs + - getpattern: use expand_string_for_pat to expand the pattern + + 2/19 + ---- +subst.c + - expand_string_for_rhs: now that this is only use to expand the RHS + of the various non-pattern ${paramOPword} expansions, set + expand_no_split_dollar_star depending on whether or not the entire + brace expansion is going to be subjected to word splitting: if it's + quoted or if IFS is set but null, we will not be splitting so we set + this to 1 and let $* expand to separate fields separated by a space. + This was heavily debated back in October 2014 and resulted in Posix + interp 888. Reported by Martijn Dekker + + 2/20 + ---- +subst.c + - expand_string_for_rhs: now takes `op' (brace expansion operator) as + an additional argument; changed call in parameter_brace_expand_rhs + - expand_string_for_rhs: make sure to set expand_no_split_dollar_star + if `op' is `=', since we are supposed to preserve the assignment + statement expansion semantics on the RHS of ${param=word} diff --git a/MANIFEST b/MANIFEST index 455a593b..a7c373a5 100644 --- a/MANIFEST +++ b/MANIFEST @@ -950,6 +950,7 @@ tests/dollar-star4.sub f tests/dollar-star5.sub f tests/dollar-star6.sub f tests/dollar-star7.sub f +tests/dollar-star8.sub f tests/dollar.right f tests/dstack.tests f tests/dstack.right f diff --git a/config-top.h b/config-top.h index 8f02d9c8..0f5e4c9e 100644 --- a/config-top.h +++ b/config-top.h @@ -66,6 +66,10 @@ "/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:." #endif +/* If you want to unconditionally set a value for PATH in every shell, set + this. You could use this for a restricted shell, for example. */ +/* #define STATIC_PATH_VALUE "/rbin:/usr/rbin" */ + /* The value for PATH when invoking `command -p'. This is only used when the Posix.2 confstr () function, or CS_PATH define are not present. */ #ifndef STANDARD_UTILS_PATH diff --git a/doc/bash.1 b/doc/bash.1 index e34e94f4..644ec502 100644 --- a/doc/bash.1 +++ b/doc/bash.1 @@ -68,8 +68,8 @@ Shell and Utilities portion of the IEEE POSIX specification can be configured to be POSIX-conformant by default. .SH OPTIONS All of the single-character shell options documented in the -description of the \fBset\fR builtin command can be used as options -when the shell is invoked. +description of the \fBset\fR builtin command, including \fB\-o\fP, +can be used as options when the shell is invoked. In addition, \fBbash\fR interprets the following options when it is invoked: .PP diff --git a/jobs.c b/jobs.c index dfc4b25e..4050835f 100644 --- a/jobs.c +++ b/jobs.c @@ -797,6 +797,17 @@ bgp_add (pid, status) bucket = pshash_getbucket (pid); psi = bgp_getindex (); + + /* XXX - what if psi == *bucket? */ + if (psi == *bucket) + { +#ifdef DEBUG + internal_warning ("hashed pid %d (pid %d) collides with bgpids.head, skipping", psi, pid); +#endif + bgpids.storage[psi].pid = NO_PID; /* make sure */ + psi = bgp_getindex (); /* skip to next one */ + } + ps = &bgpids.storage[psi]; ps->pid = pid; diff --git a/lib/readline/bind.c b/lib/readline/bind.c index f1098c48..4fa9e622 100644 --- a/lib/readline/bind.c +++ b/lib/readline/bind.c @@ -1,6 +1,6 @@ /* bind.c -- key binding and startup file support for the readline library. */ -/* 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. @@ -105,10 +105,7 @@ static int _rl_prefer_visible_bell = 1; Add NAME to the list of named functions. Make FUNCTION be the function that gets called. If KEY is not -1, then bind it. */ int -rl_add_defun (name, function, key) - const char *name; - rl_command_func_t *function; - int key; +rl_add_defun (const char *name, rl_command_func_t *function, int key) { if (key != -1) rl_bind_key (key, function); @@ -118,9 +115,7 @@ rl_add_defun (name, function, key) /* Bind KEY to FUNCTION. Returns non-zero if KEY is out of range. */ int -rl_bind_key (key, function) - int key; - rl_command_func_t *function; +rl_bind_key (int key, rl_command_func_t *function) { char keyseq[3]; int l; @@ -168,10 +163,7 @@ rl_bind_key (key, function) /* Bind KEY to FUNCTION in MAP. Returns non-zero in case of invalid KEY. */ int -rl_bind_key_in_map (key, function, map) - int key; - rl_command_func_t *function; - Keymap map; +rl_bind_key_in_map (int key, rl_command_func_t *function, Keymap map) { int result; Keymap oldmap; @@ -187,10 +179,7 @@ rl_bind_key_in_map (key, function, map) now, this is always used to attempt to bind the arrow keys, hence the check for rl_vi_movement_mode. */ int -rl_bind_key_if_unbound_in_map (key, default_func, kmap) - int key; - rl_command_func_t *default_func; - Keymap kmap; +rl_bind_key_if_unbound_in_map (int key, rl_command_func_t *default_func, Keymap kmap) { char keyseq[2]; @@ -200,9 +189,7 @@ rl_bind_key_if_unbound_in_map (key, default_func, kmap) } int -rl_bind_key_if_unbound (key, default_func) - int key; - rl_command_func_t *default_func; +rl_bind_key_if_unbound (int key, rl_command_func_t *default_func) { char keyseq[2]; @@ -214,8 +201,7 @@ rl_bind_key_if_unbound (key, default_func) /* Make KEY do nothing in the currently selected keymap. Returns non-zero in case of error. */ int -rl_unbind_key (key) - int key; +rl_unbind_key (int key) { return (rl_bind_key (key, (rl_command_func_t *)NULL)); } @@ -223,18 +209,14 @@ rl_unbind_key (key) /* Make KEY do nothing in MAP. Returns non-zero in case of error. */ int -rl_unbind_key_in_map (key, map) - int key; - Keymap map; +rl_unbind_key_in_map (int key, Keymap map) { return (rl_bind_key_in_map (key, (rl_command_func_t *)NULL, map)); } /* Unbind all keys bound to FUNCTION in MAP. */ int -rl_unbind_function_in_map (func, map) - rl_command_func_t *func; - Keymap map; +rl_unbind_function_in_map (rl_command_func_t *func, Keymap map) { register int i, rval; @@ -250,9 +232,7 @@ rl_unbind_function_in_map (func, map) } int -rl_unbind_command_in_map (command, map) - const char *command; - Keymap map; +rl_unbind_command_in_map (const char *command, Keymap map) { rl_command_func_t *func; @@ -266,9 +246,7 @@ rl_unbind_command_in_map (command, map) FUNCTION, starting in the current keymap. This makes new keymaps as necessary. */ int -rl_bind_keyseq (keyseq, function) - const char *keyseq; - rl_command_func_t *function; +rl_bind_keyseq (const char *keyseq, rl_command_func_t *function) { return (rl_generic_bind (ISFUNC, keyseq, (char *)function, _rl_keymap)); } @@ -277,20 +255,14 @@ rl_bind_keyseq (keyseq, function) FUNCTION. This makes new keymaps as necessary. The initial place to do bindings is in MAP. */ int -rl_bind_keyseq_in_map (keyseq, function, map) - const char *keyseq; - rl_command_func_t *function; - Keymap map; +rl_bind_keyseq_in_map (const char *keyseq, rl_command_func_t *function, Keymap map) { return (rl_generic_bind (ISFUNC, keyseq, (char *)function, map)); } /* Backwards compatibility; equivalent to rl_bind_keyseq_in_map() */ int -rl_set_key (keyseq, function, map) - const char *keyseq; - rl_command_func_t *function; - Keymap map; +rl_set_key (const char *keyseq, rl_command_func_t *function, Keymap map) { return (rl_generic_bind (ISFUNC, keyseq, (char *)function, map)); } @@ -299,10 +271,7 @@ rl_set_key (keyseq, function, map) now, this is always used to attempt to bind the arrow keys, hence the check for rl_vi_movement_mode. */ int -rl_bind_keyseq_if_unbound_in_map (keyseq, default_func, kmap) - const char *keyseq; - rl_command_func_t *default_func; - Keymap kmap; +rl_bind_keyseq_if_unbound_in_map (const char *keyseq, rl_command_func_t *default_func, Keymap kmap) { rl_command_func_t *func; @@ -322,9 +291,7 @@ rl_bind_keyseq_if_unbound_in_map (keyseq, default_func, kmap) } int -rl_bind_keyseq_if_unbound (keyseq, default_func) - const char *keyseq; - rl_command_func_t *default_func; +rl_bind_keyseq_if_unbound (const char *keyseq, rl_command_func_t *default_func) { return (rl_bind_keyseq_if_unbound_in_map (keyseq, default_func, _rl_keymap)); } @@ -333,9 +300,7 @@ rl_bind_keyseq_if_unbound (keyseq, default_func) the string of characters MACRO. This makes new keymaps as necessary. The initial place to do bindings is in MAP. */ int -rl_macro_bind (keyseq, macro, map) - const char *keyseq, *macro; - Keymap map; +rl_macro_bind (const char *keyseq, const char *macro, Keymap map) { char *macro_keys; int macro_keys_len; @@ -357,11 +322,7 @@ rl_macro_bind (keyseq, macro, map) a macro (ISMACR), or a keymap (ISKMAP). This makes new keymaps as necessary. The initial place to do bindings is in MAP. */ int -rl_generic_bind (type, keyseq, data, map) - int type; - const char *keyseq; - char *data; - Keymap map; +rl_generic_bind (int type, const char *keyseq, char *data, Keymap map) { char *keys; int keys_len; @@ -469,10 +430,7 @@ rl_generic_bind (type, keyseq, data, map) an array of characters. LEN gets the final length of ARRAY. Return non-zero if there was an error parsing SEQ. */ int -rl_translate_keyseq (seq, array, len) - const char *seq; - char *array; - int *len; +rl_translate_keyseq (const char *seq, char *array, int *len) { register int i, c, l, temp; @@ -596,8 +554,7 @@ rl_translate_keyseq (seq, array, len) } static int -_rl_isescape (c) - int c; +_rl_isescape (int c) { switch (c) { @@ -613,8 +570,7 @@ _rl_isescape (c) } static int -_rl_escchar (c) - int c; +_rl_escchar (int c) { switch (c) { @@ -630,8 +586,7 @@ _rl_escchar (c) } char * -rl_untranslate_keyseq (seq) - int seq; +rl_untranslate_keyseq (int seq) { static char kseq[16]; int i, c; @@ -681,9 +636,7 @@ rl_untranslate_keyseq (seq) } char * -_rl_untranslate_macro_value (seq, use_escapes) - char *seq; - int use_escapes; +_rl_untranslate_macro_value (char *seq, int use_escapes) { char *ret, *r, *s; int c; @@ -742,8 +695,7 @@ _rl_untranslate_macro_value (seq, use_escapes) If STRING doesn't have a matching function, then a NULL pointer is returned. */ rl_command_func_t * -rl_named_function (string) - const char *string; +rl_named_function (const char *string) { register int i; @@ -761,10 +713,7 @@ rl_named_function (string) type of the object pointed to. One of ISFUNC (function), ISKMAP (keymap), or ISMACR (macro). */ rl_command_func_t * -rl_function_of_keyseq (keyseq, map, type) - const char *keyseq; - Keymap map; - int *type; +rl_function_of_keyseq (const char *keyseq, Keymap map, int *type) { register int i; @@ -835,9 +784,7 @@ static int current_readline_init_lineno; The size of the buffer is returned in *SIZEP. Returns NULL if any errors were encountered. */ static char * -_rl_read_file (filename, sizep) - char *filename; - size_t *sizep; +_rl_read_file (char *filename, size_t *sizep) { struct stat finfo; size_t file_size; @@ -882,8 +829,7 @@ _rl_read_file (filename, sizep) /* Re-read the current keybindings file. */ int -rl_re_read_init_file (count, ignore) - int count, ignore; +rl_re_read_init_file (int count, int ignore) { int r; r = rl_read_init_file ((const char *)NULL); @@ -900,8 +846,7 @@ rl_re_read_init_file (count, ignore) If the file existed and could be opened and read, 0 is returned, otherwise errno is returned. */ int -rl_read_init_file (filename) - const char *filename; +rl_read_init_file (const char *filename) { /* Default the filename. */ if (filename == 0) @@ -926,9 +871,7 @@ rl_read_init_file (filename) } static int -_rl_read_init_file (filename, include_level) - const char *filename; - int include_level; +_rl_read_init_file (const char *filename, int include_level) { register int i; char *buffer, *openname, *line, *end; @@ -1055,8 +998,7 @@ static int if_stack_size; /* Push _rl_parsing_conditionalized_out, and set parser state based on ARGS. */ static int -parser_if (args) - char *args; +parser_if (char *args) { register int i; @@ -1128,8 +1070,7 @@ parser_if (args) /* Invert the current parser state if there is anything on the stack. */ static int -parser_else (args) - char *args; +parser_else (char *args) { register int i; @@ -1159,8 +1100,7 @@ parser_else (args) /* Terminate a conditional, popping the value of _rl_parsing_conditionalized_out from the stack. */ static int -parser_endif (args) - char *args; +parser_endif (char *args) { if (if_stack_depth) _rl_parsing_conditionalized_out = if_stack[--if_stack_depth]; @@ -1170,8 +1110,7 @@ parser_endif (args) } static int -parser_include (args) - char *args; +parser_include (char *args) { const char *old_init_file; char *e; @@ -1211,8 +1150,7 @@ static const struct { /* Handle a parser directive. STATEMENT is the line of the directive without any leading `$'. */ static int -handle_parser_directive (statement) - char *statement; +handle_parser_directive (char *statement) { register int i; char *directive, *args; @@ -1249,9 +1187,7 @@ handle_parser_directive (statement) /* Start at STRING[START] and look for DELIM. Return I where STRING[I] == DELIM or STRING[I] == 0. DELIM is usually a double quote. */ static int -_rl_skip_to_delim (string, start, delim) - char *string; - int start, delim; +_rl_skip_to_delim (char *string, int start, int delim) { int i, c, passc; @@ -1283,8 +1219,7 @@ _rl_skip_to_delim (string, start, delim) a variable binding command looks like: set variable value. A new-style keybinding looks like "\C-x\C-x": exchange-point-and-mark. */ int -rl_parse_and_bind (string) - char *string; +rl_parse_and_bind (char *string) { char *funname, *kname; register int c, i; @@ -1583,8 +1518,7 @@ static const struct { }; static int -find_boolean_var (name) - const char *name; +find_boolean_var (const char *name) { register int i; @@ -1598,8 +1532,7 @@ find_boolean_var (name) function needs to be called or another variable needs to be changed when they're changed. */ static void -hack_special_boolean_var (i) - int i; +hack_special_boolean_var (int i) { const char *name; @@ -1668,8 +1601,7 @@ static const struct { }; static int -find_string_var (name) - const char *name; +find_string_var (const char *name) { register int i; @@ -1683,8 +1615,7 @@ find_string_var (name) the value is null or empty, `on' (case-insensitive), or "1". Any other values result in 0 (false). */ static int -bool_to_int (value) - const char *value; +bool_to_int (const char *value) { return (value == 0 || *value == '\0' || (_rl_stricmp (value, "on") == 0) || @@ -1692,8 +1623,7 @@ bool_to_int (value) } char * -rl_variable_value (name) - const char *name; +rl_variable_value (const char *name) { register int i; @@ -1711,8 +1641,7 @@ rl_variable_value (name) } int -rl_variable_bind (name, value) - const char *name, *value; +rl_variable_bind (const char *name, const char *value) { register int i; int v; @@ -1743,8 +1672,7 @@ rl_variable_bind (name, value) } static int -sv_editmode (value) - const char *value; +sv_editmode (const char *value) { if (_rl_strnicmp (value, "vi", 2) == 0) { @@ -1764,8 +1692,7 @@ sv_editmode (value) } static int -sv_combegin (value) - const char *value; +sv_combegin (const char *value) { if (value && *value) { @@ -1777,8 +1704,7 @@ sv_combegin (value) } static int -sv_dispprefix (value) - const char *value; +sv_dispprefix (const char *value) { int nval = 0; @@ -1793,8 +1719,7 @@ sv_dispprefix (value) } static int -sv_compquery (value) - const char *value; +sv_compquery (const char *value) { int nval = 100; @@ -1809,8 +1734,7 @@ sv_compquery (value) } static int -sv_compwidth (value) - const char *value; +sv_compwidth (const char *value) { int nval = -1; @@ -1822,8 +1746,7 @@ sv_compwidth (value) } static int -sv_histsize (value) - const char *value; +sv_histsize (const char *value) { int nval; @@ -1842,8 +1765,7 @@ sv_histsize (value) } static int -sv_keymap (value) - const char *value; +sv_keymap (const char *value) { Keymap kmap; @@ -1857,8 +1779,7 @@ sv_keymap (value) } static int -sv_seqtimeout (value) - const char *value; +sv_seqtimeout (const char *value) { int nval; @@ -1874,8 +1795,7 @@ sv_seqtimeout (value) } static int -sv_bell_style (value) - const char *value; +sv_bell_style (const char *value) { if (value == 0 || *value == '\0') _rl_bell_preference = AUDIBLE_BELL; @@ -1891,8 +1811,7 @@ sv_bell_style (value) } static int -sv_isrchterm (value) - const char *value; +sv_isrchterm (const char *value) { int beg, end, delim; char *v; @@ -1929,8 +1848,7 @@ sv_isrchterm (value) extern char *_rl_emacs_mode_str; static int -sv_emacs_modestr (value) - const char *value; +sv_emacs_modestr (const char *value) { if (value && *value) { @@ -1958,8 +1876,7 @@ sv_emacs_modestr (value) } static int -sv_viins_modestr (value) - const char *value; +sv_viins_modestr (const char *value) { if (value && *value) { @@ -1987,8 +1904,7 @@ sv_viins_modestr (value) } static int -sv_vicmd_modestr (value) - const char *value; +sv_vicmd_modestr (const char *value) { if (value && *value) { @@ -2039,8 +1955,7 @@ static const assoc_list name_key_alist[] = { }; static int -glean_key_from_name (name) - char *name; +glean_key_from_name (char *name) { register int i; @@ -2070,8 +1985,7 @@ static const struct { }; Keymap -rl_get_keymap_by_name (name) - const char *name; +rl_get_keymap_by_name (const char *name) { register int i; @@ -2082,8 +1996,7 @@ rl_get_keymap_by_name (name) } char * -rl_get_keymap_name (map) - Keymap map; +rl_get_keymap_name (Keymap map) { register int i; for (i = 0; keymap_names[i].name; i++) @@ -2093,21 +2006,20 @@ rl_get_keymap_name (map) } void -rl_set_keymap (map) - Keymap map; +rl_set_keymap (Keymap map) { if (map) _rl_keymap = map; } Keymap -rl_get_keymap () +rl_get_keymap (void) { return (_rl_keymap); } void -rl_set_keymap_from_edit_mode () +rl_set_keymap_from_edit_mode (void) { if (rl_editing_mode == emacs_mode) _rl_keymap = emacs_standard_keymap; @@ -2118,7 +2030,7 @@ rl_set_keymap_from_edit_mode () } char * -rl_get_keymap_name_from_edit_mode () +rl_get_keymap_name_from_edit_mode (void) { if (rl_editing_mode == emacs_mode) return "emacs"; @@ -2143,7 +2055,7 @@ rl_get_keymap_name_from_edit_mode () /* Print the names of functions known to Readline. */ void -rl_list_funmap_names () +rl_list_funmap_names (void) { register int i; const char **funmap_names; @@ -2160,8 +2072,7 @@ rl_list_funmap_names () } static char * -_rl_get_keyname (key) - int key; +_rl_get_keyname (int key) { char *keyname; int i, c; @@ -2236,9 +2147,7 @@ _rl_get_keyname (key) /* Return a NULL terminated array of strings which represent the key sequences that are used to invoke FUNCTION in MAP. */ char ** -rl_invoking_keyseqs_in_map (function, map) - rl_command_func_t *function; - Keymap map; +rl_invoking_keyseqs_in_map (rl_command_func_t *function, Keymap map) { register int key; char **result; @@ -2345,8 +2254,7 @@ rl_invoking_keyseqs_in_map (function, map) /* Return a NULL terminated array of strings which represent the key sequences that can be used to invoke FUNCTION using the current keymap. */ char ** -rl_invoking_keyseqs (function) - rl_command_func_t *function; +rl_invoking_keyseqs (rl_command_func_t *function) { return (rl_invoking_keyseqs_in_map (function, _rl_keymap)); } @@ -2355,8 +2263,7 @@ rl_invoking_keyseqs (function) PRINT_READABLY is non-zero, then print the output in such a way that it can be read back in. */ void -rl_function_dumper (print_readably) - int print_readably; +rl_function_dumper (int print_readably) { register int i; const char **names; @@ -2427,8 +2334,7 @@ rl_function_dumper (print_readably) rl_outstream. If an explicit argument is given, then print the output in such a way that it can be read back in. */ int -rl_dump_functions (count, key) - int count, key; +rl_dump_functions (int count, int key) { if (rl_dispatching) fprintf (rl_outstream, "\r\n"); @@ -2438,10 +2344,7 @@ rl_dump_functions (count, key) } static void -_rl_macro_dumper_internal (print_readably, map, prefix) - int print_readably; - Keymap map; - char *prefix; +_rl_macro_dumper_internal (int print_readably, Keymap map, char *prefix) { register int key; char *keyname, *out; @@ -2500,15 +2403,13 @@ _rl_macro_dumper_internal (print_readably, map, prefix) } void -rl_macro_dumper (print_readably) - int print_readably; +rl_macro_dumper (int print_readably) { _rl_macro_dumper_internal (print_readably, _rl_keymap, (char *)NULL); } int -rl_dump_macros (count, key) - int count, key; +rl_dump_macros (int count, int key) { if (rl_dispatching) fprintf (rl_outstream, "\r\n"); @@ -2518,8 +2419,7 @@ rl_dump_macros (count, key) } static char * -_rl_get_string_variable_value (name) - const char *name; +_rl_get_string_variable_value (const char *name) { static char numbuf[32]; char *ret; @@ -2599,8 +2499,7 @@ _rl_get_string_variable_value (name) } void -rl_variable_dumper (print_readably) - int print_readably; +rl_variable_dumper (int print_readably) { int i; char *v; @@ -2631,8 +2530,7 @@ rl_variable_dumper (print_readably) rl_outstream. If an explicit argument is given, then print the output in such a way that it can be read back in. */ int -rl_dump_variables (count, key) - int count, key; +rl_dump_variables (int count, int key) { if (rl_dispatching) fprintf (rl_outstream, "\r\n"); @@ -2643,9 +2541,7 @@ rl_dump_variables (count, key) /* Return non-zero if any members of ARRAY are a substring in STRING. */ static int -substring_member_of_array (string, array) - const char *string; - const char * const *array; +substring_member_of_array (const char *string, const char * const *array) { while (*array) { diff --git a/lib/readline/callback.c b/lib/readline/callback.c index cc3ce11f..359bbb96 100644 --- a/lib/readline/callback.c +++ b/lib/readline/callback.c @@ -1,6 +1,6 @@ /* callback.c -- functions to use readline as an X `callback' mechanism. */ -/* 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. @@ -80,7 +80,7 @@ static int in_handler; /* terminal_prepped and signals set? */ /* Make sure the terminal is set up, initialize readline, and prompt. */ static void -_rl_callback_newline () +_rl_callback_newline (void) { rl_initialize (); @@ -103,9 +103,7 @@ _rl_callback_newline () /* Install a readline handler, set up the terminal, and issue the prompt. */ void -rl_callback_handler_install (prompt, linefunc) - const char *prompt; - rl_vcpfunc_t *linefunc; +rl_callback_handler_install (const char *prompt, rl_vcpfunc_t *linefunc) { rl_set_prompt (prompt); RL_SETSTATE (RL_STATE_CALLBACK); @@ -126,7 +124,7 @@ rl_callback_handler_install (prompt, linefunc) /* Read one character, and dispatch to the handler if it ends the line. */ void -rl_callback_read_char () +rl_callback_read_char (void) { char *line; int eof, jcode; @@ -299,7 +297,7 @@ rl_callback_read_char () /* Remove the handler, and make sure the terminal is in its normal state. */ void -rl_callback_handler_remove () +rl_callback_handler_remove (void) { rl_linefunc = NULL; RL_UNSETSTATE (RL_STATE_CALLBACK); @@ -316,8 +314,7 @@ rl_callback_handler_remove () } _rl_callback_generic_arg * -_rl_callback_data_alloc (count) - int count; +_rl_callback_data_alloc (int count) { _rl_callback_generic_arg *arg; @@ -330,15 +327,14 @@ _rl_callback_data_alloc (count) } void -_rl_callback_data_dispose (arg) - _rl_callback_generic_arg *arg; +_rl_callback_data_dispose (_rl_callback_generic_arg *arg) { xfree (arg); } /* Make sure that this agrees with cases in rl_callback_read_char */ void -rl_callback_sigcleanup () +rl_callback_sigcleanup (void) { if (RL_ISSTATE (RL_STATE_CALLBACK) == 0) return; diff --git a/lib/readline/colors.c b/lib/readline/colors.c index 5d450ee0..53758e0e 100644 --- a/lib/readline/colors.c +++ b/lib/readline/colors.c @@ -2,7 +2,7 @@ Modified by Chet Ramey for Readline. - Copyright (C) 1985, 1988, 1990-1991, 1995-2010, 2012, 2015 + Copyright (C) 1985, 1988, 1990-1991, 1995-2010, 2012, 2015, 2017 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -70,7 +70,8 @@ COLOR_EXT_TYPE *_rl_color_ext_list = 0; /* Output a color indicator (which may contain nulls). */ void -_rl_put_indicator (const struct bin_str *ind) { +_rl_put_indicator (const struct bin_str *ind) +{ fwrite (ind->string, ind->len, 1, rl_outstream); } diff --git a/lib/readline/compat.c b/lib/readline/compat.c index 2af51207..3ade3629 100644 --- a/lib/readline/compat.c +++ b/lib/readline/compat.c @@ -1,6 +1,6 @@ /* compat.c -- backwards compatibility functions. */ -/* Copyright (C) 2000-2009 Free Software Foundation, Inc. +/* Copyright (C) 2000-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. @@ -46,68 +46,61 @@ extern char *rl_filename_completion_function PARAMS((const char *, int)); /* Provide backwards-compatible entry points for old function names. */ void -free_undo_list () +free_undo_list (void) { rl_free_undo_list (); } int -maybe_replace_line () +maybe_replace_line (void) { return rl_maybe_replace_line (); } int -maybe_save_line () +maybe_save_line (void) { return rl_maybe_save_line (); } int -maybe_unsave_line () +maybe_unsave_line (void) { return rl_maybe_unsave_line (); } int -ding () +ding (void) { return rl_ding (); } int -crlf () +crlf (void) { return rl_crlf (); } int -alphabetic (c) - int c; +alphabetic (int c) { return rl_alphabetic (c); } char ** -completion_matches (s, f) - const char *s; - rl_compentry_func_t *f; +completion_matches (const char *s, rl_compentry_func_t *f) { return rl_completion_matches (s, f); } char * -username_completion_function (s, i) - const char *s; - int i; +username_completion_function (const char *s, int i) { return rl_username_completion_function (s, i); } char * -filename_completion_function (s, i) - const char *s; - int i; +filename_completion_function (const char *s, int i) { return rl_filename_completion_function (s, i); } diff --git a/lib/readline/funmap.c b/lib/readline/funmap.c index 748d92d3..aaf144de 100644 --- a/lib/readline/funmap.c +++ b/lib/readline/funmap.c @@ -1,6 +1,6 @@ /* funmap.c -- attach names to functions. */ -/* 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. @@ -206,9 +206,7 @@ static const FUNMAP default_funmap[] = { }; int -rl_add_funmap_entry (name, function) - const char *name; - rl_command_func_t *function; +rl_add_funmap_entry (const char *name, rl_command_func_t *function) { if (funmap_entry + 2 >= funmap_size) { @@ -228,7 +226,7 @@ static int funmap_initialized; /* Make the funmap contain all of the default entries. */ void -rl_initialize_funmap () +rl_initialize_funmap (void) { register int i; @@ -246,7 +244,7 @@ rl_initialize_funmap () is sorted. The array itself is allocated, but not the strings inside. You should free () the array when you done, but not the pointers. */ const char ** -rl_funmap_names () +rl_funmap_names (void) { const char **result; int result_size, result_index; diff --git a/lib/readline/input.c b/lib/readline/input.c index 0ac642b1..8c66137d 100644 --- a/lib/readline/input.c +++ b/lib/readline/input.c @@ -1,6 +1,6 @@ /* input.c -- character input functions for readline. */ -/* 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. @@ -128,13 +128,13 @@ static int ibuffer_len = sizeof (ibuffer) - 1; #define any_typein (push_index != pop_index) int -_rl_any_typein () +_rl_any_typein (void) { return any_typein; } int -_rl_pushed_input_available () +_rl_pushed_input_available (void) { return (push_index != pop_index); } @@ -142,7 +142,7 @@ _rl_pushed_input_available () /* Return the amount of space available in the buffer for stuffing characters. */ static int -ibuffer_space () +ibuffer_space (void) { if (pop_index > push_index) return (pop_index - push_index - 1); @@ -154,8 +154,7 @@ ibuffer_space () Return the key in KEY. Result is non-zero if there was a key, or 0 if there wasn't. */ static int -rl_get_char (key) - int *key; +rl_get_char (int *key) { if (push_index == pop_index) return (0); @@ -175,8 +174,7 @@ rl_get_char (key) Returns non-zero if successful, zero if there is no space left in the buffer. */ int -_rl_unget_char (key) - int key; +_rl_unget_char (int key) { if (ibuffer_space ()) { @@ -193,7 +191,7 @@ _rl_unget_char (key) IBUFFER. Otherwise, just return. Returns number of characters read (0 if none available) and -1 on error (EIO). */ static int -rl_gather_tyi () +rl_gather_tyi (void) { int tty; register int tem, result; @@ -296,8 +294,7 @@ rl_gather_tyi () } int -rl_set_keyboard_input_timeout (u) - int u; +rl_set_keyboard_input_timeout (int u) { int o; @@ -314,7 +311,7 @@ rl_set_keyboard_input_timeout (u) the user, it should use _rl_input_queued(timeout_value_in_microseconds) instead. */ int -_rl_input_available () +_rl_input_available (void) { #if defined(HAVE_SELECT) fd_set readfds, exceptfds; @@ -356,8 +353,7 @@ _rl_input_available () } int -_rl_input_queued (t) - int t; +_rl_input_queued (int t) { int old_timeout, r; @@ -368,8 +364,7 @@ _rl_input_queued (t) } void -_rl_insert_typein (c) - int c; +_rl_insert_typein (int c) { int key, t, i; char *string; @@ -394,8 +389,7 @@ _rl_insert_typein (c) /* Add KEY to the buffer of characters to be read. Returns 1 if the character was stuffed correctly; 0 otherwise. */ int -rl_stuff_char (key) - int key; +rl_stuff_char (int key) { if (ibuffer_space () == 0) return 0; @@ -419,8 +413,7 @@ rl_stuff_char (key) /* Make C be the next command to be executed. */ int -rl_execute_next (c) - int c; +rl_execute_next (int c) { rl_pending_input = c; RL_SETSTATE (RL_STATE_INPUTPENDING); @@ -429,7 +422,7 @@ rl_execute_next (c) /* Clear any pending input pushed with rl_execute_next() */ int -rl_clear_pending_input () +rl_clear_pending_input (void) { rl_pending_input = 0; RL_UNSETSTATE (RL_STATE_INPUTPENDING); @@ -444,7 +437,7 @@ rl_clear_pending_input () /* Read a key, including pending input. */ int -rl_read_key () +rl_read_key (void) { int c, r; @@ -494,8 +487,7 @@ rl_read_key () } int -rl_getc (stream) - FILE *stream; +rl_getc (FILE *stream) { int result; unsigned char c; @@ -611,9 +603,7 @@ handle_error: #if defined (HANDLE_MULTIBYTE) /* read multibyte char */ int -_rl_read_mbchar (mbchar, size) - char *mbchar; - int size; +_rl_read_mbchar (char *mbchar, int size) { int mb_len, c; size_t mbchar_bytes_length; @@ -662,10 +652,7 @@ _rl_read_mbchar (mbchar, size) may be FIRST. Used by the search functions, among others. Very similar to _rl_read_mbchar. */ int -_rl_read_mbstring (first, mb, mlen) - int first; - char *mb; - int mlen; +_rl_read_mbstring (int first, char *mb, int mlen) { int i, c; mbstate_t ps; diff --git a/lib/readline/isearch.c b/lib/readline/isearch.c index 819fcbce..10419cdb 100644 --- a/lib/readline/isearch.c +++ b/lib/readline/isearch.c @@ -6,7 +6,7 @@ /* */ /* **************************************************************** */ -/* 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. @@ -78,8 +78,7 @@ static int last_isearch_string_len; static char * const default_isearch_terminators = "\033\012"; _rl_search_cxt * -_rl_scxt_alloc (type, flags) - int type, flags; +_rl_scxt_alloc (int type, int flags) { _rl_search_cxt *cxt; @@ -120,9 +119,7 @@ _rl_scxt_alloc (type, flags) } void -_rl_scxt_dispose (cxt, flags) - _rl_search_cxt *cxt; - int flags; +_rl_scxt_dispose (_rl_search_cxt *cxt, int flags) { FREE (cxt->search_string); FREE (cxt->allocated_line); @@ -134,8 +131,7 @@ _rl_scxt_dispose (cxt, flags) /* Search backwards through the history looking for a string which is typed interactively. Start with the current line. */ int -rl_reverse_search_history (sign, key) - int sign, key; +rl_reverse_search_history (int sign, int key) { return (rl_search_history (-sign, key)); } @@ -143,8 +139,7 @@ rl_reverse_search_history (sign, key) /* Search forwards through the history looking for a string which is typed interactively. Start with the current line. */ int -rl_forward_search_history (sign, key) - int sign, key; +rl_forward_search_history (int sign, int key) { return (rl_search_history (sign, key)); } @@ -155,9 +150,7 @@ rl_forward_search_history (sign, key) WHERE is the history list number of the current line. If it is -1, then this line is the starting one. */ static void -rl_display_search (search_string, flags, where) - char *search_string; - int flags, where; +rl_display_search (char *search_string, int flags, int where) { char *message; int msglen, searchlen; @@ -206,8 +199,7 @@ rl_display_search (search_string, flags, where) } static _rl_search_cxt * -_rl_isearch_init (direction) - int direction; +_rl_isearch_init (int direction) { _rl_search_cxt *cxt; register int i; @@ -267,8 +259,7 @@ _rl_isearch_init (direction) } static void -_rl_isearch_fini (cxt) - _rl_search_cxt *cxt; +_rl_isearch_fini (_rl_search_cxt *cxt) { /* First put back the original state. */ strcpy (rl_line_buffer, cxt->lines[cxt->save_line]); @@ -306,8 +297,7 @@ _rl_isearch_fini (cxt) } int -_rl_search_getchar (cxt) - _rl_search_cxt *cxt; +_rl_search_getchar (_rl_search_cxt *cxt) { int c; @@ -334,9 +324,7 @@ _rl_search_getchar (cxt) -1 if the caller should just free the context and return, 0 if we should break out of the loop, and 1 if we should continue to read characters. */ int -_rl_isearch_dispatch (cxt, c) - _rl_search_cxt *cxt; - int c; +_rl_isearch_dispatch (_rl_search_cxt *cxt, int c) { int n, wstart, wlen, limit, cval; rl_command_func_t *f; @@ -734,9 +722,7 @@ add_character: } int -_rl_isearch_cleanup (cxt, r) - _rl_search_cxt *cxt; - int r; +_rl_isearch_cleanup (_rl_search_cxt *cxt, int r) { if (r >= 0) _rl_isearch_fini (cxt); @@ -753,8 +739,7 @@ _rl_isearch_cleanup (cxt, r) DIRECTION is which direction to search; >= 0 means forward, < 0 means backwards. */ static int -rl_search_history (direction, invoking_key) - int direction, invoking_key; +rl_search_history (int direction, int invoking_key) { _rl_search_cxt *cxt; /* local for now, but saved globally */ int c, r; @@ -792,8 +777,7 @@ rl_search_history (direction, invoking_key) If _rl_isearch_dispatch finishes searching, this function is responsible for turning off RL_STATE_ISEARCH, which it does using _rl_isearch_cleanup. */ int -_rl_isearch_callback (cxt) - _rl_search_cxt *cxt; +_rl_isearch_callback (_rl_search_cxt *cxt) { int c, r; diff --git a/lib/readline/keymaps.c b/lib/readline/keymaps.c index 58661e29..0400668b 100644 --- a/lib/readline/keymaps.c +++ b/lib/readline/keymaps.c @@ -1,6 +1,6 @@ /* keymaps.c -- Functions and keymaps for the GNU Readline library. */ -/* Copyright (C) 1988,1989-2009 Free Software Foundation, Inc. +/* Copyright (C) 1988,1989-2009,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. @@ -54,7 +54,7 @@ /* Return a new, empty keymap. Free it with free() when you are done. */ Keymap -rl_make_bare_keymap () +rl_make_bare_keymap (void) { register int i; Keymap keymap; @@ -80,8 +80,7 @@ rl_make_bare_keymap () /* Return a new keymap which is a copy of MAP. Just copies pointers, does not copy text of macros or descend into child keymaps. */ Keymap -rl_copy_keymap (map) - Keymap map; +rl_copy_keymap (Keymap map) { register int i; Keymap temp; @@ -99,7 +98,7 @@ rl_copy_keymap (map) the uppercase Meta characters bound to run their lowercase equivalents, and the Meta digits bound to produce numeric arguments. */ Keymap -rl_make_keymap () +rl_make_keymap (void) { register int i; Keymap newmap; @@ -125,8 +124,7 @@ rl_make_keymap () /* Free the storage associated with MAP. */ void -rl_discard_keymap (map) - Keymap map; +rl_discard_keymap (Keymap map) { int i; @@ -154,8 +152,7 @@ rl_discard_keymap (map) /* Convenience function that discards, then frees, MAP. */ void -rl_free_keymap (map) - Keymap map; +rl_free_keymap (Keymap map) { rl_discard_keymap (map); xfree ((char *)map); diff --git a/lib/readline/macro.c b/lib/readline/macro.c index 47525c79..92cc55c3 100644 --- a/lib/readline/macro.c +++ b/lib/readline/macro.c @@ -1,6 +1,6 @@ /* macro.c -- keyboard macros for readline. */ -/* Copyright (C) 1994-2009 Free Software Foundation, Inc. +/* Copyright (C) 1994-2009,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. @@ -90,8 +90,7 @@ static int macro_level = 0; /* Set up to read subsequent input from STRING. STRING is free ()'ed when we are done with it. */ void -_rl_with_macro_input (string) - char *string; +_rl_with_macro_input (char *string) { if (macro_level > MAX_MACRO_LEVEL) { @@ -112,7 +111,7 @@ _rl_with_macro_input (string) /* Return the next character available from a macro, or 0 if there are no macro characters. */ int -_rl_next_macro_key () +_rl_next_macro_key (void) { int c; @@ -138,7 +137,7 @@ _rl_next_macro_key () } int -_rl_peek_macro_key () +_rl_peek_macro_key (void) { if (rl_executing_macro == 0) return (0); @@ -150,7 +149,7 @@ _rl_peek_macro_key () } int -_rl_prev_macro_key () +_rl_prev_macro_key (void) { if (rl_executing_macro == 0) return (0); @@ -164,7 +163,7 @@ _rl_prev_macro_key () /* Save the currently executing macro on a stack of saved macros. */ void -_rl_push_executing_macro () +_rl_push_executing_macro (void) { struct saved_macro *saver; @@ -181,7 +180,7 @@ _rl_push_executing_macro () /* Discard the current macro, replacing it with the one on the top of the stack of saved macros. */ void -_rl_pop_executing_macro () +_rl_pop_executing_macro (void) { struct saved_macro *macro; @@ -206,8 +205,7 @@ _rl_pop_executing_macro () /* Add a character to the macro being built. */ void -_rl_add_macro_char (c) - int c; +_rl_add_macro_char (int c) { if (current_macro_index + 1 >= current_macro_size) { @@ -222,7 +220,7 @@ _rl_add_macro_char (c) } void -_rl_kill_kbd_macro () +_rl_kill_kbd_macro (void) { if (current_macro) { @@ -245,8 +243,7 @@ _rl_kill_kbd_macro () definition to the end of the existing macro, and start by re-executing the existing macro. */ int -rl_start_kbd_macro (ignore1, ignore2) - int ignore1, ignore2; +rl_start_kbd_macro (int ignore1, int ignore2) { if (RL_ISSTATE (RL_STATE_MACRODEF)) { @@ -270,8 +267,7 @@ rl_start_kbd_macro (ignore1, ignore2) A numeric argument says to execute the macro right now, that many times, counting the definition as the first time. */ int -rl_end_kbd_macro (count, ignore) - int count, ignore; +rl_end_kbd_macro (int count, int ignore) { if (RL_ISSTATE (RL_STATE_MACRODEF) == 0) { @@ -290,8 +286,7 @@ rl_end_kbd_macro (count, ignore) /* Execute the most recently defined keyboard macro. COUNT says how many times to execute it. */ int -rl_call_last_kbd_macro (count, ignore) - int count, ignore; +rl_call_last_kbd_macro (int count, int ignore) { if (current_macro == 0) _rl_abort_internal (); @@ -309,8 +304,7 @@ rl_call_last_kbd_macro (count, ignore) } int -rl_print_last_kbd_macro (count, ignore) - int count, ignore; +rl_print_last_kbd_macro (int count, int ignore) { char *m; @@ -332,8 +326,7 @@ rl_print_last_kbd_macro (count, ignore) } void -rl_push_macro_input (macro) - char *macro; +rl_push_macro_input (char *macro) { _rl_with_macro_input (macro); } diff --git a/lib/readline/mbutil.c b/lib/readline/mbutil.c index 6485278e..fac1460f 100644 --- a/lib/readline/mbutil.c +++ b/lib/readline/mbutil.c @@ -76,9 +76,7 @@ int _rl_utf8locale = 0; #if defined(HANDLE_MULTIBYTE) static int -_rl_find_next_mbchar_internal (string, seed, count, find_non_zero) - char *string; - int seed, count, find_non_zero; +_rl_find_next_mbchar_internal (char *string, int seed, int count, int find_non_zero) { size_t tmp, len; mbstate_t ps; @@ -153,9 +151,7 @@ _rl_find_next_mbchar_internal (string, seed, count, find_non_zero) } /*static*/ int -_rl_find_prev_mbchar_internal (string, seed, find_non_zero) - char *string; - int seed, find_non_zero; +_rl_find_prev_mbchar_internal (char *string, int seed, int find_non_zero) { mbstate_t ps; int prev, non_zero_prev, point, length; @@ -220,9 +216,7 @@ _rl_find_prev_mbchar_internal (string, seed, find_non_zero) if an invalid multibyte sequence was encountered. It returns (size_t)(-2) if it couldn't parse a complete multibyte character. */ int -_rl_get_char_len (src, ps) - char *src; - mbstate_t *ps; +_rl_get_char_len (char *src, mbstate_t *ps) { size_t tmp; @@ -251,13 +245,7 @@ _rl_get_char_len (src, ps) /* compare the specified two characters. If the characters matched, return 1. Otherwise return 0. */ int -_rl_compare_chars (buf1, pos1, ps1, buf2, pos2, ps2) - char *buf1; - int pos1; - mbstate_t *ps1; - char *buf2; - int pos2; - mbstate_t *ps2; +_rl_compare_chars (char *buf1, int pos1, mbstate_t *ps1, char *buf2, int pos2, mbstate_t *ps2) { int i, w1, w2; @@ -280,15 +268,13 @@ _rl_compare_chars (buf1, pos1, ps1, buf2, pos2, ps2) if point is invalied (point < 0 || more than string length), it returns -1 */ int -_rl_adjust_point (string, point, ps) - char *string; - int point; - mbstate_t *ps; +_rl_adjust_point (char *string, int point, mbstate_t *ps) { - size_t tmp = 0; - int length; - int pos = 0; + size_t tmp; + int length, pos; + tmp = 0; + pos = 0; length = strlen(string); if (point < 0) return -1; @@ -322,11 +308,7 @@ _rl_adjust_point (string, point, ps) } int -_rl_is_mbchar_matched (string, seed, end, mbchar, length) - char *string; - int seed, end; - char *mbchar; - int length; +_rl_is_mbchar_matched (char *string, int seed, int end, char *mbchar, int length) { int i; @@ -340,9 +322,7 @@ _rl_is_mbchar_matched (string, seed, end, mbchar, length) } wchar_t -_rl_char_value (buf, ind) - char *buf; - int ind; +_rl_char_value (char *buf, int ind) { size_t tmp; wchar_t wc; @@ -369,9 +349,7 @@ _rl_char_value (buf, ind) characters. */ #undef _rl_find_next_mbchar int -_rl_find_next_mbchar (string, seed, count, flags) - char *string; - int seed, count, flags; +_rl_find_next_mbchar (char *string, int seed, int count, int flags) { #if defined (HANDLE_MULTIBYTE) return _rl_find_next_mbchar_internal (string, seed, count, flags); @@ -385,9 +363,7 @@ _rl_find_next_mbchar (string, seed, count, flags) we look for non-zero-width multibyte characters. */ #undef _rl_find_prev_mbchar int -_rl_find_prev_mbchar (string, seed, flags) - char *string; - int seed, flags; +_rl_find_prev_mbchar (char *string, int seed, int flags) { #if defined (HANDLE_MULTIBYTE) return _rl_find_prev_mbchar_internal (string, seed, flags); diff --git a/lib/readline/misc.c b/lib/readline/misc.c index f7acdee0..d50a4c3a 100644 --- a/lib/readline/misc.c +++ b/lib/readline/misc.c @@ -1,6 +1,6 @@ /* misc.c -- miscellaneous bindable readline functions. */ -/* 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. @@ -76,7 +76,7 @@ int _rl_history_saved_point = -1; /* **************************************************************** */ int -_rl_arg_overflow () +_rl_arg_overflow (void) { if (rl_numeric_arg > 1000000) { @@ -92,7 +92,7 @@ _rl_arg_overflow () } void -_rl_arg_init () +_rl_arg_init (void) { rl_save_prompt (); _rl_argcxt = 0; @@ -100,7 +100,7 @@ _rl_arg_init () } int -_rl_arg_getchar () +_rl_arg_getchar (void) { int c; @@ -116,9 +116,7 @@ _rl_arg_getchar () argument should be aborted, 0 if we should not read any more chars, and 1 if we should continue to read chars. */ int -_rl_arg_dispatch (cxt, c) - _rl_arg_cxt cxt; - int c; +_rl_arg_dispatch (_rl_arg_cxt cxt, int c) { int key, r; @@ -193,7 +191,7 @@ _rl_arg_dispatch (cxt, c) /* Handle C-u style numeric args, as well as M--, and M-digits. */ static int -rl_digit_loop () +rl_digit_loop (void) { int c, r; @@ -220,7 +218,7 @@ rl_digit_loop () /* Create a default argument. */ void -_rl_reset_argument () +_rl_reset_argument (void) { rl_numeric_arg = rl_arg_sign = 1; rl_explicit_arg = 0; @@ -229,8 +227,7 @@ _rl_reset_argument () /* Start a numeric argument with initial value KEY */ int -rl_digit_argument (ignore, key) - int ignore, key; +rl_digit_argument (int ignore, int key) { _rl_arg_init (); if (RL_ISSTATE (RL_STATE_CALLBACK)) @@ -250,8 +247,7 @@ rl_digit_argument (ignore, key) Read a key. If the key has nothing to do with arguments, then dispatch on it. If the key is the abort character then abort. */ int -rl_universal_argument (count, key) - int count, key; +rl_universal_argument (int count, int key) { _rl_arg_init (); rl_numeric_arg *= 4; @@ -260,8 +256,7 @@ rl_universal_argument (count, key) } int -_rl_arg_callback (cxt) - _rl_arg_cxt cxt; +_rl_arg_callback (_rl_arg_cxt cxt) { int c, r; @@ -285,7 +280,7 @@ _rl_arg_callback (cxt) /* What to do when you abort reading an argument. */ int -rl_discard_argument () +rl_discard_argument (void) { rl_ding (); rl_clear_message (); @@ -310,7 +305,7 @@ HIST_ENTRY *_rl_saved_line_for_history = (HIST_ENTRY *)NULL; /* Set the history pointer back to the last entry in the history. */ void -_rl_start_using_history () +_rl_start_using_history (void) { using_history (); if (_rl_saved_line_for_history) @@ -321,8 +316,7 @@ _rl_start_using_history () /* Free the contents (and containing structure) of a HIST_ENTRY. */ void -_rl_free_history_entry (entry) - HIST_ENTRY *entry; +_rl_free_history_entry (HIST_ENTRY *entry) { if (entry == 0) return; @@ -335,7 +329,7 @@ _rl_free_history_entry (entry) /* Perhaps put back the current line if it has changed. */ int -rl_maybe_replace_line () +rl_maybe_replace_line (void) { HIST_ENTRY *temp; @@ -353,7 +347,7 @@ rl_maybe_replace_line () /* Restore the _rl_saved_line_for_history if there is one. */ int -rl_maybe_unsave_line () +rl_maybe_unsave_line (void) { if (_rl_saved_line_for_history) { @@ -372,7 +366,7 @@ rl_maybe_unsave_line () /* Save the current line in _rl_saved_line_for_history. */ int -rl_maybe_save_line () +rl_maybe_save_line (void) { if (_rl_saved_line_for_history == 0) { @@ -386,7 +380,7 @@ rl_maybe_save_line () } int -_rl_free_saved_history_line () +_rl_free_saved_history_line (void) { if (_rl_saved_line_for_history) { @@ -397,7 +391,7 @@ _rl_free_saved_history_line () } static void -_rl_history_set_point () +_rl_history_set_point (void) { rl_point = (_rl_history_preserve_point && _rl_history_saved_point != -1) ? _rl_history_saved_point @@ -415,9 +409,7 @@ _rl_history_set_point () } void -rl_replace_from_history (entry, flags) - HIST_ENTRY *entry; - int flags; /* currently unused */ +rl_replace_from_history (HIST_ENTRY *entry, int flags) { /* Can't call with `1' because rl_undo_list might point to an undo list from a history entry, just like we're setting up here. */ @@ -441,7 +433,7 @@ rl_replace_from_history (entry, flags) intended to be called while actively editing, and the current line is not assumed to have been added to the history list. */ void -_rl_revert_all_lines () +_rl_revert_all_lines (void) { int hpos; HIST_ENTRY *entry; @@ -490,7 +482,7 @@ _rl_revert_all_lines () to an UNDO_LIST * saved as some history entry's data member. This should not be called while editing is active. */ void -rl_clear_history () +rl_clear_history (void) { HIST_ENTRY **hlist, *hent; register int i; @@ -524,16 +516,14 @@ rl_clear_history () /* Meta-< goes to the start of the history. */ int -rl_beginning_of_history (count, key) - int count, key; +rl_beginning_of_history (int count, int key) { return (rl_get_previous_history (1 + where_history (), key)); } /* Meta-> goes to the end of the history. (The current line). */ int -rl_end_of_history (count, key) - int count, key; +rl_end_of_history (int count, int key) { rl_maybe_replace_line (); using_history (); @@ -543,8 +533,7 @@ rl_end_of_history (count, key) /* Move down to the next history line. */ int -rl_get_next_history (count, key) - int count, key; +rl_get_next_history (int count, int key) { HIST_ENTRY *temp; @@ -582,8 +571,7 @@ rl_get_next_history (count, key) /* Get the previous item out of our interactive history, making it the current line. If there is no previous history, just ding. */ int -rl_get_previous_history (count, key) - int count, key; +rl_get_previous_history (int count, int key) { HIST_ENTRY *old_temp, *temp; @@ -637,8 +625,7 @@ rl_get_previous_history (count, key) /* **************************************************************** */ /* How to toggle back and forth between editing modes. */ int -rl_vi_editing_mode (count, key) - int count, key; +rl_vi_editing_mode (int count, int key) { #if defined (VI_MODE) _rl_set_insert_mode (RL_IM_INSERT, 1); /* vi mode ignores insert mode */ @@ -650,8 +637,7 @@ rl_vi_editing_mode (count, key) } int -rl_emacs_editing_mode (count, key) - int count, key; +rl_emacs_editing_mode (int count, int key) { rl_editing_mode = emacs_mode; _rl_set_insert_mode (RL_IM_INSERT, 1); /* emacs mode default is insert mode */ @@ -665,8 +651,7 @@ rl_emacs_editing_mode (count, key) /* Function for the rest of the library to use to set insert/overwrite mode. */ void -_rl_set_insert_mode (im, force) - int im, force; +_rl_set_insert_mode (int im, int force) { #ifdef CURSOR_MODE _rl_set_cursor (im, force); @@ -678,8 +663,7 @@ _rl_set_insert_mode (im, force) /* Toggle overwrite mode. A positive explicit argument selects overwrite mode. A negative or zero explicit argument selects insert mode. */ int -rl_overwrite_mode (count, key) - int count, key; +rl_overwrite_mode (int count, int key) { if (rl_explicit_arg == 0) _rl_set_insert_mode (rl_insert_mode ^ 1, 0); diff --git a/lib/readline/nls.c b/lib/readline/nls.c index 7f3e2d8a..d2f67e0d 100644 --- a/lib/readline/nls.c +++ b/lib/readline/nls.c @@ -1,6 +1,6 @@ /* nls.c -- skeletal internationalization code. */ -/* Copyright (C) 1996-2009 Free Software Foundation, Inc. +/* Copyright (C) 1996-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. @@ -86,8 +86,7 @@ static char *find_codeset PARAMS((char *, size_t *)); static char *_rl_get_locale_var PARAMS((const char *)); static char * -_rl_get_locale_var (v) - const char *v; +_rl_get_locale_var (const char *v) { char *lspec; @@ -101,8 +100,7 @@ _rl_get_locale_var (v) } static int -utf8locale (lspec) - char *lspec; +utf8locale (char *lspec) { char *cp; size_t len; @@ -122,7 +120,7 @@ utf8locale (lspec) /* Query the right environment variables and call setlocale() to initialize the C library locale settings. */ char * -_rl_init_locale () +_rl_init_locale (void) { char *ret, *lspec; @@ -148,7 +146,7 @@ _rl_init_locale () to decide the defaults for 8-bit character input and output. Returns 1 if we set eight-bit mode. */ int -_rl_init_eightbit () +_rl_init_eightbit (void) { /* If we have setlocale(3), just check the current LC_CTYPE category value, and go into eight-bit mode if it's not C or POSIX. */ @@ -196,8 +194,7 @@ _rl_init_eightbit () #if !defined (HAVE_SETLOCALE) static char * -normalize_codeset (codeset) - char *codeset; +normalize_codeset (char *codeset) { size_t namelen, i; int len, all_digits; @@ -244,9 +241,7 @@ normalize_codeset (codeset) /* Isolate codeset portion of locale specification. */ static char * -find_codeset (name, lenp) - char *name; - size_t *lenp; +find_codeset (char *name, size_t *lenp) { char *cp, *language, *result; diff --git a/lib/readline/parens.c b/lib/readline/parens.c index ecc465c0..af479773 100644 --- a/lib/readline/parens.c +++ b/lib/readline/parens.c @@ -1,6 +1,6 @@ /* parens.c -- implementation of matching parentheses feature. */ -/* Copyright (C) 1987, 1989, 1992-2015 Free Software Foundation, Inc. +/* Copyright (C) 1987, 1989, 1992-2015, 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. @@ -64,8 +64,7 @@ static int _paren_blink_usec = 500000; /* Change emacs_standard_keymap to have bindings for paren matching when ON_OR_OFF is 1, change them back to self_insert when ON_OR_OFF == 0. */ void -_rl_enable_paren_matching (on_or_off) - int on_or_off; +_rl_enable_paren_matching (int on_or_off) { if (on_or_off) { @@ -98,8 +97,7 @@ _rl_enable_paren_matching (on_or_off) } int -rl_set_paren_blink_timeout (u) - int u; +rl_set_paren_blink_timeout (int u) { int o; @@ -110,8 +108,7 @@ rl_set_paren_blink_timeout (u) } int -rl_insert_close (count, invoking_key) - int count, invoking_key; +rl_insert_close (int count, int invoking_key) { if (rl_explicit_arg || !rl_blink_matching_paren) _rl_insert_char (count, invoking_key); @@ -148,9 +145,7 @@ rl_insert_close (count, invoking_key) } static int -find_matching_open (string, from, closer) - char *string; - int from, closer; +find_matching_open (char *string, int from, int closer) { register int i; int opener, level, delimiter; diff --git a/lib/readline/parse-colors.c b/lib/readline/parse-colors.c index 98b2e9d1..05ec9bc3 100644 --- a/lib/readline/parse-colors.c +++ b/lib/readline/parse-colors.c @@ -2,8 +2,8 @@ Modified by Chet Ramey for Readline. - Copyright (C) 1985, 1988, 1990-1991, 1995-2010, 2012 Free Software Foundation, - Inc. + Copyright (C) 1985, 1988, 1990-1991, 1995-2010, 2012, 2017 + Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -297,7 +297,7 @@ get_funky_string (char **dest, const char **src, bool equals_end, size_t *output } #endif /* COLOR_SUPPORT */ -void _rl_parse_colors() +void _rl_parse_colors(void) { #if defined (COLOR_SUPPORT) const char *p; /* Pointer to character being parsed */ diff --git a/lib/readline/rltty.c b/lib/readline/rltty.c index b1c79294..6d777ad8 100644 --- a/lib/readline/rltty.c +++ b/lib/readline/rltty.c @@ -1,7 +1,7 @@ /* rltty.c -- functions to prepare and restore the terminal for readline's use. */ -/* Copyright (C) 1992-2016 Free Software Foundation, Inc. +/* Copyright (C) 1992-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. @@ -130,8 +130,7 @@ static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *)); static void set_special_char PARAMS((Keymap, TIOTYPE *, int, rl_command_func_t *)); static void -save_tty_chars (tiop) - TIOTYPE *tiop; +save_tty_chars (TIOTYPE *tiop) { _rl_last_tty_chars = _rl_tty_chars; @@ -168,9 +167,7 @@ save_tty_chars (tiop) } static int -get_tty_settings (tty, tiop) - int tty; - TIOTYPE *tiop; +get_tty_settings (int tty, TIOTYPE *tiop) { set_winsize (tty); @@ -200,9 +197,7 @@ get_tty_settings (tty, tiop) } static int -set_tty_settings (tty, tiop) - int tty; - TIOTYPE *tiop; +set_tty_settings (int tty, TIOTYPE *tiop) { if (tiop->flags & SGTTY_SET) { @@ -239,9 +234,7 @@ set_tty_settings (tty, tiop) } static void -prepare_terminal_settings (meta_flag, oldtio, tiop) - int meta_flag; - TIOTYPE oldtio, *tiop; +prepare_terminal_settings (int meta_flag, TIOTYPE oldtio, TIOTYPE *tiop) { _rl_echoing_p = (oldtio.sgttyb.sg_flags & ECHO); _rl_echoctl = (oldtio.sgttyb.sg_flags & ECHOCTL); @@ -357,8 +350,7 @@ static void _rl_bind_tty_special_chars PARAMS((Keymap, TIOTYPE)); #endif static void -save_tty_chars (tiop) - TIOTYPE *tiop; +save_tty_chars (TIOTYPE *tiop) { _rl_last_tty_chars = _rl_tty_chars; @@ -403,7 +395,7 @@ save_tty_chars (tiop) #if defined (_AIX) || defined (_AIX41) /* Currently this is only used on AIX */ static void -rltty_warning (msg) +rltty_warning (char *msg) char *msg; { _rl_errmsg ("warning: %s", msg); @@ -412,8 +404,7 @@ rltty_warning (msg) #if defined (_AIX) void -setopost(tp) -TIOTYPE *tp; +setopost (TIOTYPE *tp) { if ((tp->c_oflag & OPOST) == 0) { @@ -424,9 +415,7 @@ TIOTYPE *tp; #endif static int -_get_tty_settings (tty, tiop) - int tty; - TIOTYPE *tiop; +_get_tty_settings (int tty, TIOTYPE *tiop) { int ioctl_ret; @@ -457,9 +446,7 @@ _get_tty_settings (tty, tiop) } static int -get_tty_settings (tty, tiop) - int tty; - TIOTYPE *tiop; +get_tty_settings (int tty, TIOTYPE *tiop) { set_winsize (tty); @@ -475,9 +462,7 @@ get_tty_settings (tty, tiop) } static int -_set_tty_settings (tty, tiop) - int tty; - TIOTYPE *tiop; +_set_tty_settings (int tty, TIOTYPE *tiop) { while (SETATTR (tty, tiop) < 0) { @@ -489,9 +474,7 @@ _set_tty_settings (tty, tiop) } static int -set_tty_settings (tty, tiop) - int tty; - TIOTYPE *tiop; +set_tty_settings (int tty, TIOTYPE *tiop) { if (_set_tty_settings (tty, tiop) < 0) return -1; @@ -518,9 +501,7 @@ set_tty_settings (tty, tiop) } static void -prepare_terminal_settings (meta_flag, oldtio, tiop) - int meta_flag; - TIOTYPE oldtio, *tiop; +prepare_terminal_settings (int meta_flag, TIOTYPE oldtio, TIOTYPE *tiop) { _rl_echoing_p = (oldtio.c_lflag & ECHO); #if defined (ECHOCTL) @@ -585,21 +566,19 @@ prepare_terminal_settings (meta_flag, oldtio, tiop) /* Put the terminal in CBREAK mode so that we can detect key presses. */ #if defined (NO_TTY_DRIVER) void -rl_prep_terminal (meta_flag) - int meta_flag; +rl_prep_terminal (int meta_flag) { _rl_echoing_p = 1; } void -rl_deprep_terminal () +rl_deprep_terminal (void) { } #else /* ! NO_TTY_DRIVER */ void -rl_prep_terminal (meta_flag) - int meta_flag; +rl_prep_terminal (int meta_flag) { int tty, nprep; TIOTYPE tio; @@ -682,7 +661,7 @@ rl_prep_terminal (meta_flag) /* Restore the terminal's normal settings and modes. */ void -rl_deprep_terminal () +rl_deprep_terminal (void) { int tty; @@ -718,8 +697,7 @@ rl_deprep_terminal () /* Set readline's idea of whether or not it is echoing output to the terminal, returning the old value. */ int -rl_tty_set_echoing (u) - int u; +rl_tty_set_echoing (int u) { int o; @@ -735,8 +713,7 @@ rl_tty_set_echoing (u) /* **************************************************************** */ int -rl_restart_output (count, key) - int count, key; +rl_restart_output (int count, int key) { #if defined (__MINGW32__) return 0; @@ -773,8 +750,7 @@ rl_restart_output (count, key) } int -rl_stop_output (count, key) - int count, key; +rl_stop_output (int count, int key) { #if defined (__MINGW32__) return 0; @@ -822,11 +798,7 @@ rl_stop_output (count, key) #elif defined (NEW_TTY_DRIVER) static void -set_special_char (kmap, tiop, sc, func) - Keymap kmap; - TIOTYPE *tiop; - int sc; - rl_command_func_t *func; +set_special_char (Keymap kmap, TIOTYPE *tiop, int sc, rl_command_func_t *func) { if (sc != -1 && kmap[(unsigned char)sc].type == ISFUNC) kmap[(unsigned char)sc].function = func; @@ -837,9 +809,7 @@ set_special_char (kmap, tiop, sc, func) kmap[(unsigned char)c].function = rl_insert; static void -_rl_bind_tty_special_chars (kmap, ttybuff) - Keymap kmap; - TIOTYPE ttybuff; +_rl_bind_tty_special_chars (Keymap kmap, TIOTYPE ttybuff) { if (ttybuff.flags & SGTTY_SET) { @@ -858,11 +828,7 @@ _rl_bind_tty_special_chars (kmap, ttybuff) #else /* !NEW_TTY_DRIVER */ static void -set_special_char (kmap, tiop, sc, func) - Keymap kmap; - TIOTYPE *tiop; - int sc; - rl_command_func_t *func; +set_special_char (Keymap kmap, TIOTYPE *tiop, int sc, rl_command_func_t *func) { unsigned char uc; @@ -877,9 +843,7 @@ set_special_char (kmap, tiop, sc, func) kmap[uc].function = rl_insert; static void -_rl_bind_tty_special_chars (kmap, ttybuff) - Keymap kmap; - TIOTYPE ttybuff; +_rl_bind_tty_special_chars (Keymap kmap, TIOTYPE ttybuff) { SET_SPECIAL (VERASE, rl_rubout); SET_SPECIAL (VKILL, rl_unix_line_discard); @@ -903,8 +867,7 @@ _rl_bind_tty_special_chars (kmap, ttybuff) /* Set the system's default editing characters to their readline equivalents in KMAP. Should be static, now that we have rl_tty_set_default_bindings. */ void -rltty_set_default_bindings (kmap) - Keymap kmap; +rltty_set_default_bindings (Keymap kmap) { #if !defined (NO_TTY_DRIVER) TIOTYPE ttybuff; @@ -920,8 +883,7 @@ rltty_set_default_bindings (kmap) /* New public way to set the system default editing chars to their readline equivalents. */ void -rl_tty_set_default_bindings (kmap) - Keymap kmap; +rl_tty_set_default_bindings (Keymap kmap) { rltty_set_default_bindings (kmap); } @@ -931,8 +893,7 @@ rl_tty_set_default_bindings (kmap) chars with save_tty_chars(). This only works on POSIX termios or termio systems. */ void -rl_tty_unset_default_bindings (kmap) - Keymap kmap; +rl_tty_unset_default_bindings (Keymap kmap) { /* Don't bother before we've saved the tty special chars at least once. */ if (RL_ISSTATE(RL_STATE_TTYCSAVED) == 0) @@ -954,13 +915,13 @@ rl_tty_unset_default_bindings (kmap) #if defined (NEW_TTY_DRIVER) || defined (NO_TTY_DRIVER) int -_rl_disable_tty_signals () +_rl_disable_tty_signals (void) { return 0; } int -_rl_restore_tty_signals () +_rl_restore_tty_signals (void) { return 0; } @@ -970,7 +931,7 @@ static TIOTYPE sigstty, nosigstty; static int tty_sigs_disabled = 0; int -_rl_disable_tty_signals () +_rl_disable_tty_signals (void) { if (tty_sigs_disabled) return 0; @@ -991,7 +952,7 @@ _rl_disable_tty_signals () } int -_rl_restore_tty_signals () +_rl_restore_tty_signals (void) { int r; diff --git a/lib/readline/savestring.c b/lib/readline/savestring.c index af985380..f4bb6aa1 100644 --- a/lib/readline/savestring.c +++ b/lib/readline/savestring.c @@ -1,6 +1,6 @@ /* savestring.c - function version of savestring for backwards compatibility */ -/* Copyright (C) 1998,2003 Free Software Foundation, Inc. +/* Copyright (C) 1998,2003,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. @@ -30,8 +30,7 @@ /* Backwards compatibility, now that savestring has been removed from all `public' readline header files. */ char * -savestring (s) - const char *s; +savestring (const char *s) { char *ret; diff --git a/lib/readline/search.c b/lib/readline/search.c index 131d12d8..2cbee629 100644 --- a/lib/readline/search.c +++ b/lib/readline/search.c @@ -1,6 +1,6 @@ /* search.c - code for non-incremental searching in emacs and vi modes. */ -/* Copyright (C) 1992-2016 Free Software Foundation, Inc. +/* Copyright (C) 1992-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. @@ -87,8 +87,7 @@ static int _rl_nsearch_dispatch PARAMS((_rl_search_cxt *, int)); current line. This doesn't do anything with rl_point; the caller must set it. */ static void -make_history_line_current (entry) - HIST_ENTRY *entry; +make_history_line_current (HIST_ENTRY *entry) { _rl_replace_text (entry->line, 0, rl_end); _rl_fix_point (1); @@ -112,10 +111,7 @@ make_history_line_current (entry) for STRING. DIR < 0 means to search backwards through the history list, DIR >= 0 means to search forward. */ static int -noninc_search_from_pos (string, pos, dir, flags, ncp) - char *string; - int pos, dir, flags; - int *ncp; +noninc_search_from_pos (char *string, int pos, int dir, int flags, int *ncp) { int ret, old, sflags; char *s; @@ -161,10 +157,7 @@ noninc_search_from_pos (string, pos, dir, flags, ncp) search is backwards through previous entries, else through subsequent entries. Returns 1 if the search was successful, 0 otherwise. */ static int -noninc_dosearch (string, dir, flags) - char *string; - int dir; - int flags; +noninc_dosearch (char *string, int dir, int flags) { int oldpos, pos; HIST_ENTRY *entry; @@ -207,8 +200,7 @@ noninc_dosearch (string, dir, flags) } static _rl_search_cxt * -_rl_nsearch_init (dir, pchar) - int dir, pchar; +_rl_nsearch_init (int dir, int pchar) { _rl_search_cxt *cxt; char *p; @@ -247,9 +239,7 @@ _rl_nsearch_init (dir, pchar) } int -_rl_nsearch_cleanup (cxt, r) - _rl_search_cxt *cxt; - int r; +_rl_nsearch_cleanup (_rl_search_cxt *cxt, int r) { _rl_scxt_dispose (cxt, 0); _rl_nscxt = 0; @@ -260,8 +250,7 @@ _rl_nsearch_cleanup (cxt, r) } static void -_rl_nsearch_abort (cxt) - _rl_search_cxt *cxt; +_rl_nsearch_abort (_rl_search_cxt *cxt) { rl_maybe_unsave_line (); rl_clear_message (); @@ -276,9 +265,7 @@ _rl_nsearch_abort (cxt) if the caller should abort the search, 0 if we should break out of the loop, and 1 if we should continue to read characters. */ static int -_rl_nsearch_dispatch (cxt, c) - _rl_search_cxt *cxt; - int c; +_rl_nsearch_dispatch (_rl_search_cxt *cxt, int c) { switch (c) { @@ -329,8 +316,7 @@ _rl_nsearch_dispatch (cxt, c) using _rl_nsearch_cleanup (). Returns 1 if the search was successful, 0 otherwise. */ static int -_rl_nsearch_dosearch (cxt) - _rl_search_cxt *cxt; +_rl_nsearch_dosearch (_rl_search_cxt *cxt) { rl_mark = cxt->save_mark; @@ -372,9 +358,7 @@ _rl_nsearch_dosearch (cxt) history list. PCHAR is the character to use for prompting when reading the search string; if not specified (0), it defaults to `:'. */ static int -noninc_search (dir, pchar) - int dir; - int pchar; +noninc_search (int dir, int pchar) { _rl_search_cxt *cxt; int c, r; @@ -407,8 +391,7 @@ noninc_search (dir, pchar) /* Search forward through the history list for a string. If the vi-mode code calls this, KEY will be `?'. */ int -rl_noninc_forward_search (count, key) - int count, key; +rl_noninc_forward_search (int count, int key) { return noninc_search (1, (key == '?') ? '?' : 0); } @@ -416,8 +399,7 @@ rl_noninc_forward_search (count, key) /* Reverse search the history list for a string. If the vi-mode code calls this, KEY will be `/'. */ int -rl_noninc_reverse_search (count, key) - int count, key; +rl_noninc_reverse_search (int count, int key) { return noninc_search (-1, (key == '/') ? '/' : 0); } @@ -426,8 +408,7 @@ rl_noninc_reverse_search (count, key) for. If there is no saved search string, abort. If the vi-mode code calls this, KEY will be `N'. */ int -rl_noninc_forward_search_again (count, key) - int count, key; +rl_noninc_forward_search_again (int count, int key) { int r; @@ -449,8 +430,7 @@ rl_noninc_forward_search_again (count, key) for. If there is no saved search string, abort. If the vi-mode code calls this, KEY will be `n'. */ int -rl_noninc_reverse_search_again (count, key) - int count, key; +rl_noninc_reverse_search_again (int count, int key) { int r; @@ -470,8 +450,7 @@ rl_noninc_reverse_search_again (count, key) #if defined (READLINE_CALLBACKS) int -_rl_nsearch_callback (cxt) - _rl_search_cxt *cxt; +_rl_nsearch_callback (_rl_search_cxt *cxt) { int c, r; @@ -486,8 +465,7 @@ _rl_nsearch_callback (cxt) #endif static int -rl_history_search_internal (count, dir) - int count, dir; +rl_history_search_internal (int count, int dir) { HIST_ENTRY *temp; int ret, oldpos, newcol; @@ -565,8 +543,7 @@ rl_history_search_internal (count, dir) } static void -rl_history_search_reinit (flags) - int flags; +rl_history_search_reinit (int flags) { int sind; @@ -596,8 +573,7 @@ rl_history_search_reinit (flags) from the start of the line to rl_point. This is a non-incremental search. The search is anchored to the beginning of the history line. */ int -rl_history_search_forward (count, ignore) - int count, ignore; +rl_history_search_forward (int count, int ignore) { if (count == 0) return (0); @@ -615,8 +591,7 @@ rl_history_search_forward (count, ignore) from the start of the line to rl_point. This is a non-incremental search. */ int -rl_history_search_backward (count, ignore) - int count, ignore; +rl_history_search_backward (int count, int ignore) { if (count == 0) return (0); @@ -635,8 +610,7 @@ rl_history_search_backward (count, ignore) search. The search succeeds if the search string is present anywhere in the history line. */ int -rl_history_substr_search_forward (count, ignore) - int count, ignore; +rl_history_substr_search_forward (int count, int ignore) { if (count == 0) return (0); @@ -654,8 +628,7 @@ rl_history_substr_search_forward (count, ignore) from the start of the line to rl_point. This is a non-incremental search. */ int -rl_history_substr_search_backward (count, ignore) - int count, ignore; +rl_history_substr_search_backward (int count, int ignore) { if (count == 0) return (0); diff --git a/lib/readline/shell.c b/lib/readline/shell.c index 6947295e..7fe2e97c 100644 --- a/lib/readline/shell.c +++ b/lib/readline/shell.c @@ -1,7 +1,7 @@ /* shell.c -- readline utility functions that are normally provided by bash when readline is linked as part of the shell. */ -/* Copyright (C) 1997-2009 Free Software Foundation, Inc. +/* Copyright (C) 1997-2009,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. @@ -92,8 +92,7 @@ extern struct passwd *getpwuid PARAMS((uid_t)); /* Does shell-like quoting using single quotes. */ char * -sh_single_quote (string) - char *string; +sh_single_quote (char *string) { register int c; char *result, *r, *s; @@ -127,8 +126,7 @@ static char putenv_buf1[INT_STRLEN_BOUND (int) + 6 + 1]; /* sizeof("LINES=") == static char putenv_buf2[INT_STRLEN_BOUND (int) + 8 + 1]; /* sizeof("COLUMNS=") == 8 */ void -sh_set_lines_and_columns (lines, cols) - int lines, cols; +sh_set_lines_and_columns (int lines, int cols) { #if defined (HAVE_SETENV) sprintf (setenv_buf, "%d", lines); @@ -148,14 +146,13 @@ sh_set_lines_and_columns (lines, cols) } char * -sh_get_env_value (varname) - const char *varname; +sh_get_env_value (const char *varname) { return ((char *)getenv (varname)); } char * -sh_get_home_dir () +sh_get_home_dir (void) { static char *home_dir = (char *)NULL; struct passwd *entry; @@ -188,8 +185,7 @@ sh_get_home_dir () #endif int -sh_unset_nodelay_mode (fd) - int fd; +sh_unset_nodelay_mode (int fd) { #if defined (HAVE_FCNTL) int flags, bflags; diff --git a/lib/readline/signals.c b/lib/readline/signals.c index 768c5d19..fcf45b73 100644 --- a/lib/readline/signals.c +++ b/lib/readline/signals.c @@ -1,6 +1,6 @@ /* signals.c -- signal handling support for 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. @@ -138,8 +138,7 @@ void *_rl_sigcleanarg; /* Called from RL_CHECK_SIGNALS() macro */ RETSIGTYPE -_rl_signal_handler (sig) - int sig; +_rl_signal_handler (int sig) { _rl_caught_signal = 0; /* XXX */ @@ -162,8 +161,7 @@ _rl_signal_handler (sig) } static RETSIGTYPE -rl_signal_handler (sig) - int sig; +rl_signal_handler (int sig) { if (_rl_interrupt_immediately) { @@ -177,8 +175,7 @@ rl_signal_handler (sig) } static RETSIGTYPE -_rl_handle_signal (sig) - int sig; +_rl_handle_signal (int sig) { #if defined (HAVE_POSIX_SIGNALS) sigset_t set; @@ -293,8 +290,7 @@ _rl_handle_signal (sig) #if defined (SIGWINCH) static RETSIGTYPE -rl_sigwinch_handler (sig) - int sig; +rl_sigwinch_handler (int sig) { SigHandler *oh; @@ -325,9 +321,7 @@ rl_sigwinch_handler (sig) #if !defined (HAVE_POSIX_SIGNALS) static int -rl_sigaction (sig, nh, oh) - int sig; - sighandler_cxt *nh, *oh; +rl_sigaction (int sig, sighandler_cxt *nh, sighandler_cxt *oh) { oh->sa_handler = signal (sig, nh->sa_handler); return 0; @@ -338,10 +332,7 @@ rl_sigaction (sig, nh, oh) information in OHANDLER. Return the old signal handler, like signal(). */ static SigHandler * -rl_set_sighandler (sig, handler, ohandler) - int sig; - SigHandler *handler; - sighandler_cxt *ohandler; +rl_set_sighandler (int sig, SigHandler *handler, sighandler_cxt *ohandler) { sighandler_cxt old_handler; #if defined (HAVE_POSIX_SIGNALS) @@ -372,10 +363,7 @@ rl_set_sighandler (sig, handler, ohandler) /* Set disposition of SIG to HANDLER, returning old state in OHANDLER. Don't change disposition if OHANDLER indicates the signal was ignored. */ static void -rl_maybe_set_sighandler (sig, handler, ohandler) - int sig; - SigHandler *handler; - sighandler_cxt *ohandler; +rl_maybe_set_sighandler (int sig, SigHandler *handler, sighandler_cxt *ohandler) { sighandler_cxt dummy; SigHandler *oh; @@ -392,9 +380,7 @@ rl_maybe_set_sighandler (sig, handler, ohandler) disposition was changed using rl_maybe_set_sighandler or for which the SIG_IGN check was performed inline (e.g., SIGALRM below). */ static void -rl_maybe_restore_sighandler (sig, handler) - int sig; - sighandler_cxt *handler; +rl_maybe_restore_sighandler (int sig, sighandler_cxt *handler) { sighandler_cxt dummy; @@ -405,7 +391,7 @@ rl_maybe_restore_sighandler (sig, handler) } int -rl_set_signals () +rl_set_signals (void) { sighandler_cxt dummy; SigHandler *oh; @@ -511,7 +497,7 @@ rl_set_signals () } int -rl_clear_signals () +rl_clear_signals (void) { sighandler_cxt dummy; @@ -564,7 +550,7 @@ rl_clear_signals () /* Clean up the terminal and readline state after catching a signal, before resending it to the calling application. */ void -rl_cleanup_after_signal () +rl_cleanup_after_signal (void) { _rl_clean_up_for_exit (); if (rl_deprep_term_function) @@ -575,7 +561,7 @@ rl_cleanup_after_signal () /* Reset the terminal and readline state after a signal handler returns. */ void -rl_reset_after_signal () +rl_reset_after_signal (void) { if (rl_prep_term_function) (*rl_prep_term_function) (_rl_meta_flag); @@ -587,7 +573,7 @@ rl_reset_after_signal () numeric arguments in process) after catching a signal, before calling rl_cleanup_after_signal(). */ void -rl_free_line_state () +rl_free_line_state (void) { register HIST_ENTRY *entry; @@ -603,7 +589,7 @@ rl_free_line_state () } int -rl_pending_signal () +rl_pending_signal (void) { return (_rl_caught_signal); } @@ -631,7 +617,7 @@ static int sigwinch_blocked; /* Cause SIGINT to not be delivered until the corresponding call to release_sigint(). */ void -_rl_block_sigint () +_rl_block_sigint (void) { if (sigint_blocked) return; @@ -641,7 +627,7 @@ _rl_block_sigint () /* Allow SIGINT to be delivered. */ void -_rl_release_sigint () +_rl_release_sigint (void) { if (sigint_blocked == 0) return; @@ -653,7 +639,7 @@ _rl_release_sigint () /* Cause SIGWINCH to not be delivered until the corresponding call to release_sigwinch(). */ void -_rl_block_sigwinch () +_rl_block_sigwinch (void) { if (sigwinch_blocked) return; @@ -682,7 +668,7 @@ _rl_block_sigwinch () /* Allow SIGWINCH to be delivered. */ void -_rl_release_sigwinch () +_rl_release_sigwinch (void) { if (sigwinch_blocked == 0) return; @@ -712,8 +698,7 @@ _rl_release_sigwinch () /* */ /* **************************************************************** */ void -rl_echo_signal_char (sig) - int sig; +rl_echo_signal_char (int sig) { char cstr[3]; int cslen, c; diff --git a/lib/readline/terminal.c b/lib/readline/terminal.c index ef2884e0..793fda3e 100644 --- a/lib/readline/terminal.c +++ b/lib/readline/terminal.c @@ -1,6 +1,6 @@ /* terminal.c -- controlling the terminal with termcap. */ -/* Copyright (C) 1996-2015 Free Software Foundation, Inc. +/* Copyright (C) 1996-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. @@ -131,6 +131,7 @@ char *_rl_term_IC; char *_rl_term_dc; char *_rl_term_DC; +/* How to move forward a char, non-destructively */ char *_rl_term_forward_char; /* How to go up a line. */ @@ -188,8 +189,7 @@ int _rl_enable_meta = 1; #if defined (__EMX__) static void -_emx_get_screensize (swp, shp) - int *swp, *shp; +_emx_get_screensize (int *swp, int *shp) { int sz[2]; @@ -204,8 +204,7 @@ _emx_get_screensize (swp, shp) #if defined (__MINGW32__) static void -_win_get_screensize (swp, shp) - int *swp, *shp; +_win_get_screensize (int *swp, int *shp) { HANDLE hConOut; CONSOLE_SCREEN_BUFFER_INFO scr; @@ -227,8 +226,7 @@ _win_get_screensize (swp, shp) values of $LINES and $COLUMNS. The tests for TERM_STRING_BUFFER being non-null serve to check whether or not we have initialized termcap. */ void -_rl_get_screen_size (tty, ignore_env) - int tty, ignore_env; +_rl_get_screen_size (int tty, int ignore_env) { char *ss; #if defined (TIOCGWINSZ) @@ -318,8 +316,7 @@ _rl_get_screen_size (tty, ignore_env) } void -_rl_set_screen_size (rows, cols) - int rows, cols; +_rl_set_screen_size (int rows, int cols) { if (_rl_term_autowrap == -1) _rl_init_terminal_io (rl_terminal_name); @@ -338,15 +335,13 @@ _rl_set_screen_size (rows, cols) } void -rl_set_screen_size (rows, cols) - int rows, cols; +rl_set_screen_size (int rows, int cols) { _rl_set_screen_size (rows, cols); } void -rl_get_screen_size (rows, cols) - int *rows, *cols; +rl_get_screen_size (int *rows, int *cols) { if (rows) *rows = _rl_screenheight; @@ -355,19 +350,19 @@ rl_get_screen_size (rows, cols) } void -rl_reset_screen_size () +rl_reset_screen_size (void) { _rl_get_screen_size (fileno (rl_instream), 0); } void -_rl_sigwinch_resize_terminal () +_rl_sigwinch_resize_terminal (void) { _rl_get_screen_size (fileno (rl_instream), 1); } void -rl_resize_terminal () +rl_resize_terminal (void) { _rl_get_screen_size (fileno (rl_instream), 1); if (_rl_echoing_p) @@ -424,8 +419,7 @@ static const struct _tc_string tc_strings[] = /* Read the desired terminal capability strings into BP. The capabilities are described in the TC_STRINGS table. */ static void -get_term_capabilities (bp) - char **bp; +get_term_capabilities (char **bp) { #if !defined (__DJGPP__) /* XXX - doesn't DJGPP have a termcap library? */ register int i; @@ -437,8 +431,7 @@ get_term_capabilities (bp) } int -_rl_init_terminal_io (terminal_name) - const char *terminal_name; +_rl_init_terminal_io (const char *terminal_name) { const char *term; char *buffer; @@ -584,8 +577,7 @@ _rl_init_terminal_io (terminal_name) /* Bind the arrow key sequences from the termcap description in MAP. */ static void -bind_termcap_arrow_keys (map) - Keymap map; +bind_termcap_arrow_keys (Keymap map) { Keymap xkeymap; @@ -606,8 +598,7 @@ bind_termcap_arrow_keys (map) } char * -rl_get_termcap (cap) - const char *cap; +rl_get_termcap (const char *cap) { register int i; @@ -624,8 +615,7 @@ rl_get_termcap (cap) /* Re-initialize the terminal considering that the TERM/TERMCAP variable has changed. */ int -rl_reset_terminal (terminal_name) - const char *terminal_name; +rl_reset_terminal (const char *terminal_name) { _rl_screenwidth = _rl_screenheight = 0; _rl_init_terminal_io (terminal_name); @@ -635,15 +625,13 @@ rl_reset_terminal (terminal_name) /* A function for the use of tputs () */ #ifdef _MINIX void -_rl_output_character_function (c) - int c; +_rl_output_character_function (int c) { putc (c, _rl_out_stream); } #else /* !_MINIX */ int -_rl_output_character_function (c) - int c; +_rl_output_character_function (int c) { return putc (c, _rl_out_stream); } @@ -651,17 +639,14 @@ _rl_output_character_function (c) /* Write COUNT characters from STRING to the output stream. */ void -_rl_output_some_chars (string, count) - const char *string; - int count; +_rl_output_some_chars (const char *string, int count) { fwrite (string, 1, count, _rl_out_stream); } /* Move the cursor back. */ int -_rl_backspace (count) - int count; +_rl_backspace (int count) { register int i; @@ -678,7 +663,7 @@ _rl_backspace (count) /* Move to the start of the next line. */ int -rl_crlf () +rl_crlf (void) { #if defined (NEW_TTY_DRIVER) || defined (__MINT__) if (_rl_term_cr) @@ -690,7 +675,7 @@ rl_crlf () /* Ring the terminal bell. */ int -rl_ding () +rl_ding (void) { if (_rl_echoing_p) { @@ -729,7 +714,7 @@ rl_ding () static int enabled_meta = 0; /* flag indicating we enabled meta mode */ void -_rl_enable_meta_key () +_rl_enable_meta_key (void) { #if !defined (__DJGPP__) if (term_has_meta && _rl_term_mm) @@ -741,7 +726,7 @@ _rl_enable_meta_key () } void -_rl_disable_meta_key () +_rl_disable_meta_key (void) { #if !defined (__DJGPP__) if (term_has_meta && _rl_term_mo && enabled_meta) @@ -753,8 +738,7 @@ _rl_disable_meta_key () } void -_rl_control_keypad (on) - int on; +_rl_control_keypad (int on) { #if !defined (__DJGPP__) if (on && _rl_term_ks) @@ -775,8 +759,7 @@ _rl_control_keypad (on) cursor. Overwrite mode gets a very visible cursor. Only does anything if we have both capabilities. */ void -_rl_set_cursor (im, force) - int im, force; +_rl_set_cursor (int im, int force) { #ifndef __MSDOS__ if (_rl_term_ve && _rl_term_vs) diff --git a/lib/readline/text.c b/lib/readline/text.c index 8043ba51..095c0ef3 100644 --- a/lib/readline/text.c +++ b/lib/readline/text.c @@ -1,6 +1,6 @@ /* text.c -- text handling commands for 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. @@ -83,8 +83,7 @@ int _rl_optimize_typeahead = 1; /* rl_insert tries to read typeahead */ way that you should do insertion. _rl_insert_char () calls this function. Returns the number of characters inserted. */ int -rl_insert_text (string) - const char *string; +rl_insert_text (const char *string) { register int i, l; @@ -121,8 +120,7 @@ rl_insert_text (string) /* Delete the string between FROM and TO. FROM is inclusive, TO is not. Returns the number of characters deleted. */ int -rl_delete_text (from, to) - int from, to; +rl_delete_text (int from, int to) { register char *text; register int diff, i; @@ -172,8 +170,7 @@ rl_delete_text (from, to) } while (0) void -_rl_fix_point (fix_mark_too) - int fix_mark_too; +_rl_fix_point (int fix_mark_too) { _RL_FIX_POINT (rl_point); if (fix_mark_too) @@ -185,9 +182,7 @@ _rl_fix_point (fix_mark_too) TEXT. The operation is undoable. To replace the entire line in an undoable mode, use _rl_replace_text(text, 0, rl_end); */ int -_rl_replace_text (text, start, end) - const char *text; - int start, end; +_rl_replace_text (const char *text, int start, int end) { int n; @@ -206,9 +201,7 @@ _rl_replace_text (text, start, end) /* Replace the current line buffer contents with TEXT. If CLEAR_UNDO is non-zero, we free the current undo list. */ void -rl_replace_line (text, clear_undo) - const char *text; - int clear_undo; +rl_replace_line (const char *text, int clear_undo) { int len; @@ -259,8 +252,7 @@ rl_replace_line (text, clear_undo) /* Move forward COUNT bytes. */ int -rl_forward_byte (count, key) - int count, key; +rl_forward_byte (int count, int key) { if (count < 0) return (rl_backward_byte (-count, key)); @@ -292,8 +284,7 @@ rl_forward_byte (count, key) } int -_rl_forward_char_internal (count) - int count; +_rl_forward_char_internal (int count) { int point; @@ -319,8 +310,7 @@ _rl_forward_char_internal (count) #if defined (HANDLE_MULTIBYTE) /* Move forward COUNT characters. */ int -rl_forward_char (count, key) - int count, key; +rl_forward_char (int count, int key) { int point; @@ -350,8 +340,7 @@ rl_forward_char (count, key) } #else /* !HANDLE_MULTIBYTE */ int -rl_forward_char (count, key) - int count, key; +rl_forward_char (int count, int key) { return (rl_forward_byte (count, key)); } @@ -359,16 +348,14 @@ rl_forward_char (count, key) /* Backwards compatibility. */ int -rl_forward (count, key) - int count, key; +rl_forward (int count, int key) { return (rl_forward_char (count, key)); } /* Move backward COUNT bytes. */ int -rl_backward_byte (count, key) - int count, key; +rl_backward_byte (int count, int key) { if (count < 0) return (rl_forward_byte (-count, key)); @@ -393,8 +380,7 @@ rl_backward_byte (count, key) #if defined (HANDLE_MULTIBYTE) /* Move backward COUNT characters. */ int -rl_backward_char (count, key) - int count, key; +rl_backward_char (int count, int key) { int point; @@ -426,8 +412,7 @@ rl_backward_char (count, key) } #else int -rl_backward_char (count, key) - int count, key; +rl_backward_char (int count, int key) { return (rl_backward_byte (count, key)); } @@ -435,16 +420,14 @@ rl_backward_char (count, key) /* Backwards compatibility. */ int -rl_backward (count, key) - int count, key; +rl_backward (int count, int key) { return (rl_backward_char (count, key)); } /* Move to the beginning of the line. */ int -rl_beg_of_line (count, key) - int count, key; +rl_beg_of_line (int count, int key) { rl_point = 0; return 0; @@ -452,8 +435,7 @@ rl_beg_of_line (count, key) /* Move to the end of the line. */ int -rl_end_of_line (count, key) - int count, key; +rl_end_of_line (int count, int key) { rl_point = rl_end; return 0; @@ -461,8 +443,7 @@ rl_end_of_line (count, key) /* Move forward a word. We do what Emacs does. Handles multibyte chars. */ int -rl_forward_word (count, key) - int count, key; +rl_forward_word (int count, int key) { int c; @@ -510,8 +491,7 @@ rl_forward_word (count, key) /* Move backward a word. We do what Emacs does. Handles multibyte chars. */ int -rl_backward_word (count, key) - int count, key; +rl_backward_word (int count, int key) { int c, p; @@ -560,8 +540,7 @@ rl_backward_word (count, key) /* Clear the current line. Numeric argument to C-l does this. */ int -rl_refresh_line (ignore1, ignore2) - int ignore1, ignore2; +rl_refresh_line (int ignore1, int ignore2) { int curr_line; @@ -582,8 +561,7 @@ rl_refresh_line (ignore1, ignore2) the prompt and the current input line. Given a numeric arg, redraw only the current line. */ int -rl_clear_screen (count, key) - int count, key; +rl_clear_screen (int count, int key) { if (rl_explicit_arg) { @@ -599,7 +577,7 @@ rl_clear_screen (count, key) } int -rl_previous_screen_line (count, key) +rl_previous_screen_line (int count, int key) { int c; @@ -608,7 +586,7 @@ rl_previous_screen_line (count, key) } int -rl_next_screen_line (count, key) +rl_next_screen_line (int count, int key) { int c; @@ -617,8 +595,7 @@ rl_next_screen_line (count, key) } int -rl_skip_csi_sequence (count, key) - int count, key; +rl_skip_csi_sequence (int count, int key) { int ch; @@ -632,8 +609,7 @@ rl_skip_csi_sequence (count, key) } int -rl_arrow_keys (count, c) - int count, c; +rl_arrow_keys (int count, int key) { int ch; @@ -690,8 +666,7 @@ static mbstate_t ps = {0}; If C introduces a multibyte sequence, we read the whole sequence and then insert the multibyte char into the line buffer. */ int -_rl_insert_char (count, c) - int count, c; +_rl_insert_char (int count, int c) { register int i; char *string; @@ -897,8 +872,7 @@ _rl_insert_char (count, c) If C introduces a multibyte character sequence, read the entire sequence before starting the overwrite loop. */ int -_rl_overwrite_char (count, c) - int count, c; +_rl_overwrite_char (int count, int c) { int i; #if defined (HANDLE_MULTIBYTE) @@ -931,8 +905,7 @@ _rl_overwrite_char (count, c) } int -rl_insert (count, c) - int count, c; +rl_insert (int count, int c) { int r, n, x; @@ -981,8 +954,7 @@ rl_insert (count, c) /* Insert the next typed character verbatim. */ static int -_rl_insert_next (count) - int count; +_rl_insert_next (int count) { int c; @@ -1006,8 +978,7 @@ _rl_insert_next (count) #if defined (READLINE_CALLBACKS) static int -_rl_insert_next_callback (data) - _rl_callback_generic_arg *data; +_rl_insert_next_callback (_rl_callback_generic_arg *data) { int count; @@ -1022,8 +993,7 @@ _rl_insert_next_callback (data) #endif int -rl_quoted_insert (count, key) - int count, key; +rl_quoted_insert (int count, int key) { /* Let's see...should the callback interface futz with signal handling? */ #if defined (HANDLE_SIGNALS) @@ -1045,8 +1015,7 @@ rl_quoted_insert (count, key) /* Insert a tab character. */ int -rl_tab_insert (count, key) - int count, key; +rl_tab_insert (int count, int key) { return (_rl_insert_char (count, '\t')); } @@ -1055,8 +1024,7 @@ rl_tab_insert (count, key) KEY is the key that invoked this command. I guess it could have meaning in the future. */ int -rl_newline (count, key) - int count, key; +rl_newline (int count, int key) { rl_done = 1; @@ -1089,8 +1057,7 @@ rl_newline (count, key) is just a stub, you bind keys to it and the code in _rl_dispatch () is special cased. */ int -rl_do_lowercase_version (ignore1, ignore2) - int ignore1, ignore2; +rl_do_lowercase_version (int ignore1, int ignore2) { return 0; } @@ -1099,8 +1066,7 @@ rl_do_lowercase_version (ignore1, ignore2) rubout in overwrite mode has one oddity: it replaces a control character that's displayed as two characters (^X) with two spaces. */ int -_rl_overwrite_rubout (count, key) - int count, key; +_rl_overwrite_rubout (int count, int key) { int opoint; int i, l; @@ -1142,8 +1108,7 @@ _rl_overwrite_rubout (count, key) /* Rubout the character behind point. */ int -rl_rubout (count, key) - int count, key; +rl_rubout (int count, int key) { if (count < 0) return (rl_delete (-count, key)); @@ -1161,8 +1126,7 @@ rl_rubout (count, key) } int -_rl_rubout_char (count, key) - int count, key; +_rl_rubout_char (int count, int key) { int orig_point; unsigned char c; @@ -1207,8 +1171,7 @@ _rl_rubout_char (count, key) /* Delete the character under the cursor. Given a numeric argument, kill that many characters instead. */ int -rl_delete (count, key) - int count, key; +rl_delete (int count, int key) { int xpoint; @@ -1245,8 +1208,7 @@ rl_delete (count, key) behind the cursor is deleted. COUNT is obeyed and may be used to delete forward or backward that many characters. */ int -rl_rubout_or_delete (count, key) - int count, key; +rl_rubout_or_delete (int count, int key) { if (rl_end != 0 && rl_point == rl_end) return (_rl_rubout_char (count, key)); @@ -1256,8 +1218,7 @@ rl_rubout_or_delete (count, key) /* Delete all spaces and tabs around point. */ int -rl_delete_horizontal_space (count, ignore) - int count, ignore; +rl_delete_horizontal_space (int count, int ignore) { int start; @@ -1285,8 +1246,7 @@ rl_delete_horizontal_space (count, ignore) is caught before this is invoked, so this really does the same thing as delete-char-or-list-or-eof, as long as it's bound to the eof character. */ int -rl_delete_or_show_completions (count, key) - int count, key; +rl_delete_or_show_completions (int count, int key) { if (rl_end != 0 && rl_point == rl_end) return (rl_possible_completions (count, key)); @@ -1301,8 +1261,7 @@ rl_delete_or_show_completions (count, key) /* Turn the current line into a comment in shell history. A K*rn shell style function. */ int -rl_insert_comment (count, key) - int count, key; +rl_insert_comment (int count, int key) { char *rl_comment_text; int rl_comment_len; @@ -1340,24 +1299,21 @@ rl_insert_comment (count, key) /* Uppercase the word at point. */ int -rl_upcase_word (count, key) - int count, key; +rl_upcase_word (int count, int key) { return (rl_change_case (count, UpCase)); } /* Lowercase the word at point. */ int -rl_downcase_word (count, key) - int count, key; +rl_downcase_word (int count, int key) { return (rl_change_case (count, DownCase)); } /* Upcase the first letter, downcase the rest. */ int -rl_capitalize_word (count, key) - int count, key; +rl_capitalize_word (int count, int key) { return (rl_change_case (count, CapCase)); } @@ -1368,8 +1324,7 @@ rl_capitalize_word (count, key) If a negative argument is given, leave point where it started, otherwise, leave it where it moves to. */ static int -rl_change_case (count, op) - int count, op; +rl_change_case (int count, int op) { int start, next, end; int inword, c, nc, nop; @@ -1463,8 +1418,7 @@ rl_change_case (count, op) /* Transpose the words at point. If point is at the end of the line, transpose the two words before point. */ int -rl_transpose_words (count, key) - int count, key; +rl_transpose_words (int count, int key) { char *word1, *word2; int w1_beg, w1_end, w2_beg, w2_end; @@ -1524,8 +1478,7 @@ rl_transpose_words (count, key) /* Transpose the characters at point. If point is at the end of the line, then transpose the characters before point. */ int -rl_transpose_chars (count, key) - int count, key; +rl_transpose_chars (int count, int key) { #if defined (HANDLE_MULTIBYTE) char *dummy; @@ -1589,13 +1542,9 @@ rl_transpose_chars (count, key) int #if defined (HANDLE_MULTIBYTE) -_rl_char_search_internal (count, dir, smbchar, len) - int count, dir; - char *smbchar; - int len; +_rl_char_search_internal (int count, int dir, char *smbchar, int len) #else -_rl_char_search_internal (count, dir, schar) - int count, dir, schar; +_rl_char_search_internal (int count, int dir, int schar) #endif { int pos, inc; @@ -1659,8 +1608,7 @@ _rl_char_search_internal (count, dir, schar) that there are two separate versions of this function. */ #if defined (HANDLE_MULTIBYTE) static int -_rl_char_search (count, fdir, bdir) - int count, fdir, bdir; +_rl_char_search (int count, int fdir, int bdir) { char mbchar[MB_LEN_MAX]; int mb_len; @@ -1677,8 +1625,7 @@ _rl_char_search (count, fdir, bdir) } #else /* !HANDLE_MULTIBYTE */ static int -_rl_char_search (count, fdir, bdir) - int count, fdir, bdir; +_rl_char_search (int count, int fdir, int bdir) { int c; @@ -1709,8 +1656,7 @@ _rl_char_search_callback (data) #endif int -rl_char_search (count, key) - int count, key; +rl_char_search (int count, int key) { #if defined (READLINE_CALLBACKS) if (RL_ISSTATE (RL_STATE_CALLBACK)) @@ -1727,8 +1673,7 @@ rl_char_search (count, key) } int -rl_backward_char_search (count, key) - int count, key; +rl_backward_char_search (int count, int key) { #if defined (READLINE_CALLBACKS) if (RL_ISSTATE (RL_STATE_CALLBACK)) @@ -1752,8 +1697,7 @@ rl_backward_char_search (count, key) /* Set the mark at POSITION. */ int -_rl_set_mark_at_pos (position) - int position; +_rl_set_mark_at_pos (int position) { if (position > rl_end) return 1; @@ -1764,16 +1708,14 @@ _rl_set_mark_at_pos (position) /* A bindable command to set the mark. */ int -rl_set_mark (count, key) - int count, key; +rl_set_mark (int count, int key) { return (_rl_set_mark_at_pos (rl_explicit_arg ? count : rl_point)); } /* Exchange the position of mark and point. */ int -rl_exchange_point_and_mark (count, key) - int count, key; +rl_exchange_point_and_mark (int count, int key) { if (rl_mark > rl_end) rl_mark = -1; diff --git a/lib/readline/undo.c b/lib/readline/undo.c index 58363040..75874e5d 100644 --- a/lib/readline/undo.c +++ b/lib/readline/undo.c @@ -1,6 +1,6 @@ /* undo.c - manage list of changes to lines, offering opportunity to undo them */ -/* 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. @@ -68,10 +68,7 @@ UNDO_LIST *rl_undo_list = (UNDO_LIST *)NULL; /* **************************************************************** */ static UNDO_LIST * -alloc_undo_entry (what, start, end, text) - enum undo_code what; - int start, end; - char *text; +alloc_undo_entry (enum undo_code what, int start, int end, char *text) { UNDO_LIST *temp; @@ -88,10 +85,7 @@ alloc_undo_entry (what, start, end, text) /* Remember how to undo something. Concatenate some undos if that seems right. */ void -rl_add_undo (what, start, end, text) - enum undo_code what; - int start, end; - char *text; +rl_add_undo (enum undo_code what, int start, int end, char *text) { UNDO_LIST *temp; @@ -102,8 +96,7 @@ rl_add_undo (what, start, end, text) /* Free an UNDO_LIST */ void -_rl_free_undo_list (ul) - UNDO_LIST *ul; +_rl_free_undo_list (UNDO_LIST *ul) { UNDO_LIST *release; @@ -121,7 +114,7 @@ _rl_free_undo_list (ul) /* Free the existing undo list. */ void -rl_free_undo_list () +rl_free_undo_list (void) { UNDO_LIST *release, *orig_list; @@ -132,8 +125,7 @@ rl_free_undo_list () } UNDO_LIST * -_rl_copy_undo_entry (entry) - UNDO_LIST *entry; +_rl_copy_undo_entry (UNDO_LIST *entry) { UNDO_LIST *new; @@ -143,8 +135,7 @@ _rl_copy_undo_entry (entry) } UNDO_LIST * -_rl_copy_undo_list (head) - UNDO_LIST *head; +_rl_copy_undo_list (UNDO_LIST *head) { UNDO_LIST *list, *new, *roving, *c; @@ -173,7 +164,7 @@ _rl_copy_undo_list (head) /* Undo the next thing in the list. Return 0 if there is nothing to undo, or non-zero if there was. */ int -rl_do_undo () +rl_do_undo (void) { UNDO_LIST *release; int waiting_for_begin, start, end; @@ -255,8 +246,7 @@ rl_do_undo () #undef TRANS int -_rl_fix_last_undo_of_type (type, start, end) - int type, start, end; +_rl_fix_last_undo_of_type (int type, int start, int end) { UNDO_LIST *rl; @@ -274,7 +264,7 @@ _rl_fix_last_undo_of_type (type, start, end) /* Begin a group. Subsequent undos are undone as an atomic operation. */ int -rl_begin_undo_group () +rl_begin_undo_group (void) { rl_add_undo (UNDO_BEGIN, 0, 0, 0); _rl_undo_group_level++; @@ -283,7 +273,7 @@ rl_begin_undo_group () /* End an undo group started with rl_begin_undo_group (). */ int -rl_end_undo_group () +rl_end_undo_group (void) { rl_add_undo (UNDO_END, 0, 0, 0); _rl_undo_group_level--; @@ -292,8 +282,7 @@ rl_end_undo_group () /* Save an undo entry for the text from START to END. */ int -rl_modifying (start, end) - int start, end; +rl_modifying (int start, int end) { if (start > end) { @@ -313,8 +302,7 @@ rl_modifying (start, end) /* Revert the current line to its previous state. */ int -rl_revert_line (count, key) - int count, key; +rl_revert_line (int count, int key) { if (rl_undo_list == 0) rl_ding (); @@ -333,8 +321,7 @@ rl_revert_line (count, key) /* Do some undoing of things that were done. */ int -rl_undo_command (count, key) - int count, key; +rl_undo_command (int count, int key) { if (count < 0) return 0; /* Nothing to do. */ diff --git a/lib/readline/util.c b/lib/readline/util.c index 4589c61f..23e4edde 100644 --- a/lib/readline/util.c +++ b/lib/readline/util.c @@ -1,6 +1,6 @@ /* util.c -- readline utility functions */ -/* 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. @@ -70,8 +70,7 @@ int _rl_allow_pathname_alphabetic_chars = 0; static const char * const pathname_alphabetic_chars = "/-_=~.#$"; int -rl_alphabetic (c) - int c; +rl_alphabetic (int c) { if (ALPHABETIC (c)) return (1); @@ -97,7 +96,7 @@ _rl_walphabetic (wchar_t wc) /* How to abort things. */ int -_rl_abort_internal () +_rl_abort_internal (void) { rl_ding (); rl_clear_message (); @@ -117,22 +116,19 @@ _rl_abort_internal () } int -rl_abort (count, key) - int count, key; +rl_abort (int count, int key) { return (_rl_abort_internal ()); } int -_rl_null_function (count, key) - int count, key; +_rl_null_function (int count, int key) { return 0; } int -rl_tty_status (count, key) - int count, key; +rl_tty_status (int count, int key) { #if defined (TIOCSTAT) ioctl (1, TIOCSTAT, (char *)0); @@ -146,8 +142,7 @@ rl_tty_status (count, key) /* Return a copy of the string between FROM and TO. FROM is inclusive, TO is not. */ char * -rl_copy_text (from, to) - int from, to; +rl_copy_text (int from, int to) { register int length; char *copy; @@ -166,8 +161,7 @@ rl_copy_text (from, to) /* Increase the size of RL_LINE_BUFFER until it has enough space to hold LEN characters. */ void -rl_extend_line_buffer (len) - int len; +rl_extend_line_buffer (int len) { while (len >= rl_line_buffer_len) { @@ -181,8 +175,7 @@ rl_extend_line_buffer (len) /* A function for simple tilde expansion. */ int -rl_tilde_expand (ignore, key) - int ignore, key; +rl_tilde_expand (int ignore, int key) { register int start, end; char *homedir, *temp; @@ -324,8 +317,7 @@ _rl_errmsg (format, arg1, arg2) /* Determine if s2 occurs in s1. If so, return a pointer to the match in s1. The compare is case insensitive. */ char * -_rl_strindex (s1, s2) - register const char *s1, *s2; +_rl_strindex (const char *s1, const char *s2) { register int i, l, len; @@ -339,8 +331,7 @@ _rl_strindex (s1, s2) /* Find the first occurrence in STRING1 of any character from STRING2. Return a pointer to the character in STRING1. */ char * -_rl_strpbrk (string1, string2) - const char *string1, *string2; +_rl_strpbrk (const char *string1, const char *string2) { register const char *scan; #if defined (HANDLE_MULTIBYTE) @@ -374,10 +365,7 @@ _rl_strpbrk (string1, string2) /* Compare at most COUNT characters from string1 to string2. Case doesn't matter (strncasecmp). */ int -_rl_strnicmp (string1, string2, count) - const char *string1; - const char *string2; - int count; +_rl_strnicmp (const char *string1, const char *string2, int count) { register const char *s1; register const char *s2; @@ -404,9 +392,7 @@ _rl_strnicmp (string1, string2, count) /* strcmp (), but caseless (strcasecmp). */ int -_rl_stricmp (string1, string2) - const char *string1; - const char *string2; +_rl_stricmp (const char *string1, const char *string2) { register const char *s1; register const char *s2; @@ -431,8 +417,7 @@ _rl_stricmp (string1, string2) /* Stupid comparison routine for qsort () ing strings. */ int -_rl_qsort_string_compare (s1, s2) - char **s1, **s2; +_rl_qsort_string_compare (char **s1, char **s2) { #if defined (HAVE_STRCOLL) return (strcoll (*s1, *s2)); @@ -448,7 +433,7 @@ _rl_qsort_string_compare (s1, s2) } /* Function equivalents for the macros defined in chardefs.h. */ -#define FUNCTION_FOR_MACRO(f) int (f) (c) int c; { return f (c); } +#define FUNCTION_FOR_MACRO(f) int (f) (int c) { return f (c); } FUNCTION_FOR_MACRO (_rl_digit_p) FUNCTION_FOR_MACRO (_rl_digit_value) @@ -461,8 +446,7 @@ FUNCTION_FOR_MACRO (_rl_uppercase_p) /* A convenience function, to force memory deallocation to be performed by readline. DLLs on Windows apparently require this. */ void -rl_free (mem) - void *mem; +rl_free (void *mem) { if (mem) free (mem); @@ -472,8 +456,7 @@ rl_free (mem) all `public' readline header files. */ #undef _rl_savestring char * -_rl_savestring (s) - const char *s; +_rl_savestring (const char *s) { return (strcpy ((char *)xmalloc (1 + (int)strlen (s)), (s))); } @@ -512,7 +495,7 @@ _rl_trace (va_alist) } int -_rl_tropen () +_rl_tropen (void) { char fnbuf[128], *x; @@ -525,14 +508,14 @@ _rl_tropen () #else x = "/var/tmp"; #endif - sprintf (fnbuf, "%s/rltrace.%ld", x, (long)getpid()); + snprintf (fnbuf, sizeof (fnbuf), "%s/rltrace.%ld", x, (long)getpid()); unlink(fnbuf); _rl_tracefp = fopen (fnbuf, "w+"); return _rl_tracefp != 0; } int -_rl_trclose () +_rl_trclose (void) { int r; @@ -542,8 +525,7 @@ _rl_trclose () } void -_rl_settracefp (fp) - FILE *fp; +_rl_settracefp (FILE *fp) { _rl_tracefp = fp; } @@ -559,8 +541,7 @@ _rl_settracefp (fp) /* Report STRING to the audit system. */ void -_rl_audit_tty (string) - char *string; +_rl_audit_tty (char *string) { struct audit_message req; struct sockaddr_nl addr; diff --git a/lib/readline/xfree.c b/lib/readline/xfree.c index 37a81e6c..c199b29b 100644 --- a/lib/readline/xfree.c +++ b/lib/readline/xfree.c @@ -1,6 +1,6 @@ /* xfree.c -- safe version of free that ignores attempts to free NUL */ -/* Copyright (C) 1991-2010 Free Software Foundation, Inc. +/* Copyright (C) 1991-2010,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 @@ /* Use this as the function to call when adding unwind protects so we don't need to know what free() returns. */ void -xfree (string) - PTR_T string; +xfree (PTR_T string) { if (string) free (string); diff --git a/shell.c b/shell.c index 17962a99..5618f1c0 100644 --- a/shell.c +++ b/shell.c @@ -1238,6 +1238,7 @@ maybe_make_restricted (name) temp++; if (restricted || (STREQ (temp, RESTRICTED_SHELL_NAME))) { + stupidly_hack_special_variables ("PATH"); /* clear hash table */ set_var_read_only ("PATH"); set_var_read_only ("SHELL"); set_var_read_only ("ENV"); diff --git a/subst.c b/subst.c index 21c3c729..dd8e5bc1 100644 --- a/subst.c +++ b/subst.c @@ -215,8 +215,11 @@ static WORD_DESC expand_wdesc_error, expand_wdesc_fatal; static char expand_param_error, expand_param_fatal, expand_param_unset; static char extract_string_error, extract_string_fatal; -/* Set by expand_word_unsplit; used to inhibit splitting and re-joining - $* on $IFS, primarily when doing assignment statements. */ +/* Set by expand_word_unsplit and several of the expand_string_XXX functions; + used to inhibit splitting and re-joining $* on $IFS, primarily when doing + assignment statements. The idea is that if we're in a context where this + is set, we're not going to be performing word splitting, so we use the same + rules to expand $* as we would if it appeared within double quotes. */ static int expand_no_split_dollar_star = 0; /* A WORD_LIST of words to be expanded by expand_word_list_internal, @@ -232,7 +235,8 @@ static inline char *expand_string_to_string_internal __P((char *, int, EXPFUNC * static WORD_LIST *call_expand_word_internal __P((WORD_DESC *, int, int, int *, int *)); static WORD_LIST *expand_string_internal __P((char *, int)); static WORD_LIST *expand_string_leave_quoted __P((char *, int)); -static WORD_LIST *expand_string_for_rhs __P((char *, int, int *, int *)); +static WORD_LIST *expand_string_for_rhs __P((char *, int, int, int *, int *)); +static WORD_LIST *expand_string_for_pat __P((char *, int, int *, int *)); static WORD_LIST *list_quote_escapes __P((WORD_LIST *)); static WORD_LIST *list_dequote_escapes __P((WORD_LIST *)); @@ -3817,7 +3821,40 @@ expand_string_leave_quoted (string, quoted) /* This does not perform word splitting or dequote the WORD_LIST it returns. */ static WORD_LIST * -expand_string_for_rhs (string, quoted, dollar_at_p, expanded_p) +expand_string_for_rhs (string, quoted, op, dollar_at_p, expanded_p) + char *string; + int quoted, op; + int *dollar_at_p, *expanded_p; +{ + WORD_DESC td; + WORD_LIST *tresult; + + if (string == 0 || *string == '\0') + return (WORD_LIST *)NULL; + + /* We want field splitting to be determined by what is going to be done with + the entire ${parameterOPword} expansion, so we don't want to split the RHS + we expand here. However, the expansion of $* is determined by whether we + are going to eventually perform word splitting, so we want to set this + depending on whether or not are are going to be splitting: if the expansion + is quoted, if the OP is `=', or if IFS is set to the empty string, we + are not going to be splitting, so we set expand_no_split_dollar_star to + 1. This may need additional changes depending on whether or not this is + on the RHS of an assignment statement. */ + /* The updated treatment of $* is the result of Posix interp 888 */ + expand_no_split_dollar_star = (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) || op == '=' || ifs_is_null == 0; + td.flags = W_NOSPLIT2; /* no splitting, remove "" and '' */ + td.word = string; + tresult = call_expand_word_internal (&td, quoted, 1, dollar_at_p, expanded_p); + expand_no_split_dollar_star = 0; + + return (tresult); +} + +/* This does not perform word splitting or dequote the WORD_LIST + it returns and it treats $* as if it were quoted. */ +static WORD_LIST * +expand_string_for_pat (string, quoted, dollar_at_p, expanded_p) char *string; int quoted, *dollar_at_p, *expanded_p; { @@ -4907,9 +4944,9 @@ getpattern (value, quoted, expandpat) } #endif - /* expand_string_for_rhs () leaves WORD quoted and does not perform + /* expand_string_for_pat () leaves WORD quoted and does not perform word splitting. */ - l = *value ? expand_string_for_rhs (value, + l = *value ? expand_string_for_pat (value, (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) ? Q_PATQUOTE : quoted, (int *)NULL, (int *)NULL) : (WORD_LIST *)0; @@ -5982,6 +6019,8 @@ process_substitute (string, open_for_read_in_child) parent. */ expanding_redir = 0; + remove_quoted_escapes (string); + subshell_level++; result = parse_and_execute (string, "process substitution", (SEVAL_NONINT|SEVAL_NOHIST)); /* leave subshell level intact for any exit trap */ @@ -6807,9 +6846,9 @@ parameter_brace_expand_indir (name, var_is_special, quoted, quoted_dollar_atp, c "-", "+", or "=". QUOTED is true if the entire brace expression occurs between double quotes. */ static WORD_DESC * -parameter_brace_expand_rhs (name, value, c, quoted, pflags, qdollaratp, hasdollarat) +parameter_brace_expand_rhs (name, value, op, quoted, pflags, qdollaratp, hasdollarat) char *name, *value; - int c, quoted, pflags, *qdollaratp, *hasdollarat; + int op, quoted, pflags, *qdollaratp, *hasdollarat; { WORD_DESC *w; WORD_LIST *l; @@ -6831,7 +6870,7 @@ parameter_brace_expand_rhs (name, value, c, quoted, pflags, qdollaratp, hasdolla w = alloc_word_desc (); l_hasdollat = 0; /* XXX was 0 not quoted */ - l = *temp ? expand_string_for_rhs (temp, quoted, &l_hasdollat, (int *)NULL) + l = *temp ? expand_string_for_rhs (temp, quoted, op, &l_hasdollat, (int *)NULL) : (WORD_LIST *)0; if (hasdollarat) *hasdollarat = l_hasdollat || (l && l->next); @@ -6903,13 +6942,13 @@ parameter_brace_expand_rhs (name, value, c, quoted, pflags, qdollaratp, hasdolla else temp = (char *)NULL; - if (c == '-' || c == '+') + if (op == '-' || op == '+') { w->word = temp; return w; } - /* c == '=' */ + /* op == '=' */ t = temp ? savestring (temp) : savestring (""); t1 = dequote_string (t); free (t); diff --git a/tests/dollar-at-star b/tests/dollar-at-star index 2d2a1b66..e04c24bb 100755 --- a/tests/dollar-at-star +++ b/tests/dollar-at-star @@ -271,4 +271,9 @@ ${THIS_SH} ./dollar-star6.sub # problem through bash-4.2 ${THIS_SH} ./dollar-star7.sub +# tests for expansions of $* (unquoted) when IFS is null and word splitting is +# not going to be performed. +# problem through bash-4.4 in some parameter expansion contexts +${THIS_SH} ./dollar-star8.sub + exit 0 diff --git a/tests/dollar-at-star4.sub b/tests/dollar-at-star4.sub index 690eb677..be2892dd 100644 --- a/tests/dollar-at-star4.sub +++ b/tests/dollar-at-star4.sub @@ -33,10 +33,12 @@ unset a unset IFS set a b "c d" printf '<%s>' $* ; echo +printf '<%s>' ${q-$*} ; echo IFS= set a b "c d" printf '<%s>' $* ; echo +printf '<%s>' ${q-$*} ; echo IFS=: set a b diff --git a/tests/dollar-star8.sub b/tests/dollar-star8.sub new file mode 100644 index 00000000..72ba1080 --- /dev/null +++ b/tests/dollar-star8.sub @@ -0,0 +1,21 @@ +IFS= +set "abc" "def ghi" "jkl" + +set ${1+$*} +printf '<%s>\n' "$#" "$@" + +set "abc" "def ghi" "jkl" +set $* +printf '<%s>\n' "$#" "$@" + +printf '<%s>\n' $* ; +printf '<%s>\n' ${q:-$*} +printf '<%s>\n' "${q:-$*}" + +IFS=: +printf '<%s>\n' $* ; +printf '<%s>\n' ${q:-$*} +printf '<%s>\n' "${q:-$*}" + +unset -v IFS +printf '<%s>\n' $* $@ diff --git a/tests/dollar.right b/tests/dollar.right index 1e48c24e..26e58ab9 100644 --- a/tests/dollar.right +++ b/tests/dollar.right @@ -177,6 +177,8 @@ ab a b a b + + @@ -478,3 +480,33 @@ argv[2] = argv[3] = argv[4] = argv[1] = +<3> + + + +<3> + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/exp.right b/tests/exp.right index 96617397..3c768053 100644 --- a/tests/exp.right +++ b/tests/exp.right @@ -210,11 +210,13 @@ argv[1] = argv[2] = argv[1] = argv[2] = +./exp7.sub: line 5: INFORM: dequote_string: string with bare CTLESC argv[1] = <^A> argv[1] = <3> argv[2] = <^C> argv[3] = <^C> argv[4] = <^C> +./exp7.sub: line 10: INFORM: dequote_string: string with bare CTLESC argv[1] = <^A> argv[1] = argv[1] = @@ -291,7 +293,9 @@ var=abc:def ghi:jkl abcdef ghijkl abcdef ghijkl abcdef ghijkl -abcdef ghijkl +abc +def ghi +jkl abcdef ghijkl abcdef ghijkl abcdef ghijkl diff --git a/variables.c b/variables.c index eb0eb0f3..e1ab03a4 100644 --- a/variables.c +++ b/variables.c @@ -451,15 +451,12 @@ initialize_shell_variables (env, privmode) /* Now make our own defaults in case the vars that we think are important are missing. */ +#if defined (STATIC_PATH_VALUE) + temp_var = bind_variable ("PATH", STATIC_PATH_VALUE, 0); +#else temp_var = set_if_not ("PATH", DEFAULT_PATH_VALUE); -#if 0 - set_auto_export (temp_var); /* XXX */ #endif - temp_var = set_if_not ("TERM", "dumb"); -#if 0 - set_auto_export (temp_var); /* XXX */ -#endif #if defined (__QNX__) /* set node id -- don't import it from the environment */