diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 58c28798..f13ea49e 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -2188,7 +2188,7 @@ inline int IsATTY(int fd) { GTEST_DISABLE_DEPRECATED_PUSH_() -// ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), Dup(), Dup2(), and +// ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and // StrError() aren't needed on Windows CE at this time and thus not // defined there. #if GTEST_HAS_FILE_SYSTEM @@ -2196,13 +2196,7 @@ GTEST_DISABLE_DEPRECATED_PUSH_() !defined(GTEST_OS_WINDOWS_RT) && !defined(GTEST_OS_WINDOWS_GAMES) && \ !defined(GTEST_OS_ESP8266) && !defined(GTEST_OS_XTENSA) && \ !defined(GTEST_OS_QURT) -inline int ChDir(const char* dir) { -#ifdef GTEST_OS_WINDOWS - return _chdir(dir); -#else - return chdir(dir); -#endif -} +inline int ChDir(const char* dir) { return chdir(dir); } #endif inline FILE* FOpen(const char* path, const char* mode) { #if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_MINGW) @@ -2219,51 +2213,17 @@ inline FILE* FOpen(const char* path, const char* mode) { inline FILE* FReopen(const char* path, const char* mode, FILE* stream) { return freopen(path, mode, stream); } -inline FILE* FDOpen(int fd, const char* mode) { -#ifdef GTEST_OS_WINDOWS - return _fdopen(fd, mode); -#else - return fdopen(fd, mode); -#endif -} +inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); } #endif // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT inline int FClose(FILE* fp) { return fclose(fp); } #if !defined(GTEST_OS_WINDOWS_MOBILE) && !defined(GTEST_OS_QURT) inline int Read(int fd, void* buf, unsigned int count) { -#ifdef GTEST_OS_WINDOWS - return static_cast(_read(fd, buf, count)); -#else return static_cast(read(fd, buf, count)); -#endif } inline int Write(int fd, const void* buf, unsigned int count) { -#ifdef GTEST_OS_WINDOWS - return static_cast(_write(fd, buf, count)); -#else return static_cast(write(fd, buf, count)); -#endif -} -inline int Close(int fd) { -#ifdef GTEST_OS_WINDOWS - return _close(fd); -#else - return close(fd); -#endif -} -inline int Dup(int fd) { -#ifdef GTEST_OS_WINDOWS - return _dup(fd); -#else - return dup(fd); -#endif -} -inline int Dup2(int fd1, int fd2) { -#ifdef GTEST_OS_WINDOWS - return _dup2(fd1, fd2); -#else - return dup2(fd1, fd2); -#endif } +inline int Close(int fd) { return close(fd); } #endif // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT #endif // GTEST_HAS_FILE_SYSTEM diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc index 0023a887..433586f3 100644 --- a/googletest/src/gtest-port.cc +++ b/googletest/src/gtest-port.cc @@ -1085,7 +1085,7 @@ bool EndsWithPathSeparator(const std::string& path) { class CapturedStream { public: // The ctor redirects the stream to a temporary file. - explicit CapturedStream(int fd) : fd_(fd), uncaptured_fd_(posix::Dup(fd)) { + explicit CapturedStream(int fd) : fd_(fd), uncaptured_fd_(dup(fd)) { #ifdef GTEST_OS_WINDOWS char temp_dir_path[MAX_PATH + 1] = {'\0'}; // NOLINT char temp_file_path[MAX_PATH + 1] = {'\0'}; // NOLINT @@ -1097,7 +1097,7 @@ class CapturedStream { GTEST_CHECK_(success != 0) << "Failed to create temporary file in " << temp_dir_path << " with error " << ::GetLastError(); - const int captured_fd = _creat(temp_file_path, _S_IREAD | _S_IWRITE); + const int captured_fd = creat(temp_file_path, _S_IREAD | _S_IWRITE); GTEST_CHECK_(captured_fd != -1) << "Failed to open temporary file " << temp_file_path << " with error " << ::GetLastError(); @@ -1167,8 +1167,8 @@ class CapturedStream { filename_ = std::move(name_template); #endif // GTEST_OS_WINDOWS fflush(nullptr); - posix::Dup2(captured_fd, fd_); - posix::Close(captured_fd); + dup2(captured_fd, fd_); + close(captured_fd); } ~CapturedStream() { remove(filename_.c_str()); } @@ -1177,8 +1177,8 @@ class CapturedStream { if (uncaptured_fd_ != -1) { // Restores the original stream. fflush(nullptr); - posix::Dup2(uncaptured_fd_, fd_); - posix::Close(uncaptured_fd_); + dup2(uncaptured_fd_, fd_); + close(uncaptured_fd_); uncaptured_fd_ = -1; } diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index f4d71897..a957c895 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -484,11 +484,9 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test { const std::string env_var = std::string("TZ=") + (time_zone ? time_zone : ""); _putenv(env_var.c_str()); -#if defined(GTEST_OS_WINDOWS) - _tzset(); -#else + GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996 /* deprecated function */) tzset(); -#endif + GTEST_DISABLE_MSC_WARNINGS_POP_() #else #if defined(GTEST_OS_LINUX_ANDROID) && __ANDROID_API__ < 21 // Work around KitKat bug in tzset by setting "UTC" before setting "UTC+00".