Commit Graph

117 Commits

Author SHA1 Message Date
Alexandre Oliva
8d75ad04d0 cppfiles.c (remove_component_p): Don't assume lstat/stat will keep errno unchanged on success.
* cppfiles.c (remove_component_p): Don't assume lstat/stat will
keep errno unchanged on success.

From-SVN: r42445
2001-05-22 11:57:21 +00:00
Neil Booth
f277b5e03b cppfiles.c (struct include_file): New member err_no.
* cppfiles.c (struct include_file): New member err_no.
	(find_or_create_entry): Set it.
	(open_file): Don't set fds to -2.  Instead, use err_no to
	remember previous errors, if any.

From-SVN: r41865
2001-05-05 11:12:19 +00:00
Neil Booth
f9200da26d configure.in: Add check for lstat.
* configure.in: Add check for lstat.
	* configure, config.in: Regenerate.
	* cppinit.c (append_include_chain): Make empty path ".".
        * cpplib.c (do_line): Don't simplify #line paths.
        * cppfiles.c (remove_component_p): New function.
	(find_or_create_entry): Acknowledge stat () errors during
	path simplification.
	(handle_missing_header): Don't simplify paths.
        (_cpp_simplify_pathname): Don't simplify VMS paths.  Return
        the empty path untouched.  Don't leave a trailing '/'.

From-SVN: r41148
2001-04-06 07:22:01 +00:00
Neil Booth
7c0927142c cppfiles.c (open_file): Fail directories silently, but with an errno of NOENT set.
* cppfiles.c (open_file): Fail directories silently, but
	with an errno of NOENT set.
	(read_include_file): Move the common exit code to the sole
	caller.  Return an int indicating success or failure.  Let
	open_file handle directories.
	(stack_include_file): If read_include_file fails,
	push a "null" buffer.

From-SVN: r41138
2001-04-06 05:21:36 +00:00
Alexandre Oliva
11bca3093b * cppfiles.c (stack_include_file): Use MAX of sysp.
From-SVN: r40536
2001-03-16 05:19:46 +00:00
Neil Booth
ba133c968c cpp.texi: Update documentation for -include and -imacros.
* cpp.texi: Update documentation for -include and -imacros.
	* cppfiles.c (struct include_file): Remove "defined" memeber.
	(find_or_create_entry): Make a copy of the file name, and
	simplify it.
	(open_file): Update to ensure we use the simplified filename.
	(stack_include_file): Don't set search_from.
	(cpp_included): Don't simplify the path name here.
	(find_include_file): New prototype.  Call search_from to
	get the start of the "" include chain.  Don't simplify the
	filenames here.
	(_cpp_execute_include): New prototype.  Move diagnostics to
	do_include_common.  Update.
	(_cpp_pop_file_buffer): Don't set defined.
	(search_from): New prototype.  Use the preprocessor's cwd
	for files included from the command line.
	(read_name_map): Don't simplify the pathname here.
	* cpphash.h (enum include_type): New.
	(struct buffer): Delete search from.  New search_cached.
	(_cpp_execute_include): Update prototype.
	* cppinit.c (do_includes): Use _cpp_execute_include.
	* cpplib.c (do_include_common): New function.
	(do_include, do_include_next, do_import): Use it.

From-SVN: r40486
2001-03-15 07:57:13 +00:00
Neil Booth
e7182666e6 cppfiles.c (stack_include_file): Only increase the include count if we actually process the file properly...
* cppfiles.c (stack_include_file): Only increase the include
	count if we actually process the file properly, as opposed
	to treating it as length zero.  Only call read_include_file
	if not DO_NOT_REREAD.  Handle the -H include file output
	here.
	(read_include_file): Remove now redundant DO_NOT_REREAD check.
	(cpp_included, find_include_file): Simplify pathnames after
	remapping them.  If remapping, don't use the remapped file
	name's buffer as our scratch buffer.
	(cpp_pop_file_buffer): Replace the multiple include macro
	only if it isn't yet set.
	(read_name_map): Simplify remapped names when reading in.
	(remap_filename): Move code to code path that uses it.
	(_cpp_simplify_pathname): Return the input pointer.
	* cpphash.h (_cpp_simplify_pathname): Update prototype.

From-SVN: r40467
2001-03-14 19:35:08 +00:00
Neil Booth
41947a54d2 cppfiles.c (NO_INCLUDE_PATH): New macro.
* cppfiles.c (NO_INCLUDE_PATH): New macro.
	(find_include_file): Decide here which part of the include
	chain to start the search.  Complain about an empty include
	chain in all cases apart from an abolsute file name.
	(_cpp_execute_include): Don't choose the search chain here.
	Don't call handle_missing_include in the case of an empty
	include chain.
	(_cpp_compare_file_date): Don't choose the search chain here.
	* cpplib.c (do_include_next): Move the in-main-file diagnostic
	here from _cpp_execute_include.  Behave like #include if
	we're in the main file.

From-SVN: r40445
2001-03-13 23:55:10 +00:00
Neil Booth
a36c54faba cppfiles.c: Update comments.
* cppfiles.c: Update comments.
	(destroy_include_file_node): Rename destroy_node.
	(find_or_create_entry): New function.
	(open_file, _cpp_fake_include): Use it.
	(handle_missing_header): New function, broken out of
	_cpp_execute include.  Don't segfault if there is no
	system or quoted path.
	(_cpp_execute_include): Use handle_missing_header.

From-SVN: r40423
2001-03-12 19:33:08 +00:00
Neil Booth
b6464a73f5 cppfiles.c (INCLUDE_LEN_FUDGE, ENOMEM): Delete.
* cppfiles.c (INCLUDE_LEN_FUDGE, ENOMEM): Delete.
	(cpp_included, find_include_file): Update.
	(_cpp_compare_file_date): Make else unconditional.

