diff --git a/src/core/platform.h b/src/core/platform.h index 2fe64a9..ecb25b9 100644 --- a/src/core/platform.h +++ b/src/core/platform.h @@ -449,6 +449,7 @@ # define SUPPORTS_NETWORKING (HAVE_SOCKET && !IS_SORTIX && !IS_DOS_DJGPP && !IS_REDOX) # define SUPPORTS_SYSLOG (HAVE_SYSLOG && !IS_SKYOS && !IS_RISCOS) # define NEEDS_SWAB_IMPL (IS_CYGWIN || IS_SYLLABLE || IS_ANDROID || IS_SORTIX) +# define SWAB_TAKES_CHAR_PTRS (IS_MINGW) # define USES_MBLEN (!IS_ANDROID && !IS_AROS) # define USES_DOS_DEVICE_PATH (IS_DOS_DJGPP || (IS_WIN32 && !IS_CYGWIN) || (IS_OS2 && !IS_EMX)) # define USES_DEVICE_PATH (IS_AROS || IS_RISCOS || IS_REDOX || USES_DOS_DEVICE_PATH) @@ -503,13 +504,6 @@ # define UNAME_SUCCESS_ZERO 1 #endif -// Work around single-arg mkdir on MinGW. -// consider using autoconf AX_FUNC_MKDIR if -// we need to handle any more cases here -/*#if IS_MINGW -# define mkdir(a,b) mkdir(a) -#endif*/ - //============================================================================= // Miscellaneous // diff --git a/src/core/tw_signal.cpp b/src/core/tw_signal.cpp index 67f3d9e..916f3d9 100644 --- a/src/core/tw_signal.cpp +++ b/src/core/tw_signal.cpp @@ -83,7 +83,7 @@ void util_SignalHandler(int sig) void tw_psignal(int sig, const TCHAR* str) { - const TCHAR* siglist[NSIG] = {_T("Unknown Signal"), + const TCHAR* siglist[] = { _T("Unknown Signal"), _T("Hangup"), _T("Interrupt"), _T("Quit"), diff --git a/src/fco/signature.cpp b/src/fco/signature.cpp index ade3950..c0e5b5f 100644 --- a/src/fco/signature.cpp +++ b/src/fco/signature.cpp @@ -114,8 +114,8 @@ void cArchiveSigGen::CalculateSignatures(cArchive& a) if (s_direct) { - unsigned long mod = (unsigned long)abBuf % iSignature::SUGGESTED_BLOCK_SIZE; - unsigned long offset = (iSignature::SUGGESTED_BLOCK_SIZE - mod); + uintptr_t mod = (uintptr_t)abBuf % iSignature::SUGGESTED_BLOCK_SIZE; + uintptr_t offset = (iSignature::SUGGESTED_BLOCK_SIZE - mod); pBuf = abBuf + offset; } diff --git a/src/twadmin/twadmincl.cpp b/src/twadmin/twadmincl.cpp index 2c4e197..ae03c4a 100644 --- a/src/twadmin/twadmincl.cpp +++ b/src/twadmin/twadmincl.cpp @@ -2076,8 +2076,15 @@ static bool ChangePassphrase(const TCHAR* keyPath, wc16_string passphraseOld, wc memcpy(passphraseCopyOld, passphraseOld.data(), passphraseLenOld); memcpy(passphraseCopy, passphrase.data(), passphraseLen); #else + + #if SWAB_TAKES_CHAR_PTRS + swab((char*)passphraseOld.data(), (char*)passphraseCopyOld, passphraseLenOld); + swab((char*)passphrase.data(), (char*)passphraseCopy, passphraseLen); +#else swab(passphraseOld.data(), passphraseCopyOld, passphraseLenOld); swab(passphrase.data(), passphraseCopy, passphraseLen); +#endif + #endif bool result; diff --git a/src/twtest/test.cpp b/src/twtest/test.cpp index ebfbef5..e12b928 100644 --- a/src/twtest/test.cpp +++ b/src/twtest/test.cpp @@ -385,7 +385,7 @@ std::string TwTestDir() iFSServices::GetInstance()->GetCurrentDir(dir); dir.append("/TWTestData"); TCERR << "Using test directory: " << dir << std::endl; - mkdir(dir.c_str(), 0777); + tw_mkdir(dir.c_str(), 0777); } return dir; diff --git a/src/twtest/test.h b/src/twtest/test.h index dfef413..67de908 100644 --- a/src/twtest/test.h +++ b/src/twtest/test.h @@ -92,5 +92,16 @@ void RegisterTest(const std::string& suite, const std::string testName, TestPtr void skip(const std::string& reason); void fail(const std::string& reason); +//////////////////////////////////////////////////////////////////////////// + +// Misc platform utility stuff available for all tests + +// Could use AX_FUNC_MKDIR autoconf macro if we need to handle +// any additional cases besides these +#if IS_MINGW +# define tw_mkdir(a,b) mkdir(a) +#else +# define tw_mkdir(a,b) mkdir(a,b) +#endif #endif // __TEST_H diff --git a/src/twtest/textreportviewer_t.cpp b/src/twtest/textreportviewer_t.cpp index ed7d452..9567f1f 100644 --- a/src/twtest/textreportviewer_t.cpp +++ b/src/twtest/textreportviewer_t.cpp @@ -151,9 +151,9 @@ void TestTextReportViewer() fcoNameSpec1 = fcoNameTempDir += _T("SPEC1/"); fcoNameSpec2 = fcoNameTempDir += _T("SPEC2/"); - mkdir( fcoNameTempDir.c_str(), 0777 ); - mkdir( fcoNameSpec1.AsString().c_str(), 0777 ); - mkdir( fcoNameSpec2.AsString().c_str(), 0777 ); + tw_mkdir( fcoNameTempDir.c_str(), 0777 ); + tw_mkdir( fcoNameSpec1.AsString().c_str(), 0777 ); + tw_mkdir( fcoNameSpec2.AsString().c_str(), 0777 ); fcoNameTempFile = fcoNameTempDir += _T("twtempXXXXXX"); pFSServices->MakeTempFilename( fcoNameTempFile ); @@ -473,7 +473,7 @@ void MakeFile(TSTRING& strNameMakeMe) void MakeDir(const TCHAR* const lpszDirName) { - TEST(0 == mkdir(lpszDirName, 0777)) + TEST(0 == tw_mkdir(lpszDirName, 0777)) } //#endif //FIXED_TRV_TEST_SUITE diff --git a/src/twtest/twutil_t.cpp b/src/twtest/twutil_t.cpp index aaa4ebc..7b0211d 100644 --- a/src/twtest/twutil_t.cpp +++ b/src/twtest/twutil_t.cpp @@ -62,7 +62,7 @@ void TestTWUtil() TSTRING tmpFN = TwTestPath("fileexiststest.tmp"); // make a subdir in the TEMP_DIR - mkdir(tmpDir.c_str(), 0700); + tw_mkdir(tmpDir.c_str(), 0700); chmod(tmpDir.c_str(), 0700); // make sure file is not there