]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
make_dependencies now behaves like the c++ compiler when searching include paths...
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 10 Jan 2012 17:25:59 +0000 (17:25 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 10 Jan 2012 17:25:59 +0000 (17:25 +0000)
git-svn-id: https://svn.dealii.org/trunk@24899 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/common/scripts/make_dependencies.cc
deal.II/doc/news/changes.h

index 4b024b9c8cbb8e47f766f3e635e400a0c21eb2c5..e17b8a9d9abceeac36e0a43a2fee62bb905d6b05 100644 (file)
@@ -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<std::string>::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<std::string>::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
index 5f1dc6607415a9b07ec41344f582c510b7fc5fef..20feb50d7c48b1e83b3839439cd0fd987efcfbff 100644 (file)
@@ -74,6 +74,11 @@ enabled due to a missing include file in file
 
 <ol>
 
+<li> Fixed: make_dependencies now behaves like the c++ compiler when
+searching include paths for #include "..." directives.
+<br>
+(Timo Heister, 2012/01/10)
+
 <li> Fixed: When <code>./configure</code> does not detect the presence
 of <code>zlib</code>, writing output in VTU format failed to produce
 a valid output file.

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.