From-SVN: r40388
2001-03-11 14:54:56 +00:00
Neil Booth
2251fd7866 cppfiles.c (search_from): Use lbasename.
* cppfiles.c (search_from): Use lbasename.
	* mkdeps.c (deps_add_default_target): Use lbasename.

From-SVN: r40364
2001-03-10 10:43:52 +00:00
Neil Booth
04c8d9b90a * cppfiles.c (search_from): Special case the empty string.
From-SVN: r40236
2001-03-04 15:10:46 +00:00
Neil Booth
7868b4a252 cppfiles.c (_cpp_execute_include): Don't make a null-terminated copy of the filename.
* cppfiles.c (_cpp_execute_include): Don't make a null-terminated
	copy of the filename.  Don't use CPP_PREV_BUFFER.  Don't call
	strlen or strcpy; we already know the length.
	(_cpp_compare_file_date): Similarly.
	* cpphash.h (struct cpp_reader): Delete done_initialising.
	(CPP_PREV_BUFFER): Delete.
	* cppinit.c (cpp_start_read): Don't set done_initialising.
	* cpplex.c (parse_string): Guarantee null-termination.
	(_cpp_equiv_toklists): Remove.
	* cpplib.c (glue_header_name): Null-terminate.
	(do_line): Don't leak memory.
	* cpplib.h (BT_WEAK): Delete.
	* cppmain.c (cb_ident): Strings are now null-terminated.

From-SVN: r40233
2001-03-04 12:02:02 +00:00
Neil Booth
591e15a110 cppfiles.c (struct include_file): Update.
* cppfiles.c (struct include_file): Update.
        (stack_include_file): Use search_from.
        (cpp_included, find_include_file): Update.
        (cpp_execute_include): Update.  ptr->name may not be
        null terminated.  Use the new search_from member variable
        of cpp_buffer.
        (_cpp_compare_file_date): Similarly.
        (search_from): New function, similiar to actual_directory.
        (actual_directory): Delete.
        (remap_filename): Update.  loc->name may not be null terminated.
        (struct file_name_list): Rename search_path.  Update.
        * cpphash.h (struct cpp_buffer): Delete actual_dir.  New members
        search_from and dir.
        (struct cpp_reader): Remove actual_dirs.
        * cppinit.c (struct cpp_pending): Update for renamed objects.
        (append_include_chain, remove_dup_dir, remove_dup_dirs,
        merge_include_chains, cpp_destroy, cpp_start_read): Similarly.
        * cpplib.h (struct cpp_options): Similarly.

From-SVN: r40178
2001-03-02 07:35:12 +00:00
Neil Booth
373e217703 cppfiles.c: Update comments.
* cppfiles.c: Update comments.
        (_cpp_read_file): Don't check for NULL filenames any more.
        * cppinit.c (cpp_start_read): Don't do canonicalization of
        in_fname and out_fname.  Use the passed file name exclusively.
        (_cpp_handle_options): Don't treat "-" as a command line option,
        but as a normal filename.
        (_cpp_post_options): Canonicalize in_fname and out_fname.
        * cppmain.c (printer_init): Don't check out_fname for NULL.
        * c-lex.c (orig_filename): Rename cpp_filename for clarity.
        (init_c_lex): Update, and use "" to represent stdin to CPP.
        (yyparse): Update.

From-SVN: r39938
2001-02-21 07:29:56 +00:00
Neil Booth
51d0f328ba cppfiles.c (stack_include_file): Generate dependencies here, and manage include_count here too.
* cppfiles.c (stack_include_file): Generate dependencies
        here, and manage include_count here too.
        (PRINT_THIS_DEP): Delete.
        (_cpp_execute_include): Do not generate dependencies here,
        apart from the case of a missing header.  Do not manage
        include_count.
        (_cpp_read_file): Leave dependency generation to
        stack_include_file.

From-SVN: r39899
2001-02-19 19:50:21 +00:00
Neil Booth
e4a345f832 cppfiles.c (_cpp_make_system_header): Generate a file change callback.
* cppfiles.c (_cpp_make_system_header): Generate a file
        change callback.

From-SVN: r39749
2001-02-16 07:41:08 +00:00
Jakub Jelinek
7855db7cb8 cppfiles.c (_cpp_read_file): Add to dependencies if requested.
* cppfiles.c (_cpp_read_file): Add to dependencies if requested.
	* cppinit.c (cpp_start_read): Remove deps_add_dep call.
	* tradcpp.c (main): Add -imacros or -include'd dependencies
	for -M*.
	* cpp.texi (-M, -MM): Document -M -include behaviour.

From-SVN: r39240
2001-01-24 19:44:40 +01:00
Neil Booth
d6d52dd655 cppfiles.c (_cpp_fake_include): New function.
* cppfiles.c (_cpp_fake_include): New function.
        * cpphash.h (_cpp_fake_include): New.
        * cpplib.c (do_line): Call _cpp_fake_include when entering
        header files in preprocessed input.
        * cppmain.c (cb_pragma_implementation): Remove handling.
	(setup_callbacks): Don't register pragmas.

From-SVN: r38987
2001-01-13 18:39:26 +00:00
Neil Booth
05e8172427 [multiple changes]
2001-01-11  Neil Booth  <neil@daikokuya.demon.co.uk>

        * cppinit.c (cpp_start_read): If -fpreprocessed, ignore
	-D, -U and -A, and don't initialize the builtins.
	* cppmain.c (cb_define, cb_undef): Unconditionally process
	the callback.
	* tradcpp.c (main): Fix typo.

2000-01-11  Mark Elbrecht  <snowball3@bigfoot.com>

        * cppfiles.c (cpp_included, find_include_file, _cpp_execute_include)
          (read_name_map): Use IS_ABSOLUTE_PATH.
        * tradcpp.c (get_filename): Likewise.

