From e0b53c5a39f9c6dfbea6e8d137f4d18e101ff014 Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Fri, 3 Feb 2017 17:40:42 -0500 Subject: [PATCH] fix expand-instantiations - 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 | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cmake/scripts/expand_instantiations.cc b/cmake/scripts/expand_instantiations.cc index 98f564d4cd..2dc0f5f8ed 100644 --- a/cmake/scripts/expand_instantiations.cc +++ b/cmake/scripts/expand_instantiations.cc @@ -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 > 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::const_iterator expansion = expansion_lists[pattern].begin(); expansion != expansion_lists[pattern].end(); -- 2.39.5