Commit 417f3e3a by Zack Weinberg

[multiple changes]

2000-07-11  Zack Weinberg  <zack@wolery.cumb.org>

	* cpplex.c (parse_name): No longer inline (premature optimization).
	(do_pop_context): Fold into pop_context.
	(pop_context): Returns int.
	(lex_next): Hoist test for end of directive into pop_context.
	(push_macro_context): Returns int; takes just reader and token.
	Hoist test for excessive nesting to caller.
	(push_arg_context): Returns void; takes just reader and token.
	Do not call stringify_arg or get_raw_token.
	(get_raw_token): Convert tail recursion through	push_arg_context
	to a loop at this level.  Call stringify_arg here if appropriate.
	(maybe_paste_with_next): Convert tail recursion to a while loop.
	Hoist test of paste_level to caller.

	(stringify_arg): Push arg context at beginning.
	(cpp_get_token): Split out core into _cpp_get_token.  Call
	process_directive here.  Throw away CPP_PLACEMARKER tokens.
	(_cpp_get_token): Convert tail recursion through
	push_macro_context to a loop at this level.
	(_cpp_glue_header_name, is_macro_disabled, stringify_arg,
	_cpp_get_raw_token): Use _cpp_get_token.
	(_cpp_skip_rest_of_line): Drop the context stack directly; do
	not call pop_context.
	(_cpp_run_directive): Call lex_next directly.

	* cpphash.h: Prototype _cpp_get_token.
	* cppexp.c (lex): Use it.
	* cpphash.c (parse_define): Use it.
	* cpplib.c (get_define_node, do_undef, parse_include,
	read_line_number, do_line, do_ident, do_pragma, do_pragma_gcc,
	do_pragma_implementation, do_pragma_poison, do_pragma_dependency,
	parse_ifdef, validate_else): Use it.
	(cpp_push_buffer): Tweak error message; abort if anyone tries
	to push a buffer while macro expansions are stacked.

2000-07-11  Donn Terry  <donnte@microsoft.com>

	* cpplex.c (free_macro_args, save_token): Cast arg of free
	and/or xrealloc to PTR.
	(_cpp_init_input_buffer): Clear all fields of the base context.

