Commit fb753f88 by Jakub Jelinek Committed by Jakub Jelinek

cpplib.h (struct cpp_reader): New field include_depth.

	* cpplib.h (struct cpp_reader): New field include_depth.
	(struct cpp_printer): Rename last_bsd to last_id.
	* cppfiles.c (read_include_file): Bump include_depth.
	* cpplex.c (cpp_pop_buffer): Decrement include_depth.
	(output_line_command): Output correct #line if a header
	is including itself and is not protected against multiple inclusion.
	Use include_depth instead of buffer_stack_depth, last_id instead of
	last_bsd.
	* cppinit.c (cpp_start_read): Initialize last_id instead of
	last_bsd.

From-SVN: r34831
parent 970d6386
2000-07-02 Jakub Jelinek <jakub@redhat.com>
* cpplib.h (struct cpp_reader): New field include_depth.
(struct cpp_printer): Rename last_bsd to last_id.
* cppfiles.c (read_include_file): Bump include_depth.
* cpplex.c (cpp_pop_buffer): Decrement include_depth.
(output_line_command): Output correct #line if a header
is including itself and is not protected against multiple inclusion.
Use include_depth instead of buffer_stack_depth, last_id instead of
last_bsd.
* cppinit.c (cpp_start_read): Initialize last_id instead of
last_bsd.
2000-07-01 Benjamin Chelf <chelf@codesourcery.com> 2000-07-01 Benjamin Chelf <chelf@codesourcery.com>
* Makefile.in (C_AND_OBJC_OBJS): Added c-semantics.o. * Makefile.in (C_AND_OBJC_OBJS): Added c-semantics.o.
......
...@@ -618,6 +618,7 @@ read_include_file (pfile, inc) ...@@ -618,6 +618,7 @@ read_include_file (pfile, inc)
/* These must be set before prescan. */ /* These must be set before prescan. */
fp->inc = inc; fp->inc = inc;
fp->nominal_fname = inc->name; fp->nominal_fname = inc->name;
pfile->include_depth++;
if (length == 0) if (length == 0)
inc->cmacro = NEVER_REREAD; inc->cmacro = NEVER_REREAD;
......
...@@ -951,7 +951,7 @@ cpp_start_read (pfile, print, fname) ...@@ -951,7 +951,7 @@ cpp_start_read (pfile, print, fname)
{ {
print->lineno = 0; print->lineno = 0;
print->last_fname = CPP_BUFFER (pfile)->nominal_fname; print->last_fname = CPP_BUFFER (pfile)->nominal_fname;
print->last_bsd = pfile->buffer_stack_depth; print->last_id = pfile->include_depth;
print->written = CPP_WRITTEN (pfile); print->written = CPP_WRITTEN (pfile);
} }
......
...@@ -218,6 +218,8 @@ cpp_pop_buffer (pfile) ...@@ -218,6 +218,8 @@ cpp_pop_buffer (pfile)
free ((PTR) buf->buf); free ((PTR) buf->buf);
if (pfile->system_include_depth) if (pfile->system_include_depth)
pfile->system_include_depth--; pfile->system_include_depth--;
if (pfile->include_depth)
pfile->include_depth--;
if (pfile->potential_control_macro) if (pfile->potential_control_macro)
{ {
if (buf->inc->cmacro != NEVER_REREAD) if (buf->inc->cmacro != NEVER_REREAD)
...@@ -289,25 +291,26 @@ output_line_command (pfile, print, line) ...@@ -289,25 +291,26 @@ output_line_command (pfile, print, line)
if (CPP_OPTION (pfile, no_line_commands)) if (CPP_OPTION (pfile, no_line_commands))
return; return;
/* Determine whether the current filename has changed, and if so, if (pfile->include_depth == print->last_id)
how. 'nominal_fname' values are unique, so they can be compared
by comparing pointers. */
if (ip->nominal_fname == print->last_fname)
change = same;
else
{ {
if (pfile->buffer_stack_depth == print->last_bsd) /* Determine whether the current filename has changed, and if so,
how. 'nominal_fname' values are unique, so they can be compared
by comparing pointers. */
if (ip->nominal_fname == print->last_fname)
change = same;
else
change = rname; change = rname;
}
else
{
if (pfile->include_depth > print->last_id)
change = enter;
else else
{ change = leave;
if (pfile->buffer_stack_depth > print->last_bsd) print->last_id = pfile->include_depth;
change = enter;
else
change = leave;
print->last_bsd = pfile->buffer_stack_depth;
}
print->last_fname = ip->nominal_fname;
} }
print->last_fname = ip->nominal_fname;
/* If the current file has not changed, we can output a few newlines /* If the current file has not changed, we can output a few newlines
instead if we want to increase the line number by a small amount. instead if we want to increase the line number by a small amount.
We cannot do this if print->lineno is zero, because that means we We cannot do this if print->lineno is zero, because that means we
......
...@@ -492,6 +492,9 @@ struct cpp_reader ...@@ -492,6 +492,9 @@ struct cpp_reader
/* Current depth of buffer stack. */ /* Current depth of buffer stack. */
unsigned int buffer_stack_depth; unsigned int buffer_stack_depth;
/* Current depth in #include directives. */
unsigned int include_depth;
/* Hash table of macros and assertions. See cpphash.c */ /* Hash table of macros and assertions. See cpphash.c */
struct htab *hashtab; struct htab *hashtab;
...@@ -564,7 +567,7 @@ struct cpp_printer ...@@ -564,7 +567,7 @@ struct cpp_printer
{ {
FILE *outf; /* stream to write to */ FILE *outf; /* stream to write to */
const char *last_fname; /* previous file name */ const char *last_fname; /* previous file name */
unsigned int last_bsd; /* did we just push? */ unsigned int last_id; /* did we just push? */
unsigned int lineno; /* line currently being written */ unsigned int lineno; /* line currently being written */
unsigned int written; /* low water mark in token buffer */ unsigned int written; /* low water mark in token 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