From 7dc0da379b2021bd135e46559b1712bcc35257bc Mon Sep 17 00:00:00 2001 From: Josh Yelon Date: Thu, 21 Jun 2007 23:46:25 +0000 Subject: [PATCH] Corrected include-file search-path --- dtool/src/cppparser/cppPreprocessor.cxx | 30 ++++++++++++++++++------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/dtool/src/cppparser/cppPreprocessor.cxx b/dtool/src/cppparser/cppPreprocessor.cxx index 83b6381fde..018d457d4e 100644 --- a/dtool/src/cppparser/cppPreprocessor.cxx +++ b/dtool/src/cppparser/cppPreprocessor.cxx @@ -1394,22 +1394,36 @@ handle_include_directive(const string &args, int first_line, CPPFile::Source source = CPPFile::S_none; if (okflag) { - if (!angle_quotes) { - found_file = filename.exists(); + + found_file = false; + + if (!angle_quotes && !found_file && filename.exists()) { + found_file = true; source = CPPFile::S_local; } + + if (!angle_quotes && !found_file) { + DSearchPath local_search_path(Filename(get_file()._filename.get_dirname())); + + // Now look for it in the same directory as the includer. + if (!found_file && filename.resolve_filename(local_search_path)) { + found_file = true; + source = CPPFile::S_alternate; + } + } - // Now look for it on the include path. + // Now look for it on the primary include path. + if (!angle_quotes && !found_file && filename.resolve_filename(_include_path)) { + found_file = true; + source = CPPFile::S_alternate; + } + + // Now look for it on the system include path. if (!found_file && filename.resolve_filename(_system_include_path)) { found_file = true; source = CPPFile::S_system; } - if (!found_file && filename.resolve_filename(_include_path)) { - found_file = true; - source = CPPFile::S_alternate; - } - if (!found_file) { warning("Cannot find " + filename.get_fullpath(), first_line, first_col, first_file);