From-SVN: r38925
2001-01-11 21:30:16 +00:00
Graham Stott
8e178c1d09 cppfiles.c (_cpp_execute_include): Move len initialisation after ptr is initialised.
* cppfiles.c (_cpp_execute_include): Move `len` initialisation
	after `ptr` is initialised.

From-SVN: r38826
2001-01-09 10:43:47 +00:00
Jakub Jelinek
c3843cea61 tradcpp.c (deps_file, [...]): New variables.
* tradcpp.c (deps_file, print_deps_missing_files): New variables.
	(main): Handle -MG, -MD, -MMD.  Bail out if -MG is given without -M
	or -MM.
	(do_include): Handle missing headers like cpp0.
	* cppfiles.c (_cpp_execute_include): Don't prefix absolute header
	paths with first include pathname.  Don't strcat to uninitialized
	string.

From-SVN: r38683
2001-01-04 18:26:12 +01:00
Neil Booth
eb1f4d9d28 c-lex.c: s/change_file/file_change.
* c-lex.c: s/change_file/file_change.
        * cpplib.h: Similarly.
        * cppmain.c: Similarly.
        * fix-header.c: Similarly.
        * cppfiles.c (stack_include_file): Pass the buffer location and
        size to cpp_push_buffer.  Generate the file_change callback,
        so that sysp is already set.
        * cpphash.h: Add _cpp_do_file_change.
        * cpplib.c (do_line): Set buffer->sysp directly. Generate the
        file_change callback after setting sysp.
        (_cpp_do_file_change): Handle FC_ENTER and the FC_RENAME exception
        here.
        (cpp_push_buffer): Don't generate a callback.  Clear sysp.
        (cpp_pop_buffer): Clean up logic.

From-SVN: r38357
2000-12-18 19:00:26 +00:00
Neil Booth
ad2a084dbd c-lex.c: Move main_input_filename handling to FC_ENTER.
* c-lex.c: Move main_input_filename handling to FC_ENTER. Clean up.
        * cpperror.c (print_containing_files): Get right line number.
        (print_location): Output column of 1 if 0.
        * cppfiles.c (stack_include_file): cpp_push_buffer handles
        the callback.
        * cpphash.h (_cpp_do_file_change): No longer external.
        * cpplib.c (do_file_change): Now local to cpplib.c.
        (do_line): Fake a buffer stack for preprocessed files.
        (cpp_push_buffer): Create a file_change callback.  Handle faked
        buffers.
        (cpp_pop_buffer): Similarly.
        * cpplib.h: BUF_FAKE: New buffer type.
        * cppmain.c: Update to handle correct file renaming where a
        #line is the first line of the main file, and produce only
        the renamed file, not the original file, as output.

From-SVN: r38319
2000-12-17 00:13:54 +00:00
Zack Weinberg
0eda43cee4 cppfiles.c (hack_vms_include_specification): Delete function (not used since 1998).
* cppfiles.c (hack_vms_include_specification): Delete function
	(not used since 1998).

From-SVN: r38268
2000-12-15 04:48:39 +00:00
Neil Booth
8767c8949a cppfiles.c (read_name_map): Return null if open () fails.
* cppfiles.c (read_name_map): Return null if open () fails.
        (remap_filename): Simplify logic.  Add ICE if it doesn't work
        as expected. Perform secondary lookup attempt on base filename
        only.

From-SVN: r38227
2000-12-13 19:20:14 +00:00
Neil Booth
0bda476066 cpperror.c (print_location): New function.
* cpperror.c (print_location): New function.
        (print_containing_files): Simplify.
        (_cpp_begin_message): Simplify and use print_location.
        * cppfiles.c (stack_include_file): Update.
        (_cpp_pop_file_buffer): Update.
        * cpphash.h (struct cpp_buffer): New members
        include_stack_listed and type.
        * cpplib.c (_cpp_handle_directive): Buffer->inc is not null.
        (run_directive): Take buffer type.  cpp_push_buffer cannot fail.
        (_cpp_do__Pragma, cpp_define, _cpp_define_builtin, cpp_undef,
        handle_assertion): Update.
        (cpp_push_buffer): Take a buffer type and file name.
        (cpp_pop_buffer): Update.  Clear include_stack_listed.
        * cpplib.h (input_stack_listing_current): Remove.
        (enum cpp_buffer_type): New.
        (cpp_push_buffer): New prototype.
        * cppmacro.c (builtin_macro): Simplify; buffer cannot be null.
        * fix-header.c (read_scan_file): Update.

From-SVN: r38186
2000-12-11 07:45:16 +00:00
Neil Booth
28e0f04034 cppfiles.c (NEVER_REREAD, [...]): Move from cpphash.h.
* cppfiles.c (NEVER_REREAD, DO_NOT_REREAD): Move from cpphash.h.
        * cpphash.h (NEVER_REREAD, DO_NOT_REREAD, ABSOLUTE_PATH): Delete.
        * cpplex.c (parse_identifier): Improve diagnostic.
        (_cpp_lex_token): Return unconditionally at the end of a directive.
        * cpplib.c (read_flag): Verify legality of each flag.
        (end_directive): Resotre pfile->skipping before skip_rest_of_line.
        (do_line): Use the new read_flag.
        * cppmacro.c (struct cpp_macro, parse_arg, replace_args,
        check_macro_redefinition, parse_params): Rename var_args to
        variadic.

