Skip to content

Commit

Permalink
[Fix] openmpt123: Set stdin to text mode only after parsing commandli…
Browse files Browse the repository at this point in the history
…ne and verifying that we are not supposed to take binary data from stdin.

git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@21733 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
manxorist committed Sep 24, 2024
1 parent 02b3d26 commit 2dda7f7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions openmpt123/openmpt123.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2184,7 +2184,6 @@ class terminal_ui_guard {

static mpt::uint8 main( std::vector<mpt::ustring> args ) {

FILE_mode_guard stdin_text_guard( stdin, FILE_mode::text );
FILE_mode_guard stdout_text_guard( stdout, FILE_mode::text );
FILE_mode_guard stderr_text_guard( stderr, FILE_mode::text );

Expand Down Expand Up @@ -2276,7 +2275,8 @@ static mpt::uint8 main( std::vector<mpt::ustring> args ) {
[[maybe_unused]] std::optional<FILE_mode_guard> stdin_guard{ stdin_data ? std::make_optional<FILE_mode_guard>( stdin, FILE_mode::binary ) : std::nullopt };
[[maybe_unused]] std::optional<FILE_mode_guard> stdout_guard{ stdout_data ? std::make_optional<FILE_mode_guard>( stdout, FILE_mode::binary ) : std::nullopt };

// setup terminal
// setup terminal input
[[maybe_unused]] std::optional<FILE_mode_guard> stdin_text_guard{ stdin_text ? std::make_optional<FILE_mode_guard>( stdin, FILE_mode::text ) : std::nullopt };
[[maybe_unused]] std::optional<terminal_ui_guard> input_guard{ stdin_text && ( flags.mode == Mode::UI ) ? std::make_optional<terminal_ui_guard>() : std::nullopt };

// choose text output between quiet/stdout/stderr
Expand Down

0 comments on commit 2dda7f7

Please sign in to comment.