aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-04-11 16:20:37 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-04-11 16:20:37 +0200
commit6d61a95027c0e199495f083b393d740933f41e82 (patch)
tree5d4b2937ba2114ef6e32d1528a8a1fa26abcd958
parent363aaeff5ffe398e1b82ef4bef3a96e6e46313ca (diff)
Separate config variable for different modules with blanks
-rw-r--r--build2/config/operation.cxx32
1 files changed, 32 insertions, 0 deletions
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 ();