From-SVN: r34972
parent 268afb99
2000-07-11 Zack Weinberg <zack@wolery.cumb.org>
* cpplex.c (parse_name): No longer inline (premature optimization).
(do_pop_context): Fold into pop_context.
(pop_context): Returns int.
(lex_next): Hoist test for end of directive into pop_context.
(push_macro_context): Returns int; takes just reader and token.
Hoist test for excessive nesting to caller.
(push_arg_context): Returns void; takes just reader and token.
Do not call stringify_arg or get_raw_token.
(get_raw_token): Convert tail recursion through push_arg_context
to a loop at this level. Call stringify_arg here if appropriate.
(maybe_paste_with_next): Convert tail recursion to a while loop.
Hoist test of paste_level to caller.
(stringify_arg): Push arg context at beginning.
(cpp_get_token): Split out core into _cpp_get_token. Call
process_directive here. Throw away CPP_PLACEMARKER tokens.
(_cpp_get_token): Convert tail recursion through
push_macro_context to a loop at this level.
(_cpp_glue_header_name, is_macro_disabled, stringify_arg,
_cpp_get_raw_token): Use _cpp_get_token.
(_cpp_skip_rest_of_line): Drop the context stack directly; do
not call pop_context.
(_cpp_run_directive): Call lex_next directly.
* cpphash.h: Prototype _cpp_get_token.
* cppexp.c (lex): Use it.
* cpphash.c (parse_define): Use it.
* cpplib.c (get_define_node, do_undef, parse_include,
read_line_number, do_line, do_ident, do_pragma, do_pragma_gcc,
do_pragma_implementation, do_pragma_poison, do_pragma_dependency,
parse_ifdef, validate_else): Use it.
(cpp_push_buffer): Tweak error message; abort if anyone tries
to push a buffer while macro expansions are stacked.
2000-07-11 Donn Terry <donnte@microsoft.com>
* cpplex.c (free_macro_args, save_token): Cast arg of free
and/or xrealloc to PTR.
(_cpp_init_input_buffer): Clear all fields of the base context.
Tue Jul 11 15:28:21 CDT 2000 Clinton Popetz <cpopetz@cygnus.com> Tue Jul 11 15:28:21 CDT 2000 Clinton Popetz <cpopetz@cygnus.com>
* gensupport.c (process_rtx): Make rtl checking stop * gensupport.c (process_rtx): Make rtl checking stop
......
...@@ -392,7 +392,7 @@ lex (pfile, skip_evaluation) ...@@ -392,7 +392,7 @@ lex (pfile, skip_evaluation)
const cpp_token *tok; const cpp_token *tok;
retry: retry:
tok = cpp_get_token (pfile); tok = _cpp_get_token (pfile);
switch (tok->type) switch (tok->type)
{ {
......
...@@ -354,7 +354,7 @@ parse_define (pfile) ...@@ -354,7 +354,7 @@ parse_define (pfile)
int prev_white = 0; int prev_white = 0;
/* The first token after the macro's name. */ /* The first token after the macro's name. */
token = cpp_get_token (pfile); token = _cpp_get_token (pfile);
/* Constraint 6.10.3.5 */ /* Constraint 6.10.3.5 */
if (is__va_args__ (pfile, token - 1)) if (is__va_args__ (pfile, token - 1))
......
...@@ -256,6 +256,7 @@ extern void _cpp_run_directive PARAMS ((cpp_reader *, ...@@ -256,6 +256,7 @@ extern void _cpp_run_directive PARAMS ((cpp_reader *,
const char *, size_t)); const char *, size_t));
extern unsigned int _cpp_get_line PARAMS ((cpp_reader *, extern unsigned int _cpp_get_line PARAMS ((cpp_reader *,
unsigned int *)); unsigned int *));
extern const cpp_token *_cpp_get_token PARAMS ((cpp_reader *));
extern const cpp_token *_cpp_get_raw_token PARAMS ((cpp_reader *)); extern const cpp_token *_cpp_get_raw_token PARAMS ((cpp_reader *));
extern void _cpp_push_token PARAMS ((cpp_reader *, const cpp_token*)); extern void _cpp_push_token PARAMS ((cpp_reader *, const cpp_token*));
extern const cpp_token *_cpp_glue_header_name PARAMS ((cpp_reader *)); extern const cpp_token *_cpp_glue_header_name PARAMS ((cpp_reader *));
......
...@@ -250,7 +250,7 @@ get_define_node (pfile) ...@@ -250,7 +250,7 @@ get_define_node (pfile)
const cpp_token *token; const cpp_token *token;
/* Skip any -C comments. */ /* Skip any -C comments. */
while ((token = cpp_get_token (pfile))->type == CPP_COMMENT) while ((token = _cpp_get_token (pfile))->type == CPP_COMMENT)
; ;
if (token->type != CPP_NAME) if (token->type != CPP_NAME)
...@@ -307,7 +307,7 @@ do_undef (pfile) ...@@ -307,7 +307,7 @@ do_undef (pfile)
{ {
cpp_hashnode *node = get_define_node (pfile); cpp_hashnode *node = get_define_node (pfile);
if (cpp_get_token (pfile)->type != CPP_EOF) if (_cpp_get_token (pfile)->type != CPP_EOF)
cpp_pedwarn (pfile, "junk on line after #undef"); cpp_pedwarn (pfile, "junk on line after #undef");
/* 6.10.3.5 paragraph 2: [#undef] is ignored if the specified identifier /* 6.10.3.5 paragraph 2: [#undef] is ignored if the specified identifier
...@@ -343,7 +343,7 @@ parse_include (pfile, dir, trail, strp, lenp, abp) ...@@ -343,7 +343,7 @@ parse_include (pfile, dir, trail, strp, lenp, abp)
unsigned int *lenp; unsigned int *lenp;
int *abp; int *abp;
{ {
const cpp_token *name = cpp_get_token (pfile); const cpp_token *name = _cpp_get_token (pfile);
if (name->type != CPP_STRING && name->type != CPP_HEADER_NAME) if (name->type != CPP_STRING && name->type != CPP_HEADER_NAME)
{ {
...@@ -361,7 +361,7 @@ parse_include (pfile, dir, trail, strp, lenp, abp) ...@@ -361,7 +361,7 @@ parse_include (pfile, dir, trail, strp, lenp, abp)
return 1; return 1;
} }
if (!trail && cpp_get_token (pfile)->type != CPP_EOF) if (!trail && _cpp_get_token (pfile)->type != CPP_EOF)
cpp_error (pfile, "junk at end of #%s", dir); cpp_error (pfile, "junk at end of #%s", dir);
*lenp = name->val.str.len; *lenp = name->val.str.len;
...@@ -459,7 +459,7 @@ read_line_number (pfile, num) ...@@ -459,7 +459,7 @@ read_line_number (pfile, num)
cpp_reader *pfile; cpp_reader *pfile;
int *num; int *num;
{ {
const cpp_token *tok = cpp_get_token (pfile); const cpp_token *tok = _cpp_get_token (pfile);
enum cpp_ttype type = tok->type; enum cpp_ttype type = tok->type;
const U_CHAR *p = tok->val.str.text; const U_CHAR *p = tok->val.str.text;
unsigned int len = tok->val.str.len; unsigned int len = tok->val.str.len;
...@@ -519,7 +519,7 @@ do_line (pfile) ...@@ -519,7 +519,7 @@ do_line (pfile)
unsigned int len; unsigned int len;
const cpp_token *tok; const cpp_token *tok;
tok = cpp_get_token (pfile); tok = _cpp_get_token (pfile);
type = tok->type; type = tok->type;
str = tok->val.str.text; str = tok->val.str.text;
len = tok->val.str.len; len = tok->val.str.len;
...@@ -535,7 +535,7 @@ do_line (pfile) ...@@ -535,7 +535,7 @@ do_line (pfile)
old_lineno = ip->lineno; old_lineno = ip->lineno;
ip->lineno = new_lineno; ip->lineno = new_lineno;
tok = cpp_get_token (pfile); tok = _cpp_get_token (pfile);
type = tok->type; type = tok->type;
str = tok->val.str.text; str = tok->val.str.text;
len = tok->val.str.len; len = tok->val.str.len;
...@@ -645,9 +645,9 @@ do_ident (pfile) ...@@ -645,9 +645,9 @@ do_ident (pfile)
cpp_reader *pfile; cpp_reader *pfile;
{ {
/* Next token should be a string constant. */ /* Next token should be a string constant. */
if (cpp_get_token (pfile)->type == CPP_STRING) if (_cpp_get_token (pfile)->type == CPP_STRING)
/* And then a newline. */ /* And then a newline. */
if (cpp_get_token (pfile)->type == CPP_EOF) if (_cpp_get_token (pfile)->type == CPP_EOF)
{ {
/* Good - ship it. */ /* Good - ship it. */
pass_thru_directive (pfile); pass_thru_directive (pfile);
...@@ -725,7 +725,7 @@ do_pragma (pfile) ...@@ -725,7 +725,7 @@ do_pragma (pfile)
const cpp_token *tok; const cpp_token *tok;
int pop; int pop;
tok = cpp_get_token (pfile); tok = _cpp_get_token (pfile);
if (tok->type == CPP_EOF) if (tok->type == CPP_EOF)
return 0; return 0;
else if (tok->type != CPP_NAME) else if (tok->type != CPP_NAME)
...@@ -746,7 +746,7 @@ do_pragma_gcc (pfile) ...@@ -746,7 +746,7 @@ do_pragma_gcc (pfile)
{ {
const cpp_token *tok; const cpp_token *tok;
tok = cpp_get_token (pfile); tok = _cpp_get_token (pfile);
if (tok->type == CPP_EOF) if (tok->type == CPP_EOF)
return 1; return 1;
else if (tok->type != CPP_NAME) else if (tok->type != CPP_NAME)
...@@ -780,13 +780,13 @@ do_pragma_implementation (pfile) ...@@ -780,13 +780,13 @@ do_pragma_implementation (pfile)
{ {
/* Be quiet about `#pragma implementation' for a file only if it hasn't /* Be quiet about `#pragma implementation' for a file only if it hasn't
been included yet. */ been included yet. */
const cpp_token *tok = cpp_get_token (pfile); const cpp_token *tok = _cpp_get_token (pfile);
char *copy; char *copy;
if (tok->type == CPP_EOF) if (tok->type == CPP_EOF)
return 0; return 0;
else if (tok->type != CPP_STRING else if (tok->type != CPP_STRING
|| cpp_get_token (pfile)->type != CPP_EOF) || _cpp_get_token (pfile)->type != CPP_EOF)
{ {
cpp_error (pfile, "malformed #pragma implementation"); cpp_error (pfile, "malformed #pragma implementation");
return 1; return 1;
...@@ -822,7 +822,7 @@ do_pragma_poison (pfile) ...@@ -822,7 +822,7 @@ do_pragma_poison (pfile)
for (;;) for (;;)
{ {
tok = cpp_get_token (pfile); tok = _cpp_get_token (pfile);
if (tok->type == CPP_EOF) if (tok->type == CPP_EOF)
break; break;
if (tok->type != CPP_NAME) if (tok->type != CPP_NAME)
...@@ -887,7 +887,7 @@ do_pragma_dependency (pfile) ...@@ -887,7 +887,7 @@ do_pragma_dependency (pfile)
cpp_warning (pfile, "cannot find source %c%s%c", left, name, right); cpp_warning (pfile, "cannot find source %c%s%c", left, name, right);
else if (ordering > 0) else if (ordering > 0)
{ {
const cpp_token *msg = cpp_get_token (pfile); const cpp_token *msg = _cpp_get_token (pfile);
cpp_warning (pfile, "current file is older than %c%s%c", cpp_warning (pfile, "current file is older than %c%s%c",
left, name, right); left, name, right);
...@@ -974,7 +974,7 @@ parse_ifdef (pfile, name) ...@@ -974,7 +974,7 @@ parse_ifdef (pfile, name)
enum cpp_ttype type; enum cpp_ttype type;
const cpp_hashnode *node = 0; const cpp_hashnode *node = 0;
const cpp_token *token = cpp_get_token (pfile); const cpp_token *token = _cpp_get_token (pfile);
type = token->type; type = token->type;
if (!CPP_TRADITIONAL (pfile)) if (!CPP_TRADITIONAL (pfile))
...@@ -983,7 +983,7 @@ parse_ifdef (pfile, name) ...@@ -983,7 +983,7 @@ parse_ifdef (pfile, name)
cpp_pedwarn (pfile, "#%s with no argument", name); cpp_pedwarn (pfile, "#%s with no argument", name);
else if (type != CPP_NAME) else if (type != CPP_NAME)
cpp_pedwarn (pfile, "#%s with invalid argument", name); cpp_pedwarn (pfile, "#%s with invalid argument", name);
else if (cpp_get_token (pfile)->type != CPP_EOF) else if (_cpp_get_token (pfile)->type != CPP_EOF)
cpp_pedwarn (pfile, "garbage at end of #%s", name); cpp_pedwarn (pfile, "garbage at end of #%s", name);
} }
...@@ -1186,7 +1186,7 @@ validate_else (pfile, directive) ...@@ -1186,7 +1186,7 @@ validate_else (pfile, directive)
cpp_reader *pfile; cpp_reader *pfile;
const U_CHAR *directive; const U_CHAR *directive;
{ {
if (CPP_PEDANTIC (pfile) && cpp_get_token (pfile)->type != CPP_EOF) if (CPP_PEDANTIC (pfile) && _cpp_get_token (pfile)->type != CPP_EOF)
cpp_pedwarn (pfile, "ISO C forbids text after #%s", directive); cpp_pedwarn (pfile, "ISO C forbids text after #%s", directive);
} }
...@@ -1515,9 +1515,14 @@ cpp_push_buffer (pfile, buffer, length) ...@@ -1515,9 +1515,14 @@ cpp_push_buffer (pfile, buffer, length)
cpp_buffer *new; cpp_buffer *new;
if (++pfile->buffer_stack_depth == CPP_STACK_MAX) if (++pfile->buffer_stack_depth == CPP_STACK_MAX)
{ {
cpp_fatal (pfile, "#include recursion too deep"); cpp_fatal (pfile, "#include nested too deep");
return NULL; return NULL;
} }
if (pfile->cur_context > 0)
{
cpp_ice (pfile, "buffer pushed with contexts stacked");
_cpp_skip_rest_of_line (pfile);
}
new = xobnew (pfile->buffer_ob, cpp_buffer); new = xobnew (pfile->buffer_ob, cpp_buffer);
memset (new, 0, sizeof (cpp_buffer)); memset (new, 0, sizeof (cpp_buffer));
......
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