summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2012-04-16 12:42:11 (GMT)
committerBrad King <brad.king@kitware.com>2012-04-16 12:48:16 (GMT)
commit3247d63abbb0ed2c5aafcc14ef693db769eeb055 (patch)
treea8003056c2edbc06ed65ad079f145ad4fd86da22
parent31e7fadbb3bfd225e0d48e2d072ccc745d7f2689 (diff)
downloadCMake-3247d63abbb0ed2c5aafcc14ef693db769eeb055.zip
CMake-3247d63abbb0ed2c5aafcc14ef693db769eeb055.tar.gz
CMake-3247d63abbb0ed2c5aafcc14ef693db769eeb055.tar.bz2
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.
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx30
1 files changed, 29 insertions, 1 deletions
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index 309abb1..ae06b0f 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -752,6 +752,33 @@ int cmCTestCoverageHandler::HandlePHPCoverage(
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(
cmCTestCoverageHandlerContainer* cont)
@@ -815,7 +842,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
int file_count = 0;
// 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.
// These are binary files that you give as input to gcov so that it will