aboutsummaryrefslogtreecommitdiff
path: root/gcc/cppinit.c
diff options
context:
space:
mode:
authorPer Bothner <per@bothner.com>2004-02-04 22:52:26 -0800
committerPer Bothner <bothner@gcc.gnu.org>2004-02-04 22:52:26 -0800
commit8e9ea4d72c8f0909db7eda507805a941d48348a2 (patch)
treea8cb79fee4ffa92207a17795cfa3750745b8d001 /gcc/cppinit.c
parent5384443a5f76667b12ccde8451b5a59faefb36da (diff)
downloadgcc-8e9ea4d72c8f0909db7eda507805a941d48348a2.zip
gcc-8e9ea4d72c8f0909db7eda507805a941d48348a2.tar.gz
gcc-8e9ea4d72c8f0909db7eda507805a941d48348a2.tar.bz2
Partially revert/redo 2003-10-01 change; fix -fworking-directory.
* c-ppoutput.c (pp_dir_change): New function. * c-common.h (pp_dir_change): New declaration. * cpplib.h (struct cpp_options): Remove working_directory field. * cppinit.c (cpp_find_main_file, cpp_push_main_file): Merge back to (cpp_read_main_file): as before 10-01. Call _cpp_stack_file. Don't handle -fworking_directory here, but in c_common_post_options. (read_original_directory): Don't back up when done. Don't clear no-longer used working_directory flag. * cpplib.h: Update declarations to match. * c-lex.c (cb_dir_change): Move to c-opts.c. (init_c_lex): Don't set dir_change callback here, since we want to set it even if flag_preprocess_only. * c-opts.c (cb_dir_change): Function moved from c-lex.c. (c_common_post_options): Set dir_change callback. Call pp_dir_change if approporiate. (finish_options): Don't call cpp_find_main_file here. Hence remove unneeded parameter and result. Do LC_RENAME for <built-in>. (c_common_post_options): Call cpp_read_main_file here instead. (c_common_init): Update accordingly. (push_command_line_include): Don't cpp_push_main_file. Do LC_RENAME rather than LC_LEASE to get back to main file. Compared to pre-10-01 version, inline cpp_rename_to_main_file. (c_common_parse_file): Call cpp_read_main_file for subsequent main files, but call finish_options for all files. * c-opts.c (sanitize_cpp_opts): Don't set cpp_opts->working_directory. * fix-header.c (read_scan_file): Call cpp_read_main_file instead of cpp_find_main_file + cpp_push_main_file. * c-lex.c (fe_file_change): Don't set main_input_filename here. * opts.c (handle_options): Only set main_input_filename first time. From-SVN: r77303
Diffstat (limited to 'gcc/cppinit.c')
-rw-r--r--gcc/cppinit.c46
1 files changed, 10 insertions, 36 deletions
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
index d6509fd..0fc9c68 100644
--- a/gcc/cppinit.c
+++ b/gcc/cppinit.c
@@ -453,9 +453,10 @@ cpp_post_options (cpp_reader *pfile)
}
/* Setup for processing input from the file named FNAME, or stdin if
- it is the empty string. Returns true if the file was found. */
-bool
-cpp_find_main_file (cpp_reader *pfile, const char *fname)
+ it is the empty string. Return the original filename
+ on success (e.g. foo.i->foo.c), or NULL on failure. */
+const char *
+cpp_read_main_file (cpp_reader *pfile, const char *fname)
{
if (CPP_OPTION (pfile, deps.style) != DEPS_NONE)
{
@@ -471,37 +472,16 @@ cpp_find_main_file (cpp_reader *pfile, const char *fname)
if (_cpp_find_failed (pfile->main_file))
return false;
- if (CPP_OPTION (pfile, working_directory))
- {
- const char *dir = getpwd ();
- char *dir_with_slashes = alloca (strlen (dir) + 3);
-
- memcpy (dir_with_slashes, dir, strlen (dir));
- memcpy (dir_with_slashes + strlen (dir), "//", 3);
-
- if (pfile->cb.dir_change)
- pfile->cb.dir_change (pfile, dir);
- }
- return true;
-}
-
-/* This function reads the file, but does not start preprocessing.
- This will generate at least one file change callback, and possibly
- a line change callback. */
-void
-cpp_push_main_file (cpp_reader *pfile)
-{
_cpp_stack_file (pfile, pfile->main_file, false);
/* For foo.i, read the original filename foo.c now, for the benefit
of the front ends. */
if (CPP_OPTION (pfile, preprocessed))
- read_original_filename (pfile);
-
- /* Set this here so the client can change the option if it wishes,
- and after stacking the main file so we don't trace the main
- file. */
- pfile->line_table->trace_includes = CPP_OPTION (pfile, print_include_names);
+ {
+ read_original_filename (pfile);
+ fname = pfile->map->to_file;
+ }
+ return fname;
}
/* For preprocessed files, if the first tokens are of the form # NUM.
@@ -579,13 +559,7 @@ read_original_directory (cpp_reader *pfile)
debugdir[token->val.str.len - 4] = '\0';
pfile->cb.dir_change (pfile, debugdir);
- }
-
- /* We want to process the fake line changes as regular changes, to
- get them output. */
- _cpp_backup_tokens (pfile, 3);
-
- CPP_OPTION (pfile, working_directory) = false;
+ }
}
/* This is called at the end of preprocessing. It pops the last