From 6d61a95027c0e199495f083b393d740933f41e82 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 11 Apr 2016 16:20:37 +0200 Subject: Separate config variable for different modules with blanks --- build2/config/operation.cxx | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/build2/config/operation.cxx b/build2/config/operation.cxx index fc583b5..ec92e89 100644 --- a/build2/config/operation.cxx +++ b/build2/config/operation.cxx @@ -94,6 +94,35 @@ namespace build2 << "#" << endl; } + // Separate variables for modules with blank lines. + // + const string* mod_s (nullptr); + size_t mod_n (0); + + auto next_module = [&mod_s, &mod_n] (const variable& var) -> bool + { + const string& s (var.name); + + size_t p (s.find ('.', 7)); // 7 for "config." + size_t n (p != string::npos ? p - 7 : s.size () - 7); + + if (mod_s == nullptr) + { + mod_s = &s; + mod_n = n; + return false; // First + } + + if (s.compare (7, n, *mod_s, 7, mod_n) != 0) + { + mod_s = &s; + mod_n = n; + return true; // Next. + } + + return false; + }; + // Save config variables. // names storage; @@ -195,6 +224,9 @@ namespace build2 continue; } + if (next_module (var)) + ofs << endl; + if (val) { storage.clear (); -- cgit v1.1