String sVersion = version.GetFixedProductVersion();
LangFormatString1(m_strVersion, IDS_VERSION_FMT, sVersion.c_str());
-#ifdef _UNICODE
m_strVersion += _T(" ");
m_strVersion += theApp.LoadString(IDS_UNICODE).c_str();
-#endif
#ifdef WIN64
m_strVersion += _T(" ");
if (SUCCEEDED(hres))
{
WCHAR wsz[MAX_PATH];
-#ifdef _UNICODE
wcsncpy((wchar_t *)wsz, lpsz, sizeof(wsz)/sizeof(WCHAR));
-#else
- ::MultiByteToWideChar(CP_ACP, 0, lpsz, -1, wsz, MAX_PATH);
-#endif
// Load shortcut
hres = ppf->Load((LPCOLESTR)wsz, STGM_READ);
// shortcut methods in case file is in the same encoding as our Strings
-#ifdef _UNICODE
if (m_unicoding == ucr::UCS2LE)
{
int cchLine = 0;
line.assign(pchLine, cchLine);
return true;
}
-#else
- if (m_unicoding == ucr::NONE && EqualCodepages(m_codepage, getDefaultCodepage()))
- {
- int cchLine = 0;
- // If there aren't any bytes left in the file, return FALSE to indicate EOF
- if (m_current - m_base >= m_filesize)
- return false;
- // Loop through chars, watching for eol chars or zero
- while (m_current - m_base < m_filesize)
- {
- char ch = *m_current;
- int ch_offset = (m_current - m_base);
- ++m_current;
- if (ch == '\n' || ch == '\r')
- {
- eol += ch;
- if (ch == '\r')
- {
- if (m_current - m_base < m_filesize && *m_current == '\n')
- {
- eol += '\n';
- ++m_current;
- ++m_txtstats.ncrlfs;
- }
- else
- {
- ++m_txtstats.ncrs;
- }
- }
- else
- {
- ++m_txtstats.nlfs;
- }
- ++m_lineno;
- line.assign(pchLine, cchLine);
- return true;
- }
- if (!ch)
- {
- RecordZero(m_txtstats, ch_offset);
- }
- ++cchLine;
- }
- line.assign(pchLine, cchLine);
- return true;
- }
-#endif
if (m_current - m_base + (m_charsize - 1) >= m_filesize)
return false;
bool UniStdioFile::WriteString(const String & line)
{
// shortcut the easy cases
-#ifdef _UNICODE
if (m_unicoding == ucr::UCS2LE)
-#else
- if (m_unicoding == ucr::NONE && EqualCodepages(m_codepage, getDefaultCodepage()))
-#endif
{
size_t bytes = line.length() * sizeof(TCHAR);
size_t wbytes = fwrite(line.c_str(), 1, bytes, m_fp);
#include <string>
-#ifdef _UNICODE
#define std_tchar(type) std::w##type
-#else
-#define std_tchar(type) std::type
-#endif // _UNICODE
typedef std_tchar(string) String;
*/
bool IsSlashOrColon(LPCTSTR pszChar, LPCTSTR begin)
{
-#ifdef _UNICODE
return (*pszChar == '/' || *pszChar == ':' || *pszChar == '\\');
-#else
- // Avoid 0x5C (ASCII backslash) byte occurring as trail byte in MBCS
- return (*pszChar == '/' || *pszChar == ':'
- || (*pszChar == '\\' && !_ismbstrail((unsigned char *)begin, (unsigned char *)pszChar)));
-#endif
}
/**
// codepoints don't extend that high).
static wint_t normch(wint_t c)
{
-#ifdef _UNICODE
return (unsigned short)(short)c;
-#else
- return (unsigned char)(char)c;
-#endif
}
/** @brief Return nonzero if input is outside ASCII or is underline. */
*/
String maketchar(unsigned int unich, bool & lossy, unsigned int codepage)
{
-#ifdef _UNICODE
if (unich < 0x10000)
{
String s(1, (TCHAR)unich);
}
lossy = TRUE;
return _T("?");
-#else
- if (unich < 0x80)
- {
- String s(1, (TCHAR)unich);
- return s;
- }
- wchar_t wch = (wchar_t)unich;
- if (!lossy)
- {
- static bool vercheck = false;
- static bool has_no_best_fit = false;
- if (!vercheck)
- {
- if (!f_osvi_fetched) fetch_verinfo();
- // Need 2000 (5.x) or 98 (4.10)
- has_no_best_fit = f_osvi.dwMajorVersion >= 5 || (f_osvi.dwMajorVersion == 4 && f_osvi.dwMinorVersion >= 10);
- vercheck = true;
- }
- // So far it isn't lossy, so try for lossless conversion
- TCHAR outch;
- BOOL defaulted = FALSE;
- DWORD flags = has_no_best_fit ? WC_NO_BEST_FIT_CHARS : 0;
- if (WideCharToMultiByte(codepage, flags, &wch, 1, &outch, 1, NULL, &defaulted)
- && !defaulted)
- {
- String s(1, outch);
- return s;
- }
- lossy = TRUE;
- }
- // already lossy, so make our best shot
- DWORD flags = WC_COMPOSITECHECK + WC_DISCARDNS + WC_SEPCHARS + WC_DEFAULTCHAR;
- TCHAR outbuff[16];
- int n = WideCharToMultiByte(codepage, flags, &wch, 1, outbuff, sizeof(outbuff) - 1, NULL, NULL);
- if (n > 0)
- {
- outbuff[n] = 0;
- return outbuff;
- }
- return _T("?");
-#endif
}
/**
*/
void getInternalEncoding(UNICODESET * unicoding, int * codepage)
{
-#ifdef _UNICODE
*unicoding = UCS2LE;
*codepage = 0;
-#else
- // NB: Windows always draws in CP_ACP, not CP_THREAD_ACP, so we must use CP_ACP as an internal codepage
- *unicoding = NONE;
- *codepage = CP_ACP;
-#endif
}
/**
paths_CreateIfNeeded(sFileName.c_str());
m_sFileName = paths_ConcatPath(sFileName, _T("WinMerge.txt"));
-#ifdef _UNICODE
if (!m_pfile->OpenCreateUtf8(m_sFileName.c_str()))
-#else
- if (!m_pfile->OpenCreate(m_sFileName.c_str()))
-#endif
{
const UniFile::UniError &err = m_pfile->GetLastUniError();
sError = err.GetError();
return false;
}
-#ifdef _UNICODE
m_pfile->SetBom(true);
m_pfile->WriteBom();
-#endif
}
// Begin log
static StatusDisplay myStatusDisplay;
-#ifdef _UNICODE
const TCHAR CMainFrame::szClassName[] = _T("WinMergeWindowClassW");
-#else
-const TCHAR CMainFrame::szClassName[] = _T("WinMergeWindowClassA");
-#endif
/**
* @brief Change MainFrame window class name
* see http://support.microsoft.com/kb/403825/ja
// this is the command id, not the button index
AfxExtractSubString(strTipText, strFullText.c_str(), 1, '\n');
}
-#ifndef _UNICODE
- if (pNMHDR->code == TTN_NEEDTEXTA)
- lstrcpyn(pTTTA->szText, strTipText, countof(pTTTA->szText));
- else
- _mbstowcsz(pTTTW->szText, strTipText, countof(pTTTW->szText));
-#else
if (pNMHDR->code == TTN_NEEDTEXTA)
_wcstombsz(pTTTA->szText, strTipText, countof(pTTTA->szText));
else
lstrcpyn(pTTTW->szText, strTipText, countof(pTTTW->szText));
-#endif
*pResult = 0;
// bring the tooltip window above other popup windows
#define UTF82A(lpu) W2A(UTF82W(lpu))
#define A2UTF8(lpa) W2UTF8(A2W(lpa))
-#ifdef _UNICODE
# define UTF82T(lpu) UTF82W(lpu)
# define T2UTF8(lpw) W2UTF8(lpw)
-#else
-# define UTF82T(lpu) UTF82A(lpu)
-# define T2UTF8(lpw) A2UTF8(lpw)
-#endif
// Constants for xml element names
const char Root_element_name[] = "project";
if (nCustomCodepageValue == 0)
{
char *result= new char[80];
-#ifdef _UNICODE
long len = wcslen(m_cCustomCodepageValue);
_wcstombsz(result, m_cCustomCodepageValue, len); //conversion to char *
-#else
- long len = m_cCustomCodepageValue.GetLength();
- strncpy(result, m_cCustomCodepageValue.GetBuffer(0), len);
-#endif
result[len] = '\0'; //don't forget to put the caracter of terminated string
nCustomCodepageValue = GetEncodingCodePageFromName(result);
delete [] result;
// Get appropriate clipboard format for TCHAR text
int GetClipTcharTextFormat()
{
-#ifdef _UNICODE
return CF_UNICODETEXT;
-#else
- return CF_TEXT;
-#endif // _UNICODE
}
#if _MSC_VER <= 1310
__try
{
TCHAR drive[_MAX_PATH], dir[_MAX_PATH], name[_MAX_PATH], ext[_MAX_PATH];
-#ifdef _UNICODE
_wsplitpath (pszFileName, drive, dir, name, ext);
-#else
- _splitpath (pszFileName, drive, dir, name, ext);
-#endif
_tcscpy (szTempFileDir, drive);
_tcscat (szTempFileDir, dir);
_tcscpy (szBackupFileName, pszFileName);
ASSERT (m_bInit); // Text buffer not yet initialized.
// You must call InitNew() or LoadFromFile() first!
-#ifdef _UNICODE
- return FALSE;
-#else // _UNICODE
- const unsigned char *string = (const unsigned char *) GetLineChars (nLine);
- const unsigned char *current = string + nCol;
- if (_ismbslead (string, current) < 0)
- return TRUE;
return FALSE;
-#endif // _UNICODE
}
BOOL CCrystalTextBuffer::
ASSERT (m_bInit); // Text buffer not yet initialized.
// You must call InitNew() or LoadFromFile() first!
-#ifdef _UNICODE
- return FALSE;
-#else // _UNICODE
- const unsigned char *string = (const unsigned char *) GetLineChars (nLine);
- const unsigned char *current = string + nCol;
- if (_ismbstrail (string, current) < 0)
- return TRUE;
return FALSE;
-#endif // _UNICODE
}
//BEGIN SW
int nCount = lineLen - ibegin;
int nCountFit = nWidth / nCharWidth + 2/* wide char */;
if (nCount > nCountFit) {
-#ifndef _UNICODE
- if (_ismbslead((unsigned char *)(LPCSTR)line, (unsigned char *)(LPCSTR)line + nCountFit - 1))
- nCountFit++;
-#endif
nCount = nCountFit;
}
bLastCharSpace = FALSE;
nNonbreakChars++;
}
-#ifndef _UNICODE
- if (IsDBCSLeadByte (ch))
- strHTML += strText[++i];
-#endif
if ((nNonbreakChars % nScreenChars) == nScreenChars - 1)
{
strHTML += _T("<wbr>");
return m_pTextBuffer->GetLineEol(nLine);
}
-#ifdef _UNICODE
int CCrystalTextView::GetCharWidthUnicodeChar(wchar_t ch)
{
if (!m_bChWidthsCalculated[ch/256])
else
return GetCharWidth();
}
-#endif
/** @brief Reset computed unicode character widths. */
void CCrystalTextView::ResetCharWidths ()
{
-#ifdef _UNICODE
ZeroMemory(m_bChWidthsCalculated, sizeof(m_bChWidthsCalculated));
ZeroMemory(m_iChDoubleWidthFlags, sizeof(m_iChDoubleWidthFlags));
-#endif
}
// This function assumes selection is in one line
int GetCharWidthFromString(LPCTSTR lpsz);
int GetCharWidthFromDisplayableChar(const ViewableWhitespaceChars * lpspc, TCHAR ch);
-#ifdef _UNICODE
BOOL m_bChWidthsCalculated[65536/256];
int m_iChDoubleWidthFlags[65536/32];
int GetCharWidthUnicodeChar(wchar_t ch);
-#endif
void ResetCharWidths();
//BEGIN SW
// remember whitespace
WORD wCharType;
-#ifdef _UNICODE
GetStringTypeW(CT_CTYPE3, &szLine[i], 1, &wCharType);
-#else
- if (IsDBCSLeadByte((BYTE)szLine[i]))
- GetStringTypeA(LOCALE_USER_DEFAULT,CT_CTYPE3, &szLine[i], 2, &wCharType);
- else
- wCharType = 0;
-#endif
if( szLine[i] == _T('\t') || szLine[i] == _T(' ') || (wCharType & (C3_IDEOGRAPH | C3_HIRAGANA | C3_KATAKANA)))
bBreakable = TRUE;
do
if ((test = sString.GetAt (--posit)) == _T ('.'))
return posit;
-#ifdef _UNICODE
while (posit && test != _T ('\\') && test != _T (':'));
-#else
- while (posit && (test != _T ('\\') || _ismbstrail((unsigned char *)pszString, (unsigned char *)pszString + posit)) && test != _T (':'));
-#endif
return len;
}
int posit = sString.GetLength ();
TCHAR test;
do
-#ifdef _UNICODE
if ((test = sString.GetAt (--posit)) == _T ('\\') || test == _T (':'))
-#else
- if (((test = sString.GetAt (--posit)) == _T ('\\') && !_ismbstrail((unsigned char *)pszString, (unsigned char *)pszString + posit)) || test == _T (':'))
-#endif
return posit + 1;
while (posit);
return posit;
TCHAR test = sString.GetAt (posit - 1);
-#ifdef _UNICODE
if (test == _T (':') || test == _T ('\\') && (posit == 1 || posit != 1 && sString.GetAt (posit - 2) == _T (':')))
-#else
- if (test == _T (':') || (test == _T ('\\') && !_ismbstrail((unsigned char *)(LPCTSTR)sString, (unsigned char *)(LPCTSTR)sString + posit)) && (posit == 1 || posit != 1 && sString.GetAt (posit - 2) == _T (':')))
-#endif
return sString.Left (posit);
return sString.Left (bClose ? posit : test == _T (':') ? posit : posit - 1);
}
static bool IsSlash(LPCTSTR pszStart, int nPos)
{
return pszStart[nPos]=='/' ||
-#ifdef _UNICODE
pszStart[nPos]=='\\';
-#else
- // Avoid 0x5C (ASCII backslash) byte occurring as trail byte in MBCS
- (pszStart[nPos]=='\\' && !_ismbstrail((unsigned char *)pszStart, (unsigned char *)pszStart + nPos));
-#endif
}
/**
if (SUCCEEDED(hres))
{
WCHAR wsz[MAX_PATH];
-#ifdef _UNICODE
wcsncpy((wchar_t *)wsz, inFile.c_str(), sizeof(wsz) / sizeof(WCHAR));
-#else
- ::MultiByteToWideChar(CP_ACP, 0, inFile.c_str(), -1, wsz, MAX_PATH);
-#endif
// Load shortcut
hres = ppf->Load(wsz, STGM_READ);