aboutsummaryrefslogtreecommitdiffstats
path: root/src/gtest-port.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/gtest-port.cc')
-rw-r--r--src/gtest-port.cc30
1 files changed, 8 insertions, 22 deletions
diff --git a/src/gtest-port.cc b/src/gtest-port.cc
index e41ab9f5..02998424 100644
--- a/src/gtest-port.cc
+++ b/src/gtest-port.cc
@@ -42,10 +42,6 @@
#include <unistd.h>
#endif // GTEST_OS_WINDOWS
-#if GTEST_USES_SIMPLE_RE
-#include <string.h>
-#endif
-
#ifdef _WIN32_WCE
#include <windows.h> // For TerminateProcess()
#endif // _WIN32_WCE
@@ -350,11 +346,7 @@ bool RE::PartialMatch(const char* str, const RE& re) {
void RE::Init(const char* regex) {
pattern_ = full_pattern_ = NULL;
if (regex != NULL) {
-#if GTEST_OS_WINDOWS
- pattern_ = _strdup(regex);
-#else
- pattern_ = strdup(regex);
-#endif
+ pattern_ = posix::strdup(regex);
}
is_valid_ = ValidateRegex(regex);
@@ -510,17 +502,9 @@ void CaptureStderr() {
::std::string GetCapturedStderr() {
g_captured_stderr->StopCapture();
-// Disables Microsoft deprecation warning for fopen and fclose.
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable: 4996)
-#endif // _MSC_VER
- FILE* const file = fopen(g_captured_stderr->filename().c_str(), "r");
+ FILE* const file = posix::fopen(g_captured_stderr->filename().c_str(), "r");
const ::std::string content = ReadEntireFile(file);
- fclose(file);
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif // _MSC_VER
+ posix::fclose(file);
delete g_captured_stderr;
g_captured_stderr = NULL;
@@ -541,10 +525,12 @@ const ::std::vector<String>& GetArgvs() { return g_argvs; }
#endif // GTEST_HAS_DEATH_TEST
#ifdef _WIN32_WCE
+namespace posix {
void abort() {
DebugBreak();
TerminateProcess(GetCurrentProcess(), 1);
}
+} // namespace posix
#endif // _WIN32_WCE
// Returns the name of the environment variable corresponding to the
@@ -609,7 +595,7 @@ bool ParseInt32(const Message& src_text, const char* str, Int32* value) {
// The value is considered true iff it's not "0".
bool BoolFromGTestEnv(const char* flag, bool default_value) {
const String env_var = FlagToEnvVar(flag);
- const char* const string_value = GetEnv(env_var.c_str());
+ const char* const string_value = posix::getenv(env_var.c_str());
return string_value == NULL ?
default_value : strcmp(string_value, "0") != 0;
}
@@ -619,7 +605,7 @@ bool BoolFromGTestEnv(const char* flag, bool default_value) {
// doesn't represent a valid 32-bit integer, returns default_value.
Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) {
const String env_var = FlagToEnvVar(flag);
- const char* const string_value = GetEnv(env_var.c_str());
+ const char* const string_value = posix::getenv(env_var.c_str());
if (string_value == NULL) {
// The environment variable is not set.
return default_value;
@@ -641,7 +627,7 @@ Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) {
// the given flag; if it's not set, returns default_value.
const char* StringFromGTestEnv(const char* flag, const char* default_value) {
const String env_var = FlagToEnvVar(flag);
- const char* const value = GetEnv(env_var.c_str());
+ const char* const value = posix::getenv(env_var.c_str());
return value == NULL ? default_value : value;
}