1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-12 20:11:03 +01:00

printTable(): Make destination stream explicit

This commit is contained in:
Eelco Dolstra 2025-12-01 20:15:23 +01:00
parent ab6dcf2047
commit c4dc42f306
3 changed files with 6 additions and 6 deletions

View file

@ -6,6 +6,6 @@ namespace nix {
typedef std::vector<std::vector<std::string>> Table;
void printTable(Table & table);
void printTable(std::ostream & out, Table & table);
} // namespace nix

View file

@ -7,7 +7,7 @@
namespace nix {
void printTable(Table & table)
void printTable(std::ostream & out, Table & table)
{
auto nrColumns = table.size() > 0 ? table.front().size() : 0;
@ -27,11 +27,11 @@ void printTable(Table & table)
for (auto j = i.begin(); j != i.end(); ++j, ++column) {
std::string s = *j;
replace(s.begin(), s.end(), '\n', ' ');
std::cout << s;
out << s;
if (column < nrColumns - 1)
std::cout << std::string(widths[column] - s.size() + 2, ' ');
out << std::string(widths[column] - s.size() + 2, ' ');
}
std::cout << std::endl;
out << std::endl;
}
}

View file

@ -1250,7 +1250,7 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
}
if (!xmlOutput)
printTable(table);
printTable(std::cout, table);
}
static void opSwitchProfile(Globals & globals, Strings opFlags, Strings opArgs)