Commit 951a0766 by Neil Booth Committed by Neil Booth

cpphash.h (_cpp_set_trad_context): Remove.

	* cpphash.h (_cpp_set_trad_context): Remove.
	* cpplib.c (prepare_directive_trad): Do nothing for #define.
	(cpp_push_buffer, _cpp_pop_buffer): Don't call _cpp_set_trad_context.
	* cpptrad.c: Update comments.
	(_cpp_read_logical_line_trad): Let scan_logical_line handle
	updating the current context.
	(scan_logical_line): Update the current context.
	(_cpp_create_trad_definition): Similarly.
	(_cpp_set_trad_context): Remove.

From-SVN: r55022
parent 06470238
2002-06-27 Neil Booth <neil@daikokuya.co.uk> 2002-06-27 Neil Booth <neil@daikokuya.co.uk>
* cpphash.h (_cpp_set_trad_context): Remove.
* cpplib.c (prepare_directive_trad): Do nothing for #define.
(cpp_push_buffer, _cpp_pop_buffer): Don't call _cpp_set_trad_context.
* cpptrad.c: Update comments.
(_cpp_read_logical_line_trad): Let scan_logical_line handle
updating the current context.
(scan_logical_line): Update the current context.
(_cpp_create_trad_definition): Similarly.
(_cpp_set_trad_context): Remove.
2002-06-27 Neil Booth <neil@daikokuya.co.uk>
PR preprocessor/7070 PR preprocessor/7070
* c-lex.c (cb_def_pragma): Don't try to spell CPP_EOF. * c-lex.c (cb_def_pragma): Don't try to spell CPP_EOF.
......
...@@ -529,7 +529,6 @@ extern bool _cpp_read_logical_line_trad PARAMS ((cpp_reader *)); ...@@ -529,7 +529,6 @@ extern bool _cpp_read_logical_line_trad PARAMS ((cpp_reader *));
extern void _cpp_overlay_buffer PARAMS ((cpp_reader *pfile, const uchar *, extern void _cpp_overlay_buffer PARAMS ((cpp_reader *pfile, const uchar *,
size_t)); size_t));
extern void _cpp_remove_overlay PARAMS ((cpp_reader *)); extern void _cpp_remove_overlay PARAMS ((cpp_reader *));
extern void _cpp_set_trad_context PARAMS ((cpp_reader *));
extern bool _cpp_create_trad_definition PARAMS ((cpp_reader *, cpp_macro *)); extern bool _cpp_create_trad_definition PARAMS ((cpp_reader *, cpp_macro *));
extern bool _cpp_expansions_different_trad PARAMS ((const cpp_macro *, extern bool _cpp_expansions_different_trad PARAMS ((const cpp_macro *,
const cpp_macro *)); const cpp_macro *));
......
...@@ -284,9 +284,7 @@ static void ...@@ -284,9 +284,7 @@ static void
prepare_directive_trad (pfile) prepare_directive_trad (pfile)
cpp_reader *pfile; cpp_reader *pfile;
{ {
if (pfile->directive == &dtable[T_DEFINE]) if (pfile->directive != &dtable[T_DEFINE])
CUR (pfile->context) = pfile->buffer->cur;
else
{ {
bool no_expand = (pfile->directive bool no_expand = (pfile->directive
&& ! (pfile->directive->flags & EXPAND)); && ! (pfile->directive->flags & EXPAND));
...@@ -1937,9 +1935,6 @@ cpp_push_buffer (pfile, buffer, len, from_stage3, return_at_eof) ...@@ -1937,9 +1935,6 @@ cpp_push_buffer (pfile, buffer, len, from_stage3, return_at_eof)
pfile->buffer = new; pfile->buffer = new;
if (CPP_OPTION (pfile, traditional))
_cpp_set_trad_context (pfile);
return new; return new;
} }
...@@ -1984,9 +1979,6 @@ _cpp_pop_buffer (pfile) ...@@ -1984,9 +1979,6 @@ _cpp_pop_buffer (pfile)
_cpp_maybe_push_include_file (pfile); _cpp_maybe_push_include_file (pfile);
} }
} }
if (pfile->buffer && CPP_OPTION (pfile, traditional))
_cpp_set_trad_context (pfile);
} }
/* Enter all recognised directives in the hash table. */ /* Enter all recognised directives in the hash table. */
......
...@@ -23,12 +23,12 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ...@@ -23,12 +23,12 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* The replacement text of a function-like macro is stored as a /* The replacement text of a function-like macro is stored as a
contiguous sequence of aligned blocks, each representing the text contiguous sequence of aligned blocks, each representing the text
between subsequent parameters in that text. between subsequent parameters.
Each block comprises the length of text contained therein, the Each block comprises the text between its surrounding parameters,
one-based index of the argument that immediately follows that text, the length of that text, and the one-based index of the following
and the text itself. The final block in the macro expansion is parameter. The final block in the replacement text is easily
easily recognizable as it has an argument index of zero. */ recognizable as it has an argument index of zero. */
struct block struct block
{ {
...@@ -139,9 +139,9 @@ handle_newline (pfile, cur) ...@@ -139,9 +139,9 @@ handle_newline (pfile, cur)
return cur + 1; return cur + 1;
} }
/* CUR points to any character in the buffer, not necessarily a /* CUR points to any character in the current context, not necessarily
backslash. Advances CUR until all escaped newlines are skipped, a backslash. Advances CUR until all escaped newlines are skipped,
and returns the new position. and returns the new position without updating the context.
Warns if a file buffer ends in an escaped newline. */ Warns if a file buffer ends in an escaped newline. */
static const uchar * static const uchar *
...@@ -160,9 +160,9 @@ skip_escaped_newlines (pfile, cur) ...@@ -160,9 +160,9 @@ skip_escaped_newlines (pfile, cur)
return cur; return cur;
} }
/* CUR points to the asterisk introducing a comment in the input /* CUR points to the asterisk introducing a comment in the current
buffer. IN_DEFINE is true if we are in the replacement text context. IN_DEFINE is true if we are in the replacement text of a
of a macro. macro.
The asterisk and following comment is copied to the buffer pointed The asterisk and following comment is copied to the buffer pointed
to by pfile->out.cur, which must be of sufficient size. to by pfile->out.cur, which must be of sufficient size.
...@@ -364,31 +364,24 @@ bool ...@@ -364,31 +364,24 @@ bool
_cpp_read_logical_line_trad (pfile) _cpp_read_logical_line_trad (pfile)
cpp_reader *pfile; cpp_reader *pfile;
{ {
cpp_buffer *buffer = pfile->buffer;
do do
{ {
if (buffer->cur == buffer->rlimit) if (pfile->buffer->cur == pfile->buffer->rlimit)
{ {
bool stop = true; bool stop = true;
/* Don't pop the last buffer. */ /* Don't pop the last buffer. */
if (buffer->prev) if (pfile->buffer->prev)
{ {
stop = buffer->return_at_eof; stop = pfile->buffer->return_at_eof;
_cpp_pop_buffer (pfile); _cpp_pop_buffer (pfile);
buffer = pfile->buffer;
} }
if (stop) if (stop)
return false; return false;
} }
CUR (pfile->context) = buffer->cur;
RLIMIT (pfile->context) = buffer->rlimit;
scan_out_logical_line (pfile, NULL); scan_out_logical_line (pfile, NULL);
buffer = pfile->buffer;
buffer->cur = CUR (pfile->context);
} }
while (pfile->state.skipping); while (pfile->state.skipping);
...@@ -426,9 +419,9 @@ save_argument (macro, offset) ...@@ -426,9 +419,9 @@ save_argument (macro, offset)
macro->args[macro->argc] = offset; macro->args[macro->argc] = offset;
} }
/* Copies the next logical line in the current buffer to the output /* Copies the next logical line in the current buffer (starting at
buffer. The output is guaranteed to terminate with a NUL buffer->cur) to the output buffer. The output is guaranteed to
character. terminate with a NUL character. buffer->cur is updated.
If MACRO is non-NULL, then we are scanning the replacement list of If MACRO is non-NULL, then we are scanning the replacement list of
MACRO, and we call save_replacement_text() every time we meet an MACRO, and we call save_replacement_text() every time we meet an
...@@ -448,6 +441,8 @@ scan_out_logical_line (pfile, macro) ...@@ -448,6 +441,8 @@ scan_out_logical_line (pfile, macro)
fmacro.buff = NULL; fmacro.buff = NULL;
start_logical_line: start_logical_line:
CUR (pfile->context) = pfile->buffer->cur;
RLIMIT (pfile->context) = pfile->buffer->rlimit;
pfile->out.cur = pfile->out.base; pfile->out.cur = pfile->out.base;
pfile->out.first_line = pfile->line; pfile->out.first_line = pfile->line;
new_context: new_context:
...@@ -721,6 +716,8 @@ scan_out_logical_line (pfile, macro) ...@@ -721,6 +716,8 @@ scan_out_logical_line (pfile, macro)
preprocessor lex the next token. */ preprocessor lex the next token. */
pfile->buffer->cur = cur; pfile->buffer->cur = cur;
_cpp_handle_directive (pfile, false /* indented */); _cpp_handle_directive (pfile, false /* indented */);
/* #include changes pfile->buffer so we need to
update the limits of the current context. */
goto start_logical_line; goto start_logical_line;
} }
} }
...@@ -759,7 +756,7 @@ scan_out_logical_line (pfile, macro) ...@@ -759,7 +756,7 @@ scan_out_logical_line (pfile, macro)
done: done:
out[-1] = '\0'; out[-1] = '\0';
CUR (context) = cur; pfile->buffer->cur = cur;
pfile->out.cur = out - 1; pfile->out.cur = out - 1;
if (fmacro.buff) if (fmacro.buff)
_cpp_release_buff (pfile, fmacro.buff); _cpp_release_buff (pfile, fmacro.buff);
...@@ -1072,11 +1069,17 @@ _cpp_create_trad_definition (pfile, macro) ...@@ -1072,11 +1069,17 @@ _cpp_create_trad_definition (pfile, macro)
{ {
const uchar *cur; const uchar *cur;
uchar *limit; uchar *limit;
cpp_context *context = pfile->context;
CUR (pfile->context) = pfile->buffer->cur; /* The context has not been set up for command line defines, and CUR
has not been updated for the macro name for in-file defines. */
pfile->out.cur = pfile->out.base;
CUR (context) = pfile->buffer->cur;
RLIMIT (context) = pfile->buffer->rlimit;
check_output_buffer (pfile, RLIMIT (context) - CUR (context));
/* Is this a function-like macro? */ /* Is this a function-like macro? */
if (* CUR (pfile->context) == '(') if (* CUR (context) == '(')
{ {
/* Setting macro to NULL indicates an error occurred, and /* Setting macro to NULL indicates an error occurred, and
prevents unnecessary work in scan_out_logical_line. */ prevents unnecessary work in scan_out_logical_line. */
...@@ -1092,8 +1095,8 @@ _cpp_create_trad_definition (pfile, macro) ...@@ -1092,8 +1095,8 @@ _cpp_create_trad_definition (pfile, macro)
} }
/* Skip leading whitespace in the replacement text. */ /* Skip leading whitespace in the replacement text. */
CUR (pfile->context) pfile->buffer->cur
= skip_whitespace (pfile, CUR (pfile->context), = skip_whitespace (pfile, CUR (context),
CPP_OPTION (pfile, discard_comments_in_macro_exp)); CPP_OPTION (pfile, discard_comments_in_macro_exp));
pfile->state.prevent_expansion++; pfile->state.prevent_expansion++;
...@@ -1202,20 +1205,3 @@ _cpp_expansions_different_trad (macro1, macro2) ...@@ -1202,20 +1205,3 @@ _cpp_expansions_different_trad (macro1, macro2)
free (p1); free (p1);
return mismatch; return mismatch;
} }
/* Prepare to be able to scan the current buffer. */
void
_cpp_set_trad_context (pfile)
cpp_reader *pfile;
{
cpp_buffer *buffer = pfile->buffer;
cpp_context *context = pfile->context;
if (pfile->context->prev)
abort ();
pfile->out.cur = pfile->out.base;
CUR (context) = buffer->cur;
RLIMIT (context) = buffer->rlimit;
check_output_buffer (pfile, RLIMIT (context) - CUR (context));
}
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