]> https://gitweb.dealii.org/ - dealii.git/commitdiff
fix expand-instantiations 3903/head
authorTimo Heister <timo.heister@gmail.com>
Fri, 3 Feb 2017 22:40:42 +0000 (17:40 -0500)
committerTimo Heister <timo.heister@gmail.com>
Fri, 3 Feb 2017 22:40:42 +0000 (17:40 -0500)
- remove trailing newlines in pattern values
- skip spaces and newlines before first pattern
- report errors if pattern is not found

cmake/scripts/expand_instantiations.cc

index 98f564d4cdaa75aba9fe074dc43e2dbf11d0fb3d..2dc0f5f8ed6c09151027300e8bd076ec54ebe7f3 100644 (file)
@@ -204,7 +204,8 @@ split_string_list (const std::string &s,
 
       skip_space (name);
 
-      while ((name.size() != 0) && (name[name.length()-1] == ' '))
+      while ((name.size() != 0) && (name[name.length()-1] == ' '
+                                    || name[name.length()-1] == '\n'))
         name.erase (name.length()-1, 1);
 
       split_list.push_back (name);
@@ -301,6 +302,8 @@ void read_expansion_lists (const std::string &filename)
   // end-of-line characters by spaces
   std::string whole_file = read_whole_file (in);
 
+  skip_space (whole_file);
+
   // now process entries of the form
   //   NAME := { class1; class2; ...}.
   while (whole_file.size() != 0)
@@ -363,6 +366,13 @@ void substitute (const std::string &text,
       const std::string name    = substitutions.front().first,
                         pattern = substitutions.front().second;
 
+      if (expansion_lists.find(pattern)==expansion_lists.end())
+        {
+          std::cerr << "could not find pattern '" << pattern << "'" << std::endl;
+          std::exit (1);
+        }
+
+
       const std::list<std::pair<std::string, std::string> >
       rest_of_substitutions (++substitutions.begin(),
                              substitutions.end());
@@ -384,6 +394,12 @@ void substitute (const std::string &text,
       const std::string name    = substitutions.front().first,
                         pattern = substitutions.front().second;
 
+      if (expansion_lists.find(pattern)==expansion_lists.end())
+        {
+          std::cerr << "could not find pattern '" << pattern << "'"<< std::endl;
+          std::exit (1);
+        }
+
       for (std::list<std::string>::const_iterator
            expansion = expansion_lists[pattern].begin();
            expansion != expansion_lists[pattern].end();

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.