From a938b4ed394f607e2a14a6b29537f20ffc573e65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 6 Apr 2008 06:26:11 +0000 Subject: [PATCH] Fixing bug 1935006 - Compile problems on cygwin --- CheckHeaders.cpp | 6 +----- CheckMemoryLeak.cpp | 6 +++--- CommonCheck.cpp | 13 +++++++++++++ CommonCheck.h | 3 +++ main.cpp | 11 +++++++---- tokenize.cpp | 6 +----- 6 files changed, 28 insertions(+), 17 deletions(-) diff --git a/CheckHeaders.cpp b/CheckHeaders.cpp index f207b5e93..2cbe2dc00 100644 --- a/CheckHeaders.cpp +++ b/CheckHeaders.cpp @@ -62,11 +62,7 @@ void WarningIncludeHeader() const char *includefile = includetok->next->str; while (hfile < Files.size()) { -#ifdef __linux__ - if (strcasecmp(Files[hfile].c_str(), includefile) == 0) -#else - if (stricmp(Files[hfile].c_str(), includefile) == 0) -#endif + if ( SameFileName( Files[hfile].c_str(), includefile ) ) break; hfile++; } diff --git a/CheckMemoryLeak.cpp b/CheckMemoryLeak.cpp index 7b085ccfb..5bc6989e0 100644 --- a/CheckMemoryLeak.cpp +++ b/CheckMemoryLeak.cpp @@ -8,10 +8,10 @@ #include #include -#ifdef __linux__ -#include -#else +#ifdef __BORLANDC__ #include // <- memset +#else +#include #endif //--------------------------------------------------------------------------- diff --git a/CommonCheck.cpp b/CommonCheck.cpp index 04b30787c..8ff994a23 100644 --- a/CommonCheck.cpp +++ b/CommonCheck.cpp @@ -41,6 +41,19 @@ std::string FileLine(const TOKEN *tok) } //--------------------------------------------------------------------------- +bool SameFileName( const char fname1[], const char fname2[] ) +{ +#ifdef __linux__ + return bool( strcmp(fname1, fname2) == 0 ); +#endif +#ifdef __BORLANDC__ + return bool( stricmp(fname1, fname2) == 0 ); +#else + return bool( strcasecmp(fname1, fname2) == 0 ); +#endif +} +//--------------------------------------------------------------------------- + std::list ErrorList; void ReportErr(const std::string &errmsg) diff --git a/CommonCheck.h b/CommonCheck.h index 087488b6b..62ed70fa2 100644 --- a/CommonCheck.h +++ b/CommonCheck.h @@ -12,6 +12,9 @@ struct TOKEN; std::string FileLine(const TOKEN *tok); +// Are two filenames the same? Case insensitive on windows +bool SameFileName( const char fname1[], const char fname2[] ); + extern bool OnlyReportUniqueErrors; void ReportErr(const std::string &errmsg); diff --git a/main.cpp b/main.cpp index 79c06104b..a0089b7e9 100644 --- a/main.cpp +++ b/main.cpp @@ -14,8 +14,7 @@ #ifdef __BORLANDC__ #include -#endif -#ifdef __GNUC__ +#else #include #endif @@ -30,7 +29,7 @@ static void CppCheck(const char FileName[], unsigned int FileId); static void AddFiles( std::vector &filenames, const char path[], const char pattern[] ) { - #ifndef __GNUC__ + #ifdef __BORLANDC__ struct ffblk f; for ( int done = findfirst(pattern, &f, 0); ! done; done = findnext(&f) ) { @@ -58,7 +57,7 @@ static void RecursiveAddFiles( std::vector &filenames, const char p AddFiles( filenames, path, "*.cc" ); AddFiles( filenames, path, "*.c" ); - #ifndef __GNUC__ + #ifdef __BORLANDC__ struct ffblk f ; for ( int done = findfirst("*", &f, FA_DIREC); ! done; done = findnext(&f) ) { @@ -73,7 +72,11 @@ static void RecursiveAddFiles( std::vector &filenames, const char p findclose(&f); #else glob_t glob_results; + #ifdef CYGWIN glob("*", GLOB_ONLYDIR, 0, &glob_results); + #else + glob("*", 0, 0, &glob_results); + #endif for ( unsigned int i = 0; i < glob_results.gl_pathc; i++ ) { const char *dirname = glob_results.gl_pathv[i]; diff --git a/tokenize.cpp b/tokenize.cpp index 1a1fb7a48..c422e61ea 100644 --- a/tokenize.cpp +++ b/tokenize.cpp @@ -262,11 +262,7 @@ void Tokenize(const char FileName[]) // Has this file been tokenized already? for (unsigned int i = 0; i < Files.size(); i++) { -#ifdef __linux__ - if( strcasecmp(Files[i].c_str(), FileName) == 0 ) -#else - if ( stricmp(Files[i].c_str(), FileName) == 0 ) -#endif + if ( SameFileName( Files[i].c_str(), FileName ) ) return; }