From-SVN: r38150
2000-12-09 12:06:37 +00:00
Neil Booth
642ce43464 cppfiles.c (struct include_file): Move from cpphash.h.
* cppfiles.c (struct include_file): Move from cpphash.h.
        (_cpp_never_reread): New function.
        (open_file, read_include_file): Use it.
        (stack_include_file): Set the buffer's sysp according to the
        path in which the file was found.
        (find_include_file): Don't set sysp.
        (cpp_make_system_header, actual_directory): Update.
        (_cpp_execute_include): Do #include_next lookup handling here,
        not in cpplib.c.  Use _cpp_never_reread.
        * cpphash.h (struct_include_file): Remove.
        (struct cpp_buffer): New member sysp.
        (CPP_IN_SYSTEM_HEADER, _cpp_execute_include): Update.
        (_cpp_never_reread): New.
        * cpplib.c (read_line_number): Rename read_flag.  Rework slightly.
        (end_directive): Clear line_extension flag.
        (_cpp_handle_directive): Set line_extension flag for #number.
        (do_include_next): Handle path lookup in _cpp_execute_include.
        (do_line): Cleanup to use read_flag.  Don't allow flags in #line.
        (_cpp_do_file_change): Update.
        (do_pragma_once): Use cpp_never_reread.  Clean up.
        * cpplib.h (struct lexer_state): New member line_extension.

From-SVN: r38120
2000-12-07 23:17:56 +00:00
Neil Booth
9ba2e1ef80 c-common.c (parse_in): Make a cpp_reader *.
* c-common.c (parse_in): Make a cpp_reader *.
        * cppfiles.c (_cpp_fake_include): Remove.
        * cpphash.h: Similarly.
        * cpplib.c (do_line): Don't call _cpp_fake_include.  A valid
        #line always creates a callback; FC_RENAME if there are no
        #line flags.
        * fix-header.c (read_scan_file): cpp_push_buffer cannot fail.
        The first EOF must be our get_char buffer.

From-SVN: r38101
2000-12-07 07:14:42 +00:00
Neil Booth
3cf3593fad cppfiles.c (stack_include_file): Push zero-length buffers in case of failure.
* cppfiles.c (stack_include_file): Push zero-length buffers
        in case of failure.  Return void, as we don't fail any more.
        (read_include_file): Check for files we shouldn't re-read.
        Don't return an error code; errors are implied by marking the
        file NEVER_REREAD.
        (_cpp_execute_include): Move the recursion and in-macro checks
        here.  Update for stack_include_file not failing.
        * cpplib.c (cpp_push_buffer): Always succeed, since
        _cpp_execute_include performs the recursion check.  Tidy up.
        * cpplib.h (cpp_push_buffer): Update prototype.

From-SVN: r38057
2000-12-05 23:42:43 +00:00
Neil Booth
614c7d3716 cppfiles.c (cpp_make_system_header): Take 2 booleans, and operate on current buffer.
* cppfiles.c (cpp_make_system_header): Take 2 booleans,
        and operate on current buffer.
        (cpp_read_file): Rename _cpp_read_file.
        * cpplib.c (do_line, do_pragma_system_header): Update calls to
        cpp_make_system_header.
        * fix-header.c: Similarly.
        * cpphash.h (_cpp_read_file): Move from...
        * cpplib.h: ... here.
        * cppinit.c (do_includes, cpp_start_read): Update appropriately.

From-SVN: r37989
2000-12-04 07:32:04 +00:00
Neil Booth
27e2564ac8 c-lex.c (cb_enter_file, [...]): Combine into the new function cb_change_file.
* c-lex.c (cb_enter_file, cb_leave_file, cb_rename_file):
        Combine into the new function cb_change_file.
        (init_c_lex): Update.
        * cppfiles.c (stack_include_file): Use _cpp_do_file_change.
        (cpp_syshdr_flags): Delete.
        * cpphash.h (_cpp_do_file_change): New prototype.
        Move struct cpp_buffer here from...
        * cpplib.h (struct cpp_buffer): ... here.
        (enum cpp_fc_reason, struct cpp_file_loc,
        struct_cpp_file_change, change_file): New.
        (enter_file, leave_file, rename_file, cpp_syshdr_flags): Delete.
        * cpplib.c (do_line): Update for new cb_change_file callback.
        (_cpp_do_file_change): New function.
        (_cpp_pop_buffer): Update to use it.
        * cppmain.c (move_printer): Delete.
        (main): Set up single callback cb_change_file.
        (cb_enter_file, cb_leave_file, cb_rename_file): Delete.
        (cb_change_file): New.
        * fix-header.c (cur_file, cb_change_file): New.
        (recognized_function, read_scan_file): Update.
        * scan-decls.c (scan_decls): Update.
        * scan.h (recognized_function): Update prototype.

From-SVN: r37784
2000-11-27 08:00:04 +00:00
Nathan Sidwell
def3263a33 cppfiles.c (open_file): If already read, then don't reopen.
* cppfiles.c (open_file): If already read, then don't reopen.
	Immediately close an empty file.

From-SVN: r37227
2000-11-03 16:03:37 +00:00
Neil Booth
a5c3cccda4 cppfiles.c (stack_include_file): Check for stacked contexts here.
* cppfiles.c (stack_include_file): Check for stacked contexts
	here.
	* cpphash.h (_cpp_do__Pragma): New prototype.
	* cppinit.c (cpp_reader_init): Add _Pragma keyword to hash table.

	* cpplex.c (skip_escaped_newlines): Only process trigraphs and
	escaped newlines if !(buffer->from_stage3).
	(_cpp_lex_token): Warn about missing newlines iff
	!buffer->from_stage3.

	* cpplib.c (get__Pragma_string, destringize,
	_cpp_do__Pragma): New functions.
	(run_directive): Set output_line for _Pragma to avoid line
	markers in output.  Set from_stage3 and prevent macro expansion
	for _Pragma and command-line options.  Check buffer exhaustion.
	(cpp_push_buffer): Don't check for stacked macro contexts, as
	this is perfectly legitimate for _Pragma.  Move the check to
	stack_include_file instead. Set from_stage3 iff buffer is
	preprocessed input.

	* cpplib.h (struct cpp_buffer): Make warned_cplusplus_comments
	unsigned. New boolean from_stage3.
	(struct spec_nodes): Add n__Pragma.

	* cppmacro.c (enter_macro_context): Flip sense of return value.
	(_cpp_get_token): Handle _Pragma operator.

