Commit 29401c30 by Neil Booth Committed by Neil Booth

cpperror.c (print_location): Don't show _Pragma.

	* cpperror.c (print_location): Don't show _Pragma.
	* cppfiles.c (_cpp_pop_file_buffer): Handle -include file pushing
	and file change callback generation here.
	(stack_include_file): Update use of cpp_push_buffer.
	* cpphash.h (_cpp_pop_file_buffer): Update prototype.
	(struct cpp_buffer): Remove type, pfile members.
	* cppinit.c (cpp_handle_option): Use free_chain.
	* cpplex.c (_cpp_lex_token): Don't do -include file pushing here.
	(skip_escaped_newlines, get_effective_char, lex_percent): Take
	a cpp_reader rather than a cpp_buffer.
	(skip_escaped_newlines, get_effective_char, skip_block_comment,
	skip_line_comment, parse_string, lex_percent, lex_dot,
	_cpp_lex_token): Update accordingly.
	* cpplib.c (_cpp_pop_buffer): Don't do file change callback
	generation here.
	(cpp_push_buffer): Update prototype.
	(run_directive): Update use of cpp_push_buffer.
	(_cpp_do__Pragma, cpp_define, cpp_define_builtin, cpp_undef,
	handle_assertion): Update use of run_directive.
	* cpplib.h (enum cpp_buffer_type): Remove.
	(cpp_push_buffer): Update prototype.
	* fix-header.c (read_scan_file): Update.

