File tree Expand file tree Collapse file tree 4 files changed +20
-8
lines changed
Expand file tree Collapse file tree 4 files changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -800,7 +800,7 @@ class cmdline_processor
800800 );
801801
802802 print (" \n Usage: cppfront [options] file ...\n " );
803- print (" \n file - The source file(s) to compile (can be 'stdin' to read text directly) \n " );
803+ print (" \n file source file(s) (can be 'stdin') \n " );
804804 print (" \n Options: \n " );
805805 int last_group = -1 ;
806806 for (auto & flag : flags) {
Original file line number Diff line number Diff line change @@ -79,7 +79,12 @@ auto main(
7979
8080 auto & out = flag_cpp1_filename != " stdout" ? std::cout : std::cerr;
8181
82- if (!flag_quiet) {
82+ if (
83+ !flag_quiet
84+ && arg.text != " stdin"
85+ && flag_cpp1_filename != " stdout"
86+ )
87+ {
8388 out << arg.text << " ..." ;
8489 }
8590
@@ -92,7 +97,10 @@ auto main(
9297 // If there were no errors, say so and generate Cpp1
9398 if (c.had_no_errors ())
9499 {
95- if (!flag_quiet)
100+ if (
101+ !flag_quiet
102+ && flag_cpp1_filename != " stdout"
103+ )
96104 {
97105 if (!c.has_cpp1 ()) {
98106 out << " ok (all Cpp2, passes safety checks)\n " ;
Original file line number Diff line number Diff line change @@ -886,7 +886,7 @@ class source
886886 //
887887 auto is_stdin = filename == " stdin" ;
888888 std::ifstream fss;
889- if (is_stdin)
889+ if (! is_stdin)
890890 {
891891 fss.open (filename);
892892 if ( !fss.is_open ()) { return false ; }
Original file line number Diff line number Diff line change @@ -1258,14 +1258,18 @@ class cppfront
12581258 }
12591259
12601260 // Now we'll open the Cpp1 file
1261- auto cpp1_filename = sourcefile.substr (0 , std::ssize (sourcefile) - 1 );
1261+ // Default to stdout if input is stdin
1262+ auto cpp1_filename = std::string{" stdout" };
1263+ if (sourcefile != " stdin" ) {
1264+ assert (sourcefile.ends_with (" 2" ));
1265+ cpp1_filename = sourcefile.substr (0 , std::ssize (sourcefile) - 1 );
1266+ }
12621267
1263- // Use explicit filename override if present,
1264- // otherwise strip leading path
1268+ // Use explicit filename override if present, otherwise strip leading path
12651269 if (!flag_cpp1_filename.empty ()) {
12661270 cpp1_filename = flag_cpp1_filename;
12671271 }
1268- else {
1272+ else if (cpp1_filename != " stdout " ) {
12691273 cpp1_filename = std::filesystem::path (cpp1_filename).filename ().string ();
12701274 }
12711275
You can’t perform that action at this time.
0 commit comments