Skip to content

Commit 66a1376

Browse files
hsutterzaucy
authored andcommitted
When -o stdout, keep stdout clean by sending non-help output to stderr instead, as requested in hsutter#615
1 parent cf991c5 commit 66a1376

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

regression-tests/test-results/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
cppfront compiler v0.2.1 Build 8828:1624
2+
cppfront compiler v0.2.1 Build 8829:1248
33
Copyright(c) Herb Sutter All rights reserved
44

55
SPDX-License-Identifier: CC-BY-NC-ND-4.0

source/build.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"8828:1624"
1+
"8829:1248"

source/cppfront.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6082,7 +6082,9 @@ auto main(
60826082
int exit_status = EXIT_SUCCESS;
60836083
for (auto const& arg : cmdline.arguments())
60846084
{
6085-
std::cout << arg.text << "...";
6085+
auto& out = flag_cpp1_filename != "stdout" ? std::cout : std::cerr;
6086+
6087+
out << arg.text << "...";
60866088

60876089
// Load + lex + parse + sema
60886090
cppfront c(arg.text);
@@ -6094,25 +6096,25 @@ auto main(
60946096
if (c.had_no_errors())
60956097
{
60966098
if (!c.has_cpp1()) {
6097-
std::cout << " ok (all Cpp2, passes safety checks)\n";
6099+
out << " ok (all Cpp2, passes safety checks)\n";
60986100
}
60996101
else if (c.has_cpp2()) {
6100-
std::cout << " ok (mixed Cpp1/Cpp2, Cpp2 code passes safety checks)\n";
6102+
out << " ok (mixed Cpp1/Cpp2, Cpp2 code passes safety checks)\n";
61016103
}
61026104
else {
6103-
std::cout << " ok (all Cpp1)\n";
6105+
out << " ok (all Cpp1)\n";
61046106
}
61056107

61066108
if (flag_verbose) {
6107-
std::cout << " Cpp1: " << count.cpp1_lines << " lines\n";
6108-
std::cout << " Cpp2: " << count.cpp2_lines << " lines";
6109+
out << " Cpp1: " << count.cpp1_lines << " lines\n";
6110+
out << " Cpp2: " << count.cpp2_lines << " lines";
61096111
if (count.cpp1_lines + count.cpp2_lines > 0) {
6110-
std::cout << " (" << 100 * count.cpp2_lines / (count.cpp1_lines + count.cpp2_lines) << "%)";
6112+
out << " (" << 100 * count.cpp2_lines / (count.cpp1_lines + count.cpp2_lines) << "%)";
61116113
}
6112-
std::cout << "\n";
6114+
out << "\n";
61136115
}
61146116

6115-
std::cout << "\n";
6117+
out << "\n";
61166118
}
61176119
// Otherwise, print the errors
61186120
else

source/sema.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,6 @@ class sema
818818
// initializations on some path(s)
819819
else {
820820
assert (std::ssize(selection_stack) > 0);
821-
// selection_stack.back().debug_print(std::cout);
822821

823822
auto true_branches = std::string{};
824823
auto false_branches = std::string{};

0 commit comments

Comments
 (0)