From-SVN: r45112
parent 8060c8ee
2001-08-22 Neil Booth <neil@daikokuya.demon.co.uk>
* cpperror.c (print_location): Don't show _Pragma.
* cppfiles.c (_cpp_pop_file_buffer): Handle -include file pushing
and file change callback generation here.
(stack_include_file): Update use of cpp_push_buffer.
* cpphash.h (_cpp_pop_file_buffer): Update prototype.
(struct cpp_buffer): Remove type, pfile members.
* cppinit.c (cpp_handle_option): Use free_chain.
* cpplex.c (_cpp_lex_token): Don't do -include file pushing here.
(skip_escaped_newlines, get_effective_char, lex_percent): Take
a cpp_reader rather than a cpp_buffer.
(skip_escaped_newlines, get_effective_char, skip_block_comment,
skip_line_comment, parse_string, lex_percent, lex_dot,
_cpp_lex_token): Update accordingly.
* cpplib.c (_cpp_pop_buffer): Don't do file change callback
generation here.
(cpp_push_buffer): Update prototype.
(run_directive): Update use of cpp_push_buffer.
(_cpp_do__Pragma, cpp_define, cpp_define_builtin, cpp_undef,
handle_assertion): Update use of run_directive.
* cpplib.h (enum cpp_buffer_type): Remove.
(cpp_push_buffer): Update prototype.
* fix-header.c (read_scan_file): Update.
2001-08-22 Matt Kraai <kraai@alumni.carnegiemellon.edu> 2001-08-22 Matt Kraai <kraai@alumni.carnegiemellon.edu>
* gcc.c (struct prefix_list): Change prefix to const char *. * gcc.c (struct prefix_list): Change prefix to const char *.
......
...@@ -69,8 +69,6 @@ print_location (pfile, pos) ...@@ -69,8 +69,6 @@ print_location (pfile, pos)
else else
fprintf (stderr, "%s:%u:%u:", map->to_file, line, col); fprintf (stderr, "%s:%u:%u:", map->to_file, line, col);
if (buffer->type == BUF_PRAGMA)
fprintf (stderr, "_Pragma:");
fputc (' ', stderr); fputc (' ', stderr);
} }
} }
......
...@@ -317,7 +317,8 @@ stack_include_file (pfile, inc) ...@@ -317,7 +317,8 @@ stack_include_file (pfile, inc)
inc->include_count++; inc->include_count++;
/* Push a buffer. */ /* Push a buffer. */
fp = cpp_push_buffer (pfile, inc->buffer, inc->st.st_size, BUF_FILE, 0); fp = cpp_push_buffer (pfile, inc->buffer, inc->st.st_size,
/* from_stage3 */ CPP_OPTION (pfile, preprocessed), 0);
fp->inc = inc; fp->inc = inc;
fp->inc->refcnt++; fp->inc->refcnt++;
...@@ -720,14 +721,12 @@ _cpp_read_file (pfile, fname) ...@@ -720,14 +721,12 @@ _cpp_read_file (pfile, fname)
} }
/* Do appropriate cleanup when a file buffer is popped off the input /* Do appropriate cleanup when a file buffer is popped off the input
stack. */ stack. Push the next -include file, if any remain. */
void void
_cpp_pop_file_buffer (pfile, buf) _cpp_pop_file_buffer (pfile, inc)
cpp_reader *pfile; cpp_reader *pfile;
cpp_buffer *buf; struct include_file *inc;
{ {
struct include_file *inc = buf->inc;
/* Record the inclusion-preventing macro, which could be NULL /* Record the inclusion-preventing macro, which could be NULL
meaning no controlling macro. */ meaning no controlling macro. */
if (pfile->mi_valid && inc->cmacro == NULL) if (pfile->mi_valid && inc->cmacro == NULL)
...@@ -739,6 +738,16 @@ _cpp_pop_file_buffer (pfile, buf) ...@@ -739,6 +738,16 @@ _cpp_pop_file_buffer (pfile, buf)
inc->refcnt--; inc->refcnt--;
if (inc->refcnt == 0 && DO_NOT_REREAD (inc)) if (inc->refcnt == 0 && DO_NOT_REREAD (inc))
purge_cache (inc); purge_cache (inc);
/* Don't generate a callback for popping the main file. */
if (pfile->buffer)
{
_cpp_do_file_change (pfile, LC_LEAVE, 0, 0, 0);
/* Finally, push the next -included file, if any. */
if (!pfile->buffer->prev)
_cpp_push_next_buffer (pfile);
}
} }
/* Returns the first place in the include chain to start searching for /* Returns the first place in the include chain to start searching for
...@@ -772,8 +781,7 @@ search_from (pfile, type) ...@@ -772,8 +781,7 @@ search_from (pfile, type)
if (dlen) if (dlen)
{ {
/* We don't guarantee NAME is null-terminated. This saves /* We don't guarantee NAME is null-terminated. This saves
allocating and freeing memory, and duplicating it when faking allocating and freeing memory. Drop a trailing '/'. */
buffers in cpp_push_buffer. Drop a trailing '/'. */
buffer->dir.name = buffer->inc->name; buffer->dir.name = buffer->inc->name;
if (dlen > 1) if (dlen > 1)
dlen--; dlen--;
......
...@@ -171,13 +171,12 @@ struct cpp_buffer ...@@ -171,13 +171,12 @@ struct cpp_buffer
cppchar_t read_ahead; /* read ahead character */ cppchar_t read_ahead; /* read ahead character */
cppchar_t extra_char; /* extra read-ahead for long tokens. */ cppchar_t extra_char; /* extra read-ahead for long tokens. */
struct cpp_reader *pfile; /* Owns this buffer. */
struct cpp_buffer *prev; struct cpp_buffer *prev;
const unsigned char *buf; /* entire buffer */ const unsigned char *buf; /* Entire buffer. */
/* Pointer into the include table. Used for include_next and /* Pointer into the include table; non-NULL if this is a file
to record control macros. */ buffer. Used for include_next and to record control macros. */
struct include_file *inc; struct include_file *inc;
/* Value of if_stack at start of this file. /* Value of if_stack at start of this file.
...@@ -214,9 +213,6 @@ struct cpp_buffer ...@@ -214,9 +213,6 @@ struct cpp_buffer
token from the enclosing buffer is returned. */ token from the enclosing buffer is returned. */
bool return_at_eof; bool return_at_eof;
/* Buffer type. */
ENUM_BITFIELD (cpp_buffer_type) type : 8;
/* The directory of the this buffer's file. Its NAME member is not /* The directory of the this buffer's file. Its NAME member is not
allocated, so we don't need to worry about freeing it. */ allocated, so we don't need to worry about freeing it. */
struct search_path dir; struct search_path dir;
...@@ -391,7 +387,8 @@ extern int _cpp_compare_file_date PARAMS ((cpp_reader *, ...@@ -391,7 +387,8 @@ extern int _cpp_compare_file_date PARAMS ((cpp_reader *,
extern void _cpp_report_missing_guards PARAMS ((cpp_reader *)); extern void _cpp_report_missing_guards PARAMS ((cpp_reader *));
extern void _cpp_init_includes PARAMS ((cpp_reader *)); extern void _cpp_init_includes PARAMS ((cpp_reader *));
extern void _cpp_cleanup_includes PARAMS ((cpp_reader *)); extern void _cpp_cleanup_includes PARAMS ((cpp_reader *));
extern void _cpp_pop_file_buffer PARAMS ((cpp_reader *, cpp_buffer *)); extern void _cpp_pop_file_buffer PARAMS ((cpp_reader *,
struct include_file *));
/* In cppexp.c */ /* In cppexp.c */
extern int _cpp_parse_expr PARAMS ((cpp_reader *)); extern int _cpp_parse_expr PARAMS ((cpp_reader *));
......
...@@ -1546,15 +1546,7 @@ cpp_handle_option (pfile, argc, argv) ...@@ -1546,15 +1546,7 @@ cpp_handle_option (pfile, argc, argv)
if (arg[1] == '\0') if (arg[1] == '\0')
{ {
struct pending_option *o1, *o2; free_chain (pend->directive_head);
o1 = pend->directive_head;
while (o1)
{
o2 = o1->next;
free (o1);
o1 = o2;
}
pend->directive_head = NULL; pend->directive_head = NULL;
pend->directive_tail = NULL; pend->directive_tail = NULL;
} }
......
...@@ -81,8 +81,8 @@ const struct token_spelling token_spellings [N_TTYPES] = {TTYPE_TABLE }; ...@@ -81,8 +81,8 @@ const struct token_spelling token_spellings [N_TTYPES] = {TTYPE_TABLE };
#define TOKEN_NAME(token) (token_spellings[(token)->type].name) #define TOKEN_NAME(token) (token_spellings[(token)->type].name)
static cppchar_t handle_newline PARAMS ((cpp_reader *, cppchar_t)); static cppchar_t handle_newline PARAMS ((cpp_reader *, cppchar_t));
static cppchar_t skip_escaped_newlines PARAMS ((cpp_buffer *, cppchar_t)); static cppchar_t skip_escaped_newlines PARAMS ((cpp_reader *, cppchar_t));
static cppchar_t get_effective_char PARAMS ((cpp_buffer *)); static cppchar_t get_effective_char PARAMS ((cpp_reader *));
static int skip_block_comment PARAMS ((cpp_reader *)); static int skip_block_comment PARAMS ((cpp_reader *));
static int skip_line_comment PARAMS ((cpp_reader *)); static int skip_line_comment PARAMS ((cpp_reader *));
...@@ -95,7 +95,7 @@ static void parse_string PARAMS ((cpp_reader *, cpp_token *, cppchar_t)); ...@@ -95,7 +95,7 @@ static void parse_string PARAMS ((cpp_reader *, cpp_token *, cppchar_t));
static void unterminated PARAMS ((cpp_reader *, int)); static void unterminated PARAMS ((cpp_reader *, int));
static int trigraph_ok PARAMS ((cpp_reader *, cppchar_t)); static int trigraph_ok PARAMS ((cpp_reader *, cppchar_t));
static void save_comment PARAMS ((cpp_reader *, cpp_token *, const U_CHAR *)); static void save_comment PARAMS ((cpp_reader *, cpp_token *, const U_CHAR *));
static void lex_percent PARAMS ((cpp_buffer *, cpp_token *)); static void lex_percent PARAMS ((cpp_reader *, cpp_token *));
static void lex_dot PARAMS ((cpp_reader *, cpp_token *)); static void lex_dot PARAMS ((cpp_reader *, cpp_token *));
static int name_p PARAMS ((cpp_reader *, const cpp_string *)); static int name_p PARAMS ((cpp_reader *, const cpp_string *));
static int maybe_read_ucs PARAMS ((cpp_reader *, const unsigned char **, static int maybe_read_ucs PARAMS ((cpp_reader *, const unsigned char **,
...@@ -205,10 +205,12 @@ trigraph_ok (pfile, from_char) ...@@ -205,10 +205,12 @@ trigraph_ok (pfile, from_char)
been placed in buffer->read_ahead. This routine performs been placed in buffer->read_ahead. This routine performs
preprocessing stages 1 and 2 of the ISO C standard. */ preprocessing stages 1 and 2 of the ISO C standard. */
static cppchar_t static cppchar_t
skip_escaped_newlines (buffer, next) skip_escaped_newlines (pfile, next)
cpp_buffer *buffer; cpp_reader *pfile;
cppchar_t next; cppchar_t next;
{ {
cpp_buffer *buffer = pfile->buffer;
/* Only do this if we apply stages 1 and 2. */ /* Only do this if we apply stages 1 and 2. */
if (!buffer->from_stage3) if (!buffer->from_stage3)
{ {
...@@ -233,7 +235,7 @@ skip_escaped_newlines (buffer, next) ...@@ -233,7 +235,7 @@ skip_escaped_newlines (buffer, next)
next1 = *buffer->cur++; next1 = *buffer->cur++;
if (!_cpp_trigraph_map[next1] if (!_cpp_trigraph_map[next1]
|| !trigraph_ok (buffer->pfile, next1)) || !trigraph_ok (pfile, next1))
{ {
RESTORE_STATE (); RESTORE_STATE ();
break; break;
...@@ -263,13 +265,12 @@ skip_escaped_newlines (buffer, next) ...@@ -263,13 +265,12 @@ skip_escaped_newlines (buffer, next)
break; break;
} }
if (space && !buffer->pfile->state.lexing_comment) if (space && !pfile->state.lexing_comment)
cpp_warning (buffer->pfile, cpp_warning (pfile, "backslash and newline separated by space");
"backslash and newline separated by space");
next = handle_newline (buffer->pfile, next1); next = handle_newline (pfile, next1);
if (next == EOF) if (next == EOF)
cpp_pedwarn (buffer->pfile, "backslash-newline at end of file"); cpp_pedwarn (pfile, "backslash-newline at end of file");
} }
while (next == '\\' || next == '?'); while (next == '\\' || next == '?');
} }
...@@ -282,9 +283,10 @@ skip_escaped_newlines (buffer, next) ...@@ -282,9 +283,10 @@ skip_escaped_newlines (buffer, next)
an arbitrary string of escaped newlines. The common case of no an arbitrary string of escaped newlines. The common case of no
trigraphs or escaped newlines falls through quickly. */ trigraphs or escaped newlines falls through quickly. */
static cppchar_t static cppchar_t
get_effective_char (buffer) get_effective_char (pfile)
cpp_buffer *buffer; cpp_reader *pfile;
{ {
cpp_buffer *buffer = pfile->buffer;
cppchar_t next = EOF; cppchar_t next = EOF;
if (buffer->cur < buffer->rlimit) if (buffer->cur < buffer->rlimit)
...@@ -296,7 +298,7 @@ get_effective_char (buffer) ...@@ -296,7 +298,7 @@ get_effective_char (buffer)
UCNs, which, depending upon lexer state, we will handle in UCNs, which, depending upon lexer state, we will handle in
the future. */ the future. */
if (next == '?' || next == '\\') if (next == '?' || next == '\\')
next = skip_escaped_newlines (buffer, next); next = skip_escaped_newlines (pfile, next);
} }
buffer->read_ahead = next; buffer->read_ahead = next;
...@@ -322,7 +324,7 @@ skip_block_comment (pfile) ...@@ -322,7 +324,7 @@ skip_block_comment (pfile)
/* FIXME: For speed, create a new character class of characters /* FIXME: For speed, create a new character class of characters
of interest inside block comments. */ of interest inside block comments. */
if (c == '?' || c == '\\') if (c == '?' || c == '\\')
c = skip_escaped_newlines (buffer, c); c = skip_escaped_newlines (pfile, c);
/* People like decorating comments with '*', so check for '/' /* People like decorating comments with '*', so check for '/'
instead for efficiency. */ instead for efficiency. */
...@@ -383,7 +385,7 @@ skip_line_comment (pfile) ...@@ -383,7 +385,7 @@ skip_line_comment (pfile)
c = *buffer->cur++; c = *buffer->cur++;
if (c == '?' || c == '\\') if (c == '?' || c == '\\')
c = skip_escaped_newlines (buffer, c); c = skip_escaped_newlines (pfile, c);
} }
while (!is_vspace (c)); while (!is_vspace (c));
...@@ -502,7 +504,7 @@ parse_identifier (pfile, c) ...@@ -502,7 +504,7 @@ parse_identifier (pfile, c)
/* Potential escaped newline? */ /* Potential escaped newline? */
if (c != '?' && c != '\\') if (c != '?' && c != '\\')
break; break;
c = skip_escaped_newlines (buffer, c); c = skip_escaped_newlines (pfile, c);
} }
while (is_idchar (c)); while (is_idchar (c));
...@@ -584,7 +586,7 @@ parse_number (pfile, number, c, leading_period) ...@@ -584,7 +586,7 @@ parse_number (pfile, number, c, leading_period)
/* Potential escaped newline? */ /* Potential escaped newline? */
if (c != '?' && c != '\\') if (c != '?' && c != '\\')
break; break;
c = skip_escaped_newlines (buffer, c); c = skip_escaped_newlines (pfile, c);
} }
while (is_numchar (c) || c == '.' || VALID_SIGN (c, dest[-1])); while (is_numchar (c) || c == '.' || VALID_SIGN (c, dest[-1]));
...@@ -680,7 +682,7 @@ parse_string (pfile, token, terminator) ...@@ -680,7 +682,7 @@ parse_string (pfile, token, terminator)
/* Handle trigraphs, escaped newlines etc. */ /* Handle trigraphs, escaped newlines etc. */
if (c == '?' || c == '\\') if (c == '?' || c == '\\')
c = skip_escaped_newlines (buffer, c); c = skip_escaped_newlines (pfile, c);
if (c == terminator && unescaped_terminator_p (pfile, dest)) if (c == terminator && unescaped_terminator_p (pfile, dest))
{ {
...@@ -764,16 +766,17 @@ save_comment (pfile, token, from) ...@@ -764,16 +766,17 @@ save_comment (pfile, token, from)
/* Subroutine of lex_token to handle '%'. A little tricky, since we /* Subroutine of lex_token to handle '%'. A little tricky, since we
want to avoid stepping back when lexing %:%X. */ want to avoid stepping back when lexing %:%X. */
static void static void
lex_percent (buffer, result) lex_percent (pfile, result)
cpp_buffer *buffer; cpp_reader *pfile;
cpp_token *result; cpp_token *result;
{ {
cpp_buffer *buffer= pfile->buffer;
cppchar_t c; cppchar_t c;
result->type = CPP_MOD; result->type = CPP_MOD;
/* Parsing %:%X could leave an extra character. */ /* Parsing %:%X could leave an extra character. */
if (buffer->extra_char == EOF) if (buffer->extra_char == EOF)
c = get_effective_char (buffer); c = get_effective_char (pfile);
else else
{ {
c = buffer->read_ahead = buffer->extra_char; c = buffer->read_ahead = buffer->extra_char;
...@@ -782,15 +785,15 @@ lex_percent (buffer, result) ...@@ -782,15 +785,15 @@ lex_percent (buffer, result)
if (c == '=') if (c == '=')
ACCEPT_CHAR (CPP_MOD_EQ); ACCEPT_CHAR (CPP_MOD_EQ);
else if (CPP_OPTION (buffer->pfile, digraphs)) else if (CPP_OPTION (pfile, digraphs))
{ {
if (c == ':') if (c == ':')
{ {
result->flags |= DIGRAPH; result->flags |= DIGRAPH;
ACCEPT_CHAR (CPP_HASH); ACCEPT_CHAR (CPP_HASH);
if (get_effective_char (buffer) == '%') if (get_effective_char (pfile) == '%')
{ {
buffer->extra_char = get_effective_char (buffer); buffer->extra_char = get_effective_char (pfile);
if (buffer->extra_char == ':') if (buffer->extra_char == ':')
{ {
buffer->extra_char = EOF; buffer->extra_char = EOF;
...@@ -822,7 +825,7 @@ lex_dot (pfile, result) ...@@ -822,7 +825,7 @@ lex_dot (pfile, result)
/* Parsing ..X could leave an extra character. */ /* Parsing ..X could leave an extra character. */
if (buffer->extra_char == EOF) if (buffer->extra_char == EOF)
c = get_effective_char (buffer); c = get_effective_char (pfile);
else else
{ {
c = buffer->read_ahead = buffer->extra_char; c = buffer->read_ahead = buffer->extra_char;
...@@ -840,7 +843,7 @@ lex_dot (pfile, result) ...@@ -840,7 +843,7 @@ lex_dot (pfile, result)
result->type = CPP_DOT; result->type = CPP_DOT;
if (c == '.') if (c == '.')
{ {
buffer->extra_char = get_effective_char (buffer); buffer->extra_char = get_effective_char (pfile);
if (buffer->extra_char == '.') if (buffer->extra_char == '.')
{ {
buffer->extra_char = EOF; buffer->extra_char = EOF;
...@@ -914,9 +917,6 @@ _cpp_lex_token (pfile, result) ...@@ -914,9 +917,6 @@ _cpp_lex_token (pfile, result)
unsigned char stop = buffer->return_at_eof; unsigned char stop = buffer->return_at_eof;
_cpp_pop_buffer (pfile); _cpp_pop_buffer (pfile);
/* Push the next -included file, if any. */
if (!pfile->buffer->prev)
_cpp_push_next_buffer (pfile);
if (!stop) if (!stop)
goto next_token; goto next_token;
} }
...@@ -963,7 +963,7 @@ _cpp_lex_token (pfile, result) ...@@ -963,7 +963,7 @@ _cpp_lex_token (pfile, result)
{ {
unsigned int line = pfile->line; unsigned int line = pfile->line;
c = skip_escaped_newlines (buffer, c); c = skip_escaped_newlines (pfile, c);
if (line != pfile->line) if (line != pfile->line)
/* We had at least one escaped newline of some sort, and the /* We had at least one escaped newline of some sort, and the
next character is in buffer->read_ahead. Update the next character is in buffer->read_ahead. Update the
...@@ -1034,7 +1034,7 @@ _cpp_lex_token (pfile, result) ...@@ -1034,7 +1034,7 @@ _cpp_lex_token (pfile, result)
/* A potential block or line comment. */ /* A potential block or line comment. */
comment_start = buffer->cur; comment_start = buffer->cur;
result->type = CPP_DIV; result->type = CPP_DIV;
c = get_effective_char (buffer); c = get_effective_char (pfile);
if (c == '=') if (c == '=')
ACCEPT_CHAR (CPP_DIV_EQ); ACCEPT_CHAR (CPP_DIV_EQ);
if (c != '/' && c != '*') if (c != '/' && c != '*')
...@@ -1091,19 +1091,19 @@ _cpp_lex_token (pfile, result) ...@@ -1091,19 +1091,19 @@ _cpp_lex_token (pfile, result)
} }
result->type = CPP_LESS; result->type = CPP_LESS;
c = get_effective_char (buffer); c = get_effective_char (pfile);
if (c == '=') if (c == '=')
ACCEPT_CHAR (CPP_LESS_EQ); ACCEPT_CHAR (CPP_LESS_EQ);
else if (c == '<') else if (c == '<')
{ {
ACCEPT_CHAR (CPP_LSHIFT); ACCEPT_CHAR (CPP_LSHIFT);
if (get_effective_char (buffer) == '=') if (get_effective_char (pfile) == '=')
ACCEPT_CHAR (CPP_LSHIFT_EQ); ACCEPT_CHAR (CPP_LSHIFT_EQ);
} }
else if (c == '?' && CPP_OPTION (pfile, cplusplus)) else if (c == '?' && CPP_OPTION (pfile, cplusplus))
{ {
ACCEPT_CHAR (CPP_MIN); ACCEPT_CHAR (CPP_MIN);
if (get_effective_char (buffer) == '=') if (get_effective_char (pfile) == '=')
ACCEPT_CHAR (CPP_MIN_EQ); ACCEPT_CHAR (CPP_MIN_EQ);
} }
else if (c == ':' && CPP_OPTION (pfile, digraphs)) else if (c == ':' && CPP_OPTION (pfile, digraphs))
...@@ -1120,25 +1120,25 @@ _cpp_lex_token (pfile, result) ...@@ -1120,25 +1120,25 @@ _cpp_lex_token (pfile, result)
case '>': case '>':
result->type = CPP_GREATER; result->type = CPP_GREATER;
c = get_effective_char (buffer); c = get_effective_char (pfile);
if (c == '=') if (c == '=')
ACCEPT_CHAR (CPP_GREATER_EQ); ACCEPT_CHAR (CPP_GREATER_EQ);
else if (c == '>') else if (c == '>')
{ {
ACCEPT_CHAR (CPP_RSHIFT); ACCEPT_CHAR (CPP_RSHIFT);
if (get_effective_char (buffer) == '=') if (get_effective_char (pfile) == '=')
ACCEPT_CHAR (CPP_RSHIFT_EQ); ACCEPT_CHAR (CPP_RSHIFT_EQ);
} }
else if (c == '?' && CPP_OPTION (pfile, cplusplus)) else if (c == '?' && CPP_OPTION (pfile, cplusplus))
{ {
ACCEPT_CHAR (CPP_MAX); ACCEPT_CHAR (CPP_MAX);
if (get_effective_char (buffer) == '=') if (get_effective_char (pfile) == '=')
ACCEPT_CHAR (CPP_MAX_EQ); ACCEPT_CHAR (CPP_MAX_EQ);
} }
break; break;
case '%': case '%':
lex_percent (buffer, result); lex_percent (pfile, result);
if (result->type == CPP_HASH) if (result->type == CPP_HASH)
goto do_hash; goto do_hash;
break; break;
...@@ -1149,7 +1149,7 @@ _cpp_lex_token (pfile, result) ...@@ -1149,7 +1149,7 @@ _cpp_lex_token (pfile, result)
case '+': case '+':
result->type = CPP_PLUS; result->type = CPP_PLUS;
c = get_effective_char (buffer); c = get_effective_char (pfile);
if (c == '=') if (c == '=')
ACCEPT_CHAR (CPP_PLUS_EQ); ACCEPT_CHAR (CPP_PLUS_EQ);
else if (c == '+') else if (c == '+')
...@@ -1158,12 +1158,12 @@ _cpp_lex_token (pfile, result) ...@@ -1158,12 +1158,12 @@ _cpp_lex_token (pfile, result)
case '-': case '-':
result->type = CPP_MINUS; result->type = CPP_MINUS;
c = get_effective_char (buffer); c = get_effective_char (pfile);
if (c == '>') if (c == '>')
{ {
ACCEPT_CHAR (CPP_DEREF); ACCEPT_CHAR (CPP_DEREF);
if (CPP_OPTION (pfile, cplusplus) if (CPP_OPTION (pfile, cplusplus)
&& get_effective_char (buffer) == '*') && get_effective_char (pfile) == '*')
ACCEPT_CHAR (CPP_DEREF_STAR); ACCEPT_CHAR (CPP_DEREF_STAR);
} }
else if (c == '=') else if (c == '=')
...@@ -1174,25 +1174,25 @@ _cpp_lex_token (pfile, result) ...@@ -1174,25 +1174,25 @@ _cpp_lex_token (pfile, result)
case '*': case '*':
result->type = CPP_MULT; result->type = CPP_MULT;
if (get_effective_char (buffer) == '=') if (get_effective_char (pfile) == '=')
ACCEPT_CHAR (CPP_MULT_EQ); ACCEPT_CHAR (CPP_MULT_EQ);
break; break;
case '=': case '=':
result->type = CPP_EQ; result->type = CPP_EQ;
if (get_effective_char (buffer) == '=') if (get_effective_char (pfile) == '=')
ACCEPT_CHAR (CPP_EQ_EQ); ACCEPT_CHAR (CPP_EQ_EQ);
break; break;
case '!': case '!':
result->type = CPP_NOT; result->type = CPP_NOT;
if (get_effective_char (buffer) == '=') if (get_effective_char (pfile) == '=')
ACCEPT_CHAR (CPP_NOT_EQ); ACCEPT_CHAR (CPP_NOT_EQ);
break; break;
case '&': case '&':
result->type = CPP_AND; result->type = CPP_AND;
c = get_effective_char (buffer); c = get_effective_char (pfile);
if (c == '=') if (c == '=')
ACCEPT_CHAR (CPP_AND_EQ); ACCEPT_CHAR (CPP_AND_EQ);
else if (c == '&') else if (c == '&')
...@@ -1207,7 +1207,7 @@ _cpp_lex_token (pfile, result) ...@@ -1207,7 +1207,7 @@ _cpp_lex_token (pfile, result)
buffer->extra_char = EOF; buffer->extra_char = EOF;
} }
else else
c = get_effective_char (buffer); c = get_effective_char (pfile);
if (c == '#') if (c == '#')
{ {
...@@ -1247,7 +1247,7 @@ _cpp_lex_token (pfile, result) ...@@ -1247,7 +1247,7 @@ _cpp_lex_token (pfile, result)
case '|': case '|':
result->type = CPP_OR; result->type = CPP_OR;
c = get_effective_char (buffer); c = get_effective_char (pfile);
if (c == '=') if (c == '=')
ACCEPT_CHAR (CPP_OR_EQ); ACCEPT_CHAR (CPP_OR_EQ);
else if (c == '|') else if (c == '|')
...@@ -1256,13 +1256,13 @@ _cpp_lex_token (pfile, result) ...@@ -1256,13 +1256,13 @@ _cpp_lex_token (pfile, result)
case '^': case '^':
result->type = CPP_XOR; result->type = CPP_XOR;
if (get_effective_char (buffer) == '=') if (get_effective_char (pfile) == '=')
ACCEPT_CHAR (CPP_XOR_EQ); ACCEPT_CHAR (CPP_XOR_EQ);
break; break;
case ':': case ':':
result->type = CPP_COLON; result->type = CPP_COLON;
c = get_effective_char (buffer); c = get_effective_char (pfile);
if (c == ':' && CPP_OPTION (pfile, cplusplus)) if (c == ':' && CPP_OPTION (pfile, cplusplus))
ACCEPT_CHAR (CPP_SCOPE); ACCEPT_CHAR (CPP_SCOPE);
else if (c == '>' && CPP_OPTION (pfile, digraphs)) else if (c == '>' && CPP_OPTION (pfile, digraphs))
......
...@@ -83,7 +83,6 @@ static void check_eol PARAMS ((cpp_reader *)); ...@@ -83,7 +83,6 @@ static void check_eol PARAMS ((cpp_reader *));
static void start_directive PARAMS ((cpp_reader *)); static void start_directive PARAMS ((cpp_reader *));
static void end_directive PARAMS ((cpp_reader *, int)); static void end_directive PARAMS ((cpp_reader *, int));
static void run_directive PARAMS ((cpp_reader *, int, static void run_directive PARAMS ((cpp_reader *, int,
enum cpp_buffer_type,
const char *, size_t)); const char *, size_t));
static int glue_header_name PARAMS ((cpp_reader *, cpp_token *)); static int glue_header_name PARAMS ((cpp_reader *, cpp_token *));
static int parse_include PARAMS ((cpp_reader *, cpp_token *)); static int parse_include PARAMS ((cpp_reader *, cpp_token *));
...@@ -394,16 +393,14 @@ _cpp_handle_directive (pfile, indented) ...@@ -394,16 +393,14 @@ _cpp_handle_directive (pfile, indented)
/* Directive handler wrapper used by the command line option /* Directive handler wrapper used by the command line option
processor. */ processor. */
static void static void
run_directive (pfile, dir_no, type, buf, count) run_directive (pfile, dir_no, buf, count)
cpp_reader *pfile; cpp_reader *pfile;
int dir_no; int dir_no;
enum cpp_buffer_type type;
const char *buf; const char *buf;
size_t count; size_t count;
{ {
cpp_buffer *buffer; cpp_push_buffer (pfile, (const U_CHAR *) buf, count,
/* from_stage3 */ true, 1);
buffer = cpp_push_buffer (pfile, (const U_CHAR *) buf, count, type, 1);
start_directive (pfile); start_directive (pfile);
pfile->state.prevent_expansion++; pfile->state.prevent_expansion++;
pfile->directive = &dtable[dir_no]; pfile->directive = &dtable[dir_no];
...@@ -1160,7 +1157,7 @@ _cpp_do__Pragma (pfile) ...@@ -1160,7 +1157,7 @@ _cpp_do__Pragma (pfile)
else else
{ {
buffer = destringize (&string.val.str, &len); buffer = destringize (&string.val.str, &len);
run_directive (pfile, T_PRAGMA, BUF_PRAGMA, (char *) buffer, len); run_directive (pfile, T_PRAGMA, (char *) buffer, len);
free ((PTR) buffer); free ((PTR) buffer);
pfile->lexer_pos = orig_pos; pfile->lexer_pos = orig_pos;
pfile->line = pfile->lexer_pos.line; pfile->line = pfile->lexer_pos.line;
...@@ -1627,7 +1624,7 @@ cpp_define (pfile, str) ...@@ -1627,7 +1624,7 @@ cpp_define (pfile, str)
buf[count++] = '1'; buf[count++] = '1';
} }
run_directive (pfile, T_DEFINE, BUF_CL_OPTION, buf, count); run_directive (pfile, T_DEFINE, buf, count);
} }
/* Slight variant of the above for use by initialize_builtins. */ /* Slight variant of the above for use by initialize_builtins. */
...@@ -1636,7 +1633,7 @@ _cpp_define_builtin (pfile, str) ...@@ -1636,7 +1633,7 @@ _cpp_define_builtin (pfile, str)
cpp_reader *pfile; cpp_reader *pfile;
const char *str; const char *str;
{ {
run_directive (pfile, T_DEFINE, BUF_BUILTIN, str, strlen (str)); run_directive (pfile, T_DEFINE, str, strlen (str));
} }
/* Process MACRO as if it appeared as the body of an #undef. */ /* Process MACRO as if it appeared as the body of an #undef. */
...@@ -1645,7 +1642,7 @@ cpp_undef (pfile, macro) ...@@ -1645,7 +1642,7 @@ cpp_undef (pfile, macro)
cpp_reader *pfile; cpp_reader *pfile;
const char *macro; const char *macro;
{ {
run_directive (pfile, T_UNDEF, BUF_CL_OPTION, macro, strlen (macro)); run_directive (pfile, T_UNDEF, macro, strlen (macro));
} }
/* Process the string STR as if it appeared as the body of a #assert. */ /* Process the string STR as if it appeared as the body of a #assert. */
...@@ -1688,7 +1685,7 @@ handle_assertion (pfile, str, type) ...@@ -1688,7 +1685,7 @@ handle_assertion (pfile, str, type)
str = buf; str = buf;
} }
run_directive (pfile, type, BUF_CL_OPTION, str, count); run_directive (pfile, type, str, count);
} }
/* The number of errors for a given reader. */ /* The number of errors for a given reader. */
...@@ -1736,11 +1733,11 @@ cpp_set_callbacks (pfile, cb) ...@@ -1736,11 +1733,11 @@ cpp_set_callbacks (pfile, cb)
doesn't fail. It does not generate a file change call back; that doesn't fail. It does not generate a file change call back; that
is the responsibility of the caller. */ is the responsibility of the caller. */
cpp_buffer * cpp_buffer *
cpp_push_buffer (pfile, buffer, len, type, return_at_eof) cpp_push_buffer (pfile, buffer, len, from_stage3, return_at_eof)
cpp_reader *pfile; cpp_reader *pfile;
const U_CHAR *buffer; const U_CHAR *buffer;
size_t len; size_t len;
enum cpp_buffer_type type; int from_stage3;
int return_at_eof; int return_at_eof;
{ {
cpp_buffer *new = xobnew (&pfile->buffer_ob, cpp_buffer); cpp_buffer *new = xobnew (&pfile->buffer_ob, cpp_buffer);
...@@ -1754,14 +1751,8 @@ cpp_push_buffer (pfile, buffer, len, type, return_at_eof) ...@@ -1754,14 +1751,8 @@ cpp_push_buffer (pfile, buffer, len, type, return_at_eof)
/* No read ahead or extra char initially. */ /* No read ahead or extra char initially. */
new->read_ahead = EOF; new->read_ahead = EOF;
new->extra_char = EOF; new->extra_char = EOF;
new->from_stage3 = from_stage3;
/* Preprocessed files, builtins, _Pragma and command line
options don't do trigraph and escaped newline processing. */
new->from_stage3 = type != BUF_FILE || CPP_OPTION (pfile, preprocessed);
new->type = type;
new->prev = pfile->buffer; new->prev = pfile->buffer;
new->pfile = pfile;
new->return_at_eof = return_at_eof; new->return_at_eof = return_at_eof;
pfile->buffer = new; pfile->buffer = new;
...@@ -1785,26 +1776,20 @@ _cpp_pop_buffer (pfile) ...@@ -1785,26 +1776,20 @@ _cpp_pop_buffer (pfile)
cpp_error_with_line (pfile, ifs->pos.line, ifs->pos.col, cpp_error_with_line (pfile, ifs->pos.line, ifs->pos.col,
"unterminated #%s", dtable[ifs->type].name); "unterminated #%s", dtable[ifs->type].name);
/* Update the reader's buffer before _cpp_do_file_change. */
pfile->buffer = buffer->prev;
if (buffer->type == BUF_FILE)
{
/* Callbacks are not generated for popping the main file. */
if (buffer->prev)
_cpp_do_file_change (pfile, LC_LEAVE, 0, 0, 0);
_cpp_pop_file_buffer (pfile, buffer);
}
obstack_free (&pfile->buffer_ob, buffer);
/* The output line can fall out of sync if we missed the final /* The output line can fall out of sync if we missed the final
newline from the previous buffer, for example because of an newline from the previous buffer, for example because of an
unterminated comment. Similarly, skipping needs to be cleared in unterminated comment. Similarly, skipping needs to be cleared in
case of a missing #endif. */ case of a missing #endif. */
pfile->lexer_pos.output_line = pfile->line; pfile->lexer_pos.output_line = pfile->line;
pfile->state.skipping = 0; pfile->state.skipping = 0;
/* Update the reader's buffer before _cpp_do_file_change. */
pfile->buffer = buffer->prev;
if (buffer->inc)
_cpp_pop_file_buffer (pfile, buffer->inc);
obstack_free (&pfile->buffer_ob, buffer);
} }
void void
......
...@@ -405,10 +405,6 @@ struct cpp_callbacks ...@@ -405,10 +405,6 @@ struct cpp_callbacks
/* Name under which this program was invoked. */ /* Name under which this program was invoked. */
extern const char *progname; extern const char *progname;
/* Where does this buffer come from? A source file, a builtin macro,
a command-line option, or a _Pragma operator. */
enum cpp_buffer_type {BUF_FILE, BUF_BUILTIN, BUF_CL_OPTION, BUF_PRAGMA};
/* The structure of a node in the hash table. The hash table has /* The structure of a node in the hash table. The hash table has
entries for all identifiers: either macros defined by #define entries for all identifiers: either macros defined by #define
commands (type NT_MACRO), assertions created with #assert commands (type NT_MACRO), assertions created with #assert
...@@ -541,7 +537,7 @@ extern void cpp_unassert PARAMS ((cpp_reader *, const char *)); ...@@ -541,7 +537,7 @@ extern void cpp_unassert PARAMS ((cpp_reader *, const char *));
extern cpp_buffer *cpp_push_buffer PARAMS ((cpp_reader *, extern cpp_buffer *cpp_push_buffer PARAMS ((cpp_reader *,
const unsigned char *, size_t, const unsigned char *, size_t,
enum cpp_buffer_type, int)); int, int));
extern int cpp_defined PARAMS ((cpp_reader *, const unsigned char *, int)); extern int cpp_defined PARAMS ((cpp_reader *, const unsigned char *, int));
/* N.B. The error-message-printer prototypes have not been nicely /* N.B. The error-message-printer prototypes have not been nicely
......
...@@ -658,7 +658,7 @@ read_scan_file (in_fname, argc, argv) ...@@ -658,7 +658,7 @@ read_scan_file (in_fname, argc, argv)
/* Scan the macro expansion of "getchar();". */ /* Scan the macro expansion of "getchar();". */
cpp_push_buffer (scan_in, getchar_call, sizeof(getchar_call) - 1, cpp_push_buffer (scan_in, getchar_call, sizeof(getchar_call) - 1,
BUF_BUILTIN, 1); /* from_stage3 */ true, 1);
for (;;) for (;;)
{ {
cpp_token t; cpp_token t;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment