diff options
author | Per Bothner <per@bothner.com> | 2004-02-04 22:52:26 -0800 |
---|---|---|
committer | Per Bothner <bothner@gcc.gnu.org> | 2004-02-04 22:52:26 -0800 |
commit | 8e9ea4d72c8f0909db7eda507805a941d48348a2 (patch) | |
tree | a8cb79fee4ffa92207a17795cfa3750745b8d001 /gcc/c-ppoutput.c | |
parent | 5384443a5f76667b12ccde8451b5a59faefb36da (diff) | |
download | gcc-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/c-ppoutput.c')
-rw-r--r-- | gcc/c-ppoutput.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/c-ppoutput.c b/gcc/c-ppoutput.c index 22e595f..f3f8f81 100644 --- a/gcc/c-ppoutput.c +++ b/gcc/c-ppoutput.c @@ -334,6 +334,22 @@ cb_include (cpp_reader *pfile ATTRIBUTE_UNUSED, fileline line, print.line++; } +/* Callback called when -fworking-director and -E to emit working + diretory in cpp output file. */ + +void +pp_dir_change (cpp_reader *pfile ATTRIBUTE_UNUSED, const char *dir) +{ + size_t to_file_len = strlen (dir); + unsigned char *to_file_quoted = alloca (to_file_len * 4 + 1); + unsigned char *p; + + /* cpp_quote_string does not nul-terminate, so we have to do it ourselves. */ + p = cpp_quote_string (to_file_quoted, (unsigned char *) dir, to_file_len); + *p = '\0'; + fprintf (print.outf, "# 1 \"%s//\"\n", to_file_quoted); +} + /* The file name, line number or system header flags have changed, as described in MAP. From this point on, the old print.map might be pointing to freed memory, and so must not be dereferenced. */ |