#endif
#include <stdio.h>
+#include "chartypes.h"
#include <signal.h>
#include "memalloc.h"
#include "flags.h"
#include "parser.h"
#include "mailcheck.h"
+#include "test.h"
#include "builtins/common.h"
#include "builtins/builtext.h"
extern int eof_encountered;
extern int no_line_editing, running_under_emacs;
extern int current_command_number;
-extern int interactive, interactive_shell, login_shell;
extern int sourcelevel;
extern int posixly_correct;
extern int last_command_exit_value;
extern char *dist_version;
extern int patch_level;
extern int dump_translatable_strings, dump_po_strings;
-extern Function *last_shell_builtin, *this_shell_builtin;
+extern sh_builtin_func_t *last_shell_builtin, *this_shell_builtin;
#if defined (BUFFERED_INPUT)
extern int bash_input_fd_changed;
#endif
/* */
/* **************************************************************** */
-static char *ansiexpand ();
-static char *localeexpand ();
-static int reserved_word_acceptable ();
-static int read_token ();
-static int yylex ();
-static int parse_arith_cmd ();
+#ifdef DEBUG
+static void debug_parser __P((int));
+#endif
+
+static int yy_getc __P((void));
+static int yy_ungetc __P((int));
+
+#if defined (READLINE)
+static int yy_readline_get __P((void));
+static int yy_readline_unget __P((int));
+#endif
+
+static int yy_string_get __P((void));
+static int yy_string_unget __P((int));
+static int yy_stream_get __P((void));
+static int yy_stream_unget __P((int));
+
+static int shell_getc __P((int));
+static void shell_ungetc __P((int));
+static void discard_until __P((int));
+
+#if defined (ALIAS) || defined (DPAREN_ARITHMETIC)
+static void push_string __P((char *, int, alias_t *));
+static void pop_string __P((void));
+static void free_string_list __P((void));
+#endif
+
+static char *read_a_line __P((int));
+
+static char *ansiexpand __P((char *, int, int, int *));
+static char *mk_msgstr __P((char *, int *));
+static char *localeexpand __P((char *, int, int, int, int *));
+static int reserved_word_acceptable __P((int));
+static int yylex __P((void));
+static int alias_expand_token __P((char *));
+static int time_command_acceptable __P((void));
+static int special_case_tokens __P((char *));
+static int read_token __P((int));
+static char *parse_matched_pair __P((int, int, int, int *, int));
+#if defined (DPAREN_ARITHMETIC) || defined (ARITH_FOR_COMMAND)
+static int parse_arith_cmd __P((char **));
+#endif
#if defined (COND_COMMAND)
-static COMMAND *parse_cond_command ();
+static COND_COM *cond_expr __P((void));
+static COND_COM *cond_or __P((void));
+static COND_COM *cond_and __P((void));
+static COND_COM *cond_term __P((void));
+static int cond_skip_newlines __P((void));
+static COMMAND *parse_cond_command __P((void));
#endif
-static int read_token_word ();
-static void discard_parser_constructs ();
+static int read_token_word __P((int));
+static void discard_parser_constructs __P((int));
-static void report_syntax_error ();
-static void handle_eof_input_unit ();
-static void prompt_again ();
+static void report_syntax_error __P((char *));
+static void handle_eof_input_unit __P((void));
+static void prompt_again __P((void));
#if 0
-static void reset_readline_prompt ();
+static void reset_readline_prompt __P((void));
#endif
-static void print_prompt ();
+static void print_prompt __P((void));
#if defined (HISTORY)
-char *history_delimiting_chars ();
+char *history_delimiting_chars __P((void));
#endif
-extern int yyerror ();
+extern int yyerror __P((const char *));
/* Default prompt strings */
char *primary_prompt = PPROMPT;
}
| GREATER_AND '-'
{
- redir.dest = 0L;
+ redir.dest = 0;
$$ = make_redirection (1, r_close_this, redir);
}
| NUMBER GREATER_AND '-'
{
- redir.dest = 0L;
+ redir.dest = 0;
$$ = make_redirection ($1, r_close_this, redir);
}
| LESS_AND '-'
{
- redir.dest = 0L;
+ redir.dest = 0;
$$ = make_redirection (0, r_close_this, redir);
}
| NUMBER LESS_AND '-'
{
- redir.dest = 0L;
+ redir.dest = 0;
$$ = make_redirection ($1, r_close_this, redir);
}
| AND_GREATER WORD
{ $$ = make_for_command ($2, REVERSE_LIST ($5, WORD_LIST *), $9); }
| FOR WORD newline_list IN word_list list_terminator newline_list '{' compound_list '}'
{ $$ = make_for_command ($2, REVERSE_LIST ($5, WORD_LIST *), $9); }
+ | FOR WORD newline_list IN list_terminator newline_list DO compound_list DONE
+ { $$ = make_for_command ($2, (WORD_LIST *)NULL, $8); }
+ | FOR WORD newline_list IN list_terminator newline_list '{' compound_list '}'
+ { $$ = make_for_command ($2, (WORD_LIST *)NULL, $8); }
;
arith_for_command: FOR ARITH_FOR_EXPRS list_terminator newline_list DO compound_list DONE
/* Global var is non-zero when end of file has been reached. */
int EOF_Reached = 0;
-void
+#ifdef DEBUG
+static void
debug_parser (i)
int i;
{
yydebug = i;
#endif
}
+#endif
/* yy_getc () returns the next available character from input or EOF.
yy_ungetc (c) makes `c' the next character to read.
bash_input.name = (char *)NULL;
bash_input.location.file = (FILE *)NULL;
bash_input.location.string = (char *)NULL;
- bash_input.getter = (Function *)NULL;
- bash_input.ungetter = (Function *)NULL;
+ bash_input.getter = (sh_cget_func_t *)NULL;
+ bash_input.ungetter = (sh_cunget_func_t *)NULL;
}
/* 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)
- Function *get, *unget;
+ sh_cget_func_t *get;
+ sh_cunget_func_t *unget;
enum stream_type type;
- char *name;
+ const char *name;
INPUT_STREAM location;
{
bash_input.type = type;
}
/* Call this to get the next character of input. */
-int
+static int
yy_getc ()
{
return (*(bash_input.getter)) ();
/* Call this to unget C. That is, to make C the next character
to be read. */
-int
+static int
yy_ungetc (c)
int c;
{
}
#if defined (BUFFERED_INPUT)
+#ifdef INCLUDE_UNUSED
int
input_file_descriptor ()
{
return (fileno (stdin));
}
}
+#endif
#endif /* BUFFERED_INPUT */
/* **************************************************************** */
yy_readline_get ()
{
SigHandler *old_sigint;
- int line_len, c;
+ int line_len;
+ unsigned char c;
if (!current_readline_line)
{
give_terminal_to (shell_pgrp, 0);
#endif /* JOB_CONTROL */
+ old_sigint = (SigHandler *)NULL;
if (signal_is_ignored (SIGINT) == 0)
{
old_sigint = (SigHandler *)set_signal_handler (SIGINT, sigint_sighandler);
current_readline_line = readline (current_readline_prompt ?
current_readline_prompt : "");
- if (signal_is_ignored (SIGINT) == 0)
+ if (signal_is_ignored (SIGINT) == 0 && old_sigint)
{
interrupt_immediately--;
set_signal_handler (SIGINT, old_sigint);
current_readline_line_index = 0;
line_len = strlen (current_readline_line);
- current_readline_line = xrealloc (current_readline_line, 2 + line_len);
+ current_readline_line = (char *)xrealloc (current_readline_line, 2 + line_len);
current_readline_line[line_len++] = '\n';
current_readline_line[line_len] = '\0';
}
}
else
{
- c = (unsigned char)current_readline_line[current_readline_line_index++];
+ c = current_readline_line[current_readline_line_index++];
return (c);
}
}
yy_string_get ()
{
register char *string;
- register int c;
+ register unsigned char c;
string = bash_input.location.string;
- c = EOF;
/* If the string doesn't exist, or is empty, EOF found. */
if (string && *string)
{
- c = *(unsigned char *)string++;
+ c = *string++;
bash_input.location.string = string;
+ return (c);
}
- return (c);
+ else
+ return (EOF);
}
static int
void
with_input_from_string (string, name)
- char *string, *name;
+ char *string;
+ const char *name;
{
INPUT_STREAM location;
void
with_input_from_stream (stream, name)
FILE *stream;
- char *name;
+ const char *name;
{
INPUT_STREAM location;
int expand;
alias_t *ap;
{
- STRING_SAVER *temp = (STRING_SAVER *) xmalloc (sizeof (STRING_SAVER));
+ STRING_SAVER *temp = (STRING_SAVER *)xmalloc (sizeof (STRING_SAVER));
temp->expand_alias = expand;
temp->saved_line = shell_input_line;
do \
{ \
if (ds.delimiter_depth + 2 > ds.delimiter_space) \
- ds.delimiters = xrealloc \
+ ds.delimiters = (char *)xrealloc \
(ds.delimiters, (ds.delimiter_space += 10) * sizeof (char)); \
ds.delimiters[ds.delimiter_depth] = character; \
ds.delimiter_depth++; \
{
register int i;
int c;
+ unsigned char uc;
static int mustpop = 0;
QUIT;
if (shell_input_line_terminator != EOF)
{
if (shell_input_line_len + 3 > shell_input_line_size)
- shell_input_line = xrealloc (shell_input_line,
+ shell_input_line = (char *)xrealloc (shell_input_line,
1 + (shell_input_line_size += 2));
shell_input_line[shell_input_line_len] = '\n';
}
}
- c = shell_input_line[shell_input_line_index];
+ uc = shell_input_line[shell_input_line_index];
- if (c)
+ if (uc)
shell_input_line_index++;
- if (c == '\\' && remove_quoted_newline &&
+ if (uc == '\\' && remove_quoted_newline &&
shell_input_line[shell_input_line_index] == '\n')
{
prompt_again ();
}
#if defined (ALIAS) || defined (DPAREN_ARITHMETIC)
- /* If C is NULL, we have reached the end of the current input string. If
+ /* If UC is NULL, we have reached the end of the current input string. If
pushed_string_list is non-empty, it's time to pop to the previous string
because we have fully consumed the result of the last alias expansion.
Do it transparently; just return the next character of the string popped
to. */
- if (!c && (pushed_string_list != (STRING_SAVER *)NULL))
+ if (!uc && (pushed_string_list != (STRING_SAVER *)NULL))
{
if (mustpop)
{
pop_string ();
- c = shell_input_line[shell_input_line_index];
- if (c)
+ uc = shell_input_line[shell_input_line_index];
+ if (uc)
shell_input_line_index++;
mustpop--;
}
else
{
mustpop++;
- c = ' ';
+ uc = ' ';
}
}
#endif /* ALIAS || DPAREN_ARITHMETIC */
- if (!c && shell_input_line_terminator == EOF)
+ if (!uc && shell_input_line_terminator == EOF)
return ((shell_input_line_index != 0) ? '\n' : EOF);
- return ((unsigned char)c);
+ return (uc);
}
/* Put C back into the input for the shell. */
eol_ungetc_lookahead = c;
}
+#ifdef INCLUDE_UNUSED
+/* Back the input pointer up by one, effectively `ungetting' a character. */
static void
shell_ungetchar ()
{
if (shell_input_line && shell_input_line_index)
shell_input_line_index--;
}
+#endif
/* Discard input until CHARACTER is seen, then push that character back
onto the input stream. */
execute_prompt_command (command)
char *command;
{
- Function *temp_last, *temp_this;
+ sh_builtin_func_t *temp_last, *temp_this;
char *last_lastarg;
int temp_exit_value, temp_eof_encountered;
Special cases that disqualify:
In a pattern list in a case statement (parser_state & PST_CASEPAT). */
static int
-alias_expand_token (token)
- char *token;
+alias_expand_token (tokstr)
+ char *tokstr;
{
char *expanded;
alias_t *ap;
if (((parser_state & PST_ALEXPNEXT) || command_token_position (last_read_token)) &&
(parser_state & PST_CASEPAT) == 0)
{
- ap = find_alias (token);
+ ap = find_alias (tokstr);
/* Currently expanding this token. */
if (ap && (ap->flags & AL_BEINGEXPANDED))
*/
static int
-special_case_tokens (token)
- char *token;
+special_case_tokens (tokstr)
+ char *tokstr;
{
if ((last_read_token == WORD) &&
#if defined (SELECT_COMMAND)
#else
((token_before_that == FOR) || (token_before_that == CASE)) &&
#endif
- (token[0] == 'i' && token[1] == 'n' && token[2] == 0))
+ (tokstr[0] == 'i' && tokstr[1] == 'n' && tokstr[2] == 0))
{
if (token_before_that == CASE)
{
#else
(token_before_that == FOR) &&
#endif
- (token[0] == 'd' && token[1] == 'o' && token[2] == '\0'))
+ (tokstr[0] == 'd' && tokstr[1] == 'o' && tokstr[2] == '\0'))
return (DO);
/* Ditto for ESAC in the CASE case.
if (esacs_needed_count)
{
esacs_needed_count--;
- if (STREQ (token, "esac"))
+ if (STREQ (tokstr, "esac"))
{
parser_state &= ~PST_CASEPAT;
return (ESAC);
if (parser_state & PST_ALLOWOPNBRC)
{
parser_state &= ~PST_ALLOWOPNBRC;
- if (token[0] == '{' && token[1] == '\0') /* } */
+ if (tokstr[0] == '{' && tokstr[1] == '\0') /* } */
{
open_brace_count++;
function_bstart = line_number;
/* We allow a `do' after a for ((...)) without an intervening
list_terminator */
- if (last_read_token == ARITH_FOR_EXPRS && token[0] == 'd' && token[1] == 'o' && !token[2])
+ if (last_read_token == ARITH_FOR_EXPRS && tokstr[0] == 'd' && tokstr[1] == 'o' && !tokstr[2])
return (DO);
- if (last_read_token == ARITH_FOR_EXPRS && token[0] == '{' && token[1] == '\0') /* } */
+ if (last_read_token == ARITH_FOR_EXPRS && tokstr[0] == '{' && tokstr[1] == '\0') /* } */
{
open_brace_count++;
return ('{'); /* } */
}
- if (open_brace_count && reserved_word_acceptable (last_read_token) && token[0] == '}' && !token[1])
+ if (open_brace_count && reserved_word_acceptable (last_read_token) && tokstr[0] == '}' && !tokstr[1])
{
open_brace_count--; /* { */
return ('}');
#if defined (COMMAND_TIMING)
/* Handle -p after `time'. */
- if (last_read_token == TIME && token[0] == '-' && token[1] == 'p' && !token[2])
+ if (last_read_token == TIME && tokstr[0] == '-' && tokstr[1] == 'p' && !tokstr[2])
return (TIMEOPT);
#endif
#endif /* COMMAND_TIMING */
#if defined (COND_COMMAND) /* [[ */
- if ((parser_state & PST_CONDEXPR) && token[0] == ']' && token[1] == ']' && token[2] == '\0')
+ if ((parser_state & PST_CONDEXPR) && tokstr[0] == ']' && tokstr[1] == ']' && tokstr[2] == '\0')
return (COND_END);
#endif
/* parse_arith_cmd adds quotes at the beginning and end
of the string it returns; we need to take those out. */
len = strlen (wval);
- wv2 = xmalloc (len);
+ wv2 = (char *)xmalloc (len);
strncpy (wv2, wval + 1, len - 2);
wv2[len - 2] = '\0';
wd = make_word (wv2);
count = 1;
pass_next_character = was_dollar = 0;
- ret = xmalloc (retsize = 64);
+ ret = (char *)xmalloc (retsize = 64);
retind = 0;
start_lineno = line_number;
{
/* Translate $'...' here. */
ttrans = ansiexpand (nestret, 0, nestlen - 1, &ttranslen);
- free (nestret);
+ xfree (nestret);
nestret = sh_single_quote (ttrans);
free (ttrans);
nestlen = strlen (nestret);
{
/* Locale expand $"..." here. */
ttrans = localeexpand (nestret, 0, nestlen - 1, start_lineno, &ttranslen);
- free (nestret);
- nestret = xmalloc (ttranslen + 3);
+ xfree (nestret);
+ nestret = (char *)xmalloc (ttranslen + 3);
nestret[0] = '"';
strcpy (nestret + 1, ttrans);
nestret[ttranslen + 1] = '"';
char **ep;
{
int exp_lineno, rval, c;
- char *ttok, *token;
+ char *ttok, *tokstr;
int ttoklen;
exp_lineno = line_number;
if ((c = shell_getc (0)) != ')')
rval = 0;
- token = xmalloc (ttoklen + 4);
+ tokstr = (char *)xmalloc (ttoklen + 4);
/* (( ... )) -> "..." */
- token[0] = (rval == 1) ? '"' : '(';
- strncpy (token + 1, ttok, ttoklen - 1); /* don't copy the final `)' */
+ tokstr[0] = (rval == 1) ? '"' : '(';
+ strncpy (tokstr + 1, ttok, ttoklen - 1); /* don't copy the final `)' */
if (rval == 1)
{
- token[ttoklen] = '"';
- token[ttoklen+1] = '\0';
+ tokstr[ttoklen] = '"';
+ tokstr[ttoklen+1] = '\0';
}
else
{
- token[ttoklen] = ')';
- token[ttoklen+1] = c;
- token[ttoklen+2] = '\0';
+ tokstr[ttoklen] = ')';
+ tokstr[ttoklen+1] = c;
+ tokstr[ttoklen+2] = '\0';
}
- *ep = token;
+ *ep = tokstr;
FREE (ttok);
return rval;
}
#endif /* DPAREN_ARITHMETIC || ARITH_FOR_COMMAND */
#if defined (COND_COMMAND)
-static COND_COM *cond_term ();
-static COND_COM *cond_and ();
-static COND_COM *cond_or ();
-static COND_COM *cond_expr ();
-
static COND_COM *
cond_expr ()
{
int token_index;
/* ALL_DIGITS becomes zero when we see a non-digit. */
- int all_digits;
+ int all_digit_token;
/* DOLLAR_PRESENT becomes non-zero if we see a `$'. */
int dollar_present;
int result, peek_char;
char *ttok, *ttrans;
int ttoklen, ttranslen;
+ long lvalue;
if (token_buffer_size < TOKEN_DEFAULT_INITIAL_SIZE)
- token = xrealloc (token, token_buffer_size = TOKEN_DEFAULT_INITIAL_SIZE);
+ token = (char *)xrealloc (token, token_buffer_size = TOKEN_DEFAULT_INITIAL_SIZE);
token_index = 0;
- all_digits = isdigit (character);
+ all_digit_token = DIGIT (character);
dollar_present = quoted = pass_next_character = 0;
for (;;)
/* If the next character is to be quoted, note it now. */
if (cd == 0 || cd == '`' ||
- (cd == '"' && (sh_syntaxtab[peek_char] & CBSDQUOTE)))
+ (cd == '"' && peek_char >= 0 && (sh_syntaxtab[peek_char] & CBSDQUOTE)))
pass_next_character++;
quoted = 1;
token[token_index++] = character;
strcpy (token + token_index, ttok);
token_index += ttoklen;
- all_digits = 0;
+ all_digit_token = 0;
quoted = 1;
dollar_present |= (character == '"' && strchr (ttok, '$') != 0);
FREE (ttok);
strcpy (token + token_index, ttok);
token_index += ttoklen;
FREE (ttok);
- dollar_present = all_digits = 0;
+ dollar_present = all_digit_token = 0;
goto next_character;
}
else
token_index += ttoklen;
FREE (ttok);
dollar_present = 1;
- all_digits = 0;
+ all_digit_token = 0;
goto next_character;
}
/* This handles $'...' and $"..." new-style quoted strings. */
free (ttok);
/* Add the double quotes back */
- ttok = xmalloc (ttranslen + 3);
+ ttok = (char *)xmalloc (ttranslen + 3);
ttok[0] = '"';
strcpy (ttok + 1, ttrans);
ttok[ttranslen + 1] = '"';
token_index += ttranslen;
FREE (ttrans);
quoted = 1;
- all_digits = 0;
+ all_digit_token = 0;
goto next_character;
}
/* This could eventually be extended to recognize all of the
shell's single-character parameter expansions, and set flags.*/
else if (character == '$' && peek_char == '$')
{
- ttok = xmalloc (3);
+ ttok = (char *)xmalloc (3);
ttok[0] = ttok[1] = '$';
ttok[2] = '\0';
RESIZE_MALLOCED_BUFFER (token, token_index, 3,
strcpy (token + token_index, ttok);
token_index += 2;
dollar_present = 1;
- all_digits = 0;
+ all_digit_token = 0;
FREE (ttok);
goto next_character;
}
strcpy (token + token_index, ttok);
token_index += ttoklen;
FREE (ttok);
- all_digits = 0;
+ all_digit_token = 0;
goto next_character;
}
else
got_character:
- all_digits &= isdigit (character);
+ all_digit_token &= DIGIT (character);
dollar_present |= character == '$';
if (character == CTLESC || character == CTLNUL)
is a `<', or a `&', or the character which ended this token is
a '>' or '<', then, and ONLY then, is this input token a NUMBER.
Otherwise, it is just a word, and should be returned as such. */
- if (all_digits && (character == '<' || character == '>' ||
+ if (all_digit_token && (character == '<' || character == '>' ||
last_read_token == LESS_AND ||
last_read_token == GREATER_AND))
{
- yylval.number = atoi (token);
+ if (legal_number (token, &lvalue) && (int)lvalue == lvalue)
+ yylval.number = lvalue;
+ else
+ yylval.number = -1;
return (NUMBER);
}
CHECK_FOR_RESERVED_WORD (token);
the_word = (WORD_DESC *)xmalloc (sizeof (WORD_DESC));
- the_word->word = xmalloc (1 + token_index);
+ the_word->word = (char *)xmalloc (1 + token_index);
the_word->flags = 0;
strcpy (the_word->word, token);
if (dollar_present)
char *temp, *t;
int len, tlen;
- temp = xmalloc (end - start + 1);
+ temp = (char *)xmalloc (end - start + 1);
for (tlen = 0, len = start; len < end; )
temp[tlen++] = string[len++];
temp[tlen] = '\0';
len += 5;
}
- r = result = xmalloc (len + 3);
+ r = result = (char *)xmalloc (len + 3);
*r++ = '"';
for (s = string; s && (c = *s); s++)
int len, tlen, foundnl;
char *temp, *t, *t2;
- temp = xmalloc (end - start + 1);
+ temp = (char *)xmalloc (end - start + 1);
for (tlen = 0, len = start; len < end; )
temp[tlen++] = string[len++];
temp[tlen] = '\0';
}
}
-/* Return 1 if TOKEN is a token that after being read would allow
+/* 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 (token)
- int token;
+reserved_word_acceptable (toksym)
+ int toksym;
{
- if (token == '\n' || token == ';' || token == '(' || token == ')' ||
- token == '|' || token == '&' || token == '{' ||
- token == '}' || /* XXX */
- token == AND_AND ||
- token == BANG ||
- token == TIME || token == TIMEOPT ||
- token == DO ||
- token == ELIF ||
- token == ELSE ||
- token == FI ||
- token == IF ||
- token == OR_OR ||
- token == SEMI_SEMI ||
- token == THEN ||
- token == UNTIL ||
- token == WHILE ||
- token == DONE || /* XXX these two are experimental */
- token == ESAC ||
- token == 0)
+ if (toksym == '\n' || toksym == ';' || toksym == '(' || toksym == ')' ||
+ toksym == '|' || toksym == '&' || toksym == '{' ||
+ toksym == '}' || /* XXX */
+ toksym == AND_AND ||
+ toksym == BANG ||
+ toksym == TIME || toksym == TIMEOPT ||
+ toksym == DO ||
+ toksym == ELIF ||
+ toksym == ELSE ||
+ toksym == FI ||
+ toksym == IF ||
+ toksym == OR_OR ||
+ toksym == SEMI_SEMI ||
+ toksym == THEN ||
+ toksym == UNTIL ||
+ toksym == WHILE ||
+ toksym == DONE || /* XXX these two are experimental */
+ toksym == ESAC ||
+ toksym == 0)
return (1);
else
return (0);
/* 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 (token)
- char *token;
+find_reserved_word (tokstr)
+ char *tokstr;
{
int i;
for (i = 0; word_token_alist[i].word; i++)
- if (STREQ (token, word_token_alist[i].word))
+ if (STREQ (tokstr, word_token_alist[i].word))
return i;
return -1;
}
if (temp_prompt == 0)
{
- temp_prompt = xmalloc (1);
+ temp_prompt = (char *)xmalloc (1);
temp_prompt[0] = '\0';
}
if (temp_prompt == 0)
{
- temp_prompt = xmalloc (1);
+ temp_prompt = (char *)xmalloc (1);
temp_prompt[0] = '\0';
}
WORD_LIST *list;
char *result, *t;
struct dstack save_dstack;
+ int last_exit_value;
#if defined (PROMPT_STRING_DECODE)
int result_size, result_index;
int c, n;
char *temp, octal_string[4];
time_t the_time;
- result = xmalloc (result_size = PROMPT_GROWTH);
+ result = (char *)xmalloc (result_size = PROMPT_GROWTH);
result[result_index = 0] = 0;
temp = (char *)NULL;
octal_string[3] = '\0';
n = read_octal (octal_string);
- temp = xmalloc (3);
+ temp = (char *)xmalloc (3);
if (n == CTLESC || n == CTLNUL)
{
case 'd':
case 'T':
case '@':
+ case 'A':
/* Make the current time/date into a string. */
the_time = time (0);
temp = ctime (&the_time);
temp = (c != 'd') ? savestring (temp + 11) : savestring (temp);
temp[(c != 'd') ? 8 : 10] = '\0';
+ temp[(c != 'A') ? 10 : 5] = '\0';
/* quick and dirty conversion to 12-hour time */
if (c == 'T' || c == '@')
goto add_string;
case 'r':
- temp = xmalloc (2);
+ temp = (char *)xmalloc (2);
temp[0] = '\r';
temp[1] = '\0';
goto add_string;
case 'n':
- temp = xmalloc (3);
+ temp = (char *)xmalloc (3);
temp[0] = no_line_editing ? '\n' : '\r';
temp[1] = no_line_editing ? '\0' : '\n';
temp[2] = '\0';
case 'v':
case 'V':
- temp = xmalloc (8);
+ temp = (char *)xmalloc (8);
if (c == 'v')
strcpy (temp, dist_version);
else
goto add_string;
case '$':
- t = temp = xmalloc (3);
+ t = temp = (char *)xmalloc (3);
if ((promptvars || posixly_correct) && (current_user.euid != 0))
*t++ = '\\';
*t++ = current_user.euid == 0 ? '#' : '$';
#if defined (READLINE)
case '[':
case ']':
- temp = xmalloc (3);
+ temp = (char *)xmalloc (3);
temp[0] = '\001';
temp[1] = (c == '[') ? RL_PROMPT_START_IGNORE : RL_PROMPT_END_IGNORE;
temp[2] = '\0';
#endif /* READLINE */
case '\\':
- temp = xmalloc (2);
+ temp = (char *)xmalloc (2);
temp[0] = c;
temp[1] = '\0';
goto add_string;
case 'a':
case 'e':
- temp = xmalloc (2);
+ temp = (char *)xmalloc (2);
temp[0] = (c == 'a') ? '\07' : '\033';
temp[1] = '\0';
goto add_string;
default:
- temp = xmalloc (3);
+ temp = (char *)xmalloc (3);
temp[0] = '\\';
temp[1] = c;
temp[2] = '\0';
the prompt string. */
if (promptvars || posixly_correct)
{
+ last_exit_value = last_command_exit_value;
list = expand_prompt_string (result, Q_DOUBLE_QUOTES);
free (result);
result = string_list (list);
dispose_words (list);
+ last_command_exit_value = last_exit_value;
}
else
{
/* Report a syntax error, and restart the parser. Call here for fatal
errors. */
int
-yyerror ()
+yyerror (msg)
+ const char *msg;
{
report_syntax_error ((char *)NULL);
reset_parser ();
resultant word list. Used by compound array assignment. */
WORD_LIST *
parse_string_to_word_list (s, whom)
- char *s, *whom;
+ char *s;
+ const char *whom;
{
WORD_LIST *wl;
int tok, orig_line_number, orig_input_terminator;
if (tok != WORD && tok != ASSIGNMENT_WORD)
{
line_number = orig_line_number + line_number - 1;
- yyerror (); /* does the right thing */
+ yyerror ((char *)NULL); /* does the right thing */
if (wl)
dispose_words (wl);
wl = &parse_string_error;