aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConor Burgess <Burgess.Conor@gmail.com>2017-12-07 10:53:13 +0000
committerGitHub <noreply@github.com>2017-12-07 10:53:13 +0000
commitad383b274db2696cf2d4bdea9d477c463992f2fc (patch)
treea870a30c48167009d6b0c380be230e83587af6e9
parenta868e618c0607259c63f37d948b72586a13922ff (diff)
downloadgoogletest-ad383b274db2696cf2d4bdea9d477c463992f2fc.tar.gz
googletest-ad383b274db2696cf2d4bdea9d477c463992f2fc.tar.bz2
googletest-ad383b274db2696cf2d4bdea9d477c463992f2fc.zip
Fix value pointed to by `_NSGetArgc()` on macOS
-rw-r--r--googletest/src/gtest.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 749e8299..41ed48bb 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -146,6 +146,12 @@
# define vsnprintf _vsnprintf
#endif // GTEST_OS_WINDOWS
+#if GTEST_OS_MAC
+# ifndef GTEST_OS_IOS
+# include <crt_externs.h>
+# endif
+#endif
+
namespace testing {
using internal::CountIf;
@@ -5341,6 +5347,16 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
}
}
+// Fix the value of *_NSGetArgc() on macOS, but iff
+// *_NSGetArgv() == argv
+#if GTEST_OS_MAC
+# ifndef GTEST_OS_IOS
+ if (*_NSGetArgv() == argv) {
+ *_NSGetArgc() = *argc;
+ }
+# endif
+#endif
+
if (g_help_flag) {
// We print the help here instead of in RUN_ALL_TESTS(), as the
// latter may not be called at all if the user is using Google