aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/files.cc5
-rw-r--r--libcpp/init.cc12
-rw-r--r--libcpp/internal.h2
3 files changed, 8 insertions, 11 deletions
diff --git a/libcpp/files.cc b/libcpp/files.cc
index c63f582..840dffc 100644
--- a/libcpp/files.cc
+++ b/libcpp/files.cc
@@ -189,9 +189,6 @@ static bool read_file_guts (cpp_reader *pfile, _cpp_file *file,
location_t loc, const char *input_charset);
static bool read_file (cpp_reader *pfile, _cpp_file *file,
location_t loc);
-static struct cpp_dir *search_path_head (cpp_reader *, const char *fname,
- int angle_brackets, enum include_type,
- bool suppress_diagnostic = false);
static const char *dir_name_of_file (_cpp_file *file);
static void open_file_failed (cpp_reader *pfile, _cpp_file *file, int,
location_t);
@@ -1081,7 +1078,7 @@ _cpp_mark_file_once_only (cpp_reader *pfile, _cpp_file *file)
/* Return the directory from which searching for FNAME should start,
considering the directive TYPE and ANGLE_BRACKETS. If there is
nothing left in the path, returns NULL. */
-static struct cpp_dir *
+struct cpp_dir *
search_path_head (cpp_reader *pfile, const char *fname, int angle_brackets,
enum include_type type, bool suppress_diagnostic)
{
diff --git a/libcpp/init.cc b/libcpp/init.cc
index 355e501..3ab120a 100644
--- a/libcpp/init.cc
+++ b/libcpp/init.cc
@@ -744,14 +744,12 @@ cpp_read_main_file (cpp_reader *pfile, const char *fname, bool injecting)
/* Set the default target (if there is none already). */
deps_add_default_target (deps, fname);
+ auto main_search = CPP_OPTION (pfile, main_search);
+ bool angle = main_search == CMS_system;
+ cpp_dir *start_dir = (main_search < CMS_user ? &pfile->no_search_path
+ : search_path_head (pfile, fname, angle, IT_CMDLINE));
pfile->main_file
- = _cpp_find_file (pfile, fname,
- CPP_OPTION (pfile, preprocessed) ? &pfile->no_search_path
- : CPP_OPTION (pfile, main_search) == CMS_user
- ? pfile->quote_include
- : CPP_OPTION (pfile, main_search) == CMS_system
- ? pfile->bracket_include : &pfile->no_search_path,
- /*angle=*/0, _cpp_FFK_NORMAL, 0);
+ = _cpp_find_file (pfile, fname, start_dir, angle, _cpp_FFK_NORMAL, 0);
if (_cpp_find_failed (pfile->main_file))
return NULL;
diff --git a/libcpp/internal.h b/libcpp/internal.h
index e65198e..d91acd6 100644
--- a/libcpp/internal.h
+++ b/libcpp/internal.h
@@ -766,6 +766,8 @@ extern _cpp_file *_cpp_find_file (cpp_reader *, const char *, cpp_dir *,
int angle, _cpp_find_file_kind, location_t);
extern bool _cpp_find_failed (_cpp_file *);
extern void _cpp_mark_file_once_only (cpp_reader *, struct _cpp_file *);
+extern cpp_dir *search_path_head (cpp_reader *, const char *, int,
+ include_type, bool = false);
extern const char *_cpp_find_header_unit (cpp_reader *, const char *file,
bool angle_p, location_t);
extern int _cpp_stack_embed (cpp_reader *, const char *, bool,