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
This commit is contained in:
Zack Weinberg 2000-06-21 18:33:51 +00:00 committed by Zack Weinberg
parent e3cd9945cb
commit c31a6508ee
8 changed files with 602 additions and 615 deletions

View File

@ -1,3 +1,40 @@
2000-06-21 Zack Weinberg <zack@wolery.cumb.org>
* 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.
Wed Jun 21 11:05:48 2000 Martin Buchholz <martin@xemacs.org>
* invoke.texi (g++): "g++" is not a script anymore.

File diff suppressed because it is too large Load Diff

View File

@ -1148,7 +1148,7 @@ special_symbol (pfile, hp)
case T_STDC:
#ifdef STDC_0_IN_SYSTEM_HEADERS
ip = cpp_file_buffer (pfile);
if (ip && ip->system_header_p
if (ip && ip->inc->sysp
&& !cpp_defined (pfile, DSC("__STRICT_ANSI__")))
{
CPP_PUTC (pfile, '0');

View File

@ -53,27 +53,27 @@ struct file_name_list
};
#define ABSOLUTE_PATH ((struct file_name_list *)-1)
/* This structure is used for the table of all includes. It is
indexed by the `short name' (the name as it appeared in the
#include statement) which is stored in *nshort. */
struct ihash
/* This structure is used for the table of all includes. */
struct include_file
{
/* Next file with the same short name but a
different (partial) pathname). */
struct ihash *next_this_file;
/* Location of the file in the include search path.
Used for include_next and to detect redundant includes. */
struct file_name_list *foundhere;
unsigned int hash; /* save hash value for future reference */
const char *nshort; /* name of file as referenced in #include;
points into name[] */
const char *name; /* actual path name of file */
const cpp_hashnode *cmacro; /* macro, if any, preventing reinclusion. */
const char name[1]; /* (partial) pathname of file */
const struct file_name_list *foundhere;
/* location in search path where file was
found, for #include_next */
int fd; /* file descriptor possibly open on file */
unsigned char before; /* file has been included before */
unsigned char sysp; /* file is a system header */
};
typedef struct ihash IHASH;
#define NEVER_REINCLUDE ((const cpp_hashnode *)-1)
/* The cmacro works like this: If it's NULL, the file is to be
included again. If it's NEVER_REREAD, the file is never to be
included again. Otherwise it is a macro hashnode, and the file is
to be included again if the macro is not defined. */
#define NEVER_REREAD ((const cpp_hashnode *)-1)
#define DO_NOT_REREAD(inc) \
((inc)->cmacro && \
((inc)->cmacro == NEVER_REREAD || (inc)->cmacro->type != T_VOID))
/* Character classes.
If the definition of `numchar' looks odd to you, please look up the
@ -143,10 +143,11 @@ extern unsigned char _cpp_IStable[256];
#define CPP_PRINT_DEPS(PFILE) CPP_OPTION (PFILE, print_deps)
#define CPP_TRADITIONAL(PFILE) CPP_OPTION (PFILE, traditional)
#define CPP_PEDANTIC(PFILE) \
(CPP_OPTION (PFILE, pedantic) && !CPP_BUFFER (PFILE)->system_header_p)
#define CPP_IN_SYSTEM_HEADER(PFILE) (cpp_file_buffer (PFILE)->inc->sysp)
#define CPP_PEDANTIC(PF) \
(CPP_OPTION (PF, pedantic) && !CPP_IN_SYSTEM_HEADER (PF))
#define CPP_WTRADITIONAL(PF) \
(CPP_OPTION (PF, warn_traditional) && !CPP_BUFFER (PF)->system_header_p)
(CPP_OPTION (PF, warn_traditional) && !CPP_IN_SYSTEM_HEADER (PF))
/* CPP_IS_MACRO_BUFFER is true if the buffer contains macro expansion.
(Note that it is false while we're expanding macro *arguments*.) */
@ -192,8 +193,8 @@ extern void _cpp_simplify_pathname PARAMS ((char *));
extern void _cpp_execute_include PARAMS ((cpp_reader *, U_CHAR *,
unsigned int, int,
struct file_name_list *));
extern void _cpp_init_include_hash PARAMS ((cpp_reader *));
extern const char *_cpp_fake_ihash PARAMS ((cpp_reader *, const char *));
extern void _cpp_init_include_table PARAMS ((cpp_reader *));
extern const char *_cpp_fake_include PARAMS ((cpp_reader *, const char *));
/* In cppexp.c */
extern int _cpp_parse_expr PARAMS ((cpp_reader *));
@ -234,6 +235,10 @@ extern int _cpp_handle_directive PARAMS ((cpp_reader *));
extern void _cpp_unwind_if_stack PARAMS ((cpp_reader *, cpp_buffer *));
extern void _cpp_check_directive PARAMS ((cpp_toklist *, cpp_token *));
/* Utility routines and macros. */
#define xnew(T) (T *) xmalloc (sizeof(T))
#define xnewvec(T, N) (T *) xmalloc (sizeof(T) * (N))
/* These are inline functions instead of macros so we can get type
checking. */

View File

@ -22,6 +22,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "config.h"
#include "system.h"
#include "hashtab.h"
#include "splay-tree.h"
#include "cpplib.h"
#include "cpphash.h"
#include "output.h"
@ -551,7 +552,7 @@ cpp_reader_init (pfile)
(struct cpp_pending *) xcalloc (1, sizeof (struct cpp_pending));
_cpp_init_macro_hash (pfile);
_cpp_init_include_hash (pfile);
_cpp_init_include_table (pfile);
}
/* Initialize a cpp_printer structure. As a side effect, open the
@ -605,7 +606,7 @@ cpp_cleanup (pfile)
deps_free (pfile->deps);
htab_delete (pfile->hashtab);
htab_delete (pfile->all_include_files);
splay_tree_delete (pfile->all_include_files);
}

View File

@ -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))
{

View File

@ -214,7 +214,7 @@ _cpp_handle_directive (pfile)
return 0;
if (CPP_PEDANTIC (pfile)
&& CPP_BUFFER (pfile)->ihash
&& CPP_BUFFER (pfile)->inc
&& ! CPP_OPTION (pfile, preprocessed))
cpp_pedwarn (pfile, "# followed by integer");
i = T_LINE;
@ -463,7 +463,7 @@ do_import (pfile)
U_CHAR *token;
if (CPP_OPTION (pfile, warn_import)
&& !CPP_BUFFER (pfile)->system_header_p && !pfile->import_warning)
&& !CPP_IN_SYSTEM_HEADER (pfile) && !pfile->import_warning)
{
pfile->import_warning = 1;
cpp_warning (pfile,
@ -508,8 +508,8 @@ do_include_next (pfile)
file like any other included source, but generate a warning. */
if (CPP_PREV_BUFFER (CPP_BUFFER (pfile)))
{
if (CPP_BUFFER (pfile)->ihash->foundhere != ABSOLUTE_PATH)
search_start = CPP_BUFFER (pfile)->ihash->foundhere->next;
if (CPP_BUFFER (pfile)->inc->foundhere)
search_start = CPP_BUFFER (pfile)->inc->foundhere->next;
}
else
cpp_warning (pfile, "#include_next in primary source file");
@ -603,23 +603,23 @@ do_line (pfile)
if (action_number == 1)
{
pfile->buffer_stack_depth++;
ip->system_header_p = 0;
ip->inc->sysp = 0;
read_line_number (pfile, &action_number);
}
else if (action_number == 2)
{
pfile->buffer_stack_depth--;
ip->system_header_p = 0;
ip->inc->sysp = 0;
read_line_number (pfile, &action_number);
}
if (action_number == 3)
{
ip->system_header_p = 1;
ip->inc->sysp = 1;
read_line_number (pfile, &action_number);
}
if (action_number == 4)
{
ip->system_header_p = 2;
ip->inc->sysp = 2;
read_line_number (pfile, &action_number);
}
}
@ -628,10 +628,10 @@ do_line (pfile)
if (strcmp ((const char *)fname, ip->nominal_fname))
{
if (!strcmp ((const char *)fname, ip->ihash->name))
ip->nominal_fname = ip->ihash->name;
if (!strcmp ((const char *)fname, ip->inc->name))
ip->nominal_fname = ip->inc->name;
else
ip->nominal_fname = _cpp_fake_ihash (pfile, (const char *)fname);
ip->nominal_fname = _cpp_fake_include (pfile, (const char *)fname);
}
}
else if (token != CPP_VSPACE && token != CPP_EOF)
@ -868,13 +868,13 @@ do_pragma_once (pfile)
/* Allow #pragma once in system headers, since that's not the user's
fault. */
if (!ip->system_header_p)
if (!CPP_IN_SYSTEM_HEADER (pfile))
cpp_warning (pfile, "#pragma once is obsolete");
if (CPP_PREV_BUFFER (ip) == NULL)
cpp_warning (pfile, "#pragma once outside include file");
else
ip->ihash->cmacro = NEVER_REINCLUDE;
ip->inc->cmacro = NEVER_REREAD;
return 1;
}
@ -978,7 +978,7 @@ do_pragma_system_header (pfile)
if (CPP_PREV_BUFFER (ip) == NULL)
cpp_warning (pfile, "#pragma system_header outside include file");
else
ip->system_header_p = 1;
ip->inc->sysp = 1;
return 1;
}

View File

@ -233,9 +233,9 @@ struct cpp_buffer
/* Actual directory of this file, used only for "" includes */
struct file_name_list *actual_dir;
/* Pointer into the include hash table. Used for include_next and
/* Pointer into the include table. Used for include_next and
to record control macros. */
struct ihash *ihash;
struct include_file *inc;
/* If the buffer is the expansion of a macro, this points to the
macro's hash table entry. */
@ -248,9 +248,6 @@ struct cpp_buffer
/* Line number at line_base (above). */
unsigned int lineno;
/* True if this is a header file included using <FILENAME>. */
char system_header_p;
/* True if buffer contains escape sequences.
Currently there are two kinds:
"\r-" means following identifier should not be macro-expanded.
@ -499,7 +496,7 @@ struct cpp_reader
struct htab *hashtab;
/* Hash table of other included files. See cppfiles.c */
struct htab *all_include_files;
struct splay_tree_s *all_include_files;
/* Chain of `actual directory' file_name_list entries,
for "" inclusion. */