From 9ee404b16e92882f690e53dc12e4a602bb3974fe Mon Sep 17 00:00:00 2001 From: d3m3t3r <46783027+d3m3t3r@users.noreply.github.com> Date: Mon, 27 May 2024 21:21:10 +0000 Subject: [PATCH] Fix no or multiple commas between sections --- src/basset.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/basset.cpp b/src/basset.cpp index a6d13f3..9ea69d4 100644 --- a/src/basset.cpp +++ b/src/basset.cpp @@ -167,17 +167,11 @@ class CompilationDatabase : ofstream { template CompilationDatabase::CompilationDatabase(Args &&... args) : ofstream(std::forward(args)...) { - *this << "["; + *this << '['; } void CompilationDatabase::add(const string &directory, const vector &command) { - if (first) { - first = false; - } else { - *this << ','; - } - vector files; for (auto &&argument : command) { @@ -187,6 +181,12 @@ void CompilationDatabase::add(const string &directory, } for (const auto &file : files) { + if (first) { + first = false; + } else { + *this << ','; + } + *this << "\n" " {\n" // clang-format off @@ -194,11 +194,11 @@ void CompilationDatabase::add(const string &directory, // clang-format on " \"arguments\": ["; - bool first{true}; + bool first_arg{true}; for (const auto &arg : command) { - if (first) { - first = false; + if (first_arg) { + first_arg = false; } else { *this << ','; }