From 1e7c8513c3563ac445ecdd67b32e2ffd49ae8e13 Mon Sep 17 00:00:00 2001 From: Josh Yelon Date: Wed, 27 Jun 2007 23:57:19 +0000 Subject: [PATCH] Interrogate include-path alterations --- dtool/src/cppparser/cppPreprocessor.cxx | 35 ++++++++++++++----------- dtool/src/cppparser/cppPreprocessor.h | 7 ++--- dtool/src/interrogate/interrogate.cxx | 7 +++-- dtool/src/interrogate/parse_file.cxx | 7 +++-- 4 files changed, 34 insertions(+), 22 deletions(-) diff --git a/dtool/src/cppparser/cppPreprocessor.cxx b/dtool/src/cppparser/cppPreprocessor.cxx index f4e5d3f688..4907233abc 100644 --- a/dtool/src/cppparser/cppPreprocessor.cxx +++ b/dtool/src/cppparser/cppPreprocessor.cxx @@ -1397,35 +1397,40 @@ handle_include_directive(const string &args, int first_line, found_file = false; + // Search the current directory. if (!angle_quotes && !found_file && filename.exists()) { found_file = true; source = CPPFile::S_local; } - + + // Search the same directory as the includer. 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)) { + Filename match(get_file()._filename.get_dirname(), filename); + if (match.exists()) { + filename = match; found_file = true; source = CPPFile::S_alternate; } } - // Now look for it on the primary include path. We have to search - // this path, even if the file was named with angle quotes, so - // that we will search parser-inc before the system path. - if (!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)) { + // Now search the angle-include-path + if (angle_quotes && !found_file && filename.resolve_filename(_angle_include_path)) { found_file = true; source = CPPFile::S_system; } + // Now search the quote-include-path + if (!angle_quotes && !found_file) { + for (int dir=0; dir<_quote_include_path.get_num_directories(); dir++) { + Filename match(_quote_include_path.get_directory(dir), filename); + if (match.exists()) { + filename = match; + found_file = true; + source = _quote_include_kind[dir]; + } + } + } + if (!found_file) { warning("Cannot find " + filename.get_fullpath(), first_line, first_col, first_file); diff --git a/dtool/src/cppparser/cppPreprocessor.h b/dtool/src/cppparser/cppPreprocessor.h index c20ef68839..9c83e03896 100644 --- a/dtool/src/cppparser/cppPreprocessor.h +++ b/dtool/src/cppparser/cppPreprocessor.h @@ -75,9 +75,10 @@ public: typedef map Manifests; Manifests _manifests; - DSearchPath _include_path; - DSearchPath _system_include_path; - + pvector _quote_include_kind; + DSearchPath _quote_include_path; + DSearchPath _angle_include_path; + CPPComments _comments; typedef set ParsedFiles; diff --git a/dtool/src/interrogate/interrogate.cxx b/dtool/src/interrogate/interrogate.cxx index 848ef9ba6d..c7095cecf7 100644 --- a/dtool/src/interrogate/interrogate.cxx +++ b/dtool/src/interrogate/interrogate.cxx @@ -327,13 +327,16 @@ main(int argc, char *argv[]) { case 'I': fn = Filename::from_os_specific(optarg); fn.make_absolute(); - parser._include_path.append_directory(fn); + parser._quote_include_path.append_directory(fn); + parser._quote_include_kind.push_back(CPPFile::S_alternate); break; case 'S': fn = Filename::from_os_specific(optarg); fn.make_absolute(); - parser._system_include_path.append_directory(fn); + parser._angle_include_path.append_directory(fn); + parser._quote_include_path.append_directory(fn); + parser._quote_include_kind.push_back(CPPFile::S_system); break; case 'D': diff --git a/dtool/src/interrogate/parse_file.cxx b/dtool/src/interrogate/parse_file.cxx index 75aceafa7b..842edd56c1 100644 --- a/dtool/src/interrogate/parse_file.cxx +++ b/dtool/src/interrogate/parse_file.cxx @@ -217,11 +217,14 @@ main(int argc, char *argv[]) { while (flag != EOF) { switch (flag) { case 'I': - parser._include_path.append_directory(optarg); + parser._quote_include_path.append_directory(optarg); + parser._quote_include_kind.push_back(CPPFile::S_alternate); break; case 'S': - parser._system_include_path.append_directory(optarg); + parser._angle_include_path.append_directory(optarg); + parser._quote_include_path.append_directory(optarg); + parser._quote_include_kind.push_back(CPPFile::S_system); break; case 'D':