gcc/libcpp/files.c

1595 lines
44 KiB
C
Raw Normal View History

Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Part of CPP library. File handling.
Makefile.in (C_AND_OBJC_OBJS, [...]): Update. * Makefile.in (C_AND_OBJC_OBJS, c-incpath.o, c-lex.o, LIBCPP_OBJS, cppinit.o, cppdefault.o, fix-header): Update. * c-incpath.c: New file. * c-incpath.h: New file. * c-lex.c: Include c-incpath.h. (init_c_lex): Register path simplifier. * c-opts.c: Include cppdefault.h and c-incpath.h. (TARGET_SYSTEM_ROOT, verbose, iprefix, sysroot, std_inc, std_cxx_inc, quote_chain_split, add_prefixed_path): New. (COMMAND_LINE_OPTIONS): Add more options from cpplib. (missing_arg, c_common_decode_option): Handle them. (c_common_post_options): Register include chains. (print_help): Update. * cppdefault.h (struct default include): Update. Move some macros to ... * cppdefault.c: ... here. (cpp_include_defaults): Add extra field add_sysroot. * cppfiles.c (include_file, search_from, find_or_create_entry, cpp_included, find_include_file, remap_filename): Update for renaming of search_path to cpp_path, and of the chain headers. (remove_component_p, _cpp_simplify_pathname): Move to c-incpath.c. * cpphash.h (struct search_path): Move to cpplib.h. (struct cpp_buffer, struct cpp_reader): Update. (_cpp_simplify_pathname): Remove. * cppinit.c: Don't include prefix.h and cppdefault.h. (INO_T_EQ, INO_T_COPY, path_include, append_include_chain, remove_dup_dir, remove_dup_nonsys_dirs, remove_dup_dirs, init_standard_includes, BRACKET, SYSTEM, AFTER, no_dir, no_pth, cpp_handle_options): Remove. (struct pending_option): Remove chain members. (cpp_destroy, cpp_read_main_file, COMMAND_LINE_OPTIONS, cpp_handle_option): Update. * cpplib.h (struct cpp_path, cpp_set_include_chains): New. (struct cpp_options): Remove quote_include, bracket_include, include_prefix, include_prefix_len, verbose, ignore_srcdir, no_standard_includes, no_standard_cplusplus_includes. (struct cpp_callbacks): Add simplify_path. (cpp_handle_options): Remove. * fix-header.c: Include c-incpath.h. (read_scan_file): Update to use c-incpath functionality. * doc/passes.texi: Update. cp: * Make-lang.in (CXX_C_OBJS): Update. From-SVN: r63612
2003-03-01 15:31:21 +01:00
Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1998,
1999, 2000, 2001, 2002, 2003, 2004, 2005 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 12:54:13 +01: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
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
Reimplemented, Neil Booth, Jul 2003
[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 12:54:13 +01:00
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
Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 12:54:13 +01:00
#include "config.h"
#include "system.h"
#include "cpplib.h"
Makefile.def (host_modules): add libcpp. ChangeLog: 2004-05-23 Paolo Bonzini <bonzini@gnu.org> * Makefile.def (host_modules): add libcpp. * Makefile.tpl: Add dependencies on and for libcpp. * Makefile.in: Regenerate. * configure.in: Add libcpp host module. * configure: Regenerate. config/ChangeLog: 2004-05-23 Paolo Bonzini <bonzini@gnu.org> * acx.m4 (ACX_HEADER_STDBOOL, ACX_HEADER_STRING): From gcc. gcc/ChangeLog: 2004-05-23 Paolo Bonzini <bonzini@gnu.org> Move libcpp to the toplevel. * Makefile.in: Remove references to libcpp files, use CPPLIBS instead of libcpp.a. Define SYMTAB_H and change hashtable.h to that. * aclocal.m4 (gcc_AC_HEADER_STDBOOL, gcc_AC_HEADER_STRING, gcc_AC_C__BOOL): Remove. * configure.ac (gcc_AC_C__BOOL, HAVE_UCHAR): Remove tests. * configure: Regenerate. * config.in: Regenerate. * c-ppoutput.c: Include ../libcpp/internal.h instead of cpphash.h. * cppcharset.c: Removed. * cpperror.c: Removed. * cppexp.c: Removed. * cppfiles.c: Removed. * cpphash.c: Removed. * cpphash.h: Removed. * cppinit.c: Removed. * cpplex.c: Removed. * cpplib.c: Removed. * cpplib.h: Removed. * cppmacro.c: Removed. * cpppch.c: Removed. * cpptrad.c: Removed. * cppucnid.h: Removed. * cppucnid.pl: Removed. * cppucnid.tab: Removed. * hashtable.c: Removed. * hashtable.h: Removed. * line-map.c: Removed. * line-map.h: Removed. * mkdeps.c: Removed. * mkdeps.h: Removed. * stringpool.h: Include symtab.h instead of hashtable.h. * tree.h: Include symtab.h instead of hashtable.h. * system.h (O_NONBLOCK, O_NOCTTY): Do not define. gcc/cp/ChangeLog: 2004-05-23 Paolo Bonzini <bonzini@gnu.org> * Make-lang.in: No need to specify $(LIBCPP). gcc/java/ChangeLog: 2004-05-23 Paolo Bonzini <bonzini@gnu.org> * Make-lang.in: Link in $(LIBCPP) instead of mkdeps.o. libcpp/ChangeLog: 2004-05-23 Paolo Bonzini <bonzini@gnu.org> Moved libcpp from the gcc subdirectory to the toplevel. * Makefile.am: New file. * Makefile.in: Regenerate. * configure.ac: New file. * configure: Regenerate. * config.in: Regenerate. * charset.c: Moved from gcc/cppcharset.c. Add note about brokenness of input charset detection. Adjust for change in name of cppucnid.h. * errors.c: Moved from gcc/cpperror.c. Do not include intl.h. * expr.c: Moved from gcc/cppexp.c. * files.c: Moved from gcc/cppfiles.c. Do not include intl.h. Remove #define of O_BINARY, it is in system.h. * identifiers.c: Moved from gcc/cpphash.c. * internal.h: Moved from gcc/cpphash.h. Change header guard name. All other files adjusted to match name change. * init.c: Moved from gcc/cppinit.c. (init_library) [ENABLE_NLS]: Call bindtextdomain. * lex.c: Moved from gcc/cpplex.c. * directives.c: Moved from gcc/cpplib.c. * macro.c: Moved from gcc/cppmacro.c. * pch.c: Moved from gcc/cpppch.c. Do not include intl.h. * traditional.c: Moved from gcc/cpptrad.c. * ucnid.h: Moved from gcc/cppucnid.h. Change header guard name. * ucnid.pl: Moved from gcc/cppucnid.pl. * ucnid.tab: Moved from gcc/cppucnid.tab. Change header guard name. * symtab.c: Moved from gcc/hashtable.c. * line-map.c: Moved from gcc. Do not include intl.h. * mkdeps.c: Moved from gcc. * system.h: New file. libcpp/include/ChangeLog: 2004-05-23 Paolo Bonzini <bonzini@gnu.org> * cpplib.h: Moved from gcc. Change header guard name. * line-map.h: Moved from gcc. Change header guard name. * mkdeps.h: Moved from gcc. Change header guard name. * symtab.h: Moved from gcc/hashtable.h. Change header guard name. libcpp/po/ChangeLog: 2004-05-23 Paolo Bonzini <bonzini@gnu.org> * be.po: Extracted from gcc/po/be.po. * ca.po: Extracted from gcc/po/ca.po. * da.po: Extracted from gcc/po/da.po. * de.po: Extracted from gcc/po/de.po. * el.po: Extracted from gcc/po/el.po. * es.po: Extracted from gcc/po/es.po. * fr.po: Extracted from gcc/po/fr.po. * ja.po: Extracted from gcc/po/ja.po. * nl.po: Extracted from gcc/po/nl.po. * sv.po: Extracted from gcc/po/sv.po. * tr.po: Extracted from gcc/po/tr.po. From-SVN: r82199
2004-05-24 12:50:45 +02:00
#include "internal.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 07:34:11 +01:00
#include "mkdeps.h"
#include "hashtab.h"
#include "md5.h"
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
#include <dirent.h>
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02: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_RELIABLE(ST) ((ST).st_fab_rfm != FAB_C_VAR)
#else
# define STAT_SIZE_RELIABLE(ST) true
#endif
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
#ifdef __DJGPP__
#include <io.h>
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* For DJGPP redirected input is opened in text mode. */
# define set_stdin_to_binary_mode() \
if (! isatty (0)) setmode (0, O_BINARY)
#else
# define set_stdin_to_binary_mode() /* Nothing */
#endif
/* This structure represents a file searched for by CPP, whether it
exists or not. An instance may be pointed to by more than one
file_hash_entry; at present no reference count is kept. */
struct _cpp_file
{
/* Filename as given to #include or command line switch. */
const char *name;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* The full path used to find the file. */
const char *path;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* The full path of the pch file. */
const char *pchname;
[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 12:54:13 +01:00
/* The file's path with the basename stripped. NULL if it hasn't
been calculated yet. */
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
const char *dir_name;
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 07:33:57 +02:00
/* Chain through all files. */
struct _cpp_file *next_file;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* The contents of NAME after calling read_file(). */
const uchar *buffer;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* The macro, if any, preventing re-inclusion. */
const cpp_hashnode *cmacro;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* The directory in the search path where FILE was found. Used for
#include_next and determining whether a header is a system
header. */
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
cpp_dir *dir;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* As filled in by stat(2) for the file. */
struct stat st;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* File descriptor. Invalid if -1, otherwise open. */
int fd;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Zero if this file was successfully opened and stat()-ed,
otherwise errno obtained from failure. */
int err_no;
[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 12:54:13 +01:00
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Number of times the file has been stacked for preprocessing. */
unsigned short stack_count;
/* If opened with #import or contains #pragma once. */
bool once_only;
[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 12:54:13 +01:00
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* If read() failed before. */
bool dont_read;
[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 12:54:13 +01:00
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* If this file is the main file. */
bool main_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 12:54:13 +01:00
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* If BUFFER above contains the true contents of the file. */
bool buffer_valid;
/* File is a PCH (on return from find_include_file). */
bool pch;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
};
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* A singly-linked list for all searches for a given file name, with
its head pointed to by a slot in FILE_HASH. The file name is what
appeared between the quotes in a #include directive; it can be
determined implicitly from the hash table location or explicitly
from FILE->name.
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
FILE is a structure containing details about the file that was
found with that search, or details of how the search failed.
START_DIR is the starting location of the search in the include
chain. The current directories for "" includes are also hashed in
the hash table and therefore unique. Files that are looked up
without using a search path, such as absolute filenames and file
names from the command line share a special starting directory so
they don't cause cache hits with normal include-chain lookups.
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
If START_DIR is NULL then the entry is for a directory, not a file,
and the directory is in DIR. Since the starting point in a file
lookup chain is never NULL, this means that simple pointer
comparisons against START_DIR can be made to determine cache hits
in file lookups.
If a cache lookup fails because of e.g. an extra "./" in the path,
then nothing will break. It is just less efficient as CPP will
have to do more work re-preprocessing the file, and/or comparing
its contents against earlier once-only files.
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
*/
struct file_hash_entry
{
struct file_hash_entry *next;
cpp_dir *start_dir;
union
{
_cpp_file *file;
cpp_dir *dir;
} u;
};
static bool open_file (_cpp_file *file);
static bool pch_open_file (cpp_reader *pfile, _cpp_file *file,
bool *invalid_pch);
static bool find_file_in_dir (cpp_reader *pfile, _cpp_file *file,
bool *invalid_pch);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
static bool read_file_guts (cpp_reader *pfile, _cpp_file *file);
static bool read_file (cpp_reader *pfile, _cpp_file *file);
static bool should_stack_file (cpp_reader *, _cpp_file *file, bool import);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
static struct cpp_dir *search_path_head (cpp_reader *, const char *fname,
int angle_brackets, enum include_type);
static const char *dir_name_of_file (_cpp_file *file);
static void open_file_failed (cpp_reader *pfile, _cpp_file *file, int);
static struct file_hash_entry *search_cache (struct file_hash_entry *head,
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
const cpp_dir *start_dir);
static _cpp_file *make_cpp_file (cpp_reader *, cpp_dir *, const char *fname);
static void destroy_cpp_file (_cpp_file *);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
static cpp_dir *make_cpp_dir (cpp_reader *, const char *dir_name, int sysp);
static void allocate_file_hash_entries (cpp_reader *pfile);
static struct file_hash_entry *new_file_hash_entry (cpp_reader *pfile);
static int report_missing_guard (void **slot, void *b);
static hashval_t file_hash_hash (const void *p);
static int file_hash_eq (const void *p, const void *q);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
static char *read_filename_string (int ch, FILE *f);
static void read_name_map (cpp_dir *dir);
static char *remap_filename (cpp_reader *pfile, _cpp_file *file);
static char *append_file_to_dir (const char *fname, cpp_dir *dir);
static bool validate_pch (cpp_reader *, _cpp_file *file, const char *pchname);
static int pchf_save_compare (const void *e1, const void *e2);
static int pchf_compare (const void *d_p, const void *e_p);
static bool check_file_against_entries (cpp_reader *, _cpp_file *, bool);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Given a filename in FILE->PATH, with the empty string interpreted
as <stdin>, open it.
On success FILE contains an open file descriptor and stat
information for the file. On failure the file descriptor is -1 and
the appropriate errno is also stored in FILE. Returns TRUE iff
successful.
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).
Use the three-argument form of open even though we aren't
specifying O_CREAT, to defend against broken system headers.
O_BINARY tells some runtime libraries (notably DJGPP) not to do
newline translation; we can handle DOS line breaks just fine
ourselves. */
static bool
open_file (_cpp_file *file)
{
if (file->path[0] == '\0')
{
file->fd = 0;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
set_stdin_to_binary_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 01:29:45 +02:00
else
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
file->fd = open (file->path, O_RDONLY | O_NOCTTY | O_BINARY, 0666);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (file->fd != -1)
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (fstat (file->fd, &file->st) == 0)
{
if (!S_ISDIR (file->st.st_mode))
{
file->err_no = 0;
return true;
}
/* Ignore a directory and continue the search. The file we're
looking for may be elsewhere in the search path. */
errno = ENOENT;
}
close (file->fd);
file->fd = -1;
}
else if (errno == ENOTDIR)
errno = ENOENT;
file->err_no = errno;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
return false;
}
/* Temporary PCH intercept of opening a file. Try to find a PCH file
based on FILE->name and FILE->dir, and test those found for
validity using PFILE->cb.valid_pch. Return true iff a valid file is
found. Set *INVALID_PCH if a PCH file is found but wasn't valid. */
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
static bool
pch_open_file (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch)
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
static const char extension[] = ".gch";
const char *path = file->path;
size_t len, flen;
char *pchname;
struct stat st;
bool valid = false;
/* No PCH on <stdin> or if not requested. */
if (file->name[0] == '\0' || !pfile->cb.valid_pch)
return false;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
flen = strlen (path);
len = flen + sizeof (extension);
configure.ac: Check declarations for asprintf and vasprintf. * configure.ac: Check declarations for asprintf and vasprintf. * config.in: Regenerate. * configure: Likewise. * charset.c (conversion_loop): Use XRESIZEVEC. (convert_no_conversion): Likewise. (convert_using_iconv): Likewise. (init_iconv_desc): Cast return value of alloca. (cpp_host_to_exec_charset): Use XNEWVEC. (emit_numeric_escape): Use XRESIZEVEC. (cpp_interpret_string): Use XNEWVEC. (cpp_interpret_string): Use XRESIZEVEC. (_cpp_interpret_identifier): Cast return value of alloca. (_cpp_convert_input): Use XNEWVEC and XRESIZEVEC. * directives.c (glue_header_name): Use XNEWVEC and XRESIZEVEC. (parse_include): Use XNEWVEC. (insert_pragma_entry): Rename local variable "new" to "new_entry". (save_registered_pragmas): Cast return value of xmemdup. (destringize_and_run): Same for alloca. (parse_assertion): Likewise. (do_assert): Cast allocated storage to proper type. (cpp_define): Likewise. (_cpp_define_builtin): Likewise. (cpp_undef): Likewise. (handle_assertion): Likewise. (cpp_push_buffer): Rename local variable "new" to "new_buffer". * expr.c (CPP_UPLUS): Cast value to type cpp_ttype. (CPP_UMINUS): Likewise. (struct cpp_operator): Rename from struct operator. (_cpp_expand_op_stack): Use XRESIZEVEC. * files.c (pch_open_file): Use XNEWVEC. (pch_open_file): Use XRESIZEVEC. (read_file_guts): Use XNEWVEC and XRESIZEVEC. (dir_name_of_file): Use XNEWVEC. (make_cpp_file): Use XCNEW. (make_cpp_dir): Likewise. (allocate_file_hash_entries): USE XNEWVEC. (cpp_included): Cast return value of htab_find_with_hash. (append_file_to_dir): Use XNEWVEC. (read_filename_string): Likewise. Use XRESIZEVEC too. (read_name_map): Cast return value of alloca. Use XRESIZEVEC. (remap_filename): Use XNEWVEC. (struct pchf_entry): Move definition out of struct pchf_data. (_cpp_save_file_entries): Use XCNEWVAR. (_cpp_read_file_entries): Use XNEWVAR. * identifiers.c (alloc_node): Use XOBNEW. * init.c (cpp_create_reader): Use XCNEW. (cpp_init_builtins): Cast of b->value to enum builtin_type. (read_original_directory): Cast return value of alloca. * lex.c (add_line_note): Use XRESIZEVEC. (warn_about_normalization): Use XNEWVEC. (_cpp_lex_direct): Cast node->directive_index to (enum cpp_ttype). (new_buff): Use XNEWVEC. * line-map.c (linemap_add): Use XRESIZEVEC. * macro.c (builtin_macro): Cast return value of alloca. (paste_tokens): Likewise. (expand_arg): Use XNEWVEC and XRESIZEVEC. (_cpp_save_parameter): Use XRESIZEVEC. (create_iso_definition): Cast allocated storage to proper type. (_cpp_create_definition): Likewise. (cpp_macro_definition): Use XRESIZEVEC. * makedepend.c (add_clm): Use XNEW. (add_dir): Likewise. * mkdeps.c (munge): Use XNEWVEC. (deps_init): Use XCNEW. (deps_add_target): Use XRESIZEVEC. (deps_add_default_target): Cast return value of alloca. (deps_add_dep): Use XRESIZEVEC. (deps_add_vpath): Likewise. Use XNEWVEC too. (deps_restore): Likewise. * pch.c (save_idents): Use XNEW and XNEWVEC. (cpp_save_state): Use XNEW. (count_defs): Cast return value of htab_find. (write_defs): Likewise. (cpp_write_pch_deps): Use XNEWVEC. (collect_ht_nodes): Use XRESIZEVEC. (cpp_valid_state): Use XNEWVEC. (save_macros): Use XRESIZEVEC. Cast return value of xmemdup. * symtab.c (ht_create): Use XCNEW. (ht_lookup_with_hash): Cast return value of obstack_copy0. (ht_expand): Use XCNEWVEC. * system.h (HAVE_DESIGNATED_INITIALIZERS): False if __cplusplus. (bool): Do not define if __cplusplus. From-SVN: r100295
2005-05-28 17:52:48 +02:00
pchname = XNEWVEC (char, len);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
memcpy (pchname, path, flen);
memcpy (pchname + flen, extension, sizeof (extension));
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (stat (pchname, &st) == 0)
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
DIR *pchdir;
struct dirent *d;
size_t dlen, plen = len;
if (!S_ISDIR (st.st_mode))
valid = validate_pch (pfile, file, pchname);
else if ((pchdir = opendir (pchname)) != NULL)
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
pchname[plen - 1] = '/';
while ((d = readdir (pchdir)) != NULL)
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
dlen = strlen (d->d_name) + 1;
if ((strcmp (d->d_name, ".") == 0)
|| (strcmp (d->d_name, "..") == 0))
continue;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (dlen + plen > len)
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
len += dlen + 64;
configure.ac: Check declarations for asprintf and vasprintf. * configure.ac: Check declarations for asprintf and vasprintf. * config.in: Regenerate. * configure: Likewise. * charset.c (conversion_loop): Use XRESIZEVEC. (convert_no_conversion): Likewise. (convert_using_iconv): Likewise. (init_iconv_desc): Cast return value of alloca. (cpp_host_to_exec_charset): Use XNEWVEC. (emit_numeric_escape): Use XRESIZEVEC. (cpp_interpret_string): Use XNEWVEC. (cpp_interpret_string): Use XRESIZEVEC. (_cpp_interpret_identifier): Cast return value of alloca. (_cpp_convert_input): Use XNEWVEC and XRESIZEVEC. * directives.c (glue_header_name): Use XNEWVEC and XRESIZEVEC. (parse_include): Use XNEWVEC. (insert_pragma_entry): Rename local variable "new" to "new_entry". (save_registered_pragmas): Cast return value of xmemdup. (destringize_and_run): Same for alloca. (parse_assertion): Likewise. (do_assert): Cast allocated storage to proper type. (cpp_define): Likewise. (_cpp_define_builtin): Likewise. (cpp_undef): Likewise. (handle_assertion): Likewise. (cpp_push_buffer): Rename local variable "new" to "new_buffer". * expr.c (CPP_UPLUS): Cast value to type cpp_ttype. (CPP_UMINUS): Likewise. (struct cpp_operator): Rename from struct operator. (_cpp_expand_op_stack): Use XRESIZEVEC. * files.c (pch_open_file): Use XNEWVEC. (pch_open_file): Use XRESIZEVEC. (read_file_guts): Use XNEWVEC and XRESIZEVEC. (dir_name_of_file): Use XNEWVEC. (make_cpp_file): Use XCNEW. (make_cpp_dir): Likewise. (allocate_file_hash_entries): USE XNEWVEC. (cpp_included): Cast return value of htab_find_with_hash. (append_file_to_dir): Use XNEWVEC. (read_filename_string): Likewise. Use XRESIZEVEC too. (read_name_map): Cast return value of alloca. Use XRESIZEVEC. (remap_filename): Use XNEWVEC. (struct pchf_entry): Move definition out of struct pchf_data. (_cpp_save_file_entries): Use XCNEWVAR. (_cpp_read_file_entries): Use XNEWVAR. * identifiers.c (alloc_node): Use XOBNEW. * init.c (cpp_create_reader): Use XCNEW. (cpp_init_builtins): Cast of b->value to enum builtin_type. (read_original_directory): Cast return value of alloca. * lex.c (add_line_note): Use XRESIZEVEC. (warn_about_normalization): Use XNEWVEC. (_cpp_lex_direct): Cast node->directive_index to (enum cpp_ttype). (new_buff): Use XNEWVEC. * line-map.c (linemap_add): Use XRESIZEVEC. * macro.c (builtin_macro): Cast return value of alloca. (paste_tokens): Likewise. (expand_arg): Use XNEWVEC and XRESIZEVEC. (_cpp_save_parameter): Use XRESIZEVEC. (create_iso_definition): Cast allocated storage to proper type. (_cpp_create_definition): Likewise. (cpp_macro_definition): Use XRESIZEVEC. * makedepend.c (add_clm): Use XNEW. (add_dir): Likewise. * mkdeps.c (munge): Use XNEWVEC. (deps_init): Use XCNEW. (deps_add_target): Use XRESIZEVEC. (deps_add_default_target): Cast return value of alloca. (deps_add_dep): Use XRESIZEVEC. (deps_add_vpath): Likewise. Use XNEWVEC too. (deps_restore): Likewise. * pch.c (save_idents): Use XNEW and XNEWVEC. (cpp_save_state): Use XNEW. (count_defs): Cast return value of htab_find. (write_defs): Likewise. (cpp_write_pch_deps): Use XNEWVEC. (collect_ht_nodes): Use XRESIZEVEC. (cpp_valid_state): Use XNEWVEC. (save_macros): Use XRESIZEVEC. Cast return value of xmemdup. * symtab.c (ht_create): Use XCNEW. (ht_lookup_with_hash): Cast return value of obstack_copy0. (ht_expand): Use XCNEWVEC. * system.h (HAVE_DESIGNATED_INITIALIZERS): False if __cplusplus. (bool): Do not define if __cplusplus. From-SVN: r100295
2005-05-28 17:52:48 +02:00
pchname = XRESIZEVEC (char, pchname, len);
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
memcpy (pchname + plen, d->d_name, dlen);
valid = validate_pch (pfile, file, pchname);
if (valid)
break;
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
closedir (pchdir);
}
if (valid)
file->pch = true;
else
*invalid_pch = true;
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (valid)
file->pchname = pchname;
else
free (pchname);
return valid;
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Try to open the path FILE->name appended to FILE->dir. This is
where remap and PCH intercept the file lookup process. Return true
[multiple changes] 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * c-opts.c (c_common_handle_option): Add -finput-charset. * c.opt: Ditto. * cppcharset.c (one_iso88591_to_utf8): Remove. (convert_iso88591_utf8): Ditto. (conversion_tab): Remove 8859-1 converter. (_cpp_input_to_utf8): Remove. (_cpp_init_iconv_buffer): Ditto. (_cpp_close_iconv_buffer): Ditto. (_cpp_convert_input): New function. (_cpp_default_encoding): Ditto. * cpphash.h: Add/remove prototypes for above. * cppfiles.c (read_file_guts): Use _cpp_convert_input. * cppinit.c (cpp_create_reader): Use _cpp_default_encoding for narrow execution and input character sets. * cpplib.c (cpp_push_buffer): Delete uses of removed functions. * doc/cppopts.texi: Document -finput-charset. 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * gcc.c-torture/execute/wchar_t-1.c: Add -finput-charset. 2004-01-29 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * testsuite/22_locale/collate/compare/wchar_t/2.cc: Remove xfail. Use -finput-charset. * testsuite/22_locale/collate/compare/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/compare/wchar_t/wrapped_locale.cc: Ditto * testsuite/22_locale/collate/hash/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_locale.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_locale.cc: Ditto. From-SVN: r77136
2004-02-02 21:20:58 +01:00
if the file was found, whether or not the open was successful.
Set *INVALID_PCH to true if a PCH file is found but wasn't valid. */
static bool
find_file_in_dir (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch)
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
char *path;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (CPP_OPTION (pfile, remap) && (path = remap_filename (pfile, file)))
;
else
Add framework support for darwin. * c-incpath.c: Include target.h and machmode.h. (add_path): Use a consistent style for cpp_dir. Initialize p->construct to 0. (add_cpp_dir_path): New. (register_include_chains): Add use of extra_includes callback. (hook_void_int): Add. (target_c_incpath): Add. * c-incpath.h (add_cpp_dir_path): New. (target_c_incpath_s): Add. (target_c_incpath): Add. (C_INCPATH_INIT): Add. * c-opts.c (c_common_missing_argument, c_common_handle_option): Add -F argument processing. * c.opt: Add -F argument processing. * gcc.c (trad_capable_cpp): Add -F argument processing. * cppfiles.c (find_file_in_dir): Update to use construct callback. (search_path_exhausted, cpp_get_path, cpp_get_buffer, cpp_get_prev): New. (_cpp_find_file): Use search_path_exhausted. (make_cpp_dir): Initialize construct to 0. * cpplib.h (missing_header_cb cpp_get_path, cpp_get_buffer, cpp_get_file, cpp_get_prev): New. (cpp_callbacks): Add missing_header (cpp_dir): Add construct. * target-def.h: (TARGET_OPTF): New. * hooks.c (hook_void_int, hook_void_charptr): Add. * hooks.h (hook_void_int, hook_void_charptr): Add. * Makefile.in (c-incpath.o) : Add $(TARGET_H) and $(MACHMODE_H) dependencies. * doc/invoke.texi (Darwin Options): Document -F. * doc/tm.texi (TARGET_EXTRA_INCLUDES): Add. (TARGET_OPTF): Add. * fix-header.c (target_c_incpath): Add. * config/darwin-c.c: Add c-incpath.h include. (using_frameworks, find_subframework_file, find_subframework_header, add_system_framework_path, frameworks_in_use, num_frameworks, max_frameworks, add_framework, find_framework, struct framework_header, framework_header_dirs, framework_construct_pathname, find_subframework_file, add_system_framework_path, add_framework_path, framework_defaults, darwin_register_frameworks, find_subframework_header): Add. * config/darwin.h (TARGET_EXTRA_INCLUDES, TARGET_OPTF): New. (TARGET_OPTION_TRANSLATE_TABLE): Add -framework support. (CPP_SPEC): Add __APPLE_CC__ support. * t-darwin (darwin-c.o): Add c-incpath.h dependency. From-SVN: r78875
2004-03-04 01:18:54 +01:00
if (file->dir->construct)
path = file->dir->construct (file->name, file->dir);
else
path = append_file_to_dir (file->name, file->dir);
Add framework support for darwin. * c-incpath.c: Include target.h and machmode.h. (add_path): Use a consistent style for cpp_dir. Initialize p->construct to 0. (add_cpp_dir_path): New. (register_include_chains): Add use of extra_includes callback. (hook_void_int): Add. (target_c_incpath): Add. * c-incpath.h (add_cpp_dir_path): New. (target_c_incpath_s): Add. (target_c_incpath): Add. (C_INCPATH_INIT): Add. * c-opts.c (c_common_missing_argument, c_common_handle_option): Add -F argument processing. * c.opt: Add -F argument processing. * gcc.c (trad_capable_cpp): Add -F argument processing. * cppfiles.c (find_file_in_dir): Update to use construct callback. (search_path_exhausted, cpp_get_path, cpp_get_buffer, cpp_get_prev): New. (_cpp_find_file): Use search_path_exhausted. (make_cpp_dir): Initialize construct to 0. * cpplib.h (missing_header_cb cpp_get_path, cpp_get_buffer, cpp_get_file, cpp_get_prev): New. (cpp_callbacks): Add missing_header (cpp_dir): Add construct. * target-def.h: (TARGET_OPTF): New. * hooks.c (hook_void_int, hook_void_charptr): Add. * hooks.h (hook_void_int, hook_void_charptr): Add. * Makefile.in (c-incpath.o) : Add $(TARGET_H) and $(MACHMODE_H) dependencies. * doc/invoke.texi (Darwin Options): Document -F. * doc/tm.texi (TARGET_EXTRA_INCLUDES): Add. (TARGET_OPTF): Add. * fix-header.c (target_c_incpath): Add. * config/darwin-c.c: Add c-incpath.h include. (using_frameworks, find_subframework_file, find_subframework_header, add_system_framework_path, frameworks_in_use, num_frameworks, max_frameworks, add_framework, find_framework, struct framework_header, framework_header_dirs, framework_construct_pathname, find_subframework_file, add_system_framework_path, add_framework_path, framework_defaults, darwin_register_frameworks, find_subframework_header): Add. * config/darwin.h (TARGET_EXTRA_INCLUDES, TARGET_OPTF): New. (TARGET_OPTION_TRANSLATE_TABLE): Add -framework support. (CPP_SPEC): Add __APPLE_CC__ support. * t-darwin (darwin-c.o): Add c-incpath.h dependency. From-SVN: r78875
2004-03-04 01:18:54 +01:00
if (path)
{
file->path = path;
if (pch_open_file (pfile, file, invalid_pch))
return true;
Add framework support for darwin. * c-incpath.c: Include target.h and machmode.h. (add_path): Use a consistent style for cpp_dir. Initialize p->construct to 0. (add_cpp_dir_path): New. (register_include_chains): Add use of extra_includes callback. (hook_void_int): Add. (target_c_incpath): Add. * c-incpath.h (add_cpp_dir_path): New. (target_c_incpath_s): Add. (target_c_incpath): Add. (C_INCPATH_INIT): Add. * c-opts.c (c_common_missing_argument, c_common_handle_option): Add -F argument processing. * c.opt: Add -F argument processing. * gcc.c (trad_capable_cpp): Add -F argument processing. * cppfiles.c (find_file_in_dir): Update to use construct callback. (search_path_exhausted, cpp_get_path, cpp_get_buffer, cpp_get_prev): New. (_cpp_find_file): Use search_path_exhausted. (make_cpp_dir): Initialize construct to 0. * cpplib.h (missing_header_cb cpp_get_path, cpp_get_buffer, cpp_get_file, cpp_get_prev): New. (cpp_callbacks): Add missing_header (cpp_dir): Add construct. * target-def.h: (TARGET_OPTF): New. * hooks.c (hook_void_int, hook_void_charptr): Add. * hooks.h (hook_void_int, hook_void_charptr): Add. * Makefile.in (c-incpath.o) : Add $(TARGET_H) and $(MACHMODE_H) dependencies. * doc/invoke.texi (Darwin Options): Document -F. * doc/tm.texi (TARGET_EXTRA_INCLUDES): Add. (TARGET_OPTF): Add. * fix-header.c (target_c_incpath): Add. * config/darwin-c.c: Add c-incpath.h include. (using_frameworks, find_subframework_file, find_subframework_header, add_system_framework_path, frameworks_in_use, num_frameworks, max_frameworks, add_framework, find_framework, struct framework_header, framework_header_dirs, framework_construct_pathname, find_subframework_file, add_system_framework_path, add_framework_path, framework_defaults, darwin_register_frameworks, find_subframework_header): Add. * config/darwin.h (TARGET_EXTRA_INCLUDES, TARGET_OPTF): New. (TARGET_OPTION_TRANSLATE_TABLE): Add -framework support. (CPP_SPEC): Add __APPLE_CC__ support. * t-darwin (darwin-c.o): Add c-incpath.h dependency. From-SVN: r78875
2004-03-04 01:18:54 +01:00
if (open_file (file))
return true;
if (file->err_no != ENOENT)
{
open_file_failed (pfile, file, 0);
Add framework support for darwin. * c-incpath.c: Include target.h and machmode.h. (add_path): Use a consistent style for cpp_dir. Initialize p->construct to 0. (add_cpp_dir_path): New. (register_include_chains): Add use of extra_includes callback. (hook_void_int): Add. (target_c_incpath): Add. * c-incpath.h (add_cpp_dir_path): New. (target_c_incpath_s): Add. (target_c_incpath): Add. (C_INCPATH_INIT): Add. * c-opts.c (c_common_missing_argument, c_common_handle_option): Add -F argument processing. * c.opt: Add -F argument processing. * gcc.c (trad_capable_cpp): Add -F argument processing. * cppfiles.c (find_file_in_dir): Update to use construct callback. (search_path_exhausted, cpp_get_path, cpp_get_buffer, cpp_get_prev): New. (_cpp_find_file): Use search_path_exhausted. (make_cpp_dir): Initialize construct to 0. * cpplib.h (missing_header_cb cpp_get_path, cpp_get_buffer, cpp_get_file, cpp_get_prev): New. (cpp_callbacks): Add missing_header (cpp_dir): Add construct. * target-def.h: (TARGET_OPTF): New. * hooks.c (hook_void_int, hook_void_charptr): Add. * hooks.h (hook_void_int, hook_void_charptr): Add. * Makefile.in (c-incpath.o) : Add $(TARGET_H) and $(MACHMODE_H) dependencies. * doc/invoke.texi (Darwin Options): Document -F. * doc/tm.texi (TARGET_EXTRA_INCLUDES): Add. (TARGET_OPTF): Add. * fix-header.c (target_c_incpath): Add. * config/darwin-c.c: Add c-incpath.h include. (using_frameworks, find_subframework_file, find_subframework_header, add_system_framework_path, frameworks_in_use, num_frameworks, max_frameworks, add_framework, find_framework, struct framework_header, framework_header_dirs, framework_construct_pathname, find_subframework_file, add_system_framework_path, add_framework_path, framework_defaults, darwin_register_frameworks, find_subframework_header): Add. * config/darwin.h (TARGET_EXTRA_INCLUDES, TARGET_OPTF): New. (TARGET_OPTION_TRANSLATE_TABLE): Add -framework support. (CPP_SPEC): Add __APPLE_CC__ support. * t-darwin (darwin-c.o): Add c-incpath.h dependency. From-SVN: r78875
2004-03-04 01:18:54 +01:00
return true;
}
free (path);
file->path = file->name;
}
else
{
file->err_no = ENOENT;
file->path = NULL;
}
return false;
}
Add framework support for darwin. * c-incpath.c: Include target.h and machmode.h. (add_path): Use a consistent style for cpp_dir. Initialize p->construct to 0. (add_cpp_dir_path): New. (register_include_chains): Add use of extra_includes callback. (hook_void_int): Add. (target_c_incpath): Add. * c-incpath.h (add_cpp_dir_path): New. (target_c_incpath_s): Add. (target_c_incpath): Add. (C_INCPATH_INIT): Add. * c-opts.c (c_common_missing_argument, c_common_handle_option): Add -F argument processing. * c.opt: Add -F argument processing. * gcc.c (trad_capable_cpp): Add -F argument processing. * cppfiles.c (find_file_in_dir): Update to use construct callback. (search_path_exhausted, cpp_get_path, cpp_get_buffer, cpp_get_prev): New. (_cpp_find_file): Use search_path_exhausted. (make_cpp_dir): Initialize construct to 0. * cpplib.h (missing_header_cb cpp_get_path, cpp_get_buffer, cpp_get_file, cpp_get_prev): New. (cpp_callbacks): Add missing_header (cpp_dir): Add construct. * target-def.h: (TARGET_OPTF): New. * hooks.c (hook_void_int, hook_void_charptr): Add. * hooks.h (hook_void_int, hook_void_charptr): Add. * Makefile.in (c-incpath.o) : Add $(TARGET_H) and $(MACHMODE_H) dependencies. * doc/invoke.texi (Darwin Options): Document -F. * doc/tm.texi (TARGET_EXTRA_INCLUDES): Add. (TARGET_OPTF): Add. * fix-header.c (target_c_incpath): Add. * config/darwin-c.c: Add c-incpath.h include. (using_frameworks, find_subframework_file, find_subframework_header, add_system_framework_path, frameworks_in_use, num_frameworks, max_frameworks, add_framework, find_framework, struct framework_header, framework_header_dirs, framework_construct_pathname, find_subframework_file, add_system_framework_path, add_framework_path, framework_defaults, darwin_register_frameworks, find_subframework_header): Add. * config/darwin.h (TARGET_EXTRA_INCLUDES, TARGET_OPTF): New. (TARGET_OPTION_TRANSLATE_TABLE): Add -framework support. (CPP_SPEC): Add __APPLE_CC__ support. * t-darwin (darwin-c.o): Add c-incpath.h dependency. From-SVN: r78875
2004-03-04 01:18:54 +01:00
/* Return tue iff the missing_header callback found the given HEADER. */
static bool
search_path_exhausted (cpp_reader *pfile, const char *header, _cpp_file *file)
{
missing_header_cb func = pfile->cb.missing_header;
/* When the regular search path doesn't work, try context dependent
headers search paths. */
if (func
&& file->dir == NULL)
{
if ((file->path = func (pfile, header, &file->dir)) != NULL)
Add framework support for darwin. * c-incpath.c: Include target.h and machmode.h. (add_path): Use a consistent style for cpp_dir. Initialize p->construct to 0. (add_cpp_dir_path): New. (register_include_chains): Add use of extra_includes callback. (hook_void_int): Add. (target_c_incpath): Add. * c-incpath.h (add_cpp_dir_path): New. (target_c_incpath_s): Add. (target_c_incpath): Add. (C_INCPATH_INIT): Add. * c-opts.c (c_common_missing_argument, c_common_handle_option): Add -F argument processing. * c.opt: Add -F argument processing. * gcc.c (trad_capable_cpp): Add -F argument processing. * cppfiles.c (find_file_in_dir): Update to use construct callback. (search_path_exhausted, cpp_get_path, cpp_get_buffer, cpp_get_prev): New. (_cpp_find_file): Use search_path_exhausted. (make_cpp_dir): Initialize construct to 0. * cpplib.h (missing_header_cb cpp_get_path, cpp_get_buffer, cpp_get_file, cpp_get_prev): New. (cpp_callbacks): Add missing_header (cpp_dir): Add construct. * target-def.h: (TARGET_OPTF): New. * hooks.c (hook_void_int, hook_void_charptr): Add. * hooks.h (hook_void_int, hook_void_charptr): Add. * Makefile.in (c-incpath.o) : Add $(TARGET_H) and $(MACHMODE_H) dependencies. * doc/invoke.texi (Darwin Options): Document -F. * doc/tm.texi (TARGET_EXTRA_INCLUDES): Add. (TARGET_OPTF): Add. * fix-header.c (target_c_incpath): Add. * config/darwin-c.c: Add c-incpath.h include. (using_frameworks, find_subframework_file, find_subframework_header, add_system_framework_path, frameworks_in_use, num_frameworks, max_frameworks, add_framework, find_framework, struct framework_header, framework_header_dirs, framework_construct_pathname, find_subframework_file, add_system_framework_path, add_framework_path, framework_defaults, darwin_register_frameworks, find_subframework_header): Add. * config/darwin.h (TARGET_EXTRA_INCLUDES, TARGET_OPTF): New. (TARGET_OPTION_TRANSLATE_TABLE): Add -framework support. (CPP_SPEC): Add __APPLE_CC__ support. * t-darwin (darwin-c.o): Add c-incpath.h dependency. From-SVN: r78875
2004-03-04 01:18:54 +01:00
{
if (open_file (file))
return true;
free ((void *)file->path);
}
file->path = file->name;
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
return false;
}
bool
_cpp_find_failed (_cpp_file *file)
{
return file->err_no != 0;
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Given a filename FNAME search for such a file in the include path
starting from START_DIR. If FNAME is the empty string it is
interpreted as STDIN if START_DIR is PFILE->no_search_path.
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
If the file is not found in the file cache fall back to the O/S and
add the result to our cache.
If the file was not found in the filesystem, or there was an error
opening it, then ERR_NO is nonzero and FD is -1. If the file was
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
found, then ERR_NO is zero and FD could be -1 or an open file
descriptor. FD can be -1 if the file was found in the cache and
had previously been closed. To open it again pass the return value
to open_file().
*/
_cpp_file *
_cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, bool fake, int angle_brackets)
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
{
struct file_hash_entry *entry, **hash_slot;
_cpp_file *file;
bool invalid_pch = false;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Ensure we get no confusion between cached files and directories. */
if (start_dir == NULL)
cpp_error (pfile, CPP_DL_ICE, "NULL directory in find_file");
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
hash_slot = (struct file_hash_entry **)
htab_find_slot_with_hash (pfile->file_hash, fname,
htab_hash_string (fname),
INSERT);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* First check the cache before we resort to memory allocation. */
entry = search_cache (*hash_slot, start_dir);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (entry)
return entry->u.file;
file = make_cpp_file (pfile, start_dir, fname);
/* Try each path in the include chain. */
for (; !fake ;)
{
if (find_file_in_dir (pfile, file, &invalid_pch))
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
break;
file->dir = file->dir->next;
if (file->dir == NULL)
{
Add framework support for darwin. * c-incpath.c: Include target.h and machmode.h. (add_path): Use a consistent style for cpp_dir. Initialize p->construct to 0. (add_cpp_dir_path): New. (register_include_chains): Add use of extra_includes callback. (hook_void_int): Add. (target_c_incpath): Add. * c-incpath.h (add_cpp_dir_path): New. (target_c_incpath_s): Add. (target_c_incpath): Add. (C_INCPATH_INIT): Add. * c-opts.c (c_common_missing_argument, c_common_handle_option): Add -F argument processing. * c.opt: Add -F argument processing. * gcc.c (trad_capable_cpp): Add -F argument processing. * cppfiles.c (find_file_in_dir): Update to use construct callback. (search_path_exhausted, cpp_get_path, cpp_get_buffer, cpp_get_prev): New. (_cpp_find_file): Use search_path_exhausted. (make_cpp_dir): Initialize construct to 0. * cpplib.h (missing_header_cb cpp_get_path, cpp_get_buffer, cpp_get_file, cpp_get_prev): New. (cpp_callbacks): Add missing_header (cpp_dir): Add construct. * target-def.h: (TARGET_OPTF): New. * hooks.c (hook_void_int, hook_void_charptr): Add. * hooks.h (hook_void_int, hook_void_charptr): Add. * Makefile.in (c-incpath.o) : Add $(TARGET_H) and $(MACHMODE_H) dependencies. * doc/invoke.texi (Darwin Options): Document -F. * doc/tm.texi (TARGET_EXTRA_INCLUDES): Add. (TARGET_OPTF): Add. * fix-header.c (target_c_incpath): Add. * config/darwin-c.c: Add c-incpath.h include. (using_frameworks, find_subframework_file, find_subframework_header, add_system_framework_path, frameworks_in_use, num_frameworks, max_frameworks, add_framework, find_framework, struct framework_header, framework_header_dirs, framework_construct_pathname, find_subframework_file, add_system_framework_path, add_framework_path, framework_defaults, darwin_register_frameworks, find_subframework_header): Add. * config/darwin.h (TARGET_EXTRA_INCLUDES, TARGET_OPTF): New. (TARGET_OPTION_TRANSLATE_TABLE): Add -framework support. (CPP_SPEC): Add __APPLE_CC__ support. * t-darwin (darwin-c.o): Add c-incpath.h dependency. From-SVN: r78875
2004-03-04 01:18:54 +01:00
if (search_path_exhausted (pfile, fname, file))
{
/* Although this file must not go in the cache, because
the file found might depend on things (like the current file)
that aren't represented in the cache, it still has to go in
the list of all files so that #import works. */
file->next_file = pfile->all_files;
pfile->all_files = file;
return file;
}
Add framework support for darwin. * c-incpath.c: Include target.h and machmode.h. (add_path): Use a consistent style for cpp_dir. Initialize p->construct to 0. (add_cpp_dir_path): New. (register_include_chains): Add use of extra_includes callback. (hook_void_int): Add. (target_c_incpath): Add. * c-incpath.h (add_cpp_dir_path): New. (target_c_incpath_s): Add. (target_c_incpath): Add. (C_INCPATH_INIT): Add. * c-opts.c (c_common_missing_argument, c_common_handle_option): Add -F argument processing. * c.opt: Add -F argument processing. * gcc.c (trad_capable_cpp): Add -F argument processing. * cppfiles.c (find_file_in_dir): Update to use construct callback. (search_path_exhausted, cpp_get_path, cpp_get_buffer, cpp_get_prev): New. (_cpp_find_file): Use search_path_exhausted. (make_cpp_dir): Initialize construct to 0. * cpplib.h (missing_header_cb cpp_get_path, cpp_get_buffer, cpp_get_file, cpp_get_prev): New. (cpp_callbacks): Add missing_header (cpp_dir): Add construct. * target-def.h: (TARGET_OPTF): New. * hooks.c (hook_void_int, hook_void_charptr): Add. * hooks.h (hook_void_int, hook_void_charptr): Add. * Makefile.in (c-incpath.o) : Add $(TARGET_H) and $(MACHMODE_H) dependencies. * doc/invoke.texi (Darwin Options): Document -F. * doc/tm.texi (TARGET_EXTRA_INCLUDES): Add. (TARGET_OPTF): Add. * fix-header.c (target_c_incpath): Add. * config/darwin-c.c: Add c-incpath.h include. (using_frameworks, find_subframework_file, find_subframework_header, add_system_framework_path, frameworks_in_use, num_frameworks, max_frameworks, add_framework, find_framework, struct framework_header, framework_header_dirs, framework_construct_pathname, find_subframework_file, add_system_framework_path, add_framework_path, framework_defaults, darwin_register_frameworks, find_subframework_header): Add. * config/darwin.h (TARGET_EXTRA_INCLUDES, TARGET_OPTF): New. (TARGET_OPTION_TRANSLATE_TABLE): Add -framework support. (CPP_SPEC): Add __APPLE_CC__ support. * t-darwin (darwin-c.o): Add c-incpath.h dependency. From-SVN: r78875
2004-03-04 01:18:54 +01:00
open_file_failed (pfile, file, angle_brackets);
if (invalid_pch)
{
[multiple changes] 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * c-opts.c (c_common_handle_option): Add -finput-charset. * c.opt: Ditto. * cppcharset.c (one_iso88591_to_utf8): Remove. (convert_iso88591_utf8): Ditto. (conversion_tab): Remove 8859-1 converter. (_cpp_input_to_utf8): Remove. (_cpp_init_iconv_buffer): Ditto. (_cpp_close_iconv_buffer): Ditto. (_cpp_convert_input): New function. (_cpp_default_encoding): Ditto. * cpphash.h: Add/remove prototypes for above. * cppfiles.c (read_file_guts): Use _cpp_convert_input. * cppinit.c (cpp_create_reader): Use _cpp_default_encoding for narrow execution and input character sets. * cpplib.c (cpp_push_buffer): Delete uses of removed functions. * doc/cppopts.texi: Document -finput-charset. 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * gcc.c-torture/execute/wchar_t-1.c: Add -finput-charset. 2004-01-29 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * testsuite/22_locale/collate/compare/wchar_t/2.cc: Remove xfail. Use -finput-charset. * testsuite/22_locale/collate/compare/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/compare/wchar_t/wrapped_locale.cc: Ditto * testsuite/22_locale/collate/hash/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_locale.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_locale.cc: Ditto. From-SVN: r77136
2004-02-02 21:20:58 +01:00
cpp_error (pfile, CPP_DL_ERROR,
"one or more PCH files were found, but they were invalid");
if (!cpp_get_options (pfile)->warn_invalid_pch)
[multiple changes] 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * c-opts.c (c_common_handle_option): Add -finput-charset. * c.opt: Ditto. * cppcharset.c (one_iso88591_to_utf8): Remove. (convert_iso88591_utf8): Ditto. (conversion_tab): Remove 8859-1 converter. (_cpp_input_to_utf8): Remove. (_cpp_init_iconv_buffer): Ditto. (_cpp_close_iconv_buffer): Ditto. (_cpp_convert_input): New function. (_cpp_default_encoding): Ditto. * cpphash.h: Add/remove prototypes for above. * cppfiles.c (read_file_guts): Use _cpp_convert_input. * cppinit.c (cpp_create_reader): Use _cpp_default_encoding for narrow execution and input character sets. * cpplib.c (cpp_push_buffer): Delete uses of removed functions. * doc/cppopts.texi: Document -finput-charset. 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * gcc.c-torture/execute/wchar_t-1.c: Add -finput-charset. 2004-01-29 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * testsuite/22_locale/collate/compare/wchar_t/2.cc: Remove xfail. Use -finput-charset. * testsuite/22_locale/collate/compare/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/compare/wchar_t/wrapped_locale.cc: Ditto * testsuite/22_locale/collate/hash/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_locale.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_locale.cc: Ditto. From-SVN: r77136
2004-02-02 21:20:58 +01:00
cpp_error (pfile, CPP_DL_ERROR,
"use -Winvalid-pch for more information");
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
break;
}
/* Only check the cache for the starting location (done above)
and the quote and bracket chain heads because there are no
other possible starting points for searches. */
if (file->dir != pfile->bracket_include
&& file->dir != pfile->quote_include)
continue;
entry = search_cache (*hash_slot, file->dir);
if (entry)
break;
}
Makefile.am: Add makedepend. libcpp: * Makefile.am: Add makedepend. * Makefile.in, aclocal.m4: Regenerate. * charset.c: Insert a space to avoid a warning. * directives.c: Include mkdeps.h. (_cpp_handle_directive): Reenable macro expander if appropriate. (undefine_macros): Inline body of _cpp_free_definition for speed. Do not call undef callback or _cpp_warn_if_unused_macro. (cpp_get_deps): New interface. * files.c (search_cache): Add pfile argument. Check for file that would be found by "" or <> search here... (_cpp_find_file): ...not here. Correct recorded start_dir of files found by directory-of-current-file search that would be found by "" or <> search. * init.c (cpp_add_dependency_target): Delete. * internal.h (struct lexer_state): Add discarding_output flag. * lex.c (lex_identifier): Compute hash function while scanning. * macro.c (cpp_scan_nooutput): Disable macro expansion outside directives. * makedepend.c: New file. * mkdeps.c (struct deps): Add vpath vector. (apply_vpath, deps_add_vpath): New function. (deps_free): Free vpath vector. (deps_add_dep, deps_add_target): Use apply_vpath. * symtab.c (calc_hash): Use HT_HASHSTEP and HT_FINISH. (ht_lookup_with_hash): New function. * cpplib.h, mkdeps.h: Update prototypes. * symtab.h: Update prototypes. (HT_HASHSTEP, HT_FINISH): New macros. gcc: * Makefile.in (MKDEPS_H): New shorthand. (c-opts.o): Update dependencies. * c-opts.c: Include mkdeps.h. (handle_deferred_opts): Use cpp_get_deps and deps_add_target, not cpp_add_dependency_target. From-SVN: r82654
2004-06-05 22:58:06 +02:00
if (entry)
{
/* Cache for START_DIR too, sharing the _cpp_file structure. */
free ((char *) file->name);
free (file);
file = entry->u.file;
}
else
{
/* This is a new file; put it in the list. */
file->next_file = pfile->all_files;
pfile->all_files = file;
Makefile.am: Add makedepend. libcpp: * Makefile.am: Add makedepend. * Makefile.in, aclocal.m4: Regenerate. * charset.c: Insert a space to avoid a warning. * directives.c: Include mkdeps.h. (_cpp_handle_directive): Reenable macro expander if appropriate. (undefine_macros): Inline body of _cpp_free_definition for speed. Do not call undef callback or _cpp_warn_if_unused_macro. (cpp_get_deps): New interface. * files.c (search_cache): Add pfile argument. Check for file that would be found by "" or <> search here... (_cpp_find_file): ...not here. Correct recorded start_dir of files found by directory-of-current-file search that would be found by "" or <> search. * init.c (cpp_add_dependency_target): Delete. * internal.h (struct lexer_state): Add discarding_output flag. * lex.c (lex_identifier): Compute hash function while scanning. * macro.c (cpp_scan_nooutput): Disable macro expansion outside directives. * makedepend.c: New file. * mkdeps.c (struct deps): Add vpath vector. (apply_vpath, deps_add_vpath): New function. (deps_free): Free vpath vector. (deps_add_dep, deps_add_target): Use apply_vpath. * symtab.c (calc_hash): Use HT_HASHSTEP and HT_FINISH. (ht_lookup_with_hash): New function. * cpplib.h, mkdeps.h: Update prototypes. * symtab.h: Update prototypes. (HT_HASHSTEP, HT_FINISH): New macros. gcc: * Makefile.in (MKDEPS_H): New shorthand. (c-opts.o): Update dependencies. * c-opts.c: Include mkdeps.h. (handle_deferred_opts): Use cpp_get_deps and deps_add_target, not cpp_add_dependency_target. From-SVN: r82654
2004-06-05 22:58:06 +02:00
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Store this new result in the hash table. */
entry = new_file_hash_entry (pfile);
entry->next = *hash_slot;
entry->start_dir = start_dir;
entry->u.file = file;
*hash_slot = entry;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
return file;
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Read a file into FILE->buffer, returning true on success.
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
If FILE->fd is something weird, like a block device, we don't want
to read it at all. Don't even try to figure out what something is,
except for plain files and block devices, since there is no
reliable portable way of doing this.
FIXME: Flush file cache and try again if we run out of memory. */
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
static bool
read_file_guts (cpp_reader *pfile, _cpp_file *file)
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
ssize_t size, total, count;
uchar *buf;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
bool regular;
[multiple changes] 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * c-opts.c (c_common_handle_option): Add -finput-charset. * c.opt: Ditto. * cppcharset.c (one_iso88591_to_utf8): Remove. (convert_iso88591_utf8): Ditto. (conversion_tab): Remove 8859-1 converter. (_cpp_input_to_utf8): Remove. (_cpp_init_iconv_buffer): Ditto. (_cpp_close_iconv_buffer): Ditto. (_cpp_convert_input): New function. (_cpp_default_encoding): Ditto. * cpphash.h: Add/remove prototypes for above. * cppfiles.c (read_file_guts): Use _cpp_convert_input. * cppinit.c (cpp_create_reader): Use _cpp_default_encoding for narrow execution and input character sets. * cpplib.c (cpp_push_buffer): Delete uses of removed functions. * doc/cppopts.texi: Document -finput-charset. 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * gcc.c-torture/execute/wchar_t-1.c: Add -finput-charset. 2004-01-29 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * testsuite/22_locale/collate/compare/wchar_t/2.cc: Remove xfail. Use -finput-charset. * testsuite/22_locale/collate/compare/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/compare/wchar_t/wrapped_locale.cc: Ditto * testsuite/22_locale/collate/hash/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_locale.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_locale.cc: Ditto. From-SVN: r77136
2004-02-02 21:20:58 +01:00
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (S_ISBLK (file->st.st_mode))
{
cpp_error (pfile, CPP_DL_ERROR, "%s is a block device", file->path);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
return false;
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
regular = S_ISREG (file->st.st_mode);
if (regular)
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 01:29:45 +02: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. */
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (file->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 01:29:45 +02:00
{
cpp_error (pfile, CPP_DL_ERROR, "%s is too large", file->path);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
return false;
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 01:29:45 +02:00
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
size = file->st.st_size;
}
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;
configure.ac: Check declarations for asprintf and vasprintf. * configure.ac: Check declarations for asprintf and vasprintf. * config.in: Regenerate. * configure: Likewise. * charset.c (conversion_loop): Use XRESIZEVEC. (convert_no_conversion): Likewise. (convert_using_iconv): Likewise. (init_iconv_desc): Cast return value of alloca. (cpp_host_to_exec_charset): Use XNEWVEC. (emit_numeric_escape): Use XRESIZEVEC. (cpp_interpret_string): Use XNEWVEC. (cpp_interpret_string): Use XRESIZEVEC. (_cpp_interpret_identifier): Cast return value of alloca. (_cpp_convert_input): Use XNEWVEC and XRESIZEVEC. * directives.c (glue_header_name): Use XNEWVEC and XRESIZEVEC. (parse_include): Use XNEWVEC. (insert_pragma_entry): Rename local variable "new" to "new_entry". (save_registered_pragmas): Cast return value of xmemdup. (destringize_and_run): Same for alloca. (parse_assertion): Likewise. (do_assert): Cast allocated storage to proper type. (cpp_define): Likewise. (_cpp_define_builtin): Likewise. (cpp_undef): Likewise. (handle_assertion): Likewise. (cpp_push_buffer): Rename local variable "new" to "new_buffer". * expr.c (CPP_UPLUS): Cast value to type cpp_ttype. (CPP_UMINUS): Likewise. (struct cpp_operator): Rename from struct operator. (_cpp_expand_op_stack): Use XRESIZEVEC. * files.c (pch_open_file): Use XNEWVEC. (pch_open_file): Use XRESIZEVEC. (read_file_guts): Use XNEWVEC and XRESIZEVEC. (dir_name_of_file): Use XNEWVEC. (make_cpp_file): Use XCNEW. (make_cpp_dir): Likewise. (allocate_file_hash_entries): USE XNEWVEC. (cpp_included): Cast return value of htab_find_with_hash. (append_file_to_dir): Use XNEWVEC. (read_filename_string): Likewise. Use XRESIZEVEC too. (read_name_map): Cast return value of alloca. Use XRESIZEVEC. (remap_filename): Use XNEWVEC. (struct pchf_entry): Move definition out of struct pchf_data. (_cpp_save_file_entries): Use XCNEWVAR. (_cpp_read_file_entries): Use XNEWVAR. * identifiers.c (alloc_node): Use XOBNEW. * init.c (cpp_create_reader): Use XCNEW. (cpp_init_builtins): Cast of b->value to enum builtin_type. (read_original_directory): Cast return value of alloca. * lex.c (add_line_note): Use XRESIZEVEC. (warn_about_normalization): Use XNEWVEC. (_cpp_lex_direct): Cast node->directive_index to (enum cpp_ttype). (new_buff): Use XNEWVEC. * line-map.c (linemap_add): Use XRESIZEVEC. * macro.c (builtin_macro): Cast return value of alloca. (paste_tokens): Likewise. (expand_arg): Use XNEWVEC and XRESIZEVEC. (_cpp_save_parameter): Use XRESIZEVEC. (create_iso_definition): Cast allocated storage to proper type. (_cpp_create_definition): Likewise. (cpp_macro_definition): Use XRESIZEVEC. * makedepend.c (add_clm): Use XNEW. (add_dir): Likewise. * mkdeps.c (munge): Use XNEWVEC. (deps_init): Use XCNEW. (deps_add_target): Use XRESIZEVEC. (deps_add_default_target): Cast return value of alloca. (deps_add_dep): Use XRESIZEVEC. (deps_add_vpath): Likewise. Use XNEWVEC too. (deps_restore): Likewise. * pch.c (save_idents): Use XNEW and XNEWVEC. (cpp_save_state): Use XNEW. (count_defs): Cast return value of htab_find. (write_defs): Likewise. (cpp_write_pch_deps): Use XNEWVEC. (collect_ht_nodes): Use XRESIZEVEC. (cpp_valid_state): Use XNEWVEC. (save_macros): Use XRESIZEVEC. Cast return value of xmemdup. * symtab.c (ht_create): Use XCNEW. (ht_lookup_with_hash): Cast return value of obstack_copy0. (ht_expand): Use XCNEWVEC. * system.h (HAVE_DESIGNATED_INITIALIZERS): False if __cplusplus. (bool): Do not define if __cplusplus. From-SVN: r100295
2005-05-28 17:52:48 +02:00
buf = XNEWVEC (uchar, size + 1);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
total = 0;
while ((count = read (file->fd, buf + total, size - total)) > 0)
{
total += count;
if (total == size)
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (regular)
break;
size *= 2;
configure.ac: Check declarations for asprintf and vasprintf. * configure.ac: Check declarations for asprintf and vasprintf. * config.in: Regenerate. * configure: Likewise. * charset.c (conversion_loop): Use XRESIZEVEC. (convert_no_conversion): Likewise. (convert_using_iconv): Likewise. (init_iconv_desc): Cast return value of alloca. (cpp_host_to_exec_charset): Use XNEWVEC. (emit_numeric_escape): Use XRESIZEVEC. (cpp_interpret_string): Use XNEWVEC. (cpp_interpret_string): Use XRESIZEVEC. (_cpp_interpret_identifier): Cast return value of alloca. (_cpp_convert_input): Use XNEWVEC and XRESIZEVEC. * directives.c (glue_header_name): Use XNEWVEC and XRESIZEVEC. (parse_include): Use XNEWVEC. (insert_pragma_entry): Rename local variable "new" to "new_entry". (save_registered_pragmas): Cast return value of xmemdup. (destringize_and_run): Same for alloca. (parse_assertion): Likewise. (do_assert): Cast allocated storage to proper type. (cpp_define): Likewise. (_cpp_define_builtin): Likewise. (cpp_undef): Likewise. (handle_assertion): Likewise. (cpp_push_buffer): Rename local variable "new" to "new_buffer". * expr.c (CPP_UPLUS): Cast value to type cpp_ttype. (CPP_UMINUS): Likewise. (struct cpp_operator): Rename from struct operator. (_cpp_expand_op_stack): Use XRESIZEVEC. * files.c (pch_open_file): Use XNEWVEC. (pch_open_file): Use XRESIZEVEC. (read_file_guts): Use XNEWVEC and XRESIZEVEC. (dir_name_of_file): Use XNEWVEC. (make_cpp_file): Use XCNEW. (make_cpp_dir): Likewise. (allocate_file_hash_entries): USE XNEWVEC. (cpp_included): Cast return value of htab_find_with_hash. (append_file_to_dir): Use XNEWVEC. (read_filename_string): Likewise. Use XRESIZEVEC too. (read_name_map): Cast return value of alloca. Use XRESIZEVEC. (remap_filename): Use XNEWVEC. (struct pchf_entry): Move definition out of struct pchf_data. (_cpp_save_file_entries): Use XCNEWVAR. (_cpp_read_file_entries): Use XNEWVAR. * identifiers.c (alloc_node): Use XOBNEW. * init.c (cpp_create_reader): Use XCNEW. (cpp_init_builtins): Cast of b->value to enum builtin_type. (read_original_directory): Cast return value of alloca. * lex.c (add_line_note): Use XRESIZEVEC. (warn_about_normalization): Use XNEWVEC. (_cpp_lex_direct): Cast node->directive_index to (enum cpp_ttype). (new_buff): Use XNEWVEC. * line-map.c (linemap_add): Use XRESIZEVEC. * macro.c (builtin_macro): Cast return value of alloca. (paste_tokens): Likewise. (expand_arg): Use XNEWVEC and XRESIZEVEC. (_cpp_save_parameter): Use XRESIZEVEC. (create_iso_definition): Cast allocated storage to proper type. (_cpp_create_definition): Likewise. (cpp_macro_definition): Use XRESIZEVEC. * makedepend.c (add_clm): Use XNEW. (add_dir): Likewise. * mkdeps.c (munge): Use XNEWVEC. (deps_init): Use XCNEW. (deps_add_target): Use XRESIZEVEC. (deps_add_default_target): Cast return value of alloca. (deps_add_dep): Use XRESIZEVEC. (deps_add_vpath): Likewise. Use XNEWVEC too. (deps_restore): Likewise. * pch.c (save_idents): Use XNEW and XNEWVEC. (cpp_save_state): Use XNEW. (count_defs): Cast return value of htab_find. (write_defs): Likewise. (cpp_write_pch_deps): Use XNEWVEC. (collect_ht_nodes): Use XRESIZEVEC. (cpp_valid_state): Use XNEWVEC. (save_macros): Use XRESIZEVEC. Cast return value of xmemdup. * symtab.c (ht_create): Use XCNEW. (ht_lookup_with_hash): Cast return value of obstack_copy0. (ht_expand): Use XCNEWVEC. * system.h (HAVE_DESIGNATED_INITIALIZERS): False if __cplusplus. (bool): Do not define if __cplusplus. From-SVN: r100295
2005-05-28 17:52:48 +02:00
buf = XRESIZEVEC (uchar, buf, size + 1);
}
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (count < 0)
{
cpp_errno (pfile, CPP_DL_ERROR, file->path);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
return false;
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (regular && total != size && STAT_SIZE_RELIABLE (file->st))
cpp_error (pfile, CPP_DL_WARNING,
"%s is shorter than expected", file->path);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
[multiple changes] 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * c-opts.c (c_common_handle_option): Add -finput-charset. * c.opt: Ditto. * cppcharset.c (one_iso88591_to_utf8): Remove. (convert_iso88591_utf8): Ditto. (conversion_tab): Remove 8859-1 converter. (_cpp_input_to_utf8): Remove. (_cpp_init_iconv_buffer): Ditto. (_cpp_close_iconv_buffer): Ditto. (_cpp_convert_input): New function. (_cpp_default_encoding): Ditto. * cpphash.h: Add/remove prototypes for above. * cppfiles.c (read_file_guts): Use _cpp_convert_input. * cppinit.c (cpp_create_reader): Use _cpp_default_encoding for narrow execution and input character sets. * cpplib.c (cpp_push_buffer): Delete uses of removed functions. * doc/cppopts.texi: Document -finput-charset. 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * gcc.c-torture/execute/wchar_t-1.c: Add -finput-charset. 2004-01-29 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * testsuite/22_locale/collate/compare/wchar_t/2.cc: Remove xfail. Use -finput-charset. * testsuite/22_locale/collate/compare/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/compare/wchar_t/wrapped_locale.cc: Ditto * testsuite/22_locale/collate/hash/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_locale.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_locale.cc: Ditto. From-SVN: r77136
2004-02-02 21:20:58 +01:00
file->buffer = _cpp_convert_input (pfile, CPP_OPTION (pfile, input_charset),
buf, size, total, &file->st.st_size);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
file->buffer_valid = true;
return true;
}
/* Convenience wrapper around read_file_guts that opens the file if
necessary and closes the file descriptor after reading. FILE must
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
have been passed through find_file() at some stage. */
static bool
read_file (cpp_reader *pfile, _cpp_file *file)
{
/* If we already have its contents in memory, succeed immediately. */
if (file->buffer_valid)
return true;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* If an earlier read failed for some reason don't try again. */
if (file->dont_read || file->err_no)
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 00:44:54 +01:00
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (file->fd == -1 && !open_file (file))
{
open_file_failed (pfile, file, 0);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
return false;
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 01:29:45 +02:00
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
file->dont_read = !read_file_guts (pfile, file);
close (file->fd);
file->fd = -1;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
return !file->dont_read;
}
/* Returns TRUE if FILE's contents have been successfully placed in
FILE->buffer and the file should be stacked, otherwise false. */
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
static bool
should_stack_file (cpp_reader *pfile, _cpp_file *file, bool import)
{
_cpp_file *f;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Skip once-only files. */
if (file->once_only)
return false;
[multiple changes] 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * c-opts.c (c_common_handle_option): Add -finput-charset. * c.opt: Ditto. * cppcharset.c (one_iso88591_to_utf8): Remove. (convert_iso88591_utf8): Ditto. (conversion_tab): Remove 8859-1 converter. (_cpp_input_to_utf8): Remove. (_cpp_init_iconv_buffer): Ditto. (_cpp_close_iconv_buffer): Ditto. (_cpp_convert_input): New function. (_cpp_default_encoding): Ditto. * cpphash.h: Add/remove prototypes for above. * cppfiles.c (read_file_guts): Use _cpp_convert_input. * cppinit.c (cpp_create_reader): Use _cpp_default_encoding for narrow execution and input character sets. * cpplib.c (cpp_push_buffer): Delete uses of removed functions. * doc/cppopts.texi: Document -finput-charset. 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * gcc.c-torture/execute/wchar_t-1.c: Add -finput-charset. 2004-01-29 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * testsuite/22_locale/collate/compare/wchar_t/2.cc: Remove xfail. Use -finput-charset. * testsuite/22_locale/collate/compare/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/compare/wchar_t/wrapped_locale.cc: Ditto * testsuite/22_locale/collate/hash/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_locale.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_locale.cc: Ditto. From-SVN: r77136
2004-02-02 21:20:58 +01:00
/* We must mark the file once-only if #import now, before header
guard checks. Otherwise, undefining the header guard might
cause the file to be re-stacked. */
if (import)
{
_cpp_mark_file_once_only (pfile, file);
/* Don't stack files that have been stacked before. */
if (file->stack_count)
return false;
}
/* Skip if the file had a header guard and the macro is defined.
PCH relies on this appearing before the PCH handler below. */
if (file->cmacro && file->cmacro->type == NT_MACRO)
return false;
/* Handle PCH files immediately; don't stack them. */
if (file->pch)
{
pfile->cb.read_pch (pfile, file->pchname, file->fd, file->path);
close (file->fd);
file->fd = -1;
return false;
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (!read_file (pfile, file))
return false;
/* Check the file against the PCH file. This is done before
checking against files we've already seen, since it may save on
I/O. */
if (check_file_against_entries (pfile, file, import))
{
/* If this isn't a #import, but yet we can't include the file,
that means that it was #import-ed in the PCH file,
so we can never include it again. */
if (! import)
_cpp_mark_file_once_only (pfile, file);
return false;
}
/* Now we've read the file's contents, we can stack it if there
are no once-only files. */
if (!pfile->seen_once_only)
return true;
/* We may have read the file under a different name. Look
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
for likely candidates and compare file contents to be sure. */
for (f = pfile->all_files; f; f = f->next_file)
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
{
if (f == file)
continue;
if ((import || f->once_only)
&& f->err_no == 0
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
&& f->st.st_mtime == file->st.st_mtime
&& f->st.st_size == file->st.st_size)
{
_cpp_file *ref_file;
bool same_file_p = false;
if (f->buffer && !f->buffer_valid)
{
/* We already have a buffer but it is not valid, because
the file is still stacked. Make a new one. */
ref_file = make_cpp_file (pfile, f->dir, f->name);
ref_file->path = f->path;
}
else
/* The file is not stacked anymore. We can reuse it. */
ref_file = f;
same_file_p = read_file (pfile, ref_file)
/* Size might have changed in read_file(). */
&& ref_file->st.st_size == file->st.st_size
&& !memcmp (ref_file->buffer,
file->buffer,
file->st.st_size);
if (f->buffer && !f->buffer_valid)
{
ref_file->path = 0;
destroy_cpp_file (ref_file);
}
if (same_file_p)
break;
}
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 12:56:54 +01:00
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
return f == NULL;
}
/* Place the file referenced by FILE into a new buffer on the buffer
stack if possible. IMPORT is true if this stacking attempt is
because of a #import directive. Returns true if a buffer is
stacked. */
bool
_cpp_stack_file (cpp_reader *pfile, _cpp_file *file, bool import)
{
cpp_buffer *buffer;
int sysp;
if (!should_stack_file (pfile, file, import))
return false;
Represent column numbers using line-map's source_location. The "next available source_location" is now managed internally by line-maps.c rather than by clients. * line-map.h (struct line_map): New field column_bits. <from_line>: Rename field to start_location. (struct line_maps): New fields highest_location and max_column_hint. (linemap_check_files_exited): New declaration. (linemap_line_start): New declaration. (linemap_add): Remove from_line parameter; use highest_location field. (SOURCE_LINE, LAST_SOURCE_LINE): Modify to use column_bits. (SOURCE_COLUMN, LAST_SOURCE_LINE_LOCATION): New macros. (CURRENT_LINE_MAP): Remove macro. (linemap_position_for_column): New inline function. * line-map.c (linemap_init): Clear new fields. (linemap_check_files_exited): New function, extracted from ... (linemap_free): Use linemap_check_files_exited. (linemap_add): Remove from_line parameter. Various updates. (linemap_line_start): New function. (linemap_lookeup): Update for new field names. * cpphash.h (struct cpp_reader) <map>: Field removed. Because linemap_position_for_column may unpredictably change the current map, it is cleaner and simpler for us to not cache it in cpp_reader. (struct cpp_buffer): New sysp field. Changed warned_cplusplus_comments and from_stage3 to bitfields. * cppinit.c (cpp_read_min_file): pfile->map no longer exists. * cpplib.c (do_line, do_linemarker, _cpp_do_file_change): Get current map using linemap_lookup. (do_linemarker): Also set buffer's sysp field. (destringize_and_run): No longer need to decrement current line. * cppfiles.c (_cpp_stack_file): Set sysp from and in buffer. (search_path_head, open_file_failed): Use buffer's sysp. (cpp_make_system_header): Get current map using linemap_lookup. Also set buffer's sysp flag. * cppmacro.c (_cpp_builtin_macro_text): Likewise use linemap_lookup. * cpphash.h (CPP_INCREMENT_LINE): New macro. (struct cpp_buffer): Moved fields saved_cur, saved_rlimit to ... (struct cpp_reader): ... and adding saved_line_base field. * cpptrad.c (_cpp_overlay_buffer, _cpp_remove_overlay): Update accordingly. Don't adjust line. (_cpp_scan_out_logical_line): Use CPP_INCREMENT_LINE. * cpphash.c (CPP_IN_SYSTEM_HEADER): Replaced macro by ... (cpp_in_system_header): ... new inline function, using buffer's sysp. * cpperror.c (_cpp_begin_message): Update to use cpp_in_system_header. * cpplex.c (_cpp_lex_direct): Likewise. * cppmacro.c (_cpp_builtin_macro_text): Likewise. * cppmacro.c (_cpp_create_definition): Use buffer's sysp field. * cpplib.h (struct cpp_token): Rename line field to src_loc. Remove col field as it is now subsumed by src_loc. * cpperror.c: Update various field, parameter, and macro names. (print_location): If col==0, try SOURCE_COLUMN of line. (cpp_error): Use cur_token's src_loc field, rather than line+col. * cpplib.c (do_diagnostic): Token's src_loc fields replaces line+col. * cpplex.c (_cpp_process_line_notes, _cpp_lex_direct, _cpp_skip_block_comment): Use CPP_INCREMENT_LINE. (_cpp_temp_token): Replace cpp_token's line+col fields by src_loc. (_cpp_get_fresh_line): Don't need to adjust line for missing newline. (_cpp_lex_direct): Use linemap_position_for_column. * c-ppoutput.c (maybe_print_line, print_line): Don't take map parameter. Instead get it from the line_table global. Adjust callers. (print): Remove map field. Replace line field to src_line. (init_pp_output, account_for_newlines, maybe_print_line): Adjust. (cb_line_change): Use SOURCE_COLUMN. Minor optimizations. (pp_file_change): Use MAIN_FILE_P since we cannot checked print.map. Use LAST_SOURCE_LINE_LOCATION to "catch up" after #include. * cpptrad.c (copy_comment): Rename variable. * c-lex.c (map): Remove static variable, for same reason we removed cpp_reader's map field. (cb_line_change, cb_def_pragma, cb_define, cb_undef): Hence we need to call linemap_lookup. (cb_line_change): Token's line field replaced by src_loc. (fe_file_change): Use MAINFILE_P and LAST_SOURCE_LINE macros. Don't save new_map. * cpphash.h, cpperror.c, cpplib.h: Some renames of fileline to source_location. From-SVN: r77663
2004-02-11 16:29:30 +01:00
if (pfile->buffer == NULL || file->dir == NULL)
sysp = 0;
else
sysp = MAX (pfile->buffer->sysp, file->dir->sysp);
/* Add the file to the dependencies on its first inclusion. */
if (CPP_OPTION (pfile, deps.style) > !!sysp && !file->stack_count)
{
if (!file->main_file || !CPP_OPTION (pfile, deps.ignore_main_file))
deps_add_dep (pfile->deps, file->path);
}
/* Clear buffer_valid since _cpp_clean_line messes it up. */
file->buffer_valid = false;
file->stack_count++;
/* Stack the buffer. */
buffer = cpp_push_buffer (pfile, file->buffer, file->st.st_size,
CPP_OPTION (pfile, preprocessed));
buffer->file = file;
Represent column numbers using line-map's source_location. The "next available source_location" is now managed internally by line-maps.c rather than by clients. * line-map.h (struct line_map): New field column_bits. <from_line>: Rename field to start_location. (struct line_maps): New fields highest_location and max_column_hint. (linemap_check_files_exited): New declaration. (linemap_line_start): New declaration. (linemap_add): Remove from_line parameter; use highest_location field. (SOURCE_LINE, LAST_SOURCE_LINE): Modify to use column_bits. (SOURCE_COLUMN, LAST_SOURCE_LINE_LOCATION): New macros. (CURRENT_LINE_MAP): Remove macro. (linemap_position_for_column): New inline function. * line-map.c (linemap_init): Clear new fields. (linemap_check_files_exited): New function, extracted from ... (linemap_free): Use linemap_check_files_exited. (linemap_add): Remove from_line parameter. Various updates. (linemap_line_start): New function. (linemap_lookeup): Update for new field names. * cpphash.h (struct cpp_reader) <map>: Field removed. Because linemap_position_for_column may unpredictably change the current map, it is cleaner and simpler for us to not cache it in cpp_reader. (struct cpp_buffer): New sysp field. Changed warned_cplusplus_comments and from_stage3 to bitfields. * cppinit.c (cpp_read_min_file): pfile->map no longer exists. * cpplib.c (do_line, do_linemarker, _cpp_do_file_change): Get current map using linemap_lookup. (do_linemarker): Also set buffer's sysp field. (destringize_and_run): No longer need to decrement current line. * cppfiles.c (_cpp_stack_file): Set sysp from and in buffer. (search_path_head, open_file_failed): Use buffer's sysp. (cpp_make_system_header): Get current map using linemap_lookup. Also set buffer's sysp flag. * cppmacro.c (_cpp_builtin_macro_text): Likewise use linemap_lookup. * cpphash.h (CPP_INCREMENT_LINE): New macro. (struct cpp_buffer): Moved fields saved_cur, saved_rlimit to ... (struct cpp_reader): ... and adding saved_line_base field. * cpptrad.c (_cpp_overlay_buffer, _cpp_remove_overlay): Update accordingly. Don't adjust line. (_cpp_scan_out_logical_line): Use CPP_INCREMENT_LINE. * cpphash.c (CPP_IN_SYSTEM_HEADER): Replaced macro by ... (cpp_in_system_header): ... new inline function, using buffer's sysp. * cpperror.c (_cpp_begin_message): Update to use cpp_in_system_header. * cpplex.c (_cpp_lex_direct): Likewise. * cppmacro.c (_cpp_builtin_macro_text): Likewise. * cppmacro.c (_cpp_create_definition): Use buffer's sysp field. * cpplib.h (struct cpp_token): Rename line field to src_loc. Remove col field as it is now subsumed by src_loc. * cpperror.c: Update various field, parameter, and macro names. (print_location): If col==0, try SOURCE_COLUMN of line. (cpp_error): Use cur_token's src_loc field, rather than line+col. * cpplib.c (do_diagnostic): Token's src_loc fields replaces line+col. * cpplex.c (_cpp_process_line_notes, _cpp_lex_direct, _cpp_skip_block_comment): Use CPP_INCREMENT_LINE. (_cpp_temp_token): Replace cpp_token's line+col fields by src_loc. (_cpp_get_fresh_line): Don't need to adjust line for missing newline. (_cpp_lex_direct): Use linemap_position_for_column. * c-ppoutput.c (maybe_print_line, print_line): Don't take map parameter. Instead get it from the line_table global. Adjust callers. (print): Remove map field. Replace line field to src_line. (init_pp_output, account_for_newlines, maybe_print_line): Adjust. (cb_line_change): Use SOURCE_COLUMN. Minor optimizations. (pp_file_change): Use MAIN_FILE_P since we cannot checked print.map. Use LAST_SOURCE_LINE_LOCATION to "catch up" after #include. * cpptrad.c (copy_comment): Rename variable. * c-lex.c (map): Remove static variable, for same reason we removed cpp_reader's map field. (cb_line_change, cb_def_pragma, cb_define, cb_undef): Hence we need to call linemap_lookup. (cb_line_change): Token's line field replaced by src_loc. (fe_file_change): Use MAINFILE_P and LAST_SOURCE_LINE macros. Don't save new_map. * cpphash.h, cpperror.c, cpplib.h: Some renames of fileline to source_location. From-SVN: r77663
2004-02-11 16:29:30 +01:00
buffer->sysp = sysp;
/* Initialize controlling macro state. */
pfile->mi_valid = true;
pfile->mi_cmacro = 0;
/* Generate the call back. */
_cpp_do_file_change (pfile, LC_ENTER, file->path, 1, sysp);
return true;
[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 12:54:13 +01:00
}
/* Mark FILE to be included once only. */
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
void
_cpp_mark_file_once_only (cpp_reader *pfile, _cpp_file *file)
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 01:29:45 +02:00
{
pfile->seen_once_only = true;
file->once_only = true;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
}
/* Return the directory from which searching for FNAME should start,
considering the directive TYPE and ANGLE_BRACKETS. If there is
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
nothing left in the path, returns NULL. */
static struct cpp_dir *
search_path_head (cpp_reader *pfile, const char *fname, int angle_brackets,
enum include_type type)
{
cpp_dir *dir;
_cpp_file *file;
if (IS_ABSOLUTE_PATH (fname))
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
return &pfile->no_search_path;
/* pfile->buffer is NULL when processing an -include command-line flag. */
file = pfile->buffer == NULL ? pfile->main_file : pfile->buffer->file;
/* For #include_next, skip in the search path past the dir in which
the current file was found, but if it was found via an absolute
path use the normal search logic. */
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (type == IT_INCLUDE_NEXT && file->dir)
dir = file->dir->next;
else if (angle_brackets)
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
dir = pfile->bracket_include;
else if (type == IT_CMDLINE)
/* -include and -imacros use the #include "" chain with the
preprocessor's cwd prepended. */
return make_cpp_dir (pfile, "./", false);
else if (pfile->quote_ignores_source_dir)
dir = pfile->quote_include;
else
Represent column numbers using line-map's source_location. The "next available source_location" is now managed internally by line-maps.c rather than by clients. * line-map.h (struct line_map): New field column_bits. <from_line>: Rename field to start_location. (struct line_maps): New fields highest_location and max_column_hint. (linemap_check_files_exited): New declaration. (linemap_line_start): New declaration. (linemap_add): Remove from_line parameter; use highest_location field. (SOURCE_LINE, LAST_SOURCE_LINE): Modify to use column_bits. (SOURCE_COLUMN, LAST_SOURCE_LINE_LOCATION): New macros. (CURRENT_LINE_MAP): Remove macro. (linemap_position_for_column): New inline function. * line-map.c (linemap_init): Clear new fields. (linemap_check_files_exited): New function, extracted from ... (linemap_free): Use linemap_check_files_exited. (linemap_add): Remove from_line parameter. Various updates. (linemap_line_start): New function. (linemap_lookeup): Update for new field names. * cpphash.h (struct cpp_reader) <map>: Field removed. Because linemap_position_for_column may unpredictably change the current map, it is cleaner and simpler for us to not cache it in cpp_reader. (struct cpp_buffer): New sysp field. Changed warned_cplusplus_comments and from_stage3 to bitfields. * cppinit.c (cpp_read_min_file): pfile->map no longer exists. * cpplib.c (do_line, do_linemarker, _cpp_do_file_change): Get current map using linemap_lookup. (do_linemarker): Also set buffer's sysp field. (destringize_and_run): No longer need to decrement current line. * cppfiles.c (_cpp_stack_file): Set sysp from and in buffer. (search_path_head, open_file_failed): Use buffer's sysp. (cpp_make_system_header): Get current map using linemap_lookup. Also set buffer's sysp flag. * cppmacro.c (_cpp_builtin_macro_text): Likewise use linemap_lookup. * cpphash.h (CPP_INCREMENT_LINE): New macro. (struct cpp_buffer): Moved fields saved_cur, saved_rlimit to ... (struct cpp_reader): ... and adding saved_line_base field. * cpptrad.c (_cpp_overlay_buffer, _cpp_remove_overlay): Update accordingly. Don't adjust line. (_cpp_scan_out_logical_line): Use CPP_INCREMENT_LINE. * cpphash.c (CPP_IN_SYSTEM_HEADER): Replaced macro by ... (cpp_in_system_header): ... new inline function, using buffer's sysp. * cpperror.c (_cpp_begin_message): Update to use cpp_in_system_header. * cpplex.c (_cpp_lex_direct): Likewise. * cppmacro.c (_cpp_builtin_macro_text): Likewise. * cppmacro.c (_cpp_create_definition): Use buffer's sysp field. * cpplib.h (struct cpp_token): Rename line field to src_loc. Remove col field as it is now subsumed by src_loc. * cpperror.c: Update various field, parameter, and macro names. (print_location): If col==0, try SOURCE_COLUMN of line. (cpp_error): Use cur_token's src_loc field, rather than line+col. * cpplib.c (do_diagnostic): Token's src_loc fields replaces line+col. * cpplex.c (_cpp_process_line_notes, _cpp_lex_direct, _cpp_skip_block_comment): Use CPP_INCREMENT_LINE. (_cpp_temp_token): Replace cpp_token's line+col fields by src_loc. (_cpp_get_fresh_line): Don't need to adjust line for missing newline. (_cpp_lex_direct): Use linemap_position_for_column. * c-ppoutput.c (maybe_print_line, print_line): Don't take map parameter. Instead get it from the line_table global. Adjust callers. (print): Remove map field. Replace line field to src_line. (init_pp_output, account_for_newlines, maybe_print_line): Adjust. (cb_line_change): Use SOURCE_COLUMN. Minor optimizations. (pp_file_change): Use MAIN_FILE_P since we cannot checked print.map. Use LAST_SOURCE_LINE_LOCATION to "catch up" after #include. * cpptrad.c (copy_comment): Rename variable. * c-lex.c (map): Remove static variable, for same reason we removed cpp_reader's map field. (cb_line_change, cb_def_pragma, cb_define, cb_undef): Hence we need to call linemap_lookup. (cb_line_change): Token's line field replaced by src_loc. (fe_file_change): Use MAINFILE_P and LAST_SOURCE_LINE macros. Don't save new_map. * cpphash.h, cpperror.c, cpplib.h: Some renames of fileline to source_location. From-SVN: r77663
2004-02-11 16:29:30 +01:00
return make_cpp_dir (pfile, dir_name_of_file (file),
pfile->buffer ? pfile->buffer->sysp : 0);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (dir == NULL)
cpp_error (pfile, CPP_DL_ERROR,
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
"no include path in which to search for %s", fname);
return dir;
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Strip the basename from the file's path. It ends with a slash if
of nonzero length. Note that this procedure also works for
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
<stdin>, which is represented by the empty string. */
static const char *
dir_name_of_file (_cpp_file *file)
{
if (!file->dir_name)
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
size_t len = lbasename (file->path) - file->path;
configure.ac: Check declarations for asprintf and vasprintf. * configure.ac: Check declarations for asprintf and vasprintf. * config.in: Regenerate. * configure: Likewise. * charset.c (conversion_loop): Use XRESIZEVEC. (convert_no_conversion): Likewise. (convert_using_iconv): Likewise. (init_iconv_desc): Cast return value of alloca. (cpp_host_to_exec_charset): Use XNEWVEC. (emit_numeric_escape): Use XRESIZEVEC. (cpp_interpret_string): Use XNEWVEC. (cpp_interpret_string): Use XRESIZEVEC. (_cpp_interpret_identifier): Cast return value of alloca. (_cpp_convert_input): Use XNEWVEC and XRESIZEVEC. * directives.c (glue_header_name): Use XNEWVEC and XRESIZEVEC. (parse_include): Use XNEWVEC. (insert_pragma_entry): Rename local variable "new" to "new_entry". (save_registered_pragmas): Cast return value of xmemdup. (destringize_and_run): Same for alloca. (parse_assertion): Likewise. (do_assert): Cast allocated storage to proper type. (cpp_define): Likewise. (_cpp_define_builtin): Likewise. (cpp_undef): Likewise. (handle_assertion): Likewise. (cpp_push_buffer): Rename local variable "new" to "new_buffer". * expr.c (CPP_UPLUS): Cast value to type cpp_ttype. (CPP_UMINUS): Likewise. (struct cpp_operator): Rename from struct operator. (_cpp_expand_op_stack): Use XRESIZEVEC. * files.c (pch_open_file): Use XNEWVEC. (pch_open_file): Use XRESIZEVEC. (read_file_guts): Use XNEWVEC and XRESIZEVEC. (dir_name_of_file): Use XNEWVEC. (make_cpp_file): Use XCNEW. (make_cpp_dir): Likewise. (allocate_file_hash_entries): USE XNEWVEC. (cpp_included): Cast return value of htab_find_with_hash. (append_file_to_dir): Use XNEWVEC. (read_filename_string): Likewise. Use XRESIZEVEC too. (read_name_map): Cast return value of alloca. Use XRESIZEVEC. (remap_filename): Use XNEWVEC. (struct pchf_entry): Move definition out of struct pchf_data. (_cpp_save_file_entries): Use XCNEWVAR. (_cpp_read_file_entries): Use XNEWVAR. * identifiers.c (alloc_node): Use XOBNEW. * init.c (cpp_create_reader): Use XCNEW. (cpp_init_builtins): Cast of b->value to enum builtin_type. (read_original_directory): Cast return value of alloca. * lex.c (add_line_note): Use XRESIZEVEC. (warn_about_normalization): Use XNEWVEC. (_cpp_lex_direct): Cast node->directive_index to (enum cpp_ttype). (new_buff): Use XNEWVEC. * line-map.c (linemap_add): Use XRESIZEVEC. * macro.c (builtin_macro): Cast return value of alloca. (paste_tokens): Likewise. (expand_arg): Use XNEWVEC and XRESIZEVEC. (_cpp_save_parameter): Use XRESIZEVEC. (create_iso_definition): Cast allocated storage to proper type. (_cpp_create_definition): Likewise. (cpp_macro_definition): Use XRESIZEVEC. * makedepend.c (add_clm): Use XNEW. (add_dir): Likewise. * mkdeps.c (munge): Use XNEWVEC. (deps_init): Use XCNEW. (deps_add_target): Use XRESIZEVEC. (deps_add_default_target): Cast return value of alloca. (deps_add_dep): Use XRESIZEVEC. (deps_add_vpath): Likewise. Use XNEWVEC too. (deps_restore): Likewise. * pch.c (save_idents): Use XNEW and XNEWVEC. (cpp_save_state): Use XNEW. (count_defs): Cast return value of htab_find. (write_defs): Likewise. (cpp_write_pch_deps): Use XNEWVEC. (collect_ht_nodes): Use XRESIZEVEC. (cpp_valid_state): Use XNEWVEC. (save_macros): Use XRESIZEVEC. Cast return value of xmemdup. * symtab.c (ht_create): Use XCNEW. (ht_lookup_with_hash): Cast return value of obstack_copy0. (ht_expand): Use XCNEWVEC. * system.h (HAVE_DESIGNATED_INITIALIZERS): False if __cplusplus. (bool): Do not define if __cplusplus. From-SVN: r100295
2005-05-28 17:52:48 +02:00
char *dir_name = XNEWVEC (char, len + 1);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
memcpy (dir_name, file->path, len);
dir_name[len] = '\0';
file->dir_name = dir_name;
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
return file->dir_name;
}
/* Handles #include-family directives (distinguished by TYPE),
including HEADER, and the command line -imacros and -include.
Returns true if a buffer was stacked. */
bool
_cpp_stack_include (cpp_reader *pfile, const char *fname, int angle_brackets,
enum include_type type)
{
struct cpp_dir *dir;
_cpp_file *file;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
dir = search_path_head (pfile, fname, angle_brackets, type);
if (!dir)
return false;
file = _cpp_find_file (pfile, fname, dir, false, angle_brackets);
/* Compensate for the increment in linemap_add. In the case of a
normal #include, we're currently at the start of the line
*following* the #include. A separate source_location for this
location makes no sense (until we do the LC_LEAVE), and
complicates LAST_SOURCE_LINE_LOCATION. This does not apply if we
found a PCH file (in which case linemap_add is not called) or we
were included from the command-line. */
if (! file->pch && file->err_no == 0 && type != IT_CMDLINE)
pfile->line_table->highest_location--;
return _cpp_stack_file (pfile, file, type == IT_IMPORT);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
}
/* Could not open FILE. The complication is dependency output. */
static void
open_file_failed (cpp_reader *pfile, _cpp_file *file, int angle_brackets)
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
{
line-map.h (struct line_maps): New field highest_line. * line-map.h (struct line_maps): New field highest_line. (linemap_position_for_column): Make non-inline function. (LINEMAP_POSITION_FOR_COLUMN): New macro. * line-map.c (linemap_init): Clear highest_line field. (linemap_add): Set highest_line field. (linemap_line_start): Minor optimization - use highest_line field. Reduce maximum column hint to 10000. Update highest_line field. (linemap_position_for_column): Moved from line-map.h. Optimize a bit. * cpphash.h (struct cpp_reader): Remove line field - instead use line_table->highest_line. (saved_line): Remove unused field. (CPP_INCREMENT_FILE): Don't do linemap_lookup - just use newest map. Use line_table's highest_line field instead of cpp_reader's line. * cpplib.c (start_directive): Likewise use highest_line field. (do_line, do_linemarker): Likewise just use newest map. (_cpp_do_file_change): Don't need to set cpp_reader's line field. * cpperror.c (cpp_error): Likewise use highest_line field. * cppfiles.c (open_file_failed: Likewise. (cpp_make_system_header): Likewise use newest map and highest_line. * cppinit.c (cpp_create_reader): Don't initialize removed field. * cpplex.c (_cpp_process_line_notes, _cpp_skip_block_comment, skip_line_comment, skip_whitespace, _cpp_get_fresh_line, _cpp_lex_direct): Likewise use highest_line. (_cpp_lex_direct): Use new LINEMAP_POSITION_FOR_COLUMN macro. * cppmacro.c (_cpp_builtin_macro_text): Likewise use highest_line, and use newest map. * cpppch.c (cpp_read_state): Don't save+restore cpp_reader's line. * cpptrad.c (_cpp_overlay_buffer): Don't save cpp_reader's line. (copy_comment, _cpp_scan_out_logical_line): Likewise use highest_line. From-SVN: r81074
2004-04-23 04:22:27 +02:00
int sysp = pfile->line_table->highest_line > 1 && pfile->buffer ? pfile->buffer->sysp : 0;
bool print_dep = CPP_OPTION (pfile, deps.style) > (angle_brackets || !!sysp);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
errno = file->err_no;
if (print_dep && CPP_OPTION (pfile, deps.missing_files) && errno == ENOENT)
deps_add_dep (pfile->deps, file->name);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
else
[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 12:54:13 +01:00
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* If we are outputting dependencies but not for this file then
don't error because we can still produce correct output. */
if (CPP_OPTION (pfile, deps.style) && ! print_dep)
cpp_errno (pfile, CPP_DL_WARNING, file->path);
else
cpp_errno (pfile, CPP_DL_ERROR, file->path);
[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 12:54:13 +01:00
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Search in the chain beginning at HEAD for a file whose search path
started at START_DIR != NULL. */
static struct file_hash_entry *
search_cache (struct file_hash_entry *head, const cpp_dir *start_dir)
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
{
while (head && head->start_dir != start_dir)
head = head->next;
return head;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
}
/* Allocate a new _cpp_file structure. */
static _cpp_file *
make_cpp_file (cpp_reader *pfile, cpp_dir *dir, const char *fname)
{
_cpp_file *file;
configure.ac: Check declarations for asprintf and vasprintf. * configure.ac: Check declarations for asprintf and vasprintf. * config.in: Regenerate. * configure: Likewise. * charset.c (conversion_loop): Use XRESIZEVEC. (convert_no_conversion): Likewise. (convert_using_iconv): Likewise. (init_iconv_desc): Cast return value of alloca. (cpp_host_to_exec_charset): Use XNEWVEC. (emit_numeric_escape): Use XRESIZEVEC. (cpp_interpret_string): Use XNEWVEC. (cpp_interpret_string): Use XRESIZEVEC. (_cpp_interpret_identifier): Cast return value of alloca. (_cpp_convert_input): Use XNEWVEC and XRESIZEVEC. * directives.c (glue_header_name): Use XNEWVEC and XRESIZEVEC. (parse_include): Use XNEWVEC. (insert_pragma_entry): Rename local variable "new" to "new_entry". (save_registered_pragmas): Cast return value of xmemdup. (destringize_and_run): Same for alloca. (parse_assertion): Likewise. (do_assert): Cast allocated storage to proper type. (cpp_define): Likewise. (_cpp_define_builtin): Likewise. (cpp_undef): Likewise. (handle_assertion): Likewise. (cpp_push_buffer): Rename local variable "new" to "new_buffer". * expr.c (CPP_UPLUS): Cast value to type cpp_ttype. (CPP_UMINUS): Likewise. (struct cpp_operator): Rename from struct operator. (_cpp_expand_op_stack): Use XRESIZEVEC. * files.c (pch_open_file): Use XNEWVEC. (pch_open_file): Use XRESIZEVEC. (read_file_guts): Use XNEWVEC and XRESIZEVEC. (dir_name_of_file): Use XNEWVEC. (make_cpp_file): Use XCNEW. (make_cpp_dir): Likewise. (allocate_file_hash_entries): USE XNEWVEC. (cpp_included): Cast return value of htab_find_with_hash. (append_file_to_dir): Use XNEWVEC. (read_filename_string): Likewise. Use XRESIZEVEC too. (read_name_map): Cast return value of alloca. Use XRESIZEVEC. (remap_filename): Use XNEWVEC. (struct pchf_entry): Move definition out of struct pchf_data. (_cpp_save_file_entries): Use XCNEWVAR. (_cpp_read_file_entries): Use XNEWVAR. * identifiers.c (alloc_node): Use XOBNEW. * init.c (cpp_create_reader): Use XCNEW. (cpp_init_builtins): Cast of b->value to enum builtin_type. (read_original_directory): Cast return value of alloca. * lex.c (add_line_note): Use XRESIZEVEC. (warn_about_normalization): Use XNEWVEC. (_cpp_lex_direct): Cast node->directive_index to (enum cpp_ttype). (new_buff): Use XNEWVEC. * line-map.c (linemap_add): Use XRESIZEVEC. * macro.c (builtin_macro): Cast return value of alloca. (paste_tokens): Likewise. (expand_arg): Use XNEWVEC and XRESIZEVEC. (_cpp_save_parameter): Use XRESIZEVEC. (create_iso_definition): Cast allocated storage to proper type. (_cpp_create_definition): Likewise. (cpp_macro_definition): Use XRESIZEVEC. * makedepend.c (add_clm): Use XNEW. (add_dir): Likewise. * mkdeps.c (munge): Use XNEWVEC. (deps_init): Use XCNEW. (deps_add_target): Use XRESIZEVEC. (deps_add_default_target): Cast return value of alloca. (deps_add_dep): Use XRESIZEVEC. (deps_add_vpath): Likewise. Use XNEWVEC too. (deps_restore): Likewise. * pch.c (save_idents): Use XNEW and XNEWVEC. (cpp_save_state): Use XNEW. (count_defs): Cast return value of htab_find. (write_defs): Likewise. (cpp_write_pch_deps): Use XNEWVEC. (collect_ht_nodes): Use XRESIZEVEC. (cpp_valid_state): Use XNEWVEC. (save_macros): Use XRESIZEVEC. Cast return value of xmemdup. * symtab.c (ht_create): Use XCNEW. (ht_lookup_with_hash): Cast return value of obstack_copy0. (ht_expand): Use XCNEWVEC. * system.h (HAVE_DESIGNATED_INITIALIZERS): False if __cplusplus. (bool): Do not define if __cplusplus. From-SVN: r100295
2005-05-28 17:52:48 +02:00
file = XCNEW (_cpp_file);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
file->main_file = !pfile->buffer;
file->fd = -1;
file->dir = dir;
file->name = xstrdup (fname);
return file;
}
/* Release a _cpp_file structure. */
static void
destroy_cpp_file (_cpp_file *file)
{
if (file->buffer)
free ((void *) file->buffer);
free ((void *) file->name);
free (file);
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* A hash of directory names. The directory names are the path names
of files which contain a #include "", the included file name is
appended to this directories.
To avoid duplicate entries we follow the convention that all
non-empty directory names should end in a '/'. DIR_NAME must be
stored in permanently allocated memory. */
static cpp_dir *
make_cpp_dir (cpp_reader *pfile, const char *dir_name, int sysp)
{
struct file_hash_entry *entry, **hash_slot;
cpp_dir *dir;
hash_slot = (struct file_hash_entry **)
htab_find_slot_with_hash (pfile->dir_hash, dir_name,
htab_hash_string (dir_name),
INSERT);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Have we already hashed this directory? */
for (entry = *hash_slot; entry; entry = entry->next)
if (entry->start_dir == NULL)
return entry->u.dir;
configure.ac: Check declarations for asprintf and vasprintf. * configure.ac: Check declarations for asprintf and vasprintf. * config.in: Regenerate. * configure: Likewise. * charset.c (conversion_loop): Use XRESIZEVEC. (convert_no_conversion): Likewise. (convert_using_iconv): Likewise. (init_iconv_desc): Cast return value of alloca. (cpp_host_to_exec_charset): Use XNEWVEC. (emit_numeric_escape): Use XRESIZEVEC. (cpp_interpret_string): Use XNEWVEC. (cpp_interpret_string): Use XRESIZEVEC. (_cpp_interpret_identifier): Cast return value of alloca. (_cpp_convert_input): Use XNEWVEC and XRESIZEVEC. * directives.c (glue_header_name): Use XNEWVEC and XRESIZEVEC. (parse_include): Use XNEWVEC. (insert_pragma_entry): Rename local variable "new" to "new_entry". (save_registered_pragmas): Cast return value of xmemdup. (destringize_and_run): Same for alloca. (parse_assertion): Likewise. (do_assert): Cast allocated storage to proper type. (cpp_define): Likewise. (_cpp_define_builtin): Likewise. (cpp_undef): Likewise. (handle_assertion): Likewise. (cpp_push_buffer): Rename local variable "new" to "new_buffer". * expr.c (CPP_UPLUS): Cast value to type cpp_ttype. (CPP_UMINUS): Likewise. (struct cpp_operator): Rename from struct operator. (_cpp_expand_op_stack): Use XRESIZEVEC. * files.c (pch_open_file): Use XNEWVEC. (pch_open_file): Use XRESIZEVEC. (read_file_guts): Use XNEWVEC and XRESIZEVEC. (dir_name_of_file): Use XNEWVEC. (make_cpp_file): Use XCNEW. (make_cpp_dir): Likewise. (allocate_file_hash_entries): USE XNEWVEC. (cpp_included): Cast return value of htab_find_with_hash. (append_file_to_dir): Use XNEWVEC. (read_filename_string): Likewise. Use XRESIZEVEC too. (read_name_map): Cast return value of alloca. Use XRESIZEVEC. (remap_filename): Use XNEWVEC. (struct pchf_entry): Move definition out of struct pchf_data. (_cpp_save_file_entries): Use XCNEWVAR. (_cpp_read_file_entries): Use XNEWVAR. * identifiers.c (alloc_node): Use XOBNEW. * init.c (cpp_create_reader): Use XCNEW. (cpp_init_builtins): Cast of b->value to enum builtin_type. (read_original_directory): Cast return value of alloca. * lex.c (add_line_note): Use XRESIZEVEC. (warn_about_normalization): Use XNEWVEC. (_cpp_lex_direct): Cast node->directive_index to (enum cpp_ttype). (new_buff): Use XNEWVEC. * line-map.c (linemap_add): Use XRESIZEVEC. * macro.c (builtin_macro): Cast return value of alloca. (paste_tokens): Likewise. (expand_arg): Use XNEWVEC and XRESIZEVEC. (_cpp_save_parameter): Use XRESIZEVEC. (create_iso_definition): Cast allocated storage to proper type. (_cpp_create_definition): Likewise. (cpp_macro_definition): Use XRESIZEVEC. * makedepend.c (add_clm): Use XNEW. (add_dir): Likewise. * mkdeps.c (munge): Use XNEWVEC. (deps_init): Use XCNEW. (deps_add_target): Use XRESIZEVEC. (deps_add_default_target): Cast return value of alloca. (deps_add_dep): Use XRESIZEVEC. (deps_add_vpath): Likewise. Use XNEWVEC too. (deps_restore): Likewise. * pch.c (save_idents): Use XNEW and XNEWVEC. (cpp_save_state): Use XNEW. (count_defs): Cast return value of htab_find. (write_defs): Likewise. (cpp_write_pch_deps): Use XNEWVEC. (collect_ht_nodes): Use XRESIZEVEC. (cpp_valid_state): Use XNEWVEC. (save_macros): Use XRESIZEVEC. Cast return value of xmemdup. * symtab.c (ht_create): Use XCNEW. (ht_lookup_with_hash): Cast return value of obstack_copy0. (ht_expand): Use XCNEWVEC. * system.h (HAVE_DESIGNATED_INITIALIZERS): False if __cplusplus. (bool): Do not define if __cplusplus. From-SVN: r100295
2005-05-28 17:52:48 +02:00
dir = XCNEW (cpp_dir);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
dir->next = pfile->quote_include;
dir->name = (char *) dir_name;
dir->len = strlen (dir_name);
dir->sysp = sysp;
Add framework support for darwin. * c-incpath.c: Include target.h and machmode.h. (add_path): Use a consistent style for cpp_dir. Initialize p->construct to 0. (add_cpp_dir_path): New. (register_include_chains): Add use of extra_includes callback. (hook_void_int): Add. (target_c_incpath): Add. * c-incpath.h (add_cpp_dir_path): New. (target_c_incpath_s): Add. (target_c_incpath): Add. (C_INCPATH_INIT): Add. * c-opts.c (c_common_missing_argument, c_common_handle_option): Add -F argument processing. * c.opt: Add -F argument processing. * gcc.c (trad_capable_cpp): Add -F argument processing. * cppfiles.c (find_file_in_dir): Update to use construct callback. (search_path_exhausted, cpp_get_path, cpp_get_buffer, cpp_get_prev): New. (_cpp_find_file): Use search_path_exhausted. (make_cpp_dir): Initialize construct to 0. * cpplib.h (missing_header_cb cpp_get_path, cpp_get_buffer, cpp_get_file, cpp_get_prev): New. (cpp_callbacks): Add missing_header (cpp_dir): Add construct. * target-def.h: (TARGET_OPTF): New. * hooks.c (hook_void_int, hook_void_charptr): Add. * hooks.h (hook_void_int, hook_void_charptr): Add. * Makefile.in (c-incpath.o) : Add $(TARGET_H) and $(MACHMODE_H) dependencies. * doc/invoke.texi (Darwin Options): Document -F. * doc/tm.texi (TARGET_EXTRA_INCLUDES): Add. (TARGET_OPTF): Add. * fix-header.c (target_c_incpath): Add. * config/darwin-c.c: Add c-incpath.h include. (using_frameworks, find_subframework_file, find_subframework_header, add_system_framework_path, frameworks_in_use, num_frameworks, max_frameworks, add_framework, find_framework, struct framework_header, framework_header_dirs, framework_construct_pathname, find_subframework_file, add_system_framework_path, add_framework_path, framework_defaults, darwin_register_frameworks, find_subframework_header): Add. * config/darwin.h (TARGET_EXTRA_INCLUDES, TARGET_OPTF): New. (TARGET_OPTION_TRANSLATE_TABLE): Add -framework support. (CPP_SPEC): Add __APPLE_CC__ support. * t-darwin (darwin-c.o): Add c-incpath.h dependency. From-SVN: r78875
2004-03-04 01:18:54 +01:00
dir->construct = 0;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Store this new result in the hash table. */
entry = new_file_hash_entry (pfile);
entry->next = *hash_slot;
entry->start_dir = NULL;
entry->u.dir = dir;
*hash_slot = entry;
return dir;
}
/* Create a new block of memory for file hash entries. */
static void
allocate_file_hash_entries (cpp_reader *pfile)
{
pfile->file_hash_entries_used = 0;
pfile->file_hash_entries_allocated = 127;
configure.ac: Check declarations for asprintf and vasprintf. * configure.ac: Check declarations for asprintf and vasprintf. * config.in: Regenerate. * configure: Likewise. * charset.c (conversion_loop): Use XRESIZEVEC. (convert_no_conversion): Likewise. (convert_using_iconv): Likewise. (init_iconv_desc): Cast return value of alloca. (cpp_host_to_exec_charset): Use XNEWVEC. (emit_numeric_escape): Use XRESIZEVEC. (cpp_interpret_string): Use XNEWVEC. (cpp_interpret_string): Use XRESIZEVEC. (_cpp_interpret_identifier): Cast return value of alloca. (_cpp_convert_input): Use XNEWVEC and XRESIZEVEC. * directives.c (glue_header_name): Use XNEWVEC and XRESIZEVEC. (parse_include): Use XNEWVEC. (insert_pragma_entry): Rename local variable "new" to "new_entry". (save_registered_pragmas): Cast return value of xmemdup. (destringize_and_run): Same for alloca. (parse_assertion): Likewise. (do_assert): Cast allocated storage to proper type. (cpp_define): Likewise. (_cpp_define_builtin): Likewise. (cpp_undef): Likewise. (handle_assertion): Likewise. (cpp_push_buffer): Rename local variable "new" to "new_buffer". * expr.c (CPP_UPLUS): Cast value to type cpp_ttype. (CPP_UMINUS): Likewise. (struct cpp_operator): Rename from struct operator. (_cpp_expand_op_stack): Use XRESIZEVEC. * files.c (pch_open_file): Use XNEWVEC. (pch_open_file): Use XRESIZEVEC. (read_file_guts): Use XNEWVEC and XRESIZEVEC. (dir_name_of_file): Use XNEWVEC. (make_cpp_file): Use XCNEW. (make_cpp_dir): Likewise. (allocate_file_hash_entries): USE XNEWVEC. (cpp_included): Cast return value of htab_find_with_hash. (append_file_to_dir): Use XNEWVEC. (read_filename_string): Likewise. Use XRESIZEVEC too. (read_name_map): Cast return value of alloca. Use XRESIZEVEC. (remap_filename): Use XNEWVEC. (struct pchf_entry): Move definition out of struct pchf_data. (_cpp_save_file_entries): Use XCNEWVAR. (_cpp_read_file_entries): Use XNEWVAR. * identifiers.c (alloc_node): Use XOBNEW. * init.c (cpp_create_reader): Use XCNEW. (cpp_init_builtins): Cast of b->value to enum builtin_type. (read_original_directory): Cast return value of alloca. * lex.c (add_line_note): Use XRESIZEVEC. (warn_about_normalization): Use XNEWVEC. (_cpp_lex_direct): Cast node->directive_index to (enum cpp_ttype). (new_buff): Use XNEWVEC. * line-map.c (linemap_add): Use XRESIZEVEC. * macro.c (builtin_macro): Cast return value of alloca. (paste_tokens): Likewise. (expand_arg): Use XNEWVEC and XRESIZEVEC. (_cpp_save_parameter): Use XRESIZEVEC. (create_iso_definition): Cast allocated storage to proper type. (_cpp_create_definition): Likewise. (cpp_macro_definition): Use XRESIZEVEC. * makedepend.c (add_clm): Use XNEW. (add_dir): Likewise. * mkdeps.c (munge): Use XNEWVEC. (deps_init): Use XCNEW. (deps_add_target): Use XRESIZEVEC. (deps_add_default_target): Cast return value of alloca. (deps_add_dep): Use XRESIZEVEC. (deps_add_vpath): Likewise. Use XNEWVEC too. (deps_restore): Likewise. * pch.c (save_idents): Use XNEW and XNEWVEC. (cpp_save_state): Use XNEW. (count_defs): Cast return value of htab_find. (write_defs): Likewise. (cpp_write_pch_deps): Use XNEWVEC. (collect_ht_nodes): Use XRESIZEVEC. (cpp_valid_state): Use XNEWVEC. (save_macros): Use XRESIZEVEC. Cast return value of xmemdup. * symtab.c (ht_create): Use XCNEW. (ht_lookup_with_hash): Cast return value of obstack_copy0. (ht_expand): Use XCNEWVEC. * system.h (HAVE_DESIGNATED_INITIALIZERS): False if __cplusplus. (bool): Do not define if __cplusplus. From-SVN: r100295
2005-05-28 17:52:48 +02:00
pfile->file_hash_entries = XNEWVEC (struct file_hash_entry,
pfile->file_hash_entries_allocated);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
}
/* Return a new file hash entry. */
static struct file_hash_entry *
new_file_hash_entry (cpp_reader *pfile)
{
if (pfile->file_hash_entries_used == pfile->file_hash_entries_allocated)
allocate_file_hash_entries (pfile);
return &pfile->file_hash_entries[pfile->file_hash_entries_used++];
}
/* Returns TRUE if a file FNAME has ever been successfully opened.
This routine is not intended to correctly handle filenames aliased
by links or redundant . or .. traversals etc. */
bool
cpp_included (cpp_reader *pfile, const char *fname)
{
struct file_hash_entry *entry;
configure.ac: Check declarations for asprintf and vasprintf. * configure.ac: Check declarations for asprintf and vasprintf. * config.in: Regenerate. * configure: Likewise. * charset.c (conversion_loop): Use XRESIZEVEC. (convert_no_conversion): Likewise. (convert_using_iconv): Likewise. (init_iconv_desc): Cast return value of alloca. (cpp_host_to_exec_charset): Use XNEWVEC. (emit_numeric_escape): Use XRESIZEVEC. (cpp_interpret_string): Use XNEWVEC. (cpp_interpret_string): Use XRESIZEVEC. (_cpp_interpret_identifier): Cast return value of alloca. (_cpp_convert_input): Use XNEWVEC and XRESIZEVEC. * directives.c (glue_header_name): Use XNEWVEC and XRESIZEVEC. (parse_include): Use XNEWVEC. (insert_pragma_entry): Rename local variable "new" to "new_entry". (save_registered_pragmas): Cast return value of xmemdup. (destringize_and_run): Same for alloca. (parse_assertion): Likewise. (do_assert): Cast allocated storage to proper type. (cpp_define): Likewise. (_cpp_define_builtin): Likewise. (cpp_undef): Likewise. (handle_assertion): Likewise. (cpp_push_buffer): Rename local variable "new" to "new_buffer". * expr.c (CPP_UPLUS): Cast value to type cpp_ttype. (CPP_UMINUS): Likewise. (struct cpp_operator): Rename from struct operator. (_cpp_expand_op_stack): Use XRESIZEVEC. * files.c (pch_open_file): Use XNEWVEC. (pch_open_file): Use XRESIZEVEC. (read_file_guts): Use XNEWVEC and XRESIZEVEC. (dir_name_of_file): Use XNEWVEC. (make_cpp_file): Use XCNEW. (make_cpp_dir): Likewise. (allocate_file_hash_entries): USE XNEWVEC. (cpp_included): Cast return value of htab_find_with_hash. (append_file_to_dir): Use XNEWVEC. (read_filename_string): Likewise. Use XRESIZEVEC too. (read_name_map): Cast return value of alloca. Use XRESIZEVEC. (remap_filename): Use XNEWVEC. (struct pchf_entry): Move definition out of struct pchf_data. (_cpp_save_file_entries): Use XCNEWVAR. (_cpp_read_file_entries): Use XNEWVAR. * identifiers.c (alloc_node): Use XOBNEW. * init.c (cpp_create_reader): Use XCNEW. (cpp_init_builtins): Cast of b->value to enum builtin_type. (read_original_directory): Cast return value of alloca. * lex.c (add_line_note): Use XRESIZEVEC. (warn_about_normalization): Use XNEWVEC. (_cpp_lex_direct): Cast node->directive_index to (enum cpp_ttype). (new_buff): Use XNEWVEC. * line-map.c (linemap_add): Use XRESIZEVEC. * macro.c (builtin_macro): Cast return value of alloca. (paste_tokens): Likewise. (expand_arg): Use XNEWVEC and XRESIZEVEC. (_cpp_save_parameter): Use XRESIZEVEC. (create_iso_definition): Cast allocated storage to proper type. (_cpp_create_definition): Likewise. (cpp_macro_definition): Use XRESIZEVEC. * makedepend.c (add_clm): Use XNEW. (add_dir): Likewise. * mkdeps.c (munge): Use XNEWVEC. (deps_init): Use XCNEW. (deps_add_target): Use XRESIZEVEC. (deps_add_default_target): Cast return value of alloca. (deps_add_dep): Use XRESIZEVEC. (deps_add_vpath): Likewise. Use XNEWVEC too. (deps_restore): Likewise. * pch.c (save_idents): Use XNEW and XNEWVEC. (cpp_save_state): Use XNEW. (count_defs): Cast return value of htab_find. (write_defs): Likewise. (cpp_write_pch_deps): Use XNEWVEC. (collect_ht_nodes): Use XRESIZEVEC. (cpp_valid_state): Use XNEWVEC. (save_macros): Use XRESIZEVEC. Cast return value of xmemdup. * symtab.c (ht_create): Use XCNEW. (ht_lookup_with_hash): Cast return value of obstack_copy0. (ht_expand): Use XCNEWVEC. * system.h (HAVE_DESIGNATED_INITIALIZERS): False if __cplusplus. (bool): Do not define if __cplusplus. From-SVN: r100295
2005-05-28 17:52:48 +02:00
entry = (struct file_hash_entry *)
htab_find_with_hash (pfile->file_hash, fname, htab_hash_string (fname));
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
while (entry && (entry->start_dir == NULL || entry->u.file->err_no))
entry = entry->next;
return entry != NULL;
}
/* Calculate the hash value of a file hash entry P. */
static hashval_t
file_hash_hash (const void *p)
{
struct file_hash_entry *entry = (struct file_hash_entry *) p;
const char *hname;
if (entry->start_dir)
hname = entry->u.file->name;
else
hname = entry->u.dir->name;
return htab_hash_string (hname);
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Compare a string Q against a file hash entry P. */
static int
file_hash_eq (const void *p, const void *q)
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
{
struct file_hash_entry *entry = (struct file_hash_entry *) p;
const char *fname = (const char *) q;
const char *hname;
if (entry->start_dir)
hname = entry->u.file->name;
else
hname = entry->u.dir->name;
return strcmp (hname, fname) == 0;
}
/* Initialize everything in this source file. */
void
_cpp_init_files (cpp_reader *pfile)
{
pfile->file_hash = htab_create_alloc (127, file_hash_hash, file_hash_eq,
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
NULL, xcalloc, free);
pfile->dir_hash = htab_create_alloc (127, file_hash_hash, file_hash_eq,
NULL, xcalloc, free);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
allocate_file_hash_entries (pfile);
}
/* Finalize everything in this source file. */
void
_cpp_cleanup_files (cpp_reader *pfile)
{
htab_delete (pfile->file_hash);
htab_delete (pfile->dir_hash);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
}
/* Enter a file name in the hash for the sake of cpp_included. */
void
_cpp_fake_include (cpp_reader *pfile, const char *fname)
{
_cpp_find_file (pfile, fname, pfile->buffer->file->dir, true, 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 12:54:13 +01:00
}
/* Not everyone who wants to set system-header-ness on a buffer can
see the details of a buffer. This is an exported interface because
fix-header needs it. */
void
cpp_make_system_header (cpp_reader *pfile, int syshdr, int externc)
{
int flags = 0;
line-map.h (struct line_maps): New field highest_line. * line-map.h (struct line_maps): New field highest_line. (linemap_position_for_column): Make non-inline function. (LINEMAP_POSITION_FOR_COLUMN): New macro. * line-map.c (linemap_init): Clear highest_line field. (linemap_add): Set highest_line field. (linemap_line_start): Minor optimization - use highest_line field. Reduce maximum column hint to 10000. Update highest_line field. (linemap_position_for_column): Moved from line-map.h. Optimize a bit. * cpphash.h (struct cpp_reader): Remove line field - instead use line_table->highest_line. (saved_line): Remove unused field. (CPP_INCREMENT_FILE): Don't do linemap_lookup - just use newest map. Use line_table's highest_line field instead of cpp_reader's line. * cpplib.c (start_directive): Likewise use highest_line field. (do_line, do_linemarker): Likewise just use newest map. (_cpp_do_file_change): Don't need to set cpp_reader's line field. * cpperror.c (cpp_error): Likewise use highest_line field. * cppfiles.c (open_file_failed: Likewise. (cpp_make_system_header): Likewise use newest map and highest_line. * cppinit.c (cpp_create_reader): Don't initialize removed field. * cpplex.c (_cpp_process_line_notes, _cpp_skip_block_comment, skip_line_comment, skip_whitespace, _cpp_get_fresh_line, _cpp_lex_direct): Likewise use highest_line. (_cpp_lex_direct): Use new LINEMAP_POSITION_FOR_COLUMN macro. * cppmacro.c (_cpp_builtin_macro_text): Likewise use highest_line, and use newest map. * cpppch.c (cpp_read_state): Don't save+restore cpp_reader's line. * cpptrad.c (_cpp_overlay_buffer): Don't save cpp_reader's line. (copy_comment, _cpp_scan_out_logical_line): Likewise use highest_line. From-SVN: r81074
2004-04-23 04:22:27 +02:00
const struct line_maps *line_table = pfile->line_table;
const struct line_map *map = &line_table->maps[line_table->used-1];
/* 1 = system header, 2 = system header to be treated as C. */
if (syshdr)
flags = 1 + (externc != 0);
Represent column numbers using line-map's source_location. The "next available source_location" is now managed internally by line-maps.c rather than by clients. * line-map.h (struct line_map): New field column_bits. <from_line>: Rename field to start_location. (struct line_maps): New fields highest_location and max_column_hint. (linemap_check_files_exited): New declaration. (linemap_line_start): New declaration. (linemap_add): Remove from_line parameter; use highest_location field. (SOURCE_LINE, LAST_SOURCE_LINE): Modify to use column_bits. (SOURCE_COLUMN, LAST_SOURCE_LINE_LOCATION): New macros. (CURRENT_LINE_MAP): Remove macro. (linemap_position_for_column): New inline function. * line-map.c (linemap_init): Clear new fields. (linemap_check_files_exited): New function, extracted from ... (linemap_free): Use linemap_check_files_exited. (linemap_add): Remove from_line parameter. Various updates. (linemap_line_start): New function. (linemap_lookeup): Update for new field names. * cpphash.h (struct cpp_reader) <map>: Field removed. Because linemap_position_for_column may unpredictably change the current map, it is cleaner and simpler for us to not cache it in cpp_reader. (struct cpp_buffer): New sysp field. Changed warned_cplusplus_comments and from_stage3 to bitfields. * cppinit.c (cpp_read_min_file): pfile->map no longer exists. * cpplib.c (do_line, do_linemarker, _cpp_do_file_change): Get current map using linemap_lookup. (do_linemarker): Also set buffer's sysp field. (destringize_and_run): No longer need to decrement current line. * cppfiles.c (_cpp_stack_file): Set sysp from and in buffer. (search_path_head, open_file_failed): Use buffer's sysp. (cpp_make_system_header): Get current map using linemap_lookup. Also set buffer's sysp flag. * cppmacro.c (_cpp_builtin_macro_text): Likewise use linemap_lookup. * cpphash.h (CPP_INCREMENT_LINE): New macro. (struct cpp_buffer): Moved fields saved_cur, saved_rlimit to ... (struct cpp_reader): ... and adding saved_line_base field. * cpptrad.c (_cpp_overlay_buffer, _cpp_remove_overlay): Update accordingly. Don't adjust line. (_cpp_scan_out_logical_line): Use CPP_INCREMENT_LINE. * cpphash.c (CPP_IN_SYSTEM_HEADER): Replaced macro by ... (cpp_in_system_header): ... new inline function, using buffer's sysp. * cpperror.c (_cpp_begin_message): Update to use cpp_in_system_header. * cpplex.c (_cpp_lex_direct): Likewise. * cppmacro.c (_cpp_builtin_macro_text): Likewise. * cppmacro.c (_cpp_create_definition): Use buffer's sysp field. * cpplib.h (struct cpp_token): Rename line field to src_loc. Remove col field as it is now subsumed by src_loc. * cpperror.c: Update various field, parameter, and macro names. (print_location): If col==0, try SOURCE_COLUMN of line. (cpp_error): Use cur_token's src_loc field, rather than line+col. * cpplib.c (do_diagnostic): Token's src_loc fields replaces line+col. * cpplex.c (_cpp_process_line_notes, _cpp_lex_direct, _cpp_skip_block_comment): Use CPP_INCREMENT_LINE. (_cpp_temp_token): Replace cpp_token's line+col fields by src_loc. (_cpp_get_fresh_line): Don't need to adjust line for missing newline. (_cpp_lex_direct): Use linemap_position_for_column. * c-ppoutput.c (maybe_print_line, print_line): Don't take map parameter. Instead get it from the line_table global. Adjust callers. (print): Remove map field. Replace line field to src_line. (init_pp_output, account_for_newlines, maybe_print_line): Adjust. (cb_line_change): Use SOURCE_COLUMN. Minor optimizations. (pp_file_change): Use MAIN_FILE_P since we cannot checked print.map. Use LAST_SOURCE_LINE_LOCATION to "catch up" after #include. * cpptrad.c (copy_comment): Rename variable. * c-lex.c (map): Remove static variable, for same reason we removed cpp_reader's map field. (cb_line_change, cb_def_pragma, cb_define, cb_undef): Hence we need to call linemap_lookup. (cb_line_change): Token's line field replaced by src_loc. (fe_file_change): Use MAINFILE_P and LAST_SOURCE_LINE macros. Don't save new_map. * cpphash.h, cpperror.c, cpplib.h: Some renames of fileline to source_location. From-SVN: r77663
2004-02-11 16:29:30 +01:00
pfile->buffer->sysp = flags;
_cpp_do_file_change (pfile, LC_RENAME, map->to_file,
line-map.h (struct line_maps): New field highest_line. * line-map.h (struct line_maps): New field highest_line. (linemap_position_for_column): Make non-inline function. (LINEMAP_POSITION_FOR_COLUMN): New macro. * line-map.c (linemap_init): Clear highest_line field. (linemap_add): Set highest_line field. (linemap_line_start): Minor optimization - use highest_line field. Reduce maximum column hint to 10000. Update highest_line field. (linemap_position_for_column): Moved from line-map.h. Optimize a bit. * cpphash.h (struct cpp_reader): Remove line field - instead use line_table->highest_line. (saved_line): Remove unused field. (CPP_INCREMENT_FILE): Don't do linemap_lookup - just use newest map. Use line_table's highest_line field instead of cpp_reader's line. * cpplib.c (start_directive): Likewise use highest_line field. (do_line, do_linemarker): Likewise just use newest map. (_cpp_do_file_change): Don't need to set cpp_reader's line field. * cpperror.c (cpp_error): Likewise use highest_line field. * cppfiles.c (open_file_failed: Likewise. (cpp_make_system_header): Likewise use newest map and highest_line. * cppinit.c (cpp_create_reader): Don't initialize removed field. * cpplex.c (_cpp_process_line_notes, _cpp_skip_block_comment, skip_line_comment, skip_whitespace, _cpp_get_fresh_line, _cpp_lex_direct): Likewise use highest_line. (_cpp_lex_direct): Use new LINEMAP_POSITION_FOR_COLUMN macro. * cppmacro.c (_cpp_builtin_macro_text): Likewise use highest_line, and use newest map. * cpppch.c (cpp_read_state): Don't save+restore cpp_reader's line. * cpptrad.c (_cpp_overlay_buffer): Don't save cpp_reader's line. (copy_comment, _cpp_scan_out_logical_line): Likewise use highest_line. From-SVN: r81074
2004-04-23 04:22:27 +02:00
SOURCE_LINE (map, pfile->line_table->highest_line), flags);
}
/* Allow the client to change the current file. Used by the front end
to achieve pseudo-file names like <built-in>.
If REASON is LC_LEAVE, then NEW_NAME must be NULL. */
void
cpp_change_file (cpp_reader *pfile, enum lc_reason reason,
const char *new_name)
{
_cpp_do_file_change (pfile, reason, new_name, 1, 0);
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Callback function for htab_traverse. */
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 07:33:57 +02:00
static int
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
report_missing_guard (void **slot, void *b)
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 07:33:57 +02:00
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
struct file_hash_entry *entry = (struct file_hash_entry *) *slot;
int *bannerp = (int *) b;
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 07:33:57 +02:00
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Skip directories. */
if (entry->start_dir != NULL)
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 07:33:57 +02:00
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
_cpp_file *file = entry->u.file;
/* We don't want MI guard advice for the main file. */
if (file->cmacro == NULL && file->stack_count == 1 && !file->main_file)
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 07:33:57 +02:00
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (*bannerp == 0)
{
fputs (_("Multiple include guards may be useful for:\n"),
stderr);
*bannerp = 1;
}
fputs (entry->u.file->path, stderr);
putc ('\n', stderr);
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 07:33:57 +02:00
}
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
return 0;
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Report on all files that might benefit from a multiple include guard.
Triggered by -H. */
void
_cpp_report_missing_guards (cpp_reader *pfile)
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 07:34:11 +01:00
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
int banner = 0;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
htab_traverse (pfile->file_hash, report_missing_guard, &banner);
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 07:34:11 +01: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, return 1, otherwise 0. */
int
_cpp_compare_file_date (cpp_reader *pfile, const char *fname,
int angle_brackets)
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
_cpp_file *file;
struct cpp_dir *dir;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
dir = search_path_head (pfile, fname, angle_brackets, IT_INCLUDE);
if (!dir)
return -1;
file = _cpp_find_file (pfile, fname, dir, false, angle_brackets);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (file->err_no)
return -1;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (file->fd != -1)
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
close (file->fd);
file->fd = -1;
}
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 03:58:21 +02:00
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
return file->st.st_mtime > pfile->buffer->file->st.st_mtime;
}
/* Pushes the given file onto the buffer stack. Returns nonzero if
successful. */
bool
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
cpp_push_include (cpp_reader *pfile, const char *fname)
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
return _cpp_stack_include (pfile, fname, false, IT_CMDLINE);
}
/* Do appropriate cleanup when a file INC's buffer is popped off the
input stack. */
void
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
_cpp_pop_file_buffer (cpp_reader *pfile, _cpp_file *file)
{
/* Record the inclusion-preventing macro, which could be NULL
meaning no controlling macro. */
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (pfile->mi_valid && file->cmacro == NULL)
file->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-28 19:59:06 +02:00
/* Invalidate control macros in the #including file. */
pfile->mi_valid = false;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (file->buffer)
{
free ((void *) file->buffer);
file->buffer = NULL;
}
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Set the include chain for "" to QUOTE, for <> to BRACKET. If
QUOTE_IGNORES_SOURCE_DIR, then "" includes do not look in the
directory of the including file.
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
If BRACKET does not lie in the QUOTE chain, it is set to QUOTE. */
void
cpp_set_include_chains (cpp_reader *pfile, cpp_dir *quote, cpp_dir *bracket,
int quote_ignores_source_dir)
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
pfile->quote_include = quote;
pfile->bracket_include = quote;
pfile->quote_ignores_source_dir = quote_ignores_source_dir;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
for (; quote; quote = quote->next)
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
quote->name_map = NULL;
quote->len = strlen (quote->name);
if (quote == bracket)
pfile->bracket_include = bracket;
}
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Append the file name to the directory to create the path, but don't
turn / into // or // into ///; // may be a namespace escape. */
static char *
append_file_to_dir (const char *fname, cpp_dir *dir)
{
size_t dlen, flen;
char *path;
dlen = dir->len;
flen = strlen (fname);
configure.ac: Check declarations for asprintf and vasprintf. * configure.ac: Check declarations for asprintf and vasprintf. * config.in: Regenerate. * configure: Likewise. * charset.c (conversion_loop): Use XRESIZEVEC. (convert_no_conversion): Likewise. (convert_using_iconv): Likewise. (init_iconv_desc): Cast return value of alloca. (cpp_host_to_exec_charset): Use XNEWVEC. (emit_numeric_escape): Use XRESIZEVEC. (cpp_interpret_string): Use XNEWVEC. (cpp_interpret_string): Use XRESIZEVEC. (_cpp_interpret_identifier): Cast return value of alloca. (_cpp_convert_input): Use XNEWVEC and XRESIZEVEC. * directives.c (glue_header_name): Use XNEWVEC and XRESIZEVEC. (parse_include): Use XNEWVEC. (insert_pragma_entry): Rename local variable "new" to "new_entry". (save_registered_pragmas): Cast return value of xmemdup. (destringize_and_run): Same for alloca. (parse_assertion): Likewise. (do_assert): Cast allocated storage to proper type. (cpp_define): Likewise. (_cpp_define_builtin): Likewise. (cpp_undef): Likewise. (handle_assertion): Likewise. (cpp_push_buffer): Rename local variable "new" to "new_buffer". * expr.c (CPP_UPLUS): Cast value to type cpp_ttype. (CPP_UMINUS): Likewise. (struct cpp_operator): Rename from struct operator. (_cpp_expand_op_stack): Use XRESIZEVEC. * files.c (pch_open_file): Use XNEWVEC. (pch_open_file): Use XRESIZEVEC. (read_file_guts): Use XNEWVEC and XRESIZEVEC. (dir_name_of_file): Use XNEWVEC. (make_cpp_file): Use XCNEW. (make_cpp_dir): Likewise. (allocate_file_hash_entries): USE XNEWVEC. (cpp_included): Cast return value of htab_find_with_hash. (append_file_to_dir): Use XNEWVEC. (read_filename_string): Likewise. Use XRESIZEVEC too. (read_name_map): Cast return value of alloca. Use XRESIZEVEC. (remap_filename): Use XNEWVEC. (struct pchf_entry): Move definition out of struct pchf_data. (_cpp_save_file_entries): Use XCNEWVAR. (_cpp_read_file_entries): Use XNEWVAR. * identifiers.c (alloc_node): Use XOBNEW. * init.c (cpp_create_reader): Use XCNEW. (cpp_init_builtins): Cast of b->value to enum builtin_type. (read_original_directory): Cast return value of alloca. * lex.c (add_line_note): Use XRESIZEVEC. (warn_about_normalization): Use XNEWVEC. (_cpp_lex_direct): Cast node->directive_index to (enum cpp_ttype). (new_buff): Use XNEWVEC. * line-map.c (linemap_add): Use XRESIZEVEC. * macro.c (builtin_macro): Cast return value of alloca. (paste_tokens): Likewise. (expand_arg): Use XNEWVEC and XRESIZEVEC. (_cpp_save_parameter): Use XRESIZEVEC. (create_iso_definition): Cast allocated storage to proper type. (_cpp_create_definition): Likewise. (cpp_macro_definition): Use XRESIZEVEC. * makedepend.c (add_clm): Use XNEW. (add_dir): Likewise. * mkdeps.c (munge): Use XNEWVEC. (deps_init): Use XCNEW. (deps_add_target): Use XRESIZEVEC. (deps_add_default_target): Cast return value of alloca. (deps_add_dep): Use XRESIZEVEC. (deps_add_vpath): Likewise. Use XNEWVEC too. (deps_restore): Likewise. * pch.c (save_idents): Use XNEW and XNEWVEC. (cpp_save_state): Use XNEW. (count_defs): Cast return value of htab_find. (write_defs): Likewise. (cpp_write_pch_deps): Use XNEWVEC. (collect_ht_nodes): Use XRESIZEVEC. (cpp_valid_state): Use XNEWVEC. (save_macros): Use XRESIZEVEC. Cast return value of xmemdup. * symtab.c (ht_create): Use XCNEW. (ht_lookup_with_hash): Cast return value of obstack_copy0. (ht_expand): Use XCNEWVEC. * system.h (HAVE_DESIGNATED_INITIALIZERS): False if __cplusplus. (bool): Do not define if __cplusplus. From-SVN: r100295
2005-05-28 17:52:48 +02:00
path = XNEWVEC (char, dlen + 1 + flen + 1);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
memcpy (path, dir->name, dlen);
if (dlen && path[dlen - 1] != '/')
path[dlen++] = '/';
memcpy (&path[dlen], fname, flen + 1);
return path;
}
/* Read a space delimited string of unlimited length from a stdio
file F. */
static char *
read_filename_string (int ch, FILE *f)
{
char *alloc, *set;
int len;
len = 20;
configure.ac: Check declarations for asprintf and vasprintf. * configure.ac: Check declarations for asprintf and vasprintf. * config.in: Regenerate. * configure: Likewise. * charset.c (conversion_loop): Use XRESIZEVEC. (convert_no_conversion): Likewise. (convert_using_iconv): Likewise. (init_iconv_desc): Cast return value of alloca. (cpp_host_to_exec_charset): Use XNEWVEC. (emit_numeric_escape): Use XRESIZEVEC. (cpp_interpret_string): Use XNEWVEC. (cpp_interpret_string): Use XRESIZEVEC. (_cpp_interpret_identifier): Cast return value of alloca. (_cpp_convert_input): Use XNEWVEC and XRESIZEVEC. * directives.c (glue_header_name): Use XNEWVEC and XRESIZEVEC. (parse_include): Use XNEWVEC. (insert_pragma_entry): Rename local variable "new" to "new_entry". (save_registered_pragmas): Cast return value of xmemdup. (destringize_and_run): Same for alloca. (parse_assertion): Likewise. (do_assert): Cast allocated storage to proper type. (cpp_define): Likewise. (_cpp_define_builtin): Likewise. (cpp_undef): Likewise. (handle_assertion): Likewise. (cpp_push_buffer): Rename local variable "new" to "new_buffer". * expr.c (CPP_UPLUS): Cast value to type cpp_ttype. (CPP_UMINUS): Likewise. (struct cpp_operator): Rename from struct operator. (_cpp_expand_op_stack): Use XRESIZEVEC. * files.c (pch_open_file): Use XNEWVEC. (pch_open_file): Use XRESIZEVEC. (read_file_guts): Use XNEWVEC and XRESIZEVEC. (dir_name_of_file): Use XNEWVEC. (make_cpp_file): Use XCNEW. (make_cpp_dir): Likewise. (allocate_file_hash_entries): USE XNEWVEC. (cpp_included): Cast return value of htab_find_with_hash. (append_file_to_dir): Use XNEWVEC. (read_filename_string): Likewise. Use XRESIZEVEC too. (read_name_map): Cast return value of alloca. Use XRESIZEVEC. (remap_filename): Use XNEWVEC. (struct pchf_entry): Move definition out of struct pchf_data. (_cpp_save_file_entries): Use XCNEWVAR. (_cpp_read_file_entries): Use XNEWVAR. * identifiers.c (alloc_node): Use XOBNEW. * init.c (cpp_create_reader): Use XCNEW. (cpp_init_builtins): Cast of b->value to enum builtin_type. (read_original_directory): Cast return value of alloca. * lex.c (add_line_note): Use XRESIZEVEC. (warn_about_normalization): Use XNEWVEC. (_cpp_lex_direct): Cast node->directive_index to (enum cpp_ttype). (new_buff): Use XNEWVEC. * line-map.c (linemap_add): Use XRESIZEVEC. * macro.c (builtin_macro): Cast return value of alloca. (paste_tokens): Likewise. (expand_arg): Use XNEWVEC and XRESIZEVEC. (_cpp_save_parameter): Use XRESIZEVEC. (create_iso_definition): Cast allocated storage to proper type. (_cpp_create_definition): Likewise. (cpp_macro_definition): Use XRESIZEVEC. * makedepend.c (add_clm): Use XNEW. (add_dir): Likewise. * mkdeps.c (munge): Use XNEWVEC. (deps_init): Use XCNEW. (deps_add_target): Use XRESIZEVEC. (deps_add_default_target): Cast return value of alloca. (deps_add_dep): Use XRESIZEVEC. (deps_add_vpath): Likewise. Use XNEWVEC too. (deps_restore): Likewise. * pch.c (save_idents): Use XNEW and XNEWVEC. (cpp_save_state): Use XNEW. (count_defs): Cast return value of htab_find. (write_defs): Likewise. (cpp_write_pch_deps): Use XNEWVEC. (collect_ht_nodes): Use XRESIZEVEC. (cpp_valid_state): Use XNEWVEC. (save_macros): Use XRESIZEVEC. Cast return value of xmemdup. * symtab.c (ht_create): Use XCNEW. (ht_lookup_with_hash): Cast return value of obstack_copy0. (ht_expand): Use XCNEWVEC. * system.h (HAVE_DESIGNATED_INITIALIZERS): False if __cplusplus. (bool): Do not define if __cplusplus. From-SVN: r100295
2005-05-28 17:52:48 +02:00
set = alloc = XNEWVEC (char, len + 1);
if (! is_space (ch))
{
*set++ = ch;
while ((ch = getc (f)) != EOF && ! is_space (ch))
{
if (set - alloc == len)
{
len *= 2;
configure.ac: Check declarations for asprintf and vasprintf. * configure.ac: Check declarations for asprintf and vasprintf. * config.in: Regenerate. * configure: Likewise. * charset.c (conversion_loop): Use XRESIZEVEC. (convert_no_conversion): Likewise. (convert_using_iconv): Likewise. (init_iconv_desc): Cast return value of alloca. (cpp_host_to_exec_charset): Use XNEWVEC. (emit_numeric_escape): Use XRESIZEVEC. (cpp_interpret_string): Use XNEWVEC. (cpp_interpret_string): Use XRESIZEVEC. (_cpp_interpret_identifier): Cast return value of alloca. (_cpp_convert_input): Use XNEWVEC and XRESIZEVEC. * directives.c (glue_header_name): Use XNEWVEC and XRESIZEVEC. (parse_include): Use XNEWVEC. (insert_pragma_entry): Rename local variable "new" to "new_entry". (save_registered_pragmas): Cast return value of xmemdup. (destringize_and_run): Same for alloca. (parse_assertion): Likewise. (do_assert): Cast allocated storage to proper type. (cpp_define): Likewise. (_cpp_define_builtin): Likewise. (cpp_undef): Likewise. (handle_assertion): Likewise. (cpp_push_buffer): Rename local variable "new" to "new_buffer". * expr.c (CPP_UPLUS): Cast value to type cpp_ttype. (CPP_UMINUS): Likewise. (struct cpp_operator): Rename from struct operator. (_cpp_expand_op_stack): Use XRESIZEVEC. * files.c (pch_open_file): Use XNEWVEC. (pch_open_file): Use XRESIZEVEC. (read_file_guts): Use XNEWVEC and XRESIZEVEC. (dir_name_of_file): Use XNEWVEC. (make_cpp_file): Use XCNEW. (make_cpp_dir): Likewise. (allocate_file_hash_entries): USE XNEWVEC. (cpp_included): Cast return value of htab_find_with_hash. (append_file_to_dir): Use XNEWVEC. (read_filename_string): Likewise. Use XRESIZEVEC too. (read_name_map): Cast return value of alloca. Use XRESIZEVEC. (remap_filename): Use XNEWVEC. (struct pchf_entry): Move definition out of struct pchf_data. (_cpp_save_file_entries): Use XCNEWVAR. (_cpp_read_file_entries): Use XNEWVAR. * identifiers.c (alloc_node): Use XOBNEW. * init.c (cpp_create_reader): Use XCNEW. (cpp_init_builtins): Cast of b->value to enum builtin_type. (read_original_directory): Cast return value of alloca. * lex.c (add_line_note): Use XRESIZEVEC. (warn_about_normalization): Use XNEWVEC. (_cpp_lex_direct): Cast node->directive_index to (enum cpp_ttype). (new_buff): Use XNEWVEC. * line-map.c (linemap_add): Use XRESIZEVEC. * macro.c (builtin_macro): Cast return value of alloca. (paste_tokens): Likewise. (expand_arg): Use XNEWVEC and XRESIZEVEC. (_cpp_save_parameter): Use XRESIZEVEC. (create_iso_definition): Cast allocated storage to proper type. (_cpp_create_definition): Likewise. (cpp_macro_definition): Use XRESIZEVEC. * makedepend.c (add_clm): Use XNEW. (add_dir): Likewise. * mkdeps.c (munge): Use XNEWVEC. (deps_init): Use XCNEW. (deps_add_target): Use XRESIZEVEC. (deps_add_default_target): Cast return value of alloca. (deps_add_dep): Use XRESIZEVEC. (deps_add_vpath): Likewise. Use XNEWVEC too. (deps_restore): Likewise. * pch.c (save_idents): Use XNEW and XNEWVEC. (cpp_save_state): Use XNEW. (count_defs): Cast return value of htab_find. (write_defs): Likewise. (cpp_write_pch_deps): Use XNEWVEC. (collect_ht_nodes): Use XRESIZEVEC. (cpp_valid_state): Use XNEWVEC. (save_macros): Use XRESIZEVEC. Cast return value of xmemdup. * symtab.c (ht_create): Use XCNEW. (ht_lookup_with_hash): Cast return value of obstack_copy0. (ht_expand): Use XCNEWVEC. * system.h (HAVE_DESIGNATED_INITIALIZERS): False if __cplusplus. (bool): Do not define if __cplusplus. From-SVN: r100295
2005-05-28 17:52:48 +02:00
alloc = XRESIZEVEC (char, alloc, len + 1);
set = alloc + len / 2;
}
*set++ = ch;
}
}
*set = '\0';
ungetc (ch, f);
return alloc;
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Read the file name map file for DIR. */
static void
read_name_map (cpp_dir *dir)
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
static const char FILE_NAME_MAP_FILE[] = "header.gcc";
char *name;
FILE *f;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
size_t len, count = 0, room = 9;
len = dir->len;
configure.ac: Check declarations for asprintf and vasprintf. * configure.ac: Check declarations for asprintf and vasprintf. * config.in: Regenerate. * configure: Likewise. * charset.c (conversion_loop): Use XRESIZEVEC. (convert_no_conversion): Likewise. (convert_using_iconv): Likewise. (init_iconv_desc): Cast return value of alloca. (cpp_host_to_exec_charset): Use XNEWVEC. (emit_numeric_escape): Use XRESIZEVEC. (cpp_interpret_string): Use XNEWVEC. (cpp_interpret_string): Use XRESIZEVEC. (_cpp_interpret_identifier): Cast return value of alloca. (_cpp_convert_input): Use XNEWVEC and XRESIZEVEC. * directives.c (glue_header_name): Use XNEWVEC and XRESIZEVEC. (parse_include): Use XNEWVEC. (insert_pragma_entry): Rename local variable "new" to "new_entry". (save_registered_pragmas): Cast return value of xmemdup. (destringize_and_run): Same for alloca. (parse_assertion): Likewise. (do_assert): Cast allocated storage to proper type. (cpp_define): Likewise. (_cpp_define_builtin): Likewise. (cpp_undef): Likewise. (handle_assertion): Likewise. (cpp_push_buffer): Rename local variable "new" to "new_buffer". * expr.c (CPP_UPLUS): Cast value to type cpp_ttype. (CPP_UMINUS): Likewise. (struct cpp_operator): Rename from struct operator. (_cpp_expand_op_stack): Use XRESIZEVEC. * files.c (pch_open_file): Use XNEWVEC. (pch_open_file): Use XRESIZEVEC. (read_file_guts): Use XNEWVEC and XRESIZEVEC. (dir_name_of_file): Use XNEWVEC. (make_cpp_file): Use XCNEW. (make_cpp_dir): Likewise. (allocate_file_hash_entries): USE XNEWVEC. (cpp_included): Cast return value of htab_find_with_hash. (append_file_to_dir): Use XNEWVEC. (read_filename_string): Likewise. Use XRESIZEVEC too. (read_name_map): Cast return value of alloca. Use XRESIZEVEC. (remap_filename): Use XNEWVEC. (struct pchf_entry): Move definition out of struct pchf_data. (_cpp_save_file_entries): Use XCNEWVAR. (_cpp_read_file_entries): Use XNEWVAR. * identifiers.c (alloc_node): Use XOBNEW. * init.c (cpp_create_reader): Use XCNEW. (cpp_init_builtins): Cast of b->value to enum builtin_type. (read_original_directory): Cast return value of alloca. * lex.c (add_line_note): Use XRESIZEVEC. (warn_about_normalization): Use XNEWVEC. (_cpp_lex_direct): Cast node->directive_index to (enum cpp_ttype). (new_buff): Use XNEWVEC. * line-map.c (linemap_add): Use XRESIZEVEC. * macro.c (builtin_macro): Cast return value of alloca. (paste_tokens): Likewise. (expand_arg): Use XNEWVEC and XRESIZEVEC. (_cpp_save_parameter): Use XRESIZEVEC. (create_iso_definition): Cast allocated storage to proper type. (_cpp_create_definition): Likewise. (cpp_macro_definition): Use XRESIZEVEC. * makedepend.c (add_clm): Use XNEW. (add_dir): Likewise. * mkdeps.c (munge): Use XNEWVEC. (deps_init): Use XCNEW. (deps_add_target): Use XRESIZEVEC. (deps_add_default_target): Cast return value of alloca. (deps_add_dep): Use XRESIZEVEC. (deps_add_vpath): Likewise. Use XNEWVEC too. (deps_restore): Likewise. * pch.c (save_idents): Use XNEW and XNEWVEC. (cpp_save_state): Use XNEW. (count_defs): Cast return value of htab_find. (write_defs): Likewise. (cpp_write_pch_deps): Use XNEWVEC. (collect_ht_nodes): Use XRESIZEVEC. (cpp_valid_state): Use XNEWVEC. (save_macros): Use XRESIZEVEC. Cast return value of xmemdup. * symtab.c (ht_create): Use XCNEW. (ht_lookup_with_hash): Cast return value of obstack_copy0. (ht_expand): Use XCNEWVEC. * system.h (HAVE_DESIGNATED_INITIALIZERS): False if __cplusplus. (bool): Do not define if __cplusplus. From-SVN: r100295
2005-05-28 17:52:48 +02:00
name = (char *) alloca (len + sizeof (FILE_NAME_MAP_FILE) + 1);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
memcpy (name, dir->name, len);
if (len && name[len - 1] != '/')
name[len++] = '/';
strcpy (name + len, FILE_NAME_MAP_FILE);
f = fopen (name, "r");
configure.ac: Check declarations for asprintf and vasprintf. * configure.ac: Check declarations for asprintf and vasprintf. * config.in: Regenerate. * configure: Likewise. * charset.c (conversion_loop): Use XRESIZEVEC. (convert_no_conversion): Likewise. (convert_using_iconv): Likewise. (init_iconv_desc): Cast return value of alloca. (cpp_host_to_exec_charset): Use XNEWVEC. (emit_numeric_escape): Use XRESIZEVEC. (cpp_interpret_string): Use XNEWVEC. (cpp_interpret_string): Use XRESIZEVEC. (_cpp_interpret_identifier): Cast return value of alloca. (_cpp_convert_input): Use XNEWVEC and XRESIZEVEC. * directives.c (glue_header_name): Use XNEWVEC and XRESIZEVEC. (parse_include): Use XNEWVEC. (insert_pragma_entry): Rename local variable "new" to "new_entry". (save_registered_pragmas): Cast return value of xmemdup. (destringize_and_run): Same for alloca. (parse_assertion): Likewise. (do_assert): Cast allocated storage to proper type. (cpp_define): Likewise. (_cpp_define_builtin): Likewise. (cpp_undef): Likewise. (handle_assertion): Likewise. (cpp_push_buffer): Rename local variable "new" to "new_buffer". * expr.c (CPP_UPLUS): Cast value to type cpp_ttype. (CPP_UMINUS): Likewise. (struct cpp_operator): Rename from struct operator. (_cpp_expand_op_stack): Use XRESIZEVEC. * files.c (pch_open_file): Use XNEWVEC. (pch_open_file): Use XRESIZEVEC. (read_file_guts): Use XNEWVEC and XRESIZEVEC. (dir_name_of_file): Use XNEWVEC. (make_cpp_file): Use XCNEW. (make_cpp_dir): Likewise. (allocate_file_hash_entries): USE XNEWVEC. (cpp_included): Cast return value of htab_find_with_hash. (append_file_to_dir): Use XNEWVEC. (read_filename_string): Likewise. Use XRESIZEVEC too. (read_name_map): Cast return value of alloca. Use XRESIZEVEC. (remap_filename): Use XNEWVEC. (struct pchf_entry): Move definition out of struct pchf_data. (_cpp_save_file_entries): Use XCNEWVAR. (_cpp_read_file_entries): Use XNEWVAR. * identifiers.c (alloc_node): Use XOBNEW. * init.c (cpp_create_reader): Use XCNEW. (cpp_init_builtins): Cast of b->value to enum builtin_type. (read_original_directory): Cast return value of alloca. * lex.c (add_line_note): Use XRESIZEVEC. (warn_about_normalization): Use XNEWVEC. (_cpp_lex_direct): Cast node->directive_index to (enum cpp_ttype). (new_buff): Use XNEWVEC. * line-map.c (linemap_add): Use XRESIZEVEC. * macro.c (builtin_macro): Cast return value of alloca. (paste_tokens): Likewise. (expand_arg): Use XNEWVEC and XRESIZEVEC. (_cpp_save_parameter): Use XRESIZEVEC. (create_iso_definition): Cast allocated storage to proper type. (_cpp_create_definition): Likewise. (cpp_macro_definition): Use XRESIZEVEC. * makedepend.c (add_clm): Use XNEW. (add_dir): Likewise. * mkdeps.c (munge): Use XNEWVEC. (deps_init): Use XCNEW. (deps_add_target): Use XRESIZEVEC. (deps_add_default_target): Cast return value of alloca. (deps_add_dep): Use XRESIZEVEC. (deps_add_vpath): Likewise. Use XNEWVEC too. (deps_restore): Likewise. * pch.c (save_idents): Use XNEW and XNEWVEC. (cpp_save_state): Use XNEW. (count_defs): Cast return value of htab_find. (write_defs): Likewise. (cpp_write_pch_deps): Use XNEWVEC. (collect_ht_nodes): Use XRESIZEVEC. (cpp_valid_state): Use XNEWVEC. (save_macros): Use XRESIZEVEC. Cast return value of xmemdup. * symtab.c (ht_create): Use XCNEW. (ht_lookup_with_hash): Cast return value of obstack_copy0. (ht_expand): Use XCNEWVEC. * system.h (HAVE_DESIGNATED_INITIALIZERS): False if __cplusplus. (bool): Do not define if __cplusplus. From-SVN: r100295
2005-05-28 17:52:48 +02:00
dir->name_map = XNEWVEC (const char *, room);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Silently return NULL if we cannot open. */
if (f)
{
int ch;
while ((ch = getc (f)) != EOF)
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
char *to;
if (is_space (ch))
continue;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (count + 2 > room)
{
room += 8;
configure.ac: Check declarations for asprintf and vasprintf. * configure.ac: Check declarations for asprintf and vasprintf. * config.in: Regenerate. * configure: Likewise. * charset.c (conversion_loop): Use XRESIZEVEC. (convert_no_conversion): Likewise. (convert_using_iconv): Likewise. (init_iconv_desc): Cast return value of alloca. (cpp_host_to_exec_charset): Use XNEWVEC. (emit_numeric_escape): Use XRESIZEVEC. (cpp_interpret_string): Use XNEWVEC. (cpp_interpret_string): Use XRESIZEVEC. (_cpp_interpret_identifier): Cast return value of alloca. (_cpp_convert_input): Use XNEWVEC and XRESIZEVEC. * directives.c (glue_header_name): Use XNEWVEC and XRESIZEVEC. (parse_include): Use XNEWVEC. (insert_pragma_entry): Rename local variable "new" to "new_entry". (save_registered_pragmas): Cast return value of xmemdup. (destringize_and_run): Same for alloca. (parse_assertion): Likewise. (do_assert): Cast allocated storage to proper type. (cpp_define): Likewise. (_cpp_define_builtin): Likewise. (cpp_undef): Likewise. (handle_assertion): Likewise. (cpp_push_buffer): Rename local variable "new" to "new_buffer". * expr.c (CPP_UPLUS): Cast value to type cpp_ttype. (CPP_UMINUS): Likewise. (struct cpp_operator): Rename from struct operator. (_cpp_expand_op_stack): Use XRESIZEVEC. * files.c (pch_open_file): Use XNEWVEC. (pch_open_file): Use XRESIZEVEC. (read_file_guts): Use XNEWVEC and XRESIZEVEC. (dir_name_of_file): Use XNEWVEC. (make_cpp_file): Use XCNEW. (make_cpp_dir): Likewise. (allocate_file_hash_entries): USE XNEWVEC. (cpp_included): Cast return value of htab_find_with_hash. (append_file_to_dir): Use XNEWVEC. (read_filename_string): Likewise. Use XRESIZEVEC too. (read_name_map): Cast return value of alloca. Use XRESIZEVEC. (remap_filename): Use XNEWVEC. (struct pchf_entry): Move definition out of struct pchf_data. (_cpp_save_file_entries): Use XCNEWVAR. (_cpp_read_file_entries): Use XNEWVAR. * identifiers.c (alloc_node): Use XOBNEW. * init.c (cpp_create_reader): Use XCNEW. (cpp_init_builtins): Cast of b->value to enum builtin_type. (read_original_directory): Cast return value of alloca. * lex.c (add_line_note): Use XRESIZEVEC. (warn_about_normalization): Use XNEWVEC. (_cpp_lex_direct): Cast node->directive_index to (enum cpp_ttype). (new_buff): Use XNEWVEC. * line-map.c (linemap_add): Use XRESIZEVEC. * macro.c (builtin_macro): Cast return value of alloca. (paste_tokens): Likewise. (expand_arg): Use XNEWVEC and XRESIZEVEC. (_cpp_save_parameter): Use XRESIZEVEC. (create_iso_definition): Cast allocated storage to proper type. (_cpp_create_definition): Likewise. (cpp_macro_definition): Use XRESIZEVEC. * makedepend.c (add_clm): Use XNEW. (add_dir): Likewise. * mkdeps.c (munge): Use XNEWVEC. (deps_init): Use XCNEW. (deps_add_target): Use XRESIZEVEC. (deps_add_default_target): Cast return value of alloca. (deps_add_dep): Use XRESIZEVEC. (deps_add_vpath): Likewise. Use XNEWVEC too. (deps_restore): Likewise. * pch.c (save_idents): Use XNEW and XNEWVEC. (cpp_save_state): Use XNEW. (count_defs): Cast return value of htab_find. (write_defs): Likewise. (cpp_write_pch_deps): Use XNEWVEC. (collect_ht_nodes): Use XRESIZEVEC. (cpp_valid_state): Use XNEWVEC. (save_macros): Use XRESIZEVEC. Cast return value of xmemdup. * symtab.c (ht_create): Use XCNEW. (ht_lookup_with_hash): Cast return value of obstack_copy0. (ht_expand): Use XCNEWVEC. * system.h (HAVE_DESIGNATED_INITIALIZERS): False if __cplusplus. (bool): Do not define if __cplusplus. From-SVN: r100295
2005-05-28 17:52:48 +02:00
dir->name_map = XRESIZEVEC (const char *, dir->name_map, room);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
}
dir->name_map[count] = read_filename_string (ch, f);
while ((ch = getc (f)) != EOF && is_hspace (ch))
;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
to = read_filename_string (ch, f);
if (IS_ABSOLUTE_PATH (to))
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
dir->name_map[count + 1] = to;
else
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
dir->name_map[count + 1] = append_file_to_dir (to, dir);
free (to);
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
count += 2;
while ((ch = getc (f)) != '\n')
if (ch == EOF)
break;
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
fclose (f);
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Terminate the list of maps. */
dir->name_map[count] = NULL;
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Remap a FILE's name based on the file_name_map, if any, for
FILE->dir. If the file name has any directory separators,
recursively check those directories too. */
static char *
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
remap_filename (cpp_reader *pfile, _cpp_file *file)
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
const char *fname, *p;
char *new_dir;
cpp_dir *dir;
size_t index, len;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
dir = file->dir;
fname = file->name;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
for (;;)
{
if (!dir->name_map)
read_name_map (dir);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
for (index = 0; dir->name_map[index]; index += 2)
if (!strcmp (dir->name_map[index], fname))
return xstrdup (dir->name_map[index + 1]);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
p = strchr (fname, '/');
if (!p || p == fname)
return NULL;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
len = dir->len + (p - fname + 1);
configure.ac: Check declarations for asprintf and vasprintf. * configure.ac: Check declarations for asprintf and vasprintf. * config.in: Regenerate. * configure: Likewise. * charset.c (conversion_loop): Use XRESIZEVEC. (convert_no_conversion): Likewise. (convert_using_iconv): Likewise. (init_iconv_desc): Cast return value of alloca. (cpp_host_to_exec_charset): Use XNEWVEC. (emit_numeric_escape): Use XRESIZEVEC. (cpp_interpret_string): Use XNEWVEC. (cpp_interpret_string): Use XRESIZEVEC. (_cpp_interpret_identifier): Cast return value of alloca. (_cpp_convert_input): Use XNEWVEC and XRESIZEVEC. * directives.c (glue_header_name): Use XNEWVEC and XRESIZEVEC. (parse_include): Use XNEWVEC. (insert_pragma_entry): Rename local variable "new" to "new_entry". (save_registered_pragmas): Cast return value of xmemdup. (destringize_and_run): Same for alloca. (parse_assertion): Likewise. (do_assert): Cast allocated storage to proper type. (cpp_define): Likewise. (_cpp_define_builtin): Likewise. (cpp_undef): Likewise. (handle_assertion): Likewise. (cpp_push_buffer): Rename local variable "new" to "new_buffer". * expr.c (CPP_UPLUS): Cast value to type cpp_ttype. (CPP_UMINUS): Likewise. (struct cpp_operator): Rename from struct operator. (_cpp_expand_op_stack): Use XRESIZEVEC. * files.c (pch_open_file): Use XNEWVEC. (pch_open_file): Use XRESIZEVEC. (read_file_guts): Use XNEWVEC and XRESIZEVEC. (dir_name_of_file): Use XNEWVEC. (make_cpp_file): Use XCNEW. (make_cpp_dir): Likewise. (allocate_file_hash_entries): USE XNEWVEC. (cpp_included): Cast return value of htab_find_with_hash. (append_file_to_dir): Use XNEWVEC. (read_filename_string): Likewise. Use XRESIZEVEC too. (read_name_map): Cast return value of alloca. Use XRESIZEVEC. (remap_filename): Use XNEWVEC. (struct pchf_entry): Move definition out of struct pchf_data. (_cpp_save_file_entries): Use XCNEWVAR. (_cpp_read_file_entries): Use XNEWVAR. * identifiers.c (alloc_node): Use XOBNEW. * init.c (cpp_create_reader): Use XCNEW. (cpp_init_builtins): Cast of b->value to enum builtin_type. (read_original_directory): Cast return value of alloca. * lex.c (add_line_note): Use XRESIZEVEC. (warn_about_normalization): Use XNEWVEC. (_cpp_lex_direct): Cast node->directive_index to (enum cpp_ttype). (new_buff): Use XNEWVEC. * line-map.c (linemap_add): Use XRESIZEVEC. * macro.c (builtin_macro): Cast return value of alloca. (paste_tokens): Likewise. (expand_arg): Use XNEWVEC and XRESIZEVEC. (_cpp_save_parameter): Use XRESIZEVEC. (create_iso_definition): Cast allocated storage to proper type. (_cpp_create_definition): Likewise. (cpp_macro_definition): Use XRESIZEVEC. * makedepend.c (add_clm): Use XNEW. (add_dir): Likewise. * mkdeps.c (munge): Use XNEWVEC. (deps_init): Use XCNEW. (deps_add_target): Use XRESIZEVEC. (deps_add_default_target): Cast return value of alloca. (deps_add_dep): Use XRESIZEVEC. (deps_add_vpath): Likewise. Use XNEWVEC too. (deps_restore): Likewise. * pch.c (save_idents): Use XNEW and XNEWVEC. (cpp_save_state): Use XNEW. (count_defs): Cast return value of htab_find. (write_defs): Likewise. (cpp_write_pch_deps): Use XNEWVEC. (collect_ht_nodes): Use XRESIZEVEC. (cpp_valid_state): Use XNEWVEC. (save_macros): Use XRESIZEVEC. Cast return value of xmemdup. * symtab.c (ht_create): Use XCNEW. (ht_lookup_with_hash): Cast return value of obstack_copy0. (ht_expand): Use XCNEWVEC. * system.h (HAVE_DESIGNATED_INITIALIZERS): False if __cplusplus. (bool): Do not define if __cplusplus. From-SVN: r100295
2005-05-28 17:52:48 +02:00
new_dir = XNEWVEC (char, len + 1);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
memcpy (new_dir, dir->name, dir->len);
memcpy (new_dir + dir->len, fname, p - fname + 1);
new_dir[len] = '\0';
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
dir = make_cpp_dir (pfile, new_dir, dir->sysp);
fname = p + 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 12:56:54 +01:00
}
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
/* Returns true if PCHNAME is a valid PCH file for FILE. */
static bool
validate_pch (cpp_reader *pfile, _cpp_file *file, const char *pchname)
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
const char *saved_path = file->path;
bool valid = false;
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
file->path = pchname;
if (open_file (file))
{
valid = 1 & pfile->cb.valid_pch (pfile, pchname, file->fd);
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (!valid)
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
close (file->fd);
file->fd = -1;
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
if (CPP_OPTION (pfile, print_include_names))
{
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
unsigned int i;
2004-01-20 08:35:21 +01:00
for (i = 1; i < pfile->line_table->depth; i++)
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
putc ('.', stderr);
fprintf (stderr, "%c %s\n",
valid ? '!' : 'x', pchname);
}
}
Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * Makefile.in (LIBCPP_DEPS): Add HASHTAB_H. * cppfiles.c: Completely rewritten. * c-incpath.c (free_path, remove_duplicates, heads, tails, add_path): struct cpp_path is now struct cpp_dir. (remove_duplicates): Don't simplify path names. * c-opts.c (c_common_parse_file): cpp_read_next_file renamed cpp_stack_file. * cpphash.h: Include hashtab.h. (_cpp_file): Declare. (struct cpp_buffer): struct include_file is now struct _cpp_file, and struct cpp_path is now struct cpp_dir. Rename members. (struct cpp_reader): Similarly. New members once_only_files, file_hash, file_hash_entries, quote_ignores_source_dir, no_search_path, saw_pragma_once. Remove all_include_files and max_include_len. Make some members bool. (_cpp_mark_only_only): Renamed from _cpp_never_reread. (_cpp_stack_file): Renamed from _cpp_read_file. (_cpp_stack_include): Renamed from _cpp_execute_include. (_cpp_init_files): Renamed from _cpp_init_includes. (_cpp_cleanup_files): Renamed from _cpp_cleanup_includes. * cppinit.c (cpp_create_reader): Initialize no_search_path. Update. (cpp_read_next_file): Rename and move to cppfiles.c. (cpp_read_main_file): Update. * cpplib.c (run_directive): Update for renamed members. (do_include_common, _cpp_pop_buffer): Update. (do_import): Undeprecate #import. (do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only. * cpplib.h: Remove file_name_map_list. (cpp_options): Remove map_list. (cpp_dir): Rename from cpp_path. New datatype for name_map. (cpp_set_include_chains, cpp_stack_file, cpp_included): Update. testsuite: * gcc.dg/cpp/include2.c: Only expect one message. From-SVN: r69942
2003-07-30 00:26:13 +02:00
file->path = saved_path;
return valid;
}
Add framework support for darwin. * c-incpath.c: Include target.h and machmode.h. (add_path): Use a consistent style for cpp_dir. Initialize p->construct to 0. (add_cpp_dir_path): New. (register_include_chains): Add use of extra_includes callback. (hook_void_int): Add. (target_c_incpath): Add. * c-incpath.h (add_cpp_dir_path): New. (target_c_incpath_s): Add. (target_c_incpath): Add. (C_INCPATH_INIT): Add. * c-opts.c (c_common_missing_argument, c_common_handle_option): Add -F argument processing. * c.opt: Add -F argument processing. * gcc.c (trad_capable_cpp): Add -F argument processing. * cppfiles.c (find_file_in_dir): Update to use construct callback. (search_path_exhausted, cpp_get_path, cpp_get_buffer, cpp_get_prev): New. (_cpp_find_file): Use search_path_exhausted. (make_cpp_dir): Initialize construct to 0. * cpplib.h (missing_header_cb cpp_get_path, cpp_get_buffer, cpp_get_file, cpp_get_prev): New. (cpp_callbacks): Add missing_header (cpp_dir): Add construct. * target-def.h: (TARGET_OPTF): New. * hooks.c (hook_void_int, hook_void_charptr): Add. * hooks.h (hook_void_int, hook_void_charptr): Add. * Makefile.in (c-incpath.o) : Add $(TARGET_H) and $(MACHMODE_H) dependencies. * doc/invoke.texi (Darwin Options): Document -F. * doc/tm.texi (TARGET_EXTRA_INCLUDES): Add. (TARGET_OPTF): Add. * fix-header.c (target_c_incpath): Add. * config/darwin-c.c: Add c-incpath.h include. (using_frameworks, find_subframework_file, find_subframework_header, add_system_framework_path, frameworks_in_use, num_frameworks, max_frameworks, add_framework, find_framework, struct framework_header, framework_header_dirs, framework_construct_pathname, find_subframework_file, add_system_framework_path, add_framework_path, framework_defaults, darwin_register_frameworks, find_subframework_header): Add. * config/darwin.h (TARGET_EXTRA_INCLUDES, TARGET_OPTF): New. (TARGET_OPTION_TRANSLATE_TABLE): Add -framework support. (CPP_SPEC): Add __APPLE_CC__ support. * t-darwin (darwin-c.o): Add c-incpath.h dependency. From-SVN: r78875
2004-03-04 01:18:54 +01:00
/* Get the path associated with the _cpp_file F. The path includes
the base name from the include directive and the directory it was
found in via the search path. */
const char *
cpp_get_path (struct _cpp_file *f)
{
return f->path;
}
/* Get the directory associated with the _cpp_file F. */
cpp_dir *
cpp_get_dir (struct _cpp_file *f)
{
return f->dir;
}
Add framework support for darwin. * c-incpath.c: Include target.h and machmode.h. (add_path): Use a consistent style for cpp_dir. Initialize p->construct to 0. (add_cpp_dir_path): New. (register_include_chains): Add use of extra_includes callback. (hook_void_int): Add. (target_c_incpath): Add. * c-incpath.h (add_cpp_dir_path): New. (target_c_incpath_s): Add. (target_c_incpath): Add. (C_INCPATH_INIT): Add. * c-opts.c (c_common_missing_argument, c_common_handle_option): Add -F argument processing. * c.opt: Add -F argument processing. * gcc.c (trad_capable_cpp): Add -F argument processing. * cppfiles.c (find_file_in_dir): Update to use construct callback. (search_path_exhausted, cpp_get_path, cpp_get_buffer, cpp_get_prev): New. (_cpp_find_file): Use search_path_exhausted. (make_cpp_dir): Initialize construct to 0. * cpplib.h (missing_header_cb cpp_get_path, cpp_get_buffer, cpp_get_file, cpp_get_prev): New. (cpp_callbacks): Add missing_header (cpp_dir): Add construct. * target-def.h: (TARGET_OPTF): New. * hooks.c (hook_void_int, hook_void_charptr): Add. * hooks.h (hook_void_int, hook_void_charptr): Add. * Makefile.in (c-incpath.o) : Add $(TARGET_H) and $(MACHMODE_H) dependencies. * doc/invoke.texi (Darwin Options): Document -F. * doc/tm.texi (TARGET_EXTRA_INCLUDES): Add. (TARGET_OPTF): Add. * fix-header.c (target_c_incpath): Add. * config/darwin-c.c: Add c-incpath.h include. (using_frameworks, find_subframework_file, find_subframework_header, add_system_framework_path, frameworks_in_use, num_frameworks, max_frameworks, add_framework, find_framework, struct framework_header, framework_header_dirs, framework_construct_pathname, find_subframework_file, add_system_framework_path, add_framework_path, framework_defaults, darwin_register_frameworks, find_subframework_header): Add. * config/darwin.h (TARGET_EXTRA_INCLUDES, TARGET_OPTF): New. (TARGET_OPTION_TRANSLATE_TABLE): Add -framework support. (CPP_SPEC): Add __APPLE_CC__ support. * t-darwin (darwin-c.o): Add c-incpath.h dependency. From-SVN: r78875
2004-03-04 01:18:54 +01:00
/* Get the cpp_buffer currently associated with the cpp_reader
PFILE. */
cpp_buffer *
cpp_get_buffer (cpp_reader *pfile)
{
return pfile->buffer;
}
/* Get the _cpp_file associated with the cpp_buffer B. */
_cpp_file *
cpp_get_file (cpp_buffer *b)
{
return b->file;
}
/* Get the previous cpp_buffer given a cpp_buffer B. The previous
buffer is the buffer that included the given buffer. */
cpp_buffer *
cpp_get_prev (cpp_buffer *b)
{
return b->prev;
}
/* This data structure holds the list of header files that were seen
while the PCH was being built. The 'entries' field is kept sorted
in memcmp() order; yes, this means that on little-endian systems,
it's sorted initially by the least-significant byte of 'size', but
that's OK. The code does rely on having entries with the same size
next to each other. */
configure.ac: Check declarations for asprintf and vasprintf. * configure.ac: Check declarations for asprintf and vasprintf. * config.in: Regenerate. * configure: Likewise. * charset.c (conversion_loop): Use XRESIZEVEC. (convert_no_conversion): Likewise. (convert_using_iconv): Likewise. (init_iconv_desc): Cast return value of alloca. (cpp_host_to_exec_charset): Use XNEWVEC. (emit_numeric_escape): Use XRESIZEVEC. (cpp_interpret_string): Use XNEWVEC. (cpp_interpret_string): Use XRESIZEVEC. (_cpp_interpret_identifier): Cast return value of alloca. (_cpp_convert_input): Use XNEWVEC and XRESIZEVEC. * directives.c (glue_header_name): Use XNEWVEC and XRESIZEVEC. (parse_include): Use XNEWVEC. (insert_pragma_entry): Rename local variable "new" to "new_entry". (save_registered_pragmas): Cast return value of xmemdup. (destringize_and_run): Same for alloca. (parse_assertion): Likewise. (do_assert): Cast allocated storage to proper type. (cpp_define): Likewise. (_cpp_define_builtin): Likewise. (cpp_undef): Likewise. (handle_assertion): Likewise. (cpp_push_buffer): Rename local variable "new" to "new_buffer". * expr.c (CPP_UPLUS): Cast value to type cpp_ttype. (CPP_UMINUS): Likewise. (struct cpp_operator): Rename from struct operator. (_cpp_expand_op_stack): Use XRESIZEVEC. * files.c (pch_open_file): Use XNEWVEC. (pch_open_file): Use XRESIZEVEC. (read_file_guts): Use XNEWVEC and XRESIZEVEC. (dir_name_of_file): Use XNEWVEC. (make_cpp_file): Use XCNEW. (make_cpp_dir): Likewise. (allocate_file_hash_entries): USE XNEWVEC. (cpp_included): Cast return value of htab_find_with_hash. (append_file_to_dir): Use XNEWVEC. (read_filename_string): Likewise. Use XRESIZEVEC too. (read_name_map): Cast return value of alloca. Use XRESIZEVEC. (remap_filename): Use XNEWVEC. (struct pchf_entry): Move definition out of struct pchf_data. (_cpp_save_file_entries): Use XCNEWVAR. (_cpp_read_file_entries): Use XNEWVAR. * identifiers.c (alloc_node): Use XOBNEW. * init.c (cpp_create_reader): Use XCNEW. (cpp_init_builtins): Cast of b->value to enum builtin_type. (read_original_directory): Cast return value of alloca. * lex.c (add_line_note): Use XRESIZEVEC. (warn_about_normalization): Use XNEWVEC. (_cpp_lex_direct): Cast node->directive_index to (enum cpp_ttype). (new_buff): Use XNEWVEC. * line-map.c (linemap_add): Use XRESIZEVEC. * macro.c (builtin_macro): Cast return value of alloca. (paste_tokens): Likewise. (expand_arg): Use XNEWVEC and XRESIZEVEC. (_cpp_save_parameter): Use XRESIZEVEC. (create_iso_definition): Cast allocated storage to proper type. (_cpp_create_definition): Likewise. (cpp_macro_definition): Use XRESIZEVEC. * makedepend.c (add_clm): Use XNEW. (add_dir): Likewise. * mkdeps.c (munge): Use XNEWVEC. (deps_init): Use XCNEW. (deps_add_target): Use XRESIZEVEC. (deps_add_default_target): Cast return value of alloca. (deps_add_dep): Use XRESIZEVEC. (deps_add_vpath): Likewise. Use XNEWVEC too. (deps_restore): Likewise. * pch.c (save_idents): Use XNEW and XNEWVEC. (cpp_save_state): Use XNEW. (count_defs): Cast return value of htab_find. (write_defs): Likewise. (cpp_write_pch_deps): Use XNEWVEC. (collect_ht_nodes): Use XRESIZEVEC. (cpp_valid_state): Use XNEWVEC. (save_macros): Use XRESIZEVEC. Cast return value of xmemdup. * symtab.c (ht_create): Use XCNEW. (ht_lookup_with_hash): Cast return value of obstack_copy0. (ht_expand): Use XCNEWVEC. * system.h (HAVE_DESIGNATED_INITIALIZERS): False if __cplusplus. (bool): Do not define if __cplusplus. From-SVN: r100295
2005-05-28 17:52:48 +02:00
struct pchf_entry {
/* The size of this file. This is used to save running a MD5 checksum
if the sizes don't match. */
off_t size;
/* The MD5 checksum of this file. */
unsigned char sum[16];
/* Is this file to be included only once? */
bool once_only;
};
struct pchf_data {
/* Number of pchf_entry structures. */
size_t count;
/* Are there any values with once_only set?
This is used as an optimisation, it means we don't have to search
the structure if we're processing a regular #include. */
bool have_once_only;
[multiple changes] 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * c-opts.c (c_common_handle_option): Add -finput-charset. * c.opt: Ditto. * cppcharset.c (one_iso88591_to_utf8): Remove. (convert_iso88591_utf8): Ditto. (conversion_tab): Remove 8859-1 converter. (_cpp_input_to_utf8): Remove. (_cpp_init_iconv_buffer): Ditto. (_cpp_close_iconv_buffer): Ditto. (_cpp_convert_input): New function. (_cpp_default_encoding): Ditto. * cpphash.h: Add/remove prototypes for above. * cppfiles.c (read_file_guts): Use _cpp_convert_input. * cppinit.c (cpp_create_reader): Use _cpp_default_encoding for narrow execution and input character sets. * cpplib.c (cpp_push_buffer): Delete uses of removed functions. * doc/cppopts.texi: Document -finput-charset. 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * gcc.c-torture/execute/wchar_t-1.c: Add -finput-charset. 2004-01-29 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * testsuite/22_locale/collate/compare/wchar_t/2.cc: Remove xfail. Use -finput-charset. * testsuite/22_locale/collate/compare/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/compare/wchar_t/wrapped_locale.cc: Ditto * testsuite/22_locale/collate/hash/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_locale.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_locale.cc: Ditto. From-SVN: r77136
2004-02-02 21:20:58 +01:00
configure.ac: Check declarations for asprintf and vasprintf. * configure.ac: Check declarations for asprintf and vasprintf. * config.in: Regenerate. * configure: Likewise. * charset.c (conversion_loop): Use XRESIZEVEC. (convert_no_conversion): Likewise. (convert_using_iconv): Likewise. (init_iconv_desc): Cast return value of alloca. (cpp_host_to_exec_charset): Use XNEWVEC. (emit_numeric_escape): Use XRESIZEVEC. (cpp_interpret_string): Use XNEWVEC. (cpp_interpret_string): Use XRESIZEVEC. (_cpp_interpret_identifier): Cast return value of alloca. (_cpp_convert_input): Use XNEWVEC and XRESIZEVEC. * directives.c (glue_header_name): Use XNEWVEC and XRESIZEVEC. (parse_include): Use XNEWVEC. (insert_pragma_entry): Rename local variable "new" to "new_entry". (save_registered_pragmas): Cast return value of xmemdup. (destringize_and_run): Same for alloca. (parse_assertion): Likewise. (do_assert): Cast allocated storage to proper type. (cpp_define): Likewise. (_cpp_define_builtin): Likewise. (cpp_undef): Likewise. (handle_assertion): Likewise. (cpp_push_buffer): Rename local variable "new" to "new_buffer". * expr.c (CPP_UPLUS): Cast value to type cpp_ttype. (CPP_UMINUS): Likewise. (struct cpp_operator): Rename from struct operator. (_cpp_expand_op_stack): Use XRESIZEVEC. * files.c (pch_open_file): Use XNEWVEC. (pch_open_file): Use XRESIZEVEC. (read_file_guts): Use XNEWVEC and XRESIZEVEC. (dir_name_of_file): Use XNEWVEC. (make_cpp_file): Use XCNEW. (make_cpp_dir): Likewise. (allocate_file_hash_entries): USE XNEWVEC. (cpp_included): Cast return value of htab_find_with_hash. (append_file_to_dir): Use XNEWVEC. (read_filename_string): Likewise. Use XRESIZEVEC too. (read_name_map): Cast return value of alloca. Use XRESIZEVEC. (remap_filename): Use XNEWVEC. (struct pchf_entry): Move definition out of struct pchf_data. (_cpp_save_file_entries): Use XCNEWVAR. (_cpp_read_file_entries): Use XNEWVAR. * identifiers.c (alloc_node): Use XOBNEW. * init.c (cpp_create_reader): Use XCNEW. (cpp_init_builtins): Cast of b->value to enum builtin_type. (read_original_directory): Cast return value of alloca. * lex.c (add_line_note): Use XRESIZEVEC. (warn_about_normalization): Use XNEWVEC. (_cpp_lex_direct): Cast node->directive_index to (enum cpp_ttype). (new_buff): Use XNEWVEC. * line-map.c (linemap_add): Use XRESIZEVEC. * macro.c (builtin_macro): Cast return value of alloca. (paste_tokens): Likewise. (expand_arg): Use XNEWVEC and XRESIZEVEC. (_cpp_save_parameter): Use XRESIZEVEC. (create_iso_definition): Cast allocated storage to proper type. (_cpp_create_definition): Likewise. (cpp_macro_definition): Use XRESIZEVEC. * makedepend.c (add_clm): Use XNEW. (add_dir): Likewise. * mkdeps.c (munge): Use XNEWVEC. (deps_init): Use XCNEW. (deps_add_target): Use XRESIZEVEC. (deps_add_default_target): Cast return value of alloca. (deps_add_dep): Use XRESIZEVEC. (deps_add_vpath): Likewise. Use XNEWVEC too. (deps_restore): Likewise. * pch.c (save_idents): Use XNEW and XNEWVEC. (cpp_save_state): Use XNEW. (count_defs): Cast return value of htab_find. (write_defs): Likewise. (cpp_write_pch_deps): Use XNEWVEC. (collect_ht_nodes): Use XRESIZEVEC. (cpp_valid_state): Use XNEWVEC. (save_macros): Use XRESIZEVEC. Cast return value of xmemdup. * symtab.c (ht_create): Use XCNEW. (ht_lookup_with_hash): Cast return value of obstack_copy0. (ht_expand): Use XCNEWVEC. * system.h (HAVE_DESIGNATED_INITIALIZERS): False if __cplusplus. (bool): Do not define if __cplusplus. From-SVN: r100295
2005-05-28 17:52:48 +02:00
struct pchf_entry entries[1];
};
static struct pchf_data *pchf;
/* A qsort ordering function for pchf_entry structures. */
static int
pchf_save_compare (const void *e1, const void *e2)
{
return memcmp (e1, e2, sizeof (struct pchf_entry));
}
/* Create and write to F a pchf_data structure. */
bool
_cpp_save_file_entries (cpp_reader *pfile, FILE *fp)
{
size_t count = 0;
struct pchf_data *result;
size_t result_size;
_cpp_file *f;
for (f = pfile->all_files; f; f = f->next_file)
++count;
result_size = (sizeof (struct pchf_data)
+ sizeof (struct pchf_entry) * (count - 1));
configure.ac: Check declarations for asprintf and vasprintf. * configure.ac: Check declarations for asprintf and vasprintf. * config.in: Regenerate. * configure: Likewise. * charset.c (conversion_loop): Use XRESIZEVEC. (convert_no_conversion): Likewise. (convert_using_iconv): Likewise. (init_iconv_desc): Cast return value of alloca. (cpp_host_to_exec_charset): Use XNEWVEC. (emit_numeric_escape): Use XRESIZEVEC. (cpp_interpret_string): Use XNEWVEC. (cpp_interpret_string): Use XRESIZEVEC. (_cpp_interpret_identifier): Cast return value of alloca. (_cpp_convert_input): Use XNEWVEC and XRESIZEVEC. * directives.c (glue_header_name): Use XNEWVEC and XRESIZEVEC. (parse_include): Use XNEWVEC. (insert_pragma_entry): Rename local variable "new" to "new_entry". (save_registered_pragmas): Cast return value of xmemdup. (destringize_and_run): Same for alloca. (parse_assertion): Likewise. (do_assert): Cast allocated storage to proper type. (cpp_define): Likewise. (_cpp_define_builtin): Likewise. (cpp_undef): Likewise. (handle_assertion): Likewise. (cpp_push_buffer): Rename local variable "new" to "new_buffer". * expr.c (CPP_UPLUS): Cast value to type cpp_ttype. (CPP_UMINUS): Likewise. (struct cpp_operator): Rename from struct operator. (_cpp_expand_op_stack): Use XRESIZEVEC. * files.c (pch_open_file): Use XNEWVEC. (pch_open_file): Use XRESIZEVEC. (read_file_guts): Use XNEWVEC and XRESIZEVEC. (dir_name_of_file): Use XNEWVEC. (make_cpp_file): Use XCNEW. (make_cpp_dir): Likewise. (allocate_file_hash_entries): USE XNEWVEC. (cpp_included): Cast return value of htab_find_with_hash. (append_file_to_dir): Use XNEWVEC. (read_filename_string): Likewise. Use XRESIZEVEC too. (read_name_map): Cast return value of alloca. Use XRESIZEVEC. (remap_filename): Use XNEWVEC. (struct pchf_entry): Move definition out of struct pchf_data. (_cpp_save_file_entries): Use XCNEWVAR. (_cpp_read_file_entries): Use XNEWVAR. * identifiers.c (alloc_node): Use XOBNEW. * init.c (cpp_create_reader): Use XCNEW. (cpp_init_builtins): Cast of b->value to enum builtin_type. (read_original_directory): Cast return value of alloca. * lex.c (add_line_note): Use XRESIZEVEC. (warn_about_normalization): Use XNEWVEC. (_cpp_lex_direct): Cast node->directive_index to (enum cpp_ttype). (new_buff): Use XNEWVEC. * line-map.c (linemap_add): Use XRESIZEVEC. * macro.c (builtin_macro): Cast return value of alloca. (paste_tokens): Likewise. (expand_arg): Use XNEWVEC and XRESIZEVEC. (_cpp_save_parameter): Use XRESIZEVEC. (create_iso_definition): Cast allocated storage to proper type. (_cpp_create_definition): Likewise. (cpp_macro_definition): Use XRESIZEVEC. * makedepend.c (add_clm): Use XNEW. (add_dir): Likewise. * mkdeps.c (munge): Use XNEWVEC. (deps_init): Use XCNEW. (deps_add_target): Use XRESIZEVEC. (deps_add_default_target): Cast return value of alloca. (deps_add_dep): Use XRESIZEVEC. (deps_add_vpath): Likewise. Use XNEWVEC too. (deps_restore): Likewise. * pch.c (save_idents): Use XNEW and XNEWVEC. (cpp_save_state): Use XNEW. (count_defs): Cast return value of htab_find. (write_defs): Likewise. (cpp_write_pch_deps): Use XNEWVEC. (collect_ht_nodes): Use XRESIZEVEC. (cpp_valid_state): Use XNEWVEC. (save_macros): Use XRESIZEVEC. Cast return value of xmemdup. * symtab.c (ht_create): Use XCNEW. (ht_lookup_with_hash): Cast return value of obstack_copy0. (ht_expand): Use XCNEWVEC. * system.h (HAVE_DESIGNATED_INITIALIZERS): False if __cplusplus. (bool): Do not define if __cplusplus. From-SVN: r100295
2005-05-28 17:52:48 +02:00
result = XCNEWVAR (struct pchf_data, result_size);
result->count = 0;
result->have_once_only = false;
for (f = pfile->all_files; f; f = f->next_file)
{
size_t count;
/* This should probably never happen, since if a read error occurred
the PCH file shouldn't be written... */
if (f->dont_read || f->err_no)
continue;
if (f->stack_count == 0)
continue;
[multiple changes] 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * c-opts.c (c_common_handle_option): Add -finput-charset. * c.opt: Ditto. * cppcharset.c (one_iso88591_to_utf8): Remove. (convert_iso88591_utf8): Ditto. (conversion_tab): Remove 8859-1 converter. (_cpp_input_to_utf8): Remove. (_cpp_init_iconv_buffer): Ditto. (_cpp_close_iconv_buffer): Ditto. (_cpp_convert_input): New function. (_cpp_default_encoding): Ditto. * cpphash.h: Add/remove prototypes for above. * cppfiles.c (read_file_guts): Use _cpp_convert_input. * cppinit.c (cpp_create_reader): Use _cpp_default_encoding for narrow execution and input character sets. * cpplib.c (cpp_push_buffer): Delete uses of removed functions. * doc/cppopts.texi: Document -finput-charset. 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * gcc.c-torture/execute/wchar_t-1.c: Add -finput-charset. 2004-01-29 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * testsuite/22_locale/collate/compare/wchar_t/2.cc: Remove xfail. Use -finput-charset. * testsuite/22_locale/collate/compare/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/compare/wchar_t/wrapped_locale.cc: Ditto * testsuite/22_locale/collate/hash/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_locale.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_locale.cc: Ditto. From-SVN: r77136
2004-02-02 21:20:58 +01:00
count = result->count++;
result->entries[count].once_only = f->once_only;
/* |= is avoided in the next line because of an HP C compiler bug */
result->have_once_only = result->have_once_only | f->once_only;
if (f->buffer_valid)
md5_buffer ((const char *)f->buffer,
f->st.st_size, result->entries[count].sum);
else
{
FILE *ff;
int oldfd = f->fd;
if (!open_file (f))
{
open_file_failed (pfile, f, 0);
return false;
}
ff = fdopen (f->fd, "rb");
md5_stream (ff, result->entries[count].sum);
fclose (ff);
f->fd = oldfd;
}
result->entries[count].size = f->st.st_size;
}
result_size = (sizeof (struct pchf_data)
+ sizeof (struct pchf_entry) * (result->count - 1));
[multiple changes] 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * c-opts.c (c_common_handle_option): Add -finput-charset. * c.opt: Ditto. * cppcharset.c (one_iso88591_to_utf8): Remove. (convert_iso88591_utf8): Ditto. (conversion_tab): Remove 8859-1 converter. (_cpp_input_to_utf8): Remove. (_cpp_init_iconv_buffer): Ditto. (_cpp_close_iconv_buffer): Ditto. (_cpp_convert_input): New function. (_cpp_default_encoding): Ditto. * cpphash.h: Add/remove prototypes for above. * cppfiles.c (read_file_guts): Use _cpp_convert_input. * cppinit.c (cpp_create_reader): Use _cpp_default_encoding for narrow execution and input character sets. * cpplib.c (cpp_push_buffer): Delete uses of removed functions. * doc/cppopts.texi: Document -finput-charset. 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * gcc.c-torture/execute/wchar_t-1.c: Add -finput-charset. 2004-01-29 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * testsuite/22_locale/collate/compare/wchar_t/2.cc: Remove xfail. Use -finput-charset. * testsuite/22_locale/collate/compare/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/compare/wchar_t/wrapped_locale.cc: Ditto * testsuite/22_locale/collate/hash/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_locale.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_locale.cc: Ditto. From-SVN: r77136
2004-02-02 21:20:58 +01:00
qsort (result->entries, result->count, sizeof (struct pchf_entry),
pchf_save_compare);
return fwrite (result, result_size, 1, fp) == 1;
}
/* Read the pchf_data structure from F. */
bool
_cpp_read_file_entries (cpp_reader *pfile ATTRIBUTE_UNUSED, FILE *f)
{
struct pchf_data d;
[multiple changes] 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * c-opts.c (c_common_handle_option): Add -finput-charset. * c.opt: Ditto. * cppcharset.c (one_iso88591_to_utf8): Remove. (convert_iso88591_utf8): Ditto. (conversion_tab): Remove 8859-1 converter. (_cpp_input_to_utf8): Remove. (_cpp_init_iconv_buffer): Ditto. (_cpp_close_iconv_buffer): Ditto. (_cpp_convert_input): New function. (_cpp_default_encoding): Ditto. * cpphash.h: Add/remove prototypes for above. * cppfiles.c (read_file_guts): Use _cpp_convert_input. * cppinit.c (cpp_create_reader): Use _cpp_default_encoding for narrow execution and input character sets. * cpplib.c (cpp_push_buffer): Delete uses of removed functions. * doc/cppopts.texi: Document -finput-charset. 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * gcc.c-torture/execute/wchar_t-1.c: Add -finput-charset. 2004-01-29 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * testsuite/22_locale/collate/compare/wchar_t/2.cc: Remove xfail. Use -finput-charset. * testsuite/22_locale/collate/compare/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/compare/wchar_t/wrapped_locale.cc: Ditto * testsuite/22_locale/collate/hash/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_locale.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_locale.cc: Ditto. From-SVN: r77136
2004-02-02 21:20:58 +01:00
if (fread (&d, sizeof (struct pchf_data) - sizeof (struct pchf_entry), 1, f)
!= 1)
return false;
[multiple changes] 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * c-opts.c (c_common_handle_option): Add -finput-charset. * c.opt: Ditto. * cppcharset.c (one_iso88591_to_utf8): Remove. (convert_iso88591_utf8): Ditto. (conversion_tab): Remove 8859-1 converter. (_cpp_input_to_utf8): Remove. (_cpp_init_iconv_buffer): Ditto. (_cpp_close_iconv_buffer): Ditto. (_cpp_convert_input): New function. (_cpp_default_encoding): Ditto. * cpphash.h: Add/remove prototypes for above. * cppfiles.c (read_file_guts): Use _cpp_convert_input. * cppinit.c (cpp_create_reader): Use _cpp_default_encoding for narrow execution and input character sets. * cpplib.c (cpp_push_buffer): Delete uses of removed functions. * doc/cppopts.texi: Document -finput-charset. 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * gcc.c-torture/execute/wchar_t-1.c: Add -finput-charset. 2004-01-29 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * testsuite/22_locale/collate/compare/wchar_t/2.cc: Remove xfail. Use -finput-charset. * testsuite/22_locale/collate/compare/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/compare/wchar_t/wrapped_locale.cc: Ditto * testsuite/22_locale/collate/hash/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_locale.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_locale.cc: Ditto. From-SVN: r77136
2004-02-02 21:20:58 +01:00
configure.ac: Check declarations for asprintf and vasprintf. * configure.ac: Check declarations for asprintf and vasprintf. * config.in: Regenerate. * configure: Likewise. * charset.c (conversion_loop): Use XRESIZEVEC. (convert_no_conversion): Likewise. (convert_using_iconv): Likewise. (init_iconv_desc): Cast return value of alloca. (cpp_host_to_exec_charset): Use XNEWVEC. (emit_numeric_escape): Use XRESIZEVEC. (cpp_interpret_string): Use XNEWVEC. (cpp_interpret_string): Use XRESIZEVEC. (_cpp_interpret_identifier): Cast return value of alloca. (_cpp_convert_input): Use XNEWVEC and XRESIZEVEC. * directives.c (glue_header_name): Use XNEWVEC and XRESIZEVEC. (parse_include): Use XNEWVEC. (insert_pragma_entry): Rename local variable "new" to "new_entry". (save_registered_pragmas): Cast return value of xmemdup. (destringize_and_run): Same for alloca. (parse_assertion): Likewise. (do_assert): Cast allocated storage to proper type. (cpp_define): Likewise. (_cpp_define_builtin): Likewise. (cpp_undef): Likewise. (handle_assertion): Likewise. (cpp_push_buffer): Rename local variable "new" to "new_buffer". * expr.c (CPP_UPLUS): Cast value to type cpp_ttype. (CPP_UMINUS): Likewise. (struct cpp_operator): Rename from struct operator. (_cpp_expand_op_stack): Use XRESIZEVEC. * files.c (pch_open_file): Use XNEWVEC. (pch_open_file): Use XRESIZEVEC. (read_file_guts): Use XNEWVEC and XRESIZEVEC. (dir_name_of_file): Use XNEWVEC. (make_cpp_file): Use XCNEW. (make_cpp_dir): Likewise. (allocate_file_hash_entries): USE XNEWVEC. (cpp_included): Cast return value of htab_find_with_hash. (append_file_to_dir): Use XNEWVEC. (read_filename_string): Likewise. Use XRESIZEVEC too. (read_name_map): Cast return value of alloca. Use XRESIZEVEC. (remap_filename): Use XNEWVEC. (struct pchf_entry): Move definition out of struct pchf_data. (_cpp_save_file_entries): Use XCNEWVAR. (_cpp_read_file_entries): Use XNEWVAR. * identifiers.c (alloc_node): Use XOBNEW. * init.c (cpp_create_reader): Use XCNEW. (cpp_init_builtins): Cast of b->value to enum builtin_type. (read_original_directory): Cast return value of alloca. * lex.c (add_line_note): Use XRESIZEVEC. (warn_about_normalization): Use XNEWVEC. (_cpp_lex_direct): Cast node->directive_index to (enum cpp_ttype). (new_buff): Use XNEWVEC. * line-map.c (linemap_add): Use XRESIZEVEC. * macro.c (builtin_macro): Cast return value of alloca. (paste_tokens): Likewise. (expand_arg): Use XNEWVEC and XRESIZEVEC. (_cpp_save_parameter): Use XRESIZEVEC. (create_iso_definition): Cast allocated storage to proper type. (_cpp_create_definition): Likewise. (cpp_macro_definition): Use XRESIZEVEC. * makedepend.c (add_clm): Use XNEW. (add_dir): Likewise. * mkdeps.c (munge): Use XNEWVEC. (deps_init): Use XCNEW. (deps_add_target): Use XRESIZEVEC. (deps_add_default_target): Cast return value of alloca. (deps_add_dep): Use XRESIZEVEC. (deps_add_vpath): Likewise. Use XNEWVEC too. (deps_restore): Likewise. * pch.c (save_idents): Use XNEW and XNEWVEC. (cpp_save_state): Use XNEW. (count_defs): Cast return value of htab_find. (write_defs): Likewise. (cpp_write_pch_deps): Use XNEWVEC. (collect_ht_nodes): Use XRESIZEVEC. (cpp_valid_state): Use XNEWVEC. (save_macros): Use XRESIZEVEC. Cast return value of xmemdup. * symtab.c (ht_create): Use XCNEW. (ht_lookup_with_hash): Cast return value of obstack_copy0. (ht_expand): Use XCNEWVEC. * system.h (HAVE_DESIGNATED_INITIALIZERS): False if __cplusplus. (bool): Do not define if __cplusplus. From-SVN: r100295
2005-05-28 17:52:48 +02:00
pchf = XNEWVAR (struct pchf_data, sizeof (struct pchf_data)
+ sizeof (struct pchf_entry) * (d.count - 1));
memcpy (pchf, &d, sizeof (struct pchf_data) - sizeof (struct pchf_entry));
if (fread (pchf->entries, sizeof (struct pchf_entry), d.count, f)
!= d.count)
return false;
return true;
}
/* The parameters for pchf_compare. */
struct pchf_compare_data
{
/* The size of the file we're looking for. */
off_t size;
/* The MD5 checksum of the file, if it's been computed. */
unsigned char sum[16];
/* Is SUM valid? */
bool sum_computed;
/* Do we need to worry about entries that don't have ONCE_ONLY set? */
bool check_included;
[multiple changes] 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * c-opts.c (c_common_handle_option): Add -finput-charset. * c.opt: Ditto. * cppcharset.c (one_iso88591_to_utf8): Remove. (convert_iso88591_utf8): Ditto. (conversion_tab): Remove 8859-1 converter. (_cpp_input_to_utf8): Remove. (_cpp_init_iconv_buffer): Ditto. (_cpp_close_iconv_buffer): Ditto. (_cpp_convert_input): New function. (_cpp_default_encoding): Ditto. * cpphash.h: Add/remove prototypes for above. * cppfiles.c (read_file_guts): Use _cpp_convert_input. * cppinit.c (cpp_create_reader): Use _cpp_default_encoding for narrow execution and input character sets. * cpplib.c (cpp_push_buffer): Delete uses of removed functions. * doc/cppopts.texi: Document -finput-charset. 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * gcc.c-torture/execute/wchar_t-1.c: Add -finput-charset. 2004-01-29 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * testsuite/22_locale/collate/compare/wchar_t/2.cc: Remove xfail. Use -finput-charset. * testsuite/22_locale/collate/compare/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/compare/wchar_t/wrapped_locale.cc: Ditto * testsuite/22_locale/collate/hash/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_locale.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_locale.cc: Ditto. From-SVN: r77136
2004-02-02 21:20:58 +01:00
/* The file that we're searching for. */
_cpp_file *f;
};
/* bsearch comparison function; look for D_P in E_P. */
static int
pchf_compare (const void *d_p, const void *e_p)
{
const struct pchf_entry *e = (const struct pchf_entry *)e_p;
struct pchf_compare_data *d = (struct pchf_compare_data *)d_p;
int result;
[multiple changes] 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * c-opts.c (c_common_handle_option): Add -finput-charset. * c.opt: Ditto. * cppcharset.c (one_iso88591_to_utf8): Remove. (convert_iso88591_utf8): Ditto. (conversion_tab): Remove 8859-1 converter. (_cpp_input_to_utf8): Remove. (_cpp_init_iconv_buffer): Ditto. (_cpp_close_iconv_buffer): Ditto. (_cpp_convert_input): New function. (_cpp_default_encoding): Ditto. * cpphash.h: Add/remove prototypes for above. * cppfiles.c (read_file_guts): Use _cpp_convert_input. * cppinit.c (cpp_create_reader): Use _cpp_default_encoding for narrow execution and input character sets. * cpplib.c (cpp_push_buffer): Delete uses of removed functions. * doc/cppopts.texi: Document -finput-charset. 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * gcc.c-torture/execute/wchar_t-1.c: Add -finput-charset. 2004-01-29 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * testsuite/22_locale/collate/compare/wchar_t/2.cc: Remove xfail. Use -finput-charset. * testsuite/22_locale/collate/compare/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/compare/wchar_t/wrapped_locale.cc: Ditto * testsuite/22_locale/collate/hash/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_locale.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_locale.cc: Ditto. From-SVN: r77136
2004-02-02 21:20:58 +01:00
result = memcmp (&d->size, &e->size, sizeof (off_t));
if (result != 0)
return result;
[multiple changes] 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * c-opts.c (c_common_handle_option): Add -finput-charset. * c.opt: Ditto. * cppcharset.c (one_iso88591_to_utf8): Remove. (convert_iso88591_utf8): Ditto. (conversion_tab): Remove 8859-1 converter. (_cpp_input_to_utf8): Remove. (_cpp_init_iconv_buffer): Ditto. (_cpp_close_iconv_buffer): Ditto. (_cpp_convert_input): New function. (_cpp_default_encoding): Ditto. * cpphash.h: Add/remove prototypes for above. * cppfiles.c (read_file_guts): Use _cpp_convert_input. * cppinit.c (cpp_create_reader): Use _cpp_default_encoding for narrow execution and input character sets. * cpplib.c (cpp_push_buffer): Delete uses of removed functions. * doc/cppopts.texi: Document -finput-charset. 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * gcc.c-torture/execute/wchar_t-1.c: Add -finput-charset. 2004-01-29 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * testsuite/22_locale/collate/compare/wchar_t/2.cc: Remove xfail. Use -finput-charset. * testsuite/22_locale/collate/compare/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/compare/wchar_t/wrapped_locale.cc: Ditto * testsuite/22_locale/collate/hash/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_locale.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_locale.cc: Ditto. From-SVN: r77136
2004-02-02 21:20:58 +01:00
if (! d->sum_computed)
{
_cpp_file *const f = d->f;
[multiple changes] 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * c-opts.c (c_common_handle_option): Add -finput-charset. * c.opt: Ditto. * cppcharset.c (one_iso88591_to_utf8): Remove. (convert_iso88591_utf8): Ditto. (conversion_tab): Remove 8859-1 converter. (_cpp_input_to_utf8): Remove. (_cpp_init_iconv_buffer): Ditto. (_cpp_close_iconv_buffer): Ditto. (_cpp_convert_input): New function. (_cpp_default_encoding): Ditto. * cpphash.h: Add/remove prototypes for above. * cppfiles.c (read_file_guts): Use _cpp_convert_input. * cppinit.c (cpp_create_reader): Use _cpp_default_encoding for narrow execution and input character sets. * cpplib.c (cpp_push_buffer): Delete uses of removed functions. * doc/cppopts.texi: Document -finput-charset. 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * gcc.c-torture/execute/wchar_t-1.c: Add -finput-charset. 2004-01-29 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * testsuite/22_locale/collate/compare/wchar_t/2.cc: Remove xfail. Use -finput-charset. * testsuite/22_locale/collate/compare/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/compare/wchar_t/wrapped_locale.cc: Ditto * testsuite/22_locale/collate/hash/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_locale.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_locale.cc: Ditto. From-SVN: r77136
2004-02-02 21:20:58 +01:00
md5_buffer ((const char *)f->buffer, f->st.st_size, d->sum);
d->sum_computed = true;
}
result = memcmp (d->sum, e->sum, 16);
if (result != 0)
return result;
if (d->check_included || e->once_only)
return 0;
else
return 1;
}
[multiple changes] 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * c-opts.c (c_common_handle_option): Add -finput-charset. * c.opt: Ditto. * cppcharset.c (one_iso88591_to_utf8): Remove. (convert_iso88591_utf8): Ditto. (conversion_tab): Remove 8859-1 converter. (_cpp_input_to_utf8): Remove. (_cpp_init_iconv_buffer): Ditto. (_cpp_close_iconv_buffer): Ditto. (_cpp_convert_input): New function. (_cpp_default_encoding): Ditto. * cpphash.h: Add/remove prototypes for above. * cppfiles.c (read_file_guts): Use _cpp_convert_input. * cppinit.c (cpp_create_reader): Use _cpp_default_encoding for narrow execution and input character sets. * cpplib.c (cpp_push_buffer): Delete uses of removed functions. * doc/cppopts.texi: Document -finput-charset. 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * gcc.c-torture/execute/wchar_t-1.c: Add -finput-charset. 2004-01-29 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * testsuite/22_locale/collate/compare/wchar_t/2.cc: Remove xfail. Use -finput-charset. * testsuite/22_locale/collate/compare/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/compare/wchar_t/wrapped_locale.cc: Ditto * testsuite/22_locale/collate/hash/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_locale.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_locale.cc: Ditto. From-SVN: r77136
2004-02-02 21:20:58 +01:00
/* Check that F is not in a list read from a PCH file (if any).
Assumes that f->buffer_valid is true. Return TRUE if the file
should not be read. */
static bool
check_file_against_entries (cpp_reader *pfile ATTRIBUTE_UNUSED,
_cpp_file *f,
bool check_included)
{
struct pchf_compare_data d;
[multiple changes] 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * c-opts.c (c_common_handle_option): Add -finput-charset. * c.opt: Ditto. * cppcharset.c (one_iso88591_to_utf8): Remove. (convert_iso88591_utf8): Ditto. (conversion_tab): Remove 8859-1 converter. (_cpp_input_to_utf8): Remove. (_cpp_init_iconv_buffer): Ditto. (_cpp_close_iconv_buffer): Ditto. (_cpp_convert_input): New function. (_cpp_default_encoding): Ditto. * cpphash.h: Add/remove prototypes for above. * cppfiles.c (read_file_guts): Use _cpp_convert_input. * cppinit.c (cpp_create_reader): Use _cpp_default_encoding for narrow execution and input character sets. * cpplib.c (cpp_push_buffer): Delete uses of removed functions. * doc/cppopts.texi: Document -finput-charset. 2004-02-02 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * gcc.c-torture/execute/wchar_t-1.c: Add -finput-charset. 2004-01-29 Eric Christopher <echristo@redhat.com> Zack Weinberg <zack@codesourcery.com> * testsuite/22_locale/collate/compare/wchar_t/2.cc: Remove xfail. Use -finput-charset. * testsuite/22_locale/collate/compare/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/compare/wchar_t/wrapped_locale.cc: Ditto * testsuite/22_locale/collate/hash/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/hash/wchar_t/wrapped_locale.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/2.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_env.cc: Ditto. * testsuite/22_locale/collate/transform/wchar_t/wrapped_locale.cc: Ditto. From-SVN: r77136
2004-02-02 21:20:58 +01:00
if (pchf == NULL
|| (! check_included && ! pchf->have_once_only))
return false;
d.size = f->st.st_size;
d.sum_computed = false;
d.f = f;
d.check_included = check_included;
return bsearch (&d, pchf->entries, pchf->count, sizeof (struct pchf_entry),
pchf_compare) != NULL;
}