Fixing bug 1935006 - Compile problems on cygwin

This commit is contained in:
Daniel Marjamäki 2008-04-06 06:26:11 +00:00
parent fd9ca7c300
commit a938b4ed39
6 changed files with 28 additions and 17 deletions

View File

@ -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++;
}

View File

@ -8,10 +8,10 @@
#include <vector>
#include <sstream>
#ifdef __linux__
#include <string.h>
#else
#ifdef __BORLANDC__
#include <mem.h> // <- memset
#else
#include <string.h>
#endif
//---------------------------------------------------------------------------

View File

@ -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<std::string> ErrorList;
void ReportErr(const std::string &errmsg)

View File

@ -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);

View File

@ -14,8 +14,7 @@
#ifdef __BORLANDC__
#include <dir.h>
#endif
#ifdef __GNUC__
#else
#include <glob.h>
#endif
@ -30,7 +29,7 @@ static void CppCheck(const char FileName[], unsigned int FileId);
static void AddFiles( std::vector<std::string> &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<std::string> &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<std::string> &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];

View File

@ -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;
}