[multiple changes]
1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* c-lang.c: Declare extern char *yy_cur if USE_CPPLIB.
(lang_init): Call check_newline always.
* c-lex.c (init_parse) [USE_CPPLIB=1]: After calling
cpp_start_read, set yy_cur and yy_lim to read from
parse_in.token_buffer, so that we'll see the first #line
directive.
* cpplib.c (cpp_start_read): finclude the main input file
before processing -include/-imacros. Process -imacros and
-include separately, and handle -include by stacking a
buffer for the file in question as if it'd been #included.
* toplev.c (documented_lang_options) Recognize -H when
USE_CPPLIB is on.
1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.c: Merge do_once into do_pragma. Break file handling
code out of do_include.
Move append_include_chain, deps_output,
file_cleanup, redundant_include_p, import_hash,
lookup_import, add_import, read_filename_string, read_name_map,
open_include_file, finclude, safe_read to cppfiles.c.
Move prototypes for deps_output, append_include_chain,
finclude to cpplib.h. Move definition of struct
file_name_list there also.
* cppfiles.c: New file. Contains all the above functions
broken out of cpplib.c; also hack_vms_include_specification
from cccp.c and find_include_file, a new function broken out of
do_include.
* Makefile.in (cppmain): Depend on cppfiles.o.
(fix-header): Likewise.
(cppfiles.o): New target.
* configure.in (--enable-c-cpplib): Add cppfiles.o to
extra_c_objs. Add ../cppfiles.o to extra_cxx_objs.
From-SVN: r23424
1998-10-29 19:54:13 +08:00
|
|
|
/* Part of CPP library. (include file handling)
|
2000-02-26 13:59:31 +08:00
|
|
|
Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1998,
|
2001-01-14 02:39:26 +08:00
|
|
|
1999, 2000, 2001 Free Software Foundation, Inc.
|
[multiple changes]
1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* c-lang.c: Declare extern char *yy_cur if USE_CPPLIB.
(lang_init): Call check_newline always.
* c-lex.c (init_parse) [USE_CPPLIB=1]: After calling
cpp_start_read, set yy_cur and yy_lim to read from
parse_in.token_buffer, so that we'll see the first #line
directive.
* cpplib.c (cpp_start_read): finclude the main input file
before processing -include/-imacros. Process -imacros and
-include separately, and handle -include by stacking a
buffer for the file in question as if it'd been #included.
* toplev.c (documented_lang_options) Recognize -H when
USE_CPPLIB is on.
1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.c: Merge do_once into do_pragma. Break file handling
code out of do_include.
Move append_include_chain, deps_output,
file_cleanup, redundant_include_p, import_hash,
lookup_import, add_import, read_filename_string, read_name_map,
open_include_file, finclude, safe_read to cppfiles.c.
Move prototypes for deps_output, append_include_chain,
finclude to cpplib.h. Move definition of struct
file_name_list there also.
* cppfiles.c: New file. Contains all the above functions
broken out of cpplib.c; also hack_vms_include_specification
from cccp.c and find_include_file, a new function broken out of
do_include.
* Makefile.in (cppmain): Depend on cppfiles.o.
(fix-header): Likewise.
(cppfiles.o): New target.
* configure.in (--enable-c-cpplib): Add cppfiles.o to
extra_c_objs. Add ../cppfiles.o to extra_cxx_objs.
From-SVN: r23424
1998-10-29 19:54:13 +08:00
|
|
|
Written by Per Bothner, 1994.
|
|
|
|
Based on CCCP program by Paul Rubin, June 1986
|
|
|
|
Adapted to ANSI C, Richard Stallman, Jan 1987
|
|
|
|
Split out of cpplib.c, Zack Weinberg, Oct 1998
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2000-04-19 04:42:00 +08:00
|
|
|
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
[multiple changes]
1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* c-lang.c: Declare extern char *yy_cur if USE_CPPLIB.
(lang_init): Call check_newline always.
* c-lex.c (init_parse) [USE_CPPLIB=1]: After calling
cpp_start_read, set yy_cur and yy_lim to read from
parse_in.token_buffer, so that we'll see the first #line
directive.
* cpplib.c (cpp_start_read): finclude the main input file
before processing -include/-imacros. Process -imacros and
-include separately, and handle -include by stacking a
buffer for the file in question as if it'd been #included.
* toplev.c (documented_lang_options) Recognize -H when
USE_CPPLIB is on.
1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.c: Merge do_once into do_pragma. Break file handling
code out of do_include.
Move append_include_chain, deps_output,
file_cleanup, redundant_include_p, import_hash,
lookup_import, add_import, read_filename_string, read_name_map,
open_include_file, finclude, safe_read to cppfiles.c.
Move prototypes for deps_output, append_include_chain,
finclude to cpplib.h. Move definition of struct
file_name_list there also.
* cppfiles.c: New file. Contains all the above functions
broken out of cpplib.c; also hack_vms_include_specification
from cccp.c and find_include_file, a new function broken out of
do_include.
* Makefile.in (cppmain): Depend on cppfiles.o.
(fix-header): Likewise.
(cppfiles.o): New target.
* configure.in (--enable-c-cpplib): Add cppfiles.o to
extra_c_objs. Add ../cppfiles.o to extra_cxx_objs.
From-SVN: r23424
1998-10-29 19:54:13 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "cpplib.h"
|
Makefile.in (LIBCPP_DEPS): New macro.
* Makefile.in (LIBCPP_DEPS): New macro.
(cpplib.o, cpphash.o, cpperror.o, cppexp.o, cppfiles.o): Use
it to declare deps.
* cpperror.c: Include cpphash.h.
* cppexp.c: Include cpphash.h. Remove MULTIBYTE_CHARS
dingleberry.
(lex): Don't use CPP_WARN_UNDEF.
(_cpp_parse_expr): Return an int, the truth value.
* cppfiles.c: Include cpphash.h.
(_cpp_merge_include_chains): Move to cppinit.c and make static.
* cppinit.c (include_defaults_array): Disentangle.
(cpp_cleanup): Don't free the if stack here.
(cpp_finish): Pop off all buffers, not just one.
* cpplib.c (eval_if_expr): Return int.
(do_xifdef): Rename do_ifdef.
(handle_directive): Don't use CPP_PREPROCESSED.
(cpp_get_token): Don't use CPP_C89.
* fix-header.c: Don't use CPP_OPTIONS.
* cpplib.h: Move U_CHAR, enum node_type, struct
file_name_list, struct ihash, is_idchar, is_idstart,
is_numchar, is_numstart, is_hspace, is_space, CPP_BUF_PEEK,
CPP_BUF_GET, CPP_FORWARD, CPP_PUTS, CPP_PUTS_Q, CPP_PUTC,
CPP_PUTC_Q, CPP_NUL_TERMINATE, CPP_NUL_TERMINATE_Q,
CPP_BUMP_BUFFER_LINE, CPP_BUMP_LINE, CPP_PREV_BUFFER,
CPP_PRINT_DEPS, CPP_TRADITIONAL, CPP_PEDANTIC, and prototypes
of _cpp_simplify_pathname, _cpp_find_include_file,
_cpp_read_include_file, and _cpp_parse_expr to cpphash.h.
Move struct if_stack to cpplib.c. Move struct cpp_pending to
cppinit.c.
Change all uses of U_CHAR to be unsigned char instead.
Delete CPP_WARN_UNDEF, CPP_C89, and CPP_PREPROCESSED.
From-SVN: r32435
2000-03-09 07:35:19 +08:00
|
|
|
#include "cpphash.h"
|
cpplib.c (my_strerror, [...]): Move to cpperror.c.
* cpplib.c (my_strerror, cpp_error, cpp_error_with_line,
cpp_error_from_errno, cpp_warning, cpp_warning_with_line,
cpp_pedwarn, cpp_pedwarn_with_line,
cpp_pedwarn_with_file_and_line): Move to cpperror.c.
(cpp_print_file_and_line, v_cpp_error, v_cpp_warning,
v_cpp_error_with_line, v_cpp_warning_with_line,
cpp_message_from_errno, cpp_perror_with_name): Delete.
* cpperror.c (cpp_print_containing_files): Take starting
buffer as argument.
(cpp_file_line_for_message): Rename to cpp_print_file_and_line.
(v_cpp_message): Now called directly by all entry points.
Remove -1 case.
(cpp_pfatal_with_name, cpp_message): Delete.
(cpp_notice_from_errno, cpp_ice): New functions.
(cpp_notice): Is now for reporting error conditions, just
without an associated file.
(cpp_error, cpp_error_with_line): Don't do anything if
opts->inhibit_errors is on.
(cpp_pedwarn_with_file_and_line): Take column argument also.
* cpplib.h: Update prototypes of exported functions.
(struct cpp_options): Add inhibit_errors.
* cppalloc.c, cppfiles.c: Use fprintf not cpp_notice for
non-error messages. Include intl.h.
* cppinit.c, cppmain.c: Likewise. Also, use
cpp_notice_from_errno instead of cpp_perror_with_name or
cpp_pfatal_with_name, and cpp_notice instead of cpp_message.
* cppexp.c, cpphash.c, cppinit.c, cpplib.c: Use cpp_ice to
report internal errors.
* cpplib.c (do_define): Switch bcopy to memcpy.
Give cpp_pedwarn_with_file_and_line a dummy column argument.
From-SVN: r31829
2000-02-07 07:46:18 +08:00
|
|
|
#include "intl.h"
|
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
2000-03-14 14:34:11 +08:00
|
|
|
#include "mkdeps.h"
|
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
2000-06-22 02:33:51 +08:00
|
|
|
#include "splay-tree.h"
|
[multiple changes]
1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* c-lang.c: Declare extern char *yy_cur if USE_CPPLIB.
(lang_init): Call check_newline always.
* c-lex.c (init_parse) [USE_CPPLIB=1]: After calling
cpp_start_read, set yy_cur and yy_lim to read from
parse_in.token_buffer, so that we'll see the first #line
directive.
* cpplib.c (cpp_start_read): finclude the main input file
before processing -include/-imacros. Process -imacros and
-include separately, and handle -include by stacking a
buffer for the file in question as if it'd been #included.
* toplev.c (documented_lang_options) Recognize -H when
USE_CPPLIB is on.
1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.c: Merge do_once into do_pragma. Break file handling
code out of do_include.
Move append_include_chain, deps_output,
file_cleanup, redundant_include_p, import_hash,
lookup_import, add_import, read_filename_string, read_name_map,
open_include_file, finclude, safe_read to cppfiles.c.
Move prototypes for deps_output, append_include_chain,
finclude to cpplib.h. Move definition of struct
file_name_list there also.
* cppfiles.c: New file. Contains all the above functions
broken out of cpplib.c; also hack_vms_include_specification
from cccp.c and find_include_file, a new function broken out of
do_include.
* Makefile.in (cppmain): Depend on cppfiles.o.
(fix-header): Likewise.
(cppfiles.o): New target.
* configure.in (--enable-c-cpplib): Add cppfiles.o to
extra_c_objs. Add ../cppfiles.o to extra_cxx_objs.
From-SVN: r23424
1998-10-29 19:54:13 +08:00
|
|
|
|
cppfiles.c: Read files in, using mmap if possible, then prescan them separately.
* cppfiles.c: Read files in, using mmap if possible, then
prescan them separately.
(read_file, read_with_read): New functions.
* cpplex.c: Don't define UCHAR_MAX.
(_cpp_read_and_prescan): Rename to _cpp_prescan. Don't read
the file here.
* cppinit.c (handle_option): Automatically define __cplusplus,
__OBJC__, __ASEEMBLER__, _LANGUAGE_FORTRAN here when we see
the respective -lang switch.
* cpphash.h (enum node_type, struct hashnode, _cpp_lookup
prototype): Move to...
* cpplib.h: ... here. Rename struct hashnode to struct
cpp_hashnode and give it a typedef. Rename _cpp_lookup to
cpp_lookup. Add 'fe_value' slot, a union tree_node *.
From-SVN: r34228
2000-05-28 13:56:38 +08:00
|
|
|
#ifdef HAVE_MMAP_FILE
|
|
|
|
# include <sys/mman.h>
|
|
|
|
# ifndef MMAP_THRESHOLD
|
|
|
|
# define MMAP_THRESHOLD 3 /* Minimum page count to mmap the file. */
|
|
|
|
# endif
|
|
|
|
|
|
|
|
#else /* No MMAP_FILE */
|
|
|
|
# undef MMAP_THRESHOLD
|
|
|
|
# define MMAP_THRESHOLD 0
|
|
|
|
#endif
|
|
|
|
|
2000-06-02 04:06:57 +08:00
|
|
|
#ifndef O_BINARY
|
|
|
|
# define O_BINARY 0
|
|
|
|
#endif
|
|
|
|
|
2000-09-12 11:42:30 +08:00
|
|
|
/* If errno is inspected immediately after a system call fails, it will be
|
|
|
|
nonzero, and no error number will ever be zero. */
|
|
|
|
#ifndef ENOENT
|
|
|
|
# define ENOENT 0
|
|
|
|
#endif
|
|
|
|
#ifndef ENOTDIR
|
|
|
|
# define ENOTDIR 0
|
|
|
|
#endif
|
|
|
|
|
cppexp.c, [...]: Eradicate all traces of code dependent on traditional, lang_chill, or lang_fortran.
* cppexp.c, cpphash.c, cpphash.h, cppinit.c, cpplex.c,
cpplib.c, cpplib.h: Eradicate all traces of code dependent on
traditional, lang_chill, or lang_fortran.
* cppfiles.c: #undef strcmp to suppress warning about macros
used without arguments.
(_cpp_execute_include): Use f, not fname, in "No include path"
error.
(_cpp_pop_file_buffer): New function.
* cpplib.c: Don't include <sys/mman.h>.
(cpp_push_buffer): Set line_base and lineno in new buffer.
(cpp_pop_buffer): Use _cpp_pop_file_buffer.
* cpplex.c: Move all prototypes and structure declarations to the
top of the file. Properly parenthesise some macro arguments.
(cpp_scan_line): New function.
(special_symbol [case T_INCLUDE_DEPTH]): Use pfile->include_depth,
don't need to walk up the stack counting.
From-SVN: r35003
2000-07-13 10:32:41 +08:00
|
|
|
/* Suppress warning about function macros used w/o arguments in traditional
|
|
|
|
C. It is unlikely that glibc's strcmp macro helps this file at all. */
|
|
|
|
#undef strcmp
|
|
|
|
|
2000-12-08 07:17:56 +08:00
|
|
|
/* This structure is used for the table of all includes. */
|
|
|
|
struct include_file
|
|
|
|
{
|
|
|
|
const char *name; /* actual path name of file */
|
|
|
|
const cpp_hashnode *cmacro; /* macro, if any, preventing reinclusion. */
|
2001-03-02 15:35:12 +08:00
|
|
|
const struct search_path *foundhere;
|
2000-12-08 07:17:56 +08:00
|
|
|
/* location in search path where file was
|
|
|
|
found, for #include_next and sysp. */
|
|
|
|
const unsigned char *buffer; /* pointer to cached file contents */
|
|
|
|
struct stat st; /* copy of stat(2) data for file */
|
|
|
|
int fd; /* fd open on file (short term storage only) */
|
2001-05-05 19:12:19 +08:00
|
|
|
int err_no; /* errno obtained if opening a file failed */
|
2000-12-08 07:17:56 +08:00
|
|
|
unsigned short include_count; /* number of times file has been read */
|
|
|
|
unsigned short refcnt; /* number of stacked buffers using this file */
|
|
|
|
unsigned char mapped; /* file buffer is mmapped */
|
|
|
|
};
|
|
|
|
|
2001-11-22 06:03:27 +08:00
|
|
|
/* Variable length record files on VMS will have a stat size that includes
|
|
|
|
record control characters that won't be included in the read size. */
|
|
|
|
#ifdef VMS
|
|
|
|
# define FAB_C_VAR 2 /* variable length records (see Starlet fabdef.h) */
|
|
|
|
# define STAT_SIZE_TOO_BIG(ST) ((ST).st_fab_rfm == FAB_C_VAR)
|
|
|
|
#else
|
|
|
|
# define STAT_SIZE_TOO_BIG(ST) 0
|
|
|
|
#endif
|
|
|
|
|
2000-12-09 20:06:37 +08:00
|
|
|
/* 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
|
2001-03-15 15:57:13 +08:00
|
|
|
to be included again if the macro is defined. */
|
2000-12-09 20:06:37 +08:00
|
|
|
#define NEVER_REREAD ((const cpp_hashnode *)-1)
|
|
|
|
#define DO_NOT_REREAD(inc) \
|
|
|
|
((inc)->cmacro && ((inc)->cmacro == NEVER_REREAD \
|
2001-03-15 15:57:13 +08:00
|
|
|
|| (inc)->cmacro->type == NT_MACRO))
|
2001-03-14 07:55:10 +08:00
|
|
|
#define NO_INCLUDE_PATH ((struct include_file *) -1)
|
2000-12-09 20:06:37 +08:00
|
|
|
|
2000-01-31 02:09:07 +08:00
|
|
|
static struct file_name_map *read_name_map
|
cpplib.h (parse_underflow_t, [...]): Delete.
* cpplib.h (parse_underflow_t, CPP_NULL_BUFFER): Delete.
(struct cpp_buffer): Remove fname and underflow fields.
(struct cpp_reader): Remove get_token field.
(struct include_hash): Rename to struct ihash. Add typedef to
IHASH.
(struct if_stack): Remove fname field.
(IF_STACK_FRAME): Rename to IF_STACK.
* cpperror.c (print_containing_files): Trust that there are no
macro buffers below the top file buffer.
* cppfiles.c: Replace all references to 'struct include_hash'
with 'IHASH'. Rename initialize_input_buffer to
init_input_buffer. Don't set or reference cpp_buffer->fname,
use buffer->ihash->name instead.
* cpphash.c (special_symbol): Use cpp_file_buffer. Use NULL
not CPP_NULL_BUFFER.
* cppinit.c: Use NULL not CPP_NULL_BUFFER, IF_STACK not
IF_STACK_FRAME, IHASH not struct include_hash.
* cpplib.c: Rename eval_if_expression to eval_if_expr. Remove
null_underflow. Use IF_STACK not IF_STACK_FRAME, IHASH not
struct include_hash, NULL not CPP_NULL_BUFFER. Remove all
references to cpp_buffer->fname (delete entirely, or use
->ihash->name instead) and IF_STACK->fname.
(cpp_push_buffer): Don't set new->underflow.
(do_include): Use cpp_file_buffer.
* cpphash.c (collect_formal_parameters): Remove duplicate
increment of argslen. Pedwarn in C99 mode if __VA_ARGS__ is
used as a macro argument name. Don't append "..." to namebuf
for varargs macros. After we're done scanning, go through
namebuf and make it NUL separated, not comma separated.
(_cpp_compare_defs): Remove register tag from variables.
Expect defn->argnames to be NUL separated.
(_cpp_dump_definition): Expect defn->argnames to be NUL
separated and in forward order.
* cpphash.h: Update documentation of argnames field.
From-SVN: r32430
2000-03-09 04:37:23 +08:00
|
|
|
PARAMS ((cpp_reader *, const char *));
|
|
|
|
static char *read_filename_string PARAMS ((int, FILE *));
|
|
|
|
static char *remap_filename PARAMS ((cpp_reader *, char *,
|
2001-03-02 15:35:12 +08:00
|
|
|
struct search_path *));
|
|
|
|
static struct search_path *search_from PARAMS ((cpp_reader *,
|
2001-03-15 15:57:13 +08:00
|
|
|
enum include_type));
|
2001-03-14 07:55:10 +08:00
|
|
|
static struct include_file *
|
2001-03-15 15:57:13 +08:00
|
|
|
find_include_file PARAMS ((cpp_reader *, const cpp_token *,
|
|
|
|
enum include_type));
|
2000-09-22 02:01:22 +08:00
|
|
|
static struct include_file *open_file PARAMS ((cpp_reader *, const char *));
|
2001-04-06 13:21:36 +08:00
|
|
|
static int read_include_file PARAMS ((cpp_reader *, struct include_file *));
|
2001-08-22 03:23:24 +08:00
|
|
|
static bool stack_include_file PARAMS ((cpp_reader *, struct include_file *));
|
2000-09-12 11:42:30 +08:00
|
|
|
static void purge_cache PARAMS ((struct include_file *));
|
2001-03-13 03:33:08 +08:00
|
|
|
static void destroy_node PARAMS ((splay_tree_value));
|
cpplex.c: Don't include sys/mman.h.
toplevel:
* cpplex.c: Don't include sys/mman.h.
(cpp_push_buffer, cpp_pop_buffer): Moved to cpplib.c.
* cpplib.c: Include sys/mman.h and obstack.h.
(cpp_push_buffer): Moved from cpplex.c; allocate buffers on an
obstack.
(cpp_pop_buffer): Moved from cpplex.c; free buffers from an obstack.
(_cpp_unwind_if_stack): Now static, unwind_if_stack. Don't
bother freeing if stack entries (they will be freed with their buffer).
(do_endif): Free if stack entries from the buffer obstack.
(push_conditional): Allocate if stack entries from the buffer obstack.
(find_answer): Rename to _cpp_find_answer.
(do_assert, do_unassert): Update.
* cpphash.h: Update prototypes.
(xobnew): New convenience macro.
* cpplib.h (struct cpp_reader): Add hash_ob and buffer_ob fields.
Update comments.
(struct cpp_hashnode): Remove disabled field.
* cppinit.c: Don't include hashtab.h or splay-tree.h.
(report_missing_guard): Moved to cppfiles.c.
(cpp_reader_init): Call cpp_init_stacks, cpp_init_macros,
cpp_init_includes.
(cpp_cleanup): Call cpp_cleanup_stacks, cpp_cleanup_macros,
cpp_cleanup_includes. Don't destroy hashtab or
all_include_files here.
(cpp_finish): Use _cpp_report_missing_guards.
* cppfiles.c (report_missing_guard): Moved from cppinit.c.
(_cpp_init_include_table): Rename _cpp_init_includes.
(_cpp_cleanup_includes, _cpp_report_missing_guards): New.
* cppexp.c (parse_assertion): Update for new name of
find_answer.
* Makefile.in (cpplib.o, cpphash.o, cppinit.o): Update deps.
* cpplib.c (do_ident): s/VSPACE/EOF/
testsuite:
* gcc.dg/cpp/ident.c: New test.
From-SVN: r34870
2000-07-05 13:33:57 +08:00
|
|
|
static int report_missing_guard PARAMS ((splay_tree_node, void *));
|
2001-03-13 03:33:08 +08:00
|
|
|
static splay_tree_node find_or_create_entry PARAMS ((cpp_reader *,
|
|
|
|
const char *));
|
|
|
|
static void handle_missing_header PARAMS ((cpp_reader *, const char *, int));
|
2001-04-06 15:22:01 +08:00
|
|
|
static int remove_component_p PARAMS ((const char *));
|
2001-03-13 03:33:08 +08:00
|
|
|
|
|
|
|
/* Set up the splay tree we use to store information about all the
|
|
|
|
file names seen in this compilation. We also have entries for each
|
|
|
|
file we tried to open but failed; this saves system calls since we
|
|
|
|
don't try to open it again in future.
|
|
|
|
|
|
|
|
The key of each node is the file name, after processing by
|
|
|
|
_cpp_simplify_pathname. The path name may or may not be absolute.
|
|
|
|
The path string has been malloced, as is automatically freed by
|
|
|
|
registering free () as the splay tree key deletion function.
|
|
|
|
|
|
|
|
A node's value is a pointer to a struct include_file, and is never
|
|
|
|
NULL. */
|
Convert cpplib to use libiberty/hashtab.c.
* cpplib.h (struct cpp_reader): Make hashtab and
all_include_files of type 'struct htab *'. Delete HASHSIZE
and ALL_INCLUDE_HASHSIZE macros.
* cpphash.h: Update prototypes.
(struct hashnode): Remove next, prev, and bucket_hdr members.
Make length a size_t. Add hash member.
(struct ihash): Remove next member. Add hash member. Make
name a flexible array member.
* cppfiles.c: Include hashtab.h.
(include_hash): Delete.
(IHASHSIZE): New macro.
(hash_IHASH, eq_IHASH, _cpp_init_include_hash): New functions.
(cpp_included): Do the hash lookup here.
(_cpp_find_include_file): Rewrite.
(cpp_read_file): Put the "fake" hash entry into the hash
table. Honor the control_macro, if it turns out we've seen
the file before. Don't push the buffer here.
(_cpp_read_include_file): Push the buffer here.
(OMODES): New macro. Use it whenever we call open(2).
* cpphash.c: Include hashtab.h.
(hash_HASHNODE, eq_HASHNODE, del_HASHNODE, dump_hash_helper,
_cpp_init_macro_hash, _cpp_dump_macro_hash, _cpp_make_hashnode,
_cpp_lookup_slot): New functions.
(HASHSIZE): new macro.
(hashf, _cpp_install, _cpp_delete_macro): Delete.
(_cpp_lookup): Use hashtab.h routines.
* cppinit.c: Include hashtab.h.
(cpp_reader_init): Call _cpp_init_macro_hash and
_cpp_init_include_hash. Don't allocate hashtab directly.
(cpp_cleanup): Just call htab_delete on pfile->hashtab and
pfile->all_include_files.
(initialize_builtins): Use _cpp_make_hashnode and
htab_find_slot to add hash entries.
(cpp_finish): Just call _cpp_dump_macro_hash.
* cpplib.c: Include hashtab.h.
(do_define): Use _cpp_lookup_slot and _cpp_make_hashnode to
create hash entries.
(do_pragma_poison, do_assert): Likewise.
(do_include): Don't push the buffer here. Don't increment
system_include_depth unless _cpp_read_include_file succeeds.
(do_undef, do_unassert): Use _cpp_lookup_slot and htab_clear_slot
or htab_remove_elt.
(do_pragma_implementation): Use alloca to create copy.
* Makefile.in: Update dependencies.
From-SVN: r32497
2000-03-13 07:46:05 +08:00
|
|
|
void
|
cpplex.c: Don't include sys/mman.h.
toplevel:
* cpplex.c: Don't include sys/mman.h.
(cpp_push_buffer, cpp_pop_buffer): Moved to cpplib.c.
* cpplib.c: Include sys/mman.h and obstack.h.
(cpp_push_buffer): Moved from cpplex.c; allocate buffers on an
obstack.
(cpp_pop_buffer): Moved from cpplex.c; free buffers from an obstack.
(_cpp_unwind_if_stack): Now static, unwind_if_stack. Don't
bother freeing if stack entries (they will be freed with their buffer).
(do_endif): Free if stack entries from the buffer obstack.
(push_conditional): Allocate if stack entries from the buffer obstack.
(find_answer): Rename to _cpp_find_answer.
(do_assert, do_unassert): Update.
* cpphash.h: Update prototypes.
(xobnew): New convenience macro.
* cpplib.h (struct cpp_reader): Add hash_ob and buffer_ob fields.
Update comments.
(struct cpp_hashnode): Remove disabled field.
* cppinit.c: Don't include hashtab.h or splay-tree.h.
(report_missing_guard): Moved to cppfiles.c.
(cpp_reader_init): Call cpp_init_stacks, cpp_init_macros,
cpp_init_includes.
(cpp_cleanup): Call cpp_cleanup_stacks, cpp_cleanup_macros,
cpp_cleanup_includes. Don't destroy hashtab or
all_include_files here.
(cpp_finish): Use _cpp_report_missing_guards.
* cppfiles.c (report_missing_guard): Moved from cppinit.c.
(_cpp_init_include_table): Rename _cpp_init_includes.
(_cpp_cleanup_includes, _cpp_report_missing_guards): New.
* cppexp.c (parse_assertion): Update for new name of
find_answer.
* Makefile.in (cpplib.o, cpphash.o, cppinit.o): Update deps.
* cpplib.c (do_ident): s/VSPACE/EOF/
testsuite:
* gcc.dg/cpp/ident.c: New test.
From-SVN: r34870
2000-07-05 13:33:57 +08:00
|
|
|
_cpp_init_includes (pfile)
|
Convert cpplib to use libiberty/hashtab.c.
* cpplib.h (struct cpp_reader): Make hashtab and
all_include_files of type 'struct htab *'. Delete HASHSIZE
and ALL_INCLUDE_HASHSIZE macros.
* cpphash.h: Update prototypes.
(struct hashnode): Remove next, prev, and bucket_hdr members.
Make length a size_t. Add hash member.
(struct ihash): Remove next member. Add hash member. Make
name a flexible array member.
* cppfiles.c: Include hashtab.h.
(include_hash): Delete.
(IHASHSIZE): New macro.
(hash_IHASH, eq_IHASH, _cpp_init_include_hash): New functions.
(cpp_included): Do the hash lookup here.
(_cpp_find_include_file): Rewrite.
(cpp_read_file): Put the "fake" hash entry into the hash
table. Honor the control_macro, if it turns out we've seen
the file before. Don't push the buffer here.
(_cpp_read_include_file): Push the buffer here.
(OMODES): New macro. Use it whenever we call open(2).
* cpphash.c: Include hashtab.h.
(hash_HASHNODE, eq_HASHNODE, del_HASHNODE, dump_hash_helper,
_cpp_init_macro_hash, _cpp_dump_macro_hash, _cpp_make_hashnode,
_cpp_lookup_slot): New functions.
(HASHSIZE): new macro.
(hashf, _cpp_install, _cpp_delete_macro): Delete.
(_cpp_lookup): Use hashtab.h routines.
* cppinit.c: Include hashtab.h.
(cpp_reader_init): Call _cpp_init_macro_hash and
_cpp_init_include_hash. Don't allocate hashtab directly.
(cpp_cleanup): Just call htab_delete on pfile->hashtab and
pfile->all_include_files.
(initialize_builtins): Use _cpp_make_hashnode and
htab_find_slot to add hash entries.
(cpp_finish): Just call _cpp_dump_macro_hash.
* cpplib.c: Include hashtab.h.
(do_define): Use _cpp_lookup_slot and _cpp_make_hashnode to
create hash entries.
(do_pragma_poison, do_assert): Likewise.
(do_include): Don't push the buffer here. Don't increment
system_include_depth unless _cpp_read_include_file succeeds.
(do_undef, do_unassert): Use _cpp_lookup_slot and htab_clear_slot
or htab_remove_elt.
(do_pragma_implementation): Use alloca to create copy.
* Makefile.in: Update dependencies.
From-SVN: r32497
2000-03-13 07:46:05 +08:00
|
|
|
cpp_reader *pfile;
|
|
|
|
{
|
|
|
|
pfile->all_include_files
|
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
2000-06-22 02:33:51 +08:00
|
|
|
= splay_tree_new ((splay_tree_compare_fn) strcmp,
|
|
|
|
(splay_tree_delete_key_fn) free,
|
2001-03-13 03:33:08 +08:00
|
|
|
destroy_node);
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
}
|
[multiple changes]
1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* c-lang.c: Declare extern char *yy_cur if USE_CPPLIB.
(lang_init): Call check_newline always.
* c-lex.c (init_parse) [USE_CPPLIB=1]: After calling
cpp_start_read, set yy_cur and yy_lim to read from
parse_in.token_buffer, so that we'll see the first #line
directive.
* cpplib.c (cpp_start_read): finclude the main input file
before processing -include/-imacros. Process -imacros and
-include separately, and handle -include by stacking a
buffer for the file in question as if it'd been #included.
* toplev.c (documented_lang_options) Recognize -H when
USE_CPPLIB is on.
1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.c: Merge do_once into do_pragma. Break file handling
code out of do_include.
Move append_include_chain, deps_output,
file_cleanup, redundant_include_p, import_hash,
lookup_import, add_import, read_filename_string, read_name_map,
open_include_file, finclude, safe_read to cppfiles.c.
Move prototypes for deps_output, append_include_chain,
finclude to cpplib.h. Move definition of struct
file_name_list there also.
* cppfiles.c: New file. Contains all the above functions
broken out of cpplib.c; also hack_vms_include_specification
from cccp.c and find_include_file, a new function broken out of
do_include.
* Makefile.in (cppmain): Depend on cppfiles.o.
(fix-header): Likewise.
(cppfiles.o): New target.
* configure.in (--enable-c-cpplib): Add cppfiles.o to
extra_c_objs. Add ../cppfiles.o to extra_cxx_objs.
From-SVN: r23424
1998-10-29 19:54:13 +08:00
|
|
|
|
2001-03-13 03:33:08 +08:00
|
|
|
/* Tear down the splay tree. */
|
cpplex.c: Don't include sys/mman.h.
toplevel:
* cpplex.c: Don't include sys/mman.h.
(cpp_push_buffer, cpp_pop_buffer): Moved to cpplib.c.
* cpplib.c: Include sys/mman.h and obstack.h.
(cpp_push_buffer): Moved from cpplex.c; allocate buffers on an
obstack.
(cpp_pop_buffer): Moved from cpplex.c; free buffers from an obstack.
(_cpp_unwind_if_stack): Now static, unwind_if_stack. Don't
bother freeing if stack entries (they will be freed with their buffer).
(do_endif): Free if stack entries from the buffer obstack.
(push_conditional): Allocate if stack entries from the buffer obstack.
(find_answer): Rename to _cpp_find_answer.
(do_assert, do_unassert): Update.
* cpphash.h: Update prototypes.
(xobnew): New convenience macro.
* cpplib.h (struct cpp_reader): Add hash_ob and buffer_ob fields.
Update comments.
(struct cpp_hashnode): Remove disabled field.
* cppinit.c: Don't include hashtab.h or splay-tree.h.
(report_missing_guard): Moved to cppfiles.c.
(cpp_reader_init): Call cpp_init_stacks, cpp_init_macros,
cpp_init_includes.
(cpp_cleanup): Call cpp_cleanup_stacks, cpp_cleanup_macros,
cpp_cleanup_includes. Don't destroy hashtab or
all_include_files here.
(cpp_finish): Use _cpp_report_missing_guards.
* cppfiles.c (report_missing_guard): Moved from cppinit.c.
(_cpp_init_include_table): Rename _cpp_init_includes.
(_cpp_cleanup_includes, _cpp_report_missing_guards): New.
* cppexp.c (parse_assertion): Update for new name of
find_answer.
* Makefile.in (cpplib.o, cpphash.o, cppinit.o): Update deps.
* cpplib.c (do_ident): s/VSPACE/EOF/
testsuite:
* gcc.dg/cpp/ident.c: New test.
From-SVN: r34870
2000-07-05 13:33:57 +08:00
|
|
|
void
|
|
|
|
_cpp_cleanup_includes (pfile)
|
|
|
|
cpp_reader *pfile;
|
|
|
|
{
|
|
|
|
splay_tree_delete (pfile->all_include_files);
|
|
|
|
}
|
|
|
|
|
2001-03-13 03:33:08 +08:00
|
|
|
/* Free a node. The path string is automatically freed. */
|
|
|
|
static void
|
|
|
|
destroy_node (v)
|
|
|
|
splay_tree_value v;
|
|
|
|
{
|
|
|
|
struct include_file *f = (struct include_file *)v;
|
|
|
|
|
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
purge_cache (f);
|
|
|
|
free (f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-08 07:17:56 +08:00
|
|
|
/* Mark a file to not be reread (e.g. #import, read failure). */
|
|
|
|
void
|
|
|
|
_cpp_never_reread (file)
|
|
|
|
struct include_file *file;
|
|
|
|
{
|
|
|
|
file->cmacro = NEVER_REREAD;
|
|
|
|
}
|
|
|
|
|
2001-03-15 15:57:13 +08:00
|
|
|
/* Lookup a filename, which is simplified after making a copy, and
|
2001-04-06 15:22:01 +08:00
|
|
|
create an entry if none exists. errno is nonzero iff a (reported)
|
|
|
|
stat() error occurred during simplification. */
|
2001-03-13 03:33:08 +08:00
|
|
|
static splay_tree_node
|
|
|
|
find_or_create_entry (pfile, fname)
|
2001-01-14 02:39:26 +08:00
|
|
|
cpp_reader *pfile;
|
|
|
|
const char *fname;
|
|
|
|
{
|
2001-03-13 03:33:08 +08:00
|
|
|
splay_tree_node node;
|
|
|
|
struct include_file *file;
|
2001-03-15 15:57:13 +08:00
|
|
|
char *name = xstrdup (fname);
|
2001-01-14 02:39:26 +08:00
|
|
|
|
2001-03-15 15:57:13 +08:00
|
|
|
_cpp_simplify_pathname (name);
|
|
|
|
node = splay_tree_lookup (pfile->all_include_files, (splay_tree_key) name);
|
|
|
|
if (node)
|
|
|
|
free (name);
|
|
|
|
else
|
2001-01-14 02:39:26 +08:00
|
|
|
{
|
2001-03-13 03:33:08 +08:00
|
|
|
file = xcnew (struct include_file);
|
2001-03-15 15:57:13 +08:00
|
|
|
file->name = name;
|
2001-05-05 19:12:19 +08:00
|
|
|
file->err_no = errno;
|
2001-03-13 03:33:08 +08:00
|
|
|
node = splay_tree_insert (pfile->all_include_files,
|
|
|
|
(splay_tree_key) file->name,
|
|
|
|
(splay_tree_value) file);
|
2001-01-14 02:39:26 +08:00
|
|
|
}
|
2001-03-13 03:33:08 +08:00
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2001-03-15 15:57:13 +08:00
|
|
|
/* Enter a file name in the splay tree, for the sake of cpp_included. */
|
2001-03-13 03:33:08 +08:00
|
|
|
void
|
|
|
|
_cpp_fake_include (pfile, fname)
|
|
|
|
cpp_reader *pfile;
|
|
|
|
const char *fname;
|
|
|
|
{
|
|
|
|
find_or_create_entry (pfile, fname);
|
2001-01-14 02:39:26 +08:00
|
|
|
}
|
|
|
|
|
2000-09-12 11:42:30 +08:00
|
|
|
/* Given a file name, look it up in the cache; if there is no entry,
|
2000-09-22 02:01:22 +08:00
|
|
|
create one with a non-NULL value (regardless of success in opening
|
|
|
|
the file). If the file doesn't exist or is inaccessible, this
|
|
|
|
entry is flagged so we don't attempt to open it again in the
|
2001-02-21 15:29:56 +08:00
|
|
|
future. If the file isn't open, open it. The empty string is
|
|
|
|
interpreted as stdin.
|
2000-09-22 02:01:22 +08:00
|
|
|
|
|
|
|
Returns an include_file structure with an open file descriptor on
|
|
|
|
success, or NULL on failure. */
|
[multiple changes]
1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* c-lang.c: Declare extern char *yy_cur if USE_CPPLIB.
(lang_init): Call check_newline always.
* c-lex.c (init_parse) [USE_CPPLIB=1]: After calling
cpp_start_read, set yy_cur and yy_lim to read from
parse_in.token_buffer, so that we'll see the first #line
directive.
* cpplib.c (cpp_start_read): finclude the main input file
before processing -include/-imacros. Process -imacros and
-include separately, and handle -include by stacking a
buffer for the file in question as if it'd been #included.
* toplev.c (documented_lang_options) Recognize -H when
USE_CPPLIB is on.
1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.c: Merge do_once into do_pragma. Break file handling
code out of do_include.
Move append_include_chain, deps_output,
file_cleanup, redundant_include_p, import_hash,
lookup_import, add_import, read_filename_string, read_name_map,
open_include_file, finclude, safe_read to cppfiles.c.
Move prototypes for deps_output, append_include_chain,
finclude to cpplib.h. Move definition of struct
file_name_list there also.
* cppfiles.c: New file. Contains all the above functions
broken out of cpplib.c; also hack_vms_include_specification
from cccp.c and find_include_file, a new function broken out of
do_include.
* Makefile.in (cppmain): Depend on cppfiles.o.
(fix-header): Likewise.
(cppfiles.o): New target.
* configure.in (--enable-c-cpplib): Add cppfiles.o to
extra_c_objs. Add ../cppfiles.o to extra_cxx_objs.
From-SVN: r23424
1998-10-29 19:54:13 +08:00
|
|
|
|
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
2000-06-22 02:33:51 +08:00
|
|
|
static struct include_file *
|
2000-09-22 02:01:22 +08:00
|
|
|
open_file (pfile, filename)
|
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
2000-06-22 02:33:51 +08:00
|
|
|
cpp_reader *pfile;
|
|
|
|
const char *filename;
|
2000-09-22 02:01:22 +08:00
|
|
|
{
|
2001-03-13 03:33:08 +08:00
|
|
|
splay_tree_node nd = find_or_create_entry (pfile, filename);
|
|
|
|
struct include_file *file = (struct include_file *) nd->value;
|
[multiple changes]
1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* c-lang.c: Declare extern char *yy_cur if USE_CPPLIB.
(lang_init): Call check_newline always.
* c-lex.c (init_parse) [USE_CPPLIB=1]: After calling
cpp_start_read, set yy_cur and yy_lim to read from
parse_in.token_buffer, so that we'll see the first #line
directive.
* cpplib.c (cpp_start_read): finclude the main input file
before processing -include/-imacros. Process -imacros and
-include separately, and handle -include by stacking a
buffer for the file in question as if it'd been #included.
* toplev.c (documented_lang_options) Recognize -H when
USE_CPPLIB is on.
1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.c: Merge do_once into do_pragma. Break file handling
code out of do_include.
Move append_include_chain, deps_output,
file_cleanup, redundant_include_p, import_hash,
lookup_import, add_import, read_filename_string, read_name_map,
open_include_file, finclude, safe_read to cppfiles.c.
Move prototypes for deps_output, append_include_chain,
finclude to cpplib.h. Move definition of struct
file_name_list there also.
* cppfiles.c: New file. Contains all the above functions
broken out of cpplib.c; also hack_vms_include_specification
from cccp.c and find_include_file, a new function broken out of
do_include.
* Makefile.in (cppmain): Depend on cppfiles.o.
(fix-header): Likewise.
(cppfiles.o): New target.
* configure.in (--enable-c-cpplib): Add cppfiles.o to
extra_c_objs. Add ../cppfiles.o to extra_cxx_objs.
From-SVN: r23424
1998-10-29 19:54:13 +08:00
|
|
|
|
2001-05-05 19:12:19 +08:00
|
|
|
if (file->err_no)
|
|
|
|
{
|
|
|
|
/* Ugh. handle_missing_header () needs errno to be set. */
|
|
|
|
errno = file->err_no;
|
|
|
|
return 0;
|
|
|
|
}
|
2000-09-22 02:01:22 +08:00
|
|
|
|
2001-08-02 01:57:27 +08:00
|
|
|
/* Don't reopen an idempotent file. */
|
2001-03-13 03:33:08 +08:00
|
|
|
if (DO_NOT_REREAD (file))
|
|
|
|
return file;
|
2000-11-04 00:03:37 +08:00
|
|
|
|
2001-08-02 01:57:27 +08:00
|
|
|
/* Don't reopen one which is already loaded. */
|
2001-03-13 03:33:08 +08:00
|
|
|
if (file->buffer != NULL)
|
|
|
|
return file;
|
[multiple changes]
1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* c-lang.c: Declare extern char *yy_cur if USE_CPPLIB.
(lang_init): Call check_newline always.
* c-lex.c (init_parse) [USE_CPPLIB=1]: After calling
cpp_start_read, set yy_cur and yy_lim to read from
parse_in.token_buffer, so that we'll see the first #line
directive.
* cpplib.c (cpp_start_read): finclude the main input file
before processing -include/-imacros. Process -imacros and
-include separately, and handle -include by stacking a
buffer for the file in question as if it'd been #included.
* toplev.c (documented_lang_options) Recognize -H when
USE_CPPLIB is on.
1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.c: Merge do_once into do_pragma. Break file handling
code out of do_include.
Move append_include_chain, deps_output,
file_cleanup, redundant_include_p, import_hash,
lookup_import, add_import, read_filename_string, read_name_map,
open_include_file, finclude, safe_read to cppfiles.c.
Move prototypes for deps_output, append_include_chain,
finclude to cpplib.h. Move definition of struct
file_name_list there also.
* cppfiles.c: New file. Contains all the above functions
broken out of cpplib.c; also hack_vms_include_specification
from cccp.c and find_include_file, a new function broken out of
do_include.
* Makefile.in (cppmain): Depend on cppfiles.o.
(fix-header): Likewise.
(cppfiles.o): New target.
* configure.in (--enable-c-cpplib): Add cppfiles.o to
extra_c_objs. Add ../cppfiles.o to extra_cxx_objs.
From-SVN: r23424
1998-10-29 19:54:13 +08:00
|
|
|
|
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
2000-06-22 02:33:51 +08:00
|
|
|
/* We used to open files in nonblocking mode, but that caused more
|
|
|
|
problems than it solved. Do take care not to acquire a
|
|
|
|
controlling terminal by mistake (this can't happen on sane
|
|
|
|
systems, but paranoia is a virtue).
|
[multiple changes]
1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* c-lang.c: Declare extern char *yy_cur if USE_CPPLIB.
(lang_init): Call check_newline always.
* c-lex.c (init_parse) [USE_CPPLIB=1]: After calling
cpp_start_read, set yy_cur and yy_lim to read from
parse_in.token_buffer, so that we'll see the first #line
directive.
* cpplib.c (cpp_start_read): finclude the main input file
before processing -include/-imacros. Process -imacros and
-include separately, and handle -include by stacking a
buffer for the file in question as if it'd been #included.
* toplev.c (documented_lang_options) Recognize -H when
USE_CPPLIB is on.
1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.c: Merge do_once into do_pragma. Break file handling
code out of do_include.
Move append_include_chain, deps_output,
file_cleanup, redundant_include_p, import_hash,
lookup_import, add_import, read_filename_string, read_name_map,
open_include_file, finclude, safe_read to cppfiles.c.
Move prototypes for deps_output, append_include_chain,
finclude to cpplib.h. Move definition of struct
file_name_list there also.
* cppfiles.c: New file. Contains all the above functions
broken out of cpplib.c; also hack_vms_include_specification
from cccp.c and find_include_file, a new function broken out of
do_include.
* Makefile.in (cppmain): Depend on cppfiles.o.
(fix-header): Likewise.
(cppfiles.o): New target.
* configure.in (--enable-c-cpplib): Add cppfiles.o to
extra_c_objs. Add ../cppfiles.o to extra_cxx_objs.
From-SVN: r23424
1998-10-29 19:54:13 +08:00
|
|
|
|
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
2000-06-22 02:33:51 +08:00
|
|
|
Use the three-argument form of open even though we aren't
|
|
|
|
specifying O_CREAT, to defend against broken system headers.
|
[multiple changes]
1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* c-lang.c: Declare extern char *yy_cur if USE_CPPLIB.
(lang_init): Call check_newline always.
* c-lex.c (init_parse) [USE_CPPLIB=1]: After calling
cpp_start_read, set yy_cur and yy_lim to read from
parse_in.token_buffer, so that we'll see the first #line
directive.
* cpplib.c (cpp_start_read): finclude the main input file
before processing -include/-imacros. Process -imacros and
-include separately, and handle -include by stacking a
buffer for the file in question as if it'd been #included.
* toplev.c (documented_lang_options) Recognize -H when
USE_CPPLIB is on.
1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.c: Merge do_once into do_pragma. Break file handling
code out of do_include.
Move append_include_chain, deps_output,
file_cleanup, redundant_include_p, import_hash,
lookup_import, add_import, read_filename_string, read_name_map,
open_include_file, finclude, safe_read to cppfiles.c.
Move prototypes for deps_output, append_include_chain,
finclude to cpplib.h. Move definition of struct
file_name_list there also.
* cppfiles.c: New file. Contains all the above functions
broken out of cpplib.c; also hack_vms_include_specification
from cccp.c and find_include_file, a new function broken out of
do_include.
* Makefile.in (cppmain): Depend on cppfiles.o.
(fix-header): Likewise.
(cppfiles.o): New target.
* configure.in (--enable-c-cpplib): Add cppfiles.o to
extra_c_objs. Add ../cppfiles.o to extra_cxx_objs.
From-SVN: r23424
1998-10-29 19:54:13 +08:00
|
|
|
|
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
2000-06-22 02:33:51 +08:00
|
|
|
O_BINARY tells some runtime libraries (notably DJGPP) not to do
|
|
|
|
newline translation; we can handle DOS line breaks just fine
|
|
|
|
ourselves.
|
cppfiles.c (_cpp_find_include_file): Make sure ih->name is initialized.
* cppfiles.c (_cpp_find_include_file): Make sure ih->name is
initialized.
* cppinit.c (cpp_cleanup): Free imp->nshort also.
* cpperror.c (cpp_print_containing_files,
cpp_print_file_and_line, v_cpp_message): Rename to
print_containing_files, print_file_and_line, and v_message.
* cppexp.c (cpp_parse_expr, cpp_parse_escape, cpp_lex): Rename
to _cpp_parse_expr, parse_escape, and lex.
(parse_charconst): Remove broken multibyte support.
* cppfiles.c (include_hash): Make static.
(cpp_included): New function.
(merge_include_chains, find_include_file, finclude,
simplify_pathname): Rename to _cpp_merge_include_chains,
_cpp_find_include_file, _cpp_read_include_file, and
_cpp_simplify_pathname.
* cpphash.c (cpp_lookup, free_definition, delete_macro,
cpp_install, create_definition, macroexpand, compare_defs,
dump_definition): Rename to _cpp_lookup, _cpp_free_definition,
_cpp_delete_macro, _cpp_install, _cpp_create_definition,
_cpp_macroexpand, _cpp_compare_defs, and _cpp_dump_definition.
* cppinit.c (cpp_handle_option): Rename to handle_option, make
static.
* cpplib.c: Remove extern prototype of cpp_parse_expr.
* cpphash.h: Update prototypes.
* cpplib.h: Likewise. Prototype _cpp_parse_expr here.
From-SVN: r32390
2000-03-08 04:58:47 +08:00
|
|
|
|
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
2000-06-22 02:33:51 +08:00
|
|
|
Special case: the empty string is translated to stdin. */
|
2000-06-29 03:03:08 +08:00
|
|
|
|
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
2000-06-22 02:33:51 +08:00
|
|
|
if (filename[0] == '\0')
|
2000-09-22 02:01:22 +08:00
|
|
|
file->fd = 0;
|
cpplex.c (cpp_output_tokens, [...]): New public interfaces.
* cpplex.c (cpp_output_tokens, cpp_scan_buffer_nooutput): New public
interfaces.
(safe_fwrite, output_line_command): New static functions.
(cpp_expand_to_buffer): Now private to cpplib.
(cpp_scan_buffer): Take a printer.
* cpphash.h: Update prototypes.
* cpplib.h: Update prototypes.
(cpp_printer): New.
(cpp_buffer): Remove last_nominal_fname.
(cpp_reader): Remove lineno.
* cppmain.c: Use a cpp_printer.
* fix-header.c: No need to inhibit line commands. Call
cpp_start_read with no printer.
* cpperror.c (cpp_notice_from_errno): Provide default name.
* cppfiles.c (make_IHASH, _cpp_fake_ihash): New functions.
(find_include_file, cpp_read_file): Use make_IHASH.
(file_cleanup): Set control_macro and clear
input_stack_listing_current here.
(_cpp_execute_include): Don't output entering-file marker.
* cpphash.c (special_symbol): Look for the line number in the
buffer, not the reader.
(_cpp_macroexpand): No need to disable line commands.
(_cpp_dump_definition): No need to generate line commands.
(dump_hash_helper): Remove excess newline from output.
* cppinit.c (dump_special_to_buffer): No need to generate line
commands.
(cpp_printer_init): New.
(cpp_start_read): Take a printer, and start it up if it's not
NULL. No need to generate line commands.
(cpp_finish): Expect no buffers stacked at all. Take a
printer argument, and flush the output buffer if it's not
NULL.
* cpplex.c (_cpp_lex_token): Return EOF if there's no buffer.
Don't put two hashes at the beginning of an assertion.
(cpp_get_token): Don't increment pfile->lineno or emit line
commands here. Return EOF if there's no buffer when we get
EOF.
* cpplib.c (do_define, skip_if_group):
No need to disable line commands.
(_cpp_output_line_command): Delete function.
(do_line): Don't emit line commands here, but set things up so
they will be emitted if necessary. Use _cpp_fake_ihash to
make unique nominal_fnames if necessary.
(do_elif, do_else, _cpp_handle_eof): Call cpp_error_with_line
with 0 for column, not -1.
(_cpp_handle_eof): Don't set the control macro here. Don't
clear input_stack_listing_current here. Don't emit line
commands.
From-SVN: r33159
2000-04-15 07:29:45 +08:00
|
|
|
else
|
2001-03-15 15:57:13 +08:00
|
|
|
file->fd = open (file->name, O_RDONLY | O_NOCTTY | O_BINARY, 0666);
|
2000-09-12 11:42:30 +08:00
|
|
|
|
2000-09-22 02:01:22 +08:00
|
|
|
if (file->fd != -1 && fstat (file->fd, &file->st) == 0)
|
|
|
|
{
|
2001-10-09 01:54:15 +08:00
|
|
|
if (!S_ISDIR (file->st.st_mode))
|
|
|
|
return file;
|
2001-04-06 13:21:36 +08:00
|
|
|
/* If it's a directory, we return null and continue the search
|
|
|
|
as the file we're looking for may appear elsewhere in the
|
|
|
|
search path. */
|
2001-10-09 01:54:15 +08:00
|
|
|
errno = ENOENT;
|
2000-09-22 02:01:22 +08:00
|
|
|
}
|
2000-09-12 11:42:30 +08:00
|
|
|
|
2001-05-05 19:12:19 +08:00
|
|
|
file->err_no = errno;
|
2000-09-12 11:42:30 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-08-22 03:23:24 +08:00
|
|
|
/* Place the file referenced by INC into a new buffer on the buffer
|
|
|
|
stack, unless there are errors, or the file is not re-included
|
|
|
|
because of e.g. multiple-include guards. Returns true if a buffer
|
|
|
|
is stacked. */
|
2000-09-12 11:42:30 +08:00
|
|
|
|
2001-08-22 03:23:24 +08:00
|
|
|
static bool
|
2000-09-12 11:42:30 +08:00
|
|
|
stack_include_file (pfile, inc)
|
|
|
|
cpp_reader *pfile;
|
|
|
|
struct include_file *inc;
|
|
|
|
{
|
|
|
|
cpp_buffer *fp;
|
2001-08-22 03:23:24 +08:00
|
|
|
int sysp;
|
2001-08-18 06:23:49 +08:00
|
|
|
const char *filename;
|
2001-02-20 03:50:21 +08:00
|
|
|
|
2001-08-22 03:23:24 +08:00
|
|
|
if (DO_NOT_REREAD (inc))
|
|
|
|
return false;
|
|
|
|
|
2001-08-11 15:33:39 +08:00
|
|
|
sysp = MAX ((pfile->map ? pfile->map->sysp : 0),
|
2001-03-16 13:19:46 +08:00
|
|
|
(inc->foundhere ? inc->foundhere->sysp : 0));
|
2001-02-20 03:50:21 +08:00
|
|
|
|
|
|
|
/* For -M, add the file to the dependencies on its first inclusion. */
|
2001-08-22 03:23:24 +08:00
|
|
|
if (CPP_OPTION (pfile, print_deps) > sysp && !inc->include_count)
|
2001-02-20 03:50:21 +08:00
|
|
|
deps_add_dep (pfile->deps, inc->name);
|
|
|
|
|
2001-04-06 13:21:36 +08:00
|
|
|
/* Not in cache? */
|
2001-08-22 03:23:24 +08:00
|
|
|
if (! inc->buffer)
|
2001-04-06 13:21:36 +08:00
|
|
|
{
|
cppfiles.c (stack_include_file): Don't optimize zero-length files.
* cppfiles.c (stack_include_file): Don't optimize zero-length
files.
(read_include_file): NUL-terminate read files.
* cpplex.c (handle_newline, skip_escaped_newlines,
get_effective_char, skip_whitespace, parse_identifier,
parse_identifier_slow, parse_number, parse_string,
_cpp_lex_direct): Optimize for the fact that buffers are guaranteed
NUL-terminated.
* cpplib.c (destringize_and_run, cpp_define, handle_assertion):
Be sure buffers are NUL terminated.
* cppmacro.c (warn_of_redefinition): Kill compile warning.
* c-common.c: Include tree-inline.h.
(c_language): Move separate definitions here.
(c_common_init_options, c_common_post_options): New.
(c_common_lang_init): Rename c_common_init.
* c-common.h (c_common_lang_init): Similarly.
(c_common_init_options, c_common_post_options): New.
* c-lang.c (c_post_options): Move body to c_common_post_options.
(c_init_options): Use c_common_init_options.
(c_init): Update.
* langhooks.def: Rearrange.
* langhooks.h: Rearrange, and improve comments.
* toplev.c (do_compile): New function.
(toplev_main): Use it.
(lang_independent_f_options, parse_options_and_default_flags,
process_options): Remove trailing periods.
* Makefile.in: Update.
cp: * decl2.c (c_language): Move to c-common.c.
* lex.c (cxx_post_options, cxx_init_options): Use c-common.c
functions.
(cxx_init): Update.
objc: * objc-act.c (objc_post_options, objc_init_options): Use c-common.c
functions.
(ojbc_init): Update.
From-SVN: r47362
2001-11-27 07:44:54 +08:00
|
|
|
if (read_include_file (pfile, inc))
|
2001-08-22 03:23:24 +08:00
|
|
|
{
|
2001-10-09 01:54:15 +08:00
|
|
|
/* If an error occurs, do not try to read this file again. */
|
2001-08-22 03:23:24 +08:00
|
|
|
_cpp_never_reread (inc);
|
|
|
|
return false;
|
|
|
|
}
|
cppfiles.c (stack_include_file): Don't optimize zero-length files.
* cppfiles.c (stack_include_file): Don't optimize zero-length
files.
(read_include_file): NUL-terminate read files.
* cpplex.c (handle_newline, skip_escaped_newlines,
get_effective_char, skip_whitespace, parse_identifier,
parse_identifier_slow, parse_number, parse_string,
_cpp_lex_direct): Optimize for the fact that buffers are guaranteed
NUL-terminated.
* cpplib.c (destringize_and_run, cpp_define, handle_assertion):
Be sure buffers are NUL terminated.
* cppmacro.c (warn_of_redefinition): Kill compile warning.
* c-common.c: Include tree-inline.h.
(c_language): Move separate definitions here.
(c_common_init_options, c_common_post_options): New.
(c_common_lang_init): Rename c_common_init.
* c-common.h (c_common_lang_init): Similarly.
(c_common_init_options, c_common_post_options): New.
* c-lang.c (c_post_options): Move body to c_common_post_options.
(c_init_options): Use c_common_init_options.
(c_init): Update.
* langhooks.def: Rearrange.
* langhooks.h: Rearrange, and improve comments.
* toplev.c (do_compile): New function.
(toplev_main): Use it.
(lang_independent_f_options, parse_options_and_default_flags,
process_options): Remove trailing periods.
* Makefile.in: Update.
cp: * decl2.c (c_language): Move to c-common.c.
* lex.c (cxx_post_options, cxx_init_options): Use c-common.c
functions.
(cxx_init): Update.
objc: * objc-act.c (objc_post_options, objc_init_options): Use c-common.c
functions.
(ojbc_init): Update.
From-SVN: r47362
2001-11-27 07:44:54 +08:00
|
|
|
/* Mark a regular, zero-length file never-reread. We read it,
|
|
|
|
NUL-terminate it, and stack it once, so preprocessing a main
|
|
|
|
file of zero length does not raise an error. */
|
|
|
|
if (S_ISREG (inc->st.st_mode) && inc->st.st_size == 0)
|
|
|
|
_cpp_never_reread (inc);
|
2001-04-06 13:21:36 +08:00
|
|
|
close (inc->fd);
|
|
|
|
inc->fd = -1;
|
|
|
|
}
|
|
|
|
|
2001-08-22 03:23:24 +08:00
|
|
|
if (pfile->buffer)
|
2001-08-22 05:17:48 +08:00
|
|
|
/* We don't want MI guard advice for the main file. */
|
|
|
|
inc->include_count++;
|
2000-12-19 03:00:26 +08:00
|
|
|
|
|
|
|
/* Push a buffer. */
|
cpperror.c (print_location): Don't show _Pragma.
* cpperror.c (print_location): Don't show _Pragma.
* cppfiles.c (_cpp_pop_file_buffer): Handle -include file pushing
and file change callback generation here.
(stack_include_file): Update use of cpp_push_buffer.
* cpphash.h (_cpp_pop_file_buffer): Update prototype.
(struct cpp_buffer): Remove type, pfile members.
* cppinit.c (cpp_handle_option): Use free_chain.
* cpplex.c (_cpp_lex_token): Don't do -include file pushing here.
(skip_escaped_newlines, get_effective_char, lex_percent): Take
a cpp_reader rather than a cpp_buffer.
(skip_escaped_newlines, get_effective_char, skip_block_comment,
skip_line_comment, parse_string, lex_percent, lex_dot,
_cpp_lex_token): Update accordingly.
* cpplib.c (_cpp_pop_buffer): Don't do file change callback
generation here.
(cpp_push_buffer): Update prototype.
(run_directive): Update use of cpp_push_buffer.
(_cpp_do__Pragma, cpp_define, cpp_define_builtin, cpp_undef,
handle_assertion): Update use of run_directive.
* cpplib.h (enum cpp_buffer_type): Remove.
(cpp_push_buffer): Update prototype.
* fix-header.c (read_scan_file): Update.
From-SVN: r45112
2001-08-23 04:37:20 +08:00
|
|
|
fp = cpp_push_buffer (pfile, inc->buffer, inc->st.st_size,
|
|
|
|
/* from_stage3 */ CPP_OPTION (pfile, preprocessed), 0);
|
2000-12-19 03:00:26 +08:00
|
|
|
fp->inc = inc;
|
2000-12-06 07:42:43 +08:00
|
|
|
fp->inc->refcnt++;
|
2000-09-12 11:42:30 +08:00
|
|
|
|
2000-12-06 07:42:43 +08:00
|
|
|
/* Initialise controlling macro state. */
|
2001-07-30 01:27:57 +08:00
|
|
|
pfile->mi_valid = true;
|
2000-12-06 07:42:43 +08:00
|
|
|
pfile->mi_cmacro = 0;
|
2000-12-19 03:00:26 +08:00
|
|
|
|
|
|
|
/* Generate the call back. */
|
2001-08-18 06:23:49 +08:00
|
|
|
filename = inc->name;
|
|
|
|
if (*filename == '\0')
|
|
|
|
filename = _("<stdin>");
|
|
|
|
_cpp_do_file_change (pfile, LC_ENTER, filename, 1, sysp);
|
2001-08-22 03:23:24 +08:00
|
|
|
|
|
|
|
return true;
|
2000-09-12 11:42:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Read the file referenced by INC into the file cache.
|
|
|
|
|
|
|
|
If fd points to a plain file, we might be able to mmap it; we can
|
|
|
|
definitely allocate the buffer all at once. If fd is a pipe or
|
|
|
|
terminal, we can't do either. If fd is something weird, like a
|
2001-04-06 13:21:36 +08:00
|
|
|
block device, we don't want to read it at all.
|
2000-09-12 11:42:30 +08:00
|
|
|
|
|
|
|
Unfortunately, different systems use different st.st_mode values
|
|
|
|
for pipes: some have S_ISFIFO, some S_ISSOCK, some are buggy and
|
|
|
|
zero the entire struct stat except a couple fields. Hence we don't
|
2001-04-06 13:21:36 +08:00
|
|
|
even try to figure out what something is, except for plain files
|
|
|
|
and block devices.
|
2000-09-12 11:42:30 +08:00
|
|
|
|
|
|
|
FIXME: Flush file cache and try again if we run out of memory. */
|
|
|
|
|
2001-04-06 13:21:36 +08:00
|
|
|
static int
|
2000-09-12 11:42:30 +08:00
|
|
|
read_include_file (pfile, inc)
|
|
|
|
cpp_reader *pfile;
|
|
|
|
struct include_file *inc;
|
|
|
|
{
|
|
|
|
ssize_t size, offset, count;
|
|
|
|
U_CHAR *buf;
|
|
|
|
#if MMAP_THRESHOLD
|
|
|
|
static int pagesize = -1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (S_ISREG (inc->st.st_mode))
|
cpplex.c (cpp_output_tokens, [...]): New public interfaces.
* cpplex.c (cpp_output_tokens, cpp_scan_buffer_nooutput): New public
interfaces.
(safe_fwrite, output_line_command): New static functions.
(cpp_expand_to_buffer): Now private to cpplib.
(cpp_scan_buffer): Take a printer.
* cpphash.h: Update prototypes.
* cpplib.h: Update prototypes.
(cpp_printer): New.
(cpp_buffer): Remove last_nominal_fname.
(cpp_reader): Remove lineno.
* cppmain.c: Use a cpp_printer.
* fix-header.c: No need to inhibit line commands. Call
cpp_start_read with no printer.
* cpperror.c (cpp_notice_from_errno): Provide default name.
* cppfiles.c (make_IHASH, _cpp_fake_ihash): New functions.
(find_include_file, cpp_read_file): Use make_IHASH.
(file_cleanup): Set control_macro and clear
input_stack_listing_current here.
(_cpp_execute_include): Don't output entering-file marker.
* cpphash.c (special_symbol): Look for the line number in the
buffer, not the reader.
(_cpp_macroexpand): No need to disable line commands.
(_cpp_dump_definition): No need to generate line commands.
(dump_hash_helper): Remove excess newline from output.
* cppinit.c (dump_special_to_buffer): No need to generate line
commands.
(cpp_printer_init): New.
(cpp_start_read): Take a printer, and start it up if it's not
NULL. No need to generate line commands.
(cpp_finish): Expect no buffers stacked at all. Take a
printer argument, and flush the output buffer if it's not
NULL.
* cpplex.c (_cpp_lex_token): Return EOF if there's no buffer.
Don't put two hashes at the beginning of an assertion.
(cpp_get_token): Don't increment pfile->lineno or emit line
commands here. Return EOF if there's no buffer when we get
EOF.
* cpplib.c (do_define, skip_if_group):
No need to disable line commands.
(_cpp_output_line_command): Delete function.
(do_line): Don't emit line commands here, but set things up so
they will be emitted if necessary. Use _cpp_fake_ihash to
make unique nominal_fnames if necessary.
(do_elif, do_else, _cpp_handle_eof): Call cpp_error_with_line
with 0 for column, not -1.
(_cpp_handle_eof): Don't set the control macro here. Don't
clear input_stack_listing_current here. Don't emit line
commands.
From-SVN: r33159
2000-04-15 07:29:45 +08:00
|
|
|
{
|
2000-09-12 11:42:30 +08:00
|
|
|
/* off_t might have a wider range than ssize_t - in other words,
|
|
|
|
the max size of a file might be bigger than the address
|
|
|
|
space. We can't handle a file that large. (Anyone with
|
|
|
|
a single source file bigger than 2GB needs to rethink
|
|
|
|
their coding style.) Some systems (e.g. AIX 4.1) define
|
|
|
|
SSIZE_MAX to be much smaller than the actual range of the
|
|
|
|
type. Use INTTYPE_MAXIMUM unconditionally to ensure this
|
|
|
|
does not bite us. */
|
|
|
|
if (inc->st.st_size > INTTYPE_MAXIMUM (ssize_t))
|
cpplex.c (cpp_output_tokens, [...]): New public interfaces.
* cpplex.c (cpp_output_tokens, cpp_scan_buffer_nooutput): New public
interfaces.
(safe_fwrite, output_line_command): New static functions.
(cpp_expand_to_buffer): Now private to cpplib.
(cpp_scan_buffer): Take a printer.
* cpphash.h: Update prototypes.
* cpplib.h: Update prototypes.
(cpp_printer): New.
(cpp_buffer): Remove last_nominal_fname.
(cpp_reader): Remove lineno.
* cppmain.c: Use a cpp_printer.
* fix-header.c: No need to inhibit line commands. Call
cpp_start_read with no printer.
* cpperror.c (cpp_notice_from_errno): Provide default name.
* cppfiles.c (make_IHASH, _cpp_fake_ihash): New functions.
(find_include_file, cpp_read_file): Use make_IHASH.
(file_cleanup): Set control_macro and clear
input_stack_listing_current here.
(_cpp_execute_include): Don't output entering-file marker.
* cpphash.c (special_symbol): Look for the line number in the
buffer, not the reader.
(_cpp_macroexpand): No need to disable line commands.
(_cpp_dump_definition): No need to generate line commands.
(dump_hash_helper): Remove excess newline from output.
* cppinit.c (dump_special_to_buffer): No need to generate line
commands.
(cpp_printer_init): New.
(cpp_start_read): Take a printer, and start it up if it's not
NULL. No need to generate line commands.
(cpp_finish): Expect no buffers stacked at all. Take a
printer argument, and flush the output buffer if it's not
NULL.
* cpplex.c (_cpp_lex_token): Return EOF if there's no buffer.
Don't put two hashes at the beginning of an assertion.
(cpp_get_token): Don't increment pfile->lineno or emit line
commands here. Return EOF if there's no buffer when we get
EOF.
* cpplib.c (do_define, skip_if_group):
No need to disable line commands.
(_cpp_output_line_command): Delete function.
(do_line): Don't emit line commands here, but set things up so
they will be emitted if necessary. Use _cpp_fake_ihash to
make unique nominal_fnames if necessary.
(do_elif, do_else, _cpp_handle_eof): Call cpp_error_with_line
with 0 for column, not -1.
(_cpp_handle_eof): Don't set the control macro here. Don't
clear input_stack_listing_current here. Don't emit line
commands.
From-SVN: r33159
2000-04-15 07:29:45 +08:00
|
|
|
{
|
2000-09-12 11:42:30 +08:00
|
|
|
cpp_error (pfile, "%s is too large", inc->name);
|
|
|
|
goto fail;
|
cpplex.c (cpp_output_tokens, [...]): New public interfaces.
* cpplex.c (cpp_output_tokens, cpp_scan_buffer_nooutput): New public
interfaces.
(safe_fwrite, output_line_command): New static functions.
(cpp_expand_to_buffer): Now private to cpplib.
(cpp_scan_buffer): Take a printer.
* cpphash.h: Update prototypes.
* cpplib.h: Update prototypes.
(cpp_printer): New.
(cpp_buffer): Remove last_nominal_fname.
(cpp_reader): Remove lineno.
* cppmain.c: Use a cpp_printer.
* fix-header.c: No need to inhibit line commands. Call
cpp_start_read with no printer.
* cpperror.c (cpp_notice_from_errno): Provide default name.
* cppfiles.c (make_IHASH, _cpp_fake_ihash): New functions.
(find_include_file, cpp_read_file): Use make_IHASH.
(file_cleanup): Set control_macro and clear
input_stack_listing_current here.
(_cpp_execute_include): Don't output entering-file marker.
* cpphash.c (special_symbol): Look for the line number in the
buffer, not the reader.
(_cpp_macroexpand): No need to disable line commands.
(_cpp_dump_definition): No need to generate line commands.
(dump_hash_helper): Remove excess newline from output.
* cppinit.c (dump_special_to_buffer): No need to generate line
commands.
(cpp_printer_init): New.
(cpp_start_read): Take a printer, and start it up if it's not
NULL. No need to generate line commands.
(cpp_finish): Expect no buffers stacked at all. Take a
printer argument, and flush the output buffer if it's not
NULL.
* cpplex.c (_cpp_lex_token): Return EOF if there's no buffer.
Don't put two hashes at the beginning of an assertion.
(cpp_get_token): Don't increment pfile->lineno or emit line
commands here. Return EOF if there's no buffer when we get
EOF.
* cpplib.c (do_define, skip_if_group):
No need to disable line commands.
(_cpp_output_line_command): Delete function.
(do_line): Don't emit line commands here, but set things up so
they will be emitted if necessary. Use _cpp_fake_ihash to
make unique nominal_fnames if necessary.
(do_elif, do_else, _cpp_handle_eof): Call cpp_error_with_line
with 0 for column, not -1.
(_cpp_handle_eof): Don't set the control macro here. Don't
clear input_stack_listing_current here. Don't emit line
commands.
From-SVN: r33159
2000-04-15 07:29:45 +08:00
|
|
|
}
|
2000-09-12 11:42:30 +08:00
|
|
|
size = inc->st.st_size;
|
|
|
|
|
2000-09-17 02:17:53 +08:00
|
|
|
inc->mapped = 0;
|
2000-09-12 11:42:30 +08:00
|
|
|
#if MMAP_THRESHOLD
|
|
|
|
if (pagesize == -1)
|
|
|
|
pagesize = getpagesize ();
|
|
|
|
|
2001-11-27 15:42:10 +08:00
|
|
|
/* Use mmap if the file is big enough to be worth it (controlled
|
|
|
|
by MMAP_THRESHOLD) and if we can safely count on there being
|
|
|
|
at least one readable NUL byte after the end of the file's
|
|
|
|
contents. This is true for all tested operating systems when
|
|
|
|
the file size is not an exact multiple of the page size. */
|
cppfiles.c (stack_include_file): Don't optimize zero-length files.
* cppfiles.c (stack_include_file): Don't optimize zero-length
files.
(read_include_file): NUL-terminate read files.
* cpplex.c (handle_newline, skip_escaped_newlines,
get_effective_char, skip_whitespace, parse_identifier,
parse_identifier_slow, parse_number, parse_string,
_cpp_lex_direct): Optimize for the fact that buffers are guaranteed
NUL-terminated.
* cpplib.c (destringize_and_run, cpp_define, handle_assertion):
Be sure buffers are NUL terminated.
* cppmacro.c (warn_of_redefinition): Kill compile warning.
* c-common.c: Include tree-inline.h.
(c_language): Move separate definitions here.
(c_common_init_options, c_common_post_options): New.
(c_common_lang_init): Rename c_common_init.
* c-common.h (c_common_lang_init): Similarly.
(c_common_init_options, c_common_post_options): New.
* c-lang.c (c_post_options): Move body to c_common_post_options.
(c_init_options): Use c_common_init_options.
(c_init): Update.
* langhooks.def: Rearrange.
* langhooks.h: Rearrange, and improve comments.
* toplev.c (do_compile): New function.
(toplev_main): Use it.
(lang_independent_f_options, parse_options_and_default_flags,
process_options): Remove trailing periods.
* Makefile.in: Update.
cp: * decl2.c (c_language): Move to c-common.c.
* lex.c (cxx_post_options, cxx_init_options): Use c-common.c
functions.
(cxx_init): Update.
objc: * objc-act.c (objc_post_options, objc_init_options): Use c-common.c
functions.
(ojbc_init): Update.
From-SVN: r47362
2001-11-27 07:44:54 +08:00
|
|
|
if (size / pagesize >= MMAP_THRESHOLD
|
|
|
|
&& (size % pagesize) != 0)
|
2000-09-12 11:42:30 +08:00
|
|
|
{
|
|
|
|
buf = (U_CHAR *) mmap (0, size, PROT_READ, MAP_PRIVATE, inc->fd, 0);
|
|
|
|
if (buf == (U_CHAR *)-1)
|
|
|
|
goto perror_fail;
|
|
|
|
inc->mapped = 1;
|
|
|
|
}
|
|
|
|
else
|
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
2000-06-22 02:33:51 +08:00
|
|
|
#endif
|
2000-06-29 03:03:08 +08:00
|
|
|
{
|
cppfiles.c (stack_include_file): Don't optimize zero-length files.
* cppfiles.c (stack_include_file): Don't optimize zero-length
files.
(read_include_file): NUL-terminate read files.
* cpplex.c (handle_newline, skip_escaped_newlines,
get_effective_char, skip_whitespace, parse_identifier,
parse_identifier_slow, parse_number, parse_string,
_cpp_lex_direct): Optimize for the fact that buffers are guaranteed
NUL-terminated.
* cpplib.c (destringize_and_run, cpp_define, handle_assertion):
Be sure buffers are NUL terminated.
* cppmacro.c (warn_of_redefinition): Kill compile warning.
* c-common.c: Include tree-inline.h.
(c_language): Move separate definitions here.
(c_common_init_options, c_common_post_options): New.
(c_common_lang_init): Rename c_common_init.
* c-common.h (c_common_lang_init): Similarly.
(c_common_init_options, c_common_post_options): New.
* c-lang.c (c_post_options): Move body to c_common_post_options.
(c_init_options): Use c_common_init_options.
(c_init): Update.
* langhooks.def: Rearrange.
* langhooks.h: Rearrange, and improve comments.
* toplev.c (do_compile): New function.
(toplev_main): Use it.
(lang_independent_f_options, parse_options_and_default_flags,
process_options): Remove trailing periods.
* Makefile.in: Update.
cp: * decl2.c (c_language): Move to c-common.c.
* lex.c (cxx_post_options, cxx_init_options): Use c-common.c
functions.
(cxx_init): Update.
objc: * objc-act.c (objc_post_options, objc_init_options): Use c-common.c
functions.
(ojbc_init): Update.
From-SVN: r47362
2001-11-27 07:44:54 +08:00
|
|
|
buf = (U_CHAR *) xmalloc (size + 1);
|
2000-09-12 11:42:30 +08:00
|
|
|
offset = 0;
|
|
|
|
while (offset < size)
|
|
|
|
{
|
|
|
|
count = read (inc->fd, buf + offset, size - offset);
|
|
|
|
if (count < 0)
|
|
|
|
goto perror_fail;
|
|
|
|
if (count == 0)
|
|
|
|
{
|
2001-11-22 06:03:27 +08:00
|
|
|
if (!STAT_SIZE_TOO_BIG (inc->st))
|
|
|
|
cpp_warning
|
|
|
|
(pfile, "%s is shorter than expected", inc->name);
|
|
|
|
buf = xrealloc (buf, offset);
|
|
|
|
inc->st.st_size = offset;
|
2000-09-12 11:42:30 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
offset += count;
|
|
|
|
}
|
cppfiles.c (stack_include_file): Don't optimize zero-length files.
* cppfiles.c (stack_include_file): Don't optimize zero-length
files.
(read_include_file): NUL-terminate read files.
* cpplex.c (handle_newline, skip_escaped_newlines,
get_effective_char, skip_whitespace, parse_identifier,
parse_identifier_slow, parse_number, parse_string,
_cpp_lex_direct): Optimize for the fact that buffers are guaranteed
NUL-terminated.
* cpplib.c (destringize_and_run, cpp_define, handle_assertion):
Be sure buffers are NUL terminated.
* cppmacro.c (warn_of_redefinition): Kill compile warning.
* c-common.c: Include tree-inline.h.
(c_language): Move separate definitions here.
(c_common_init_options, c_common_post_options): New.
(c_common_lang_init): Rename c_common_init.
* c-common.h (c_common_lang_init): Similarly.
(c_common_init_options, c_common_post_options): New.
* c-lang.c (c_post_options): Move body to c_common_post_options.
(c_init_options): Use c_common_init_options.
(c_init): Update.
* langhooks.def: Rearrange.
* langhooks.h: Rearrange, and improve comments.
* toplev.c (do_compile): New function.
(toplev_main): Use it.
(lang_independent_f_options, parse_options_and_default_flags,
process_options): Remove trailing periods.
* Makefile.in: Update.
cp: * decl2.c (c_language): Move to c-common.c.
* lex.c (cxx_post_options, cxx_init_options): Use c-common.c
functions.
(cxx_init): Update.
objc: * objc-act.c (objc_post_options, objc_init_options): Use c-common.c
functions.
(ojbc_init): Update.
From-SVN: r47362
2001-11-27 07:44:54 +08:00
|
|
|
/* The lexer requires that the buffer be NUL-terminated. */
|
|
|
|
buf[size] = '\0';
|
2000-06-29 03:03:08 +08:00
|
|
|
}
|
2000-09-12 11:42:30 +08:00
|
|
|
}
|
|
|
|
else if (S_ISBLK (inc->st.st_mode))
|
|
|
|
{
|
|
|
|
cpp_error (pfile, "%s is a block device", inc->name);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* 8 kilobytes is a sensible starting size. It ought to be
|
|
|
|
bigger than the kernel pipe buffer, and it's definitely
|
|
|
|
bigger than the majority of C source files. */
|
|
|
|
size = 8 * 1024;
|
2000-06-29 03:03:08 +08:00
|
|
|
|
cppfiles.c (stack_include_file): Don't optimize zero-length files.
* cppfiles.c (stack_include_file): Don't optimize zero-length
files.
(read_include_file): NUL-terminate read files.
* cpplex.c (handle_newline, skip_escaped_newlines,
get_effective_char, skip_whitespace, parse_identifier,
parse_identifier_slow, parse_number, parse_string,
_cpp_lex_direct): Optimize for the fact that buffers are guaranteed
NUL-terminated.
* cpplib.c (destringize_and_run, cpp_define, handle_assertion):
Be sure buffers are NUL terminated.
* cppmacro.c (warn_of_redefinition): Kill compile warning.
* c-common.c: Include tree-inline.h.
(c_language): Move separate definitions here.
(c_common_init_options, c_common_post_options): New.
(c_common_lang_init): Rename c_common_init.
* c-common.h (c_common_lang_init): Similarly.
(c_common_init_options, c_common_post_options): New.
* c-lang.c (c_post_options): Move body to c_common_post_options.
(c_init_options): Use c_common_init_options.
(c_init): Update.
* langhooks.def: Rearrange.
* langhooks.h: Rearrange, and improve comments.
* toplev.c (do_compile): New function.
(toplev_main): Use it.
(lang_independent_f_options, parse_options_and_default_flags,
process_options): Remove trailing periods.
* Makefile.in: Update.
cp: * decl2.c (c_language): Move to c-common.c.
* lex.c (cxx_post_options, cxx_init_options): Use c-common.c
functions.
(cxx_init): Update.
objc: * objc-act.c (objc_post_options, objc_init_options): Use c-common.c
functions.
(ojbc_init): Update.
From-SVN: r47362
2001-11-27 07:44:54 +08:00
|
|
|
buf = (U_CHAR *) xmalloc (size + 1);
|
2000-09-12 11:42:30 +08:00
|
|
|
offset = 0;
|
|
|
|
while ((count = read (inc->fd, buf + offset, size - offset)) > 0)
|
cpplex.c (cpp_output_tokens, [...]): New public interfaces.
* cpplex.c (cpp_output_tokens, cpp_scan_buffer_nooutput): New public
interfaces.
(safe_fwrite, output_line_command): New static functions.
(cpp_expand_to_buffer): Now private to cpplib.
(cpp_scan_buffer): Take a printer.
* cpphash.h: Update prototypes.
* cpplib.h: Update prototypes.
(cpp_printer): New.
(cpp_buffer): Remove last_nominal_fname.
(cpp_reader): Remove lineno.
* cppmain.c: Use a cpp_printer.
* fix-header.c: No need to inhibit line commands. Call
cpp_start_read with no printer.
* cpperror.c (cpp_notice_from_errno): Provide default name.
* cppfiles.c (make_IHASH, _cpp_fake_ihash): New functions.
(find_include_file, cpp_read_file): Use make_IHASH.
(file_cleanup): Set control_macro and clear
input_stack_listing_current here.
(_cpp_execute_include): Don't output entering-file marker.
* cpphash.c (special_symbol): Look for the line number in the
buffer, not the reader.
(_cpp_macroexpand): No need to disable line commands.
(_cpp_dump_definition): No need to generate line commands.
(dump_hash_helper): Remove excess newline from output.
* cppinit.c (dump_special_to_buffer): No need to generate line
commands.
(cpp_printer_init): New.
(cpp_start_read): Take a printer, and start it up if it's not
NULL. No need to generate line commands.
(cpp_finish): Expect no buffers stacked at all. Take a
printer argument, and flush the output buffer if it's not
NULL.
* cpplex.c (_cpp_lex_token): Return EOF if there's no buffer.
Don't put two hashes at the beginning of an assertion.
(cpp_get_token): Don't increment pfile->lineno or emit line
commands here. Return EOF if there's no buffer when we get
EOF.
* cpplib.c (do_define, skip_if_group):
No need to disable line commands.
(_cpp_output_line_command): Delete function.
(do_line): Don't emit line commands here, but set things up so
they will be emitted if necessary. Use _cpp_fake_ihash to
make unique nominal_fnames if necessary.
(do_elif, do_else, _cpp_handle_eof): Call cpp_error_with_line
with 0 for column, not -1.
(_cpp_handle_eof): Don't set the control macro here. Don't
clear input_stack_listing_current here. Don't emit line
commands.
From-SVN: r33159
2000-04-15 07:29:45 +08:00
|
|
|
{
|
2000-09-12 11:42:30 +08:00
|
|
|
offset += count;
|
|
|
|
if (offset == size)
|
cppfiles.c (stack_include_file): Don't optimize zero-length files.
* cppfiles.c (stack_include_file): Don't optimize zero-length
files.
(read_include_file): NUL-terminate read files.
* cpplex.c (handle_newline, skip_escaped_newlines,
get_effective_char, skip_whitespace, parse_identifier,
parse_identifier_slow, parse_number, parse_string,
_cpp_lex_direct): Optimize for the fact that buffers are guaranteed
NUL-terminated.
* cpplib.c (destringize_and_run, cpp_define, handle_assertion):
Be sure buffers are NUL terminated.
* cppmacro.c (warn_of_redefinition): Kill compile warning.
* c-common.c: Include tree-inline.h.
(c_language): Move separate definitions here.
(c_common_init_options, c_common_post_options): New.
(c_common_lang_init): Rename c_common_init.
* c-common.h (c_common_lang_init): Similarly.
(c_common_init_options, c_common_post_options): New.
* c-lang.c (c_post_options): Move body to c_common_post_options.
(c_init_options): Use c_common_init_options.
(c_init): Update.
* langhooks.def: Rearrange.
* langhooks.h: Rearrange, and improve comments.
* toplev.c (do_compile): New function.
(toplev_main): Use it.
(lang_independent_f_options, parse_options_and_default_flags,
process_options): Remove trailing periods.
* Makefile.in: Update.
cp: * decl2.c (c_language): Move to c-common.c.
* lex.c (cxx_post_options, cxx_init_options): Use c-common.c
functions.
(cxx_init): Update.
objc: * objc-act.c (objc_post_options, objc_init_options): Use c-common.c
functions.
(ojbc_init): Update.
From-SVN: r47362
2001-11-27 07:44:54 +08:00
|
|
|
{
|
|
|
|
size *= 2;
|
|
|
|
buf = xrealloc (buf, size + 1);
|
|
|
|
}
|
cpplex.c (cpp_output_tokens, [...]): New public interfaces.
* cpplex.c (cpp_output_tokens, cpp_scan_buffer_nooutput): New public
interfaces.
(safe_fwrite, output_line_command): New static functions.
(cpp_expand_to_buffer): Now private to cpplib.
(cpp_scan_buffer): Take a printer.
* cpphash.h: Update prototypes.
* cpplib.h: Update prototypes.
(cpp_printer): New.
(cpp_buffer): Remove last_nominal_fname.
(cpp_reader): Remove lineno.
* cppmain.c: Use a cpp_printer.
* fix-header.c: No need to inhibit line commands. Call
cpp_start_read with no printer.
* cpperror.c (cpp_notice_from_errno): Provide default name.
* cppfiles.c (make_IHASH, _cpp_fake_ihash): New functions.
(find_include_file, cpp_read_file): Use make_IHASH.
(file_cleanup): Set control_macro and clear
input_stack_listing_current here.
(_cpp_execute_include): Don't output entering-file marker.
* cpphash.c (special_symbol): Look for the line number in the
buffer, not the reader.
(_cpp_macroexpand): No need to disable line commands.
(_cpp_dump_definition): No need to generate line commands.
(dump_hash_helper): Remove excess newline from output.
* cppinit.c (dump_special_to_buffer): No need to generate line
commands.
(cpp_printer_init): New.
(cpp_start_read): Take a printer, and start it up if it's not
NULL. No need to generate line commands.
(cpp_finish): Expect no buffers stacked at all. Take a
printer argument, and flush the output buffer if it's not
NULL.
* cpplex.c (_cpp_lex_token): Return EOF if there's no buffer.
Don't put two hashes at the beginning of an assertion.
(cpp_get_token): Don't increment pfile->lineno or emit line
commands here. Return EOF if there's no buffer when we get
EOF.
* cpplib.c (do_define, skip_if_group):
No need to disable line commands.
(_cpp_output_line_command): Delete function.
(do_line): Don't emit line commands here, but set things up so
they will be emitted if necessary. Use _cpp_fake_ihash to
make unique nominal_fnames if necessary.
(do_elif, do_else, _cpp_handle_eof): Call cpp_error_with_line
with 0 for column, not -1.
(_cpp_handle_eof): Don't set the control macro here. Don't
clear input_stack_listing_current here. Don't emit line
commands.
From-SVN: r33159
2000-04-15 07:29:45 +08:00
|
|
|
}
|
2000-09-12 11:42:30 +08:00
|
|
|
if (count < 0)
|
|
|
|
goto perror_fail;
|
|
|
|
|
cppfiles.c (stack_include_file): Don't optimize zero-length files.
* cppfiles.c (stack_include_file): Don't optimize zero-length
files.
(read_include_file): NUL-terminate read files.
* cpplex.c (handle_newline, skip_escaped_newlines,
get_effective_char, skip_whitespace, parse_identifier,
parse_identifier_slow, parse_number, parse_string,
_cpp_lex_direct): Optimize for the fact that buffers are guaranteed
NUL-terminated.
* cpplib.c (destringize_and_run, cpp_define, handle_assertion):
Be sure buffers are NUL terminated.
* cppmacro.c (warn_of_redefinition): Kill compile warning.
* c-common.c: Include tree-inline.h.
(c_language): Move separate definitions here.
(c_common_init_options, c_common_post_options): New.
(c_common_lang_init): Rename c_common_init.
* c-common.h (c_common_lang_init): Similarly.
(c_common_init_options, c_common_post_options): New.
* c-lang.c (c_post_options): Move body to c_common_post_options.
(c_init_options): Use c_common_init_options.
(c_init): Update.
* langhooks.def: Rearrange.
* langhooks.h: Rearrange, and improve comments.
* toplev.c (do_compile): New function.
(toplev_main): Use it.
(lang_independent_f_options, parse_options_and_default_flags,
process_options): Remove trailing periods.
* Makefile.in: Update.
cp: * decl2.c (c_language): Move to c-common.c.
* lex.c (cxx_post_options, cxx_init_options): Use c-common.c
functions.
(cxx_init): Update.
objc: * objc-act.c (objc_post_options, objc_init_options): Use c-common.c
functions.
(ojbc_init): Update.
From-SVN: r47362
2001-11-27 07:44:54 +08:00
|
|
|
if (offset + 1 < size)
|
|
|
|
buf = xrealloc (buf, offset + 1);
|
|
|
|
|
|
|
|
/* The lexer requires that the buffer be NUL-terminated. */
|
|
|
|
buf[offset] = '\0';
|
2000-09-12 11:42:30 +08:00
|
|
|
inc->st.st_size = offset;
|
cpplex.c (cpp_output_tokens, [...]): New public interfaces.
* cpplex.c (cpp_output_tokens, cpp_scan_buffer_nooutput): New public
interfaces.
(safe_fwrite, output_line_command): New static functions.
(cpp_expand_to_buffer): Now private to cpplib.
(cpp_scan_buffer): Take a printer.
* cpphash.h: Update prototypes.
* cpplib.h: Update prototypes.
(cpp_printer): New.
(cpp_buffer): Remove last_nominal_fname.
(cpp_reader): Remove lineno.
* cppmain.c: Use a cpp_printer.
* fix-header.c: No need to inhibit line commands. Call
cpp_start_read with no printer.
* cpperror.c (cpp_notice_from_errno): Provide default name.
* cppfiles.c (make_IHASH, _cpp_fake_ihash): New functions.
(find_include_file, cpp_read_file): Use make_IHASH.
(file_cleanup): Set control_macro and clear
input_stack_listing_current here.
(_cpp_execute_include): Don't output entering-file marker.
* cpphash.c (special_symbol): Look for the line number in the
buffer, not the reader.
(_cpp_macroexpand): No need to disable line commands.
(_cpp_dump_definition): No need to generate line commands.
(dump_hash_helper): Remove excess newline from output.
* cppinit.c (dump_special_to_buffer): No need to generate line
commands.
(cpp_printer_init): New.
(cpp_start_read): Take a printer, and start it up if it's not
NULL. No need to generate line commands.
(cpp_finish): Expect no buffers stacked at all. Take a
printer argument, and flush the output buffer if it's not
NULL.
* cpplex.c (_cpp_lex_token): Return EOF if there's no buffer.
Don't put two hashes at the beginning of an assertion.
(cpp_get_token): Don't increment pfile->lineno or emit line
commands here. Return EOF if there's no buffer when we get
EOF.
* cpplib.c (do_define, skip_if_group):
No need to disable line commands.
(_cpp_output_line_command): Delete function.
(do_line): Don't emit line commands here, but set things up so
they will be emitted if necessary. Use _cpp_fake_ihash to
make unique nominal_fnames if necessary.
(do_elif, do_else, _cpp_handle_eof): Call cpp_error_with_line
with 0 for column, not -1.
(_cpp_handle_eof): Don't set the control macro here. Don't
clear input_stack_listing_current here. Don't emit line
commands.
From-SVN: r33159
2000-04-15 07:29:45 +08:00
|
|
|
}
|
2000-06-02 04:06:57 +08:00
|
|
|
|
2000-09-12 11:42:30 +08:00
|
|
|
inc->buffer = buf;
|
2001-04-06 13:21:36 +08:00
|
|
|
return 0;
|
2000-09-12 11:42:30 +08:00
|
|
|
|
|
|
|
perror_fail:
|
|
|
|
cpp_error_from_errno (pfile, inc->name);
|
|
|
|
fail:
|
2001-04-06 13:21:36 +08:00
|
|
|
return 1;
|
2000-09-12 11:42:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
purge_cache (inc)
|
|
|
|
struct include_file *inc;
|
|
|
|
{
|
|
|
|
if (inc->buffer)
|
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
2000-06-22 02:33:51 +08:00
|
|
|
{
|
2000-09-17 02:17:53 +08:00
|
|
|
#if MMAP_THRESHOLD
|
2000-09-12 11:42:30 +08:00
|
|
|
if (inc->mapped)
|
2000-09-17 01:48:10 +08:00
|
|
|
munmap ((PTR) inc->buffer, inc->st.st_size);
|
2000-09-12 11:42:30 +08:00
|
|
|
else
|
2000-09-17 02:17:53 +08:00
|
|
|
#endif
|
2000-09-12 11:42:30 +08:00
|
|
|
free ((PTR) inc->buffer);
|
|
|
|
inc->buffer = NULL;
|
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
2000-06-22 02:33:51 +08:00
|
|
|
}
|
2000-03-16 06:03:37 +08:00
|
|
|
}
|
|
|
|
|
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
2000-06-22 02:33:51 +08:00
|
|
|
/* Return 1 if the file named by FNAME has been included before in
|
|
|
|
any context, 0 otherwise. */
|
|
|
|
int
|
|
|
|
cpp_included (pfile, fname)
|
[multiple changes]
1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* c-lang.c: Declare extern char *yy_cur if USE_CPPLIB.
(lang_init): Call check_newline always.
* c-lex.c (init_parse) [USE_CPPLIB=1]: After calling
cpp_start_read, set yy_cur and yy_lim to read from
parse_in.token_buffer, so that we'll see the first #line
directive.
* cpplib.c (cpp_start_read): finclude the main input file
before processing -include/-imacros. Process -imacros and
-include separately, and handle -include by stacking a
buffer for the file in question as if it'd been #included.
* toplev.c (documented_lang_options) Recognize -H when
USE_CPPLIB is on.
1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.c: Merge do_once into do_pragma. Break file handling
code out of do_include.
Move append_include_chain, deps_output,
file_cleanup, redundant_include_p, import_hash,
lookup_import, add_import, read_filename_string, read_name_map,
open_include_file, finclude, safe_read to cppfiles.c.
Move prototypes for deps_output, append_include_chain,
finclude to cpplib.h. Move definition of struct
file_name_list there also.
* cppfiles.c: New file. Contains all the above functions
broken out of cpplib.c; also hack_vms_include_specification
from cccp.c and find_include_file, a new function broken out of
do_include.
* Makefile.in (cppmain): Depend on cppfiles.o.
(fix-header): Likewise.
(cppfiles.o): New target.
* configure.in (--enable-c-cpplib): Add cppfiles.o to
extra_c_objs. Add ../cppfiles.o to extra_cxx_objs.
From-SVN: r23424
1998-10-29 19:54:13 +08:00
|
|
|
cpp_reader *pfile;
|
cpperror.c (cpp_file_line_for_message): Constify a char*.
* cpperror.c (cpp_file_line_for_message): Constify a char*.
* cppexp.c (parse_number, parse_charconst, cpp_lex,
cpp_parse_expr): Add static prototypes.
(parse_charconst): Don't cast away const-ness.
(token): Constify a char*.
* cppfiles.c (file_name_list, include_hash, find_include_file,
finclude, initialize_input_buffer): Constify a char*.
(file_cleanup, find_position): Add static prototypes.
* cpphash.c (macro_cleanup, macarg, timestamp, special_symbol,
collect_expansion): Add static prototypes.
(cpp_install, create_definition, monthnames): Constify a char*.
* cpphash.h (cpp_install): Likewise.
* cppinit.c (known_suffixes, default_include,
dump_special_to_buffer, NAME, cpp_start_read, cpp_finish): Likewise.
(base_name, dump_special_to_buffer, initialize_dependency_output):
Add static prototypes.
* cpplib.c (my_strerror): Constify a char*.
(null_underflow, null_cleanup, skip_comment, copy_comment,
copy_rest_of_line, handle_directive, pass_thru_directive,
get_directive_token, read_line_number, cpp_print_file_and_line,
v_cpp_error, v_cpp_warning, v_cpp_error_with_line,
v_cpp_warning_with_line, detect_if_not_defined,
consider_directive_while_skipping): Add static prototypes.
(pass_thru_directive, check_macro_name, cpp_expand_to_buffer,
cpp_pedwarn_with_file_and_line): Constify a char*.
* cpplib.h (cpp_options, include_hash, progname, definition,
cpp_pedwarn_with_file_and_line, cpp_expand_to_buffer,
check_macro_name, cpp_pfatal_with_name, cpp_file_line_for_message,
find_include_file, deps_output, include_hash): Constify a char*.
* cppmain.c (progname): Constify.
(main): Add prototype. Use return, not exit.
* fix-header.c (fatal, add_symbols, lookup_std_proto, write_lbrac,
recognized_macro, check_macro_names, read_scan_file, write_rbrac,
inf_skip_spaces, inf_read_upto, inf_scan_ident, inf_scan_ident,
check_protection): Add static prototype.
(xfree): Remove.
(progname, recognized_macrom, recognized_extern): Constify a char*.
(main): Add prototype.
* gen-protos.c (progname): Constify a char*.
From-SVN: r29171
1999-09-07 23:41:26 +08:00
|
|
|
const char *fname;
|
[multiple changes]
1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* c-lang.c: Declare extern char *yy_cur if USE_CPPLIB.
(lang_init): Call check_newline always.
* c-lex.c (init_parse) [USE_CPPLIB=1]: After calling
cpp_start_read, set yy_cur and yy_lim to read from
parse_in.token_buffer, so that we'll see the first #line
directive.
* cpplib.c (cpp_start_read): finclude the main input file
before processing -include/-imacros. Process -imacros and
-include separately, and handle -include by stacking a
buffer for the file in question as if it'd been #included.
* toplev.c (documented_lang_options) Recognize -H when
USE_CPPLIB is on.
1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.c: Merge do_once into do_pragma. Break file handling
code out of do_include.
Move append_include_chain, deps_output,
file_cleanup, redundant_include_p, import_hash,
lookup_import, add_import, read_filename_string, read_name_map,
open_include_file, finclude, safe_read to cppfiles.c.
Move prototypes for deps_output, append_include_chain,
finclude to cpplib.h. Move definition of struct
file_name_list there also.
* cppfiles.c: New file. Contains all the above functions
broken out of cpplib.c; also hack_vms_include_specification
from cccp.c and find_include_file, a new function broken out of
do_include.
* Makefile.in (cppmain): Depend on cppfiles.o.
(fix-header): Likewise.
(cppfiles.o): New target.
* configure.in (--enable-c-cpplib): Add cppfiles.o to
extra_c_objs. Add ../cppfiles.o to extra_cxx_objs.
From-SVN: r23424
1998-10-29 19:54:13 +08:00
|
|
|
{
|
2001-03-02 15:35:12 +08:00
|
|
|
struct search_path *path;
|
2001-03-15 03:35:08 +08:00
|
|
|
char *name, *n;
|
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
2000-06-22 02:33:51 +08:00
|
|
|
splay_tree_node nd;
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
|
2001-01-12 05:30:16 +08:00
|
|
|
if (IS_ABSOLUTE_PATHNAME (fname))
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
{
|
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
2000-06-22 02:33:51 +08:00
|
|
|
/* Just look it up. */
|
|
|
|
nd = splay_tree_lookup (pfile->all_include_files, (splay_tree_key) fname);
|
|
|
|
return (nd && nd->value);
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
}
|
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
2000-06-22 02:33:51 +08:00
|
|
|
|
|
|
|
/* Search directory path for the file. */
|
2001-03-11 22:54:56 +08:00
|
|
|
name = (char *) alloca (strlen (fname) + pfile->max_include_len + 2);
|
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
2000-06-22 02:33:51 +08:00
|
|
|
for (path = CPP_OPTION (pfile, quote_include); path; path = path->next)
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
{
|
2001-03-02 15:35:12 +08:00
|
|
|
memcpy (name, path->name, path->len);
|
|
|
|
name[path->len] = '/';
|
|
|
|
strcpy (&name[path->len + 1], fname);
|
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
2000-06-22 02:33:51 +08:00
|
|
|
if (CPP_OPTION (pfile, remap))
|
2001-03-15 03:35:08 +08:00
|
|
|
n = remap_filename (pfile, name, path);
|
|
|
|
else
|
2001-03-15 15:57:13 +08:00
|
|
|
n = name;
|
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
2000-06-22 02:33:51 +08:00
|
|
|
|
2001-03-15 03:35:08 +08:00
|
|
|
nd = splay_tree_lookup (pfile->all_include_files, (splay_tree_key) n);
|
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
2000-06-22 02:33:51 +08:00
|
|
|
if (nd && nd->value)
|
|
|
|
return 1;
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
}
|
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
2000-06-22 02:33:51 +08:00
|
|
|
return 0;
|
[multiple changes]
1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* c-lang.c: Declare extern char *yy_cur if USE_CPPLIB.
(lang_init): Call check_newline always.
* c-lex.c (init_parse) [USE_CPPLIB=1]: After calling
cpp_start_read, set yy_cur and yy_lim to read from
parse_in.token_buffer, so that we'll see the first #line
directive.
* cpplib.c (cpp_start_read): finclude the main input file
before processing -include/-imacros. Process -imacros and
-include separately, and handle -include by stacking a
buffer for the file in question as if it'd been #included.
* toplev.c (documented_lang_options) Recognize -H when
USE_CPPLIB is on.
1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.c: Merge do_once into do_pragma. Break file handling
code out of do_include.
Move append_include_chain, deps_output,
file_cleanup, redundant_include_p, import_hash,
lookup_import, add_import, read_filename_string, read_name_map,
open_include_file, finclude, safe_read to cppfiles.c.
Move prototypes for deps_output, append_include_chain,
finclude to cpplib.h. Move definition of struct
file_name_list there also.
* cppfiles.c: New file. Contains all the above functions
broken out of cpplib.c; also hack_vms_include_specification
from cccp.c and find_include_file, a new function broken out of
do_include.
* Makefile.in (cppmain): Depend on cppfiles.o.
(fix-header): Likewise.
(cppfiles.o): New target.
* configure.in (--enable-c-cpplib): Add cppfiles.o to
extra_c_objs. Add ../cppfiles.o to extra_cxx_objs.
From-SVN: r23424
1998-10-29 19:54:13 +08:00
|
|
|
}
|
|
|
|
|
2001-03-14 07:55:10 +08:00
|
|
|
/* Search for HEADER. Return 0 if there is no such file (or it's
|
|
|
|
un-openable), in which case an error code will be in errno. If
|
|
|
|
there is no include path to use it returns NO_INCLUDE_PATH,
|
|
|
|
otherwise an include_file structure. If this request originates
|
|
|
|
from a #include_next directive, set INCLUDE_NEXT to true. */
|
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
2000-06-22 02:33:51 +08:00
|
|
|
|
|
|
|
static struct include_file *
|
2001-03-15 15:57:13 +08:00
|
|
|
find_include_file (pfile, header, type)
|
cpplex.c (cpp_output_tokens, [...]): New public interfaces.
* cpplex.c (cpp_output_tokens, cpp_scan_buffer_nooutput): New public
interfaces.
(safe_fwrite, output_line_command): New static functions.
(cpp_expand_to_buffer): Now private to cpplib.
(cpp_scan_buffer): Take a printer.
* cpphash.h: Update prototypes.
* cpplib.h: Update prototypes.
(cpp_printer): New.
(cpp_buffer): Remove last_nominal_fname.
(cpp_reader): Remove lineno.
* cppmain.c: Use a cpp_printer.
* fix-header.c: No need to inhibit line commands. Call
cpp_start_read with no printer.
* cpperror.c (cpp_notice_from_errno): Provide default name.
* cppfiles.c (make_IHASH, _cpp_fake_ihash): New functions.
(find_include_file, cpp_read_file): Use make_IHASH.
(file_cleanup): Set control_macro and clear
input_stack_listing_current here.
(_cpp_execute_include): Don't output entering-file marker.
* cpphash.c (special_symbol): Look for the line number in the
buffer, not the reader.
(_cpp_macroexpand): No need to disable line commands.
(_cpp_dump_definition): No need to generate line commands.
(dump_hash_helper): Remove excess newline from output.
* cppinit.c (dump_special_to_buffer): No need to generate line
commands.
(cpp_printer_init): New.
(cpp_start_read): Take a printer, and start it up if it's not
NULL. No need to generate line commands.
(cpp_finish): Expect no buffers stacked at all. Take a
printer argument, and flush the output buffer if it's not
NULL.
* cpplex.c (_cpp_lex_token): Return EOF if there's no buffer.
Don't put two hashes at the beginning of an assertion.
(cpp_get_token): Don't increment pfile->lineno or emit line
commands here. Return EOF if there's no buffer when we get
EOF.
* cpplib.c (do_define, skip_if_group):
No need to disable line commands.
(_cpp_output_line_command): Delete function.
(do_line): Don't emit line commands here, but set things up so
they will be emitted if necessary. Use _cpp_fake_ihash to
make unique nominal_fnames if necessary.
(do_elif, do_else, _cpp_handle_eof): Call cpp_error_with_line
with 0 for column, not -1.
(_cpp_handle_eof): Don't set the control macro here. Don't
clear input_stack_listing_current here. Don't emit line
commands.
From-SVN: r33159
2000-04-15 07:29:45 +08:00
|
|
|
cpp_reader *pfile;
|
2001-03-14 07:55:10 +08:00
|
|
|
const cpp_token *header;
|
2001-03-15 15:57:13 +08:00
|
|
|
enum include_type type;
|
cpplex.c (cpp_output_tokens, [...]): New public interfaces.
* cpplex.c (cpp_output_tokens, cpp_scan_buffer_nooutput): New public
interfaces.
(safe_fwrite, output_line_command): New static functions.
(cpp_expand_to_buffer): Now private to cpplib.
(cpp_scan_buffer): Take a printer.
* cpphash.h: Update prototypes.
* cpplib.h: Update prototypes.
(cpp_printer): New.
(cpp_buffer): Remove last_nominal_fname.
(cpp_reader): Remove lineno.
* cppmain.c: Use a cpp_printer.
* fix-header.c: No need to inhibit line commands. Call
cpp_start_read with no printer.
* cpperror.c (cpp_notice_from_errno): Provide default name.
* cppfiles.c (make_IHASH, _cpp_fake_ihash): New functions.
(find_include_file, cpp_read_file): Use make_IHASH.
(file_cleanup): Set control_macro and clear
input_stack_listing_current here.
(_cpp_execute_include): Don't output entering-file marker.
* cpphash.c (special_symbol): Look for the line number in the
buffer, not the reader.
(_cpp_macroexpand): No need to disable line commands.
(_cpp_dump_definition): No need to generate line commands.
(dump_hash_helper): Remove excess newline from output.
* cppinit.c (dump_special_to_buffer): No need to generate line
commands.
(cpp_printer_init): New.
(cpp_start_read): Take a printer, and start it up if it's not
NULL. No need to generate line commands.
(cpp_finish): Expect no buffers stacked at all. Take a
printer argument, and flush the output buffer if it's not
NULL.
* cpplex.c (_cpp_lex_token): Return EOF if there's no buffer.
Don't put two hashes at the beginning of an assertion.
(cpp_get_token): Don't increment pfile->lineno or emit line
commands here. Return EOF if there's no buffer when we get
EOF.
* cpplib.c (do_define, skip_if_group):
No need to disable line commands.
(_cpp_output_line_command): Delete function.
(do_line): Don't emit line commands here, but set things up so
they will be emitted if necessary. Use _cpp_fake_ihash to
make unique nominal_fnames if necessary.
(do_elif, do_else, _cpp_handle_eof): Call cpp_error_with_line
with 0 for column, not -1.
(_cpp_handle_eof): Don't set the control macro here. Don't
clear input_stack_listing_current here. Don't emit line
commands.
From-SVN: r33159
2000-04-15 07:29:45 +08:00
|
|
|
{
|
2001-03-14 07:55:10 +08:00
|
|
|
const char *fname = (const char *) header->val.str.text;
|
2001-03-02 15:35:12 +08:00
|
|
|
struct search_path *path;
|
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
2000-06-22 02:33:51 +08:00
|
|
|
struct include_file *file;
|
2001-03-15 03:35:08 +08:00
|
|
|
char *name, *n;
|
[multiple changes]
1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* c-lang.c: Declare extern char *yy_cur if USE_CPPLIB.
(lang_init): Call check_newline always.
* c-lex.c (init_parse) [USE_CPPLIB=1]: After calling
cpp_start_read, set yy_cur and yy_lim to read from
parse_in.token_buffer, so that we'll see the first #line
directive.
* cpplib.c (cpp_start_read): finclude the main input file
before processing -include/-imacros. Process -imacros and
-include separately, and handle -include by stacking a
buffer for the file in question as if it'd been #included.
* toplev.c (documented_lang_options) Recognize -H when
USE_CPPLIB is on.
1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.c: Merge do_once into do_pragma. Break file handling
code out of do_include.
Move append_include_chain, deps_output,
file_cleanup, redundant_include_p, import_hash,
lookup_import, add_import, read_filename_string, read_name_map,
open_include_file, finclude, safe_read to cppfiles.c.
Move prototypes for deps_output, append_include_chain,
finclude to cpplib.h. Move definition of struct
file_name_list there also.
* cppfiles.c: New file. Contains all the above functions
broken out of cpplib.c; also hack_vms_include_specification
from cccp.c and find_include_file, a new function broken out of
do_include.
* Makefile.in (cppmain): Depend on cppfiles.o.
(fix-header): Likewise.
(cppfiles.o): New target.
* configure.in (--enable-c-cpplib): Add cppfiles.o to
extra_c_objs. Add ../cppfiles.o to extra_cxx_objs.
From-SVN: r23424
1998-10-29 19:54:13 +08:00
|
|
|
|
2001-01-12 05:30:16 +08:00
|
|
|
if (IS_ABSOLUTE_PATHNAME (fname))
|
2000-09-22 02:01:22 +08:00
|
|
|
return open_file (pfile, fname);
|
2001-03-14 07:55:10 +08:00
|
|
|
|
|
|
|
/* For #include_next, skip in the search path past the dir in which
|
2001-03-15 03:35:08 +08:00
|
|
|
the current file was found, but if it was found via an absolute
|
|
|
|
path use the normal search logic. */
|
2001-03-15 15:57:13 +08:00
|
|
|
if (type == IT_INCLUDE_NEXT && pfile->buffer->inc->foundhere)
|
2001-03-14 07:55:10 +08:00
|
|
|
path = pfile->buffer->inc->foundhere->next;
|
|
|
|
else if (header->type == CPP_HEADER_NAME)
|
|
|
|
path = CPP_OPTION (pfile, bracket_include);
|
|
|
|
else
|
2001-03-15 15:57:13 +08:00
|
|
|
path = search_from (pfile, type);
|
2001-03-14 07:55:10 +08:00
|
|
|
|
|
|
|
if (path == NULL)
|
|
|
|
{
|
c-decl.c (duplicate_decls, [...]): Remove leading capital from diagnostics.
* c-decl.c (duplicate_decls, push_parm_decl): Remove leading
capital from diagnostics.
* c-lex.c (cb_file_change): Similarly.
* c-parse.in : Similarly.
* cfgrtl.c (verify_flow_info): Similarly.
* collect2.c: Similarly.
* cppfiles.c (find_include_file): Similarly.
* cppinit.c (cpp_handle_option): Similarly.
* cpplex.c (cpp_spell_token): Similarly.
* cppmain.c (do_preprocessing): Similarly.
* gcc.c (translate_options, process_command, do_spec1,
main, pfatal_execute): Similarly.
* genattr.c (main): Similarly.
* genattrtab.c (check_attr_test, operate_exp, simplify_test_exp,
write_test_expr, main): Similarly.
* gencodes.c (main): Similarly.
* genconfig.c (main): Similarly.
* genconstants.c (main): Similarly.
* genemit.c (main): Similarly.
* genextract.c (main): Similarly.
* genflags.c (main): Similarly.
* genopinit.c (main): Similarly.
* genoutput.c (process_template, main): Similarly.
* genpeep.c (main): Similarly.
* genrecog.c (main): Similarly.
* gensupport.c (is_predicable, identify_predicable_attribute,
alter_predicate_for_insn, init_md_reader_args, main): Similarly.
* ggc-page.c (alloc_anon): Similarly.
* mips-tfile.c (add_string, add_procedure, add_file, read_line,
parse_begin, parse_bend, parse_def, parse_end, parse_file,
parse_stabs_common, parse_stabs, write_varray, write_object,
read_seek, copy_object, main, error): Similarly.
* profile.c (compute_branch_probabilities): Similarly.
* reg-stack.c (check_asm_stack_operands): Similarly.
* reload.c (find_reloads): Similarly.
* reload1.c (spill_failure, failed_reload): Similarly.
* rtl-error.c (_fatal_insn_not_found): Similarly.
* toplev.c (read_integral_parameter, crash_signal,
decode_f_option, set_target_switch, parse_options_and_default_flags)
: Similarly.
* tradcif.y (parse_number, yylex): Similarly.
* tradcpp.c (main, fancy_abort): Similarly.
* tree.c (tree_check_failed): Similarly.
* varray.c (varray_check_failed): Similarly.
* xcoffout.c (xcoff_output_standard_types): Similarly.
cp:
* call.c (build_java_interface_fn_ref): Similarly.
* except.c (is_admissible_throw_operand): Similarly.
* init.c (build_java_class_ref): Similarly.
* xref.c (open_xref_file): Similarly.
objc:
* objc-act.c (get_object_ref, lookup_and_install_protocols,
build_objc_string_object, objc_declare_alias, build_ivar_chain,
finish_message_expr, build_protocol_expr, is_public,
start_class): Similarly.
testsuite:
* objc.dg/alias.m: Update.
* objc.dg/class-1.m: Update.
* objc.dg/const-str-1.m: Update.
* objc.dg/fwd-proto-1.m: Update.
* objc.dg/id-1.m: Update.
* objc.dg/super-class-1.m: Update.
From-SVN: r47518
2001-12-02 08:04:36 +08:00
|
|
|
cpp_error (pfile, "no include path in which to find %s", fname);
|
2001-03-14 07:55:10 +08:00
|
|
|
return NO_INCLUDE_PATH;
|
|
|
|
}
|
|
|
|
|
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
2000-06-22 02:33:51 +08:00
|
|
|
/* Search directory path for the file. */
|
2001-03-11 22:54:56 +08:00
|
|
|
name = (char *) alloca (strlen (fname) + pfile->max_include_len + 2);
|
2001-03-14 07:55:10 +08:00
|
|
|
for (; path; path = path->next)
|
[multiple changes]
1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* c-lang.c: Declare extern char *yy_cur if USE_CPPLIB.
(lang_init): Call check_newline always.
* c-lex.c (init_parse) [USE_CPPLIB=1]: After calling
cpp_start_read, set yy_cur and yy_lim to read from
parse_in.token_buffer, so that we'll see the first #line
directive.
* cpplib.c (cpp_start_read): finclude the main input file
before processing -include/-imacros. Process -imacros and
-include separately, and handle -include by stacking a
buffer for the file in question as if it'd been #included.
* toplev.c (documented_lang_options) Recognize -H when
USE_CPPLIB is on.
1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.c: Merge do_once into do_pragma. Break file handling
code out of do_include.
Move append_include_chain, deps_output,
file_cleanup, redundant_include_p, import_hash,
lookup_import, add_import, read_filename_string, read_name_map,
open_include_file, finclude, safe_read to cppfiles.c.
Move prototypes for deps_output, append_include_chain,
finclude to cpplib.h. Move definition of struct
file_name_list there also.
* cppfiles.c: New file. Contains all the above functions
broken out of cpplib.c; also hack_vms_include_specification
from cccp.c and find_include_file, a new function broken out of
do_include.
* Makefile.in (cppmain): Depend on cppfiles.o.
(fix-header): Likewise.
(cppfiles.o): New target.
* configure.in (--enable-c-cpplib): Add cppfiles.o to
extra_c_objs. Add ../cppfiles.o to extra_cxx_objs.
From-SVN: r23424
1998-10-29 19:54:13 +08:00
|
|
|
{
|
2001-03-02 15:35:12 +08:00
|
|
|
memcpy (name, path->name, path->len);
|
|
|
|
name[path->len] = '/';
|
|
|
|
strcpy (&name[path->len + 1], fname);
|
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
2000-06-22 02:33:51 +08:00
|
|
|
if (CPP_OPTION (pfile, remap))
|
2001-03-15 03:35:08 +08:00
|
|
|
n = remap_filename (pfile, name, path);
|
|
|
|
else
|
2001-03-15 15:57:13 +08:00
|
|
|
n = name;
|
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
2000-06-22 02:33:51 +08:00
|
|
|
|
2001-03-15 03:35:08 +08:00
|
|
|
file = open_file (pfile, n);
|
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
2000-06-22 02:33:51 +08:00
|
|
|
if (file)
|
[multiple changes]
1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* c-lang.c: Declare extern char *yy_cur if USE_CPPLIB.
(lang_init): Call check_newline always.
* c-lex.c (init_parse) [USE_CPPLIB=1]: After calling
cpp_start_read, set yy_cur and yy_lim to read from
parse_in.token_buffer, so that we'll see the first #line
directive.
* cpplib.c (cpp_start_read): finclude the main input file
before processing -include/-imacros. Process -imacros and
-include separately, and handle -include by stacking a
buffer for the file in question as if it'd been #included.
* toplev.c (documented_lang_options) Recognize -H when
USE_CPPLIB is on.
1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.c: Merge do_once into do_pragma. Break file handling
code out of do_include.
Move append_include_chain, deps_output,
file_cleanup, redundant_include_p, import_hash,
lookup_import, add_import, read_filename_string, read_name_map,
open_include_file, finclude, safe_read to cppfiles.c.
Move prototypes for deps_output, append_include_chain,
finclude to cpplib.h. Move definition of struct
file_name_list there also.
* cppfiles.c: New file. Contains all the above functions
broken out of cpplib.c; also hack_vms_include_specification
from cccp.c and find_include_file, a new function broken out of
do_include.
* Makefile.in (cppmain): Depend on cppfiles.o.
(fix-header): Likewise.
(cppfiles.o): New target.
* configure.in (--enable-c-cpplib): Add cppfiles.o to
extra_c_objs. Add ../cppfiles.o to extra_cxx_objs.
From-SVN: r23424
1998-10-29 19:54:13 +08:00
|
|
|
{
|
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
2000-06-22 02:33:51 +08:00
|
|
|
file->foundhere = path;
|
|
|
|
return file;
|
[multiple changes]
1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* c-lang.c: Declare extern char *yy_cur if USE_CPPLIB.
(lang_init): Call check_newline always.
* c-lex.c (init_parse) [USE_CPPLIB=1]: After calling
cpp_start_read, set yy_cur and yy_lim to read from
parse_in.token_buffer, so that we'll see the first #line
directive.
* cpplib.c (cpp_start_read): finclude the main input file
before processing -include/-imacros. Process -imacros and
-include separately, and handle -include by stacking a
buffer for the file in question as if it'd been #included.
* toplev.c (documented_lang_options) Recognize -H when
USE_CPPLIB is on.
1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.c: Merge do_once into do_pragma. Break file handling
code out of do_include.
Move append_include_chain, deps_output,
file_cleanup, redundant_include_p, import_hash,
lookup_import, add_import, read_filename_string, read_name_map,
open_include_file, finclude, safe_read to cppfiles.c.
Move prototypes for deps_output, append_include_chain,
finclude to cpplib.h. Move definition of struct
file_name_list there also.
* cppfiles.c: New file. Contains all the above functions
broken out of cpplib.c; also hack_vms_include_specification
from cccp.c and find_include_file, a new function broken out of
do_include.
* Makefile.in (cppmain): Depend on cppfiles.o.
(fix-header): Likewise.
(cppfiles.o): New target.
* configure.in (--enable-c-cpplib): Add cppfiles.o to
extra_c_objs. Add ../cppfiles.o to extra_cxx_objs.
From-SVN: r23424
1998-10-29 19:54:13 +08:00
|
|
|
}
|
|
|
|
}
|
2001-03-02 15:35:12 +08:00
|
|
|
|
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
2000-06-22 02:33:51 +08:00
|
|
|
return 0;
|
[multiple changes]
1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* c-lang.c: Declare extern char *yy_cur if USE_CPPLIB.
(lang_init): Call check_newline always.
* c-lex.c (init_parse) [USE_CPPLIB=1]: After calling
cpp_start_read, set yy_cur and yy_lim to read from
parse_in.token_buffer, so that we'll see the first #line
directive.
* cpplib.c (cpp_start_read): finclude the main input file
before processing -include/-imacros. Process -imacros and
-include separately, and handle -include by stacking a
buffer for the file in question as if it'd been #included.
* toplev.c (documented_lang_options) Recognize -H when
USE_CPPLIB is on.
1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.c: Merge do_once into do_pragma. Break file handling
code out of do_include.
Move append_include_chain, deps_output,
file_cleanup, redundant_include_p, import_hash,
lookup_import, add_import, read_filename_string, read_name_map,
open_include_file, finclude, safe_read to cppfiles.c.
Move prototypes for deps_output, append_include_chain,
finclude to cpplib.h. Move definition of struct
file_name_list there also.
* cppfiles.c: New file. Contains all the above functions
broken out of cpplib.c; also hack_vms_include_specification
from cccp.c and find_include_file, a new function broken out of
do_include.
* Makefile.in (cppmain): Depend on cppfiles.o.
(fix-header): Likewise.
(cppfiles.o): New target.
* configure.in (--enable-c-cpplib): Add cppfiles.o to
extra_c_objs. Add ../cppfiles.o to extra_cxx_objs.
From-SVN: r23424
1998-10-29 19:54:13 +08:00
|
|
|
}
|
|
|
|
|
2000-06-22 07:08:17 +08:00
|
|
|
/* Not everyone who wants to set system-header-ness on a buffer can
|
2000-12-08 07:17:56 +08:00
|
|
|
see the details of a buffer. This is an exported interface because
|
|
|
|
fix-header needs it. */
|
2000-06-22 07:08:17 +08:00
|
|
|
void
|
2000-12-04 15:32:04 +08:00
|
|
|
cpp_make_system_header (pfile, syshdr, externc)
|
2000-06-22 07:08:17 +08:00
|
|
|
cpp_reader *pfile;
|
2000-12-04 15:32:04 +08:00
|
|
|
int syshdr, externc;
|
2000-06-22 07:08:17 +08:00
|
|
|
{
|
2000-12-04 15:32:04 +08:00
|
|
|
int flags = 0;
|
|
|
|
|
|
|
|
/* 1 = system header, 2 = system header to be treated as C. */
|
|
|
|
if (syshdr)
|
|
|
|
flags = 1 + (externc != 0);
|
2001-08-11 15:33:39 +08:00
|
|
|
_cpp_do_file_change (pfile, LC_RENAME, pfile->map->to_file,
|
|
|
|
SOURCE_LINE (pfile->map, pfile->line), flags);
|
2000-06-22 07:08:17 +08:00
|
|
|
}
|
|
|
|
|
cpplex.c: Don't include sys/mman.h.
toplevel:
* cpplex.c: Don't include sys/mman.h.
(cpp_push_buffer, cpp_pop_buffer): Moved to cpplib.c.
* cpplib.c: Include sys/mman.h and obstack.h.
(cpp_push_buffer): Moved from cpplex.c; allocate buffers on an
obstack.
(cpp_pop_buffer): Moved from cpplex.c; free buffers from an obstack.
(_cpp_unwind_if_stack): Now static, unwind_if_stack. Don't
bother freeing if stack entries (they will be freed with their buffer).
(do_endif): Free if stack entries from the buffer obstack.
(push_conditional): Allocate if stack entries from the buffer obstack.
(find_answer): Rename to _cpp_find_answer.
(do_assert, do_unassert): Update.
* cpphash.h: Update prototypes.
(xobnew): New convenience macro.
* cpplib.h (struct cpp_reader): Add hash_ob and buffer_ob fields.
Update comments.
(struct cpp_hashnode): Remove disabled field.
* cppinit.c: Don't include hashtab.h or splay-tree.h.
(report_missing_guard): Moved to cppfiles.c.
(cpp_reader_init): Call cpp_init_stacks, cpp_init_macros,
cpp_init_includes.
(cpp_cleanup): Call cpp_cleanup_stacks, cpp_cleanup_macros,
cpp_cleanup_includes. Don't destroy hashtab or
all_include_files here.
(cpp_finish): Use _cpp_report_missing_guards.
* cppfiles.c (report_missing_guard): Moved from cppinit.c.
(_cpp_init_include_table): Rename _cpp_init_includes.
(_cpp_cleanup_includes, _cpp_report_missing_guards): New.
* cppexp.c (parse_assertion): Update for new name of
find_answer.
* Makefile.in (cpplib.o, cpphash.o, cppinit.o): Update deps.
* cpplib.c (do_ident): s/VSPACE/EOF/
testsuite:
* gcc.dg/cpp/ident.c: New test.
From-SVN: r34870
2000-07-05 13:33:57 +08:00
|
|
|
/* Report on all files that might benefit from a multiple include guard.
|
|
|
|
Triggered by -H. */
|
|
|
|
void
|
|
|
|
_cpp_report_missing_guards (pfile)
|
|
|
|
cpp_reader *pfile;
|
|
|
|
{
|
|
|
|
int banner = 0;
|
|
|
|
splay_tree_foreach (pfile->all_include_files, report_missing_guard,
|
|
|
|
(PTR) &banner);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
report_missing_guard (n, b)
|
|
|
|
splay_tree_node n;
|
|
|
|
void *b;
|
|
|
|
{
|
|
|
|
struct include_file *f = (struct include_file *) n->value;
|
|
|
|
int *bannerp = (int *)b;
|
|
|
|
|
|
|
|
if (f && f->cmacro == 0 && f->include_count == 1)
|
|
|
|
{
|
|
|
|
if (*bannerp == 0)
|
|
|
|
{
|
|
|
|
fputs (_("Multiple include guards may be useful for:\n"), stderr);
|
|
|
|
*bannerp = 1;
|
|
|
|
}
|
|
|
|
fputs (f->name, stderr);
|
|
|
|
putc ('\n', stderr);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-10-10 19:33:39 +08:00
|
|
|
/* Create a dependency, or issue an error message as appropriate. */
|
2001-03-13 03:33:08 +08:00
|
|
|
static void
|
|
|
|
handle_missing_header (pfile, fname, angle_brackets)
|
|
|
|
cpp_reader *pfile;
|
|
|
|
const char *fname;
|
|
|
|
int angle_brackets;
|
|
|
|
{
|
2001-08-22 07:05:12 +08:00
|
|
|
int print_dep = CPP_PRINT_DEPS(pfile) > (angle_brackets || pfile->map->sysp);
|
2001-04-06 13:21:36 +08:00
|
|
|
|
2001-03-13 03:33:08 +08:00
|
|
|
if (CPP_OPTION (pfile, print_deps_missing_files) && print_dep)
|
|
|
|
{
|
|
|
|
if (!angle_brackets || IS_ABSOLUTE_PATHNAME (fname))
|
|
|
|
deps_add_dep (pfile->deps, fname);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* If requested as a system header, assume it belongs in
|
|
|
|
the first system header directory. */
|
|
|
|
struct search_path *ptr = CPP_OPTION (pfile, bracket_include);
|
|
|
|
char *p;
|
|
|
|
int len = 0, fname_len = strlen (fname);
|
|
|
|
|
|
|
|
if (ptr)
|
|
|
|
len = ptr->len;
|
|
|
|
|
|
|
|
p = (char *) alloca (len + fname_len + 2);
|
|
|
|
if (len)
|
|
|
|
{
|
|
|
|
memcpy (p, ptr->name, len);
|
|
|
|
p[len++] = '/';
|
|
|
|
}
|
|
|
|
memcpy (p + len, fname, fname_len + 1);
|
|
|
|
deps_add_dep (pfile->deps, p);
|
|
|
|
}
|
|
|
|
}
|
2001-03-15 03:35:08 +08:00
|
|
|
/* If -M was specified, 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
|
ChangeLog.0, [...]: Fix spelling errors.
* ChangeLog.0, ChangeLog.2, ChangeLog.3, ChangeLog.4, ChangeLog,
FSFChangeLog.10, c-decl.c, cppfiles.c, cppinit.c, cpplex.c,
cpplib.c, cppmain.c, cse.c, df.c, diagnostic.c, dominance.c,
dwarf2out.c, dwarfout.c, emit-rtl.c, errors.c, except.c, except.h,
explow.c, function.c, gcse.c, genrecog.c, predict.c, regmove.c,
sched-rgn.c, ssa-ccp.c, stmt.c, toplev.c: Fix spelling errors.
From-SVN: r47279
2001-11-23 10:05:19 +08:00
|
|
|
file exists in. FIXME: Use a future cpp_diagnostic_with_errno ()
|
2001-03-15 03:35:08 +08:00
|
|
|
for both of these cases. */
|
2001-03-13 03:33:08 +08:00
|
|
|
else if (CPP_PRINT_DEPS (pfile) && ! print_dep)
|
2001-03-15 03:35:08 +08:00
|
|
|
cpp_warning (pfile, "%s: %s", fname, xstrerror (errno));
|
2001-03-13 03:33:08 +08:00
|
|
|
else
|
|
|
|
cpp_error_from_errno (pfile, fname);
|
|
|
|
}
|
|
|
|
|
2001-08-22 03:23:24 +08:00
|
|
|
/* Handles #include-family directives, and the command line -imacros
|
|
|
|
and -include. Returns true if a buffer was stacked. */
|
|
|
|
bool
|
2001-03-15 15:57:13 +08:00
|
|
|
_cpp_execute_include (pfile, header, type)
|
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
2000-03-14 14:34:11 +08:00
|
|
|
cpp_reader *pfile;
|
New macro expander.
2000-10-28 Neil Booth <neilb@earthling.net>
New macro expander.
* cpplib.c (struct answer): New.
(struct if_stack): Use cpp_lexer_pos rather than line and col.
Rename cmacro mi_cmacro.
(struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL,
IN_I): New directive and flags.
(skip_rest_of_line, check_eol, run_directive, glue_header_name,
parse_answer, parse_assertion, find_answer): New functions.
(parse_ifdef, detect_if_not_defined, validate_else): Remove.
(lex_macro_node): New function to replace parse_ifdef and
get_define_node.
(_cpp_handle_directive): New function, combines _cpp_check_directive
and _cpp_check_linemarker.
(do_define, do_undef, parse_include, do_include, do_import,
do_include_next, read_line_number, do_line, do_ident, do_pragma,
do_pragma_once, do_pragma_poison, do_pragma_dependency):
Update for new token getting interface.
(do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional)
: Update for new multiple-include optimisation technique.
(do_elif): Don't forget to invalidate controlling macros.
(unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update.
(parse_assertion, parse_answer, find_answer, _cpp_test_assertion):
Functions to handle assertions with the new token interface.
(do_assert, do_unassert): Use them.
(cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert):
Use run_directive.
(_cpp_init_stacks): Register directive names. Don't register special
nodes.
* cpperror.c (print_containing_files, _cpp_begin_message): Update to
new position recording regime.
(cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes.
(cpp_type2name): Move to cpplex.c.
* cppexp.c (parse_charconst): spec_nodes is no longer a pointer.
(parse_defined): Update to handle new multiple include optimisation
method. Remove poisoned identifier warning.
(parse_assertion, TYPE_NAME): Delete.
(lex): Update for multiple include optimisation, removal of
CPP_DEFINED, to use _cpp_test_assertion for assertions and
cpp_token_as_text.
(_cpp_parse_expr): Update for MI optimisation, and to use op_as_text.
(op_as_text): New function, to wrap cpp_token_as_text.
* cppfiles.c (stack_include_file, _cpp_pop_file_buffer):
Update for MI optimisation.
(_cpp_execute_include): Take a token rather than 3 arguments. Fix
segfault on diagnostic.
(_cpp_compare_file_date): Take a token rather than 3 args.
(cpp_read_file): Work correctly for zero-length files.
* cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename
_cpp_init_hashtable and _cpp_cleanup_hashtable.
(cpp_lookup): Place identifiers at front of identifier pool
for _cpp_lookup_with_hash.
(_cpp_lookup_with_hash): Require identifiers to be at the front of
the identifier pool. Commit the memory if not already in the
hash table.
* cppinit.c (cpp_reader_init): Move cpp_init_completed test to top.
Initialise various members of cpp_reader, memory pools, and the
special nodes.
(cpp_printer_init): Delete.
(cpp_cleanup): Update.
(struct builtin, builtin_array, initialize_builtins): Update for new
hashnode definition and builtin handling.
(cpp_start_read, cpp_finish): Don't take or initialise a
printer. Update.
* cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL,
PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE,
T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL,
T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete.
(struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos,
struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind,
NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos,
struct toklist, struct cpp_context, struct specnodes,
TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED,
NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION,
enum builtin_type, cpp_can_paste): New.
(struct cpp_token): Delete line and col members.
(struct cpp_buffer): New member output_lineno.
(struct lexer_state): Delete indented, in_lex_line, seen_dot.
Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args.
(struct cpp_reader): New members lexer_pos, macro_pos, directive_pos,
ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool,
base_context, context, directive, mi_state, mi_if_not_defined,
mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused,
mlstring_pos, macro_buffer, macro_buffer_len.
Delete members mls_line, mls_column, token_list, potential_control_macro,
temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token,
context_cap, cur_context, no_expand_level, paste_level, contexts, args,
save_parameter_spellings, need_newline, .
Change type of date, time and spec_nodes members.
Change prototypes for include and ident callbacks.
(struct cpp_hashnode): Change type of name. Remove union members
expansion and code. Add members macro, operator and builtin.
(cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read,
cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line,
cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead,
cpp_stop_lookahead): New prototypes.
(cpp_printer_init, cpp_dump_definition): Delete prototypes.
(U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs):
Move from cpphash.h.
* cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr,
ufputs): Move to cpplib.h.
(enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL,
TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION,
COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler,
struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens,
_cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist,
_cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space,
_cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive,
_cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name,
_cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker,
_cpp_parse_assertion, _cpp_find_answer): Delete.
(VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE,
POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool,
_cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk,
_cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion,
_cpp_handle_directive, DSC): New.
(struct include_file): New member defined.
(DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include,
_cpp_compare_file_date): Update.
(_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New.
(_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable,
_cpp_cleanup_hashtable.
* Makefile.in: Remove cppoutput.c.
* cppoutput.c: Delete
* fixheader.c (read_scan_file): Update for new cpp_get_token
prototype.
(recognized_function): New argument LINE.
* scan-decls.c (skip_to_closing_brace, scan_decls): Update for
new cpp_get_token prototype.
* scan.h (recognized_function): Update prototype.
* po/POTFILES.in: Remove cppoutput.c.
From-SVN: r37098
2000-10-29 01:59:06 +08:00
|
|
|
const cpp_token *header;
|
2001-03-15 15:57:13 +08:00
|
|
|
enum include_type type;
|
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
2000-03-14 14:34:11 +08:00
|
|
|
{
|
2001-08-22 03:23:24 +08:00
|
|
|
bool stacked = false;
|
2001-03-15 15:57:13 +08:00
|
|
|
struct include_file *inc = find_include_file (pfile, header, type);
|
2000-12-08 07:17:56 +08:00
|
|
|
|
2001-03-14 07:55:10 +08:00
|
|
|
if (inc == 0)
|
|
|
|
handle_missing_header (pfile, (const char *) header->val.str.text,
|
|
|
|
header->type == CPP_HEADER_NAME);
|
|
|
|
else if (inc != NO_INCLUDE_PATH)
|
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
2000-03-14 14:34:11 +08:00
|
|
|
{
|
2001-08-22 03:23:24 +08:00
|
|
|
stacked = stack_include_file (pfile, inc);
|
2001-02-20 03:50:21 +08:00
|
|
|
|
2001-03-15 15:57:13 +08:00
|
|
|
if (type == IT_IMPORT)
|
2001-03-15 03:35:08 +08:00
|
|
|
_cpp_never_reread (inc);
|
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
2000-03-14 14:34:11 +08:00
|
|
|
}
|
2001-03-15 15:57:13 +08:00
|
|
|
|
2001-08-22 03:23:24 +08:00
|
|
|
return stacked;
|
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
2000-03-14 14:34:11 +08:00
|
|
|
}
|
|
|
|
|
2001-03-14 07:55:10 +08:00
|
|
|
/* Locate HEADER, and determine whether it is newer than the current
|
|
|
|
file. If it cannot be located or dated, return -1, if it is newer
|
|
|
|
newer, return 1, otherwise 0. */
|
2000-06-30 17:47:49 +08:00
|
|
|
int
|
2001-03-14 07:55:10 +08:00
|
|
|
_cpp_compare_file_date (pfile, header)
|
2000-06-30 17:47:49 +08:00
|
|
|
cpp_reader *pfile;
|
2001-03-14 07:55:10 +08:00
|
|
|
const cpp_token *header;
|
2000-06-30 17:47:49 +08:00
|
|
|
{
|
2001-03-14 07:55:10 +08:00
|
|
|
struct include_file *inc = find_include_file (pfile, header, 0);
|
2000-06-30 17:47:49 +08:00
|
|
|
|
2001-03-14 07:55:10 +08:00
|
|
|
if (inc == NULL || inc == NO_INCLUDE_PATH)
|
2000-06-30 17:47:49 +08:00
|
|
|
return -1;
|
2001-03-14 07:55:10 +08:00
|
|
|
|
2000-09-12 11:42:30 +08:00
|
|
|
if (inc->fd > 0)
|
2000-06-30 17:47:49 +08:00
|
|
|
{
|
|
|
|
close (inc->fd);
|
|
|
|
inc->fd = -1;
|
|
|
|
}
|
2000-09-12 11:42:30 +08:00
|
|
|
|
2001-03-14 07:55:10 +08:00
|
|
|
return inc->st.st_mtime > pfile->buffer->inc->st.st_mtime;
|
2000-06-30 17:47:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-22 03:23:24 +08:00
|
|
|
/* Push an input buffer and load it up with the contents of FNAME. If
|
|
|
|
FNAME is "", read standard input. Return true if a buffer was
|
|
|
|
stacked. */
|
|
|
|
bool
|
2000-12-04 15:32:04 +08:00
|
|
|
_cpp_read_file (pfile, fname)
|
2000-03-03 04:14:32 +08:00
|
|
|
cpp_reader *pfile;
|
|
|
|
const char *fname;
|
|
|
|
{
|
2001-02-21 15:29:56 +08:00
|
|
|
struct include_file *f = open_file (pfile, fname);
|
2000-03-03 04:14:32 +08:00
|
|
|
|
top level:
2000-07-03 Zack Weinberg <zack@wolery.cumb.org>
* fix-header.c (struct partial_proto): Remove unnecessary fields.
(recognized_extern, recognized_function, read_scan_file):
Update for new scheme.
(check_protection): It's still a multiple include guard even
if it doesn't always trigger.
* scan-decls.c (skip_to_closing_brace, scan_decls): Update for
new scheme.
* scan.h: Declare struct cpp_token. Update prototypes.
2000-07-03 Neil Booth <neilb@earthling.net>
Zack Weinberg <zack@wolery.cumb.org>
Complete overhaul of the lexer and macro expander.
* cpphash.c (object_defn, funct_defn, push_macro_expansion,
arg, arglist, argdata, reflist, collect_objlike_expansion,
collect_funlike_expansion, collect_params,
warn_trad_stringify, trad_stringify, duplicate_arg_p, add_pat,
unsafe_chars, macarg, compare_defs, special_symbol,
scan_arguments, stringify, funlike_macroexpand,
_cpp_quote_string, monthnames): Delete.
(cpp_lookup, _cpp_free_definition, dump_funlike_macro,
_cpp_create_definition, _cpp_dump_definition,
dump_hash_helper): Adjust.
(find_param, count_params, parse_define, var_args_str,
check_macro_redefinition, save_expansion): New.
* cpplex.c (skip_block_comment, skip_line_comment, parse_name,
parse_string, output_line_command, trigraph_replace,
lex_line, cpp_push_buffer, cpp_pop_buffer, cpp_output_tokens,
cpp_scan_buffer_nooutput, cpp_scan_buffer, cpp_free_toklist,
cpp_idcmp, _cpp_get_directive_token, _cpp_init_input_buffer,
_cpp_skip_rest_of_line): Modify.
(maybe_macroexpand, skip_comment, copy_comment, skip_string,
find_position, null_warning, bump_column, expand_name_space,
pedantic_whitespace, _cpp_output_list, _cpp_slice_toklist,
_cpp_squeeze_toklist, _cpp_scan_until, _cpp_skip_hspace,
_cpp_parse_name, _cpp_lex_token, cpp_get_non_space_token,
_cpp_prescan): Delete.
(dump_param_spelling, process_directive, lex_next,
is_macro_disabled, stringify_arg, expand_context_stack,
output_token, make_string_token, alloc_number_token,
special_symbol, duplicate_token, maybe_paste_with_next,
can_paste, prevent_macro_expansion, restore_macro_expansion,
get_temp_token, release_temp_tokens, quote_string,
token_names, token_spellings, _cpp_expand_name_space,
_cpp_glue_header_name, _cpp_reserve_name_space,
digraph_spellings, trigraph_ok, skip_whitespace, save_comment,
placemarker_token, eof_token, cpp_context, macro_args,
get_raw_token, parse_arg, parse_args, save_token,
push_arg_context, push_macro_context, pop_context,
do_pop_context, free_macro_args, _cpp_get_line,
_cpp_run_directive): New.
* cpplib.c (validate_else, parse_include, push_conditional,
pass_thru_directive, read_line_number, parse_ifdef,
detect_if_not_defined, _cpp_check_directive, do_define,
do_undef, do_include, do_import, do_include_next, do_error,
do_warning, do_ident, do_pragma, pragma_dispatch, gcc_pragmas,
top_pragmas, do_pragma_gcc, do_pragma_implementation,
do_pragma_poison, do_pragma_system_header,
do_pragma_dependency, do_sccs, do_ifdef, do_ifndef, do_else,
dl_elif, do_endif, _cpp_unwind_if_stack, do_assert,
do_unassert, cpp_define, cpp_undef, cpp_assert, cpp_unassert,
cpp_defined): Update for new scheme.
(strtoul_for_line, get_define_node, dump_macro_name,
_cpp_check_linemarker, _cpp_parse_assertion): New.
(_cpp_handle_directive, do_pragma_default): Delete.
* cpphash.h (struct predicate): Now struct answer.
(enum spell_type, struct token_spelling, struct directive,
directive_handler): New.
Update prototypes. Remove unused macros.
* cpplib.h: Update prototypes. Remove unused macros,
structure definitions, and fields.
* cpperror.c (print_containing_files, v_message): Adjust.
* cppexp.c (parse_assertion, lex, parse_escape,
_cpp_parse_expr): Adjust.
* cppfiles.c (open_include_file, _cpp_execute_include,
_cpp_compare_file_date, cpp_read_file, read_include_file):
Adjust.
* cppinit.c (dump_special_to_buffer): Delete.
(append_include_chain, merge_include_chains, cpp_reader_init,
cpp_cleanup, initialize_builtins, builtin_array, cpp_start_read,
cpp_finish, handle_option, print_help): Adjust.
* cppmain.c (main): Adjust.
testsuite:
2000-07-03 Zack Weinberg <zack@wolery.cumb.org>
* testsuite/gcc.dg/cpp/19951025-1.c: Adjust regexps.
* testsuite/gcc.dg/cpp/19990703-1.c: Likewise.
* testsuite/gcc.dg/cpp/20000625-1.c: Likewise.
* testsuite/gcc.dg/cpp/20000625-2.c: Likewise.
* testsuite/gcc.dg/cpp/macro1.c,
testsuite/gcc.dg/cpp/paste1.c, testsuite/gcc.dg/cpp/paste2.c,
testsuite/gcc.dg/cpp/paste3.c, testsuite/gcc.dg/cpp/paste4.c,
testsuite/gcc.dg/cpp/strify1.c,
testsuite/gcc.dg/cpp/strify2.c: New tests.
From-SVN: r34859
2000-07-04 09:58:21 +08:00
|
|
|
if (f == NULL)
|
2001-10-09 01:54:15 +08:00
|
|
|
{
|
|
|
|
cpp_error_from_errno (pfile, fname);
|
|
|
|
return false;
|
|
|
|
}
|
top level:
2000-07-03 Zack Weinberg <zack@wolery.cumb.org>
* fix-header.c (struct partial_proto): Remove unnecessary fields.
(recognized_extern, recognized_function, read_scan_file):
Update for new scheme.
(check_protection): It's still a multiple include guard even
if it doesn't always trigger.
* scan-decls.c (skip_to_closing_brace, scan_decls): Update for
new scheme.
* scan.h: Declare struct cpp_token. Update prototypes.
2000-07-03 Neil Booth <neilb@earthling.net>
Zack Weinberg <zack@wolery.cumb.org>
Complete overhaul of the lexer and macro expander.
* cpphash.c (object_defn, funct_defn, push_macro_expansion,
arg, arglist, argdata, reflist, collect_objlike_expansion,
collect_funlike_expansion, collect_params,
warn_trad_stringify, trad_stringify, duplicate_arg_p, add_pat,
unsafe_chars, macarg, compare_defs, special_symbol,
scan_arguments, stringify, funlike_macroexpand,
_cpp_quote_string, monthnames): Delete.
(cpp_lookup, _cpp_free_definition, dump_funlike_macro,
_cpp_create_definition, _cpp_dump_definition,
dump_hash_helper): Adjust.
(find_param, count_params, parse_define, var_args_str,
check_macro_redefinition, save_expansion): New.
* cpplex.c (skip_block_comment, skip_line_comment, parse_name,
parse_string, output_line_command, trigraph_replace,
lex_line, cpp_push_buffer, cpp_pop_buffer, cpp_output_tokens,
cpp_scan_buffer_nooutput, cpp_scan_buffer, cpp_free_toklist,
cpp_idcmp, _cpp_get_directive_token, _cpp_init_input_buffer,
_cpp_skip_rest_of_line): Modify.
(maybe_macroexpand, skip_comment, copy_comment, skip_string,
find_position, null_warning, bump_column, expand_name_space,
pedantic_whitespace, _cpp_output_list, _cpp_slice_toklist,
_cpp_squeeze_toklist, _cpp_scan_until, _cpp_skip_hspace,
_cpp_parse_name, _cpp_lex_token, cpp_get_non_space_token,
_cpp_prescan): Delete.
(dump_param_spelling, process_directive, lex_next,
is_macro_disabled, stringify_arg, expand_context_stack,
output_token, make_string_token, alloc_number_token,
special_symbol, duplicate_token, maybe_paste_with_next,
can_paste, prevent_macro_expansion, restore_macro_expansion,
get_temp_token, release_temp_tokens, quote_string,
token_names, token_spellings, _cpp_expand_name_space,
_cpp_glue_header_name, _cpp_reserve_name_space,
digraph_spellings, trigraph_ok, skip_whitespace, save_comment,
placemarker_token, eof_token, cpp_context, macro_args,
get_raw_token, parse_arg, parse_args, save_token,
push_arg_context, push_macro_context, pop_context,
do_pop_context, free_macro_args, _cpp_get_line,
_cpp_run_directive): New.
* cpplib.c (validate_else, parse_include, push_conditional,
pass_thru_directive, read_line_number, parse_ifdef,
detect_if_not_defined, _cpp_check_directive, do_define,
do_undef, do_include, do_import, do_include_next, do_error,
do_warning, do_ident, do_pragma, pragma_dispatch, gcc_pragmas,
top_pragmas, do_pragma_gcc, do_pragma_implementation,
do_pragma_poison, do_pragma_system_header,
do_pragma_dependency, do_sccs, do_ifdef, do_ifndef, do_else,
dl_elif, do_endif, _cpp_unwind_if_stack, do_assert,
do_unassert, cpp_define, cpp_undef, cpp_assert, cpp_unassert,
cpp_defined): Update for new scheme.
(strtoul_for_line, get_define_node, dump_macro_name,
_cpp_check_linemarker, _cpp_parse_assertion): New.
(_cpp_handle_directive, do_pragma_default): Delete.
* cpphash.h (struct predicate): Now struct answer.
(enum spell_type, struct token_spelling, struct directive,
directive_handler): New.
Update prototypes. Remove unused macros.
* cpplib.h: Update prototypes. Remove unused macros,
structure definitions, and fields.
* cpperror.c (print_containing_files, v_message): Adjust.
* cppexp.c (parse_assertion, lex, parse_escape,
_cpp_parse_expr): Adjust.
* cppfiles.c (open_include_file, _cpp_execute_include,
_cpp_compare_file_date, cpp_read_file, read_include_file):
Adjust.
* cppinit.c (dump_special_to_buffer): Delete.
(append_include_chain, merge_include_chains, cpp_reader_init,
cpp_cleanup, initialize_builtins, builtin_array, cpp_start_read,
cpp_finish, handle_option, print_help): Adjust.
* cppmain.c (main): Adjust.
testsuite:
2000-07-03 Zack Weinberg <zack@wolery.cumb.org>
* testsuite/gcc.dg/cpp/19951025-1.c: Adjust regexps.
* testsuite/gcc.dg/cpp/19990703-1.c: Likewise.
* testsuite/gcc.dg/cpp/20000625-1.c: Likewise.
* testsuite/gcc.dg/cpp/20000625-2.c: Likewise.
* testsuite/gcc.dg/cpp/macro1.c,
testsuite/gcc.dg/cpp/paste1.c, testsuite/gcc.dg/cpp/paste2.c,
testsuite/gcc.dg/cpp/paste3.c, testsuite/gcc.dg/cpp/paste4.c,
testsuite/gcc.dg/cpp/strify1.c,
testsuite/gcc.dg/cpp/strify2.c: New tests.
From-SVN: r34859
2000-07-04 09:58:21 +08:00
|
|
|
|
2001-10-09 01:54:15 +08:00
|
|
|
return stack_include_file (pfile, f);
|
cppfiles.c: Read files in, using mmap if possible, then prescan them separately.
* cppfiles.c: Read files in, using mmap if possible, then
prescan them separately.
(read_file, read_with_read): New functions.
* cpplex.c: Don't define UCHAR_MAX.
(_cpp_read_and_prescan): Rename to _cpp_prescan. Don't read
the file here.
* cppinit.c (handle_option): Automatically define __cplusplus,
__OBJC__, __ASEEMBLER__, _LANGUAGE_FORTRAN here when we see
the respective -lang switch.
* cpphash.h (enum node_type, struct hashnode, _cpp_lookup
prototype): Move to...
* cpplib.h: ... here. Rename struct hashnode to struct
cpp_hashnode and give it a typedef. Rename _cpp_lookup to
cpp_lookup. Add 'fe_value' slot, a union tree_node *.
From-SVN: r34228
2000-05-28 13:56:38 +08:00
|
|
|
}
|
|
|
|
|
cppexp.c, [...]: Eradicate all traces of code dependent on traditional, lang_chill, or lang_fortran.
* cppexp.c, cpphash.c, cpphash.h, cppinit.c, cpplex.c,
cpplib.c, cpplib.h: Eradicate all traces of code dependent on
traditional, lang_chill, or lang_fortran.
* cppfiles.c: #undef strcmp to suppress warning about macros
used without arguments.
(_cpp_execute_include): Use f, not fname, in "No include path"
error.
(_cpp_pop_file_buffer): New function.
* cpplib.c: Don't include <sys/mman.h>.
(cpp_push_buffer): Set line_base and lineno in new buffer.
(cpp_pop_buffer): Use _cpp_pop_file_buffer.
* cpplex.c: Move all prototypes and structure declarations to the
top of the file. Properly parenthesise some macro arguments.
(cpp_scan_line): New function.
(special_symbol [case T_INCLUDE_DEPTH]): Use pfile->include_depth,
don't need to walk up the stack counting.
From-SVN: r35003
2000-07-13 10:32:41 +08:00
|
|
|
/* Do appropriate cleanup when a file buffer is popped off the input
|
cpperror.c (print_location): Don't show _Pragma.
* cpperror.c (print_location): Don't show _Pragma.
* cppfiles.c (_cpp_pop_file_buffer): Handle -include file pushing
and file change callback generation here.
(stack_include_file): Update use of cpp_push_buffer.
* cpphash.h (_cpp_pop_file_buffer): Update prototype.
(struct cpp_buffer): Remove type, pfile members.
* cppinit.c (cpp_handle_option): Use free_chain.
* cpplex.c (_cpp_lex_token): Don't do -include file pushing here.
(skip_escaped_newlines, get_effective_char, lex_percent): Take
a cpp_reader rather than a cpp_buffer.
(skip_escaped_newlines, get_effective_char, skip_block_comment,
skip_line_comment, parse_string, lex_percent, lex_dot,
_cpp_lex_token): Update accordingly.
* cpplib.c (_cpp_pop_buffer): Don't do file change callback
generation here.
(cpp_push_buffer): Update prototype.
(run_directive): Update use of cpp_push_buffer.
(_cpp_do__Pragma, cpp_define, cpp_define_builtin, cpp_undef,
handle_assertion): Update use of run_directive.
* cpplib.h (enum cpp_buffer_type): Remove.
(cpp_push_buffer): Update prototype.
* fix-header.c (read_scan_file): Update.
From-SVN: r45112
2001-08-23 04:37:20 +08:00
|
|
|
stack. Push the next -include file, if any remain. */
|
cppexp.c, [...]: Eradicate all traces of code dependent on traditional, lang_chill, or lang_fortran.
* cppexp.c, cpphash.c, cpphash.h, cppinit.c, cpplex.c,
cpplib.c, cpplib.h: Eradicate all traces of code dependent on
traditional, lang_chill, or lang_fortran.
* cppfiles.c: #undef strcmp to suppress warning about macros
used without arguments.
(_cpp_execute_include): Use f, not fname, in "No include path"
error.
(_cpp_pop_file_buffer): New function.
* cpplib.c: Don't include <sys/mman.h>.
(cpp_push_buffer): Set line_base and lineno in new buffer.
(cpp_pop_buffer): Use _cpp_pop_file_buffer.
* cpplex.c: Move all prototypes and structure declarations to the
top of the file. Properly parenthesise some macro arguments.
(cpp_scan_line): New function.
(special_symbol [case T_INCLUDE_DEPTH]): Use pfile->include_depth,
don't need to walk up the stack counting.
From-SVN: r35003
2000-07-13 10:32:41 +08:00
|
|
|
void
|
cpperror.c (print_location): Don't show _Pragma.
* cpperror.c (print_location): Don't show _Pragma.
* cppfiles.c (_cpp_pop_file_buffer): Handle -include file pushing
and file change callback generation here.
(stack_include_file): Update use of cpp_push_buffer.
* cpphash.h (_cpp_pop_file_buffer): Update prototype.
(struct cpp_buffer): Remove type, pfile members.
* cppinit.c (cpp_handle_option): Use free_chain.
* cpplex.c (_cpp_lex_token): Don't do -include file pushing here.
(skip_escaped_newlines, get_effective_char, lex_percent): Take
a cpp_reader rather than a cpp_buffer.
(skip_escaped_newlines, get_effective_char, skip_block_comment,
skip_line_comment, parse_string, lex_percent, lex_dot,
_cpp_lex_token): Update accordingly.
* cpplib.c (_cpp_pop_buffer): Don't do file change callback
generation here.
(cpp_push_buffer): Update prototype.
(run_directive): Update use of cpp_push_buffer.
(_cpp_do__Pragma, cpp_define, cpp_define_builtin, cpp_undef,
handle_assertion): Update use of run_directive.
* cpplib.h (enum cpp_buffer_type): Remove.
(cpp_push_buffer): Update prototype.
* fix-header.c (read_scan_file): Update.
From-SVN: r45112
2001-08-23 04:37:20 +08:00
|
|
|
_cpp_pop_file_buffer (pfile, inc)
|
cppexp.c, [...]: Eradicate all traces of code dependent on traditional, lang_chill, or lang_fortran.
* cppexp.c, cpphash.c, cpphash.h, cppinit.c, cpplex.c,
cpplib.c, cpplib.h: Eradicate all traces of code dependent on
traditional, lang_chill, or lang_fortran.
* cppfiles.c: #undef strcmp to suppress warning about macros
used without arguments.
(_cpp_execute_include): Use f, not fname, in "No include path"
error.
(_cpp_pop_file_buffer): New function.
* cpplib.c: Don't include <sys/mman.h>.
(cpp_push_buffer): Set line_base and lineno in new buffer.
(cpp_pop_buffer): Use _cpp_pop_file_buffer.
* cpplex.c: Move all prototypes and structure declarations to the
top of the file. Properly parenthesise some macro arguments.
(cpp_scan_line): New function.
(special_symbol [case T_INCLUDE_DEPTH]): Use pfile->include_depth,
don't need to walk up the stack counting.
From-SVN: r35003
2000-07-13 10:32:41 +08:00
|
|
|
cpp_reader *pfile;
|
cpperror.c (print_location): Don't show _Pragma.
* cpperror.c (print_location): Don't show _Pragma.
* cppfiles.c (_cpp_pop_file_buffer): Handle -include file pushing
and file change callback generation here.
(stack_include_file): Update use of cpp_push_buffer.
* cpphash.h (_cpp_pop_file_buffer): Update prototype.
(struct cpp_buffer): Remove type, pfile members.
* cppinit.c (cpp_handle_option): Use free_chain.
* cpplex.c (_cpp_lex_token): Don't do -include file pushing here.
(skip_escaped_newlines, get_effective_char, lex_percent): Take
a cpp_reader rather than a cpp_buffer.
(skip_escaped_newlines, get_effective_char, skip_block_comment,
skip_line_comment, parse_string, lex_percent, lex_dot,
_cpp_lex_token): Update accordingly.
* cpplib.c (_cpp_pop_buffer): Don't do file change callback
generation here.
(cpp_push_buffer): Update prototype.
(run_directive): Update use of cpp_push_buffer.
(_cpp_do__Pragma, cpp_define, cpp_define_builtin, cpp_undef,
handle_assertion): Update use of run_directive.
* cpplib.h (enum cpp_buffer_type): Remove.
(cpp_push_buffer): Update prototype.
* fix-header.c (read_scan_file): Update.
From-SVN: r45112
2001-08-23 04:37:20 +08:00
|
|
|
struct include_file *inc;
|
cppexp.c, [...]: Eradicate all traces of code dependent on traditional, lang_chill, or lang_fortran.
* cppexp.c, cpphash.c, cpphash.h, cppinit.c, cpplex.c,
cpplib.c, cpplib.h: Eradicate all traces of code dependent on
traditional, lang_chill, or lang_fortran.
* cppfiles.c: #undef strcmp to suppress warning about macros
used without arguments.
(_cpp_execute_include): Use f, not fname, in "No include path"
error.
(_cpp_pop_file_buffer): New function.
* cpplib.c: Don't include <sys/mman.h>.
(cpp_push_buffer): Set line_base and lineno in new buffer.
(cpp_pop_buffer): Use _cpp_pop_file_buffer.
* cpplex.c: Move all prototypes and structure declarations to the
top of the file. Properly parenthesise some macro arguments.
(cpp_scan_line): New function.
(special_symbol [case T_INCLUDE_DEPTH]): Use pfile->include_depth,
don't need to walk up the stack counting.
From-SVN: r35003
2000-07-13 10:32:41 +08:00
|
|
|
{
|
2001-03-15 15:57:13 +08:00
|
|
|
/* Record the inclusion-preventing macro, which could be NULL
|
2001-07-30 01:27:57 +08:00
|
|
|
meaning no controlling macro. */
|
|
|
|
if (pfile->mi_valid && inc->cmacro == NULL)
|
2001-03-15 15:57:13 +08:00
|
|
|
inc->cmacro = pfile->mi_cmacro;
|
New macro expander.
2000-10-28 Neil Booth <neilb@earthling.net>
New macro expander.
* cpplib.c (struct answer): New.
(struct if_stack): Use cpp_lexer_pos rather than line and col.
Rename cmacro mi_cmacro.
(struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL,
IN_I): New directive and flags.
(skip_rest_of_line, check_eol, run_directive, glue_header_name,
parse_answer, parse_assertion, find_answer): New functions.
(parse_ifdef, detect_if_not_defined, validate_else): Remove.
(lex_macro_node): New function to replace parse_ifdef and
get_define_node.
(_cpp_handle_directive): New function, combines _cpp_check_directive
and _cpp_check_linemarker.
(do_define, do_undef, parse_include, do_include, do_import,
do_include_next, read_line_number, do_line, do_ident, do_pragma,
do_pragma_once, do_pragma_poison, do_pragma_dependency):
Update for new token getting interface.
(do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional)
: Update for new multiple-include optimisation technique.
(do_elif): Don't forget to invalidate controlling macros.
(unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update.
(parse_assertion, parse_answer, find_answer, _cpp_test_assertion):
Functions to handle assertions with the new token interface.
(do_assert, do_unassert): Use them.
(cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert):
Use run_directive.
(_cpp_init_stacks): Register directive names. Don't register special
nodes.
* cpperror.c (print_containing_files, _cpp_begin_message): Update to
new position recording regime.
(cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes.
(cpp_type2name): Move to cpplex.c.
* cppexp.c (parse_charconst): spec_nodes is no longer a pointer.
(parse_defined): Update to handle new multiple include optimisation
method. Remove poisoned identifier warning.
(parse_assertion, TYPE_NAME): Delete.
(lex): Update for multiple include optimisation, removal of
CPP_DEFINED, to use _cpp_test_assertion for assertions and
cpp_token_as_text.
(_cpp_parse_expr): Update for MI optimisation, and to use op_as_text.
(op_as_text): New function, to wrap cpp_token_as_text.
* cppfiles.c (stack_include_file, _cpp_pop_file_buffer):
Update for MI optimisation.
(_cpp_execute_include): Take a token rather than 3 arguments. Fix
segfault on diagnostic.
(_cpp_compare_file_date): Take a token rather than 3 args.
(cpp_read_file): Work correctly for zero-length files.
* cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename
_cpp_init_hashtable and _cpp_cleanup_hashtable.
(cpp_lookup): Place identifiers at front of identifier pool
for _cpp_lookup_with_hash.
(_cpp_lookup_with_hash): Require identifiers to be at the front of
the identifier pool. Commit the memory if not already in the
hash table.
* cppinit.c (cpp_reader_init): Move cpp_init_completed test to top.
Initialise various members of cpp_reader, memory pools, and the
special nodes.
(cpp_printer_init): Delete.
(cpp_cleanup): Update.
(struct builtin, builtin_array, initialize_builtins): Update for new
hashnode definition and builtin handling.
(cpp_start_read, cpp_finish): Don't take or initialise a
printer. Update.
* cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL,
PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE,
T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL,
T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete.
(struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos,
struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind,
NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos,
struct toklist, struct cpp_context, struct specnodes,
TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED,
NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION,
enum builtin_type, cpp_can_paste): New.
(struct cpp_token): Delete line and col members.
(struct cpp_buffer): New member output_lineno.
(struct lexer_state): Delete indented, in_lex_line, seen_dot.
Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args.
(struct cpp_reader): New members lexer_pos, macro_pos, directive_pos,
ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool,
base_context, context, directive, mi_state, mi_if_not_defined,
mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused,
mlstring_pos, macro_buffer, macro_buffer_len.
Delete members mls_line, mls_column, token_list, potential_control_macro,
temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token,
context_cap, cur_context, no_expand_level, paste_level, contexts, args,
save_parameter_spellings, need_newline, .
Change type of date, time and spec_nodes members.
Change prototypes for include and ident callbacks.
(struct cpp_hashnode): Change type of name. Remove union members
expansion and code. Add members macro, operator and builtin.
(cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read,
cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line,
cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead,
cpp_stop_lookahead): New prototypes.
(cpp_printer_init, cpp_dump_definition): Delete prototypes.
(U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs):
Move from cpphash.h.
* cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr,
ufputs): Move to cpplib.h.
(enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL,
TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION,
COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler,
struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens,
_cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist,
_cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space,
_cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive,
_cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name,
_cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker,
_cpp_parse_assertion, _cpp_find_answer): Delete.
(VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE,
POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool,
_cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk,
_cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion,
_cpp_handle_directive, DSC): New.
(struct include_file): New member defined.
(DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include,
_cpp_compare_file_date): Update.
(_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New.
(_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable,
_cpp_cleanup_hashtable.
* Makefile.in: Remove cppoutput.c.
* cppoutput.c: Delete
* fixheader.c (read_scan_file): Update for new cpp_get_token
prototype.
(recognized_function): New argument LINE.
* scan-decls.c (skip_to_closing_brace, scan_decls): Update for
new cpp_get_token prototype.
* scan.h (recognized_function): Update prototype.
* po/POTFILES.in: Remove cppoutput.c.
From-SVN: r37098
2000-10-29 01:59:06 +08:00
|
|
|
|
|
|
|
/* Invalidate control macros in the #including file. */
|
2001-07-30 01:27:57 +08:00
|
|
|
pfile->mi_valid = false;
|
cppexp.c, [...]: Eradicate all traces of code dependent on traditional, lang_chill, or lang_fortran.
* cppexp.c, cpphash.c, cpphash.h, cppinit.c, cpplex.c,
cpplib.c, cpplib.h: Eradicate all traces of code dependent on
traditional, lang_chill, or lang_fortran.
* cppfiles.c: #undef strcmp to suppress warning about macros
used without arguments.
(_cpp_execute_include): Use f, not fname, in "No include path"
error.
(_cpp_pop_file_buffer): New function.
* cpplib.c: Don't include <sys/mman.h>.
(cpp_push_buffer): Set line_base and lineno in new buffer.
(cpp_pop_buffer): Use _cpp_pop_file_buffer.
* cpplex.c: Move all prototypes and structure declarations to the
top of the file. Properly parenthesise some macro arguments.
(cpp_scan_line): New function.
(special_symbol [case T_INCLUDE_DEPTH]): Use pfile->include_depth,
don't need to walk up the stack counting.
From-SVN: r35003
2000-07-13 10:32:41 +08:00
|
|
|
|
2000-09-12 11:42:30 +08:00
|
|
|
inc->refcnt--;
|
|
|
|
if (inc->refcnt == 0 && DO_NOT_REREAD (inc))
|
|
|
|
purge_cache (inc);
|
cpperror.c (print_location): Don't show _Pragma.
* cpperror.c (print_location): Don't show _Pragma.
* cppfiles.c (_cpp_pop_file_buffer): Handle -include file pushing
and file change callback generation here.
(stack_include_file): Update use of cpp_push_buffer.
* cpphash.h (_cpp_pop_file_buffer): Update prototype.
(struct cpp_buffer): Remove type, pfile members.
* cppinit.c (cpp_handle_option): Use free_chain.
* cpplex.c (_cpp_lex_token): Don't do -include file pushing here.
(skip_escaped_newlines, get_effective_char, lex_percent): Take
a cpp_reader rather than a cpp_buffer.
(skip_escaped_newlines, get_effective_char, skip_block_comment,
skip_line_comment, parse_string, lex_percent, lex_dot,
_cpp_lex_token): Update accordingly.
* cpplib.c (_cpp_pop_buffer): Don't do file change callback
generation here.
(cpp_push_buffer): Update prototype.
(run_directive): Update use of cpp_push_buffer.
(_cpp_do__Pragma, cpp_define, cpp_define_builtin, cpp_undef,
handle_assertion): Update use of run_directive.
* cpplib.h (enum cpp_buffer_type): Remove.
(cpp_push_buffer): Update prototype.
* fix-header.c (read_scan_file): Update.
From-SVN: r45112
2001-08-23 04:37:20 +08:00
|
|
|
|
|
|
|
/* Don't generate a callback for popping the main file. */
|
|
|
|
if (pfile->buffer)
|
|
|
|
{
|
|
|
|
_cpp_do_file_change (pfile, LC_LEAVE, 0, 0, 0);
|
|
|
|
|
|
|
|
/* Finally, push the next -included file, if any. */
|
|
|
|
if (!pfile->buffer->prev)
|
|
|
|
_cpp_push_next_buffer (pfile);
|
|
|
|
}
|
cppexp.c, [...]: Eradicate all traces of code dependent on traditional, lang_chill, or lang_fortran.
* cppexp.c, cpphash.c, cpphash.h, cppinit.c, cpplex.c,
cpplib.c, cpplib.h: Eradicate all traces of code dependent on
traditional, lang_chill, or lang_fortran.
* cppfiles.c: #undef strcmp to suppress warning about macros
used without arguments.
(_cpp_execute_include): Use f, not fname, in "No include path"
error.
(_cpp_pop_file_buffer): New function.
* cpplib.c: Don't include <sys/mman.h>.
(cpp_push_buffer): Set line_base and lineno in new buffer.
(cpp_pop_buffer): Use _cpp_pop_file_buffer.
* cpplex.c: Move all prototypes and structure declarations to the
top of the file. Properly parenthesise some macro arguments.
(cpp_scan_line): New function.
(special_symbol [case T_INCLUDE_DEPTH]): Use pfile->include_depth,
don't need to walk up the stack counting.
From-SVN: r35003
2000-07-13 10:32:41 +08:00
|
|
|
}
|
|
|
|
|
2001-03-02 15:35:12 +08:00
|
|
|
/* Returns the first place in the include chain to start searching for
|
|
|
|
"" includes. This involves stripping away the basename of the
|
2001-03-15 15:57:13 +08:00
|
|
|
current file, unless -I- was specified.
|
|
|
|
|
|
|
|
If we're handling -include or -imacros, use the "" chain, but with
|
|
|
|
the preprocessor's cwd prepended. */
|
2001-03-02 15:35:12 +08:00
|
|
|
static struct search_path *
|
2001-03-15 15:57:13 +08:00
|
|
|
search_from (pfile, type)
|
2001-03-02 15:35:12 +08:00
|
|
|
cpp_reader *pfile;
|
2001-03-15 15:57:13 +08:00
|
|
|
enum include_type type;
|
2001-03-02 15:35:12 +08:00
|
|
|
{
|
|
|
|
cpp_buffer *buffer = pfile->buffer;
|
|
|
|
unsigned int dlen;
|
|
|
|
|
2001-03-15 15:57:13 +08:00
|
|
|
/* Command line uses the cwd, and does not cache the result. */
|
|
|
|
if (type == IT_CMDLINE)
|
|
|
|
goto use_cwd;
|
|
|
|
|
2001-03-02 15:35:12 +08:00
|
|
|
/* Ignore the current file's directory if -I- was given. */
|
|
|
|
if (CPP_OPTION (pfile, ignore_srcdir))
|
|
|
|
return CPP_OPTION (pfile, quote_include);
|
|
|
|
|
2001-03-15 15:57:13 +08:00
|
|
|
if (! buffer->search_cached)
|
2001-03-02 15:35:12 +08:00
|
|
|
{
|
2001-03-15 15:57:13 +08:00
|
|
|
buffer->search_cached = 1;
|
2001-03-02 15:35:12 +08:00
|
|
|
|
2001-03-15 15:57:13 +08:00
|
|
|
dlen = lbasename (buffer->inc->name) - buffer->inc->name;
|
2001-03-02 15:35:12 +08:00
|
|
|
|
2001-03-15 15:57:13 +08:00
|
|
|
if (dlen)
|
|
|
|
{
|
|
|
|
/* We don't guarantee NAME is null-terminated. This saves
|
cpperror.c (print_location): Don't show _Pragma.
* cpperror.c (print_location): Don't show _Pragma.
* cppfiles.c (_cpp_pop_file_buffer): Handle -include file pushing
and file change callback generation here.
(stack_include_file): Update use of cpp_push_buffer.
* cpphash.h (_cpp_pop_file_buffer): Update prototype.
(struct cpp_buffer): Remove type, pfile members.
* cppinit.c (cpp_handle_option): Use free_chain.
* cpplex.c (_cpp_lex_token): Don't do -include file pushing here.
(skip_escaped_newlines, get_effective_char, lex_percent): Take
a cpp_reader rather than a cpp_buffer.
(skip_escaped_newlines, get_effective_char, skip_block_comment,
skip_line_comment, parse_string, lex_percent, lex_dot,
_cpp_lex_token): Update accordingly.
* cpplib.c (_cpp_pop_buffer): Don't do file change callback
generation here.
(cpp_push_buffer): Update prototype.
(run_directive): Update use of cpp_push_buffer.
(_cpp_do__Pragma, cpp_define, cpp_define_builtin, cpp_undef,
handle_assertion): Update use of run_directive.
* cpplib.h (enum cpp_buffer_type): Remove.
(cpp_push_buffer): Update prototype.
* fix-header.c (read_scan_file): Update.
From-SVN: r45112
2001-08-23 04:37:20 +08:00
|
|
|
allocating and freeing memory. Drop a trailing '/'. */
|
2001-03-15 15:57:13 +08:00
|
|
|
buffer->dir.name = buffer->inc->name;
|
|
|
|
if (dlen > 1)
|
|
|
|
dlen--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
use_cwd:
|
|
|
|
buffer->dir.name = ".";
|
|
|
|
dlen = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dlen > pfile->max_include_len)
|
|
|
|
pfile->max_include_len = dlen;
|
|
|
|
|
|
|
|
buffer->dir.len = dlen;
|
|
|
|
buffer->dir.next = CPP_OPTION (pfile, quote_include);
|
2001-08-11 15:33:39 +08:00
|
|
|
buffer->dir.sysp = pfile->map->sysp;
|
2001-03-15 15:57:13 +08:00
|
|
|
}
|
2001-03-02 15:35:12 +08:00
|
|
|
|
|
|
|
return &buffer->dir;
|
|
|
|
}
|
|
|
|
|
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
2000-06-22 02:33:51 +08:00
|
|
|
/* The file_name_map structure holds a mapping of file names for a
|
|
|
|
particular directory. This mapping is read from the file named
|
|
|
|
FILE_NAME_MAP_FILE in that directory. Such a file can be used to
|
|
|
|
map filenames on a file system with severe filename restrictions,
|
|
|
|
such as DOS. The format of the file name map file is just a series
|
|
|
|
of lines with two tokens on each line. The first token is the name
|
|
|
|
to map, and the second token is the actual name to use. */
|
|
|
|
|
|
|
|
struct file_name_map
|
|
|
|
{
|
|
|
|
struct file_name_map *map_next;
|
|
|
|
char *map_from;
|
|
|
|
char *map_to;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define FILE_NAME_MAP_FILE "header.gcc"
|
|
|
|
|
|
|
|
/* Read a space delimited string of unlimited length from a stdio
|
|
|
|
file. */
|
|
|
|
|
|
|
|
static char *
|
|
|
|
read_filename_string (ch, f)
|
|
|
|
int ch;
|
|
|
|
FILE *f;
|
|
|
|
{
|
|
|
|
char *alloc, *set;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
len = 20;
|
|
|
|
set = alloc = xmalloc (len + 1);
|
|
|
|
if (! is_space(ch))
|
|
|
|
{
|
|
|
|
*set++ = ch;
|
|
|
|
while ((ch = getc (f)) != EOF && ! is_space(ch))
|
|
|
|
{
|
|
|
|
if (set - alloc == len)
|
|
|
|
{
|
|
|
|
len *= 2;
|
|
|
|
alloc = xrealloc (alloc, len + 1);
|
|
|
|
set = alloc + len / 2;
|
|
|
|
}
|
|
|
|
*set++ = ch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*set = '\0';
|
|
|
|
ungetc (ch, f);
|
|
|
|
return alloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This structure holds a linked list of file name maps, one per directory. */
|
|
|
|
|
|
|
|
struct file_name_map_list
|
|
|
|
{
|
|
|
|
struct file_name_map_list *map_list_next;
|
|
|
|
char *map_list_name;
|
|
|
|
struct file_name_map *map_list_map;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Read the file name map file for DIRNAME. */
|
|
|
|
|
|
|
|
static struct file_name_map *
|
|
|
|
read_name_map (pfile, dirname)
|
|
|
|
cpp_reader *pfile;
|
|
|
|
const char *dirname;
|
|
|
|
{
|
2001-10-11 11:16:15 +08:00
|
|
|
struct file_name_map_list *map_list_ptr;
|
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
2000-06-22 02:33:51 +08:00
|
|
|
char *name;
|
|
|
|
FILE *f;
|
|
|
|
|
2000-12-14 03:20:14 +08:00
|
|
|
/* Check the cache of directories, and mappings in their remap file. */
|
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
2000-06-22 02:33:51 +08:00
|
|
|
for (map_list_ptr = CPP_OPTION (pfile, map_list); map_list_ptr;
|
|
|
|
map_list_ptr = map_list_ptr->map_list_next)
|
|
|
|
if (! strcmp (map_list_ptr->map_list_name, dirname))
|
|
|
|
return map_list_ptr->map_list_map;
|
|
|
|
|
|
|
|
map_list_ptr = ((struct file_name_map_list *)
|
|
|
|
xmalloc (sizeof (struct file_name_map_list)));
|
|
|
|
map_list_ptr->map_list_name = xstrdup (dirname);
|
2000-12-14 03:20:14 +08:00
|
|
|
|
|
|
|
/* The end of the list ends in NULL. */
|
2000-07-17 05:22:19 +08:00
|
|
|
map_list_ptr->map_list_map = NULL;
|
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
2000-06-22 02:33:51 +08:00
|
|
|
|
|
|
|
name = (char *) alloca (strlen (dirname) + strlen (FILE_NAME_MAP_FILE) + 2);
|
|
|
|
strcpy (name, dirname);
|
|
|
|
if (*dirname)
|
|
|
|
strcat (name, "/");
|
|
|
|
strcat (name, FILE_NAME_MAP_FILE);
|
|
|
|
f = fopen (name, "r");
|
2000-12-14 03:20:14 +08:00
|
|
|
|
|
|
|
/* Silently return NULL if we cannot open. */
|
|
|
|
if (f)
|
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
2000-06-22 02:33:51 +08:00
|
|
|
{
|
|
|
|
int ch;
|
|
|
|
int dirlen = strlen (dirname);
|
|
|
|
|
|
|
|
while ((ch = getc (f)) != EOF)
|
|
|
|
{
|
|
|
|
char *from, *to;
|
|
|
|
struct file_name_map *ptr;
|
|
|
|
|
|
|
|
if (is_space(ch))
|
|
|
|
continue;
|
|
|
|
from = read_filename_string (ch, f);
|
|
|
|
while ((ch = getc (f)) != EOF && is_hspace(ch))
|
|
|
|
;
|
|
|
|
to = read_filename_string (ch, f);
|
|
|
|
|
|
|
|
ptr = ((struct file_name_map *)
|
|
|
|
xmalloc (sizeof (struct file_name_map)));
|
|
|
|
ptr->map_from = from;
|
|
|
|
|
|
|
|
/* Make the real filename absolute. */
|
2001-01-12 05:30:16 +08:00
|
|
|
if (IS_ABSOLUTE_PATHNAME (to))
|
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
2000-06-22 02:33:51 +08:00
|
|
|
ptr->map_to = to;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ptr->map_to = xmalloc (dirlen + strlen (to) + 2);
|
|
|
|
strcpy (ptr->map_to, dirname);
|
|
|
|
ptr->map_to[dirlen] = '/';
|
|
|
|
strcpy (ptr->map_to + dirlen + 1, to);
|
|
|
|
free (to);
|
|
|
|
}
|
|
|
|
|
|
|
|
ptr->map_next = map_list_ptr->map_list_map;
|
|
|
|
map_list_ptr->map_list_map = ptr;
|
|
|
|
|
|
|
|
while ((ch = getc (f)) != '\n')
|
|
|
|
if (ch == EOF)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fclose (f);
|
|
|
|
}
|
|
|
|
|
2000-12-14 03:20:14 +08:00
|
|
|
/* Add this information to the cache. */
|
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
2000-06-22 02:33:51 +08:00
|
|
|
map_list_ptr->map_list_next = CPP_OPTION (pfile, map_list);
|
|
|
|
CPP_OPTION (pfile, map_list) = map_list_ptr;
|
|
|
|
|
|
|
|
return map_list_ptr->map_list_map;
|
|
|
|
}
|
|
|
|
|
2001-03-15 03:35:08 +08:00
|
|
|
/* Remap an unsimplified path NAME based on the file_name_map (if any)
|
|
|
|
for LOC. */
|
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
2000-06-22 02:33:51 +08:00
|
|
|
static char *
|
|
|
|
remap_filename (pfile, name, loc)
|
|
|
|
cpp_reader *pfile;
|
|
|
|
char *name;
|
2001-03-02 15:35:12 +08:00
|
|
|
struct search_path *loc;
|
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
2000-06-22 02:33:51 +08:00
|
|
|
{
|
|
|
|
struct file_name_map *map;
|
2000-12-14 03:20:14 +08:00
|
|
|
const char *from, *p;
|
2001-03-15 03:35:08 +08:00
|
|
|
char *dir;
|
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
2000-06-22 02:33:51 +08:00
|
|
|
|
|
|
|
if (! loc->name_map)
|
2000-12-14 03:20:14 +08:00
|
|
|
{
|
2001-03-15 03:35:08 +08:00
|
|
|
/* Get a null-terminated path. */
|
|
|
|
char *dname = alloca (loc->len + 1);
|
|
|
|
memcpy (dname, loc->name, loc->len);
|
|
|
|
dname[loc->len] = '\0';
|
|
|
|
|
2001-03-02 15:35:12 +08:00
|
|
|
loc->name_map = read_name_map (pfile, dname);
|
2000-12-14 03:20:14 +08:00
|
|
|
if (! loc->name_map)
|
|
|
|
return name;
|
|
|
|
}
|
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
2000-06-22 02:33:51 +08:00
|
|
|
|
2001-03-15 03:35:08 +08:00
|
|
|
/* This works since NAME has not been simplified yet. */
|
2001-03-02 15:35:12 +08:00
|
|
|
from = name + loc->len + 1;
|
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
2000-06-22 02:33:51 +08:00
|
|
|
|
|
|
|
for (map = loc->name_map; map; map = map->map_next)
|
|
|
|
if (!strcmp (map->map_from, from))
|
|
|
|
return map->map_to;
|
|
|
|
|
|
|
|
/* Try to find a mapping file for the particular directory we are
|
|
|
|
looking in. Thus #include <sys/types.h> will look up sys/types.h
|
|
|
|
in /usr/include/header.gcc and look up types.h in
|
|
|
|
/usr/include/sys/header.gcc. */
|
|
|
|
p = strrchr (name, '/');
|
|
|
|
if (!p)
|
|
|
|
return name;
|
|
|
|
|
2000-12-14 03:20:14 +08:00
|
|
|
/* We know p != name as absolute paths don't call remap_filename. */
|
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
2000-06-22 02:33:51 +08:00
|
|
|
if (p == name)
|
2000-12-14 03:20:14 +08:00
|
|
|
cpp_ice (pfile, "absolute file name in remap_filename");
|
|
|
|
|
|
|
|
dir = (char *) alloca (p - name + 1);
|
|
|
|
memcpy (dir, name, p - name);
|
|
|
|
dir[p - name] = '\0';
|
|
|
|
from = p + 1;
|
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
2000-06-22 02:33:51 +08:00
|
|
|
|
|
|
|
for (map = read_name_map (pfile, dir); map; map = map->map_next)
|
2000-12-14 03:20:14 +08:00
|
|
|
if (! strcmp (map->map_from, from))
|
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
2000-06-22 02:33:51 +08:00
|
|
|
return map->map_to;
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2001-04-06 15:22:01 +08:00
|
|
|
/* Returns true if it is safe to remove the final component of path,
|
|
|
|
when it is followed by a ".." component. We use lstat to avoid
|
|
|
|
symlinks if we have it. If not, we can still catch errors with
|
|
|
|
stat (). */
|
|
|
|
static int
|
|
|
|
remove_component_p (path)
|
|
|
|
const char *path;
|
|
|
|
{
|
|
|
|
struct stat s;
|
|
|
|
int result;
|
|
|
|
|
|
|
|
#ifdef HAVE_LSTAT
|
|
|
|
result = lstat (path, &s);
|
|
|
|
#else
|
|
|
|
result = stat (path, &s);
|
|
|
|
#endif
|
|
|
|
|
2001-05-22 19:57:21 +08:00
|
|
|
/* There's no guarantee that errno will be unchanged, even on
|
|
|
|
success. Cygwin's lstat(), for example, will often set errno to
|
|
|
|
ENOSYS. In case of success, reset errno to zero. */
|
|
|
|
if (result == 0)
|
|
|
|
errno = 0;
|
|
|
|
|
2001-04-06 15:22:01 +08:00
|
|
|
return result == 0 && S_ISDIR (s.st_mode);
|
|
|
|
}
|
|
|
|
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
/* Simplify a path name in place, deleting redundant components. This
|
|
|
|
reduces OS overhead and guarantees that equivalent paths compare
|
|
|
|
the same (modulo symlinks).
|
|
|
|
|
|
|
|
Transforms made:
|
|
|
|
foo/bar/../quux foo/quux
|
|
|
|
foo/./bar foo/bar
|
|
|
|
foo//bar foo/bar
|
|
|
|
/../quux /quux
|
|
|
|
//quux //quux (POSIX allows leading // as a namespace escape)
|
|
|
|
|
2001-04-06 15:22:01 +08:00
|
|
|
Guarantees no trailing slashes. All transforms reduce the length
|
|
|
|
of the string. Returns PATH. errno is 0 if no error occurred;
|
|
|
|
nonzero if an error occurred when using stat () or lstat (). */
|
|
|
|
|
2001-03-15 03:35:08 +08:00
|
|
|
char *
|
cppfiles.c (_cpp_find_include_file): Make sure ih->name is initialized.
* cppfiles.c (_cpp_find_include_file): Make sure ih->name is
initialized.
* cppinit.c (cpp_cleanup): Free imp->nshort also.
* cpperror.c (cpp_print_containing_files,
cpp_print_file_and_line, v_cpp_message): Rename to
print_containing_files, print_file_and_line, and v_message.
* cppexp.c (cpp_parse_expr, cpp_parse_escape, cpp_lex): Rename
to _cpp_parse_expr, parse_escape, and lex.
(parse_charconst): Remove broken multibyte support.
* cppfiles.c (include_hash): Make static.
(cpp_included): New function.
(merge_include_chains, find_include_file, finclude,
simplify_pathname): Rename to _cpp_merge_include_chains,
_cpp_find_include_file, _cpp_read_include_file, and
_cpp_simplify_pathname.
* cpphash.c (cpp_lookup, free_definition, delete_macro,
cpp_install, create_definition, macroexpand, compare_defs,
dump_definition): Rename to _cpp_lookup, _cpp_free_definition,
_cpp_delete_macro, _cpp_install, _cpp_create_definition,
_cpp_macroexpand, _cpp_compare_defs, and _cpp_dump_definition.
* cppinit.c (cpp_handle_option): Rename to handle_option, make
static.
* cpplib.c: Remove extern prototype of cpp_parse_expr.
* cpphash.h: Update prototypes.
* cpplib.h: Likewise. Prototype _cpp_parse_expr here.
From-SVN: r32390
2000-03-08 04:58:47 +08:00
|
|
|
_cpp_simplify_pathname (path)
|
1998-11-26 13:41:29 +08:00
|
|
|
char *path;
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
{
|
2001-04-06 15:22:01 +08:00
|
|
|
#ifndef VMS
|
|
|
|
char *from, *to;
|
|
|
|
char *base, *orig_base;
|
|
|
|
int absolute = 0;
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
/* Don't overflow the empty path by putting a '.' in it below. */
|
|
|
|
if (*path == '\0')
|
|
|
|
return path;
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
|
1999-04-10 12:27:16 +08:00
|
|
|
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
|
2001-08-02 01:57:27 +08:00
|
|
|
/* Convert all backslashes to slashes. */
|
2001-04-06 15:22:01 +08:00
|
|
|
for (from = path; *from; from++)
|
|
|
|
if (*from == '\\') *from = '/';
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
|
2001-08-02 01:57:27 +08:00
|
|
|
/* Skip over leading drive letter if present. */
|
2001-04-06 15:22:01 +08:00
|
|
|
if (ISALPHA (path[0]) && path[1] == ':')
|
|
|
|
from = to = &path[2];
|
|
|
|
else
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
from = to = path;
|
2001-04-06 15:22:01 +08:00
|
|
|
#else
|
|
|
|
from = to = path;
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
#endif
|
|
|
|
|
2001-04-06 15:22:01 +08:00
|
|
|
/* Remove redundant leading /s. */
|
|
|
|
if (*from == '/')
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
{
|
2001-04-06 15:22:01 +08:00
|
|
|
absolute = 1;
|
|
|
|
to++;
|
|
|
|
from++;
|
|
|
|
if (*from == '/')
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
{
|
2001-04-06 15:22:01 +08:00
|
|
|
if (*++from == '/')
|
|
|
|
/* 3 or more initial /s are equivalent to 1 /. */
|
|
|
|
while (*++from == '/');
|
|
|
|
else
|
|
|
|
/* On some hosts // differs from /; Posix allows this. */
|
|
|
|
to++;
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
}
|
|
|
|
}
|
2001-04-06 15:22:01 +08:00
|
|
|
|
|
|
|
base = orig_base = to;
|
|
|
|
for (;;)
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
{
|
2001-04-06 15:22:01 +08:00
|
|
|
int move_base = 0;
|
|
|
|
|
|
|
|
while (*from == '/')
|
|
|
|
from++;
|
|
|
|
|
|
|
|
if (*from == '\0')
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (*from == '.')
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
{
|
2001-04-06 15:22:01 +08:00
|
|
|
if (from[1] == '\0')
|
|
|
|
break;
|
|
|
|
if (from[1] == '/')
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
{
|
2001-04-06 15:22:01 +08:00
|
|
|
from += 2;
|
|
|
|
continue;
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
}
|
2001-04-06 15:22:01 +08:00
|
|
|
else if (from[1] == '.' && (from[2] == '/' || from[2] == '\0'))
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
{
|
2001-04-06 15:22:01 +08:00
|
|
|
/* Don't simplify if there was no previous component. */
|
|
|
|
if (absolute && orig_base == to)
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
{
|
2001-04-06 15:22:01 +08:00
|
|
|
from += 2;
|
|
|
|
continue;
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
}
|
2001-04-06 15:22:01 +08:00
|
|
|
/* Don't simplify if the previous component was "../",
|
|
|
|
or if an error has already occurred with (l)stat. */
|
|
|
|
if (base != to && errno == 0)
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
{
|
2001-04-06 15:22:01 +08:00
|
|
|
/* We don't back up if it's a symlink. */
|
|
|
|
*to = '\0';
|
|
|
|
if (remove_component_p (path))
|
|
|
|
{
|
|
|
|
while (to > base && *to != '/')
|
|
|
|
to--;
|
|
|
|
from += 2;
|
|
|
|
continue;
|
|
|
|
}
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
}
|
2001-04-06 15:22:01 +08:00
|
|
|
move_base = 1;
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
}
|
2001-04-06 15:22:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Add the component separator. */
|
|
|
|
if (to > orig_base)
|
|
|
|
*to++ = '/';
|
|
|
|
|
|
|
|
/* Copy this component until the trailing null or '/'. */
|
|
|
|
while (*from != '\0' && *from != '/')
|
|
|
|
*to++ = *from++;
|
|
|
|
|
|
|
|
if (move_base)
|
|
|
|
base = to;
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
}
|
|
|
|
|
2001-04-06 15:22:01 +08:00
|
|
|
/* Change the empty string to "." so that it is not treated as stdin.
|
|
|
|
Null terminate. */
|
|
|
|
if (to == path)
|
|
|
|
*to++ = '.';
|
|
|
|
*to = '\0';
|
|
|
|
|
|
|
|
return path;
|
|
|
|
#else /* VMS */
|
|
|
|
errno = 0;
|
|
|
|
return path;
|
|
|
|
#endif /* !VMS */
|
cpplib.h: Delete struct import_file.
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
From-SVN: r23857
1998-11-25 19:56:54 +08:00
|
|
|
}
|