Skip to content

Commit

Permalink
Fix no or multiple commas between sections
Browse files Browse the repository at this point in the history
  • Loading branch information
d3m3t3r authored and i-ky committed May 28, 2024
1 parent 9dae343 commit 9ee404b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/basset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,11 @@ class CompilationDatabase : ofstream {
template <typename... Args>
CompilationDatabase::CompilationDatabase(Args &&... args)
: ofstream(std::forward<Args>(args)...) {
*this << "[";
*this << '[';
}

void CompilationDatabase::add(const string &directory,
const vector<string> &command) {
if (first) {
first = false;
} else {
*this << ',';
}

vector<string> files;

for (auto &&argument : command) {
Expand All @@ -187,18 +181,24 @@ void CompilationDatabase::add(const string &directory,
}

for (const auto &file : files) {
if (first) {
first = false;
} else {
*this << ',';
}

*this << "\n"
" {\n"
// clang-format off
" \"directory\": \"" << directory << "\",\n"
// 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 << ',';
}
Expand Down

0 comments on commit 9ee404b

Please sign in to comment.