diff --git a/src/build_log.cc b/src/build_log.cc old mode 100644 new mode 100755 index 3073f7fbf9..8c45c77747 --- a/src/build_log.cc +++ b/src/build_log.cc @@ -54,7 +54,7 @@ bool BuildLog::OpenForWrite(const string& path, string* err) { *err = strerror(errno); return false; } - setvbuf(log_file_, NULL, _IOLBF, 0); + setvbuf(log_file_, NULL, _IOLBF, BUFSIZ); if (ftell(log_file_) == 0) { if (fwrite(kFileSignature, sizeof(kFileSignature) - 1, 1, log_file_) < 1) { diff --git a/src/build_log_test.cc b/src/build_log_test.cc old mode 100644 new mode 100755 index 8bb2bfaaff..1df28db7fe --- a/src/build_log_test.cc +++ b/src/build_log_test.cc @@ -16,6 +16,10 @@ #include "test.h" +#ifdef WIN32 +#include +#endif + static const char kTestFilename[] = "BuildLogTest-tempfile"; struct BuildLogTest : public StateTestWithBuiltinRules { @@ -90,7 +94,14 @@ TEST_F(BuildLogTest, Truncate) { // For all possible truncations of the input file, assert that we don't // crash or report an error when parsing. for (off_t size = statbuf.st_size; size > 0; --size) { +#ifndef WIN32 ASSERT_EQ(0, truncate(kTestFilename, size)); +#else + int fh; + ASSERT_EQ(0, _sopen_s(&fh, kTestFilename, _O_RDWR | _O_CREAT, _SH_DENYNO, _S_IREAD | _S_IWRITE)); + ASSERT_EQ(0, _chsize(fh, size)); + _close(fh); +#endif BuildLog log2; EXPECT_TRUE(log2.Load(kTestFilename, &err)); diff --git a/src/ninja_test.cc b/src/ninja_test.cc old mode 100644 new mode 100755 index 6e3f549f35..a5ef3ab751 --- a/src/ninja_test.cc +++ b/src/ninja_test.cc @@ -217,7 +217,7 @@ TEST_F(StatTest, Middle) { #ifndef _mktemp_s /// mingw has no mktemp. Implement one with the same type as the one /// found in the Windows API. -int _mktemp_s(const char* templ) { +int _mktemp_s(char* templ) { char* ofs = strchr(templ, 'X'); sprintf(ofs, "%d", rand() % 1000000); return 0; diff --git a/src/util.cc b/src/util.cc old mode 100644 new mode 100755 index 14b3379b5f..d5a8f1f331 --- a/src/util.cc +++ b/src/util.cc @@ -25,7 +25,10 @@ #include #include #include + +#ifndef _WIN32 #include +#endif #include diff --git a/src/util.h b/src/util.h old mode 100644 new mode 100755 index 794177dffd..c9e06f4d72 --- a/src/util.h +++ b/src/util.h @@ -46,4 +46,8 @@ int ReadFile(const string& path, string* contents, string* err); /// time. int64_t GetTimeMillis(); +#ifdef _WIN32 +#define snprintf _snprintf +#endif + #endif // NINJA_UTIL_H_