// ID line follows -- this is updated by SVN
// $Id$
-#include <windows.h>
#include "Utf8FileDetect.h"
// Algorithm originally from:
* @param [in] size Size of the buffer in bytes.
* @return true if invalid bytes found, false otherwise.
*/
-bool CheckForInvalidUtf8(LPBYTE pBuffer, int size)
+bool CheckForInvalidUtf8(const char *pBuffer, int size)
{
- UINT8 * pVal2 = (UINT8 *)pBuffer;
+ unsigned char * pVal2 = (unsigned char *)pBuffer;
for (int j = 0; j < size; ++j)
{
if ((*pVal2 == 0xC0) || (*pVal2 == 0xC1) || (*pVal2 >= 0xF5))
return true;
pVal2++;
}
- pVal2 = (UINT8 *)pBuffer;
+ pVal2 = (unsigned char *)pBuffer;
bool bUTF8 = false;
for (int i = 0; i < (size - 3); ++i)
{
#ifndef _UTF8FILEDETECT_H_
#define _UTF8FILEDETECT_H_
-bool CheckForInvalidUtf8(LPBYTE pBuffer, int size);
+bool CheckForInvalidUtf8(const char *pBuffer, int size);
#endif // _UTF8FILEDETECT_H_
// ID line follows -- this is updated by SVN
// $Id: ByteComparator.h 3397 2006-07-27 10:41:24Z kimmov $
-#include <windows.h>
-#include <crtdbg.h>
-#include "DIFF.H"
#include "CompareOptions.h"
+#include "DIFF.H"
// Global defined in diffutils code
extern int recursive;
m_ignoreWhitespace = WHITESPACE_IGNORE_ALL;
break;
default:
- _RPTF0(_CRT_ERROR, "Unknown whitespace ignore value!");
+ throw "Unknown whitespace ignore value!";
break;
}
m_bIgnoreBlankLines = options.bIgnoreBlankLines;
output_style = OUTPUT_HTML;
break;
default:
- _RPTF0(_CRT_ERROR, "Unknown output style!");
+ throw "Unknown output style!";
break;
}
options.nIgnoreWhitespace = 2;
break;
default:
- _RPTF0(_CRT_ERROR, "Unknown whitespace ignore value!");
+ throw "Unknown whitespace ignore value!";
break;
}
}
// ID line follows -- this is updated by SVN
// $Id: DiffList.cpp 7105 2010-01-14 21:14:22Z kimmov $
-#include <windows.h>
-#include <crtdbg.h>
-#include <assert.h>
+#include <cassert>
+#include <string>
+#include <sstream>
#include "DiffList.h"
-#include "coretools.h"
using std::swap;
using std::vector;
* @return -1 if line is before diff, 0 if line is in diff and
* 1 if line is after diff.
*/
-int DiffList::LineRelDiff(UINT nLine, UINT nDiff) const
+int DiffList::LineRelDiff(unsigned int nLine, unsigned int nDiff) const
{
const DIFFRANGE * dfi = DiffRangeAt(nDiff);
if (nLine < dfi->dbegin[0])
* @param [in] nDiff Index to diff table
* @return TRUE if line is inside given difference.
*/
-bool DiffList::LineInDiff(UINT nLine, UINT nDiff) const
+bool DiffList::LineInDiff(unsigned int nLine, unsigned int nDiff) const
{
const DIFFRANGE * dfi = DiffRangeAt(nDiff);
if (nLine >= dfi->dbegin[0] && nLine <= dfi->dend[0])
* @param [in] nLine Linenumber, 0-based.
* @return Index to diff table, -1 if line is not inside any diff.
*/
-int DiffList::LineToDiff(UINT nLine) const
+int DiffList::LineToDiff(unsigned int nLine) const
{
const int nDiffCount = (int) m_diffs.size();
if (nDiffCount == 0)
left = middle + 1;
break;
default:
- _RPTF1(_CRT_ERROR, "Invalid return value %d from LineRelDiff(): "
- "-1, 0 or 1 expected!", result);
+ {
+ std::stringstream s;
+ s << "Invalid return value " << result << " from LineRelDiff(): -1, 0 or 1 expected!";
+ throw s.str();
break;
+ }
}
}
return -1;
* @param [in] nLine First line searched.
* @return Index for next difference or -1 if no difference is found.
*/
-int DiffList::PrevSignificantDiffFromLine(UINT nLine) const
+int DiffList::PrevSignificantDiffFromLine(unsigned int nLine) const
{
int nDiff = -1;
const int size = (int) m_diffs.size();
* @param [in] nLine First line searched.
* @return Index for previous difference or -1 if no difference is found.
*/
-int DiffList::NextSignificantDiffFromLine(UINT nLine) const
+int DiffList::NextSignificantDiffFromLine(unsigned int nLine) const
{
int nDiff = -1;
const int nDiffCount = (int) m_diffs.size();
* @param [in] nLine First line searched.
* @return Index for next difference or -1 if no difference is found.
*/
-int DiffList::PrevSignificant3wayDiffFromLine(UINT nLine, int nDiffType) const
+int DiffList::PrevSignificant3wayDiffFromLine(unsigned int nLine, int nDiffType) const
{
for (int i = m_diffs.size() - 1; i >= 0 ; i--)
{
* @param [in] nLine First line searched.
* @return Index for previous difference or -1 if no difference is found.
*/
-int DiffList::NextSignificant3wayDiffFromLine(UINT nLine, int nDiffType) const
+int DiffList::NextSignificant3wayDiffFromLine(unsigned int nLine, int nDiffType) const
{
const int nDiffCount = m_diffs.size();
for (file = 0; file < nFiles; file++)
{
nline[file] = curDiff.end[file]-curDiff.begin[file]+1;
- nmaxline = max(nmaxline, nline[file]);
+ nmaxline = std::max(nmaxline, nline[file]);
}
for (file = 0; file < nFiles; file++)
extras[file] += nmaxline - nline[file];
int GetSignificantIndex(int nDiff) const;
bool GetDiff(int nDiff, DIFFRANGE & di) const;
bool SetDiff(int nDiff, const DIFFRANGE & di);
- int LineRelDiff(UINT nLine, UINT nDiff) const;
- bool LineInDiff(UINT nLine, UINT nDiff) const;
- int LineToDiff(UINT nLine) const;
+ int LineRelDiff(unsigned int nLine, unsigned int nDiff) const;
+ bool LineInDiff(unsigned int nLine, unsigned int nDiff) const;
+ int LineToDiff(unsigned int nLine) const;
bool GetPrevDiff(int nLine, int & nDiff) const;
bool GetNextDiff(int nLine, int & nDiff) const;
bool HasSignificantDiffs() const;
- int PrevSignificantDiffFromLine(UINT nLine) const;
- int NextSignificantDiffFromLine(UINT nLine) const;
+ int PrevSignificantDiffFromLine(unsigned int nLine) const;
+ int NextSignificantDiffFromLine(unsigned int nLine) const;
int FirstSignificantDiff() const;
int NextSignificantDiff(int nDiff) const;
int PrevSignificantDiff(int nDiff) const;
int LastSignificantDiff() const;
const DIFFRANGE * FirstSignificantDiffRange() const;
const DIFFRANGE * LastSignificantDiffRange() const;
- int PrevSignificant3wayDiffFromLine(UINT nLine, int nDiffType) const;
- int NextSignificant3wayDiffFromLine(UINT nLine, int nDiffType) const;
+ int PrevSignificant3wayDiffFromLine(unsigned int nLine, int nDiffType) const;
+ int NextSignificant3wayDiffFromLine(unsigned int nLine, int nDiffType) const;
int FirstSignificant3wayDiff(int nDiffType) const;
int NextSignificant3wayDiff(int nDiff, int nDiffType) const;
int PrevSignificant3wayDiff(int nDiff, int nDiffType) const;
easily plug into a Win32 application that does not use Tidy elsewhere.
Runtime-allocated indexes have been added to improve lookup speed.
*/
-
-#include <windows.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#ifndef _WIN32
+#include <strings.h>
+#endif
#include "charsets.h"
+#ifdef _WIN32
+#define strcasecmp(a, b) stricmp((a), (b))
+#endif
+
enum { no, yes };
/* todo: documentation of table and data */
{
const struct _charsetInfo *p = *(const struct _charsetInfo **)elem1;
const struct _charsetInfo *q = *(const struct _charsetInfo **)elem2;
- return lstrcmpiA(p->charset, q->charset);
+ return strcasecmp(p->charset, q->charset);
}
static int CompareByCodePage(const void *elem1, const void *elem2)
}
else
{
- if (!CheckForInvalidUtf8((LPBYTE)src, len))
+ if (!CheckForInvalidUtf8(src, len))
cp = CP_UTF8;
}
if (guessEncodingType & 1)