cppfiles.c: Include mkdeps.h.

* cppfiles.c: Include mkdeps.h.
	(find_include_file, read_include_file): Remove _cpp_ prefix
	from name, make static.
	(_cpp_execute_include): New function, broken out of
	do_include.

	* cpplib.c: Don't include mkdeps.h.
	(struct directive): Remove type field. Reorder entries.  The
	function takes only one argument.
	(struct if_stack): Make type field an int.
	(directive_table): Rename to dtable.  Generate it, the
	prototypes of the directive handlers, and the enum for the
	directive numbers, from a template macro.
	(do_ifndef, do_include_next, do_import): New functions.
	(do_define, do_include, do_endif, do_ifdef, do_if, do_else,
	do_undef, do_line, do_elif, do_error, do_pragma, do_warning,
	do_ident, do_assert, do_unassert, do_sccs): Take only one
	argument.
	(do_sccs): Define always, but alter behavior based on
	SCCS_DIRECTIVE.
	(_cpp_handle_directive, consider_directive_while_skipping):
	Restructure for new directive table layout.

	(pass_thru_directive): Take a directive number, not a pointer
	to a struct directive.
	(parse_include): New function, broken out of do_include.
	(do_include, do_import, do_include_next): Use parse_include
	and _cpp_execute_include.
	(do_elif, do_else): Test for T_ELSE specifically when checking
	for #elif/#else after #else.
	(parse_ifdef): New function, broken out of do_ifdef.
	(validate_else): Expect a name arg without a leading #.
	(if_directive_name): Delete.
	(cpp_define, cpp_assert, cpp_undef, cpp_unassert): Call
	directive handlers with only one argument.

	* cpphash.h: Update prototypes.
	(enum node_type): Remove entries for directives.
	* Makefile.in: Update dependencies.

From-SVN: r32519
This commit is contained in:
Zack Weinberg 2000-03-14 06:34:11 +00:00 committed by Zack Weinberg
parent 194ae3f644
commit 168d3732aa
5 changed files with 488 additions and 445 deletions

View File

@ -1,5 +1,45 @@
2000-03-13 Zack Weinberg <zack@wolery.cumb.org>
* cppfiles.c: Include mkdeps.h.
(find_include_file, read_include_file): Remove _cpp_ prefix
from name, make static.
(_cpp_execute_include): New function, broken out of
do_include.
* cpplib.c: Don't include mkdeps.h.
(struct directive): Remove type field. Reorder entries. The
function takes only one argument.
(struct if_stack): Make type field an int.
(directive_table): Rename to dtable. Generate it, the
prototypes of the directive handlers, and the enum for the
directive numbers, from a template macro.
(do_ifndef, do_include_next, do_import): New functions.
(do_define, do_include, do_endif, do_ifdef, do_if, do_else,
do_undef, do_line, do_elif, do_error, do_pragma, do_warning,
do_ident, do_assert, do_unassert, do_sccs): Take only one
argument.
(do_sccs): Define always, but alter behavior based on
SCCS_DIRECTIVE.
(_cpp_handle_directive, consider_directive_while_skipping):
Restructure for new directive table layout.
(pass_thru_directive): Take a directive number, not a pointer
to a struct directive.
(parse_include): New function, broken out of do_include.
(do_include, do_import, do_include_next): Use parse_include
and _cpp_execute_include.
(do_elif, do_else): Test for T_ELSE specifically when checking
for #elif/#else after #else.
(parse_ifdef): New function, broken out of do_ifdef.
(validate_else): Expect a name arg without a leading #.
(if_directive_name): Delete.
(cpp_define, cpp_assert, cpp_undef, cpp_unassert): Call
directive handlers with only one argument.
* cpphash.h: Update prototypes.
(enum node_type): Remove entries for directives.
* Makefile.in: Update dependencies.
* cpphash.c (dump_hash_helper): Only dump nodes of type
T_MACRO. Emit a newline after each definition.

View File

