summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx63
1 files changed, 8 insertions, 55 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 22acac8..bb0a86b 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -972,61 +972,14 @@ bool cmSystemTools::FilesDiffer(const char* source,
{
return true;
}
- const int buffer_length = 4096;
- char bufferSource[buffer_length];
- char bufferDest[buffer_length];
- while(finSource && finDestination)
- {
- if(finSource.getline(bufferSource, buffer_length, '\n')
- || finSource.gcount())
- {
- if(finDestination.getline(bufferDest, buffer_length, '\n')
- || finDestination.gcount())
- {
- // both if statements passed
- if(finSource.eof())
- {
- if(!finDestination.eof())
- {
- return true;
- }
- if(finSource.gcount() != finDestination.gcount())
- {
- return true;
- }
- if(strncmp(bufferSource, bufferDest, finSource.gcount()) != 0)
- {
- return true;
- }
- }
- else if(finSource.fail())
- {
- if(!finDestination.fail())
- {
- return true;
- }
- if(strcmp(bufferSource, bufferDest) != 0)
- {
- return true;
- }
- finSource.clear(finSource.rdstate() & ~std::ios::failbit);
- finDestination.clear(finDestination.rdstate() & ~std::ios::failbit);
- }
- else
- {
- if(strcmp(bufferSource, bufferDest) != 0)
- {
- return true;
- }
- }
- }
- else
- {
- return true;
- }
- }
- }
- return false;
+ char* buffer1 = new char[statSource.st_size];
+ char* buffer2 = new char[statSource.st_size];
+ finSource.read(buffer1, statSource.st_size);
+ finDestination.read(buffer2, statSource.st_size);
+ int ret = memcmp(buffer1, buffer2, statSource.st_size);
+ delete [] buffer2;
+ delete [] buffer1;
+ return ret != 0;
}