From-SVN: r37147
2000-10-30 22:29:00 +00:00
Neil Booth
93c80368d9 New macro expander.
2000-10-28  Neil Booth  <neilb@earthling.net>

	New macro expander.

	* cpplib.c (struct answer): New.
	(struct if_stack): Use cpp_lexer_pos rather than line and col.
	Rename cmacro mi_cmacro.
	(struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL,
	IN_I): New directive and flags.
	(skip_rest_of_line, check_eol, run_directive, glue_header_name,
	parse_answer, parse_assertion, find_answer): New functions.
	(parse_ifdef, detect_if_not_defined, validate_else): Remove.
	(lex_macro_node): New function to replace parse_ifdef and
	get_define_node.

	(_cpp_handle_directive): New function, combines _cpp_check_directive
	and _cpp_check_linemarker.

	(do_define, do_undef, parse_include, do_include, do_import,
	do_include_next, read_line_number, do_line, do_ident, do_pragma,
	do_pragma_once, do_pragma_poison, do_pragma_dependency):
	Update for new token getting interface.

	(do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional)
	: Update for new multiple-include optimisation technique.
	(do_elif): Don't forget to invalidate controlling macros.

	(unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update.
	(parse_assertion, parse_answer, find_answer, _cpp_test_assertion):
	Functions to handle assertions with the new token interface.
	(do_assert, do_unassert): Use them.

	(cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert):
	Use run_directive.

	(_cpp_init_stacks): Register directive names.  Don't register special
	nodes.

	* cpperror.c (print_containing_files, _cpp_begin_message): Update to
	new position recording regime.
	(cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning,
	cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
	cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes.
	(cpp_type2name): Move to cpplex.c.

	* cppexp.c (parse_charconst): spec_nodes is no longer a pointer.
	(parse_defined): Update to handle new multiple include optimisation
	method.  Remove poisoned identifier warning.
	(parse_assertion, TYPE_NAME): Delete.
	(lex): Update for multiple include optimisation, removal of
	CPP_DEFINED, to use _cpp_test_assertion for assertions and
	cpp_token_as_text.
	(_cpp_parse_expr): Update for MI optimisation, and to use op_as_text.
	(op_as_text): New function, to wrap cpp_token_as_text.

	* cppfiles.c (stack_include_file, _cpp_pop_file_buffer):
	Update for MI optimisation.
	(_cpp_execute_include): Take a token rather than 3 arguments.  Fix
	segfault on diagnostic.
	(_cpp_compare_file_date): Take a token rather than 3 args.
	(cpp_read_file): Work correctly for zero-length files.

	* cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename
	_cpp_init_hashtable and _cpp_cleanup_hashtable.
	(cpp_lookup): Place identifiers at front of identifier pool
	for _cpp_lookup_with_hash.
	(_cpp_lookup_with_hash): Require identifiers to be at the front of
	the identifier pool.  Commit the memory if not already in the
	hash table.

	* cppinit.c (cpp_reader_init): Move cpp_init_completed test to top.
	Initialise various members of cpp_reader, memory pools, and the
	special nodes.
	(cpp_printer_init): Delete.
	(cpp_cleanup): Update.
	(struct builtin, builtin_array, initialize_builtins): Update for new
	hashnode definition and builtin handling.
	(cpp_start_read, cpp_finish): Don't take or initialise a
	printer.  Update.

	* cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL,
	PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE,
	T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL,
	T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete.
	(struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos,
	struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind,
	NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos,
	struct toklist, struct cpp_context, struct specnodes,
	TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED,
	NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION,
	enum builtin_type, cpp_can_paste): New.
	(struct cpp_token): Delete line and col members.
	(struct cpp_buffer): New member output_lineno.
	(struct lexer_state): Delete indented, in_lex_line, seen_dot.
	Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args.
	(struct cpp_reader): New members lexer_pos, macro_pos, directive_pos,
	ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool,
	base_context, context, directive, mi_state, mi_if_not_defined,
	mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused,
	mlstring_pos, macro_buffer, macro_buffer_len.
	Delete members mls_line, mls_column, token_list, potential_control_macro,
	temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token,
	context_cap, cur_context, no_expand_level, paste_level, contexts, args,
	save_parameter_spellings, need_newline, .
	Change type of date, time and spec_nodes members.
	Change prototypes for include and ident callbacks.
	(struct cpp_hashnode): Change type of name.  Remove union members
	expansion and code.  Add members macro, operator and builtin.

	(cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read,
	cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line,
	cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead,
	cpp_stop_lookahead): New prototypes.
	(cpp_printer_init, cpp_dump_definition): Delete prototypes.

	(U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs):
	Move from cpphash.h.

	* cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr,
	ufputs): Move to cpplib.h.
	(enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL,
	TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION,
	COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler,
	struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens,
	_cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist,
	_cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space,
	_cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive,
	_cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name,
	_cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker,
	_cpp_parse_assertion, _cpp_find_answer): Delete.
	(VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE,
	POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool,
	_cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk,
	_cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion,
	_cpp_handle_directive, DSC): New.
	(struct include_file): New member defined.

	(DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include,
	_cpp_compare_file_date): Update.
	(_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New.
	(_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable,
	_cpp_cleanup_hashtable.

	* Makefile.in: Remove cppoutput.c.

	* cppoutput.c: Delete

	* fixheader.c (read_scan_file): Update for new cpp_get_token
	prototype.
	(recognized_function): New argument LINE.

	* scan-decls.c (skip_to_closing_brace, scan_decls): Update for
	new cpp_get_token prototype.

	* scan.h (recognized_function): Update prototype.

	* po/POTFILES.in: Remove cppoutput.c.

From-SVN: r37098
2000-10-28 17:59:06 +00:00
Neil Booth
2047e26f26 cppfiles.c (lookup_include_file): Rename to open_file.
* cppfiles.c (lookup_include_file): Rename to open_file.
	Always create a splay tree value, even on syscall failures.
	Negative entries indicated by fd == -2.
	Re-open files closed in the meantime.
	(_cpp_fake_include): Create a negative splay tree entry.
	(find_include_file, cpp_read_file): Update for function name
	change.
	* gcc.gd/cpp/mi4.c: Testcase.

From-SVN: r36564
2000-09-21 18:01:22 +00:00
Neil Booth
6f3d20a022 cppfiles.c (read_include_file): Take no special action for zero-length files.
* cppfiles.c (read_include_file): Take no special action for
        zero-length files.

From-SVN: r36539
2000-09-19 17:28:46 +00:00
Laurynas Biveinis
ae0f4dee02 cppfiles.c (purge_cache): use munmap() only if MMAP_THRESHOLD defined.
* cppfiles.c (purge_cache): use munmap() only if MMAP_THRESHOLD
	 defined.
	(read_include_file): Ensure inc->mmaped is initialized.

From-SVN: r36459
2000-09-16 18:17:53 +00:00
Richard Henderson
6f84c9bdaa * cppiles.c (purge_cache): Use PTR not caddr_t.
From-SVN: r36458
2000-09-16 10:48:10 -07:00
Zack Weinberg
a58d32c208 cppfiles.c: Move all default-#defines to top of file.
* cppfiles.c: Move all default-#defines to top of file.
	(open_include_file): Replace by lookup_include_file.
	(read_with_read, read_file): Merged into read_include_file.
	(stack_include_file, purge_cache): New functions.
	(close_cached_fd): Delete.
	(lookup_include_file, read_include_file, _cpp_pop_file_buffer):
	Cache the in-memory buffer, not the file descriptor.

	* cpphash.h (struct include_file): Add buffer, st, refcnt,
	mapped fields.
	(xcnew): New utility macro.
	(DO_NOT_REREAD, NEVER_REREAD): Move up by struct include_file.
	* cpplib.h (struct cpp_buffer): Remove mapped field.

	* cpplex.c (parse_string): Accept backslash space newline as a
	line continuation.
	(lex_line): Likewise.
	(_cpp_get_token): Remove hard limit on macro nesting.

testsuite:
	* gcc.dg/cpp/backslash.c: New test.

From-SVN: r36347
2000-09-12 03:42:30 +00:00
Zack Weinberg
3d7428b8f6 *** empty log message ***
From-SVN: r35960
2000-08-24 22:18:53 +00:00
Greg McGary
87ae0c74eb cppfiles.c (actual_directory): Don't write beyond `dir' when it contains "".
* cppfiles.c (actual_directory): Don't write beyond `dir'
	when it contains "".
	* real.c (asctoeg): Stay within bounds of etens[][].

From-SVN: r35944
2000-08-24 20:04:10 +00:00
Zack Weinberg
58fea6afd9 cpperror.c (v_message): Split into _cpp_begin_message and v_message macro.
* cpperror.c (v_message): Split into _cpp_begin_message and
	v_message macro.  All callers updated.
	(_cpp_begin_message): Do inhibit_errors/inhibit_warnings
	checks here.

	* cppfiles.c (cpp_syshdr_flags): New function.
	(read_include_file): Don't call cpp_output_tokens.  Call
	enter_file hook.
	* cppinit.c (dump_macros_helper): Moved to cppmain.c.
	(cpp_reader_init): Don't initialize token_buffer.  Call
	_cpp_init_internal_pragmas.
	(cpp_cleanup): Don't clear token_buffer.
	(cpp_start_read): Don't worry about output from -D processing.
	Don't call cpp_output_tokens.
	(cpp_finish): Don't dump macros here.  Don't call
	cpp_output_tokens.
	* cppmacro.c (_cpp_dump_definition): Rename
	cpp_dump_definition.  Write directly to a FILE *.
	(dump_funlike_macro): Delete.
	(dump_macro_args): New.

	* cpplex.c (TOKEN_LEN): Convert to inline function.
	(_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens,
	cpp_scan_line, _cpp_dump_list): Delete.
	(cpp_printf, cpp_output_list): New.
	(output_line_command): Don't worry about entering or leaving files.
	(cpp_scan_buffer): Just output each token as we hit it.
	(process_directive): Don't call cpp_output_tokens.
	(_cpp_glue_header_name): Don't use token_buffer.
	(output_token, dump_param_spelling): Write directly to a FILE *.

	* cpplib.c (pass_thru_directive, dump_macro_name,
	pragma_dispatch, do_pragma_gcc): Delete.
	(do_define, do_undef, parse_include, do_line, do_ident, do_pragma,
	do_pragma_poison, cpp_pop_buffer): Call the appropriate hook
	functions.
	(do_error, do_warning, pragma_dependency): Call
	_cpp_begin_message, then cpp_output_list.
	(cpp_register_pragma, cpp_register_pragma_space,
	_cpp_init_internal_pragmas): New.
	(do_pragma): Walk the pragmas table here.
	(do_pragma_once, do_pragma_poison, do_pragma_system_header,
	do_pragma_dependency): Return void.
	(do_pragma_implementation): Moved to cppmain.c.

	* cpplib.h: Update prototypes.
	 (struct cpp_reader): Remove printer, token_buffer,
	token_buffer_size, and limit.  Add struct cb, and pragmas.
	(struct cpp_printer): Remove last_id and written.
	(CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN,
	CPP_ADJUST_WRITTEN): Delete.
	* cpphash.h: Update prototypes.
	(ufputs): New wrapper.

	* cppmain.c (cb_define, cb_undef, cb_include, cb_ident,
	cb_enter_file, cb_leave_file, cb_def_pragma): New functions.
	(main): Set up callbacks.  Register #pragma implementation.
	Dump macros from here.

From-SVN: r35415
2000-08-02 01:13:45 +00:00
Laurynas Biveinis
4b5882417e cppfiles.c (read_name_map): Set map_list_ptr->map_list_map to NULL.
2000-07-16  Laurynas Biveinis  <lauras@softhome.net>

	* cppfiles.c (read_name_map): Set map_list_ptr->map_list_map to NULL.

From-SVN: r35065
2000-07-16 21:22:19 +00:00
Zack Weinberg
f9a0e96c17 cppexp.c, [...]: Eradicate all traces of code dependent on traditional, lang_chill, or lang_fortran.
* cppexp.c, cpphash.c, cpphash.h, cppinit.c, cpplex.c,
	cpplib.c, cpplib.h: Eradicate all traces of code dependent on
	traditional, lang_chill, or lang_fortran.

	* cppfiles.c: #undef strcmp to suppress warning about macros
	used without arguments.
	(_cpp_execute_include): Use f, not fname, in "No include path"
	error.
	(_cpp_pop_file_buffer): New function.
	* cpplib.c: Don't include <sys/mman.h>.
	(cpp_push_buffer): Set line_base and lineno in new buffer.
	(cpp_pop_buffer): Use _cpp_pop_file_buffer.

	* cpplex.c: Move all prototypes and structure declarations to the
	top of the file.  Properly parenthesise some macro arguments.
	(cpp_scan_line): New function.
	(special_symbol [case T_INCLUDE_DEPTH]): Use pfile->include_depth,
	don't need to walk up the stack counting.

From-SVN: r35003
2000-07-13 02:32:41 +00:00
Zack Weinberg
c71f835b25 cpplex.c: Don't include sys/mman.h.
toplevel:
	* cpplex.c: Don't include sys/mman.h.
	(cpp_push_buffer, cpp_pop_buffer): Moved to cpplib.c.

	* cpplib.c: Include sys/mman.h and obstack.h.
	(cpp_push_buffer): Moved from cpplex.c; allocate buffers on an
	obstack.
	(cpp_pop_buffer): Moved from cpplex.c; free buffers from an obstack.
	(_cpp_unwind_if_stack): Now static, unwind_if_stack.  Don't
	bother freeing if stack entries (they will be freed with their buffer).
	(do_endif): Free if stack entries from the buffer obstack.
	(push_conditional): Allocate if stack entries from the buffer obstack.

	(find_answer): Rename to _cpp_find_answer.
	(do_assert, do_unassert): Update.

	* cpphash.h: Update prototypes.
	(xobnew): New convenience macro.
	* cpplib.h (struct cpp_reader): Add hash_ob and buffer_ob fields.
	Update comments.
	(struct cpp_hashnode): Remove disabled field.

	* cppinit.c: Don't include hashtab.h or splay-tree.h.
	(report_missing_guard): Moved to cppfiles.c.
	(cpp_reader_init): Call cpp_init_stacks, cpp_init_macros,
	cpp_init_includes.
	(cpp_cleanup): Call cpp_cleanup_stacks, cpp_cleanup_macros,
	cpp_cleanup_includes.  Don't destroy hashtab or
	all_include_files here.
	(cpp_finish): Use _cpp_report_missing_guards.

	* cppfiles.c (report_missing_guard): Moved from cppinit.c.
	(_cpp_init_include_table): Rename _cpp_init_includes.
	(_cpp_cleanup_includes, _cpp_report_missing_guards): New.

	* cppexp.c (parse_assertion): Update for new name of
	find_answer.

	* Makefile.in (cpplib.o, cpphash.o, cppinit.o): Update deps.

	* cpplib.c (do_ident): s/VSPACE/EOF/

testsuite:
	* gcc.dg/cpp/ident.c: New test.

From-SVN: r34870
2000-07-05 05:33:57 +00:00
Zack Weinberg
041c31944c top level:
2000-07-03  Zack Weinberg  <zack@wolery.cumb.org>

	* fix-header.c (struct partial_proto): Remove unnecessary fields.
	(recognized_extern, recognized_function, read_scan_file):
	Update for new scheme.
	(check_protection): It's still a multiple include guard even
	if it doesn't always trigger.
	* scan-decls.c (skip_to_closing_brace, scan_decls): Update for
	new scheme.
	* scan.h: Declare struct cpp_token.  Update prototypes.

2000-07-03  Neil Booth  <neilb@earthling.net>
	    Zack Weinberg  <zack@wolery.cumb.org>

	Complete overhaul of the lexer and macro expander.

	* cpphash.c (object_defn, funct_defn, push_macro_expansion,
	arg, arglist, argdata, reflist, collect_objlike_expansion,
	collect_funlike_expansion, collect_params,
	warn_trad_stringify, trad_stringify, duplicate_arg_p, add_pat,
	unsafe_chars, macarg, compare_defs, special_symbol,
	scan_arguments, stringify, funlike_macroexpand,
	_cpp_quote_string, monthnames): Delete.
	(cpp_lookup, _cpp_free_definition, dump_funlike_macro,
	_cpp_create_definition, _cpp_dump_definition,
	dump_hash_helper): Adjust.
	(find_param, count_params, parse_define, var_args_str,
	check_macro_redefinition, save_expansion): New.

	* cpplex.c (skip_block_comment, skip_line_comment, parse_name,
        parse_string, output_line_command, trigraph_replace,
        lex_line, cpp_push_buffer, cpp_pop_buffer, cpp_output_tokens,
        cpp_scan_buffer_nooutput, cpp_scan_buffer, cpp_free_toklist,
        cpp_idcmp, _cpp_get_directive_token, _cpp_init_input_buffer,
	_cpp_skip_rest_of_line): Modify.

        (maybe_macroexpand, skip_comment, copy_comment, skip_string,
	find_position, null_warning, bump_column, expand_name_space,
	pedantic_whitespace, _cpp_output_list, _cpp_slice_toklist,
	_cpp_squeeze_toklist, _cpp_scan_until, _cpp_skip_hspace,
	_cpp_parse_name, _cpp_lex_token, cpp_get_non_space_token,
	_cpp_prescan): Delete.

	(dump_param_spelling, process_directive, lex_next,
        is_macro_disabled, stringify_arg, expand_context_stack,
        output_token, make_string_token, alloc_number_token,
        special_symbol, duplicate_token, maybe_paste_with_next,
        can_paste, prevent_macro_expansion, restore_macro_expansion,
        get_temp_token, release_temp_tokens, quote_string,
        token_names, token_spellings, _cpp_expand_name_space,
        _cpp_glue_header_name, _cpp_reserve_name_space,
        digraph_spellings, trigraph_ok, skip_whitespace, save_comment,
        placemarker_token, eof_token, cpp_context, macro_args,
        get_raw_token, parse_arg, parse_args, save_token,
        push_arg_context, push_macro_context, pop_context,
        do_pop_context, free_macro_args, _cpp_get_line,
        _cpp_run_directive): New.

	* cpplib.c (validate_else, parse_include, push_conditional,
	pass_thru_directive, read_line_number, parse_ifdef,
	detect_if_not_defined, _cpp_check_directive, do_define,
	do_undef, do_include, do_import, do_include_next, do_error,
	do_warning, do_ident, do_pragma, pragma_dispatch, gcc_pragmas,
	top_pragmas, do_pragma_gcc, do_pragma_implementation,
	do_pragma_poison, do_pragma_system_header,
	do_pragma_dependency, do_sccs, do_ifdef, do_ifndef, do_else,
	dl_elif, do_endif, _cpp_unwind_if_stack, do_assert,
	do_unassert, cpp_define, cpp_undef, cpp_assert, cpp_unassert,
	cpp_defined): Update for new scheme.
	(strtoul_for_line, get_define_node, dump_macro_name,
	_cpp_check_linemarker, _cpp_parse_assertion): New.
	(_cpp_handle_directive, do_pragma_default): Delete.

	* cpphash.h (struct predicate): Now struct answer.
	(enum spell_type, struct token_spelling, struct directive,
	directive_handler): New.
	Update prototypes.  Remove unused macros.
	* cpplib.h: Update prototypes.  Remove unused macros,
	structure definitions, and fields.

	* cpperror.c (print_containing_files, v_message): Adjust.
	* cppexp.c (parse_assertion, lex, parse_escape,
	_cpp_parse_expr): Adjust.
	* cppfiles.c (open_include_file, _cpp_execute_include,
	_cpp_compare_file_date, cpp_read_file, read_include_file):
	Adjust.
	* cppinit.c (dump_special_to_buffer): Delete.
	(append_include_chain, merge_include_chains, cpp_reader_init,
	cpp_cleanup, initialize_builtins, builtin_array, cpp_start_read,
	cpp_finish, handle_option, print_help): Adjust.
	* cppmain.c (main): Adjust.

testsuite:
2000-07-03  Zack Weinberg  <zack@wolery.cumb.org>

	* testsuite/gcc.dg/cpp/19951025-1.c: Adjust regexps.
	* testsuite/gcc.dg/cpp/19990703-1.c: Likewise.
	* testsuite/gcc.dg/cpp/20000625-1.c: Likewise.
	* testsuite/gcc.dg/cpp/20000625-2.c: Likewise.

	* testsuite/gcc.dg/cpp/macro1.c,
	testsuite/gcc.dg/cpp/paste1.c, testsuite/gcc.dg/cpp/paste2.c,
	testsuite/gcc.dg/cpp/paste3.c, testsuite/gcc.dg/cpp/paste4.c,
	testsuite/gcc.dg/cpp/strify1.c,
	testsuite/gcc.dg/cpp/strify2.c: New tests.

From-SVN: r34859
2000-07-04 01:58:21 +00:00
Jakub Jelinek
fb753f88e9 cpplib.h (struct cpp_reader): New field include_depth.
* cpplib.h (struct cpp_reader): New field include_depth.
	(struct cpp_printer): Rename last_bsd to last_id.
	* cppfiles.c (read_include_file): Bump include_depth.
	* cpplex.c (cpp_pop_buffer): Decrement include_depth.
	(output_line_command): Output correct #line if a header
	is including itself and is not protected against multiple inclusion.
	Use include_depth instead of buffer_stack_depth, last_id instead of
	last_bsd.
	* cppinit.c (cpp_start_read): Initialize last_id instead of
	last_bsd.

From-SVN: r34831
2000-07-02 10:56:57 +02:00
Nathan Sidwell
f3f751adcb cpp.texi: Document #pragma GCC dependency
* cpp.texi: Document #pragma GCC dependency
	* cppfiles.c (open_include_file): Set date to unknown.
	(_cpp_compare_file_date): New function.
	(read_include_file): Set file date.
	* cpphash.h (struct include_file): Add date member.
	(_cpp_compare_file_date): Prototype.
	* cpplib.c (parse_include): Add trail parameter. Adjust.
	(do_include): Adjust parse_include call.
	(do_import): Likewise.
	(do_include_next): Likewise.
	(gcc_pragmas): Add dependency pragma.
	(do_pragma_dependancy): New pragma.

From-SVN: r34808
2000-06-30 09:47:49 +00:00