aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplex.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@wolery.cumb.org>2000-06-21 18:33:51 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-06-21 18:33:51 +0000
commitc31a6508eedf17dc50388f1694bc131bd965004f (patch)
treeeb5aadb8fbe401846a1ceb69f99c1b4e7af8d929 /gcc/cpplex.c
parente3cd9945cbe33d50af459b6b4951d3dcb12a33f7 (diff)
downloadgcc-c31a6508eedf17dc50388f1694bc131bd965004f.zip
gcc-c31a6508eedf17dc50388f1694bc131bd965004f.tar.gz
gcc-c31a6508eedf17dc50388f1694bc131bd965004f.tar.bz2
cppfiles.c: Include splay-tree.h, not hashtab.h.
* cppfiles.c: Include splay-tree.h, not hashtab.h. (redundant_include_p, make_IHASH, hash_IHASH, eq_IHASH): Delete. (destroy_include_file_node): New. (_cpp_init_include_hash): Rename _cpp_init_include_table. Create a splay tree, not a hash table. (open_include_file): Look up the path in the include table, do the multiple include optimization here, etc. (cpp_included): Walk the path. (find_include_file): Just walk the path calling open_include_file, or call it directly for an absolute path. (_cpp_fake_ihash): Rename _cpp_fake_include and update for new scheme. (read_include_file): Update for new scheme. Don't close the file unless reading fails. (_cpp_execute_include, cpp_read_file): Tweak for new scheme. * cpphash.h (struct ihash, NEVER_REINCLUDE): Delete. (struct include_file): New. (NEVER_REREAD, DO_NOT_REREAD, CPP_IN_SYSTEM_HEADER): New macros. (CPP_PEDANTIC, CPP_WTRADITIONAL): Update. Update prototypes. * cppinit.c: Include splay-tree.h. (cpp_reader_init, cpp_cleanup): Update. * cpplib.h (struct cpp_buffer): Change ihash field to 'struct include_file *inc'. Remove system_header_p. (struct cpp_reader): Change all_include_files to a struct splay_tree_s *. * cpplex.c: Update all references to cpp_buffer->ihash and/or cpp_buffer->system_header_p. (cpp_pop_buffer): Close file here, only if DO_NOT_REREAD. From-SVN: r34636
Diffstat (limited to 'gcc/cpplex.c')
-rw-r--r--gcc/cpplex.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/gcc/cpplex.c b/gcc/cpplex.c
index 4a159aa..b7f6da5 100644
--- a/gcc/cpplex.c
+++ b/gcc/cpplex.c
@@ -211,7 +211,7 @@ cpp_pop_buffer (pfile)
if (ACTIVE_MARK_P (pfile))
cpp_ice (pfile, "mark active in cpp_pop_buffer");
- if (buf->ihash)
+ if (buf->inc)
{
_cpp_unwind_if_stack (pfile, buf);
if (buf->buf)
@@ -220,10 +220,17 @@ cpp_pop_buffer (pfile)
pfile->system_include_depth--;
if (pfile->potential_control_macro)
{
- buf->ihash->cmacro = pfile->potential_control_macro;
+ if (buf->inc->cmacro != NEVER_REREAD)
+ buf->inc->cmacro = pfile->potential_control_macro;
pfile->potential_control_macro = 0;
}
pfile->input_stack_listing_current = 0;
+ /* If the file will not be included again, then close it. */
+ if (DO_NOT_REREAD (buf->inc))
+ {
+ close (buf->inc->fd);
+ buf->inc->fd = -1;
+ }
}
else if (buf->macro)
{
@@ -321,13 +328,13 @@ output_line_command (pfile, print, line)
if (CPP_OPTION (pfile, cplusplus))
fprintf (print->outf, "# %u \"%s\"%s%s%s\n", line, ip->nominal_fname,
codes[change],
- ip->system_header_p ? " 3" : "",
- (ip->system_header_p == 2) ? " 4" : "");
+ ip->inc->sysp ? " 3" : "",
+ (ip->inc->sysp == 2) ? " 4" : "");
else
#endif
fprintf (print->outf, "# %u \"%s\"%s%s\n", line, ip->nominal_fname,
codes[change],
- ip->system_header_p ? " 3" : "");
+ ip->inc->sysp ? " 3" : "");
print->lineno = line;
}
@@ -516,7 +523,7 @@ cpp_file_buffer (pfile)
cpp_buffer *ip;
for (ip = CPP_BUFFER (pfile); ip; ip = CPP_PREV_BUFFER (ip))
- if (ip->ihash != NULL)
+ if (ip->inc != NULL)
return ip;
return NULL;
}
@@ -914,7 +921,7 @@ skip_comment (pfile, m)
}
else if (m == '/' && PEEKC() == '/')
{
- if (CPP_BUFFER (pfile)->system_header_p)
+ if (CPP_IN_SYSTEM_HEADER (pfile))
{
/* We silently allow C++ comments in system headers, irrespective
of conformance mode, because lots of busted systems do that
@@ -2965,7 +2972,7 @@ _cpp_lex_line (pfile, list)
irrespective of conformance mode, because lots of
broken systems do that and trying to clean it up
in fixincludes is a nightmare. */
- if (buffer->system_header_p)
+ if (CPP_IN_SYSTEM_HEADER (pfile))
goto do_line_comment;
else if (CPP_OPTION (pfile, cplusplus_comments))
{