* @param [in] offset Byte offset in whole file (among several buffers).
*/
static void TextScan(FileTextStats & stats, LPCSTR ptr, LPCSTR end, bool eof,
- bool crflag, int offset)
+ bool crflag, __int64 offset)
{
LPCSTR start = ptr; // remember for recording zero-byte offsets
if (ch == 0)
{
++stats.nzeros;
- int index = offset + (ptr - start);
+ __int64 index = offset + (ptr - start);
if (stats.first_zero == -1)
stats.first_zero = index;
stats.last_zero = index;
*/
ByteComparator::COMP_RESULT ByteComparator::CompareBuffers(
FileTextStats & stats0, FileTextStats & stats1, LPCSTR &ptr0, LPCSTR &ptr1,
- LPCSTR end0, LPCSTR end1, bool eof0, bool eof1, int offset0, int offset1)
+ LPCSTR end0, LPCSTR end1, bool eof0, bool eof1, __int64 offset0, __int64 offset1)
{
// First, update file text statistics by doing a full scan
// for 0s and all types of line delimiters
COMP_RESULT CompareBuffers(FileTextStats & stats0, FileTextStats & stats1,
LPCSTR &ptr0, LPCSTR &ptr1, LPCSTR end0, LPCSTR end1, bool eof0, bool eof1,
- int offset0, int offset1);
+ __int64 offset0, __int64 offset1);
private:
// settings
2006-07-27 Kimmo
PATCH: [ 1528841 ] Cleanup ByteComparator
Src: ByteComparator.cpp ByteComparator.h FileTextStats.h
+ PATCH: [ 1528987 ] Use 64-bit variable as file position in Bytecompare
+ Src: ByteComparator.cpp ByteComparator.h DiffWrapper.cpp FileTextStats.h
2006-07-26 Kimmo
PATCH: [ 1528444 ] Cleanup for AppSerialize
}
// area of buffer currently holding data
- int bfstart[2]; // offset into buff[i] where current data resides
- int bfend[2]; // past-the-end pointer into buff[i], giving end of current data
+ __int64 bfstart[2]; // offset into buff[i] where current data resides
+ __int64 bfend[2]; // past-the-end pointer into buff[i], giving end of current data
// buff[0] has bytes to process from buff[0][bfstart[0]] to buff[0][bfend[0]-1]
bool eof[2]; // if we've finished file
}
if (!eof[i] && bfend[i]<countof(buff[i])-1)
{
- int space = countof(buff[i]) - bfend[i];
- int rtn = fread(&buff[i][bfend[i]], 1, space, fp[i]);
+ // Assume our blocks are in range of unsigned int
+ unsigned int space = countof(buff[i]) - bfend[i];
+ size_t rtn = fread(&buff[i][bfend[i]], 1, space, fp[i]);
if (ferror(fp[i]))
return DIFFCODE::CMPERR;
if (feof(fp[i]))
LPCSTR end0 = &buff[0][bfend[0]];
LPCSTR end1 = &buff[1][bfend[1]];
- int offset0 = (ptr0 - &buff[0][0]);
- int offset1 = (ptr1 - &buff[1][0]);
+ __int64 offset0 = (ptr0 - &buff[0][0]);
+ __int64 offset1 = (ptr1 - &buff[1][0]);
// are these two buffers the same?
if (!comparator.CompareBuffers(m_textStats0, m_textStats1,
*/
struct FileTextStats
{
- int ncrs; /**< Count of MAC (CR-byte) EOLs. */
- int nlfs; /**< Count of Unix (LF-byte) EOLs. */
- int ncrlfs; /**< Count of DOS (CR+LF-bytes) EOLs. */
- int nzeros; /**< Count of zero-bytes. */
- int first_zero; /**< Byte offset to first zero-byte, initially -1 */
- int last_zero; /**< Byte offset to last zero-byte, initially -1 */
- int nlosses;
+ unsigned int ncrs; /**< Count of MAC (CR-byte) EOLs. */
+ unsigned int nlfs; /**< Count of Unix (LF-byte) EOLs. */
+ unsigned int ncrlfs; /**< Count of DOS (CR+LF-bytes) EOLs. */
+ unsigned int nzeros; /**< Count of zero-bytes. */
+ __int64 first_zero; /**< Byte offset to first zero-byte, initially -1 */
+ __int64 last_zero; /**< Byte offset to last zero-byte, initially -1 */
+ unsigned int nlosses;
FileTextStats() { clear(); }
void clear() { ncrs = nlfs = ncrlfs = nzeros = nlosses = 0; first_zero = -1; last_zero = -1; }
};