Merge branch 'UniCodePage_Branch' into StrSafe3_Branch

This commit is contained in:
Rainer Kottenhoff 2017-08-31 14:24:32 +02:00
commit dce3076e39
11 changed files with 213 additions and 152 deletions

View File

@ -12,6 +12,7 @@ optionally with master key
see ecryption-doc.txt for details
*/
#define VC_EXTRALEAN 1
#include <windows.h>
#include <intsafe.h>
#include <time.h>

View File

@ -40,6 +40,8 @@
have been tweaked for compatibility with the local environment.
*/
#define VC_EXTRALEAN 1
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
//#include "helpers.h"
//#include "appreg.h"

View File

@ -255,6 +255,12 @@
<ClCompile Include="lexers\LexRegistry.cxx">
<Filter>lexers</Filter>
</ClCompile>
<ClCompile Include="src\DBCS.cxx">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="lexlib\DefaultLexer.cxx">
<Filter>lexlib</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\ILexer.h">
@ -428,6 +434,12 @@
<ClInclude Include="src\UniqueString.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="src\DBCS.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="lexlib\DefaultLexer.h">
<Filter>lexlib</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="deelx\doc\deelx_en.chm">

View File

@ -15,6 +15,8 @@
#if !defined(_WIN32_WINNT)
#define _WIN32_WINNT 0x501
#endif
#define VC_EXTRALEAN 1
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#include <commctrl.h>
#include <shlobj.h>
@ -399,8 +401,8 @@ INT_PTR CALLBACK RunDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
ExpandEnvironmentStringsEx(arg1,COUNTOF(arg1));
ExtractFirstArgument(arg1,arg1,arg2,MAX_PATH);
if (lstrcmpi(arg1,L"notepad3") == 0 ||
lstrcmpi(arg1,L"notepad3.exe") == 0) {
if (StringCchCompareIN(arg1,COUNTOF(arg1),L"notepad3",-1) == 0 ||
StringCchCompareIN(arg1,COUNTOF(arg1),L"notepad3.exe",-1) == 0) {
GetModuleFileName(NULL,arg1,COUNTOF(arg1));
bQuickExit = TRUE;
}

View File

@ -15,6 +15,7 @@
#if !defined(_WIN32_WINNT)
#define _WIN32_WINNT 0x501
#endif
#define VC_EXTRALEAN 1
#include <windows.h>
#include <commctrl.h>
#include <shlobj.h>
@ -932,7 +933,7 @@ BOOL DirList_SelectItem(HWND hwnd,LPCWSTR lpszDisplayName,LPCWSTR lpszFullPath)
DirList_GetItem(hwnd,i,&dli);
GetShortPathName(dli.szFileName,dli.szFileName,MAX_PATH);
if (!lstrcmpi(dli.szFileName,szShortPath))
if (!StringCchCompareI(dli.szFileName,szShortPath))
{
ListView_SetItemState(hwnd,i,LVIS_FLAGS,LVIS_FLAGS);
ListView_EnsureVisible(hwnd,i,FALSE);
@ -964,7 +965,7 @@ void DirList_CreateFilter(PDL_FILTER pdlf,LPCWSTR lpszFileSpec,
StringCchCopyN(pdlf->tFilterBuf,COUNTOF(pdlf->tFilterBuf),lpszFileSpec,DL_FILTER_BUFSIZE);
pdlf->bExcludeFilter = bExcludeFilter;
if (!lstrcmp(lpszFileSpec,L"*.*") || !StringCchLenN(lpszFileSpec,DL_FILTER_BUFSIZE))
if (!StringCchCompareX(lpszFileSpec,L"*.*") || !StringCchLenN(lpszFileSpec,DL_FILTER_BUFSIZE))
return;
pdlf->nCount = 1;

View File

@ -16,6 +16,7 @@
#if !defined(_WIN32_WINNT)
#define _WIN32_WINNT 0x501
#endif
#define VC_EXTRALEAN 1
#include <windows.h>
#include <shlwapi.h>
#include <commctrl.h>
@ -346,7 +347,7 @@ void EditSetNewText(HWND hwnd,char* lpstrText,DWORD cbText)
SendMessage(hwnd,SCI_CANCEL,0,0);
SendMessage(hwnd,SCI_SETUNDOCOLLECTION,0,0);
SendMessage(hwnd,SCI_EMPTYUNDOBUFFER,0,0);
UndoRedoSelectionMap(-1,NULL);
SendMessage(hwnd,SCI_CLEARALL,0,0);
SendMessage(hwnd,SCI_MARKERDELETEALL,(WPARAM)-1,0);
SendMessage(hwnd,SCI_SETSCROLLWIDTH,2048,0);
@ -358,8 +359,7 @@ void EditSetNewText(HWND hwnd,char* lpstrText,DWORD cbText)
SendMessage(hwnd,SCI_ADDTEXT,cbText,(LPARAM)lpstrText);
SendMessage(hwnd,SCI_SETUNDOCOLLECTION,1,0);
SendMessage(hwnd,EM_EMPTYUNDOBUFFER,0,0);
UndoRedoSelectionMap(-1,NULL);
//SendMessage(hwnd,EM_EMPTYUNDOBUFFER,0,0); // deprecated
SendMessage(hwnd,SCI_SETSAVEPOINT,0,0);
SendMessage(hwnd,SCI_GOTOPOS,0,0);
SendMessage(hwnd,SCI_CHOOSECARETX,0,0);
@ -390,13 +390,12 @@ BOOL EditConvertText(HWND hwnd,int encSource,int encDest,BOOL bSetSavePoint)
if (length == 0) {
SendMessage(hwnd,SCI_CANCEL,0,0);
SendMessage(hwnd,SCI_SETUNDOCOLLECTION,0,0);
SendMessage(hwnd,SCI_EMPTYUNDOBUFFER,0,0);
UndoRedoSelectionMap(-1,NULL);
SendMessage(hwnd,SCI_CLEARALL,0,0);
SendMessage(hwnd,SCI_MARKERDELETEALL,(WPARAM)-1,0);
Encoding_SciSetCodePage(hwnd,encDest);
SendMessage(hwnd,SCI_SETUNDOCOLLECTION,1,0);
SendMessage(hwnd,EM_EMPTYUNDOBUFFER,0,0);
UndoRedoSelectionMap(-1,NULL);
SendMessage(hwnd,SCI_SETUNDOCOLLECTION,(WPARAM)1,0);
//SendMessage(hwnd,EM_EMPTYUNDOBUFFER,0,0); // deprecated
SendMessage(hwnd,SCI_GOTOPOS,0,0);
SendMessage(hwnd,SCI_CHOOSECARETX,0,0);
@ -428,13 +427,12 @@ BOOL EditConvertText(HWND hwnd,int encSource,int encDest,BOOL bSetSavePoint)
SendMessage(hwnd,SCI_CANCEL,0,0);
SendMessage(hwnd,SCI_SETUNDOCOLLECTION,0,0);
SendMessage(hwnd,SCI_EMPTYUNDOBUFFER,0,0);
UndoRedoSelectionMap(-1,NULL);
SendMessage(hwnd,SCI_CLEARALL,0,0);
SendMessage(hwnd,SCI_MARKERDELETEALL,(WPARAM)-1,0);
Encoding_SciSetCodePage(hwnd,encDest);
SendMessage(hwnd,SCI_ADDTEXT,cbText,(LPARAM)pchText);
SendMessage(hwnd,SCI_EMPTYUNDOBUFFER,0,0);
SendMessage(hwnd,SCI_SETUNDOCOLLECTION,1,0);
SendMessage(hwnd,SCI_SETUNDOCOLLECTION,(WPARAM)1,0);
SendMessage(hwnd,SCI_GOTOPOS,0,0);
SendMessage(hwnd,SCI_CHOOSECARETX,0,0);
@ -1145,9 +1143,11 @@ int Encoding_SciMappedCodePage(int iEncoding)
void Encoding_SciSetCodePage(HWND hwnd, int iEncoding)
{
int charset = SC_CHARSET_ANSI;
int cp = Encoding_SciMappedCodePage(iEncoding);
SendMessage(hwnd,SCI_SETCODEPAGE,(WPARAM)cp,0);
// charsets can be changed via styles schema
/*
int charset = SC_CHARSET_ANSI;
switch (cp) {
case 932:
charset = SC_CHARSET_SHIFTJIS;
@ -1165,8 +1165,8 @@ void Encoding_SciSetCodePage(HWND hwnd, int iEncoding)
charset = iDefaultCharSet;
break;
}
SendMessage(hwnd,SCI_SETCODEPAGE,(WPARAM)cp,0);
SendMessage(hwnd,SCI_STYLESETCHARACTERSET,(WPARAM)STYLE_DEFAULT,(LPARAM)charset);
*/
}
@ -1488,7 +1488,7 @@ BOOL EditLoadFile(
if (bLoadNFOasOEM)
{
PCWSTR pszExt = pszFile + StringCchLenN(pszFile,MAX_PATH) - 4;
if (pszExt >= pszFile && !(lstrcmpi(pszExt, L".nfo") && lstrcmpi(pszExt, L".diz")))
if (pszExt >= pszFile && !(StringCchCompareIX(pszExt,L".nfo") && StringCchCompareIX(pszExt,L".diz")))
bPreferOEM = TRUE;
}
@ -4790,17 +4790,17 @@ void EditSortLines(HWND hwnd,int iSortFlags)
if (!bIsRectangular) {
if (iAnchorPos > iCurPos) {
iCurPos = iSelStart;
iAnchorPos = iSelStart + StringCchLenNA(pmszResult,lenRes);
iAnchorPos = iSelStart + _StringCchLenNA(pmszResult,lenRes);
}
else {
iAnchorPos = iSelStart;
iCurPos = iSelStart + StringCchLenNA(pmszResult,lenRes);
iCurPos = iSelStart + _StringCchLenNA(pmszResult,lenRes);
}
}
SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0),0);
SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0),0);
SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)StringCchLenNA(pmszResult,lenRes),(LPARAM)pmszResult);
SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)_StringCchLenNA(pmszResult,lenRes),(LPARAM)pmszResult);
SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
LocalFree(pmszResult);
@ -5079,7 +5079,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
SendMessage(lpefr->hwnd,SCI_GETSELTEXT,0,(LPARAM)lpszSelection);
// First time you bring up find/replace dialog, copy content from clipboard to find box (but only if nothing is selected in the editor)
if (lstrcmpA( lpszSelection , "" ) == 0 && bFirstTime )
if (StringCchCompareNA(lpszSelection,cchSelection + 2,"",-1) == 0 && bFirstTime )
{
char *pClip = EditGetClipboardText(hwndEdit);
@ -5736,7 +5736,7 @@ BOOL EditReplace(HWND hwnd,LPCEDITFINDREPLACE lpefr)
if( lpefr->bWildcardSearch ) EscapeWildcards( szFind2 , lpefr );
if (lstrcmpA(lpefr->szReplace,"^c") == 0) {
if (StringCchCompareNA(lpefr->szReplace,FNDRPL_BUFFER,"^c",-1) == 0) {
iReplaceMsg = SCI_REPLACETARGET;
pszReplace2 = EditGetClipboardText(hwnd);
}
@ -5868,7 +5868,7 @@ void CompleteWord(HWND hwnd, BOOL autoInsert) {
pRoot = LocalAlloc(LPTR,cnt);
StringCchCopyNA(pRoot,cnt,pLine + iStartWordPos,cnt-1);
LocalFree(pLine);
iRootLen = StringCchLenNA(pRoot,cnt);
iRootLen = _StringCchLenNA(pRoot,cnt);
iDocLen = (int)SendMessage(hwnd, SCI_GETLENGTH, 0, 0);
@ -5900,8 +5900,8 @@ void CompleteWord(HWND hwnd, BOOL autoInsert) {
SendMessage(hwnd, SCI_GETTEXTRANGE, 0, (LPARAM)&tr);
while(p) {
int cmp = lstrcmpA(pWord, p->word);
if (!cmp) {
int cmp = StringCchCompareNA(pWord,wordLength + 2, p->word,-1);
if (cmp == 0) {
found = TRUE;
break;
} else if (cmp < 0) {
@ -5922,7 +5922,7 @@ void CompleteWord(HWND hwnd, BOOL autoInsert) {
}
iNumWords++;
iWListSize += StringCchLenNA(pWord,wordLength + 2) + 1;
iWListSize += _StringCchLenNA(pWord,wordLength + 2) + 1;
}
LocalFree(pWord);
}
@ -6085,9 +6085,11 @@ BOOL EditReplaceAll(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL bShowInfo)
(szFind2[0] == '^');
bRegexStartOrEndOfLine =
(lpefr->fuFlags & SCFIND_REGEXP &&
(!lstrcmpA(szFind2,"$") || !lstrcmpA(szFind2,"^") || !lstrcmpA(szFind2,"^$")));
(!StringCchCompareNA(szFind2,FNDRPL_BUFFER,"$",-1) ||
!StringCchCompareNA(szFind2,FNDRPL_BUFFER,"^",-1) ||
!StringCchCompareNA(szFind2,FNDRPL_BUFFER,"^$",-1)));
if (lstrcmpA(lpefr->szReplace,"^c") == 0) {
if (StringCchCompareNA(lpefr->szReplace,FNDRPL_BUFFER,"^c",-1) == 0) {
iReplaceMsg = SCI_REPLACETARGET;
pszReplace2 = EditGetClipboardText(hwnd);
}
@ -6211,9 +6213,11 @@ BOOL EditReplaceAllInSelection(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL bShowInfo
bRegexStartOfLine = (szFind2[0] == '^');
bRegexStartOrEndOfLine = (lpefr->fuFlags & SCFIND_REGEXP &&
(!lstrcmpA(szFind2,"$") || !lstrcmpA(szFind2,"^") || !lstrcmpA(szFind2,"^$")));
(!StringCchCompareNA(szFind2,FNDRPL_BUFFER,"$",-1) ||
!StringCchCompareNA(szFind2,FNDRPL_BUFFER,"^",-1) ||
!StringCchCompareNA(szFind2,FNDRPL_BUFFER,"^$",-1)));
if (lstrcmpA(lpefr->szReplace,"^c") == 0) {
if (StringCchCompareNA(lpefr->szReplace,FNDRPL_BUFFER,"^c",-1) == 0) {
iReplaceMsg = SCI_REPLACETARGET;
pszReplace2 = EditGetClipboardText(hwnd);
}
@ -6854,15 +6858,15 @@ INT_PTR CALLBACK EditInsertTagDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM l
wchIns[cchIns] = L'\0';
if (cchIns > 3 &&
lstrcmpi(wchIns,L"</base>") &&
lstrcmpi(wchIns,L"</bgsound>") &&
lstrcmpi(wchIns,L"</br>") &&
lstrcmpi(wchIns,L"</embed>") &&
lstrcmpi(wchIns,L"</hr>") &&
lstrcmpi(wchIns,L"</img>") &&
lstrcmpi(wchIns,L"</input>") &&
lstrcmpi(wchIns,L"</link>") &&
lstrcmpi(wchIns,L"</meta>")) {
StringCchCompareIN(wchIns,COUNTOF(wchIns),L"</base>",-1) &&
StringCchCompareIN(wchIns,COUNTOF(wchIns),L"</bgsound>",-1) &&
StringCchCompareIN(wchIns,COUNTOF(wchIns),L"</br>",-1) &&
StringCchCompareIN(wchIns,COUNTOF(wchIns),L"</embed>",-1) &&
StringCchCompareIN(wchIns,COUNTOF(wchIns),L"</hr>",-1) &&
StringCchCompareIN(wchIns,COUNTOF(wchIns),L"</img>",-1) &&
StringCchCompareIN(wchIns,COUNTOF(wchIns),L"</input>",-1) &&
StringCchCompareIN(wchIns,COUNTOF(wchIns),L"</link>",-1) &&
StringCchCompareIN(wchIns,COUNTOF(wchIns),L"</meta>",-1)) {
SetDlgItemTextW(hwnd,101,wchIns);
bClear = FALSE;
@ -7383,8 +7387,8 @@ BOOL FileVars_ParseStr(char* pszData,char* pszName,char* pszValue,int cchValue)
//
BOOL FileVars_IsUTF8(LPFILEVARS lpfv) {
if (lpfv->mask & FV_ENCODING) {
if (lstrcmpiA(lpfv->tchEncoding,"utf-8") == 0 ||
lstrcmpiA(lpfv->tchEncoding,"utf8") == 0)
if (StringCchCompareINA(lpfv->tchEncoding,COUNTOF(lpfv->tchEncoding),"utf-8",-1) == 0 ||
StringCchCompareINA(lpfv->tchEncoding,COUNTOF(lpfv->tchEncoding),"utf8",-1) == 0)
return(TRUE);
}
return(FALSE);
@ -7398,8 +7402,8 @@ BOOL FileVars_IsUTF8(LPFILEVARS lpfv) {
BOOL FileVars_IsNonUTF8(LPFILEVARS lpfv) {
if (lpfv->mask & FV_ENCODING) {
if (StringCchLenA(lpfv->tchEncoding) &&
lstrcmpiA(lpfv->tchEncoding,"utf-8") != 0 &&
lstrcmpiA(lpfv->tchEncoding,"utf8") != 0)
StringCchCompareINA(lpfv->tchEncoding,COUNTOF(lpfv->tchEncoding),"utf-8",-1) != 0 &&
StringCchCompareINA(lpfv->tchEncoding,COUNTOF(lpfv->tchEncoding),"utf8",-1) != 0)
return(TRUE);
}
return(FALSE);

View File

@ -18,6 +18,7 @@
#if !defined(_WIN32_WINNT)
#define _WIN32_WINNT 0x501
#endif
#define VC_EXTRALEAN 1
#include <windows.h>
#include <shlobj.h>
#include <shlwapi.h>
@ -172,7 +173,7 @@ HRESULT PrivateSetCurrentProcessExplicitAppUserModelID(PCWSTR AppID)
if (lstrlen(AppID) == 0)
return(S_OK);
if (lstrcmpi(AppID,L"(default)") == 0)
if (StringCchCompareIX(AppID,L"(default)") == 0)
return(S_OK);
pfnSetCurrentProcessExplicitAppUserModelID =
@ -422,7 +423,7 @@ BOOL SetWindowTitle(HWND hwnd,UINT uIDAppName,BOOL bIsElevated,UINT uIDUntitled,
{
if (iFormat < 2 && !PathIsRoot(lpszFile))
{
if (lstrcmp(szCachedFile,lpszFile) != 0) {
if (StringCchCompareN(szCachedFile,COUNTOF(szCachedFile),lpszFile,MAX_PATH) != 0) {
SHFILEINFO shfi;
StringCchCopy(szCachedFile,COUNTOF(szCachedFile),lpszFile);
if (SHGetFileInfo2(lpszFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME))
@ -1062,44 +1063,22 @@ void PathAbsoluteFromApp(LPWSTR lpszSrc,LPWSTR lpszDest,int cchDest,BOOL bExpand
//
// Name: PathIsLnkFile()
//
// Purpose: Determine wheter pszPath is a Windows Shell Link File by
// Purpose: Determine whether pszPath is a Windows Shell Link File by
// comparing the filename extension with L".lnk"
//
// Manipulates:
//
BOOL PathIsLnkFile(LPCWSTR pszPath)
{
//WCHAR *pszExt;
WCHAR tchResPath[256] = { L'\0' };
WCHAR tchResPath[MAX_PATH] = { L'\0' };
if (!pszPath || !*pszPath)
return FALSE;
/*pszExt = StrRChr(pszPath,NULL,L'.');
if (!pszExt)
if (StringCchCompareIX(PathFindExtension(pszPath),L".lnk"))
return FALSE;
if (!lstrcmpi(pszExt,L".lnk"))
return TRUE;
else
return FALSE;*/
//if (!lstrcmpi(PathFindExtension(pszPath),L".lnk"))
// return TRUE;
//else
// return FALSE;
if (lstrcmpi(PathFindExtension(pszPath),L".lnk"))
return FALSE;
else
return PathGetLnkPath(pszPath,tchResPath,COUNTOF(tchResPath));
}
@ -1674,8 +1653,8 @@ LPMRULIST MRU_Create(LPCWSTR pszRegKey,int iFlags,int iSize) {
return(pmru);
}
BOOL MRU_Destroy(LPMRULIST pmru) {
BOOL MRU_Destroy(LPMRULIST pmru)
{
int i;
for (i = 0; i < pmru->iSize; i++) {
if (pmru->pszItems[i])
@ -1686,16 +1665,16 @@ BOOL MRU_Destroy(LPMRULIST pmru) {
return(1);
}
int MRU_Compare(LPMRULIST pmru,LPCWSTR psz1,LPCWSTR psz2) {
int MRU_Compare(LPMRULIST pmru,LPCWSTR psz1,LPCWSTR psz2)
{
if (pmru->iFlags & MRU_NOCASE)
return(lstrcmpi(psz1,psz2));
return(StringCchCompareIX(psz1,psz2));
else
return(lstrcmp(psz1,psz2));
return(StringCchCompareX(psz1,psz2));
}
BOOL MRU_Add(LPMRULIST pmru,LPCWSTR pszNew) {
BOOL MRU_Add(LPMRULIST pmru,LPCWSTR pszNew)
{
int i;
for (i = 0; i < pmru->iSize; i++) {
if (MRU_Compare(pmru,pmru->pszItems[i],pszNew) == 0) {
@ -1714,7 +1693,7 @@ BOOL MRU_AddFile(LPMRULIST pmru,LPCWSTR pszFile,BOOL bRelativePath,BOOL bUnexpan
int i;
for (i = 0; i < pmru->iSize; i++) {
if (lstrcmpi(pmru->pszItems[i],pszFile) == 0) {
if (StringCchCompareIX(pmru->pszItems[i],pszFile) == 0) {
LocalFree(pmru->pszItems[i]);
break;
}
@ -1724,7 +1703,7 @@ BOOL MRU_AddFile(LPMRULIST pmru,LPCWSTR pszFile,BOOL bRelativePath,BOOL bUnexpan
else {
WCHAR wchItem[MAX_PATH] = { L'\0' };
PathAbsoluteFromApp(pmru->pszItems[i],wchItem,COUNTOF(wchItem),TRUE);
if (lstrcmpi(wchItem,pszFile) == 0) {
if (StringCchCompareIN(wchItem,COUNTOF(wchItem),pszFile,-1) == 0) {
LocalFree(pmru->pszItems[i]);
break;
}
@ -1770,7 +1749,7 @@ BOOL MRU_DeleteFileFromStore(LPMRULIST pmru,LPCWSTR pszFile) {
while (MRU_Enum(pmruStore,i,wchItem,COUNTOF(wchItem)) != -1) {
PathAbsoluteFromApp(wchItem,wchItem,COUNTOF(wchItem),TRUE);
if (lstrcmpi(wchItem,pszFile) == 0)
if (StringCchCompareIN(wchItem,COUNTOF(wchItem),pszFile,-1) == 0)
MRU_Delete(pmruStore,i);
else
i++;

View File

@ -260,20 +260,70 @@ VOID MinimizeWndToTray(HWND hWnd);
VOID RestoreWndFromTray(HWND hWnd);
//==== StrSafe strlen() =======================================================
inline int StringCchLenNA(LPCSTR s,size_t n) { size_t len; HRESULT hr = StringCchLengthA(s,n,&len); return (SUCCEEDED(hr) ? (int)len : 0); }
#define StringCchLenA(s) StringCchLenNA((s),COUNTOF(s))
inline int StringCchLenNW(LPCWSTR s, size_t n) { size_t len; HRESULT hr = StringCchLengthW(s,n,&len); return (SUCCEEDED(hr) ? (int)len : 0); }
#define StringCchLenW(s) StringCchLenNW((s),COUNTOF(s))
//==== StrSafe lstrlen() =======================================================
inline int _StringCchLenNA(LPCSTR s,size_t n) { size_t len; HRESULT hr = StringCchLengthA(s,n,&len); return (SUCCEEDED(hr) ? (int)len : 0); }
#define StringCchLenA(s) _StringCchLenNA((s),COUNTOF(s))
inline int _StringCchLenNW(LPCWSTR s,size_t n) { size_t len; HRESULT hr = StringCchLengthW(s,n,&len); return (SUCCEEDED(hr) ? (int)len : 0); }
#define StringCchLenW(s) _StringCchLenNW((s),COUNTOF(s))
#if defined(UNICODE) || defined(_UNICODE)
#define StringCchLen(s) StringCchLenNW((s),COUNTOF(s))
#define StringCchLenN(s,n) StringCchLenNW((s),(n))
#define StringCchLen(s) _StringCchLenNW((s),COUNTOF(s))
#define StringCchLenN(s,n) _StringCchLenNW((s),(n))
#else
#define StringCchLen(s) StringCchLenNA((s),COUNTOF(s))
#define StringCchLenN(s,n) StringCchLenNA((s),(n))
#define StringCchLen(s) _StringCchLenNA((s),COUNTOF(s))
#define StringCchLenN(s,n) _StringCchLenNA((s),(n))
#endif
//==== StrSafe lstrcmp(),lstrcmpi() =============================================
inline int _StringCchCmpNA(PCNZCH s1,int l1,PCNZCH s2,int l2)
{
return (CompareStringA(LOCALE_INVARIANT,0,s1,(l1 >= 0 ? _StringCchLenNA(s1,l1) : -1),
s2,(l2 >= 0 ? _StringCchLenNA(s2,l2) : -1)) - CSTR_EQUAL);
}
#define StringCchCompareA(s1,s2) _StringCchCmpNA((s1),COUNTOF(s1),(s2),COUNTOF(s2))
#define StringCchCompareNA(s1,l1,s2,l2) _StringCchCmpNA((s1),(l1),(s2),(l2))
#define StringCchCompareXA(s1,s2) _StringCchCmpNA((s1),-1,(s2),-1)
inline int _StringCchCmpINA(PCNZCH s1,int l1,PCNZCH s2,int l2)
{
return (CompareStringA(LOCALE_INVARIANT,NORM_IGNORECASE,s1,(l1 >= 0 ? _StringCchLenNA(s1,l1) : -1),
s2,(l2 >= 0 ? _StringCchLenNA(s2,l2) : -1)) - CSTR_EQUAL);
}
#define StringCchCompareIA(s1,s2) _StringCchCmpINA((s1),COUNTOF(s1),(s2),COUNTOF(s2))
#define StringCchCompareINA(s1,l1,s2,l2) _StringCchCmpINA((s1),(l1),(s2),(l2))
#define StringCchCompareIXA(s1,s2) _StringCchCmpINA((s1),-1,(s2),-1)
inline int _StringCchCmpNW(PCNZWCH s1,int l1,PCNZWCH s2,int l2) {
return (CompareStringW(LOCALE_INVARIANT,0,s1,(l1 >= 0 ? _StringCchLenNW(s1,l1) : -1),
s2,(l2 >= 0 ? _StringCchLenNW(s2,l2) : -1)) - CSTR_EQUAL);
}
#define StringCchCompareW(s1,s2) _StringCchCmpNW((s1),COUNTOF(s1),(s2),COUNTOF(s2))
#define StringCchCompareNW(s1,l1,s2,l2) _StringCchCmpNW((s1),(l1),(s2),(l2))
#define StringCchCompareXW(s1,s2) _StringCchCmpNW((s1),-1,(s2),-1)
inline int _StringCchCmpINW(PCNZWCH s1,int l1,PCNZWCH s2,int l2) {
return (CompareStringW(LOCALE_INVARIANT,NORM_IGNORECASE,s1,(l1 >= 0 ? _StringCchLenNW(s1,l1) : -1),
s2,(l2 >= 0 ? _StringCchLenNW(s2,l2) : -1)) - CSTR_EQUAL);
}
#define StringCchCompareIW(s1,s2) _StringCchCmpINW((s1),COUNTOF(s1),(s2),COUNTOF(s2))
#define StringCchCompareINW(s1,l1,s2,l2) _StringCchCmpINW((s1),(l1),(s2),(l2))
#define StringCchCompareIXW(s1,s2) _StringCchCmpINW((s1),-1,(s2),-1)
#if defined(UNICODE) || defined(_UNICODE)
#define StringCchCompare(s1,s2) StringCchCompareW((s1),(s2))
#define StringCchCompareN(s1,l1,s2,l2) StringCchCompareNW((s1),(l1),(s2),(l2))
#define StringCchCompareX(s1,s2) StringCchCompareXW((s1),(s2))
#define StringCchCompareI(s1,s2) StringCchCompareIW((s1),(s2))
#define StringCchCompareIN(s1,l1,s2,l2) StringCchCompareINW((s1),(l1),(s2),(l2))
#define StringCchCompareIX(s1,s2) StringCchCompareIXW((s1),(s2))
#else
#define StringCchCompare(s1,s2) StringCchCompareA((s1),(s2))
#define StringCchCompareN(s1,l1,s2,l2) StringCchCompareNA((s1),(l1),(s2),(l2))
#define StringCchCompareX(s1,s2) StringCchCompareXA((s1),(s2))
#define StringCchCompareI(s1,s2) StringCchCompareIA((s1),(s2))
#define StringCchCompareIN(s1,l1,s2,l2) StringCchCompareINA((s1),(l1),(s2),(l2))
#define StringCchCompareIX(s1,s2) StringCchCompareIXA((s1),(s2))
#endif
#endif //_NP3_HELPERS_H_

View File

@ -21,6 +21,8 @@
#define NTDDI_VERSION 0x05010100 /*NTDDI_WINXPSP1*/
#endif
#define VC_EXTRALEAN 1
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#include <commctrl.h>
#include <shlobj.h>
@ -1484,9 +1486,9 @@ LRESULT CALLBACK MainWndProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
}
else if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) >= 4) {
char tch[5] = "";
char tch[5] = { '\0' };
SendMessage(hwndEdit,SCI_GETTEXT,5,(LPARAM)tch);
if (lstrcmpiA(tch,".LOG") != 0) {
if (StringCchCompareXA(tch,".LOG") != 0) {
int iNewTopLine;
SendMessage(hwndEdit,SCI_SETSEL,iAnchorPos,iCurPos);
SendMessage(hwndEdit,SCI_ENSUREVISIBLE,(WPARAM)iDocTopLine,0);
@ -2425,9 +2427,9 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
if (FileLoad(TRUE,FALSE,TRUE,FALSE,tchCurFile2))
{
if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) >= 4) {
char tch[5] = "";
char tch[5] = { '\0' };
SendMessage(hwndEdit,SCI_GETTEXT,5,(LPARAM)tch);
if (lstrcmpiA(tch,".LOG") != 0) {
if (StringCchCompareXA(tch,".LOG") != 0) {
int iNewTopLine;
SendMessage(hwndEdit,SCI_SETSEL,iAnchorPos,iCurPos);
SendMessage(hwndEdit,SCI_ENSUREVISIBLE,(WPARAM)iDocTopLine,0);
@ -5531,15 +5533,15 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam)
tchIns[cchIns] = 0;
if (cchIns > 3 &&
lstrcmpiA(tchIns,"</base>") &&
lstrcmpiA(tchIns,"</bgsound>") &&
lstrcmpiA(tchIns,"</br>") &&
lstrcmpiA(tchIns,"</embed>") &&
lstrcmpiA(tchIns,"</hr>") &&
lstrcmpiA(tchIns,"</img>") &&
lstrcmpiA(tchIns,"</input>") &&
lstrcmpiA(tchIns,"</link>") &&
lstrcmpiA(tchIns,"</meta>"))
StringCchCompareINA(tchIns,COUNTOF(tchIns),"</base>",-1) &&
StringCchCompareINA(tchIns,COUNTOF(tchIns),"</bgsound>",-1) &&
StringCchCompareINA(tchIns,COUNTOF(tchIns),"</br>",-1) &&
StringCchCompareINA(tchIns,COUNTOF(tchIns),"</embed>",-1) &&
StringCchCompareINA(tchIns,COUNTOF(tchIns),"</hr>",-1) &&
StringCchCompareINA(tchIns,COUNTOF(tchIns),"</img>",-1) &&
StringCchCompareINA(tchIns,COUNTOF(tchIns),"</input>",-1) &&
StringCchCompareINA(tchIns,COUNTOF(tchIns),"</link>",-1) &&
StringCchCompareINA(tchIns,COUNTOF(tchIns),"</meta>",-1))
{
int token = BeginSelUndoAction();
SendMessage(hwndEdit,SCI_REPLACESEL,0,(LPARAM)tchIns);
@ -6284,12 +6286,12 @@ void ParseCommandLine()
{
// options
if (!bIsFileArg && lstrcmp(lp1,L"+") == 0) {
if (!bIsFileArg && (StringCchCompareN(lp1,len,L"+",-1) == 0)) {
flagMultiFileArg = 2;
bIsFileArg = TRUE;
}
else if (!bIsFileArg && lstrcmp(lp1,L"-") == 0) {
else if (!bIsFileArg && (StringCchCompareN(lp1,len,L"-",-1) == 0)) {
flagMultiFileArg = 1;
bIsFileArg = TRUE;
}
@ -6301,25 +6303,25 @@ void ParseCommandLine()
StrLTrim(lp1,L"-/");
// Encoding
if (lstrcmpi(lp1,L"ANSI") == 0 || lstrcmpi(lp1,L"A") == 0 || lstrcmpi(lp1,L"MBCS") == 0)
if (StringCchCompareIX(lp1,L"ANSI") == 0 || StringCchCompareIX(lp1,L"A") == 0 || StringCchCompareIX(lp1,L"MBCS") == 0)
flagSetEncoding = IDM_ENCODING_ANSI-IDM_ENCODING_ANSI + 1;
else if (lstrcmpi(lp1,L"UNICODE") == 0 || lstrcmpi(lp1,L"W") == 0)
else if (StringCchCompareIX(lp1,L"UNICODE") == 0 || StringCchCompareIX(lp1,L"W") == 0)
flagSetEncoding = IDM_ENCODING_UNICODE-IDM_ENCODING_ANSI + 1;
else if (lstrcmpi(lp1,L"UNICODEBE") == 0 || lstrcmpi(lp1,L"UNICODE-BE") == 0)
else if (StringCchCompareIX(lp1,L"UNICODEBE") == 0 || StringCchCompareIX(lp1,L"UNICODE-BE") == 0)
flagSetEncoding = IDM_ENCODING_UNICODEREV-IDM_ENCODING_ANSI + 1;
else if (lstrcmpi(lp1,L"UTF8") == 0 || lstrcmpi(lp1,L"UTF-8") == 0)
else if (StringCchCompareIX(lp1,L"UTF8") == 0 || StringCchCompareIX(lp1,L"UTF-8") == 0)
flagSetEncoding = IDM_ENCODING_UTF8-IDM_ENCODING_ANSI + 1;
else if (lstrcmpi(lp1,L"UTF8SIG") == 0 || lstrcmpi(lp1,L"UTF-8SIG") == 0 ||
lstrcmpi(lp1,L"UTF8SIGNATURE") == 0 || lstrcmpi(lp1,L"UTF-8SIGNATURE") == 0 ||
lstrcmpi(lp1,L"UTF8-SIGNATURE") == 0 || lstrcmpi(lp1,L"UTF-8-SIGNATURE") == 0)
else if (StringCchCompareIX(lp1,L"UTF8SIG") == 0 || StringCchCompareIX(lp1,L"UTF-8SIG") == 0 ||
StringCchCompareIX(lp1,L"UTF8SIGNATURE") == 0 || StringCchCompareIX(lp1,L"UTF-8SIGNATURE") == 0 ||
StringCchCompareIX(lp1,L"UTF8-SIGNATURE") == 0 || StringCchCompareIX(lp1,L"UTF-8-SIGNATURE") == 0)
flagSetEncoding = IDM_ENCODING_UTF8SIGN-IDM_ENCODING_ANSI + 1;
// EOL Mode
else if (lstrcmpi(lp1,L"CRLF") == 0 || lstrcmpi(lp1,L"CR+LF") == 0)
else if (StringCchCompareIX(lp1,L"CRLF") == 0 || StringCchCompareIX(lp1,L"CR+LF") == 0)
flagSetEOLMode = IDM_LINEENDINGS_CRLF-IDM_LINEENDINGS_CRLF + 1;
else if (lstrcmpi(lp1,L"LF") == 0)
else if (StringCchCompareIX(lp1,L"LF") == 0)
flagSetEOLMode = IDM_LINEENDINGS_LF-IDM_LINEENDINGS_CRLF + 1;
else if (lstrcmpi(lp1,L"CR") == 0)
else if (StringCchCompareIX(lp1,L"CR") == 0)
flagSetEOLMode = IDM_LINEENDINGS_CR-IDM_LINEENDINGS_CRLF + 1;
// Shell integration
@ -6784,7 +6786,7 @@ int FindIniFile() {
GetModuleFileName(NULL,tchModule,COUNTOF(tchModule));
if (StringCchLen(szIniFile)) {
if (lstrcmpi(szIniFile,L"*?") == 0)
if (StringCchCompareIX(szIniFile,L"*?") == 0)
return(0);
else {
if (!CheckIniFile(szIniFile,tchModule)) {
@ -6828,7 +6830,7 @@ int FindIniFile() {
int TestIniFile() {
if (lstrcmpi(szIniFile,L"*?") == 0) {
if (StringCchCompareIX(szIniFile,L"*?") == 0) {
StringCchCopy(szIniFile2,COUNTOF(szIniFile2),L"");
StringCchCopy(szIniFile,COUNTOF(szIniFile),L"");
return(0);
@ -7219,6 +7221,7 @@ int UndoRedoSelectionMap(int token, UndoRedoSelection_t* selection)
if (selection == NULL) {
// reset / clear
SendMessage(hwndEdit,SCI_EMPTYUNDOBUFFER,0,0);
if (UndoRedoSelectionUTArray != NULL) {
utarray_clear(UndoRedoSelectionUTArray);
utarray_init(UndoRedoSelectionUTArray,&UndoRedoSelection_icd);
@ -7227,6 +7230,10 @@ int UndoRedoSelectionMap(int token, UndoRedoSelection_t* selection)
return -1;
}
if (!(BOOL)SendMessage(hwndEdit,SCI_GETUNDOCOLLECTION,0,0)) {
return -1;
}
// get or set map item request ?
if (token >= 0 && utoken < iTokenCnt) {
if (selection->anchorPos_undo < 0) {
@ -7435,7 +7442,7 @@ BOOL FileLoad(BOOL bDontSave,BOOL bNew,BOOL bReload,BOOL bNoEncDetect,LPCWSTR lp
if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) >= 4) {
char tchLog[5] = "";
SendMessage(hwndEdit,SCI_GETTEXT,5,(LPARAM)tchLog);
if (lstrcmpA(tchLog,".LOG") == 0) {
if (StringCchCompareXA(tchLog,".LOG") == 0) {
EditJumpTo(hwndEdit,-1,0);
SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0);
SendMessage(hwndEdit,SCI_NEWLINE,0,0);
@ -7449,7 +7456,7 @@ BOOL FileLoad(BOOL bDontSave,BOOL bNew,BOOL bReload,BOOL bNoEncDetect,LPCWSTR lp
}
// consistent settings file handling (if loaded in editor)
bEnableSaveSettings = (lstrcmpi(szCurFile, szIniFile) == 0) ? FALSE : TRUE;
bEnableSaveSettings = (StringCchCompareI(szCurFile, szIniFile) == 0) ? FALSE : TRUE;
UpdateSettingsCmds();
// Show warning: Unicode file loaded as ANSI
@ -7733,7 +7740,7 @@ BOOL CALLBACK EnumWndProc(HWND hwnd,LPARAM lParam)
if (GetClassName(hwnd,szClassName,COUNTOF(szClassName)))
if (lstrcmpi(szClassName,wchWndClass) == 0) {
if (StringCchCompareI(szClassName,wchWndClass) == 0) {
DWORD dwReuseLock = GetDlgItemInt(hwnd,IDC_REUSELOCK,NULL,FALSE);
if (GetTickCount() - dwReuseLock >= REUSEWINDOWLOCKTIMEOUT) {
@ -7754,7 +7761,7 @@ BOOL CALLBACK EnumWndProc2(HWND hwnd,LPARAM lParam)
if (GetClassName(hwnd,szClassName,COUNTOF(szClassName)))
if (lstrcmpi(szClassName,wchWndClass) == 0) {
if (StringCchCompareI(szClassName,wchWndClass) == 0) {
DWORD dwReuseLock = GetDlgItemInt(hwnd,IDC_REUSELOCK,NULL,FALSE);
if (GetTickCount() - dwReuseLock >= REUSEWINDOWLOCKTIMEOUT) {
@ -7765,7 +7772,7 @@ BOOL CALLBACK EnumWndProc2(HWND hwnd,LPARAM lParam)
bContinue = FALSE;
GetDlgItemText(hwnd,IDC_FILENAME,tchFileName,COUNTOF(tchFileName));
if (lstrcmpi(tchFileName,lpFileArg) == 0)
if (StringCchCompareIN(tchFileName,COUNTOF(tchFileName),lpFileArg,-1) == 0)
*(HWND*)lParam = hwnd;
else
bContinue = TRUE;

View File

@ -17,6 +17,7 @@
#if !defined(_WIN32_WINNT)
#define _WIN32_WINNT 0x501
#endif
#define VC_EXTRALEAN 1
#include <windows.h>
#include <commctrl.h>
#include <shlwapi.h>

View File

@ -16,6 +16,7 @@
#if !defined(_WIN32_WINNT)
#define _WIN32_WINNT 0x501
#endif
#define VC_EXTRALEAN 1
#include <windows.h>
#include <commctrl.h>
#include <commdlg.h>
@ -3424,7 +3425,7 @@ PEDITLEXER __fastcall Style_MatchLexer(LPCWSTR lpszMatch,BOOL bCheckNames)
else
p2 = StrEnd(p1);
StrTrim(p1,L" .");
if (lstrcmpi(p1,lpszMatch) == 0)
if (StringCchCompareIX(p1,lpszMatch) == 0)
return(pLexArray[i]);
p1 = p2+1;
}
@ -3468,14 +3469,15 @@ void Style_SetLexerFromFile(HWND hwnd,LPCWSTR lpszFile)
UINT cp = Encoding_SciGetCodePage(hwnd);
MultiByteToWideCharStrg(cp,fvCurFile.tchMode,wchMode);
if (!fNoCGIGuess && (lstrcmpi(wchMode,L"cgi") == 0 || lstrcmpi(wchMode,L"fcgi") == 0)) {
if (!fNoCGIGuess && (StringCchCompareIN(wchMode,COUNTOF(wchMode),L"cgi",-1) == 0 ||
StringCchCompareIN(wchMode,COUNTOF(wchMode),L"fcgi",-1) == 0)) {
char tchText[256] = { L'\0' };
SendMessage(hwnd,SCI_GETTEXT,(WPARAM)COUNTOF(tchText)-1,(LPARAM)tchText);
StrTrimA(tchText," \t\n\r");
pLexSniffed = Style_SniffShebang(tchText);
if (pLexSniffed) {
if (Encoding_Current(CPI_GET) != g_DOSEncoding || pLexSniffed != &lexDefault || (
lstrcmpi(lpszExt,L"nfo") && lstrcmpi(lpszExt,L"diz"))) {
StringCchCompareIX(lpszExt,L"nfo") && StringCchCompareIX(lpszExt,L"diz"))) {
// Although .nfo and .diz were removed from the default lexer's
// default extensions list, they may still presist in the user's INI
pLexNew = pLexSniffed;
@ -3506,7 +3508,7 @@ void Style_SetLexerFromFile(HWND hwnd,LPCWSTR lpszFile)
if (*lpszExt == L'.')
lpszExt++;
if (!fNoCGIGuess && (lstrcmpi(lpszExt,L"cgi") == 0 || lstrcmpi(lpszExt,L"fcgi") == 0)) {
if (!fNoCGIGuess && (StringCchCompareIX(lpszExt,L"cgi") == 0 || StringCchCompareIX(lpszExt,L"fcgi") == 0)) {
char tchText[256] = { L'\0' };
SendMessage(hwnd,SCI_GETTEXT,(WPARAM)COUNTOF(tchText)-1,(LPARAM)tchText);
StrTrimA(tchText," \t\n\r");
@ -3517,7 +3519,7 @@ void Style_SetLexerFromFile(HWND hwnd,LPCWSTR lpszFile)
}
}
if (!bFound && lstrcmpi(PathFindFileName(lpszFile),L"cmakelists.txt") == 0) {
if (!bFound && StringCchCompareIX(PathFindFileName(lpszFile),L"cmakelists.txt") == 0) {
pLexNew = &lexCmake;
bFound = TRUE;
}
@ -3533,19 +3535,19 @@ void Style_SetLexerFromFile(HWND hwnd,LPCWSTR lpszFile)
}
if (!bFound && bAutoSelect &&
lstrcmpi(PathFindFileName(lpszFile),L"makefile") == 0) {
StringCchCompareIX(PathFindFileName(lpszFile),L"makefile") == 0) {
pLexNew = &lexMAK;
bFound = TRUE;
}
if (!bFound && bAutoSelect &&
lstrcmpi(PathFindFileName(lpszFile),L"rakefile") == 0) {
StringCchCompareIX(PathFindFileName(lpszFile),L"rakefile") == 0) {
pLexNew = &lexRUBY;
bFound = TRUE;
}
if (!bFound && bAutoSelect &&
lstrcmpi(PathFindFileName(lpszFile),L"mozconfig") == 0) {
StringCchCompareIX(PathFindFileName(lpszFile),L"mozconfig") == 0) {
pLexNew = &lexBASH;
bFound = TRUE;
}
@ -3738,7 +3740,7 @@ BOOL Style_StrGetFont(LPCWSTR lpszStyle,LPWSTR lpszFont,int cchFont)
*p = L'\0';
TrimString(tch);
if (lstrcmpi(tch,L"Default") == 0)
if (StringCchCompareIN(tch,COUNTOF(tch),L"Default",-1) == 0)
{
if (fIsConsolasAvailable)
StringCchCopyN(lpszFont,cchFont,L"Consolas",cchFont);
@ -3771,10 +3773,10 @@ BOOL Style_StrGetFontQuality(LPCWSTR lpszStyle,LPWSTR lpszQuality,int cchQuality
if (p)
*p = L'\0';
TrimString(tch);
if (lstrcmpi(tch,L"none") == 0 ||
lstrcmpi(tch,L"standard") == 0 ||
lstrcmpi(tch,L"cleartype") == 0 ||
lstrcmpi(tch,L"default") == 0) {
if (StringCchCompareIN(tch,COUNTOF(tch),L"none",-1) == 0 ||
StringCchCompareIN(tch,COUNTOF(tch),L"standard",-1) == 0 ||
StringCchCompareIN(tch,COUNTOF(tch),L"cleartype",-1) == 0 ||
StringCchCompareIN(tch,COUNTOF(tch),L"default",-1) == 0) {
StringCchCopyN(lpszQuality,cchQuality,tch,COUNTOF(tch));
return TRUE;
}
@ -4277,25 +4279,25 @@ void Style_SetFontQuality(HWND hwnd,LPCWSTR lpszStyle) {
WCHAR tch[64] = { L'\0' };
if (Style_StrGetFontQuality(lpszStyle,tch,COUNTOF(tch))) {
if (lstrcmpi(tch,L"default") == 0)
if (StringCchCompareIN(tch,COUNTOF(tch),L"default",-1) == 0)
wQuality = SC_EFF_QUALITY_DEFAULT;
else if (lstrcmpi(tch,L"none") == 0)
else if (StringCchCompareIN(tch,COUNTOF(tch),L"none",-1) == 0)
wQuality = SC_EFF_QUALITY_NON_ANTIALIASED;
else if (lstrcmpi(tch,L"standard") == 0)
else if (StringCchCompareIN(tch,COUNTOF(tch),L"standard",-1) == 0)
wQuality = SC_EFF_QUALITY_ANTIALIASED;
else if (lstrcmpi(tch,L"cleartype") == 0)
else if (StringCchCompareIN(tch,COUNTOF(tch),L"cleartype",-1) == 0)
wQuality = SC_EFF_QUALITY_LCD_OPTIMIZED;
}
else { // undefined, use general settings, except for special fonts
if (Style_StrGetFont(lpszStyle,tch,COUNTOF(tch))) {
if (lstrcmpi(tch,L"Calibri") == 0 ||
lstrcmpi(tch,L"Cambria") == 0 ||
lstrcmpi(tch,L"Candara") == 0 ||
lstrcmpi(tch,L"Consolas") == 0 ||
lstrcmpi(tch,L"Constantia") == 0 ||
lstrcmpi(tch,L"Corbel") == 0 ||
lstrcmpi(tch,L"Segoe UI") == 0 ||
lstrcmpi(tch,L"Source Code Pro") == 0)
if (StringCchCompareIN(tch,COUNTOF(tch),L"Calibri",-1) == 0 ||
StringCchCompareIN(tch,COUNTOF(tch),L"Cambria",-1) == 0 ||
StringCchCompareIN(tch,COUNTOF(tch),L"Candara",-1) == 0 ||
StringCchCompareIN(tch,COUNTOF(tch),L"Consolas",-1) == 0 ||
StringCchCompareIN(tch,COUNTOF(tch),L"Constantia",-1) == 0 ||
StringCchCompareIN(tch,COUNTOF(tch),L"Corbel",-1) == 0 ||
StringCchCompareIN(tch,COUNTOF(tch),L"Segoe UI",-1) == 0 ||
StringCchCompareIN(tch,COUNTOF(tch),L"Source Code Pro",-1) == 0)
wQuality = SC_EFF_QUALITY_LCD_OPTIMIZED;
}
}
@ -4459,7 +4461,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP
// Add lexers
for (i = 0; i < COUNTOF(pLexArray); i++)
{
if (!found && lstrcmp(pLexArray[i]->pszName,pLexCurrent->pszName) == 0)
if (!found && (StringCchCompareX(pLexArray[i]->pszName,pLexCurrent->pszName) == 0))
{
found = 1;
currentLex = Style_AddLexerToTreeView(hwndTV,pLexArray[i]);
@ -4757,8 +4759,8 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP
WCHAR tch[256] = { L'\0' };
GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch));
if (Style_SelectFont(hwnd,tch,COUNTOF(tch),
lstrcmpi(pCurrentStyle->pszName,L"Default Style") == 0 ||
lstrcmpi(pCurrentStyle->pszName,L"2nd Default Style") == 0)) {
StringCchCompareIX(pCurrentStyle->pszName,L"Default Style") == 0 ||
StringCchCompareIX(pCurrentStyle->pszName,L"2nd Default Style") == 0)) {
SetDlgItemText(hwnd,IDC_STYLEEDIT,tch);
//CheckDlgButton(hwnd,IDC_STYLEBOLD,(Style_StrGetAttribute(tch,L"bold") ? BST_CHECKED : BST_UNCHECKED));
//CheckDlgButton(hwnd,IDC_STYLEITALIC,(Style_StrGetAttribute(tch,L"italic") ? BST_CHECKED : BST_UNCHECKED));
@ -5097,7 +5099,7 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR
for (i = 0; i < lvItems; i++) {
lvi.iItem = i;
ListView_GetItem(hwndLV,&lvi);;
if (lstrcmp(((PEDITLEXER)lvi.lParam)->pszName,pLexCurrent->pszName) == 0) {
if (StringCchCompareX(((PEDITLEXER)lvi.lParam)->pszName,pLexCurrent->pszName) == 0) {
ListView_SetItemState(hwndLV,i,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED);
ListView_EnsureVisible(hwndLV,i,FALSE);
if (iDefaultLexer == i) {