second set of ANSI C changes: C89-style function declarations, more inline functions, remove register keyword

This commit is contained in:
Chet Ramey
2023-01-03 10:23:11 -05:00
parent 81e3a4fb07
commit a61ffa78ed
85 changed files with 2867 additions and 5479 deletions
+150 -223
View File
@@ -71,7 +71,7 @@
#if defined (JOB_CONTROL)
# include "jobs.h"
#else
extern int cleanup_dead_jobs PARAMS((void));
extern int cleanup_dead_jobs (void);
#endif /* JOB_CONTROL */
#if defined (ALIAS)
@@ -144,87 +144,87 @@ extern int errno;
/* **************************************************************** */
#ifdef DEBUG
static void debug_parser PARAMS((int));
static void debug_parser (int);
#endif
static int yy_getc PARAMS((void));
static int yy_ungetc PARAMS((int));
static int yy_getc (void);
static int yy_ungetc (int);
#if defined (READLINE)
static int yy_readline_get PARAMS((void));
static int yy_readline_unget PARAMS((int));
static int yy_readline_get (void);
static int yy_readline_unget (int);
#endif
static int yy_string_get PARAMS((void));
static int yy_string_unget PARAMS((int));
static int yy_stream_get PARAMS((void));
static int yy_stream_unget PARAMS((int));
static int yy_string_get (void);
static int yy_string_unget (int);
static int yy_stream_get (void);
static int yy_stream_unget (int);
static int shell_getc PARAMS((int));
static void shell_ungetc PARAMS((int));
static void discard_until PARAMS((int));
static int shell_getc (int);
static void shell_ungetc (int);
static void discard_until (int);
static void push_string PARAMS((char *, int, alias_t *));
static void pop_string PARAMS((void));
static void free_string_list PARAMS((void));
static void push_string (char *, int, alias_t *);
static void pop_string (void);
static void free_string_list (void);
static char *read_a_line PARAMS((int));
static char *read_a_line (int);
static int reserved_word_acceptable PARAMS((int));
static int yylex PARAMS((void));
static int reserved_word_acceptable (int);
static int yylex (void);
static void push_heredoc PARAMS((REDIRECT *));
static char *mk_alexpansion PARAMS((char *));
static int alias_expand_token PARAMS((char *));
static int time_command_acceptable PARAMS((void));
static int special_case_tokens PARAMS((char *));
static int read_token PARAMS((int));
static char *parse_matched_pair PARAMS((int, int, int, int *, int));
static char *parse_comsub PARAMS((int, int, int, int *, int));
static void push_heredoc (REDIRECT *);
static char *mk_alexpansion (char *);
static int alias_expand_token (char *);
static int time_command_acceptable (void);
static int special_case_tokens (char *);
static int read_token (int);
static char *parse_matched_pair (int, int, int, int *, int);
static char *parse_comsub (int, int, int, int *, int);
#if defined (ARRAY_VARS)
static char *parse_compound_assignment PARAMS((int *));
static char *parse_compound_assignment (int *);
#endif
#if defined (DPAREN_ARITHMETIC) || defined (ARITH_FOR_COMMAND)
static int parse_dparen PARAMS((int));
static int parse_arith_cmd PARAMS((char **, int));
static int parse_dparen (int);
static int parse_arith_cmd (char **, int);
#endif
#if defined (COND_COMMAND)
static void cond_error PARAMS((void));
static COND_COM *cond_expr PARAMS((void));
static COND_COM *cond_or PARAMS((void));
static COND_COM *cond_and PARAMS((void));
static COND_COM *cond_term PARAMS((void));
static int cond_skip_newlines PARAMS((void));
static COMMAND *parse_cond_command PARAMS((void));
static void cond_error (void);
static COND_COM *cond_expr (void);
static COND_COM *cond_or (void);
static COND_COM *cond_and (void);
static COND_COM *cond_term (void);
static int cond_skip_newlines (void);
static COMMAND *parse_cond_command (void);
#endif
#if defined (ARRAY_VARS)
static int token_is_assignment PARAMS((char *, int));
static int token_is_ident PARAMS((char *, int));
static int token_is_assignment (char *, int);
static int token_is_ident (char *, int);
#endif
static int read_token_word PARAMS((int));
static void discard_parser_constructs PARAMS((int));
static int read_token_word (int);
static void discard_parser_constructs (int);
static char *error_token_from_token PARAMS((int));
static char *error_token_from_text PARAMS((void));
static void print_offending_line PARAMS((void));
static void report_syntax_error PARAMS((char *));
static char *error_token_from_token (int);
static char *error_token_from_text (void);
static void print_offending_line (void);
static void report_syntax_error (char *);
static void handle_eof_input_unit PARAMS((void));
static void prompt_again PARAMS((int));
static void handle_eof_input_unit (void);
static void prompt_again (int);
#if 0
static void reset_readline_prompt PARAMS((void));
static void reset_readline_prompt (void);
#endif
static void print_prompt PARAMS((void));
static void print_prompt (void);
#if defined (HANDLE_MULTIBYTE)
static void set_line_mbstate PARAMS((void));
static void set_line_mbstate (void);
static char *shell_input_line_property = NULL;
static size_t shell_input_line_propsize = 0;
#else
# define set_line_mbstate()
#endif
extern int yyerror PARAMS((const char *));
extern int yyerror (const char *);
#ifdef DEBUG
extern int yydebug;
@@ -1397,8 +1397,7 @@ int EOF_Reached = 0;
#ifdef DEBUG
static void
debug_parser (i)
int i;
debug_parser (int i)
{
#if YYDEBUG != 0
yydebug = i;
@@ -1418,7 +1417,7 @@ debug_parser (i)
/* Unconditionally returns end-of-file. */
int
return_EOF ()
return_EOF (void)
{
return (EOF);
}
@@ -1430,7 +1429,7 @@ BASH_INPUT bash_input;
/* Set all of the fields in BASH_INPUT to NULL. Free bash_input.name if it
is non-null, avoiding a memory leak. */
void
initialize_bash_input ()
initialize_bash_input (void)
{
bash_input.type = st_none;
FREE (bash_input.name);
@@ -1444,12 +1443,7 @@ initialize_bash_input ()
/* Set the contents of the current bash input stream from
GET, UNGET, TYPE, NAME, and LOCATION. */
void
init_yy_io (get, unget, type, name, location)
sh_cget_func_t *get;
sh_cunget_func_t *unget;
enum stream_type type;
const char *name;
INPUT_STREAM location;
init_yy_io (sh_cget_func_t *get, sh_cunget_func_t *unget, enum stream_type type, const char *name, INPUT_STREAM location)
{
bash_input.type = type;
FREE (bash_input.name);
@@ -1466,14 +1460,14 @@ init_yy_io (get, unget, type, name, location)
}
char *
yy_input_name ()
yy_input_name (void)
{
return (bash_input.name ? bash_input.name : "stdin");
}
/* Call this to get the next character of input. */
static int
yy_getc ()
yy_getc (void)
{
return (*(bash_input.getter)) ();
}
@@ -1481,8 +1475,7 @@ yy_getc ()
/* Call this to unget C. That is, to make C the next character
to be read. */
static int
yy_ungetc (c)
int c;
yy_ungetc (int c)
{
return (*(bash_input.ungetter)) (c);
}
@@ -1490,7 +1483,7 @@ yy_ungetc (c)
#if defined (BUFFERED_INPUT)
#ifdef INCLUDE_UNUSED
int
input_file_descriptor ()
input_file_descriptor (void)
{
switch (bash_input.type)
{
@@ -1518,7 +1511,7 @@ char *current_readline_line = (char *)NULL;
int current_readline_line_index = 0;
static int
yy_readline_get ()
yy_readline_get (void)
{
SigHandler *old_sigint;
int line_len;
@@ -1581,8 +1574,7 @@ yy_readline_get ()
}
static int
yy_readline_unget (c)
int c;
yy_readline_unget (int c)
{
if (current_readline_line_index && current_readline_line)
current_readline_line[--current_readline_line_index] = c;
@@ -1590,7 +1582,7 @@ yy_readline_unget (c)
}
void
with_input_from_stdin ()
with_input_from_stdin (void)
{
INPUT_STREAM location;
@@ -1607,7 +1599,7 @@ with_input_from_stdin ()
embed a newline in the middle of the line it collects, which the parser
will interpret as a line break and command delimiter. */
int
parser_will_prompt ()
parser_will_prompt (void)
{
return (current_readline_line == 0 || current_readline_line[current_readline_line_index] == 0);
}
@@ -1615,7 +1607,7 @@ parser_will_prompt ()
#else /* !READLINE */
void
with_input_from_stdin ()
with_input_from_stdin (void)
{
with_input_from_stream (stdin, "stdin");
}
@@ -1628,7 +1620,7 @@ with_input_from_stdin ()
/* **************************************************************** */
static int
yy_string_get ()
yy_string_get (void)
{
register char *string;
register unsigned char c;
@@ -1647,17 +1639,14 @@ yy_string_get ()
}
static int
yy_string_unget (c)
int c;
yy_string_unget (int c)
{
*(--bash_input.location.string) = c;
return (c);
}
void
with_input_from_string (string, name)
char *string;
const char *name;
with_input_from_string (char *string, const char *name)
{
INPUT_STREAM location;
@@ -1671,7 +1660,7 @@ with_input_from_string (string, name)
that number of characters, so it points to the last character actually
consumed by the parser. */
void
rewind_input_string ()
rewind_input_string (void)
{
int xchars;
@@ -1705,7 +1694,7 @@ rewind_input_string ()
We will need to restart it ourselves. */
static int
yy_stream_get ()
yy_stream_get (void)
{
int result;
@@ -1720,16 +1709,13 @@ yy_stream_get ()
}
static int
yy_stream_unget (c)
int c;
yy_stream_unget (int c)
{
return (ungetc_with_restart (c, bash_input.location.file));
}
void
with_input_from_stream (stream, name)
FILE *stream;
const char *name;
with_input_from_stream (FILE *stream, const char *name)
{
INPUT_STREAM location;
@@ -1760,8 +1746,7 @@ static int cond_token;
STREAM_SAVER *stream_list = (STREAM_SAVER *)NULL;
void
push_stream (reset_lineno)
int reset_lineno;
push_stream (int reset_lineno)
{
STREAM_SAVER *saver = (STREAM_SAVER *)xmalloc (sizeof (STREAM_SAVER));
@@ -1785,7 +1770,7 @@ push_stream (reset_lineno)
}
void
pop_stream ()
pop_stream (void)
{
if (!stream_list)
EOF_Reached = 1;
@@ -1833,8 +1818,7 @@ pop_stream ()
/* Return 1 if a stream of type TYPE is saved on the stack. */
int
stream_on_stack (type)
enum stream_type type;
stream_on_stack (enum stream_type type)
{
register STREAM_SAVER *s;
@@ -1846,7 +1830,7 @@ stream_on_stack (type)
/* Save the current token state and return it in a malloced array. */
int *
save_token_state ()
save_token_state (void)
{
int *ret;
@@ -1859,8 +1843,7 @@ save_token_state ()
}
void
restore_token_state (ts)
int *ts;
restore_token_state (int *ts)
{
if (ts == 0)
return;
@@ -1918,10 +1901,7 @@ STRING_SAVER *pushed_string_list = (STRING_SAVER *)NULL;
* into S; it is saved and used to prevent infinite recursive expansion.
*/
static void
push_string (s, expand, ap)
char *s;
int expand;
alias_t *ap;
push_string (char *s, int expand, alias_t *ap)
{
STRING_SAVER *temp = (STRING_SAVER *)xmalloc (sizeof (STRING_SAVER));
@@ -1963,7 +1943,7 @@ push_string (s, expand, ap)
* and needs to return to the original input line.
*/
static void
pop_string ()
pop_string (void)
{
STRING_SAVER *t;
@@ -1995,7 +1975,7 @@ pop_string ()
}
static void
free_string_list ()
free_string_list (void)
{
register STRING_SAVER *t, *t1;
@@ -2014,7 +1994,7 @@ free_string_list ()
}
void
free_pushed_string_input ()
free_pushed_string_input (void)
{
#if defined (ALIAS) || defined (DPAREN_ARITHMETIC)
free_string_list ();
@@ -2022,13 +2002,13 @@ free_pushed_string_input ()
}
int
parser_expanding_alias ()
parser_expanding_alias (void)
{
return (expanding_alias ());
}
void
parser_save_alias ()
parser_save_alias (void)
{
#if defined (ALIAS) || defined (DPAREN_ARITHMETIC)
push_string ((char *)NULL, 0, (alias_t *)NULL);
@@ -2039,7 +2019,7 @@ parser_save_alias ()
}
void
parser_restore_alias ()
parser_restore_alias (void)
{
#if defined (ALIAS) || defined (DPAREN_ARITHMETIC)
if (pushed_string_list)
@@ -2053,8 +2033,7 @@ parser_restore_alias ()
/* Before freeing AP, make sure that there aren't any cases of pointer
aliasing that could cause us to reference freed memory later on. */
void
clear_string_list_expander (ap)
alias_t *ap;
clear_string_list_expander (alias_t *ap)
{
register STRING_SAVER *t;
@@ -2067,7 +2046,7 @@ clear_string_list_expander (ap)
#endif
void
clear_shell_input_line ()
clear_shell_input_line (void)
{
if (shell_input_line)
shell_input_line[shell_input_line_index = 0] = '\0';
@@ -2078,8 +2057,7 @@ clear_shell_input_line ()
is non-zero, we remove unquoted \<newline> pairs. This is used by
read_secondary_line to read here documents. */
static char *
read_a_line (remove_quoted_newline)
int remove_quoted_newline;
read_a_line (int remove_quoted_newline)
{
static char *line_buffer = (char *)NULL;
static int buffer_size = 0;
@@ -2169,8 +2147,7 @@ read_a_line (remove_quoted_newline)
newlines quoted with backslashes while reading the line. It is
non-zero unless the delimiter of the here document was quoted. */
char *
read_secondary_line (remove_quoted_newline)
int remove_quoted_newline;
read_secondary_line (int remove_quoted_newline)
{
char *ret;
int n, c;
@@ -2325,8 +2302,7 @@ static int eol_ungetc_lookahead = 0;
static int unquoted_backslash = 0;
static int
shell_getc (remove_quoted_newline)
int remove_quoted_newline;
shell_getc (int remove_quoted_newline)
{
register int i;
int c, truncating, last_was_backslash;
@@ -2733,8 +2709,7 @@ pop_alias:
to change when manipulating shell_input_line. The define for
last_shell_getc_is_singlebyte should take care of it, though. */
static void
shell_ungetc (c)
int c;
shell_ungetc (int c)
{
if (shell_input_line && shell_input_line_index)
shell_input_line[--shell_input_line_index] = c;
@@ -2744,8 +2719,7 @@ shell_ungetc (c)
/* Push S back into shell_input_line; updating shell_input_line_index */
void
shell_ungets (s)
char *s;
shell_ungets (char *s)
{
size_t slen, chars_left;
@@ -2797,7 +2771,7 @@ shell_ungets (s)
}
char *
parser_remaining_input ()
parser_remaining_input (void)
{
if (shell_input_line == 0)
return 0;
@@ -2809,7 +2783,7 @@ parser_remaining_input ()
#ifdef INCLUDE_UNUSED
/* Back the input pointer up by one, effectively `ungetting' a character. */
static void
shell_ungetchar ()
shell_ungetchar (void)
{
if (shell_input_line && shell_input_line_index)
shell_input_line_index--;
@@ -2819,8 +2793,7 @@ shell_ungetchar ()
/* Discard input until CHARACTER is seen, then push that character back
onto the input stream. */
static void
discard_until (character)
int character;
discard_until (int character)
{
int c;
@@ -2832,8 +2805,7 @@ discard_until (character)
}
void
execute_variable_command (command, vname)
char *command, *vname;
execute_variable_command (char *command, char *vname)
{
char *last_lastarg;
sh_parser_state_t ps;
@@ -2854,8 +2826,7 @@ execute_variable_command (command, vname)
}
void
push_token (x)
int x;
push_token (int x)
{
two_tokens_ago = token_before_that;
token_before_that = last_read_token;
@@ -2880,7 +2851,7 @@ static size_t token_buffer_size;
/* Function for yyparse to call. yylex keeps track of
the last two tokens read, and calls read_token. */
static int
yylex ()
yylex (void)
{
if (interactive && (current_token == 0 || current_token == '\n'))
{
@@ -2930,8 +2901,7 @@ static int esacs_needed_count;
static int expecting_in_token;
static void
push_heredoc (r)
REDIRECT *r;
push_heredoc (REDIRECT *r)
{
if (need_here_doc >= HEREDOC_MAX)
{
@@ -2945,7 +2915,7 @@ push_heredoc (r)
}
void
gather_here_documents ()
gather_here_documents (void)
{
int r;
@@ -3043,8 +3013,7 @@ static int open_brace_count;
In a pattern list in a case statement (parser_state & PST_CASEPAT). */
static char *
mk_alexpansion (s)
char *s;
mk_alexpansion (char *s)
{
int l;
char *r;
@@ -3066,8 +3035,7 @@ mk_alexpansion (s)
}
static int
alias_expand_token (tokstr)
char *tokstr;
alias_expand_token (char *tokstr)
{
char *expanded;
alias_t *ap;
@@ -3104,7 +3072,7 @@ alias_expand_token (tokstr)
#endif /* ALIAS */
static int
time_command_acceptable ()
time_command_acceptable (void)
{
#if defined (COMMAND_TIMING)
int i;
@@ -3182,8 +3150,7 @@ time_command_acceptable ()
*/
static int
special_case_tokens (tokstr)
char *tokstr;
special_case_tokens (char *tokstr)
{
/* Posix grammar rule 6 */
if ((last_read_token == WORD) &&
@@ -3307,7 +3274,7 @@ special_case_tokens (tokstr)
/* Called from shell.c when Control-C is typed at top level. Or
by the error rule at top level. */
void
reset_parser ()
reset_parser (void)
{
dstack.delimiter_depth = 0; /* No delimiters found so far. */
open_brace_count = 0;
@@ -3352,7 +3319,7 @@ reset_parser ()
}
void
reset_readahead_token ()
reset_readahead_token (void)
{
if (token_to_read == '\n')
token_to_read = 0;
@@ -3361,8 +3328,7 @@ reset_readahead_token ()
/* Read the next token. Command can be READ (normal operation) or
RESET (to normalize state). */
static int
read_token (command)
int command;
read_token (int command)
{
int character; /* Current character. */
int peek_char; /* Temporary look-ahead character. */
@@ -3667,11 +3633,9 @@ tokword:
static char matched_pair_error;
/* QC == `"' if this construct is within double quotes */
static char *
parse_matched_pair (qc, open, close, lenp, flags)
int qc; /* `"' if this construct is within double quotes */
int open, close;
int *lenp, flags;
parse_matched_pair (int qc, int open, int close, int *lenp, int flags)
{
int count, ch, prevch, tflags;
int nestlen, ttranslen, start_lineno;
@@ -3985,8 +3949,7 @@ parse_dollar_word:
#if defined (DEBUG)
static void
dump_tflags (flags)
int flags;
dump_tflags (int flags)
{
int f;
@@ -4074,12 +4037,9 @@ dump_tflags (flags)
#endif
/* Parse a $(...) command substitution. This reads input from the current
input stream. */
input stream. QC == `"' if this construct is within double quotes */
static char *
parse_comsub (qc, open, close, lenp, flags)
int qc; /* `"' if this construct is within double quotes */
int open, close;
int *lenp, flags;
parse_comsub (int qc, int open, int close, int *lenp, int flags)
{
int peekc, r;
int start_lineno, local_extglob, was_extpat;
@@ -4242,11 +4202,7 @@ INTERNAL_DEBUG(("current_token (%d) != shell_eof_token (%c)", current_token, she
called by the word expansion code and so does not have to reset as much
parser state before calling yyparse(). */
char *
xparse_dolparen (base, string, indp, flags)
char *base;
char *string;
int *indp;
int flags;
xparse_dolparen (char *base, char *string, int *indp, int flags)
{
sh_parser_state_t ps;
sh_input_line_state_t ls;
@@ -4380,9 +4336,7 @@ xparse_dolparen (base, string, indp, flags)
substitution to a COMMAND *. This is called from command_substitute() and
has the same parser state constraints as xparse_dolparen(). */
COMMAND *
parse_string_to_command (string, flags)
char *string;
int flags;
parse_string_to_command (char *string, int flags)
{
sh_parser_state_t ps;
sh_input_line_state_t ls;
@@ -4451,8 +4405,7 @@ parse_string_to_command (string, flags)
the parsed token, -1 on error, or -2 if we didn't do anything and
should just go on. */
static int
parse_dparen (c)
int c;
parse_dparen (int c)
{
int cmdtyp, sline;
char *wval;
@@ -4513,9 +4466,7 @@ parse_dparen (c)
allocated buffer and make *ep point to that buffer. Return -1 on an
error, for example EOF. */
static int
parse_arith_cmd (ep, adddq)
char **ep;
int adddq;
parse_arith_cmd (char **ep, int adddq)
{
int exp_lineno, rval, c;
char *ttok, *tokstr;
@@ -4564,7 +4515,7 @@ parse_arith_cmd (ep, adddq)
#if defined (COND_COMMAND)
static void
cond_error ()
cond_error (void)
{
char *etext;
@@ -4583,13 +4534,13 @@ cond_error ()
}
static COND_COM *
cond_expr ()
cond_expr (void)
{
return (cond_or ());
}
static COND_COM *
cond_or ()
cond_or (void)
{
COND_COM *l, *r;
@@ -4603,7 +4554,7 @@ cond_or ()
}
static COND_COM *
cond_and ()
cond_and (void)
{
COND_COM *l, *r;
@@ -4617,7 +4568,7 @@ cond_and ()
}
static int
cond_skip_newlines ()
cond_skip_newlines (void)
{
while ((cond_token = read_token (READ)) == '\n')
{
@@ -4631,7 +4582,7 @@ cond_skip_newlines ()
do { cond_token = COND_ERROR; return ((COND_COM *)NULL); } while (0)
static COND_COM *
cond_term ()
cond_term (void)
{
WORD_DESC *op;
COND_COM *term, *tleft, *tright;
@@ -4801,7 +4752,7 @@ cond_term ()
/* This is kind of bogus -- we slip a mini recursive-descent parser in
here to handle the conditional statement syntax. */
static COMMAND *
parse_cond_command ()
parse_cond_command (void)
{
COND_COM *cexp;
@@ -4817,9 +4768,7 @@ parse_cond_command ()
substitution that will reallocate atoken. We don't want to write beyond
the end of an allocated buffer. */
static int
token_is_assignment (t, i)
char *t;
int i;
token_is_assignment (char *t, int i)
{
int r;
char *atoken;
@@ -4840,9 +4789,7 @@ token_is_assignment (t, i)
/* XXX - possible changes here for `+=' */
static int
token_is_ident (t, i)
char *t;
int i;
token_is_ident (char *t, int i)
{
unsigned char c;
int r;
@@ -4856,8 +4803,7 @@ token_is_ident (t, i)
#endif
static int
read_token_word (character)
int character;
read_token_word (int character)
{
/* The value for YYLVAL when a WORD is read. */
WORD_DESC *the_word;
@@ -5368,9 +5314,8 @@ got_token:
/* Return 1 if TOKSYM is a token that after being read would allow
a reserved word to be seen, else 0. */
static int
reserved_word_acceptable (toksym)
int toksym;
static inline int
reserved_word_acceptable (int toksym)
{
switch (toksym)
{
@@ -5422,8 +5367,7 @@ reserved_word_acceptable (toksym)
/* Return the index of TOKEN in the alist of reserved words, or -1 if
TOKEN is not a shell reserved word. */
int
find_reserved_word (tokstr)
char *tokstr;
find_reserved_word (char *tokstr)
{
int i;
for (i = 0; word_token_alist[i].word; i++)
@@ -5435,7 +5379,7 @@ find_reserved_word (tokstr)
/* An interface to let the rest of the shell (primarily the completion
system) know what the parser is expecting. */
int
parser_in_command_position ()
parser_in_command_position (void)
{
return (command_token_position (last_read_token));
}
@@ -5446,7 +5390,7 @@ parser_in_command_position ()
the new prompt string is gets propagated to readline's local prompt
variable. */
static void
reset_readline_prompt ()
reset_readline_prompt (void)
{
char *temp_prompt;
@@ -5486,8 +5430,7 @@ static const int no_semi_successors[] = {
history entry. LINE is the line we're about to add; it helps
make some more intelligent decisions in certain cases. */
char *
history_delimiting_chars (line)
const char *line;
history_delimiting_chars (const char *line)
{
static int last_was_heredoc = 0; /* was the last entry the start of a here document? */
register int i;
@@ -5579,8 +5522,7 @@ history_delimiting_chars (line)
/* Issue a prompt, or prepare to issue a prompt when the next character
is read. */
static void
prompt_again (force)
int force;
prompt_again (int force)
{
char *temp_prompt;
@@ -5623,21 +5565,20 @@ prompt_again (force)
}
int
get_current_prompt_level ()
get_current_prompt_level (void)
{
return ((current_prompt_string && current_prompt_string == ps2_prompt) ? 2 : 1);
}
void
set_current_prompt_level (x)
int x;
set_current_prompt_level (int x)
{
prompt_string_pointer = (x == 2) ? &ps2_prompt : &ps1_prompt;
current_prompt_string = *prompt_string_pointer;
}
static void
print_prompt ()
print_prompt (void)
{
fprintf (stderr, "%s", current_decoded_prompt);
fflush (stderr);
@@ -5648,8 +5589,7 @@ print_prompt ()
the first line of a potentially multi-line command, so we compensate
here by returning one fewer when appropriate. */
static int
prompt_history_number (pmt)
char *pmt;
prompt_history_number (char *pmt)
{
int ret;
@@ -5701,8 +5641,7 @@ prompt_history_number (pmt)
*/
#define PROMPT_GROWTH 48
char *
decode_prompt_string (string)
char *string;
decode_prompt_string (char *string)
{
WORD_LIST *list;
char *result, *t, *orig_string;
@@ -6124,8 +6063,7 @@ not_escape:
/* Report a syntax error, and restart the parser. Call here for fatal
errors. */
int
yyerror (msg)
const char *msg;
yyerror (const char *msg)
{
if ((parser_state & PST_NOERROR) == 0)
report_syntax_error ((char *)NULL);
@@ -6134,8 +6072,7 @@ yyerror (msg)
}
static char *
error_token_from_token (tok)
int tok;
error_token_from_token (int tok)
{
char *t;
@@ -6174,7 +6111,7 @@ error_token_from_token (tok)
}
static char *
error_token_from_text ()
error_token_from_text (void)
{
char *msg, *t;
int token_end, i;
@@ -6216,7 +6153,7 @@ error_token_from_text ()
}
static void
print_offending_line ()
print_offending_line (void)
{
char *msg;
int token_end;
@@ -6235,8 +6172,7 @@ print_offending_line ()
then place it in MESSAGE, otherwise pass NULL and this will figure
out an appropriate message for you. */
static void
report_syntax_error (message)
char *message;
report_syntax_error (char *message)
{
char *msg, *p;
@@ -6317,8 +6253,7 @@ report_syntax_error (message)
to throw away the information about where the allocated objects live.
(dispose_command () will actually free the command.) */
static void
discard_parser_constructs (error_p)
int error_p;
discard_parser_constructs (int error_p)
{
}
@@ -6346,7 +6281,7 @@ int eof_encountered_limit = 10;
Otherwise, if ignoreeof is set, and we haven't done this the
required number of times in a row, print a message. */
static void
handle_eof_input_unit ()
handle_eof_input_unit (void)
{
if (interactive)
{
@@ -6401,10 +6336,7 @@ static WORD_LIST parse_string_error;
/* Take a string and run it through the shell parser, returning the
resultant word list. Used by compound array assignment. */
WORD_LIST *
parse_string_to_word_list (s, flags, whom)
char *s;
int flags;
const char *whom;
parse_string_to_word_list (char *s, int flags, const char *whom)
{
WORD_LIST *wl;
int tok, orig_current_token, orig_line_number;
@@ -6487,8 +6419,7 @@ parse_string_to_word_list (s, flags, whom)
}
static char *
parse_compound_assignment (retlenp)
int *retlenp;
parse_compound_assignment (int *retlenp)
{
WORD_LIST *wl, *rl;
int tok, orig_line_number, assignok;
@@ -6576,8 +6507,7 @@ parse_compound_assignment (retlenp)
************************************************/
sh_parser_state_t *
save_parser_state (ps)
sh_parser_state_t *ps;
save_parser_state (sh_parser_state_t *ps)
{
if (ps == 0)
ps = (sh_parser_state_t *)xmalloc (sizeof (sh_parser_state_t));
@@ -6638,8 +6568,7 @@ save_parser_state (ps)
}
void
restore_parser_state (ps)
sh_parser_state_t *ps;
restore_parser_state (sh_parser_state_t *ps)
{
int i;
@@ -6705,8 +6634,7 @@ restore_parser_state (ps)
}
sh_input_line_state_t *
save_input_line_state (ls)
sh_input_line_state_t *ls;
save_input_line_state (sh_input_line_state_t *ls)
{
if (ls == 0)
ls = (sh_input_line_state_t *)xmalloc (sizeof (sh_input_line_state_t));
@@ -6736,8 +6664,7 @@ save_input_line_state (ls)
}
void
restore_input_line_state (ls)
sh_input_line_state_t *ls;
restore_input_line_state (sh_input_line_state_t *ls)
{
FREE (shell_input_line);
shell_input_line = ls->input_line;
@@ -6768,7 +6695,7 @@ restore_input_line_state (ls)
#define MAX_PROPSIZE 32768
static void
set_line_mbstate ()
set_line_mbstate (void)
{
int c;
size_t i, previ, len;