@ -2050,9 +2050,9 @@ cppulp.o: cppulp.c $(CONFIG_H) system.h output.h
cpperror.o: cpperror.c $(CONFIG_H) $(LIBCPP_DEPS)
cppexp.o: cppexp.c $(CONFIG_H) $(LIBCPP_DEPS)
cpplex.o: cpplex.c $(CONFIG_H) $(LIBCPP_DEPS)
cppfiles.o: cppfiles.c $(CONFIG_H) $(LIBCPP_DEPS) $(HASHTAB_H)
cpplib.o: cpplib.c $(CONFIG_H) $(LIBCPP_DEPS) $(HASHTAB_H)
cpphash.o: cpphash.c $(CONFIG_H) $(LIBCPP_DEPS) $(HASHTAB_H)
cpplib.o: cpplib.c $(CONFIG_H) $(LIBCPP_DEPS) $(HASHTAB_H) mkdeps.h
cppfiles.o: cppfiles.c $(CONFIG_H) $(LIBCPP_DEPS) $(HASHTAB_H) mkdeps.h
cppinit.o: cppinit.c $(CONFIG_H) $(LIBCPP_DEPS) $(HASHTAB_H) mkdeps.h \
prefix.h output.h Makefile version.h

View File

@ -30,6 +30,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "cpphash.h"
#include "hashtab.h"
#include "intl.h"
#include "mkdeps.h"
static IHASH *redundant_include_p PARAMS ((cpp_reader *, IHASH *,
struct file_name_list *));
@ -40,11 +41,14 @@ static char *remap_filename PARAMS ((cpp_reader *, char *,
struct file_name_list *));
static struct file_name_list *actual_directory
PARAMS ((cpp_reader *, const char *));
static unsigned int hash_IHASH PARAMS ((const void *));
static int eq_IHASH PARAMS ((const void *, const void *));
static int file_cleanup PARAMS ((cpp_buffer *, cpp_reader *));
static int find_include_file PARAMS ((cpp_reader *, const char *,
struct file_name_list *,
IHASH **, int *));
static int read_include_file PARAMS ((cpp_reader *, int, IHASH *));
#if 0
static void hack_vms_include_specification PARAMS ((char *));
@ -58,7 +62,7 @@ static void hack_vms_include_specification PARAMS ((char *));
#endif
/* Open files in nonblocking mode, so we don't get stuck if someone
clever has asked cpp to process /dev/rmt0. _cpp_read_include_file
clever has asked cpp to process /dev/rmt0. read_include_file
will check that we have a real file to work with. Also take care
not to acquire a controlling terminal by mistake (this can't happen
on sane systems, but paranoia is a virtue). */
@ -185,8 +189,8 @@ file_cleanup (pbuf, pfile)
*IHASH is set to point to the include hash entry for this file, and
*BEFORE is set to 1 if the file was included before (but needs to be read
again). */
int
_cpp_find_include_file (pfile, fname, search_start, ihash, before)
static int
find_include_file (pfile, fname, search_start, ihash, before)
cpp_reader *pfile;
const char *fname;
struct file_name_list *search_start;
@ -465,6 +469,120 @@ remap_filename (pfile, name, loc)
return name;
}
void
_cpp_execute_include (pfile, fname, len, no_reinclude, search_start)
cpp_reader *pfile;
char *fname;
unsigned int len;
int no_reinclude;
struct file_name_list *search_start;
{
IHASH *ihash;
int fd;
int angle_brackets = fname[0] == '<';
int before;
if (!search_start)
{
if (angle_brackets)
search_start = CPP_OPTIONS (pfile)->bracket_include;
else if (CPP_OPTIONS (pfile)->ignore_srcdir)
search_start = CPP_OPTIONS (pfile)->quote_include;
else
search_start = CPP_BUFFER (pfile)->actual_dir;
}
if (!search_start)
{
cpp_error (pfile, "No include path in which to find %s", fname);
return;
}
/* Remove quote marks. */
fname++;
len -= 2;
fname[len] = '\0';
fd = find_include_file (pfile, fname, search_start, &ihash, &before);
if (fd == -2)
return;
if (fd == -1)
{
if (CPP_OPTIONS (pfile)->print_deps_missing_files
&& CPP_PRINT_DEPS (pfile) > (angle_brackets ||
(pfile->system_include_depth > 0)))
{
if (!angle_brackets)
deps_add_dep (pfile->deps, fname);
else
{
char *p;
struct file_name_list *ptr;
/* If requested as a system header, assume it belongs in
the first system header directory. */
if (CPP_OPTIONS (pfile)->bracket_include)
ptr = CPP_OPTIONS (pfile)->bracket_include;
else
ptr = CPP_OPTIONS (pfile)->quote_include;
p = (char *) alloca (strlen (ptr->name)
+ strlen (fname) + 2);
if (*ptr->name != '\0')
{
strcpy (p, ptr->name);
strcat (p, "/");
}
strcat (p, fname);
deps_add_dep (pfile->deps, p);
}
}
/* If -M was specified, and this header file won't be added to
the dependency list, then don't count this as an error,
because we can still produce correct output. Otherwise, we
can't produce correct output, because there may be
dependencies we need inside the missing file, and we don't
know what directory this missing file exists in. */
else if (CPP_PRINT_DEPS (pfile)
&& (CPP_PRINT_DEPS (pfile)
<= (angle_brackets || (pfile->system_include_depth > 0))))
cpp_warning (pfile, "No include path in which to find %s", fname);
else
cpp_error_from_errno (pfile, fname);
return;
}
/* For -M, add the file to the dependencies on its first inclusion. */
if (!before && (CPP_PRINT_DEPS (pfile)
> (angle_brackets || (pfile->system_include_depth > 0))))
deps_add_dep (pfile->deps, ihash->name);
/* Handle -H option. */
if (CPP_OPTIONS(pfile)->print_include_names)
{
cpp_buffer *fp = CPP_BUFFER (pfile);
while ((fp = CPP_PREV_BUFFER (fp)) != NULL)
putc ('.', stderr);
fprintf (stderr, " %s\n", ihash->name);
}
/* Actually process the file */
if (no_reinclude)
ihash->control_macro = (const U_CHAR *) "";
if (read_include_file (pfile, fd, ihash))
{
_cpp_output_line_command (pfile, enter_file);
if (angle_brackets)
pfile->system_include_depth++; /* Decremented in file_cleanup. */
}
}
/* Push an input buffer and load it up with the contents of FNAME.
If FNAME is "" or NULL, read standard input. */
int
@ -506,7 +624,7 @@ cpp_read_file (pfile, fname)
else
f = open (fname, OMODES);
return _cpp_read_include_file (pfile, f, ih);
return read_include_file (pfile, f, ih);
}
/* Read the contents of FD into the buffer on the top of PFILE's stack.
@ -515,8 +633,8 @@ cpp_read_file (pfile, fname)
The caller is responsible for the cpp_push_buffer. */
int
_cpp_read_include_file (pfile, fd, ihash)
static int
read_include_file (pfile, fd, ihash)
cpp_reader *pfile;
int fd;
IHASH *ihash;

