aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 ();