From c75b93a0cb09fb1348c12eb285c90c08515b52f5 Mon Sep 17 00:00:00 2001 From: heister Date: Tue, 10 Jan 2012 17:25:59 +0000 Subject: [PATCH] make_dependencies now behaves like the c++ compiler when searching include paths for #include "..." directives. git-svn-id: https://svn.dealii.org/trunk@24899 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/common/scripts/make_dependencies.cc | 56 ++++++++++++--------- deal.II/doc/news/changes.h | 5 ++ 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/deal.II/common/scripts/make_dependencies.cc b/deal.II/common/scripts/make_dependencies.cc index 4b024b9c8c..e17b8a9d9a 100644 --- a/deal.II/common/scripts/make_dependencies.cc +++ b/deal.II/common/scripts/make_dependencies.cc @@ -69,6 +69,16 @@ enum Format } format; +bool file_exists(const std::string & file) +{ + struct stat buf; + int error = stat (file.c_str(), &buf); + + return ((error == 0) && + S_ISREG(buf.st_mode)); +} + + // for the given file, fill a // respective entry in the "direct_includes" // map listing the names of those @@ -174,25 +184,25 @@ void determine_direct_includes (const std::string &file) std::abort(); } - // next try to locate the file - // in absolute paths. this is - // easy if it was included via - // "...", but for <...> we have - // to work a little harder + // next try to locate the file in + // absolute paths. For includes of the + // form #include "...", we check the + // current path first. if (included_file[0] != '/') { - if (line[pos] == '"') - included_file = present_path+included_file; - else - for (std::vector::const_iterator + bool is_relative_path = false; + if (line[pos] == '"' && file_exists(present_path+included_file)) + { + included_file = present_path+included_file; + is_relative_path = true; + } + + if (is_relative_path == false) + for (std::vector::const_iterator include_dir=include_directories.begin(); include_dir!=include_directories.end(); ++include_dir) { - struct stat buf; - int error = stat ((*include_dir+included_file).c_str(), &buf); - - if ((error == 0) && - S_ISREG(buf.st_mode)) + if (file_exists((*include_dir+included_file))) { included_file = *include_dir+included_file; break; @@ -209,14 +219,14 @@ void determine_direct_includes (const std::string &file) // it will be generated by make // later, so we better keep it // on the list. - if (line[pos] != '"' || included_file.rfind(".inst") != (included_file.size()-5)) { - struct stat buf; - int error = stat (included_file.c_str(), &buf); - - if ((error != 0) || - !S_ISREG(buf.st_mode)) - continue; - } + bool is_inst_file = + included_file.size()>5 && (included_file.rfind(".inst") == (included_file.size()-5)); + + if (line[pos] != '"' || !is_inst_file) + { + if (!file_exists(included_file)) + continue; + } @@ -227,7 +237,7 @@ void determine_direct_includes (const std::string &file) // work on the include file // recursively. note that the - // first line of this file + // first line of this function // saves us from infinite // recursions in case of // include loops diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 5f1dc66074..20feb50d7c 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -74,6 +74,11 @@ enabled due to a missing include file in file
    +
  1. Fixed: make_dependencies now behaves like the c++ compiler when +searching include paths for #include "..." directives. +
    +(Timo Heister, 2012/01/10) +
  2. Fixed: When ./configure does not detect the presence of zlib, writing output in VTU format failed to produce a valid output file. -- 2.39.5