View File

@ -83,28 +83,9 @@ struct definition
It does not contain control words like "#define", which are recognized
by a separate piece of code. */
/* different flavors of hash nodes --- also used in keyword table */
/* different flavors of hash nodes */
enum node_type
{
T_DEFINE = 1, /* `#define' */
T_INCLUDE, /* `#include' */
T_INCLUDE_NEXT, /* `#include_next' */
T_IMPORT, /* `#import' */
T_IFDEF, /* `#ifdef' */
T_IFNDEF, /* `#ifndef' */
T_IF, /* `#if' */
T_ELSE, /* `#else' */
T_PRAGMA, /* `#pragma' */
T_ELIF, /* `#elif' */
T_UNDEF, /* `#undef' */
T_LINE, /* `#line' */
T_ERROR, /* `#error' */
T_WARNING, /* `#warning' */
T_ENDIF, /* `#endif' */
T_SCCS, /* `#sccs' */
T_IDENT, /* `#ident' */
T_ASSERT, /* `#assert' */
T_UNASSERT, /* `#unassert', */
T_SPECLINE, /* `__LINE__' */
T_DATE, /* `__DATE__' */
T_FILE, /* `__FILE__' */
@ -292,10 +273,9 @@ extern void _cpp_dump_macro_hash PARAMS ((cpp_reader *));
/* In cppfiles.c */
extern void _cpp_simplify_pathname PARAMS ((char *));
extern int _cpp_find_include_file PARAMS ((cpp_reader *, const char *,
struct file_name_list *,
IHASH **, int *));
extern int _cpp_read_include_file PARAMS ((cpp_reader *, int, IHASH *));
extern void _cpp_execute_include PARAMS ((cpp_reader *, char *,
unsigned int, int,
struct file_name_list *));
extern void _cpp_init_include_hash PARAMS ((cpp_reader *));
/* In cppexp.c */

File diff suppressed because it is too large Load Diff