gcc/gcc/cppfiles.c

1628 lines
42 KiB
C
Raw Normal View History

[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
/* Part of CPP library. (include file handling)
2000-01-20 00:47:13 +01:00
Copyright (C) 1986, 87, 89, 92-95, 98, 99, 2000 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
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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding! */
#include "config.h"
#include "system.h"
#include "cpplib.h"
/* The entry points to this file are: find_include_file, finclude,
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
include_hash, append_include_chain, deps_output, and file_cleanup.
[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
file_cleanup is only called through CPP_BUFFER(pfile)->cleanup,
so it's static anyway. */
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
static struct include_hash *redundant_include_p
PARAMS ((cpp_reader *,
struct include_hash *,
struct file_name_list *));
static struct file_name_map *read_name_map
PARAMS ((cpp_reader *, const char *));
static char *read_filename_string PARAMS ((int, FILE *));
static char *remap_filename PARAMS ((cpp_reader *, char *,
struct file_name_list *));
static long read_and_prescan PARAMS ((cpp_reader *, cpp_buffer *,
int, size_t));
static struct file_name_list *actual_directory
PARAMS ((cpp_reader *, const char *));
static void initialize_input_buffer PARAMS ((cpp_reader *, int,
struct stat *));
static int file_cleanup PARAMS ((cpp_buffer *, cpp_reader *));
static U_CHAR *find_position PARAMS ((U_CHAR *, U_CHAR *,
unsigned long *));
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
#if 0
static void hack_vms_include_specification PARAMS ((char *));
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
#endif
[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
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
/* Windows does not natively support inodes, and neither does MSDOS.
Cygwin's emulation can generate non-unique inodes, so don't use it.
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
VMS has non-numeric inodes. */
#ifdef VMS
#define INO_T_EQ(a, b) (!bcmp((char *) &(a), (char *) &(b), sizeof (a)))
#elif (defined _WIN32 && ! defined (_UWIN)) \
|| defined __MSDOS__
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
#define INO_T_EQ(a, b) 0
#else
#define INO_T_EQ(a, b) ((a) == (b))
#endif
[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
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
/* Merge the four include chains together in the order quote, bracket,
system, after. Remove duplicate dirs (as determined by
INO_T_EQ()). The system_include and after_include chains are never
referred to again after this function; all access is through the
bracket_include path.
For the future: Check if the directory is empty (but
how?) and possibly preload the include hash. */
[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
void
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
merge_include_chains (opts)
struct cpp_options *opts;
[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
{
cppinit.c: Instead of one pending list... 1999-03-15 21:39 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppinit.c: Instead of one pending list, keep separate lists for each category of pending option: -D/-U, -A, -include, -imacros. Move the four partial include-path lists into the pending block. Use head and tail pointers so we don't ever have to reverse the lists. (cpp_start_read): Break out blocks of code to their own functions: install_predefs and initialize_dependency_output. Use path_include for C_INCLUDE_PATH and friends as well as CPATH. Remove include_defaults gunk. Warn about the combination of -lang-chill and -trigraphs. Optimize string bashing. Walk each pending list once, deallocating as we go. (append_include_chain): Brought over from cppfiles.c. Mark dirs as system include dirs if and only if appending to system include path. If opts->verbose, print a notice when a dir is dropped from the include path because it doesn't exist. Fix memory leak: this function is not supposed to copy its DIR argument. (nreverse_pending, push_pending): Removed. (APPEND): New macro for adding to pending lists. (path_include): Can now add to any partial include path. (base_name): Bring over from cccp.c. (cpp_options_init): Allocate the pending block. (cpp_handle_option): Add --version. Exit after --help. Fix formatting. Order -ifoo options by frequency of usage. (install_predefs): New function, simplified version of code that was in cpp_start_read. (initialize_dependency_output): Likewise. Understand OBJECT_SUFFIX. * cppfiles.c (simplify_pathname): Export. (merge_include_chains): Don't nreverse the lists. If opts->verbose, print a notice when a duplicate dir is detected and dropped from the include path. (finclude): Fix excessive cleverness in setting fp->system_header_p. (actual_directory): Set x->sysp from CPP_BUFFER (pfile)->system_header_p so that one system header may include another with "". (deps_output): Fix double adjustment of deps_size which would cause all dependencies after the first two lines to be lost. * cpplib.c (cpp_unassert): New function. * cpplib.h: Lay out struct cpp_pending here. Adjust prototypes. Add include_prefix_len to struct cpp_options. From-SVN: r25793
1999-03-15 19:42:46 +01:00
struct file_name_list *prev, *cur, *other;
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
struct file_name_list *quote, *brack, *systm, *after;
struct file_name_list *qtail, *btail, *stail, *atail;
cppinit.c: Instead of one pending list... 1999-03-15 21:39 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppinit.c: Instead of one pending list, keep separate lists for each category of pending option: -D/-U, -A, -include, -imacros. Move the four partial include-path lists into the pending block. Use head and tail pointers so we don't ever have to reverse the lists. (cpp_start_read): Break out blocks of code to their own functions: install_predefs and initialize_dependency_output. Use path_include for C_INCLUDE_PATH and friends as well as CPATH. Remove include_defaults gunk. Warn about the combination of -lang-chill and -trigraphs. Optimize string bashing. Walk each pending list once, deallocating as we go. (append_include_chain): Brought over from cppfiles.c. Mark dirs as system include dirs if and only if appending to system include path. If opts->verbose, print a notice when a dir is dropped from the include path because it doesn't exist. Fix memory leak: this function is not supposed to copy its DIR argument. (nreverse_pending, push_pending): Removed. (APPEND): New macro for adding to pending lists. (path_include): Can now add to any partial include path. (base_name): Bring over from cccp.c. (cpp_options_init): Allocate the pending block. (cpp_handle_option): Add --version. Exit after --help. Fix formatting. Order -ifoo options by frequency of usage. (install_predefs): New function, simplified version of code that was in cpp_start_read. (initialize_dependency_output): Likewise. Understand OBJECT_SUFFIX. * cppfiles.c (simplify_pathname): Export. (merge_include_chains): Don't nreverse the lists. If opts->verbose, print a notice when a duplicate dir is detected and dropped from the include path. (finclude): Fix excessive cleverness in setting fp->system_header_p. (actual_directory): Set x->sysp from CPP_BUFFER (pfile)->system_header_p so that one system header may include another with "". (deps_output): Fix double adjustment of deps_size which would cause all dependencies after the first two lines to be lost. * cpplib.c (cpp_unassert): New function. * cpplib.h: Lay out struct cpp_pending here. Adjust prototypes. Add include_prefix_len to struct cpp_options. From-SVN: r25793
1999-03-15 19:42:46 +01:00
qtail = opts->pending->quote_tail;
btail = opts->pending->brack_tail;
stail = opts->pending->systm_tail;
atail = opts->pending->after_tail;
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
cppinit.c: Instead of one pending list... 1999-03-15 21:39 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppinit.c: Instead of one pending list, keep separate lists for each category of pending option: -D/-U, -A, -include, -imacros. Move the four partial include-path lists into the pending block. Use head and tail pointers so we don't ever have to reverse the lists. (cpp_start_read): Break out blocks of code to their own functions: install_predefs and initialize_dependency_output. Use path_include for C_INCLUDE_PATH and friends as well as CPATH. Remove include_defaults gunk. Warn about the combination of -lang-chill and -trigraphs. Optimize string bashing. Walk each pending list once, deallocating as we go. (append_include_chain): Brought over from cppfiles.c. Mark dirs as system include dirs if and only if appending to system include path. If opts->verbose, print a notice when a dir is dropped from the include path because it doesn't exist. Fix memory leak: this function is not supposed to copy its DIR argument. (nreverse_pending, push_pending): Removed. (APPEND): New macro for adding to pending lists. (path_include): Can now add to any partial include path. (base_name): Bring over from cccp.c. (cpp_options_init): Allocate the pending block. (cpp_handle_option): Add --version. Exit after --help. Fix formatting. Order -ifoo options by frequency of usage. (install_predefs): New function, simplified version of code that was in cpp_start_read. (initialize_dependency_output): Likewise. Understand OBJECT_SUFFIX. * cppfiles.c (simplify_pathname): Export. (merge_include_chains): Don't nreverse the lists. If opts->verbose, print a notice when a duplicate dir is detected and dropped from the include path. (finclude): Fix excessive cleverness in setting fp->system_header_p. (actual_directory): Set x->sysp from CPP_BUFFER (pfile)->system_header_p so that one system header may include another with "". (deps_output): Fix double adjustment of deps_size which would cause all dependencies after the first two lines to be lost. * cpplib.c (cpp_unassert): New function. * cpplib.h: Lay out struct cpp_pending here. Adjust prototypes. Add include_prefix_len to struct cpp_options. From-SVN: r25793
1999-03-15 19:42:46 +01:00
quote = opts->pending->quote_head;
brack = opts->pending->brack_head;
systm = opts->pending->systm_head;
after = opts->pending->after_head;
[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
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
/* Paste together bracket, system, and after include chains. */
if (stail)
stail->next = after;
[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
else
cpplib.h: Delete struct import_file. Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu> * cpplib.h: Delete struct import_file. Add ihash element to struct cpp_buffer. Delete dont_repeat_files and import_hash_table elements from cpp_reader; change all_include_files to a hash table. Delete all foobar_include / last_foobar_include elements from struct cpp_options; put back four such: quote_include, bracket_include, system_include, after_include. Redo struct file_name_list completely. Add new structure type include_hash. Add prototypes for merge_include_chains and include_hash. Change prototypes for finclude, find_include_file, and append_include_chain to match changes below. * cppfiles.c (simplify_pathname, include_hash, remap_filename, merge_include_chains): New functions. (add_import, lookup_import, open_include_file): Removed. (INO_T_EQ): Define this (copied from cccp.c). (hack_vms_include_specification): Remove all calls and #if 0 out the definition. It was being called incorrectly and at the wrong times. Until a VMSie can look at this, it's better to not pretend to support it. (append_include_chain): Change calling convention; now takes only one directory at a time, and sets up the data structure itself. (redundant_include_p): Rewritten - this is now used for all include redundancy, whether by #ifndef, #import, or #pragma once. Looks up things in the include hash table. (file_cleanup): Decrement pfile->system_include_depth here if it's >0. (find_include_file): Calling convention changed; now passes around a struct include_hash instead of 3 separate parameters. Guts ripped out and replaced with new include_hash mechanism. (finclude): Calling convention changed as for find_include_file. Error exits pulled out-of-line. Reformat. (safe_read): Return a long, not an int. (deps_output): Don't recurse. * cpplib.c (is_system_include): Deleted. (path_include): Fix up call to append_include_chain. (do_include): Fix up calls to find_include_file and finclude. Clean up dependency output a bit. Shorten obnoxiously lengthy #import warning message. Don't decrement pfile->system_include_depth here. (do_pragma): Understand the include_hash structure. Reformat. (do_endif): Correct handling of control macros. Understand the include_hash. (cpp_start_read): Fix up calls to finclude. Call merge_include_chains. (cpp_handle_option): Fix up calls to append_include_chain. Understand the four partial include chains. (cpp_finish): Add debugging code (#if 0-ed out) for the include_hash. (cpp_cleanup): Free the include_hash, not the import hash and the all_include and dont_repeat lists which no longer exist. From-SVN: r23857
1998-11-25 12:56:54 +01:00
systm = after;
if (btail)
btail->next = systm;
else
brack = systm;
[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
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
/* This is a bit tricky.
First we drop dupes from the quote-include list.
Then we drop dupes from the bracket-include list.
Finally, if qtail and brack are the same directory,
we cut out qtail.
[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
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
We can't just merge the lists and then uniquify them because
then we may lose directories from the <> search path that should
be there; consider -Ifoo -Ibar -I- -Ifoo -Iquux. It is however
safe to treat -Ibar -Ifoo -I- -Ifoo -Iquux as if written
cppinit.c: Instead of one pending list... 1999-03-15 21:39 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppinit.c: Instead of one pending list, keep separate lists for each category of pending option: -D/-U, -A, -include, -imacros. Move the four partial include-path lists into the pending block. Use head and tail pointers so we don't ever have to reverse the lists. (cpp_start_read): Break out blocks of code to their own functions: install_predefs and initialize_dependency_output. Use path_include for C_INCLUDE_PATH and friends as well as CPATH. Remove include_defaults gunk. Warn about the combination of -lang-chill and -trigraphs. Optimize string bashing. Walk each pending list once, deallocating as we go. (append_include_chain): Brought over from cppfiles.c. Mark dirs as system include dirs if and only if appending to system include path. If opts->verbose, print a notice when a dir is dropped from the include path because it doesn't exist. Fix memory leak: this function is not supposed to copy its DIR argument. (nreverse_pending, push_pending): Removed. (APPEND): New macro for adding to pending lists. (path_include): Can now add to any partial include path. (base_name): Bring over from cccp.c. (cpp_options_init): Allocate the pending block. (cpp_handle_option): Add --version. Exit after --help. Fix formatting. Order -ifoo options by frequency of usage. (install_predefs): New function, simplified version of code that was in cpp_start_read. (initialize_dependency_output): Likewise. Understand OBJECT_SUFFIX. * cppfiles.c (simplify_pathname): Export. (merge_include_chains): Don't nreverse the lists. If opts->verbose, print a notice when a duplicate dir is detected and dropped from the include path. (finclude): Fix excessive cleverness in setting fp->system_header_p. (actual_directory): Set x->sysp from CPP_BUFFER (pfile)->system_header_p so that one system header may include another with "". (deps_output): Fix double adjustment of deps_size which would cause all dependencies after the first two lines to be lost. * cpplib.c (cpp_unassert): New function. * cpplib.h: Lay out struct cpp_pending here. Adjust prototypes. Add include_prefix_len to struct cpp_options. From-SVN: r25793
1999-03-15 19:42:46 +01:00
-Ibar -I- -Ifoo -Iquux.
Note that this algorithm is quadratic in the number of -I switches,
which is acceptable since there aren't usually that many of them. */
[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
for (cur = quote, prev = NULL; cur; cur = cur->next)
cpplib.h: Delete struct import_file. Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu> * cpplib.h: Delete struct import_file. Add ihash element to struct cpp_buffer. Delete dont_repeat_files and import_hash_table elements from cpp_reader; change all_include_files to a hash table. Delete all foobar_include / last_foobar_include elements from struct cpp_options; put back four such: quote_include, bracket_include, system_include, after_include. Redo struct file_name_list completely. Add new structure type include_hash. Add prototypes for merge_include_chains and include_hash. Change prototypes for finclude, find_include_file, and append_include_chain to match changes below. * cppfiles.c (simplify_pathname, include_hash, remap_filename, merge_include_chains): New functions. (add_import, lookup_import, open_include_file): Removed. (INO_T_EQ): Define this (copied from cccp.c). (hack_vms_include_specification): Remove all calls and #if 0 out the definition. It was being called incorrectly and at the wrong times. Until a VMSie can look at this, it's better to not pretend to support it. (append_include_chain): Change calling convention; now takes only one directory at a time, and sets up the data structure itself. (redundant_include_p): Rewritten - this is now used for all include redundancy, whether by #ifndef, #import, or #pragma once. Looks up things in the include hash table. (file_cleanup): Decrement pfile->system_include_depth here if it's >0. (find_include_file): Calling convention changed; now passes around a struct include_hash instead of 3 separate parameters. Guts ripped out and replaced with new include_hash mechanism. (finclude): Calling convention changed as for find_include_file. Error exits pulled out-of-line. Reformat. (safe_read): Return a long, not an int. (deps_output): Don't recurse. * cpplib.c (is_system_include): Deleted. (path_include): Fix up call to append_include_chain. (do_include): Fix up calls to find_include_file and finclude. Clean up dependency output a bit. Shorten obnoxiously lengthy #import warning message. Don't decrement pfile->system_include_depth here. (do_pragma): Understand the include_hash structure. Reformat. (do_endif): Correct handling of control macros. Understand the include_hash. (cpp_start_read): Fix up calls to finclude. Call merge_include_chains. (cpp_handle_option): Fix up calls to append_include_chain. Understand the four partial include chains. (cpp_finish): Add debugging code (#if 0-ed out) for the include_hash. (cpp_cleanup): Free the include_hash, not the import hash and the all_include and dont_repeat lists which no longer exist. From-SVN: r23857
1998-11-25 12:56:54 +01:00
{
for (other = quote; other != cur; other = other->next)
if (INO_T_EQ (cur->ino, other->ino)
&& cur->dev == other->dev)
{
cppinit.c: Instead of one pending list... 1999-03-15 21:39 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppinit.c: Instead of one pending list, keep separate lists for each category of pending option: -D/-U, -A, -include, -imacros. Move the four partial include-path lists into the pending block. Use head and tail pointers so we don't ever have to reverse the lists. (cpp_start_read): Break out blocks of code to their own functions: install_predefs and initialize_dependency_output. Use path_include for C_INCLUDE_PATH and friends as well as CPATH. Remove include_defaults gunk. Warn about the combination of -lang-chill and -trigraphs. Optimize string bashing. Walk each pending list once, deallocating as we go. (append_include_chain): Brought over from cppfiles.c. Mark dirs as system include dirs if and only if appending to system include path. If opts->verbose, print a notice when a dir is dropped from the include path because it doesn't exist. Fix memory leak: this function is not supposed to copy its DIR argument. (nreverse_pending, push_pending): Removed. (APPEND): New macro for adding to pending lists. (path_include): Can now add to any partial include path. (base_name): Bring over from cccp.c. (cpp_options_init): Allocate the pending block. (cpp_handle_option): Add --version. Exit after --help. Fix formatting. Order -ifoo options by frequency of usage. (install_predefs): New function, simplified version of code that was in cpp_start_read. (initialize_dependency_output): Likewise. Understand OBJECT_SUFFIX. * cppfiles.c (simplify_pathname): Export. (merge_include_chains): Don't nreverse the lists. If opts->verbose, print a notice when a duplicate dir is detected and dropped from the include path. (finclude): Fix excessive cleverness in setting fp->system_header_p. (actual_directory): Set x->sysp from CPP_BUFFER (pfile)->system_header_p so that one system header may include another with "". (deps_output): Fix double adjustment of deps_size which would cause all dependencies after the first two lines to be lost. * cpplib.c (cpp_unassert): New function. * cpplib.h: Lay out struct cpp_pending here. Adjust prototypes. Add include_prefix_len to struct cpp_options. From-SVN: r25793
1999-03-15 19:42:46 +01:00
if (opts->verbose)
cpp_notice ("ignoring duplicate directory `%s'\n", cur->name);
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
prev->next = cur->next;
free (cur->name);
free (cur);
cur = prev;
break;
}
prev = cur;
[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
}
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
qtail = prev;
[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
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
for (cur = brack; cur; cur = cur->next)
[multiple changes] 1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu> * c-lang.c: Declare extern char *yy_cur if USE_CPPLIB. (lang_init): Call check_newline always. * c-lex.c (init_parse) [USE_CPPLIB=1]: After calling cpp_start_read, set yy_cur and yy_lim to read from parse_in.token_buffer, so that we'll see the first #line directive. * cpplib.c (cpp_start_read): finclude the main input file before processing -include/-imacros. Process -imacros and -include separately, and handle -include by stacking a buffer for the file in question as if it'd been #included. * toplev.c (documented_lang_options) Recognize -H when USE_CPPLIB is on. 1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu> * cpplib.c: Merge do_once into do_pragma. Break file handling code out of do_include. Move append_include_chain, deps_output, file_cleanup, redundant_include_p, import_hash, lookup_import, add_import, read_filename_string, read_name_map, open_include_file, finclude, safe_read to cppfiles.c. Move prototypes for deps_output, append_include_chain, finclude to cpplib.h. Move definition of struct file_name_list there also. * cppfiles.c: New file. Contains all the above functions broken out of cpplib.c; also hack_vms_include_specification from cccp.c and find_include_file, a new function broken out of do_include. * Makefile.in (cppmain): Depend on cppfiles.o. (fix-header): Likewise. (cppfiles.o): New target. * configure.in (--enable-c-cpplib): Add cppfiles.o to extra_c_objs. Add ../cppfiles.o to extra_cxx_objs. From-SVN: r23424
1998-10-29 12:54:13 +01:00
{
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
for (other = brack; other != cur; other = other->next)
if (INO_T_EQ (cur->ino, other->ino)
&& cur->dev == other->dev)
{
cppinit.c: Instead of one pending list... 1999-03-15 21:39 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppinit.c: Instead of one pending list, keep separate lists for each category of pending option: -D/-U, -A, -include, -imacros. Move the four partial include-path lists into the pending block. Use head and tail pointers so we don't ever have to reverse the lists. (cpp_start_read): Break out blocks of code to their own functions: install_predefs and initialize_dependency_output. Use path_include for C_INCLUDE_PATH and friends as well as CPATH. Remove include_defaults gunk. Warn about the combination of -lang-chill and -trigraphs. Optimize string bashing. Walk each pending list once, deallocating as we go. (append_include_chain): Brought over from cppfiles.c. Mark dirs as system include dirs if and only if appending to system include path. If opts->verbose, print a notice when a dir is dropped from the include path because it doesn't exist. Fix memory leak: this function is not supposed to copy its DIR argument. (nreverse_pending, push_pending): Removed. (APPEND): New macro for adding to pending lists. (path_include): Can now add to any partial include path. (base_name): Bring over from cccp.c. (cpp_options_init): Allocate the pending block. (cpp_handle_option): Add --version. Exit after --help. Fix formatting. Order -ifoo options by frequency of usage. (install_predefs): New function, simplified version of code that was in cpp_start_read. (initialize_dependency_output): Likewise. Understand OBJECT_SUFFIX. * cppfiles.c (simplify_pathname): Export. (merge_include_chains): Don't nreverse the lists. If opts->verbose, print a notice when a duplicate dir is detected and dropped from the include path. (finclude): Fix excessive cleverness in setting fp->system_header_p. (actual_directory): Set x->sysp from CPP_BUFFER (pfile)->system_header_p so that one system header may include another with "". (deps_output): Fix double adjustment of deps_size which would cause all dependencies after the first two lines to be lost. * cpplib.c (cpp_unassert): New function. * cpplib.h: Lay out struct cpp_pending here. Adjust prototypes. Add include_prefix_len to struct cpp_options. From-SVN: r25793
1999-03-15 19:42:46 +01:00
if (opts->verbose)
cpp_notice ("ignoring duplicate directory `%s'\n", cur->name);
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
prev->next = cur->next;
free (cur->name);
free (cur);
cur = prev;
break;
}
prev = cur;
[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
}
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
if (quote)
{
if (INO_T_EQ (qtail->ino, brack->ino) && qtail->dev == brack->dev)
{
if (quote == qtail)
[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
{
cppinit.c: Instead of one pending list... 1999-03-15 21:39 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppinit.c: Instead of one pending list, keep separate lists for each category of pending option: -D/-U, -A, -include, -imacros. Move the four partial include-path lists into the pending block. Use head and tail pointers so we don't ever have to reverse the lists. (cpp_start_read): Break out blocks of code to their own functions: install_predefs and initialize_dependency_output. Use path_include for C_INCLUDE_PATH and friends as well as CPATH. Remove include_defaults gunk. Warn about the combination of -lang-chill and -trigraphs. Optimize string bashing. Walk each pending list once, deallocating as we go. (append_include_chain): Brought over from cppfiles.c. Mark dirs as system include dirs if and only if appending to system include path. If opts->verbose, print a notice when a dir is dropped from the include path because it doesn't exist. Fix memory leak: this function is not supposed to copy its DIR argument. (nreverse_pending, push_pending): Removed. (APPEND): New macro for adding to pending lists. (path_include): Can now add to any partial include path. (base_name): Bring over from cccp.c. (cpp_options_init): Allocate the pending block. (cpp_handle_option): Add --version. Exit after --help. Fix formatting. Order -ifoo options by frequency of usage. (install_predefs): New function, simplified version of code that was in cpp_start_read. (initialize_dependency_output): Likewise. Understand OBJECT_SUFFIX. * cppfiles.c (simplify_pathname): Export. (merge_include_chains): Don't nreverse the lists. If opts->verbose, print a notice when a duplicate dir is detected and dropped from the include path. (finclude): Fix excessive cleverness in setting fp->system_header_p. (actual_directory): Set x->sysp from CPP_BUFFER (pfile)->system_header_p so that one system header may include another with "". (deps_output): Fix double adjustment of deps_size which would cause all dependencies after the first two lines to be lost. * cpplib.c (cpp_unassert): New function. * cpplib.h: Lay out struct cpp_pending here. Adjust prototypes. Add include_prefix_len to struct cpp_options. From-SVN: r25793
1999-03-15 19:42:46 +01:00
if (opts->verbose)
cpp_notice ("ignoring duplicate directory `%s'\n",
quote->name);
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
free (quote->name);
free (quote);
quote = brack;
[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
}
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
else
{
cur = quote;
while (cur->next != qtail)
cur = cur->next;
cur->next = brack;
cppinit.c: Instead of one pending list... 1999-03-15 21:39 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppinit.c: Instead of one pending list, keep separate lists for each category of pending option: -D/-U, -A, -include, -imacros. Move the four partial include-path lists into the pending block. Use head and tail pointers so we don't ever have to reverse the lists. (cpp_start_read): Break out blocks of code to their own functions: install_predefs and initialize_dependency_output. Use path_include for C_INCLUDE_PATH and friends as well as CPATH. Remove include_defaults gunk. Warn about the combination of -lang-chill and -trigraphs. Optimize string bashing. Walk each pending list once, deallocating as we go. (append_include_chain): Brought over from cppfiles.c. Mark dirs as system include dirs if and only if appending to system include path. If opts->verbose, print a notice when a dir is dropped from the include path because it doesn't exist. Fix memory leak: this function is not supposed to copy its DIR argument. (nreverse_pending, push_pending): Removed. (APPEND): New macro for adding to pending lists. (path_include): Can now add to any partial include path. (base_name): Bring over from cccp.c. (cpp_options_init): Allocate the pending block. (cpp_handle_option): Add --version. Exit after --help. Fix formatting. Order -ifoo options by frequency of usage. (install_predefs): New function, simplified version of code that was in cpp_start_read. (initialize_dependency_output): Likewise. Understand OBJECT_SUFFIX. * cppfiles.c (simplify_pathname): Export. (merge_include_chains): Don't nreverse the lists. If opts->verbose, print a notice when a duplicate dir is detected and dropped from the include path. (finclude): Fix excessive cleverness in setting fp->system_header_p. (actual_directory): Set x->sysp from CPP_BUFFER (pfile)->system_header_p so that one system header may include another with "". (deps_output): Fix double adjustment of deps_size which would cause all dependencies after the first two lines to be lost. * cpplib.c (cpp_unassert): New function. * cpplib.h: Lay out struct cpp_pending here. Adjust prototypes. Add include_prefix_len to struct cpp_options. From-SVN: r25793
1999-03-15 19:42:46 +01:00
if (opts->verbose)
cpp_notice ("ignoring duplicate directory `%s'\n",
qtail->name);
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
free (qtail->name);
free (qtail);
}
}
else
qtail->next = brack;
[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
}
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
else
quote = brack;
[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
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
opts->quote_include = quote;
opts->bracket_include = brack;
[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
}
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
/* Look up or add an entry to the table of all includes. This table
is indexed by the name as it appears in the #include line. The
->next_this_file chain stores all different files with the same
#include name (there are at least three ways this can happen). The
hash function could probably be improved a bit. */
[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
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
struct include_hash *
include_hash (pfile, fname, add)
[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
cpp_reader *pfile;
cpperror.c (cpp_file_line_for_message): Constify a char*. * cpperror.c (cpp_file_line_for_message): Constify a char*. * cppexp.c (parse_number, parse_charconst, cpp_lex, cpp_parse_expr): Add static prototypes. (parse_charconst): Don't cast away const-ness. (token): Constify a char*. * cppfiles.c (file_name_list, include_hash, find_include_file, finclude, initialize_input_buffer): Constify a char*. (file_cleanup, find_position): Add static prototypes. * cpphash.c (macro_cleanup, macarg, timestamp, special_symbol, collect_expansion): Add static prototypes. (cpp_install, create_definition, monthnames): Constify a char*. * cpphash.h (cpp_install): Likewise. * cppinit.c (known_suffixes, default_include, dump_special_to_buffer, NAME, cpp_start_read, cpp_finish): Likewise. (base_name, dump_special_to_buffer, initialize_dependency_output): Add static prototypes. * cpplib.c (my_strerror): Constify a char*. (null_underflow, null_cleanup, skip_comment, copy_comment, copy_rest_of_line, handle_directive, pass_thru_directive, get_directive_token, read_line_number, cpp_print_file_and_line, v_cpp_error, v_cpp_warning, v_cpp_error_with_line, v_cpp_warning_with_line, detect_if_not_defined, consider_directive_while_skipping): Add static prototypes. (pass_thru_directive, check_macro_name, cpp_expand_to_buffer, cpp_pedwarn_with_file_and_line): Constify a char*. * cpplib.h (cpp_options, include_hash, progname, definition, cpp_pedwarn_with_file_and_line, cpp_expand_to_buffer, check_macro_name, cpp_pfatal_with_name, cpp_file_line_for_message, find_include_file, deps_output, include_hash): Constify a char*. * cppmain.c (progname): Constify. (main): Add prototype. Use return, not exit. * fix-header.c (fatal, add_symbols, lookup_std_proto, write_lbrac, recognized_macro, check_macro_names, read_scan_file, write_rbrac, inf_skip_spaces, inf_read_upto, inf_scan_ident, inf_scan_ident, check_protection): Add static prototype. (xfree): Remove. (progname, recognized_macrom, recognized_extern): Constify a char*. (main): Add prototype. * gen-protos.c (progname): Constify a char*. From-SVN: r29171
1999-09-07 17:41:26 +02:00
const char *fname;
cpplib.h: Delete struct import_file. Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu> * cpplib.h: Delete struct import_file. Add ihash element to struct cpp_buffer. Delete dont_repeat_files and import_hash_table elements from cpp_reader; change all_include_files to a hash table. Delete all foobar_include / last_foobar_include elements from struct cpp_options; put back four such: quote_include, bracket_include, system_include, after_include. Redo struct file_name_list completely. Add new structure type include_hash. Add prototypes for merge_include_chains and include_hash. Change prototypes for finclude, find_include_file, and append_include_chain to match changes below. * cppfiles.c (simplify_pathname, include_hash, remap_filename, merge_include_chains): New functions. (add_import, lookup_import, open_include_file): Removed. (INO_T_EQ): Define this (copied from cccp.c). (hack_vms_include_specification): Remove all calls and #if 0 out the definition. It was being called incorrectly and at the wrong times. Until a VMSie can look at this, it's better to not pretend to support it. (append_include_chain): Change calling convention; now takes only one directory at a time, and sets up the data structure itself. (redundant_include_p): Rewritten - this is now used for all include redundancy, whether by #ifndef, #import, or #pragma once. Looks up things in the include hash table. (file_cleanup): Decrement pfile->system_include_depth here if it's >0. (find_include_file): Calling convention changed; now passes around a struct include_hash instead of 3 separate parameters. Guts ripped out and replaced with new include_hash mechanism. (finclude): Calling convention changed as for find_include_file. Error exits pulled out-of-line. Reformat. (safe_read): Return a long, not an int. (deps_output): Don't recurse. * cpplib.c (is_system_include): Deleted. (path_include): Fix up call to append_include_chain. (do_include): Fix up calls to find_include_file and finclude. Clean up dependency output a bit. Shorten obnoxiously lengthy #import warning message. Don't decrement pfile->system_include_depth here. (do_pragma): Understand the include_hash structure. Reformat. (do_endif): Correct handling of control macros. Understand the include_hash. (cpp_start_read): Fix up calls to finclude. Call merge_include_chains. (cpp_handle_option): Fix up calls to append_include_chain. Understand the four partial include chains. (cpp_finish): Add debugging code (#if 0-ed out) for the include_hash. (cpp_cleanup): Free the include_hash, not the import hash and the all_include and dont_repeat lists which no longer exist. From-SVN: r23857
1998-11-25 12:56:54 +01:00
int add;
[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
{
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
unsigned int hash = 0;
struct include_hash *l, *m;
cpperror.c (cpp_file_line_for_message): Constify a char*. * cpperror.c (cpp_file_line_for_message): Constify a char*. * cppexp.c (parse_number, parse_charconst, cpp_lex, cpp_parse_expr): Add static prototypes. (parse_charconst): Don't cast away const-ness. (token): Constify a char*. * cppfiles.c (file_name_list, include_hash, find_include_file, finclude, initialize_input_buffer): Constify a char*. (file_cleanup, find_position): Add static prototypes. * cpphash.c (macro_cleanup, macarg, timestamp, special_symbol, collect_expansion): Add static prototypes. (cpp_install, create_definition, monthnames): Constify a char*. * cpphash.h (cpp_install): Likewise. * cppinit.c (known_suffixes, default_include, dump_special_to_buffer, NAME, cpp_start_read, cpp_finish): Likewise. (base_name, dump_special_to_buffer, initialize_dependency_output): Add static prototypes. * cpplib.c (my_strerror): Constify a char*. (null_underflow, null_cleanup, skip_comment, copy_comment, copy_rest_of_line, handle_directive, pass_thru_directive, get_directive_token, read_line_number, cpp_print_file_and_line, v_cpp_error, v_cpp_warning, v_cpp_error_with_line, v_cpp_warning_with_line, detect_if_not_defined, consider_directive_while_skipping): Add static prototypes. (pass_thru_directive, check_macro_name, cpp_expand_to_buffer, cpp_pedwarn_with_file_and_line): Constify a char*. * cpplib.h (cpp_options, include_hash, progname, definition, cpp_pedwarn_with_file_and_line, cpp_expand_to_buffer, check_macro_name, cpp_pfatal_with_name, cpp_file_line_for_message, find_include_file, deps_output, include_hash): Constify a char*. * cppmain.c (progname): Constify. (main): Add prototype. Use return, not exit. * fix-header.c (fatal, add_symbols, lookup_std_proto, write_lbrac, recognized_macro, check_macro_names, read_scan_file, write_rbrac, inf_skip_spaces, inf_read_upto, inf_scan_ident, inf_scan_ident, check_protection): Add static prototype. (xfree): Remove. (progname, recognized_macrom, recognized_extern): Constify a char*. (main): Add prototype. * gen-protos.c (progname): Constify a char*. From-SVN: r29171
1999-09-07 17:41:26 +02:00
const char *f = fname;
[multiple changes] 1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu> * c-lang.c: Declare extern char *yy_cur if USE_CPPLIB. (lang_init): Call check_newline always. * c-lex.c (init_parse) [USE_CPPLIB=1]: After calling cpp_start_read, set yy_cur and yy_lim to read from parse_in.token_buffer, so that we'll see the first #line directive. * cpplib.c (cpp_start_read): finclude the main input file before processing -include/-imacros. Process -imacros and -include separately, and handle -include by stacking a buffer for the file in question as if it'd been #included. * toplev.c (documented_lang_options) Recognize -H when USE_CPPLIB is on. 1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu> * cpplib.c: Merge do_once into do_pragma. Break file handling code out of do_include. Move append_include_chain, deps_output, file_cleanup, redundant_include_p, import_hash, lookup_import, add_import, read_filename_string, read_name_map, open_include_file, finclude, safe_read to cppfiles.c. Move prototypes for deps_output, append_include_chain, finclude to cpplib.h. Move definition of struct file_name_list there also. * cppfiles.c: New file. Contains all the above functions broken out of cpplib.c; also hack_vms_include_specification from cccp.c and find_include_file, a new function broken out of do_include. * Makefile.in (cppmain): Depend on cppfiles.o. (fix-header): Likewise. (cppfiles.o): New target. * configure.in (--enable-c-cpplib): Add cppfiles.o to extra_c_objs. Add ../cppfiles.o to extra_cxx_objs. From-SVN: r23424
1998-10-29 12:54:13 +01:00
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
while (*f)
hash += *f++;
[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
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
l = pfile->all_include_files[hash % ALL_INCLUDE_HASHSIZE];
m = 0;
for (; l; m = l, l = l->next)
if (!strcmp (l->nshort, fname))
return l;
[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
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
if (!add)
return 0;
l = (struct include_hash *) xmalloc (sizeof (struct include_hash));
l->next = NULL;
l->next_this_file = NULL;
l->foundhere = NULL;
l->buf = NULL;
l->limit = NULL;
if (m)
m->next = l;
else
pfile->all_include_files[hash % ALL_INCLUDE_HASHSIZE] = l;
return l;
}
[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
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
/* Return 0 if the file pointed to by IHASH has never been included before,
-1 if it has been included before and need not be again,
or a pointer to an IHASH entry which is the file to be reread.
"Never before" is with respect to the position in ILIST.
[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
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
This will not detect redundancies involving odd uses of the
`current directory' rule for "" includes. They aren't quite
pathological, but I think they are rare enough not to worry about.
The simplest example is:
[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
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
top.c:
#include "a/a.h"
#include "b/b.h"
[multiple changes] 1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu> * c-lang.c: Declare extern char *yy_cur if USE_CPPLIB. (lang_init): Call check_newline always. * c-lex.c (init_parse) [USE_CPPLIB=1]: After calling cpp_start_read, set yy_cur and yy_lim to read from parse_in.token_buffer, so that we'll see the first #line directive. * cpplib.c (cpp_start_read): finclude the main input file before processing -include/-imacros. Process -imacros and -include separately, and handle -include by stacking a buffer for the file in question as if it'd been #included. * toplev.c (documented_lang_options) Recognize -H when USE_CPPLIB is on. 1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu> * cpplib.c: Merge do_once into do_pragma. Break file handling code out of do_include. Move append_include_chain, deps_output, file_cleanup, redundant_include_p, import_hash, lookup_import, add_import, read_filename_string, read_name_map, open_include_file, finclude, safe_read to cppfiles.c. Move prototypes for deps_output, append_include_chain, finclude to cpplib.h. Move definition of struct file_name_list there also. * cppfiles.c: New file. Contains all the above functions broken out of cpplib.c; also hack_vms_include_specification from cccp.c and find_include_file, a new function broken out of do_include. * Makefile.in (cppmain): Depend on cppfiles.o. (fix-header): Likewise. (cppfiles.o): New target. * configure.in (--enable-c-cpplib): Add cppfiles.o to extra_c_objs. Add ../cppfiles.o to extra_cxx_objs. From-SVN: r23424
1998-10-29 12:54:13 +01:00
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
a/a.h:
#include "../b/b.h"
[multiple changes] 1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu> * c-lang.c: Declare extern char *yy_cur if USE_CPPLIB. (lang_init): Call check_newline always. * c-lex.c (init_parse) [USE_CPPLIB=1]: After calling cpp_start_read, set yy_cur and yy_lim to read from parse_in.token_buffer, so that we'll see the first #line directive. * cpplib.c (cpp_start_read): finclude the main input file before processing -include/-imacros. Process -imacros and -include separately, and handle -include by stacking a buffer for the file in question as if it'd been #included. * toplev.c (documented_lang_options) Recognize -H when USE_CPPLIB is on. 1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu> * cpplib.c: Merge do_once into do_pragma. Break file handling code out of do_include. Move append_include_chain, deps_output, file_cleanup, redundant_include_p, import_hash, lookup_import, add_import, read_filename_string, read_name_map, open_include_file, finclude, safe_read to cppfiles.c. Move prototypes for deps_output, append_include_chain, finclude to cpplib.h. Move definition of struct file_name_list there also. * cppfiles.c: New file. Contains all the above functions broken out of cpplib.c; also hack_vms_include_specification from cccp.c and find_include_file, a new function broken out of do_include. * Makefile.in (cppmain): Depend on cppfiles.o. (fix-header): Likewise. (cppfiles.o): New target. * configure.in (--enable-c-cpplib): Add cppfiles.o to extra_c_objs. Add ../cppfiles.o to extra_cxx_objs. From-SVN: r23424
1998-10-29 12:54:13 +01:00
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
and the problem is that for `current directory' includes,
ihash->foundhere is not on any of the global include chains,
so the test below (i->foundhere == l) may be false even when
the directories are in fact the same. */
static struct include_hash *
redundant_include_p (pfile, ihash, ilist)
[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
cpp_reader *pfile;
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
struct include_hash *ihash;
struct file_name_list *ilist;
[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
{
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
struct file_name_list *l;
struct include_hash *i;
[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
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
if (! ihash->foundhere)
return 0;
[multiple changes] 1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu> * c-lang.c: Declare extern char *yy_cur if USE_CPPLIB. (lang_init): Call check_newline always. * c-lex.c (init_parse) [USE_CPPLIB=1]: After calling cpp_start_read, set yy_cur and yy_lim to read from parse_in.token_buffer, so that we'll see the first #line directive. * cpplib.c (cpp_start_read): finclude the main input file before processing -include/-imacros. Process -imacros and -include separately, and handle -include by stacking a buffer for the file in question as if it'd been #included. * toplev.c (documented_lang_options) Recognize -H when USE_CPPLIB is on. 1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu> * cpplib.c: Merge do_once into do_pragma. Break file handling code out of do_include. Move append_include_chain, deps_output, file_cleanup, redundant_include_p, import_hash, lookup_import, add_import, read_filename_string, read_name_map, open_include_file, finclude, safe_read to cppfiles.c. Move prototypes for deps_output, append_include_chain, finclude to cpplib.h. Move definition of struct file_name_list there also. * cppfiles.c: New file. Contains all the above functions broken out of cpplib.c; also hack_vms_include_specification from cccp.c and find_include_file, a new function broken out of do_include. * Makefile.in (cppmain): Depend on cppfiles.o. (fix-header): Likewise. (cppfiles.o): New target. * configure.in (--enable-c-cpplib): Add cppfiles.o to extra_c_objs. Add ../cppfiles.o to extra_cxx_objs. From-SVN: r23424
1998-10-29 12:54:13 +01:00
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
for (i = ihash; i; i = i->next_this_file)
for (l = ilist; l; l = l->next)
if (i->foundhere == l)
/* The control_macro works like this: If it's NULL, the file
is to be included again. If it's "", the file is never to
be included again. If it's a string, the file is not to be
included again if the string is the name of a defined macro. */
return (i->control_macro
&& (i->control_macro[0] == '\0'
|| cpp_lookup (pfile, i->control_macro, -1, -1)))
? (struct include_hash *)-1 : i;
[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
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
return 0;
[multiple changes] 1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu> * c-lang.c: Declare extern char *yy_cur if USE_CPPLIB. (lang_init): Call check_newline always. * c-lex.c (init_parse) [USE_CPPLIB=1]: After calling cpp_start_read, set yy_cur and yy_lim to read from parse_in.token_buffer, so that we'll see the first #line directive. * cpplib.c (cpp_start_read): finclude the main input file before processing -include/-imacros. Process -imacros and -include separately, and handle -include by stacking a buffer for the file in question as if it'd been #included. * toplev.c (documented_lang_options) Recognize -H when USE_CPPLIB is on. 1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu> * cpplib.c: Merge do_once into do_pragma. Break file handling code out of do_include. Move append_include_chain, deps_output, file_cleanup, redundant_include_p, import_hash, lookup_import, add_import, read_filename_string, read_name_map, open_include_file, finclude, safe_read to cppfiles.c. Move prototypes for deps_output, append_include_chain, finclude to cpplib.h. Move definition of struct file_name_list there also. * cppfiles.c: New file. Contains all the above functions broken out of cpplib.c; also hack_vms_include_specification from cccp.c and find_include_file, a new function broken out of do_include. * Makefile.in (cppmain): Depend on cppfiles.o. (fix-header): Likewise. (cppfiles.o): New target. * configure.in (--enable-c-cpplib): Add cppfiles.o to extra_c_objs. Add ../cppfiles.o to extra_cxx_objs. From-SVN: r23424
1998-10-29 12:54:13 +01:00
}
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
static int
file_cleanup (pbuf, pfile)
cpp_buffer *pbuf;
cpp_reader *pfile;
{
if (pbuf->buf)
{
free (pbuf->buf);
pbuf->buf = 0;
}
if (pfile->system_include_depth)
pfile->system_include_depth--;
return 0;
}
[multiple changes] 1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu> * c-lang.c: Declare extern char *yy_cur if USE_CPPLIB. (lang_init): Call check_newline always. * c-lex.c (init_parse) [USE_CPPLIB=1]: After calling cpp_start_read, set yy_cur and yy_lim to read from parse_in.token_buffer, so that we'll see the first #line directive. * cpplib.c (cpp_start_read): finclude the main input file before processing -include/-imacros. Process -imacros and -include separately, and handle -include by stacking a buffer for the file in question as if it'd been #included. * toplev.c (documented_lang_options) Recognize -H when USE_CPPLIB is on. 1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu> * cpplib.c: Merge do_once into do_pragma. Break file handling code out of do_include. Move append_include_chain, deps_output, file_cleanup, redundant_include_p, import_hash, lookup_import, add_import, read_filename_string, read_name_map, open_include_file, finclude, safe_read to cppfiles.c. Move prototypes for deps_output, append_include_chain, finclude to cpplib.h. Move definition of struct file_name_list there also. * cppfiles.c: New file. Contains all the above functions broken out of cpplib.c; also hack_vms_include_specification from cccp.c and find_include_file, a new function broken out of do_include. * Makefile.in (cppmain): Depend on cppfiles.o. (fix-header): Likewise. (cppfiles.o): New target. * configure.in (--enable-c-cpplib): Add cppfiles.o to extra_c_objs. Add ../cppfiles.o to extra_cxx_objs. From-SVN: r23424
1998-10-29 12:54:13 +01:00
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
/* Search for include file FNAME in the include chain starting at
SEARCH_START. Return -2 if this file doesn't need to be included
(because it was included already and it's marked idempotent),
-1 if an error occurred, or a file descriptor open on the file.
*IHASH is set to point to the include hash entry for this file, and
*BEFORE is 1 if the file was included before (but needs to be read
again). */
int
find_include_file (pfile, fname, search_start, ihash, before)
[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
cpp_reader *pfile;
cpperror.c (cpp_file_line_for_message): Constify a char*. * cpperror.c (cpp_file_line_for_message): Constify a char*. * cppexp.c (parse_number, parse_charconst, cpp_lex, cpp_parse_expr): Add static prototypes. (parse_charconst): Don't cast away const-ness. (token): Constify a char*. * cppfiles.c (file_name_list, include_hash, find_include_file, finclude, initialize_input_buffer): Constify a char*. (file_cleanup, find_position): Add static prototypes. * cpphash.c (macro_cleanup, macarg, timestamp, special_symbol, collect_expansion): Add static prototypes. (cpp_install, create_definition, monthnames): Constify a char*. * cpphash.h (cpp_install): Likewise. * cppinit.c (known_suffixes, default_include, dump_special_to_buffer, NAME, cpp_start_read, cpp_finish): Likewise. (base_name, dump_special_to_buffer, initialize_dependency_output): Add static prototypes. * cpplib.c (my_strerror): Constify a char*. (null_underflow, null_cleanup, skip_comment, copy_comment, copy_rest_of_line, handle_directive, pass_thru_directive, get_directive_token, read_line_number, cpp_print_file_and_line, v_cpp_error, v_cpp_warning, v_cpp_error_with_line, v_cpp_warning_with_line, detect_if_not_defined, consider_directive_while_skipping): Add static prototypes. (pass_thru_directive, check_macro_name, cpp_expand_to_buffer, cpp_pedwarn_with_file_and_line): Constify a char*. * cpplib.h (cpp_options, include_hash, progname, definition, cpp_pedwarn_with_file_and_line, cpp_expand_to_buffer, check_macro_name, cpp_pfatal_with_name, cpp_file_line_for_message, find_include_file, deps_output, include_hash): Constify a char*. * cppmain.c (progname): Constify. (main): Add prototype. Use return, not exit. * fix-header.c (fatal, add_symbols, lookup_std_proto, write_lbrac, recognized_macro, check_macro_names, read_scan_file, write_rbrac, inf_skip_spaces, inf_read_upto, inf_scan_ident, inf_scan_ident, check_protection): Add static prototype. (xfree): Remove. (progname, recognized_macrom, recognized_extern): Constify a char*. (main): Add prototype. * gen-protos.c (progname): Constify a char*. From-SVN: r29171
1999-09-07 17:41:26 +02:00
const char *fname;
cpplib.h: Delete struct import_file. Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu> * cpplib.h: Delete struct import_file. Add ihash element to struct cpp_buffer. Delete dont_repeat_files and import_hash_table elements from cpp_reader; change all_include_files to a hash table. Delete all foobar_include / last_foobar_include elements from struct cpp_options; put back four such: quote_include, bracket_include, system_include, after_include. Redo struct file_name_list completely. Add new structure type include_hash. Add prototypes for merge_include_chains and include_hash. Change prototypes for finclude, find_include_file, and append_include_chain to match changes below. * cppfiles.c (simplify_pathname, include_hash, remap_filename, merge_include_chains): New functions. (add_import, lookup_import, open_include_file): Removed. (INO_T_EQ): Define this (copied from cccp.c). (hack_vms_include_specification): Remove all calls and #if 0 out the definition. It was being called incorrectly and at the wrong times. Until a VMSie can look at this, it's better to not pretend to support it. (append_include_chain): Change calling convention; now takes only one directory at a time, and sets up the data structure itself. (redundant_include_p): Rewritten - this is now used for all include redundancy, whether by #ifndef, #import, or #pragma once. Looks up things in the include hash table. (file_cleanup): Decrement pfile->system_include_depth here if it's >0. (find_include_file): Calling convention changed; now passes around a struct include_hash instead of 3 separate parameters. Guts ripped out and replaced with new include_hash mechanism. (finclude): Calling convention changed as for find_include_file. Error exits pulled out-of-line. Reformat. (safe_read): Return a long, not an int. (deps_output): Don't recurse. * cpplib.c (is_system_include): Deleted. (path_include): Fix up call to append_include_chain. (do_include): Fix up calls to find_include_file and finclude. Clean up dependency output a bit. Shorten obnoxiously lengthy #import warning message. Don't decrement pfile->system_include_depth here. (do_pragma): Understand the include_hash structure. Reformat. (do_endif): Correct handling of control macros. Understand the include_hash. (cpp_start_read): Fix up calls to finclude. Call merge_include_chains. (cpp_handle_option): Fix up calls to append_include_chain. Understand the four partial include chains. (cpp_finish): Add debugging code (#if 0-ed out) for the include_hash. (cpp_cleanup): Free the include_hash, not the import hash and the all_include and dont_repeat lists which no longer exist. From-SVN: r23857
1998-11-25 12:56:54 +01:00
struct file_name_list *search_start;
struct include_hash **ihash;
int *before;
[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
{
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
struct file_name_list *l;
struct include_hash *ih, *jh;
int f, len;
char *name;
ih = include_hash (pfile, fname, 1);
jh = redundant_include_p (pfile, ih,
fname[0] == '/' ? ABSOLUTE_PATH : search_start);
if (jh != 0)
{
*before = 1;
*ihash = jh;
if (jh == (struct include_hash *)-1)
return -2;
else
return open (jh->name, O_RDONLY, 0666);
}
if (ih->foundhere)
/* A file is already known by this name, but it's not the same file.
Allocate another include_hash block and add it to the next_this_file
chain. */
{
jh = (struct include_hash *)xmalloc (sizeof (struct include_hash));
while (ih->next_this_file) ih = ih->next_this_file;
ih->next_this_file = jh;
jh = ih;
ih = ih->next_this_file;
ih->next = NULL;
ih->next_this_file = NULL;
ih->buf = NULL;
ih->limit = NULL;
}
*before = 0;
*ihash = ih;
ih->nshort = xstrdup (fname);
cpplib.h: Delete struct import_file. Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu> * cpplib.h: Delete struct import_file. Add ihash element to struct cpp_buffer. Delete dont_repeat_files and import_hash_table elements from cpp_reader; change all_include_files to a hash table. Delete all foobar_include / last_foobar_include elements from struct cpp_options; put back four such: quote_include, bracket_include, system_include, after_include. Redo struct file_name_list completely. Add new structure type include_hash. Add prototypes for merge_include_chains and include_hash. Change prototypes for finclude, find_include_file, and append_include_chain to match changes below. * cppfiles.c (simplify_pathname, include_hash, remap_filename, merge_include_chains): New functions. (add_import, lookup_import, open_include_file): Removed. (INO_T_EQ): Define this (copied from cccp.c). (hack_vms_include_specification): Remove all calls and #if 0 out the definition. It was being called incorrectly and at the wrong times. Until a VMSie can look at this, it's better to not pretend to support it. (append_include_chain): Change calling convention; now takes only one directory at a time, and sets up the data structure itself. (redundant_include_p): Rewritten - this is now used for all include redundancy, whether by #ifndef, #import, or #pragma once. Looks up things in the include hash table. (file_cleanup): Decrement pfile->system_include_depth here if it's >0. (find_include_file): Calling convention changed; now passes around a struct include_hash instead of 3 separate parameters. Guts ripped out and replaced with new include_hash mechanism. (finclude): Calling convention changed as for find_include_file. Error exits pulled out-of-line. Reformat. (safe_read): Return a long, not an int. (deps_output): Don't recurse. * cpplib.c (is_system_include): Deleted. (path_include): Fix up call to append_include_chain. (do_include): Fix up calls to find_include_file and finclude. Clean up dependency output a bit. Shorten obnoxiously lengthy #import warning message. Don't decrement pfile->system_include_depth here. (do_pragma): Understand the include_hash structure. Reformat. (do_endif): Correct handling of control macros. Understand the include_hash. (cpp_start_read): Fix up calls to finclude. Call merge_include_chains. (cpp_handle_option): Fix up calls to append_include_chain. Understand the four partial include chains. (cpp_finish): Add debugging code (#if 0-ed out) for the include_hash. (cpp_cleanup): Free the include_hash, not the import hash and the all_include and dont_repeat lists which no longer exist. From-SVN: r23857
1998-11-25 12:56:54 +01:00
ih->control_macro = NULL;
/* If the pathname is absolute, just open it. */
if (fname[0] == '/')
{
ih->foundhere = ABSOLUTE_PATH;
ih->name = ih->nshort;
return open (ih->name, O_RDONLY, 0666);
}
/* Search directory path, trying to open the file. */
len = strlen (fname);
name = xmalloc (len + pfile->max_include_len + 2 + INCLUDE_LEN_FUDGE);
for (l = search_start; l; l = l->next)
{
bcopy (l->name, name, l->nlen);
name[l->nlen] = '/';
strcpy (&name[l->nlen+1], fname);
simplify_pathname (name);
if (CPP_OPTIONS (pfile)->remap)
name = remap_filename (pfile, name, l);
f = open (name, O_RDONLY|O_NONBLOCK|O_NOCTTY, 0666);
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
#ifdef EACCES
if (f == -1 && errno == EACCES)
{
cpp_error(pfile, "included file `%s' exists but is not readable",
name);
return -1;
}
#endif
if (f >= 0)
{
ih->foundhere = l;
ih->name = xrealloc (name, strlen (name)+1);
return f;
}
}
if (jh)
{
jh->next_this_file = NULL;
free (ih);
}
free (name);
*ihash = (struct include_hash *)-1;
return -1;
[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_name_map structure holds a mapping of file names for a
particular directory. This mapping is read from the file named
FILE_NAME_MAP_FILE in that directory. Such a file can be used to
map filenames on a file system with severe filename restrictions,
such as DOS. The format of the file name map file is just a series
of lines with two tokens on each line. The first token is the name
to map, and the second token is the actual name to use. */
struct file_name_map
{
struct file_name_map *map_next;
char *map_from;
char *map_to;
};
#define FILE_NAME_MAP_FILE "header.gcc"
/* Read a space delimited string of unlimited length from a stdio
file. */
static char *
read_filename_string (ch, f)
int ch;
FILE *f;
{
char *alloc, *set;
int len;
len = 20;
set = alloc = xmalloc (len + 1);
cpplib.h (struct cpp_buffer: fname, [...]): Mark const. 1999-10-28 21:27 -0700 Zack Weinberg <zack@bitmover.com> * cpplib.h (struct cpp_buffer: fname, nominal_fname, last_nominal_fname): Mark const. (struct include_hash: name, nshort, control_macro): Mark const. (struct macrodef: symnam): Mark const. (struct if_stack: fname): Mark const. (is_idchar, is_idstart, is_hor_space, trigraph_table): Delete. (IStable): New character-syntax array which encompasses all the old is_foo arrays. (is_idchar, is_numchar, is_idstart, is_numstart, is_hspace, is_space): New macros for interrogating IStable. (check_macro_name): Kill last argument. All callers changed. * cppinit.c (initialize_char_syntax): Delete. (is_idchar, is_idstart, is_hor_space, is_space, trigraph_table): Delete. (IStable): New. Initialize with clever macros to avoid information duplication. (builtin_array): Table of builtins to get rid of explicit list in initialize_builtins. (initialize_builtins): Use builtins_array. (cpp_start_read): Call init_IStable, and set IStable['$'] if opts->dollars_in_ident. * cppexp.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. (cpp_parse_expr): Avoid 'format string is not constant' warning. Use ISGRAPH to identify printable chars. * cppfiles.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. (read_and_prescan): Map trigraphs to chars with open-coded if-else-if-... sequence, not a lookup table. * cpphash.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. * cpplib.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. Kill SKIP_ALL_WHITE_SPACE (unused). (check_macro_name): Remove ability to report an invalid assertion name, which is never used. (do_line): Constify a couple of char *'s. * cppmain.c (main): Call cpp_cleanup before returning. From-SVN: r30252
1999-10-29 06:31:14 +02:00
if (! is_space(ch))
[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
{
*set++ = ch;
cpplib.h (struct cpp_buffer: fname, [...]): Mark const. 1999-10-28 21:27 -0700 Zack Weinberg <zack@bitmover.com> * cpplib.h (struct cpp_buffer: fname, nominal_fname, last_nominal_fname): Mark const. (struct include_hash: name, nshort, control_macro): Mark const. (struct macrodef: symnam): Mark const. (struct if_stack: fname): Mark const. (is_idchar, is_idstart, is_hor_space, trigraph_table): Delete. (IStable): New character-syntax array which encompasses all the old is_foo arrays. (is_idchar, is_numchar, is_idstart, is_numstart, is_hspace, is_space): New macros for interrogating IStable. (check_macro_name): Kill last argument. All callers changed. * cppinit.c (initialize_char_syntax): Delete. (is_idchar, is_idstart, is_hor_space, is_space, trigraph_table): Delete. (IStable): New. Initialize with clever macros to avoid information duplication. (builtin_array): Table of builtins to get rid of explicit list in initialize_builtins. (initialize_builtins): Use builtins_array. (cpp_start_read): Call init_IStable, and set IStable['$'] if opts->dollars_in_ident. * cppexp.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. (cpp_parse_expr): Avoid 'format string is not constant' warning. Use ISGRAPH to identify printable chars. * cppfiles.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. (read_and_prescan): Map trigraphs to chars with open-coded if-else-if-... sequence, not a lookup table. * cpphash.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. * cpplib.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. Kill SKIP_ALL_WHITE_SPACE (unused). (check_macro_name): Remove ability to report an invalid assertion name, which is never used. (do_line): Constify a couple of char *'s. * cppmain.c (main): Call cpp_cleanup before returning. From-SVN: r30252
1999-10-29 06:31:14 +02:00
while ((ch = getc (f)) != EOF && ! is_space(ch))
[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
{
if (set - alloc == len)
{
len *= 2;
alloc = xrealloc (alloc, len + 1);
set = alloc + len / 2;
}
*set++ = ch;
}
}
*set = '\0';
ungetc (ch, f);
return alloc;
}
/* This structure holds a linked list of file name maps, one per directory. */
struct file_name_map_list
{
struct file_name_map_list *map_list_next;
char *map_list_name;
struct file_name_map *map_list_map;
};
/* Read the file name map file for DIRNAME. */
static struct file_name_map *
read_name_map (pfile, dirname)
cpp_reader *pfile;
const char *dirname;
[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
{
register struct file_name_map_list *map_list_ptr;
char *name;
FILE *f;
for (map_list_ptr = CPP_OPTIONS (pfile)->map_list; map_list_ptr;
map_list_ptr = map_list_ptr->map_list_next)
if (! strcmp (map_list_ptr->map_list_name, dirname))
return map_list_ptr->map_list_map;
map_list_ptr = ((struct file_name_map_list *)
xmalloc (sizeof (struct file_name_map_list)));
map_list_ptr->map_list_name = xstrdup (dirname);
[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
name = (char *) alloca (strlen (dirname) + strlen (FILE_NAME_MAP_FILE) + 2);
strcpy (name, dirname);
if (*dirname)
strcat (name, "/");
strcat (name, FILE_NAME_MAP_FILE);
f = fopen (name, "r");
if (!f)
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
map_list_ptr->map_list_map = (struct file_name_map *)-1;
[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
else
{
int ch;
int dirlen = strlen (dirname);
while ((ch = getc (f)) != EOF)
{
char *from, *to;
struct file_name_map *ptr;
cpplib.h (struct cpp_buffer: fname, [...]): Mark const. 1999-10-28 21:27 -0700 Zack Weinberg <zack@bitmover.com> * cpplib.h (struct cpp_buffer: fname, nominal_fname, last_nominal_fname): Mark const. (struct include_hash: name, nshort, control_macro): Mark const. (struct macrodef: symnam): Mark const. (struct if_stack: fname): Mark const. (is_idchar, is_idstart, is_hor_space, trigraph_table): Delete. (IStable): New character-syntax array which encompasses all the old is_foo arrays. (is_idchar, is_numchar, is_idstart, is_numstart, is_hspace, is_space): New macros for interrogating IStable. (check_macro_name): Kill last argument. All callers changed. * cppinit.c (initialize_char_syntax): Delete. (is_idchar, is_idstart, is_hor_space, is_space, trigraph_table): Delete. (IStable): New. Initialize with clever macros to avoid information duplication. (builtin_array): Table of builtins to get rid of explicit list in initialize_builtins. (initialize_builtins): Use builtins_array. (cpp_start_read): Call init_IStable, and set IStable['$'] if opts->dollars_in_ident. * cppexp.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. (cpp_parse_expr): Avoid 'format string is not constant' warning. Use ISGRAPH to identify printable chars. * cppfiles.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. (read_and_prescan): Map trigraphs to chars with open-coded if-else-if-... sequence, not a lookup table. * cpphash.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. * cpplib.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. Kill SKIP_ALL_WHITE_SPACE (unused). (check_macro_name): Remove ability to report an invalid assertion name, which is never used. (do_line): Constify a couple of char *'s. * cppmain.c (main): Call cpp_cleanup before returning. From-SVN: r30252
1999-10-29 06:31:14 +02:00
if (is_space(ch))
[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
continue;
from = read_filename_string (ch, f);
cpplib.h (struct cpp_buffer: fname, [...]): Mark const. 1999-10-28 21:27 -0700 Zack Weinberg <zack@bitmover.com> * cpplib.h (struct cpp_buffer: fname, nominal_fname, last_nominal_fname): Mark const. (struct include_hash: name, nshort, control_macro): Mark const. (struct macrodef: symnam): Mark const. (struct if_stack: fname): Mark const. (is_idchar, is_idstart, is_hor_space, trigraph_table): Delete. (IStable): New character-syntax array which encompasses all the old is_foo arrays. (is_idchar, is_numchar, is_idstart, is_numstart, is_hspace, is_space): New macros for interrogating IStable. (check_macro_name): Kill last argument. All callers changed. * cppinit.c (initialize_char_syntax): Delete. (is_idchar, is_idstart, is_hor_space, is_space, trigraph_table): Delete. (IStable): New. Initialize with clever macros to avoid information duplication. (builtin_array): Table of builtins to get rid of explicit list in initialize_builtins. (initialize_builtins): Use builtins_array. (cpp_start_read): Call init_IStable, and set IStable['$'] if opts->dollars_in_ident. * cppexp.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. (cpp_parse_expr): Avoid 'format string is not constant' warning. Use ISGRAPH to identify printable chars. * cppfiles.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. (read_and_prescan): Map trigraphs to chars with open-coded if-else-if-... sequence, not a lookup table. * cpphash.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. * cpplib.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. Kill SKIP_ALL_WHITE_SPACE (unused). (check_macro_name): Remove ability to report an invalid assertion name, which is never used. (do_line): Constify a couple of char *'s. * cppmain.c (main): Call cpp_cleanup before returning. From-SVN: r30252
1999-10-29 06:31:14 +02:00
while ((ch = getc (f)) != EOF && is_hspace(ch))
[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
;
to = read_filename_string (ch, f);
ptr = ((struct file_name_map *)
xmalloc (sizeof (struct file_name_map)));
ptr->map_from = from;
/* Make the real filename absolute. */
if (*to == '/')
ptr->map_to = to;
else
{
ptr->map_to = xmalloc (dirlen + strlen (to) + 2);
strcpy (ptr->map_to, dirname);
ptr->map_to[dirlen] = '/';
strcpy (ptr->map_to + dirlen + 1, to);
free (to);
}
ptr->map_next = map_list_ptr->map_list_map;
map_list_ptr->map_list_map = ptr;
while ((ch = getc (f)) != '\n')
if (ch == EOF)
break;
}
fclose (f);
}
map_list_ptr->map_list_next = CPP_OPTIONS (pfile)->map_list;
CPP_OPTIONS (pfile)->map_list = map_list_ptr;
return map_list_ptr->map_list_map;
}
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
/* Remap NAME based on the file_name_map (if any) for LOC. */
[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
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
static char *
remap_filename (pfile, name, loc)
[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
cpp_reader *pfile;
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
char *name;
struct file_name_list *loc;
[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
{
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
struct file_name_map *map;
const char *from, *p, *dir;
[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
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
if (! loc->name_map)
loc->name_map = read_name_map (pfile,
loc->name
? loc->name : ".");
[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
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
if (loc->name_map == (struct file_name_map *)-1)
return name;
from = name + strlen (loc->name) + 1;
for (map = loc->name_map; map; map = map->map_next)
if (!strcmp (map->map_from, from))
return map->map_to;
/* Try to find a mapping file for the particular directory we are
looking in. Thus #include <sys/types.h> will look up sys/types.h
in /usr/include/header.gcc and look up types.h in
/usr/include/sys/header.gcc. */
p = rindex (name, '/');
if (!p)
p = name;
if (loc && loc->name
&& strlen (loc->name) == (size_t) (p - name)
&& !strncmp (loc->name, name, p - name))
/* FILENAME is in SEARCHPTR, which we've already checked. */
return name;
if (p == name)
{
dir = ".";
from = name;
}
else
{
char * newdir = (char *) alloca (p - name + 1);
bcopy (name, newdir, p - name);
newdir[p - name] = '\0';
dir = newdir;
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
from = p + 1;
[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
}
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
for (map = read_name_map (pfile, dir); map; map = map->map_next)
if (! strcmp (map->map_from, name))
return map->map_to;
[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
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
return name;
[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
}
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
/* Read the contents of FD into the buffer on the top of PFILE's stack.
IHASH points to the include hash entry for the file associated with
FD.
[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 caller is responsible for the cpp_push_buffer. */
int
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
finclude (pfile, fd, ihash)
[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
cpp_reader *pfile;
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
int fd;
struct include_hash *ihash;
[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
{
struct stat st;
size_t st_size;
long length;
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
cpp_buffer *fp;
[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
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
if (fstat (fd, &st) < 0)
goto perror_fail;
if (fcntl (fd, F_SETFL, 0) == -1) /* turn off nonblocking mode */
goto perror_fail;
[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
fp = CPP_BUFFER (pfile);
/* If fd points to a plain file, we know how big it is, so we can
allocate the buffer all at once. If fd is a pipe or terminal, we
can't. Most C source files are 4k or less, so we guess that. If
fd is something weird, like a block device or a directory, we
don't want to read it at all.
Unfortunately, different systems use different st.st_mode values
for pipes: some have S_ISFIFO, some S_ISSOCK, some are buggy and
zero the entire struct stat except a couple fields. Hence the
mess below.
In all cases, read_and_prescan will resize the buffer if it
turns out there's more data than we thought. */
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
if (S_ISREG (st.st_mode))
{
/* off_t might have a wider range than size_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 4GB needs to rethink
their coding style.) */
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
st_size = (size_t) st.st_size;
if ((unsigned HOST_WIDEST_INT) st_size
!= (unsigned HOST_WIDEST_INT) st.st_size)
{
cpp_error (pfile, "file `%s' is too large", ihash->name);
goto fail;
}
[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
}
else if (S_ISFIFO (st.st_mode) || S_ISSOCK (st.st_mode)
/* Permit any kind of character device: the sensible ones are
ttys and /dev/null, but weeding out the others is too hard. */
|| S_ISCHR (st.st_mode)
/* Some 4.x (x<4) derivatives have a bug that makes fstat() of a
socket or pipe return a stat struct with most fields zeroed. */
|| (st.st_mode == 0 && st.st_nlink == 0 && st.st_size == 0))
cpplib.h: Delete struct import_file. Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu> * cpplib.h: Delete struct import_file. Add ihash element to struct cpp_buffer. Delete dont_repeat_files and import_hash_table elements from cpp_reader; change all_include_files to a hash table. Delete all foobar_include / last_foobar_include elements from struct cpp_options; put back four such: quote_include, bracket_include, system_include, after_include. Redo struct file_name_list completely. Add new structure type include_hash. Add prototypes for merge_include_chains and include_hash. Change prototypes for finclude, find_include_file, and append_include_chain to match changes below. * cppfiles.c (simplify_pathname, include_hash, remap_filename, merge_include_chains): New functions. (add_import, lookup_import, open_include_file): Removed. (INO_T_EQ): Define this (copied from cccp.c). (hack_vms_include_specification): Remove all calls and #if 0 out the definition. It was being called incorrectly and at the wrong times. Until a VMSie can look at this, it's better to not pretend to support it. (append_include_chain): Change calling convention; now takes only one directory at a time, and sets up the data structure itself. (redundant_include_p): Rewritten - this is now used for all include redundancy, whether by #ifndef, #import, or #pragma once. Looks up things in the include hash table. (file_cleanup): Decrement pfile->system_include_depth here if it's >0. (find_include_file): Calling convention changed; now passes around a struct include_hash instead of 3 separate parameters. Guts ripped out and replaced with new include_hash mechanism. (finclude): Calling convention changed as for find_include_file. Error exits pulled out-of-line. Reformat. (safe_read): Return a long, not an int. (deps_output): Don't recurse. * cpplib.c (is_system_include): Deleted. (path_include): Fix up call to append_include_chain. (do_include): Fix up calls to find_include_file and finclude. Clean up dependency output a bit. Shorten obnoxiously lengthy #import warning message. Don't decrement pfile->system_include_depth here. (do_pragma): Understand the include_hash structure. Reformat. (do_endif): Correct handling of control macros. Understand the include_hash. (cpp_start_read): Fix up calls to finclude. Call merge_include_chains. (cpp_handle_option): Fix up calls to append_include_chain. Understand the four partial include chains. (cpp_finish): Add debugging code (#if 0-ed out) for the include_hash. (cpp_cleanup): Free the include_hash, not the import hash and the all_include and dont_repeat lists which no longer exist. From-SVN: r23857
1998-11-25 12:56:54 +01:00
{
/* Cannot get its file size before reading. 4k is a decent
first guess. */
st_size = 4096;
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
}
else
{
cpp_error (pfile, "`%s' is not a file, pipe, or tty", ihash->name);
goto fail;
[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
}
if (pfile->input_buffer == NULL)
initialize_input_buffer (pfile, fd, &st);
/* Read the file, converting end-of-line characters and trigraphs
(if enabled). */
fp->ihash = ihash;
fp->nominal_fname = fp->fname = ihash->name;
length = read_and_prescan (pfile, fp, fd, st_size);
if (length < 0)
goto fail;
if (length == 0)
ihash->control_macro = ""; /* never re-include */
[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
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
close (fd);
fp->rlimit = fp->alimit = fp->buf + length;
fp->cur = fp->buf;
cppinit.c: Instead of one pending list... 1999-03-15 21:39 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppinit.c: Instead of one pending list, keep separate lists for each category of pending option: -D/-U, -A, -include, -imacros. Move the four partial include-path lists into the pending block. Use head and tail pointers so we don't ever have to reverse the lists. (cpp_start_read): Break out blocks of code to their own functions: install_predefs and initialize_dependency_output. Use path_include for C_INCLUDE_PATH and friends as well as CPATH. Remove include_defaults gunk. Warn about the combination of -lang-chill and -trigraphs. Optimize string bashing. Walk each pending list once, deallocating as we go. (append_include_chain): Brought over from cppfiles.c. Mark dirs as system include dirs if and only if appending to system include path. If opts->verbose, print a notice when a dir is dropped from the include path because it doesn't exist. Fix memory leak: this function is not supposed to copy its DIR argument. (nreverse_pending, push_pending): Removed. (APPEND): New macro for adding to pending lists. (path_include): Can now add to any partial include path. (base_name): Bring over from cccp.c. (cpp_options_init): Allocate the pending block. (cpp_handle_option): Add --version. Exit after --help. Fix formatting. Order -ifoo options by frequency of usage. (install_predefs): New function, simplified version of code that was in cpp_start_read. (initialize_dependency_output): Likewise. Understand OBJECT_SUFFIX. * cppfiles.c (simplify_pathname): Export. (merge_include_chains): Don't nreverse the lists. If opts->verbose, print a notice when a duplicate dir is detected and dropped from the include path. (finclude): Fix excessive cleverness in setting fp->system_header_p. (actual_directory): Set x->sysp from CPP_BUFFER (pfile)->system_header_p so that one system header may include another with "". (deps_output): Fix double adjustment of deps_size which would cause all dependencies after the first two lines to be lost. * cpplib.c (cpp_unassert): New function. * cpplib.h: Lay out struct cpp_pending here. Adjust prototypes. Add include_prefix_len to struct cpp_options. From-SVN: r25793
1999-03-15 19:42:46 +01:00
if (ihash->foundhere != ABSOLUTE_PATH)
fp->system_header_p = ihash->foundhere->sysp;
fp->lineno = 1;
fp->colno = 1;
fp->line_base = fp->buf;
fp->cleanup = file_cleanup;
/* The ->actual_dir field is only used when ignore_srcdir is not in effect;
see do_include */
if (!CPP_OPTIONS (pfile)->ignore_srcdir)
fp->actual_dir = actual_directory (pfile, fp->fname);
[multiple changes] 1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu> * c-lang.c: Declare extern char *yy_cur if USE_CPPLIB. (lang_init): Call check_newline always. * c-lex.c (init_parse) [USE_CPPLIB=1]: After calling cpp_start_read, set yy_cur and yy_lim to read from parse_in.token_buffer, so that we'll see the first #line directive. * cpplib.c (cpp_start_read): finclude the main input file before processing -include/-imacros. Process -imacros and -include separately, and handle -include by stacking a buffer for the file in question as if it'd been #included. * toplev.c (documented_lang_options) Recognize -H when USE_CPPLIB is on. 1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu> * cpplib.c: Merge do_once into do_pragma. Break file handling code out of do_include. Move append_include_chain, deps_output, file_cleanup, redundant_include_p, import_hash, lookup_import, add_import, read_filename_string, read_name_map, open_include_file, finclude, safe_read to cppfiles.c. Move prototypes for deps_output, append_include_chain, finclude to cpplib.h. Move definition of struct file_name_list there also. * cppfiles.c: New file. Contains all the above functions broken out of cpplib.c; also hack_vms_include_specification from cccp.c and find_include_file, a new function broken out of do_include. * Makefile.in (cppmain): Depend on cppfiles.o. (fix-header): Likewise. (cppfiles.o): New target. * configure.in (--enable-c-cpplib): Add cppfiles.o to extra_c_objs. Add ../cppfiles.o to extra_cxx_objs. From-SVN: r23424
1998-10-29 12:54:13 +01:00
pfile->input_stack_listing_current = 0;
return 1;
cpplib.h: Delete struct import_file. Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu> * cpplib.h: Delete struct import_file. Add ihash element to struct cpp_buffer. Delete dont_repeat_files and import_hash_table elements from cpp_reader; change all_include_files to a hash table. Delete all foobar_include / last_foobar_include elements from struct cpp_options; put back four such: quote_include, bracket_include, system_include, after_include. Redo struct file_name_list completely. Add new structure type include_hash. Add prototypes for merge_include_chains and include_hash. Change prototypes for finclude, find_include_file, and append_include_chain to match changes below. * cppfiles.c (simplify_pathname, include_hash, remap_filename, merge_include_chains): New functions. (add_import, lookup_import, open_include_file): Removed. (INO_T_EQ): Define this (copied from cccp.c). (hack_vms_include_specification): Remove all calls and #if 0 out the definition. It was being called incorrectly and at the wrong times. Until a VMSie can look at this, it's better to not pretend to support it. (append_include_chain): Change calling convention; now takes only one directory at a time, and sets up the data structure itself. (redundant_include_p): Rewritten - this is now used for all include redundancy, whether by #ifndef, #import, or #pragma once. Looks up things in the include hash table. (file_cleanup): Decrement pfile->system_include_depth here if it's >0. (find_include_file): Calling convention changed; now passes around a struct include_hash instead of 3 separate parameters. Guts ripped out and replaced with new include_hash mechanism. (finclude): Calling convention changed as for find_include_file. Error exits pulled out-of-line. Reformat. (safe_read): Return a long, not an int. (deps_output): Don't recurse. * cpplib.c (is_system_include): Deleted. (path_include): Fix up call to append_include_chain. (do_include): Fix up calls to find_include_file and finclude. Clean up dependency output a bit. Shorten obnoxiously lengthy #import warning message. Don't decrement pfile->system_include_depth here. (do_pragma): Understand the include_hash structure. Reformat. (do_endif): Correct handling of control macros. Understand the include_hash. (cpp_start_read): Fix up calls to finclude. Call merge_include_chains. (cpp_handle_option): Fix up calls to append_include_chain. Understand the four partial include chains. (cpp_finish): Add debugging code (#if 0-ed out) for the include_hash. (cpp_cleanup): Free the include_hash, not the import hash and the all_include and dont_repeat lists which no longer exist. From-SVN: r23857
1998-11-25 12:56:54 +01:00
perror_fail:
cpp_error_from_errno (pfile, ihash->name);
fail:
cpp_pop_buffer (pfile);
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
close (fd);
return 0;
[multiple changes] 1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu> * c-lang.c: Declare extern char *yy_cur if USE_CPPLIB. (lang_init): Call check_newline always. * c-lex.c (init_parse) [USE_CPPLIB=1]: After calling cpp_start_read, set yy_cur and yy_lim to read from parse_in.token_buffer, so that we'll see the first #line directive. * cpplib.c (cpp_start_read): finclude the main input file before processing -include/-imacros. Process -imacros and -include separately, and handle -include by stacking a buffer for the file in question as if it'd been #included. * toplev.c (documented_lang_options) Recognize -H when USE_CPPLIB is on. 1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu> * cpplib.c: Merge do_once into do_pragma. Break file handling code out of do_include. Move append_include_chain, deps_output, file_cleanup, redundant_include_p, import_hash, lookup_import, add_import, read_filename_string, read_name_map, open_include_file, finclude, safe_read to cppfiles.c. Move prototypes for deps_output, append_include_chain, finclude to cpplib.h. Move definition of struct file_name_list there also. * cppfiles.c: New file. Contains all the above functions broken out of cpplib.c; also hack_vms_include_specification from cccp.c and find_include_file, a new function broken out of do_include. * Makefile.in (cppmain): Depend on cppfiles.o. (fix-header): Likewise. (cppfiles.o): New target. * configure.in (--enable-c-cpplib): Add cppfiles.o to extra_c_objs. Add ../cppfiles.o to extra_cxx_objs. From-SVN: r23424
1998-10-29 12:54:13 +01:00
}
/* Given a path FNAME, extract the directory component and place it
onto the actual_dirs list. Return a pointer to the allocated
file_name_list structure. These structures are used to implement
current-directory "" include searching. */
cpplib.h (struct cpp_buffer): Replace dir and dlen members with a struct file_name_list pointer. 1998-11-26 01:17 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu> * cpplib.h (struct cpp_buffer): Replace dir and dlen members with a struct file_name_list pointer. (struct cpp_reader): Add pointer to chain of `actual directory' include searchpath entries. (struct file_name_list): Add *alloc pointer for the sake of the actual-directory chain. Move definition of HOST_WIDE_INT here. (cpp_parse_escape): Change prototype to match changes in cppexp.c. * cppfiles.c (actual_directory): New function. (finclude): Use it to initialize the buffer's actual_dir entry. (find_include_file): We don't need to fix up max_include_len here. * cpplib.c (do_include): Don't allocate a file_name_list on the fly for current directory "" includes, use the one that's been preallocated in pfile->buffer->actual_dir. Hoist out duplicate code from the search_start selection logic. (cpp_reader_init): Initialize pfile->actual_dirs. Remove definition of HOST_WIDE_INT. Change calls to cpp_parse_escape to match changes in cppexp.c (note hardcoded MASK, which is safe since this is the source character set). * cppexp.c: Bring over changes to cpp_parse_escape from cccp.c to handle wide character constants in #if directives. The function now returns a HOST_WIDE_INT, and takes a third argument which is a binary mask for all legal values (0x00ff for 8-bit `char', 0xffff for 16-bit `wchar_t', etc.) Define MAX_CHAR_TYPE_MASK and MAX_WCHAR_TYPE_MASK. Change callers of cpp_parse_escape to match. [Fixes c-torture/execute/widechar-1.c] From-SVN: r24153
1998-12-07 14:35:20 +01:00
static struct file_name_list *
actual_directory (pfile, fname)
cpp_reader *pfile;
cpperror.c (cpp_file_line_for_message): Constify a char*. * cpperror.c (cpp_file_line_for_message): Constify a char*. * cppexp.c (parse_number, parse_charconst, cpp_lex, cpp_parse_expr): Add static prototypes. (parse_charconst): Don't cast away const-ness. (token): Constify a char*. * cppfiles.c (file_name_list, include_hash, find_include_file, finclude, initialize_input_buffer): Constify a char*. (file_cleanup, find_position): Add static prototypes. * cpphash.c (macro_cleanup, macarg, timestamp, special_symbol, collect_expansion): Add static prototypes. (cpp_install, create_definition, monthnames): Constify a char*. * cpphash.h (cpp_install): Likewise. * cppinit.c (known_suffixes, default_include, dump_special_to_buffer, NAME, cpp_start_read, cpp_finish): Likewise. (base_name, dump_special_to_buffer, initialize_dependency_output): Add static prototypes. * cpplib.c (my_strerror): Constify a char*. (null_underflow, null_cleanup, skip_comment, copy_comment, copy_rest_of_line, handle_directive, pass_thru_directive, get_directive_token, read_line_number, cpp_print_file_and_line, v_cpp_error, v_cpp_warning, v_cpp_error_with_line, v_cpp_warning_with_line, detect_if_not_defined, consider_directive_while_skipping): Add static prototypes. (pass_thru_directive, check_macro_name, cpp_expand_to_buffer, cpp_pedwarn_with_file_and_line): Constify a char*. * cpplib.h (cpp_options, include_hash, progname, definition, cpp_pedwarn_with_file_and_line, cpp_expand_to_buffer, check_macro_name, cpp_pfatal_with_name, cpp_file_line_for_message, find_include_file, deps_output, include_hash): Constify a char*. * cppmain.c (progname): Constify. (main): Add prototype. Use return, not exit. * fix-header.c (fatal, add_symbols, lookup_std_proto, write_lbrac, recognized_macro, check_macro_names, read_scan_file, write_rbrac, inf_skip_spaces, inf_read_upto, inf_scan_ident, inf_scan_ident, check_protection): Add static prototype. (xfree): Remove. (progname, recognized_macrom, recognized_extern): Constify a char*. (main): Add prototype. * gen-protos.c (progname): Constify a char*. From-SVN: r29171
1999-09-07 17:41:26 +02:00
const char *fname;
cpplib.h (struct cpp_buffer): Replace dir and dlen members with a struct file_name_list pointer. 1998-11-26 01:17 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu> * cpplib.h (struct cpp_buffer): Replace dir and dlen members with a struct file_name_list pointer. (struct cpp_reader): Add pointer to chain of `actual directory' include searchpath entries. (struct file_name_list): Add *alloc pointer for the sake of the actual-directory chain. Move definition of HOST_WIDE_INT here. (cpp_parse_escape): Change prototype to match changes in cppexp.c. * cppfiles.c (actual_directory): New function. (finclude): Use it to initialize the buffer's actual_dir entry. (find_include_file): We don't need to fix up max_include_len here. * cpplib.c (do_include): Don't allocate a file_name_list on the fly for current directory "" includes, use the one that's been preallocated in pfile->buffer->actual_dir. Hoist out duplicate code from the search_start selection logic. (cpp_reader_init): Initialize pfile->actual_dirs. Remove definition of HOST_WIDE_INT. Change calls to cpp_parse_escape to match changes in cppexp.c (note hardcoded MASK, which is safe since this is the source character set). * cppexp.c: Bring over changes to cpp_parse_escape from cccp.c to handle wide character constants in #if directives. The function now returns a HOST_WIDE_INT, and takes a third argument which is a binary mask for all legal values (0x00ff for 8-bit `char', 0xffff for 16-bit `wchar_t', etc.) Define MAX_CHAR_TYPE_MASK and MAX_WCHAR_TYPE_MASK. Change callers of cpp_parse_escape to match. [Fixes c-torture/execute/widechar-1.c] From-SVN: r24153
1998-12-07 14:35:20 +01:00
{
char *last_slash, *dir;
size_t dlen;
struct file_name_list *x;
dir = xstrdup (fname);
cpplib.h (struct cpp_buffer): Replace dir and dlen members with a struct file_name_list pointer. 1998-11-26 01:17 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu> * cpplib.h (struct cpp_buffer): Replace dir and dlen members with a struct file_name_list pointer. (struct cpp_reader): Add pointer to chain of `actual directory' include searchpath entries. (struct file_name_list): Add *alloc pointer for the sake of the actual-directory chain. Move definition of HOST_WIDE_INT here. (cpp_parse_escape): Change prototype to match changes in cppexp.c. * cppfiles.c (actual_directory): New function. (finclude): Use it to initialize the buffer's actual_dir entry. (find_include_file): We don't need to fix up max_include_len here. * cpplib.c (do_include): Don't allocate a file_name_list on the fly for current directory "" includes, use the one that's been preallocated in pfile->buffer->actual_dir. Hoist out duplicate code from the search_start selection logic. (cpp_reader_init): Initialize pfile->actual_dirs. Remove definition of HOST_WIDE_INT. Change calls to cpp_parse_escape to match changes in cppexp.c (note hardcoded MASK, which is safe since this is the source character set). * cppexp.c: Bring over changes to cpp_parse_escape from cccp.c to handle wide character constants in #if directives. The function now returns a HOST_WIDE_INT, and takes a third argument which is a binary mask for all legal values (0x00ff for 8-bit `char', 0xffff for 16-bit `wchar_t', etc.) Define MAX_CHAR_TYPE_MASK and MAX_WCHAR_TYPE_MASK. Change callers of cpp_parse_escape to match. [Fixes c-torture/execute/widechar-1.c] From-SVN: r24153
1998-12-07 14:35:20 +01:00
last_slash = rindex (dir, '/');
if (last_slash)
{
if (last_slash == dir)
{
dlen = 1;
last_slash[1] = '\0';
}
else
{
dlen = last_slash - dir;
*last_slash = '\0';
}
}
else
{
dir[0] = '.';
dir[1] = '\0';
dlen = 1;
}
if (dlen > pfile->max_include_len)
pfile->max_include_len = dlen;
for (x = pfile->actual_dirs; x; x = x->alloc)
if (!strcmp (x->name, dir))
{
free (dir);
return x;
}
/* Not found, make a new one. */
x = (struct file_name_list *) xmalloc (sizeof (struct file_name_list));
x->name = dir;
x->nlen = dlen;
x->next = CPP_OPTIONS (pfile)->quote_include;
x->alloc = pfile->actual_dirs;
cppinit.c: Instead of one pending list... 1999-03-15 21:39 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppinit.c: Instead of one pending list, keep separate lists for each category of pending option: -D/-U, -A, -include, -imacros. Move the four partial include-path lists into the pending block. Use head and tail pointers so we don't ever have to reverse the lists. (cpp_start_read): Break out blocks of code to their own functions: install_predefs and initialize_dependency_output. Use path_include for C_INCLUDE_PATH and friends as well as CPATH. Remove include_defaults gunk. Warn about the combination of -lang-chill and -trigraphs. Optimize string bashing. Walk each pending list once, deallocating as we go. (append_include_chain): Brought over from cppfiles.c. Mark dirs as system include dirs if and only if appending to system include path. If opts->verbose, print a notice when a dir is dropped from the include path because it doesn't exist. Fix memory leak: this function is not supposed to copy its DIR argument. (nreverse_pending, push_pending): Removed. (APPEND): New macro for adding to pending lists. (path_include): Can now add to any partial include path. (base_name): Bring over from cccp.c. (cpp_options_init): Allocate the pending block. (cpp_handle_option): Add --version. Exit after --help. Fix formatting. Order -ifoo options by frequency of usage. (install_predefs): New function, simplified version of code that was in cpp_start_read. (initialize_dependency_output): Likewise. Understand OBJECT_SUFFIX. * cppfiles.c (simplify_pathname): Export. (merge_include_chains): Don't nreverse the lists. If opts->verbose, print a notice when a duplicate dir is detected and dropped from the include path. (finclude): Fix excessive cleverness in setting fp->system_header_p. (actual_directory): Set x->sysp from CPP_BUFFER (pfile)->system_header_p so that one system header may include another with "". (deps_output): Fix double adjustment of deps_size which would cause all dependencies after the first two lines to be lost. * cpplib.c (cpp_unassert): New function. * cpplib.h: Lay out struct cpp_pending here. Adjust prototypes. Add include_prefix_len to struct cpp_options. From-SVN: r25793
1999-03-15 19:42:46 +01:00
x->sysp = CPP_BUFFER (pfile)->system_header_p;
cpplib.h (struct cpp_buffer): Replace dir and dlen members with a struct file_name_list pointer. 1998-11-26 01:17 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu> * cpplib.h (struct cpp_buffer): Replace dir and dlen members with a struct file_name_list pointer. (struct cpp_reader): Add pointer to chain of `actual directory' include searchpath entries. (struct file_name_list): Add *alloc pointer for the sake of the actual-directory chain. Move definition of HOST_WIDE_INT here. (cpp_parse_escape): Change prototype to match changes in cppexp.c. * cppfiles.c (actual_directory): New function. (finclude): Use it to initialize the buffer's actual_dir entry. (find_include_file): We don't need to fix up max_include_len here. * cpplib.c (do_include): Don't allocate a file_name_list on the fly for current directory "" includes, use the one that's been preallocated in pfile->buffer->actual_dir. Hoist out duplicate code from the search_start selection logic. (cpp_reader_init): Initialize pfile->actual_dirs. Remove definition of HOST_WIDE_INT. Change calls to cpp_parse_escape to match changes in cppexp.c (note hardcoded MASK, which is safe since this is the source character set). * cppexp.c: Bring over changes to cpp_parse_escape from cccp.c to handle wide character constants in #if directives. The function now returns a HOST_WIDE_INT, and takes a third argument which is a binary mask for all legal values (0x00ff for 8-bit `char', 0xffff for 16-bit `wchar_t', etc.) Define MAX_CHAR_TYPE_MASK and MAX_WCHAR_TYPE_MASK. Change callers of cpp_parse_escape to match. [Fixes c-torture/execute/widechar-1.c] From-SVN: r24153
1998-12-07 14:35:20 +01:00
x->name_map = NULL;
pfile->actual_dirs = x;
return x;
}
/* Determine the current line and column. Used only by read_and_prescan. */
static U_CHAR *
find_position (start, limit, linep)
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
U_CHAR *start;
U_CHAR *limit;
unsigned long *linep;
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
{
unsigned long line = *linep;
U_CHAR *lbase = start;
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
while (start < limit)
{
U_CHAR ch = *start++;
if (ch == '\n' || ch == '\r')
{
line++;
lbase = start;
}
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
}
*linep = line;
return lbase;
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
}
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
/* Read the entire contents of file DESC into buffer BUF. LEN is how
much memory to allocate initially; more will be allocated if
necessary. Convert end-of-line markers (\n, \r, \r\n, \n\r) to
canonical form (\n). If enabled, convert and/or warn about
trigraphs. Convert backslash-newline to a one-character escape
(\r) and remove it from "embarrassing" places (i.e. the middle of a
token). If there is no newline at the end of the file, add one and
warn. Returns -1 on failure, or the actual length of the data to
be scanned.
This function does a lot of work, and can be a serious performance
bottleneck. It has been tuned heavily; make sure you understand it
before hacking. The common case - no trigraphs, Unix style line
breaks, backslash-newline set off by whitespace, newline at EOF -
has been optimized at the expense of the others. The performance
penalty for DOS style line breaks (\r\n) is about 15%.
Warnings lose particularly heavily since we have to determine the
line number, which involves scanning from the beginning of the file
or from the last warning. The penalty for the absence of a newline
at the end of reload1.c is about 60%. (reload1.c is 329k.)
If your file has more than one kind of end-of-line marker, you
will get messed-up line numbering. */
[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
/* Table of characters that can't be handled in the inner loop.
Keep these contiguous to optimize the performance of the code generated
for the switch that uses them. */
#define SPECCASE_EMPTY 0
#define SPECCASE_NUL 1
#define SPECCASE_CR 2
#define SPECCASE_BACKSLASH 3
#define SPECCASE_QUESTION 4
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
static long
read_and_prescan (pfile, fp, desc, len)
cpp_reader *pfile;
cpp_buffer *fp;
[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
int desc;
size_t len;
[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
{
U_CHAR *buf = (U_CHAR *) xmalloc (len);
U_CHAR *ip, *op, *line_base;
U_CHAR *ibase;
U_CHAR *speccase = pfile->input_speccase;
unsigned long line;
unsigned int deferred_newlines;
int count;
size_t offset;
offset = 0;
op = buf;
line_base = buf;
line = 1;
ibase = pfile->input_buffer + 2;
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
deferred_newlines = 0;
for (;;)
{
read_next:
count = read (desc, pfile->input_buffer + 2, pfile->input_buffer_len);
if (count < 0)
goto error;
else if (count == 0)
break;
offset += count;
ip = ibase;
ibase = pfile->input_buffer + 2;
ibase[count] = ibase[count+1] = '\0';
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
if (offset > len)
{
size_t delta_op;
size_t delta_line_base;
len *= 2;
if (offset > len)
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
/* len overflowed.
This could happen if the file is larger than half the
maximum address space of the machine. */
goto too_big;
delta_op = op - buf;
delta_line_base = line_base - buf;
buf = (U_CHAR *) xrealloc (buf, len);
op = buf + delta_op;
line_base = buf + delta_line_base;
}
for (;;)
{
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
unsigned int span = 0;
/* Deal with \-newline in the middle of a token. */
if (deferred_newlines)
{
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
while (speccase[ip[span]] == SPECCASE_EMPTY
&& ip[span] != '\n'
&& ip[span] != '\t'
&& ip[span] != ' ')
span++;
memcpy (op, ip, span);
op += span;
ip += span;
if (*ip == '\n' || *ip == '\t'
|| *ip == ' ' || *ip == ' ')
while (deferred_newlines)
deferred_newlines--, *op++ = '\r';
span = 0;
}
/* Copy as much as we can without special treatment. */
while (speccase[ip[span]] == SPECCASE_EMPTY) span++;
memcpy (op, ip, span);
op += span;
ip += span;
switch (speccase[*ip++])
{
case SPECCASE_NUL: /* \0 */
ibase[-1] = op[-1];
goto read_next;
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
case SPECCASE_CR: /* \r */
if (*ip == '\n')
ip++;
else if (*ip == '\0')
{
*--ibase = '\r';
goto read_next;
}
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
else if (ip[-2] == '\n')
continue;
*op++ = '\n';
break;
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
case SPECCASE_BACKSLASH: /* \ */
backslash:
{
/* If we're at the end of the intermediate buffer,
we have to shift the backslash down to the start
and come back next pass. */
if (*ip == '\0')
{
*--ibase = '\\';
goto read_next;
}
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
else if (*ip == '\n')
{
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
ip++;
if (*ip == '\r') ip++;
if (*ip == '\n' || *ip == '\t' || *ip == ' ')
*op++ = '\r';
else if (op[-1] == '\t' || op[-1] == ' '
|| op[-1] == '\r' || op[-1] == '\n')
*op++ = '\r';
else
deferred_newlines++;
}
else if (*ip == '\r')
{
ip++;
if (*ip == '\n') ip++;
else if (*ip == '\0')
{
*--ibase = '\r';
*--ibase = '\\';
goto read_next;
}
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
else if (*ip == '\r' || *ip == '\t' || *ip == ' ')
*op++ = '\r';
else
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
deferred_newlines++;
}
else
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
*op++ = '\\';
}
break;
case SPECCASE_QUESTION: /* ? */
{
cpplib.h (struct cpp_buffer: fname, [...]): Mark const. 1999-10-28 21:27 -0700 Zack Weinberg <zack@bitmover.com> * cpplib.h (struct cpp_buffer: fname, nominal_fname, last_nominal_fname): Mark const. (struct include_hash: name, nshort, control_macro): Mark const. (struct macrodef: symnam): Mark const. (struct if_stack: fname): Mark const. (is_idchar, is_idstart, is_hor_space, trigraph_table): Delete. (IStable): New character-syntax array which encompasses all the old is_foo arrays. (is_idchar, is_numchar, is_idstart, is_numstart, is_hspace, is_space): New macros for interrogating IStable. (check_macro_name): Kill last argument. All callers changed. * cppinit.c (initialize_char_syntax): Delete. (is_idchar, is_idstart, is_hor_space, is_space, trigraph_table): Delete. (IStable): New. Initialize with clever macros to avoid information duplication. (builtin_array): Table of builtins to get rid of explicit list in initialize_builtins. (initialize_builtins): Use builtins_array. (cpp_start_read): Call init_IStable, and set IStable['$'] if opts->dollars_in_ident. * cppexp.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. (cpp_parse_expr): Avoid 'format string is not constant' warning. Use ISGRAPH to identify printable chars. * cppfiles.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. (read_and_prescan): Map trigraphs to chars with open-coded if-else-if-... sequence, not a lookup table. * cpphash.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. * cpplib.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. Kill SKIP_ALL_WHITE_SPACE (unused). (check_macro_name): Remove ability to report an invalid assertion name, which is never used. (do_line): Constify a couple of char *'s. * cppmain.c (main): Call cpp_cleanup before returning. From-SVN: r30252
1999-10-29 06:31:14 +02:00
unsigned int d, t;
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
/* If we're at the end of the intermediate buffer,
we have to shift the ?'s down to the start and
come back next pass. */
d = ip[0];
if (d == '\0')
{
*--ibase = '?';
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
goto read_next;
}
if (d != '?')
{
*op++ = '?';
break;
}
d = ip[1];
if (d == '\0')
{
*--ibase = '?';
*--ibase = '?';
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
goto read_next;
}
cpplib.h (struct cpp_buffer: fname, [...]): Mark const. 1999-10-28 21:27 -0700 Zack Weinberg <zack@bitmover.com> * cpplib.h (struct cpp_buffer: fname, nominal_fname, last_nominal_fname): Mark const. (struct include_hash: name, nshort, control_macro): Mark const. (struct macrodef: symnam): Mark const. (struct if_stack: fname): Mark const. (is_idchar, is_idstart, is_hor_space, trigraph_table): Delete. (IStable): New character-syntax array which encompasses all the old is_foo arrays. (is_idchar, is_numchar, is_idstart, is_numstart, is_hspace, is_space): New macros for interrogating IStable. (check_macro_name): Kill last argument. All callers changed. * cppinit.c (initialize_char_syntax): Delete. (is_idchar, is_idstart, is_hor_space, is_space, trigraph_table): Delete. (IStable): New. Initialize with clever macros to avoid information duplication. (builtin_array): Table of builtins to get rid of explicit list in initialize_builtins. (initialize_builtins): Use builtins_array. (cpp_start_read): Call init_IStable, and set IStable['$'] if opts->dollars_in_ident. * cppexp.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. (cpp_parse_expr): Avoid 'format string is not constant' warning. Use ISGRAPH to identify printable chars. * cppfiles.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. (read_and_prescan): Map trigraphs to chars with open-coded if-else-if-... sequence, not a lookup table. * cpphash.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. * cpplib.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. Kill SKIP_ALL_WHITE_SPACE (unused). (check_macro_name): Remove ability to report an invalid assertion name, which is never used. (do_line): Constify a couple of char *'s. * cppmain.c (main): Call cpp_cleanup before returning. From-SVN: r30252
1999-10-29 06:31:14 +02:00
/* Trigraph map:
* from to from to from to
* ?? = # ?? ) ] ?? ! |
* ?? ( [ ?? ' ^ ?? > }
* ?? / \ ?? < { ?? - ~
*/
if (d == '=') t = '#';
else if (d == ')') t = ']';
else if (d == '!') t = '|';
else if (d == '(') t = '[';
else if (d == '\'') t = '^';
else if (d == '>') t = '}';
else if (d == '/') t = '\\';
else if (d == '<') t = '{';
else if (d == '-') t = '~';
else
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
{
*op++ = '?';
break;
}
ip += 2;
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
if (CPP_OPTIONS (pfile)->warn_trigraphs)
{
unsigned long col;
line_base = find_position (line_base, op, &line);
col = op - line_base + 1;
if (CPP_OPTIONS (pfile)->trigraphs)
cpp_warning_with_line (pfile, line, col,
"trigraph ??%c converted to %c", d, t);
else
cpp_warning_with_line (pfile, line, col,
"trigraph ??%c ignored", d);
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
}
if (CPP_OPTIONS (pfile)->trigraphs)
{
cpplib.h (struct cpp_buffer: fname, [...]): Mark const. 1999-10-28 21:27 -0700 Zack Weinberg <zack@bitmover.com> * cpplib.h (struct cpp_buffer: fname, nominal_fname, last_nominal_fname): Mark const. (struct include_hash: name, nshort, control_macro): Mark const. (struct macrodef: symnam): Mark const. (struct if_stack: fname): Mark const. (is_idchar, is_idstart, is_hor_space, trigraph_table): Delete. (IStable): New character-syntax array which encompasses all the old is_foo arrays. (is_idchar, is_numchar, is_idstart, is_numstart, is_hspace, is_space): New macros for interrogating IStable. (check_macro_name): Kill last argument. All callers changed. * cppinit.c (initialize_char_syntax): Delete. (is_idchar, is_idstart, is_hor_space, is_space, trigraph_table): Delete. (IStable): New. Initialize with clever macros to avoid information duplication. (builtin_array): Table of builtins to get rid of explicit list in initialize_builtins. (initialize_builtins): Use builtins_array. (cpp_start_read): Call init_IStable, and set IStable['$'] if opts->dollars_in_ident. * cppexp.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. (cpp_parse_expr): Avoid 'format string is not constant' warning. Use ISGRAPH to identify printable chars. * cppfiles.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. (read_and_prescan): Map trigraphs to chars with open-coded if-else-if-... sequence, not a lookup table. * cpphash.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. * cpplib.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. Kill SKIP_ALL_WHITE_SPACE (unused). (check_macro_name): Remove ability to report an invalid assertion name, which is never used. (do_line): Constify a couple of char *'s. * cppmain.c (main): Call cpp_cleanup before returning. From-SVN: r30252
1999-10-29 06:31:14 +02:00
if (t == '\\')
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
goto backslash;
else
cpplib.h (struct cpp_buffer: fname, [...]): Mark const. 1999-10-28 21:27 -0700 Zack Weinberg <zack@bitmover.com> * cpplib.h (struct cpp_buffer: fname, nominal_fname, last_nominal_fname): Mark const. (struct include_hash: name, nshort, control_macro): Mark const. (struct macrodef: symnam): Mark const. (struct if_stack: fname): Mark const. (is_idchar, is_idstart, is_hor_space, trigraph_table): Delete. (IStable): New character-syntax array which encompasses all the old is_foo arrays. (is_idchar, is_numchar, is_idstart, is_numstart, is_hspace, is_space): New macros for interrogating IStable. (check_macro_name): Kill last argument. All callers changed. * cppinit.c (initialize_char_syntax): Delete. (is_idchar, is_idstart, is_hor_space, is_space, trigraph_table): Delete. (IStable): New. Initialize with clever macros to avoid information duplication. (builtin_array): Table of builtins to get rid of explicit list in initialize_builtins. (initialize_builtins): Use builtins_array. (cpp_start_read): Call init_IStable, and set IStable['$'] if opts->dollars_in_ident. * cppexp.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. (cpp_parse_expr): Avoid 'format string is not constant' warning. Use ISGRAPH to identify printable chars. * cppfiles.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. (read_and_prescan): Map trigraphs to chars with open-coded if-else-if-... sequence, not a lookup table. * cpphash.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. * cpplib.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. Kill SKIP_ALL_WHITE_SPACE (unused). (check_macro_name): Remove ability to report an invalid assertion name, which is never used. (do_line): Constify a couple of char *'s. * cppmain.c (main): Call cpp_cleanup before returning. From-SVN: r30252
1999-10-29 06:31:14 +02:00
*op++ = t;
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
}
else
{
*op++ = '?';
*op++ = '?';
*op++ = d;
}
}
}
}
}
if (offset == 0)
return 0;
/* Deal with pushed-back chars at true EOF.
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
This may be any of: ?? ? \ \r \n \\r \\n.
\r must become \n, \\r or \\n must become \r.
We know we have space already. */
if (ibase == pfile->input_buffer)
{
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
if (*ibase == '?')
{
*op++ = '?';
*op++ = '?';
}
else
*op++ = '\r';
}
else if (ibase == pfile->input_buffer + 1)
{
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
if (*ibase == '\r')
*op++ = '\n';
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
else
*op++ = *ibase;
}
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
if (op[-1] != '\n')
{
unsigned long col;
line_base = find_position (line_base, op, &line);
col = op - line_base + 1;
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
cpp_warning_with_line (pfile, line, col, "no newline at end of file\n");
if (offset + 1 > len)
{
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
len += 1;
if (offset + 1 > len)
goto too_big;
buf = (U_CHAR *) xrealloc (buf, len);
op = buf + offset;
}
*op++ = '\n';
}
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
fp->buf = ((len - offset < 20) ? buf : (U_CHAR *)xrealloc (buf, op - buf));
return op - buf;
too_big:
cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-16 14:10:15 +01:00
cpp_error (pfile, "file is too large (>%lu bytes)\n", (unsigned long)offset);
free (buf);
return -1;
error:
cpp_error_from_errno (pfile, fp->fname);
free (buf);
return -1;
[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
}
/* Initialize the `input_buffer' and `input_speccase' tables.
These are only used by read_and_prescan, but they're large and
somewhat expensive to set up, so we want them allocated once for
the duration of the cpp run. */
static void
initialize_input_buffer (pfile, fd, st)
cpp_reader *pfile;
int fd;
struct stat *st;
{
long pipe_buf;
U_CHAR *tmp;
/* Table of characters that cannot be handled by the
read_and_prescan inner loop. The number of non-EMPTY entries
should be as small as humanly possible. */
tmp = (U_CHAR *) xmalloc (1 << CHAR_BIT);
memset (tmp, SPECCASE_EMPTY, 1 << CHAR_BIT);
tmp['\0'] = SPECCASE_NUL;
tmp['\r'] = SPECCASE_CR;
tmp['\\'] = SPECCASE_BACKSLASH;
if (CPP_OPTIONS (pfile)->trigraphs || CPP_OPTIONS (pfile)->warn_trigraphs)
tmp['?'] = SPECCASE_QUESTION;
pfile->input_speccase = tmp;
/* Determine the appropriate size for the input buffer. Normal C
source files are smaller than eight K. If we are reading a pipe,
we want to make sure the input buffer is bigger than the kernel's
pipe buffer. */
pipe_buf = -1;
if (! S_ISREG (st->st_mode))
{
#ifdef _PC_PIPE_BUF
pipe_buf = fpathconf (fd, _PC_PIPE_BUF);
#endif
if (pipe_buf == -1)
{
#ifdef PIPE_BUF
pipe_buf = PIPE_BUF;
#else
pipe_buf = 8192;
#endif
}
}
if (pipe_buf < 8192)
pipe_buf = 8192;
/* PIPE_BUF bytes of buffer proper, 2 to detect running off the end
without address arithmetic all the time, and 2 for pushback in
the case there's a potential trigraph or end-of-line digraph at
the end of a block. */
tmp = (U_CHAR *) xmalloc (pipe_buf + 2 + 2);
pfile->input_buffer = tmp;
pfile->input_buffer_len = pipe_buf;
}
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
/* Add output to `deps_buffer' for the -M switch.
STRING points to the text to be output.
SPACER is ':' for targets, ' ' for dependencies, zero for text
to be inserted literally. */
void
deps_output (pfile, string, spacer)
cpp_reader *pfile;
cpperror.c (cpp_file_line_for_message): Constify a char*. * cpperror.c (cpp_file_line_for_message): Constify a char*. * cppexp.c (parse_number, parse_charconst, cpp_lex, cpp_parse_expr): Add static prototypes. (parse_charconst): Don't cast away const-ness. (token): Constify a char*. * cppfiles.c (file_name_list, include_hash, find_include_file, finclude, initialize_input_buffer): Constify a char*. (file_cleanup, find_position): Add static prototypes. * cpphash.c (macro_cleanup, macarg, timestamp, special_symbol, collect_expansion): Add static prototypes. (cpp_install, create_definition, monthnames): Constify a char*. * cpphash.h (cpp_install): Likewise. * cppinit.c (known_suffixes, default_include, dump_special_to_buffer, NAME, cpp_start_read, cpp_finish): Likewise. (base_name, dump_special_to_buffer, initialize_dependency_output): Add static prototypes. * cpplib.c (my_strerror): Constify a char*. (null_underflow, null_cleanup, skip_comment, copy_comment, copy_rest_of_line, handle_directive, pass_thru_directive, get_directive_token, read_line_number, cpp_print_file_and_line, v_cpp_error, v_cpp_warning, v_cpp_error_with_line, v_cpp_warning_with_line, detect_if_not_defined, consider_directive_while_skipping): Add static prototypes. (pass_thru_directive, check_macro_name, cpp_expand_to_buffer, cpp_pedwarn_with_file_and_line): Constify a char*. * cpplib.h (cpp_options, include_hash, progname, definition, cpp_pedwarn_with_file_and_line, cpp_expand_to_buffer, check_macro_name, cpp_pfatal_with_name, cpp_file_line_for_message, find_include_file, deps_output, include_hash): Constify a char*. * cppmain.c (progname): Constify. (main): Add prototype. Use return, not exit. * fix-header.c (fatal, add_symbols, lookup_std_proto, write_lbrac, recognized_macro, check_macro_names, read_scan_file, write_rbrac, inf_skip_spaces, inf_read_upto, inf_scan_ident, inf_scan_ident, check_protection): Add static prototype. (xfree): Remove. (progname, recognized_macrom, recognized_extern): Constify a char*. (main): Add prototype. * gen-protos.c (progname): Constify a char*. From-SVN: r29171
1999-09-07 17:41:26 +02:00
const char *string;
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
int spacer;
{
int size;
int cr = 0;
if (!*string)
return;
size = strlen (string);
#ifndef MAX_OUTPUT_COLUMNS
#define MAX_OUTPUT_COLUMNS 72
#endif
if (pfile->deps_column > 0
&& (pfile->deps_column + size) > MAX_OUTPUT_COLUMNS)
{
cppinit.c: Instead of one pending list... 1999-03-15 21:39 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppinit.c: Instead of one pending list, keep separate lists for each category of pending option: -D/-U, -A, -include, -imacros. Move the four partial include-path lists into the pending block. Use head and tail pointers so we don't ever have to reverse the lists. (cpp_start_read): Break out blocks of code to their own functions: install_predefs and initialize_dependency_output. Use path_include for C_INCLUDE_PATH and friends as well as CPATH. Remove include_defaults gunk. Warn about the combination of -lang-chill and -trigraphs. Optimize string bashing. Walk each pending list once, deallocating as we go. (append_include_chain): Brought over from cppfiles.c. Mark dirs as system include dirs if and only if appending to system include path. If opts->verbose, print a notice when a dir is dropped from the include path because it doesn't exist. Fix memory leak: this function is not supposed to copy its DIR argument. (nreverse_pending, push_pending): Removed. (APPEND): New macro for adding to pending lists. (path_include): Can now add to any partial include path. (base_name): Bring over from cccp.c. (cpp_options_init): Allocate the pending block. (cpp_handle_option): Add --version. Exit after --help. Fix formatting. Order -ifoo options by frequency of usage. (install_predefs): New function, simplified version of code that was in cpp_start_read. (initialize_dependency_output): Likewise. Understand OBJECT_SUFFIX. * cppfiles.c (simplify_pathname): Export. (merge_include_chains): Don't nreverse the lists. If opts->verbose, print a notice when a duplicate dir is detected and dropped from the include path. (finclude): Fix excessive cleverness in setting fp->system_header_p. (actual_directory): Set x->sysp from CPP_BUFFER (pfile)->system_header_p so that one system header may include another with "". (deps_output): Fix double adjustment of deps_size which would cause all dependencies after the first two lines to be lost. * cpplib.c (cpp_unassert): New function. * cpplib.h: Lay out struct cpp_pending here. Adjust prototypes. Add include_prefix_len to struct cpp_options. From-SVN: r25793
1999-03-15 19:42:46 +01:00
cr = 5;
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
pfile->deps_column = 0;
}
cppinit.c: Instead of one pending list... 1999-03-15 21:39 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppinit.c: Instead of one pending list, keep separate lists for each category of pending option: -D/-U, -A, -include, -imacros. Move the four partial include-path lists into the pending block. Use head and tail pointers so we don't ever have to reverse the lists. (cpp_start_read): Break out blocks of code to their own functions: install_predefs and initialize_dependency_output. Use path_include for C_INCLUDE_PATH and friends as well as CPATH. Remove include_defaults gunk. Warn about the combination of -lang-chill and -trigraphs. Optimize string bashing. Walk each pending list once, deallocating as we go. (append_include_chain): Brought over from cppfiles.c. Mark dirs as system include dirs if and only if appending to system include path. If opts->verbose, print a notice when a dir is dropped from the include path because it doesn't exist. Fix memory leak: this function is not supposed to copy its DIR argument. (nreverse_pending, push_pending): Removed. (APPEND): New macro for adding to pending lists. (path_include): Can now add to any partial include path. (base_name): Bring over from cccp.c. (cpp_options_init): Allocate the pending block. (cpp_handle_option): Add --version. Exit after --help. Fix formatting. Order -ifoo options by frequency of usage. (install_predefs): New function, simplified version of code that was in cpp_start_read. (initialize_dependency_output): Likewise. Understand OBJECT_SUFFIX. * cppfiles.c (simplify_pathname): Export. (merge_include_chains): Don't nreverse the lists. If opts->verbose, print a notice when a duplicate dir is detected and dropped from the include path. (finclude): Fix excessive cleverness in setting fp->system_header_p. (actual_directory): Set x->sysp from CPP_BUFFER (pfile)->system_header_p so that one system header may include another with "". (deps_output): Fix double adjustment of deps_size which would cause all dependencies after the first two lines to be lost. * cpplib.c (cpp_unassert): New function. * cpplib.h: Lay out struct cpp_pending here. Adjust prototypes. Add include_prefix_len to struct cpp_options. From-SVN: r25793
1999-03-15 19:42:46 +01:00
if (pfile->deps_size + size + cr + 8 > pfile->deps_allocated_size)
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
{
pfile->deps_allocated_size = (pfile->deps_size + size + 50) * 2;
pfile->deps_buffer = (char *) xrealloc (pfile->deps_buffer,
pfile->deps_allocated_size);
}
if (cr)
{
bcopy (" \\\n ", &pfile->deps_buffer[pfile->deps_size], 5);
pfile->deps_size += 5;
}
if (spacer == ' ' && pfile->deps_column > 0)
pfile->deps_buffer[pfile->deps_size++] = ' ';
bcopy (string, &pfile->deps_buffer[pfile->deps_size], size);
pfile->deps_size += size;
pfile->deps_column += size;
if (spacer == ':')
pfile->deps_buffer[pfile->deps_size++] = ':';
pfile->deps_buffer[pfile->deps_size] = 0;
}
/* Simplify a path name in place, deleting redundant components. This
reduces OS overhead and guarantees that equivalent paths compare
the same (modulo symlinks).
Transforms made:
foo/bar/../quux foo/quux
foo/./bar foo/bar
foo//bar foo/bar
/../quux /quux
//quux //quux (POSIX allows leading // as a namespace escape)
Guarantees no trailing slashes. All transforms reduce the length
of the string.
*/
cppinit.c: Instead of one pending list... 1999-03-15 21:39 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppinit.c: Instead of one pending list, keep separate lists for each category of pending option: -D/-U, -A, -include, -imacros. Move the four partial include-path lists into the pending block. Use head and tail pointers so we don't ever have to reverse the lists. (cpp_start_read): Break out blocks of code to their own functions: install_predefs and initialize_dependency_output. Use path_include for C_INCLUDE_PATH and friends as well as CPATH. Remove include_defaults gunk. Warn about the combination of -lang-chill and -trigraphs. Optimize string bashing. Walk each pending list once, deallocating as we go. (append_include_chain): Brought over from cppfiles.c. Mark dirs as system include dirs if and only if appending to system include path. If opts->verbose, print a notice when a dir is dropped from the include path because it doesn't exist. Fix memory leak: this function is not supposed to copy its DIR argument. (nreverse_pending, push_pending): Removed. (APPEND): New macro for adding to pending lists. (path_include): Can now add to any partial include path. (base_name): Bring over from cccp.c. (cpp_options_init): Allocate the pending block. (cpp_handle_option): Add --version. Exit after --help. Fix formatting. Order -ifoo options by frequency of usage. (install_predefs): New function, simplified version of code that was in cpp_start_read. (initialize_dependency_output): Likewise. Understand OBJECT_SUFFIX. * cppfiles.c (simplify_pathname): Export. (merge_include_chains): Don't nreverse the lists. If opts->verbose, print a notice when a duplicate dir is detected and dropped from the include path. (finclude): Fix excessive cleverness in setting fp->system_header_p. (actual_directory): Set x->sysp from CPP_BUFFER (pfile)->system_header_p so that one system header may include another with "". (deps_output): Fix double adjustment of deps_size which would cause all dependencies after the first two lines to be lost. * cpplib.c (cpp_unassert): New function. * cpplib.h: Lay out struct cpp_pending here. Adjust prototypes. Add include_prefix_len to struct cpp_options. From-SVN: r25793
1999-03-15 19:42:46 +01:00
void
simplify_pathname (path)
char *path;
cpplib.h: Delete struct import_file. Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu> * cpplib.h: Delete struct import_file. Add ihash element to struct cpp_buffer. Delete dont_repeat_files and import_hash_table elements from cpp_reader; change all_include_files to a hash table. Delete all foobar_include / last_foobar_include elements from struct cpp_options; put back four such: quote_include, bracket_include, system_include, after_include. Redo struct file_name_list completely. Add new structure type include_hash. Add prototypes for merge_include_chains and include_hash. Change prototypes for finclude, find_include_file, and append_include_chain to match changes below. * cppfiles.c (simplify_pathname, include_hash, remap_filename, merge_include_chains): New functions. (add_import, lookup_import, open_include_file): Removed. (INO_T_EQ): Define this (copied from cccp.c). (hack_vms_include_specification): Remove all calls and #if 0 out the definition. It was being called incorrectly and at the wrong times. Until a VMSie can look at this, it's better to not pretend to support it. (append_include_chain): Change calling convention; now takes only one directory at a time, and sets up the data structure itself. (redundant_include_p): Rewritten - this is now used for all include redundancy, whether by #ifndef, #import, or #pragma once. Looks up things in the include hash table. (file_cleanup): Decrement pfile->system_include_depth here if it's >0. (find_include_file): Calling convention changed; now passes around a struct include_hash instead of 3 separate parameters. Guts ripped out and replaced with new include_hash mechanism. (finclude): Calling convention changed as for find_include_file. Error exits pulled out-of-line. Reformat. (safe_read): Return a long, not an int. (deps_output): Don't recurse. * cpplib.c (is_system_include): Deleted. (path_include): Fix up call to append_include_chain. (do_include): Fix up calls to find_include_file and finclude. Clean up dependency output a bit. Shorten obnoxiously lengthy #import warning message. Don't decrement pfile->system_include_depth here. (do_pragma): Understand the include_hash structure. Reformat. (do_endif): Correct handling of control macros. Understand the include_hash. (cpp_start_read): Fix up calls to finclude. Call merge_include_chains. (cpp_handle_option): Fix up calls to append_include_chain. Understand the four partial include chains. (cpp_finish): Add debugging code (#if 0-ed out) for the include_hash. (cpp_cleanup): Free the include_hash, not the import hash and the all_include and dont_repeat lists which no longer exist. From-SVN: r23857
1998-11-25 12:56:54 +01:00
{
char *from, *to;
char *base;
int absolute = 0;
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
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
/* Convert all backslashes to slashes. */
for (from = path; *from; from++)
if (*from == '\\') *from = '/';
/* Skip over leading drive letter if present. */
if (ISALPHA (path[0]) && path[1] == ':')
from = to = &path[2];
else
from = to = path;
#else
from = to = path;
#endif
/* Remove redundant initial /s. */
if (*from == '/')
{
absolute = 1;
to++;
from++;
if (*from == '/')
{
if (*++from == '/')
/* 3 or more initial /s are equivalent to 1 /. */
while (*++from == '/');
else
/* On some hosts // differs from /; Posix allows this. */
to++;
}
}
base = to;
for (;;)
{
while (*from == '/')
from++;
if (from[0] == '.' && from[1] == '/')
from += 2;
else if (from[0] == '.' && from[1] == '\0')
goto done;
else if (from[0] == '.' && from[1] == '.' && from[2] == '/')
{
if (base == to)
{
if (absolute)
from += 3;
else
{
*to++ = *from++;
*to++ = *from++;
*to++ = *from++;
base = to;
}
}
else
{
to -= 2;
while (to > base && *to != '/') to--;
if (*to == '/')
to++;
from += 3;
}
}
else if (from[0] == '.' && from[1] == '.' && from[2] == '\0')
{
if (base == to)
{
if (!absolute)
{
*to++ = *from++;
*to++ = *from++;
}
}
else
{
to -= 2;
while (to > base && *to != '/') to--;
if (*to == '/')
to++;
}
goto done;
}
else
/* Copy this component and trailing /, if any. */
while ((*to++ = *from++) != '/')
{
if (!to[-1])
{
to--;
goto done;
}
}
}
done:
/* Trim trailing slash */
if (to[0] == '/' && (!absolute || to > path+1))
to--;
/* Change the empty string to "." so that stat() on the result
will always work. */
if (to == path)
*to++ = '.';
*to = '\0';
return;
}
/* It is not clear when this should be used if at all, so I've
disabled it until someone who understands VMS can look at it. */
#if 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
/* Under VMS we need to fix up the "include" specification filename.
Rules for possible conversions
fullname tried paths
name name
./dir/name [.dir]name
/dir/name dir:name
/name [000000]name, name
dir/name dir:[000000]name, dir:name, dir/name
dir1/dir2/name dir1:[dir2]name, dir1:[000000.dir2]name
path:/name path:[000000]name, path:name
path:/dir/name path:[000000.dir]name, path:[dir]name
path:dir/name path:[dir]name
[path]:[dir]name [path.dir]name
path/[dir]name [path.dir]name
The path:/name input is constructed when expanding <> includes. */
static void
hack_vms_include_specification (fullname)
char *fullname;
{
register char *basename, *unixname, *local_ptr, *first_slash;
int f, check_filename_before_returning, must_revert;
char Local[512];
check_filename_before_returning = 0;
must_revert = 0;
/* See if we can find a 1st slash. If not, there's no path information. */
first_slash = index (fullname, '/');
if (first_slash == 0)
return 0; /* Nothing to do!!! */
/* construct device spec if none given. */
if (index (fullname, ':') == 0)
{
/* If fullname has a slash, take it as device spec. */
if (first_slash == fullname)
{
first_slash = index (fullname+1, '/'); /* 2nd slash ? */
if (first_slash)
*first_slash = ':'; /* make device spec */
for (basename = fullname; *basename != 0; basename++)
*basename = *(basename+1); /* remove leading slash */
}
else if ((first_slash[-1] != '.') /* keep ':/', './' */
&& (first_slash[-1] != ':')
&& (first_slash[-1] != ']')) /* or a vms path */
{
*first_slash = ':';
}
else if ((first_slash[1] == '[') /* skip './' in './[dir' */
&& (first_slash[-1] == '.'))
fullname += 2;
}
/* Get part after first ':' (basename[-1] == ':')
or last '/' (basename[-1] == '/'). */
basename = base_name (fullname);
local_ptr = Local; /* initialize */
/* We are trying to do a number of things here. First of all, we are
trying to hammer the filenames into a standard format, such that later
processing can handle them.
If the file name contains something like [dir.], then it recognizes this
as a root, and strips the ".]". Later processing will add whatever is
needed to get things working properly.
If no device is specified, then the first directory name is taken to be
a device name (or a rooted logical). */
/* Point to the UNIX filename part (which needs to be fixed!)
but skip vms path information.
[basename != fullname since first_slash != 0]. */
if ((basename[-1] == ':') /* vms path spec. */
|| (basename[-1] == ']')
|| (basename[-1] == '>'))
unixname = basename;
else
unixname = fullname;
if (*unixname == '/')
unixname++;
/* If the directory spec is not rooted, we can just copy
the UNIX filename part and we are done. */
if (((basename - fullname) > 1)
&& ( (basename[-1] == ']')
|| (basename[-1] == '>')))
{
if (basename[-2] != '.')
{
/* The VMS part ends in a `]', and the preceding character is not a `.'.
-> PATH]:/name (basename = '/name', unixname = 'name')
We strip the `]', and then splice the two parts of the name in the
usual way. Given the default locations for include files in cccp.c,
we will only use this code if the user specifies alternate locations
with the /include (-I) switch on the command line. */
basename -= 1; /* Strip "]" */
unixname--; /* backspace */
}
else
{
/* The VMS part has a ".]" at the end, and this will not do. Later
processing will add a second directory spec, and this would be a syntax
error. Thus we strip the ".]", and thus merge the directory specs.
We also backspace unixname, so that it points to a '/'. This inhibits the
generation of the 000000 root directory spec (which does not belong here
in this case). */
basename -= 2; /* Strip ".]" */
unixname--; /* backspace */
}
}
else
{
/* We drop in here if there is no VMS style directory specification yet.
If there is no device specification either, we make the first dir a
device and try that. If we do not do this, then we will be essentially
searching the users default directory (as if they did a #include "asdf.h").
Then all we need to do is to push a '[' into the output string. Later
processing will fill this in, and close the bracket. */
if ((unixname != fullname) /* vms path spec found. */
&& (basename[-1] != ':'))
*local_ptr++ = ':'; /* dev not in spec. take first dir */
*local_ptr++ = '['; /* Open the directory specification */
}
if (unixname == fullname) /* no vms dir spec. */
{
must_revert = 1;
if ((first_slash != 0) /* unix dir spec. */
&& (*unixname != '/') /* not beginning with '/' */
&& (*unixname != '.')) /* or './' or '../' */
*local_ptr++ = '.'; /* dir is local ! */
}
/* at this point we assume that we have the device spec, and (at least
the opening "[" for a directory specification. We may have directories
specified already.
If there are no other slashes then the filename will be
in the "root" directory. Otherwise, we need to add
directory specifications. */
if (index (unixname, '/') == 0)
{
/* if no directories specified yet and none are following. */
if (local_ptr[-1] == '[')
{
/* Just add "000000]" as the directory string */
strcpy (local_ptr, "000000]");
local_ptr += strlen (local_ptr);
check_filename_before_returning = 1; /* we might need to fool with this later */
}
}
else
{
/* As long as there are still subdirectories to add, do them. */
while (index (unixname, '/') != 0)
{
/* If this token is "." we can ignore it
if it's not at the beginning of a path. */
if ((unixname[0] == '.') && (unixname[1] == '/'))
{
/* remove it at beginning of path. */
if ( ((unixname == fullname) /* no device spec */
&& (fullname+2 != basename)) /* starts with ./ */
/* or */
|| ((basename[-1] == ':') /* device spec */
&& (unixname-1 == basename))) /* and ./ afterwards */
*local_ptr++ = '.'; /* make '[.' start of path. */
unixname += 2;
continue;
}
/* Add a subdirectory spec. Do not duplicate "." */
if ( local_ptr[-1] != '.'
&& local_ptr[-1] != '['
&& local_ptr[-1] != '<')
*local_ptr++ = '.';
/* If this is ".." then the spec becomes "-" */
if ( (unixname[0] == '.')
&& (unixname[1] == '.')
&& (unixname[2] == '/'))
{
/* Add "-" and skip the ".." */
if ((local_ptr[-1] == '.')
&& (local_ptr[-2] == '['))
local_ptr--; /* prevent [.- */
*local_ptr++ = '-';
unixname += 3;
continue;
}
/* Copy the subdirectory */
while (*unixname != '/')
*local_ptr++= *unixname++;
unixname++; /* Skip the "/" */
}
/* Close the directory specification */
if (local_ptr[-1] == '.') /* no trailing periods */
local_ptr--;
if (local_ptr[-1] == '[') /* no dir needed */
local_ptr--;
else
*local_ptr++ = ']';
}
/* Now add the filename. */
while (*unixname)
*local_ptr++ = *unixname++;
*local_ptr = 0;
/* Now append it to the original VMS spec. */
strcpy ((must_revert==1)?fullname:basename, Local);
/* If we put a [000000] in the filename, try to open it first. If this fails,
remove the [000000], and return that name. This provides flexibility
to the user in that they can use both rooted and non-rooted logical names
to point to the location of the file. */
if (check_filename_before_returning)
{
f = open (fullname, O_RDONLY, 0666);
if (f >= 0)
{
/* The file name is OK as it is, so return it as is. */
close (f);
return 1;
}
/* The filename did not work. Try to remove the [000000] from the name,
and return it. */
basename = index (fullname, '[');
local_ptr = index (fullname, ']') + 1;
strcpy (basename, local_ptr); /* this gets rid of it */
}
return 1;
}
#endif /* VMS */