Skip to content

Commit

Permalink
flush gflags output
Browse files Browse the repository at this point in the history
last stab at #5999
  • Loading branch information
rt committed Nov 25, 2018
1 parent 0a80d32 commit 2d04e27
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 3 additions & 5 deletions rts/System/SpringApp.cpp
Expand Up @@ -167,11 +167,9 @@ static void ConsolePrintInitialize(const std::string& configSource, bool safemod
*/
SpringApp::SpringApp(int argc, char** argv)
{
// {--,/}help overrides all other flags and causes exit(),
// even in the unusual event it is not given as first arg
if (argc > 1 && strstr(argv[1], "help") != nullptr)
ConsolePrintInitialize("", false);

// NB
// {--,/}help overrides all other flags and causes exit(),
// even in the unusual event it is not given as first arg
gflags::SetUsageMessage("Usage: " + std::string(argv[0]) + " [options] [path_to_script.txt or demo.sdfz]");
gflags::SetVersionString(SpringVersion::GetFull());
gflags::ParseCommandLineFlags(&argc, &argv, true);
Expand Down
10 changes: 9 additions & 1 deletion rts/lib/gflags/src/gflags.cc
Expand Up @@ -135,8 +135,16 @@ using std::sort;
using std::string;
using std::vector;

static void flush_exit(int ec) {
// exit(1) is not a normal termination, force a flush
std::fflush(stdout);
std::exit(ec);
}

// This is used by the unittest to test error-exit code
void GFLAGS_DLL_DECL (*gflags_exitfunc)(int) = &exit; // from stdlib.h
// void GFLAGS_DLL_DECL (*gflags_exitfunc)(int) = &exit; // from stdlib.h
//SPRING
void GFLAGS_DLL_DECL (*gflags_exitfunc)(int) = &flush_exit;


// The help message indicating that the commandline flag has been
Expand Down

0 comments on commit 2d04e27

Please sign in to comment.