ctest_coverage: Save/restore LC_ALL around gcov (#13136)

Commit ffbe61bb (make sure english is used for output of gcov, 2008-05-10)
taught ctest_coverage to set LC_ALL=POSIX to get English output from gcov.
Use the more portable value LC_ALL=C and restore the original value when
finished.
This commit is contained in:
Brad King 2012-04-16 08:42:11 -04:00
parent 31e7fadbb3
commit 3247d63abb
1 changed files with 29 additions and 1 deletions

View File

@ -752,6 +752,33 @@ int cmCTestCoverageHandler::HandlePHPCoverage(
return static_cast<int>(cont->TotalCoverage.size()); return static_cast<int>(cont->TotalCoverage.size());
} }
struct cmCTestCoverageHandlerLocale
{
cmCTestCoverageHandlerLocale()
{
if(const char* l = cmSystemTools::GetEnv("LC_ALL"))
{
lc_all = l;
}
if(lc_all != "C")
{
cmSystemTools::PutEnv("LC_ALL=C");
}
}
~cmCTestCoverageHandlerLocale()
{
if(!lc_all.empty())
{
cmSystemTools::PutEnv(("LC_ALL=" + lc_all).c_str());
}
else
{
cmSystemTools::UnsetEnv("LC_ALL");
}
}
std::string lc_all;
};
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCTestCoverageHandler::HandleGCovCoverage( int cmCTestCoverageHandler::HandleGCovCoverage(
cmCTestCoverageHandlerContainer* cont) cmCTestCoverageHandlerContainer* cont)
@ -815,7 +842,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
int file_count = 0; int file_count = 0;
// make sure output from gcov is in English! // make sure output from gcov is in English!
cmSystemTools::PutEnv("LC_ALL=POSIX"); cmCTestCoverageHandlerLocale locale_C;
static_cast<void>(locale_C);
// files is a list of *.da and *.gcda files with coverage data in them. // files is a list of *.da and *.gcda files with coverage data in them.
// These are binary files that you give as input to gcov so that it will // These are binary files that you give as input to gcov so that it will