Merge pull request #159 from RaiKoHoff/RegEx_Engine

major refactoring of find/repl regarding regex evaluation
This commit is contained in:
Derick Payne 2017-10-30 11:16:03 +02:00 committed by GitHub
commit 52122cb477
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 5269 additions and 770 deletions

View File

@ -271,6 +271,7 @@
<ClCompile Include="win32\ScintillaWin.cxx" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="deelx\deelx.h" />
<ClInclude Include="deelx\deelx64.h" />
<ClInclude Include="include\ILexer.h" />
<ClInclude Include="include\ILoader.h" />

View File

@ -446,6 +446,9 @@
<ClInclude Include="include\ILoader.h">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="deelx\deelx.h">
<Filter>deelx</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="deelx\doc\deelx_en.chm">

View File

@ -43,6 +43,7 @@
#include "CharClassify.h"
#include "Document.h"
// ---------------------------------------------------------------
//#include "deelx.h" // DEELX - Regular Expression Engine (v1.2)
#include "deelx64.h" // DEELX - Regular Expression Engine (v1.3)
// ---------------------------------------------------------------
@ -129,7 +130,7 @@ long DeelxRegexSearch::FindText(Document* doc,int minPos,int maxPos,const char *
bool caseSensitive,bool word,bool wordStart,int searchFlags,int *length)
{
const bool right2left = false; // always left-to-right match mode
const bool extended = false; // ignore spaces and use '#' as line-comment)
const bool extended = false; // ignore spaces and use '#' as line-comment)
// Range endpoints should not be inside DBCS characters, but just in case, move them.
minPos = doc->MovePositionOutsideChar(minPos,1,false);
@ -140,6 +141,7 @@ long DeelxRegexSearch::FindText(Document* doc,int minPos,int maxPos,const char *
int compileFlags = deelx::NO_FLAG;
compileFlags |= (deelx::MULTILINE | deelx::GLOBAL); // the .(dot) does not match line-breaks
//compileFlags |= (deelx::SINGLELINE | deelx::MULTILINE | deelx::GLOBAL); // the .(dot) also matches line-breaks
compileFlags |= (extended) ? deelx::EXTENDED : deelx::NO_FLAG;
compileFlags |= (!caseSensitive) ? deelx::IGNORECASE : deelx::NO_FLAG;
compileFlags |= (right2left) ? deelx::RIGHTTOLEFT : deelx::NO_FLAG;

4673
scintilla/deelx/deelx.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -10,10 +10,14 @@
// Author: Ê·ÊÙΰ (sswater shi)
// sswater@gmail.com
//
// $Revision $
//
// + adaption for 64-bit usage: "basetsd : INT_PTR" replaces int-pointer arithmetic and buffer indexes
// + Cppcheck cleanup
//
// Good Overview:
// https://www.regular-expressions.info/
//
#ifndef __DEELX_REGEXP64__H__
#define __DEELX_REGEXP64__H__

View File

@ -363,7 +363,7 @@ INT_PTR CALLBACK RunDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
if (GetOpenFileName(&ofn)) {
PathQuoteSpaces(szFile);
if (StringCchLen(szArg2))
if (StringCchLen(szArg2,COUNTOF(szArg2)))
{
StringCchCat(szFile,COUNTOF(szFile),L" ");
StringCchCat(szFile,COUNTOF(szFile),szArg2);
@ -383,7 +383,7 @@ INT_PTR CALLBACK RunDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
if (GetDlgItemText(hwnd,IDC_COMMANDLINE,args,MAX_PATH))
if (ExtractFirstArgument(args,args,NULL,MAX_PATH))
if (StringCchLen(args))
if (StringCchLenW(args,COUNTOF(args)))
bEnableOK = TRUE;
EnableWindow(GetDlgItem(hwnd,IDOK),bEnableOK);
@ -410,7 +410,7 @@ INT_PTR CALLBACK RunDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
bQuickExit = TRUE;
}
if (StringCchLen(szCurFile)) {
if (StringCchLenW(szCurFile,COUNTOF(szCurFile))) {
StringCchCopy(wchDirectory,COUNTOF(wchDirectory),szCurFile);
PathRemoveFileSpec(wchDirectory);
}
@ -644,7 +644,7 @@ BOOL OpenWithDlg(HWND hwnd,LPCWSTR lpstrFile)
WCHAR szParam[MAX_PATH] = { L'\0' };
WCHAR wchDirectory[MAX_PATH] = { L'\0' };
if (StringCchLen(szCurFile)) {
if (StringCchLenW(szCurFile,COUNTOF(szCurFile))) {
StringCchCopy(wchDirectory,COUNTOF(wchDirectory),szCurFile);
PathRemoveFileSpec(wchDirectory);
}
@ -2365,7 +2365,7 @@ INT_PTR InfoBox(int iType,LPCWSTR lpstrSetting,int uidMessage,...)
ib.lpstrMessage = LocalAlloc(LPTR, HUGE_BUFFER * sizeof(WCHAR));
StringCchVPrintfW(ib.lpstrMessage,HUGE_BUFFER,wchFormat,(LPVOID)((PUINT_PTR)&uidMessage + 1));
ib.lpstrSetting = (LPWSTR)lpstrSetting;
ib.bDisableCheckBox = (StringCchLen(szIniFile) == 0 || lstrlen(lpstrSetting) == 0 || iMode == 2) ? TRUE : FALSE;
ib.bDisableCheckBox = (StringCchLenW(szIniFile,COUNTOF(szIniFile)) == 0 || lstrlen(lpstrSetting) == 0 || iMode == 2) ? TRUE : FALSE;
if (iType == MBYESNO)
idDlg = IDD_INFOBOX2;

View File

@ -875,12 +875,12 @@ BOOL DirList_SelectItem(HWND hwnd,LPCWSTR lpszDisplayName,LPCWSTR lpszFullPath)
int i = -1;
if (!lpszFullPath || !StringCchLenN(lpszFullPath,MAX_PATH))
if (!lpszFullPath || !StringCchLen(lpszFullPath,MAX_PATH))
return(FALSE);
else
GetShortPathName(lpszFullPath,szShortPath,MAX_PATH);
if (!lpszDisplayName || !StringCchLenN(lpszDisplayName,MAX_PATH))
if (!lpszDisplayName || !StringCchLen(lpszDisplayName,MAX_PATH))
SHGetFileInfo(lpszFullPath,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME);
else
StringCchCopyN(shfi.szDisplayName,COUNTOF(shfi.szDisplayName),lpszDisplayName,MAX_PATH);
@ -896,7 +896,7 @@ BOOL DirList_SelectItem(HWND hwnd,LPCWSTR lpszDisplayName,LPCWSTR lpszFullPath)
DirList_GetItem(hwnd,i,&dli);
GetShortPathName(dli.szFileName,dli.szFileName,MAX_PATH);
if (!StringCchCompareI(dli.szFileName,szShortPath))
if (!StringCchCompareIN(dli.szFileName,COUNTOF(dli.szFileName),szShortPath,COUNTOF(szShortPath)))
{
ListView_SetItemState(hwnd,i,LVIS_FLAGS,LVIS_FLAGS);
ListView_EnsureVisible(hwnd,i,FALSE);
@ -928,7 +928,7 @@ void DirList_CreateFilter(PDL_FILTER pdlf,LPCWSTR lpszFileSpec,
StringCchCopyN(pdlf->tFilterBuf,COUNTOF(pdlf->tFilterBuf),lpszFileSpec,DL_FILTER_BUFSIZE);
pdlf->bExcludeFilter = bExcludeFilter;
if (!StringCchCompareX(lpszFileSpec,L"*.*") || !StringCchLenN(lpszFileSpec,DL_FILTER_BUFSIZE))
if (!StringCchCompareX(lpszFileSpec,L"*.*") || !StringCchLen(lpszFileSpec,DL_FILTER_BUFSIZE))
return;
pdlf->nCount = 1;

1101
src/Edit.c

File diff suppressed because it is too large Load Diff

View File

@ -103,6 +103,7 @@ HWND EditFindReplaceDlg(HWND,LPCEDITFINDREPLACE,BOOL);
BOOL EditFindNext(HWND,LPCEDITFINDREPLACE,BOOL);
BOOL EditFindPrev(HWND,LPCEDITFINDREPLACE,BOOL);
BOOL EditReplace(HWND,LPCEDITFINDREPLACE);
int EditReplaceAllInRange(HWND,LPCEDITFINDREPLACE,BOOL,int,int);
BOOL EditReplaceAll(HWND,LPCEDITFINDREPLACE,BOOL);
BOOL EditReplaceAllInSelection(HWND,LPCEDITFINDREPLACE,BOOL);
BOOL EditLinenumDlg(HWND);

View File

@ -94,19 +94,19 @@ int IniSectionGetString(
if (p) {
StringCchCopy(tch,COUNTOF(tch),lpName);
StringCchCat(tch,COUNTOF(tch),L"=");
ich = StringCchLen(tch);
ich = StringCchLenW(tch,COUNTOF(tch));
while (*p) {
if (StrCmpNI(p,tch,ich) == 0) {
StringCchCopyN(lpReturnedString,cchReturnedString,p + ich,cchReturnedString);
return(StringCchLenN(lpReturnedString,cchReturnedString));
return(StringCchLen(lpReturnedString,cchReturnedString));
}
else
p = StrEnd(p) + 1;
}
}
StringCchCopyN(lpReturnedString,cchReturnedString,lpDefault,cchReturnedString);
return(StringCchLenN(lpReturnedString,cchReturnedString));
return(StringCchLen(lpReturnedString,cchReturnedString));
}
@ -123,7 +123,7 @@ int IniSectionGetInt(
if (p) {
StringCchCopy(tch,COUNTOF(tch),lpName);
StringCchCat(tch,COUNTOF(tch),L"=");
ich = StringCchLen(tch);
ich = StringCchLenW(tch,COUNTOF(tch));
while (*p) {
if (StrCmpNI(p,tch,ich) == 0) {
@ -152,7 +152,7 @@ UINT IniSectionGetUInt(
if (p) {
StringCchCopy(tch,COUNTOF(tch),lpName);
StringCchCat(tch,COUNTOF(tch),L"=");
ich = StringCchLen(tch);
ich = StringCchLenW(tch,COUNTOF(tch));
while (*p) {
if (StrCmpNI(p, tch, ich) == 0) {
@ -494,7 +494,7 @@ BOOL SetWindowTitle(HWND hwnd,UINT uIDAppName,BOOL bIsElevated,UINT uIDUntitled,
StringCchCat(szTitle,COUNTOF(szTitle),szExcrptQuot);
}
else if (StringCchLenN(lpszFile,MAX_PATH))
else if (StringCchLen(lpszFile,MAX_PATH))
{
if (iFormat < 2 && !PathIsRoot(lpszFile))
{
@ -509,7 +509,7 @@ BOOL SetWindowTitle(HWND hwnd,UINT uIDAppName,BOOL bIsElevated,UINT uIDUntitled,
StringCchCat(szTitle,COUNTOF(szTitle),szCachedDisplayName);
if (iFormat == 1) {
WCHAR tchPath[MAX_PATH] = { L'\0' };
StringCchCopyN(tchPath,COUNTOF(tchPath),lpszFile,StringCchLenN(lpszFile,MAX_PATH));
StringCchCopyN(tchPath,COUNTOF(tchPath),lpszFile,StringCchLen(lpszFile,MAX_PATH));
PathRemoveFileSpec(tchPath);
StringCchCat(szTitle,COUNTOF(szTitle),L" [");
StringCchCat(szTitle,COUNTOF(szTitle),tchPath);
@ -1065,7 +1065,7 @@ int FormatString(LPWSTR lpOutput,int nOutput,UINT uIdFormat,...)
LocalFree(p);
return StringCchLenN(lpOutput,nOutput);
return StringCchLen(lpOutput,nOutput);
}
@ -1256,7 +1256,7 @@ BOOL PathGetLnkPath(LPCWSTR pszLnkFile,LPWSTR pszResPath,int cchResPath)
}
// This additional check seems reasonable
if (!StringCchLenN(pszResPath,cchResPath))
if (!StringCchLen(pszResPath,cchResPath))
bSucceeded = FALSE;
if (bSucceeded) {
@ -1329,7 +1329,7 @@ BOOL PathCreateDeskLnk(LPCWSTR pszDocument)
BOOL bSucceeded = FALSE;
BOOL fMustCopy;
if (!pszDocument || StringCchLenN(pszDocument,MAX_PATH) == 0)
if (!pszDocument || StringCchLen(pszDocument,MAX_PATH) == 0)
return TRUE;
// init strings
@ -1397,7 +1397,7 @@ BOOL PathCreateFavLnk(LPCWSTR pszName,LPCWSTR pszTarget,LPCWSTR pszDir)
IShellLink *psl;
BOOL bSucceeded = FALSE;
if (!pszName || StringCchLenN(pszName,MAX_PATH) == 0)
if (!pszName || StringCchLen(pszName,MAX_PATH) == 0)
return TRUE;
StringCchCopy(tchLnkFileName,COUNTOF(tchLnkFileName),pszDir);
@ -1653,14 +1653,14 @@ DWORD_PTR SHGetFileInfo2(LPCWSTR pszPath,DWORD dwFileAttributes,
if (PathFileExists(pszPath)) {
DWORD_PTR dw = SHGetFileInfo(pszPath,dwFileAttributes,psfi,cbFileInfo,uFlags);
if (StringCchLen(psfi->szDisplayName) < StringCchLenN(PathFindFileName(pszPath),MAX_PATH))
if (StringCchLenW(psfi->szDisplayName,COUNTOF(psfi->szDisplayName)) < StringCchLen(PathFindFileName(pszPath),MAX_PATH))
StringCchCat(psfi->szDisplayName,COUNTOF(psfi->szDisplayName),PathFindExtension(pszPath));
return(dw);
}
else {
DWORD_PTR dw = SHGetFileInfo(pszPath,FILE_ATTRIBUTE_NORMAL,psfi,cbFileInfo,uFlags|SHGFI_USEFILEATTRIBUTES);
if (StringCchLen(psfi->szDisplayName) < StringCchLenN(PathFindFileName(pszPath),MAX_PATH))
if (StringCchLenW(psfi->szDisplayName,COUNTOF(psfi->szDisplayName)) < StringCchLen(PathFindFileName(pszPath),MAX_PATH))
StringCchCat(psfi->szDisplayName,COUNTOF(psfi->szDisplayName),PathFindExtension(pszPath));
return(dw);
}
@ -1953,7 +1953,7 @@ int MRU_Enum(LPMRULIST pmru,int iIndex,LPWSTR pszItem,int cchItem) {
return(-1);
else {
StringCchCopyN(pszItem,cchItem,pmru->pszItems[iIndex],cchItem);
return(StringCchLenN(pszItem,cchItem));
return(StringCchLen(pszItem,cchItem));
}
}
}
@ -2207,7 +2207,7 @@ DLGTEMPLATE* LoadThemedDialogTemplate(LPCTSTR lpDialogTemplateID,HINSTANCE hInst
else
pTemplate->style |= DS_SHELLFONT;
cbNew = cbFontAttr + ((StringCchLen(wchFaceName) + 1) * sizeof(WCHAR));
cbNew = cbFontAttr + ((StringCchLenW(wchFaceName,COUNTOF(wchFaceName)) + 1) * sizeof(WCHAR));
pbNew = (BYTE*)wchFaceName;
pb = DialogTemplate_GetFontSizeField(pTemplate);

View File

@ -32,6 +32,8 @@
extern WCHAR szIniFile[MAX_PATH];
__inline void swapi(int a, int b) { int t = a; a = b; b = t; }
#define IniGetString(lpSection,lpName,lpDefault,lpReturnedStr,nSize) \
GetPrivateProfileString(lpSection,lpName,(lpDefault),(lpReturnedStr),(nSize),szIniFile)
#define IniGetInt(lpSection,lpName,nDefault) \
@ -285,51 +287,43 @@ WCHAR* _StrCutIW(WCHAR*,const WCHAR*);
#endif
//==== 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))
inline int StringCchLenA(LPCSTR s,size_t n) { size_t len; HRESULT hr = StringCchLengthA(s,n,&len); return (SUCCEEDED(hr) ? (int)len : 0); }
inline int StringCchLenW(LPCWSTR s,size_t n) { size_t len; HRESULT hr = StringCchLengthW(s,n,&len); return (SUCCEEDED(hr) ? (int)len : 0); }
#if defined(UNICODE) || defined(_UNICODE)
#define StringCchLen(s) _StringCchLenNW((s),COUNTOF(s))
#define StringCchLenN(s,n) _StringCchLenNW((s),(n))
#define StringCchLen(s,n) StringCchLenW((s),(n))
#else
#define StringCchLen(s) _StringCchLenNA((s),COUNTOF(s))
#define StringCchLenN(s,n) _StringCchLenNA((s),(n))
#define StringCchLen(s,n) StringCchLenA((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);
return (CompareStringA(LOCALE_INVARIANT,0,s1,(l1 >= 0 ? StringCchLenA(s1,l1) : -1),
s2,(l2 >= 0 ? StringCchLenA(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);
return (CompareStringA(LOCALE_INVARIANT,NORM_IGNORECASE,s1,(l1 >= 0 ? StringCchLenA(s1,l1) : -1),
s2,(l2 >= 0 ? StringCchLenA(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);
return (CompareStringW(LOCALE_INVARIANT,0,s1,(l1 >= 0 ? StringCchLenW(s1,l1) : -1),
s2,(l2 >= 0 ? StringCchLenW(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);
return (CompareStringW(LOCALE_INVARIANT,NORM_IGNORECASE,s1,(l1 >= 0 ? StringCchLenW(s1,l1) : -1),
s2,(l2 >= 0 ? StringCchLenW(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)

View File

@ -1022,7 +1022,7 @@ HWND InitInstance(HINSTANCE hInstance,LPSTR pszCmdLine,int nCmdShow)
WCHAR tchUntitled[32] = { L'\0' };
WCHAR tchPageFmt[32] = { L'\0' };
if (StringCchLen(szCurFile)) {
if (StringCchLenW(szCurFile,COUNTOF(szCurFile))) {
SHGetFileInfo2(szCurFile, 0, &shfi, sizeof(SHFILEINFO), SHGFI_DISPLAYNAME);
pszTitle = shfi.szDisplayName;
}
@ -1468,7 +1468,7 @@ void CreateBars(HWND hwnd,HINSTANCE hInstance)
// Add normal Toolbar Bitmap
hbmp = NULL;
if (StringCchLen(tchToolbarBitmap))
if (StringCchLenW(tchToolbarBitmap,COUNTOF(tchToolbarBitmap)))
{
if (!SearchPath(NULL,tchToolbarBitmap,NULL,COUNTOF(szTmp),szTmp,NULL))
StringCchCopy(szTmp,COUNTOF(szTmp),tchToolbarBitmap);
@ -1492,7 +1492,7 @@ void CreateBars(HWND hwnd,HINSTANCE hInstance)
// Optionally add hot Toolbar Bitmap
hbmp = NULL;
if (StringCchLen(tchToolbarBitmapHot))
if (StringCchLenW(tchToolbarBitmapHot,COUNTOF(tchToolbarBitmapHot)))
{
if (!SearchPath(NULL,tchToolbarBitmapHot,NULL,COUNTOF(szTmp),szTmp,NULL))
StringCchCopy(szTmp,COUNTOF(szTmp),tchToolbarBitmapHot);
@ -1510,7 +1510,7 @@ void CreateBars(HWND hwnd,HINSTANCE hInstance)
// Optionally add disabled Toolbar Bitmap
hbmp = NULL;
if (StringCchLen(tchToolbarBitmapDisabled))
if (StringCchLenW(tchToolbarBitmapDisabled,COUNTOF(tchToolbarBitmapDisabled)))
{
if (!SearchPath(NULL,tchToolbarBitmapDisabled,NULL,COUNTOF(szTmp),szTmp,NULL))
StringCchCopy(szTmp,COUNTOF(szTmp),tchToolbarBitmapDisabled);
@ -1643,7 +1643,7 @@ void MsgEndSession(HWND hwnd, UINT umsg)
// call SaveSettings() when hwndToolbar is still valid
SaveSettings(FALSE);
if (StringCchLen(szIniFile) != 0) {
if (StringCchLenW(szIniFile,COUNTOF(szIniFile)) != 0) {
// Cleanup unwanted MRU's
if (!bSaveRecentFiles) {
@ -2126,7 +2126,7 @@ void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam)
int i,i2;
HMENU hmenu = (HMENU)wParam;
i = StringCchLen(szCurFile);
i = StringCchLenW(szCurFile,COUNTOF(szCurFile));
EnableCmd(hmenu,IDM_FILE_REVERT,i);
EnableCmd(hmenu, CMD_RELOADASCIIASUTF8, i);
EnableCmd(hmenu, CMD_RECODEANSI, i);
@ -2351,7 +2351,7 @@ void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam)
CheckCmd(hmenu,IDM_VIEW_CHANGENOTIFY,iFileWatchingMode);
if (StringCchLen(szTitleExcerpt))
if (StringCchLenW(szTitleExcerpt,COUNTOF(szTitleExcerpt)))
i = IDM_VIEW_SHOWEXCERPT;
else if (iPathNameFormat == 0)
i = IDM_VIEW_SHOWFILENAMEONLY;
@ -2369,7 +2369,7 @@ void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam)
i = IDM_VIEW_NOESCFUNC;
CheckMenuRadioItem(hmenu,IDM_VIEW_NOESCFUNC,IDM_VIEW_ESCEXIT,i,MF_BYCOMMAND);
i = StringCchLen(szIniFile);
i = StringCchLenW(szIniFile,COUNTOF(szIniFile));
CheckCmd(hmenu,IDM_VIEW_SAVESETTINGS,bSaveSettings && i);
EnableCmd(hmenu,IDM_VIEW_REUSEWINDOW,i);
@ -2380,7 +2380,7 @@ void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam)
EnableCmd(hmenu,IDM_VIEW_NOSAVEFINDREPL,i);
EnableCmd(hmenu,IDM_VIEW_SAVESETTINGS,bEnableSaveSettings && i);
i = (StringCchLen(szIniFile) > 0 || StringCchLen(szIniFile2) > 0);
i = (StringCchLenW(szIniFile,COUNTOF(szIniFile)) > 0 || StringCchLenW(szIniFile2,COUNTOF(szIniFile2)) > 0);
EnableCmd(hmenu,IDM_VIEW_SAVESETTINGSNOW,bEnableSaveSettings && i);
UNUSED(lParam);
@ -2465,7 +2465,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
//SendMessage(hwndEdit,SCI_SETREADONLY,bReadOnly,0);
//UpdateToolbar();
//UpdateStatusbar();
if (StringCchLen(szCurFile))
if (StringCchLenW(szCurFile,COUNTOF(szCurFile)))
{
DWORD dwFileAttributes = GetFileAttributes(szCurFile);
if (dwFileAttributes != INVALID_FILE_ATTRIBUTES) {
@ -2514,10 +2514,10 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
}
}
if (StringCchLen(tchParam) && StringCchLen(szCurFile))
if (StringCchLenW(tchParam,COUNTOF(tchParam)) && StringCchLenW(szCurFile,COUNTOF(szCurFile)))
StringCchCat(tchParam,COUNTOF(tchParam),L" ");
if (StringCchLen(szCurFile)) {
if (StringCchLenW(szCurFile,COUNTOF(szCurFile))) {
StringCchCopy(tchTemp,COUNTOF(tchTemp),szCurFile);
PathQuoteSpaces(tchTemp);
StringCchCat(tchParam,COUNTOF(tchParam),tchTemp);
@ -2561,7 +2561,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
StringCchCat(szParameters,COUNTOF(szParameters),tch);
StringCchCat(szParameters,COUNTOF(szParameters),L" -f");
if (StringCchLen(szIniFile)) {
if (StringCchLenW(szIniFile,COUNTOF(szIniFile))) {
StringCchCat(szParameters,COUNTOF(szParameters),L" \"");
StringCchCat(szParameters,COUNTOF(szParameters),szIniFile);
StringCchCat(szParameters,COUNTOF(szParameters),L" \"");
@ -2586,7 +2586,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
StringCchPrintf(tch,COUNTOF(tch),L" -pos %i,%i,%i,%i,%i",wi.x,wi.y,wi.cx,wi.cy,wi.max);
StringCchCat(szParameters,COUNTOF(szParameters),tch);
if (LOWORD(wParam) != IDM_FILE_NEWWINDOW2 && StringCchLen(szCurFile)) {
if (LOWORD(wParam) != IDM_FILE_NEWWINDOW2 && StringCchLenW(szCurFile,COUNTOF(szCurFile))) {
StringCchCopy(szFileName,COUNTOF(szFileName),szCurFile);
PathQuoteSpaces(szFileName);
StringCchCat(szParameters,COUNTOF(szParameters),L" ");
@ -2612,13 +2612,13 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
{
WCHAR wchDirectory[MAX_PATH] = { L'\0' };
if (!StringCchLen(szCurFile))
if (!StringCchLenW(szCurFile,COUNTOF(szCurFile)))
break;
if (bSaveBeforeRunningTools && !FileSave(FALSE,TRUE,FALSE,FALSE))
break;
if (StringCchLen(szCurFile)) {
if (StringCchLenW(szCurFile,COUNTOF(szCurFile))) {
StringCchCopy(wchDirectory,COUNTOF(wchDirectory),szCurFile);
PathRemoveFileSpec(wchDirectory);
}
@ -2671,7 +2671,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
WCHAR tchUntitled[32] = { L'\0' };
WCHAR tchPageFmt[32] = { L'\0' };
if (StringCchLen(szCurFile)) {
if (StringCchLenW(szCurFile,COUNTOF(szCurFile))) {
SHGetFileInfo2(szCurFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME);
pszTitle = shfi.szDisplayName;
}
@ -2690,7 +2690,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
case IDM_FILE_PROPERTIES:
{
if (StringCchLen(szCurFile) == 0)
if (StringCchLenW(szCurFile,COUNTOF(szCurFile)) == 0)
break;
SHELLEXECUTEINFO sei;
@ -2707,7 +2707,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
case IDM_FILE_CREATELINK:
{
if (!StringCchLen(szCurFile))
if (!StringCchLenW(szCurFile,COUNTOF(szCurFile)))
break;
if (!PathCreateDeskLnk(szCurFile))
@ -2741,7 +2741,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
case IDM_FILE_ADDTOFAV:
if (StringCchLen(szCurFile)) {
if (StringCchLenW(szCurFile,COUNTOF(szCurFile))) {
SHFILEINFO shfi;
SHGetFileInfo2(szCurFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME);
AddToFavDlg(hwnd,shfi.szDisplayName,szCurFile);
@ -2806,7 +2806,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
if (EditSetNewEncoding(hwndEdit,
iNewEncoding,
(flagSetEncoding),
StringCchLen(szCurFile) == 0)) {
StringCchLenW(szCurFile,COUNTOF(szCurFile)) == 0)) {
if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) == 0) {
Encoding_Current(iNewEncoding);
@ -2827,7 +2827,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
case IDM_ENCODING_RECODE:
{
if (StringCchLen(szCurFile)) {
if (StringCchLenW(szCurFile,COUNTOF(szCurFile))) {
WCHAR tchCurFile2[MAX_PATH] = { L'\0' };
@ -3508,7 +3508,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
char mszBuf[MAX_PATH*3];
//int iSelStart;
if (StringCchLen(szCurFile)) {
if (StringCchLenW(szCurFile,COUNTOF(szCurFile))) {
if (LOWORD(wParam) == IDM_EDIT_INSERT_FILENAME) {
SHGetFileInfo2(szCurFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME);
pszInsert = shfi.szDisplayName;
@ -4441,9 +4441,9 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
BOOL bCreateFailure = FALSE;
if (StringCchLen(szIniFile) == 0) {
if (StringCchLenW(szIniFile,COUNTOF(szIniFile)) == 0) {
if (StringCchLen(szIniFile2) > 0) {
if (StringCchLenW(szIniFile2,COUNTOF(szIniFile2)) > 0) {
if (CreateIniFileEx(szIniFile2)) {
StringCchCopy(szIniFile,COUNTOF(szIniFile),szIniFile2);
StringCchCopy(szIniFile2,COUNTOF(szIniFile2),L"");
@ -4628,7 +4628,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
case CMD_RECODEDEFAULT:
{
WCHAR tchCurFile2[MAX_PATH] = { L'\0' };
if (StringCchLen(szCurFile)) {
if (StringCchLenW(szCurFile,COUNTOF(szCurFile))) {
Encoding_Source(Encoding_MapUnicode(iDefaultEncoding));
StringCchCopy(tchCurFile2,COUNTOF(tchCurFile2),szCurFile);
FileLoad(FALSE,FALSE,TRUE,TRUE,tchCurFile2);
@ -4640,7 +4640,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
case CMD_RECODEANSI:
{
WCHAR tchCurFile2[MAX_PATH] = { L'\0' };
if (StringCchLen(szCurFile)) {
if (StringCchLenW(szCurFile,COUNTOF(szCurFile))) {
Encoding_Source(CPI_ANSI_DEFAULT);
StringCchCopy(tchCurFile2,COUNTOF(tchCurFile2),szCurFile);
FileLoad(FALSE,FALSE,TRUE,TRUE,tchCurFile2);
@ -4652,7 +4652,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
case CMD_RECODEOEM:
{
WCHAR tchCurFile2[MAX_PATH] = { L'\0' };
if (StringCchLen(szCurFile)) {
if (StringCchLenW(szCurFile,COUNTOF(szCurFile))) {
Encoding_Source(CPI_OEM);
StringCchCopy(tchCurFile2,COUNTOF(tchCurFile2),szCurFile);
FileLoad(FALSE,FALSE,TRUE,TRUE,tchCurFile2);
@ -4665,7 +4665,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
{
WCHAR tchCurFile2[MAX_PATH] = { L'\0' };
BOOL _bLoadASCIIasUTF8 = bLoadASCIIasUTF8;
if (StringCchLen(szCurFile)) {
if (StringCchLenW(szCurFile,COUNTOF(szCurFile))) {
bLoadASCIIasUTF8 = 1;
StringCchCopy(tchCurFile2,COUNTOF(tchCurFile2),szCurFile);
FileLoad(FALSE,FALSE,TRUE,FALSE,tchCurFile2);
@ -4678,7 +4678,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
case CMD_RELOADNOFILEVARS:
{
WCHAR tchCurFile2[MAX_PATH] = { L'\0' };
if (StringCchLen(szCurFile)) {
if (StringCchLenW(szCurFile,COUNTOF(szCurFile))) {
int _fNoFileVariables = fNoFileVariables;
BOOL _bNoEncodingTags = bNoEncodingTags;
fNoFileVariables = 1;
@ -4737,7 +4737,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
StrTrim(wchFind,L" ");
StrTrim(wchTemplate,L" ");
if (StringCchLen(wchFind) == 0 || StringCchLen(wchTemplate) == 0)
if (StringCchLenW(wchFind,COUNTOF(wchFind)) == 0 || StringCchLenW(wchTemplate,COUNTOF(wchTemplate)) == 0)
break;
GetLocalTime(&st);
@ -4801,7 +4801,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
lpsz = StrChrA(mszSelection,9);
if (lpsz) *lpsz = '\0';
if (StringCchLenA(mszSelection)) {
if (StringCchLenA(mszSelection,COUNTOF(mszSelection))) {
WCHAR wszSelection[512] = { L'\0' };
UINT uCP = Encoding_SciGetCodePage(hwndEdit);
@ -4815,7 +4815,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
lpszArgs = GlobalAlloc(GPTR,GlobalSize(lpszCommand));
ExtractFirstArgument(lpszCommand,lpszCommand,lpszArgs,cmdsz);
if (StringCchLen(szCurFile)) {
if (StringCchLenW(szCurFile,COUNTOF(szCurFile))) {
StringCchCopy(wchDirectory,COUNTOF(wchDirectory),szCurFile);
PathRemoveFileSpec(wchDirectory);
}
@ -5019,7 +5019,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
WCHAR *pszCopy;
WCHAR tchUntitled[32] = { L'\0' };
if (StringCchLen(szCurFile))
if (StringCchLenW(szCurFile,COUNTOF(szCurFile)))
pszCopy = szCurFile;
else {
GetString(IDS_UNTITLED,tchUntitled,COUNTOF(tchUntitled));
@ -5053,7 +5053,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
HANDLE hData;
WCHAR *pData;
EmptyClipboard();
int len = StringCchLen(wszWinPos);
int len = StringCchLenW(wszWinPos,COUNTOF(wszWinPos));
hData = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,sizeof(WCHAR) * (len+1));
pData = GlobalLock(hData);
StringCchCopyN(pData,(len+1),wszWinPos,len);
@ -5072,7 +5072,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
case CMD_OPENINIFILE:
if (StringCchLen(szIniFile)) {
if (StringCchLenW(szIniFile,COUNTOF(szIniFile))) {
CreateIniFile();
FileLoad(FALSE,FALSE,FALSE,FALSE,szIniFile);
}
@ -5974,7 +5974,7 @@ void SaveSettings(BOOL bSaveSettingsNow) {
WCHAR wchTmp[MAX_PATH] = { L'\0' };
if (StringCchLen(szIniFile) == 0)
if (StringCchLenW(szIniFile,COUNTOF(szIniFile)) == 0)
return;
if (!bEnableSaveSettings)
@ -6196,7 +6196,7 @@ void ParseCommandLine()
StringCchCopyN(g_wchAppUserModelID,COUNTOF(g_wchAppUserModelID),
lp1 + CSTRLEN(L"appid="),len - CSTRLEN(L"appid="));
StrTrim(g_wchAppUserModelID,L" ");
if (StringCchLen(g_wchAppUserModelID) == 0)
if (StringCchLenW(g_wchAppUserModelID,COUNTOF(g_wchAppUserModelID)) == 0)
StringCchCopy(g_wchAppUserModelID,COUNTOF(g_wchAppUserModelID),L"Notepad3");
}
@ -6576,7 +6576,7 @@ void LoadFlags()
if (IniSectionGetInt(pIniSection,L"NoFileVariables",0))
fNoFileVariables = 1;
if (StringCchLen(g_wchAppUserModelID) == 0) {
if (StringCchLenW(g_wchAppUserModelID,COUNTOF(g_wchAppUserModelID)) == 0) {
IniSectionGetString(pIniSection,L"ShellAppUserModelID",L"Notepad3",
g_wchAppUserModelID,COUNTOF(g_wchAppUserModelID));
}
@ -6666,7 +6666,7 @@ int FindIniFile() {
WCHAR tchModule[MAX_PATH] = { L'\0' };
GetModuleFileName(NULL,tchModule,COUNTOF(tchModule));
if (StringCchLen(szIniFile)) {
if (StringCchLenW(szIniFile,COUNTOF(szIniFile))) {
if (StringCchCompareIX(szIniFile,L"*?") == 0)
return(0);
else {
@ -6801,7 +6801,7 @@ void UpdateToolbar()
if (!bShowToolbar)
return;
EnableTool(IDT_FILE_ADDTOFAV,StringCchLen(szCurFile));
EnableTool(IDT_FILE_ADDTOFAV,StringCchLenW(szCurFile,COUNTOF(szCurFile)));
EnableTool(IDT_EDIT_UNDO,SendMessage(hwndEdit,SCI_CANUNDO,0,0) /*&& !bReadOnly*/);
EnableTool(IDT_EDIT_REDO,SendMessage(hwndEdit,SCI_CANREDO,0,0) /*&& !bReadOnly*/);
@ -6982,7 +6982,7 @@ void UpdateLineNumberWidth()
void UpdateSettingsCmds()
{
HMENU hmenu = GetSystemMenu(hwndMain, FALSE);
BOOL hasIniFile = (StringCchLen(szIniFile) > 0 || StringCchLen(szIniFile2) > 0);
BOOL hasIniFile = (StringCchLenW(szIniFile,COUNTOF(szIniFile)) > 0 || StringCchLenW(szIniFile2,COUNTOF(szIniFile2)) > 0);
CheckCmd(hmenu, IDM_VIEW_SAVESETTINGS, bSaveSettings && bEnableSaveSettings);
EnableCmd(hmenu, IDM_VIEW_SAVESETTINGS, hasIniFile && bEnableSaveSettings);
EnableCmd(hmenu, IDM_VIEW_SAVESETTINGSNOW, hasIniFile && bEnableSaveSettings);
@ -7408,7 +7408,7 @@ BOOL FileLoad(BOOL bDontSave,BOOL bNew,BOOL bReload,BOOL bNoEncDetect,LPCWSTR lp
}
}
// consistent settings file handling (if loaded in editor)
bEnableSaveSettings = (StringCchCompareI(szCurFile, szIniFile) == 0) ? FALSE : TRUE;
bEnableSaveSettings = (StringCchCompareINW(szCurFile, COUNTOF(szCurFile), szIniFile, COUNTOF(szIniFile)) == 0) ? FALSE : TRUE;
UpdateSettingsCmds();
// Show warning: Unicode file loaded as ANSI
@ -7485,7 +7485,7 @@ BOOL FileSave(BOOL bSaveAlways,BOOL bAsk,BOOL bSaveAs,BOOL bSaveCopy)
BOOL bCancelDataLoss = FALSE;
BOOL bIsEmptyNewFile = FALSE;
if (StringCchLen(szCurFile) == 0) {
if (StringCchLenW(szCurFile,COUNTOF(szCurFile)) == 0) {
int cchText = (int)SendMessage(hwndEdit,SCI_GETLENGTH,0,0);
if (cchText == 0)
bIsEmptyNewFile = TRUE;
@ -7511,7 +7511,7 @@ BOOL FileSave(BOOL bSaveAlways,BOOL bAsk,BOOL bSaveAs,BOOL bSaveCopy)
{
// File or "Untitled" ...
WCHAR tch[MAX_PATH] = { L'\0' };
if (StringCchLen(szCurFile))
if (StringCchLenW(szCurFile,COUNTOF(szCurFile)))
StringCchCopy(tch,COUNTOF(tch),szCurFile);
else
GetString(IDS_UNTITLED,tch,COUNTOF(tch));
@ -7525,7 +7525,7 @@ BOOL FileSave(BOOL bSaveAlways,BOOL bAsk,BOOL bSaveAs,BOOL bSaveCopy)
}
// Read only...
if (!bSaveAs && !bSaveCopy && StringCchLen(szCurFile))
if (!bSaveAs && !bSaveCopy && StringCchLenW(szCurFile,COUNTOF(szCurFile)))
{
DWORD dwFileAttributes = GetFileAttributes(szCurFile);
if (dwFileAttributes != INVALID_FILE_ATTRIBUTES)
@ -7540,10 +7540,10 @@ BOOL FileSave(BOOL bSaveAlways,BOOL bAsk,BOOL bSaveAs,BOOL bSaveCopy)
}
// Save As...
if (bSaveAs || bSaveCopy || StringCchLen(szCurFile) == 0)
if (bSaveAs || bSaveCopy || StringCchLenW(szCurFile,COUNTOF(szCurFile)) == 0)
{
WCHAR tchInitialDir[MAX_PATH] = { L'\0' };
if (bSaveCopy && StringCchLen(tchLastSaveCopyDir)) {
if (bSaveCopy && StringCchLenW(tchLastSaveCopyDir,COUNTOF(tchLastSaveCopyDir))) {
StringCchCopy(tchInitialDir,COUNTOF(tchInitialDir),tchLastSaveCopyDir);
StringCchCopy(tchFile,COUNTOF(tchFile),tchLastSaveCopyDir);
PathCchAppend(tchFile,COUNTOF(tchFile),PathFindFileName(szCurFile));
@ -7604,7 +7604,7 @@ BOOL FileSave(BOOL bSaveAlways,BOOL bAsk,BOOL bSaveAs,BOOL bSaveCopy)
}
else if (!bCancelDataLoss)
{
if (StringCchLen(szCurFile) > 0) {
if (StringCchLenW(szCurFile,COUNTOF(szCurFile)) > 0) {
StringCchCopy(tchFile,COUNTOF(tchFile),szCurFile);
StringCchCopy(tchBase,COUNTOF(tchBase),szCurFile);
PathStripPath(tchBase);
@ -7631,7 +7631,7 @@ BOOL FileSave(BOOL bSaveAlways,BOOL bAsk,BOOL bSaveAs,BOOL bSaveCopy)
WININFO wi = GetMyWindowPlacement(hwndMain,NULL);
StringCchPrintf(szArguments,COUNTOF(szArguments),
L"/pos %i,%i,%i,%i,%i /tmpfbuf=\"%s\" %s",wi.x,wi.y,wi.cx,wi.cy,wi.max,szTempFileName,lpArgs);
if (StringCchLen(tchFile)) {
if (StringCchLenW(tchFile,COUNTOF(tchFile))) {
if (!StrStrI(szArguments,tchBase)) {
StringCchPrintf(szArguments,COUNTOF(szArguments),L"%s \"%s\"",szArguments,tchFile);
}
@ -7680,11 +7680,11 @@ BOOL OpenFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir)
Style_GetOpenDlgFilterStr(szFilter,COUNTOF(szFilter));
if (!lpstrInitialDir) {
if (StringCchLen(szCurFile)) {
if (StringCchLenW(szCurFile,COUNTOF(szCurFile))) {
StringCchCopy(tchInitialDir,COUNTOF(tchInitialDir),szCurFile);
PathRemoveFileSpec(tchInitialDir);
}
else if (StringCchLen(tchDefaultDir)) {
else if (StringCchLenW(tchDefaultDir,COUNTOF(tchDefaultDir))) {
ExpandEnvironmentStrings(tchDefaultDir,tchInitialDir,COUNTOF(tchInitialDir));
if (PathIsRelative(tchInitialDir)) {
WCHAR tchModule[MAX_PATH] = { L'\0' };
@ -7708,7 +7708,7 @@ BOOL OpenFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir)
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | /* OFN_NOCHANGEDIR |*/
OFN_DONTADDTORECENT | OFN_PATHMUSTEXIST |
OFN_SHAREAWARE /*| OFN_NODEREFERENCELINKS*/;
ofn.lpstrDefExt = (StringCchLen(tchDefaultExtension)) ? tchDefaultExtension : NULL;
ofn.lpstrDefExt = (StringCchLenW(tchDefaultExtension,COUNTOF(tchDefaultExtension))) ? tchDefaultExtension : NULL;
if (GetOpenFileName(&ofn)) {
StringCchCopyN(lpstrFile,cchFile,szFile,COUNTOF(szFile));
@ -7737,11 +7737,11 @@ BOOL SaveFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir)
if (lstrlen(lpstrInitialDir))
StringCchCopy(tchInitialDir,COUNTOF(tchInitialDir),lpstrInitialDir);
else if (StringCchLen(szCurFile)) {
else if (StringCchLenW(szCurFile,COUNTOF(szCurFile))) {
StringCchCopy(tchInitialDir,COUNTOF(tchInitialDir),szCurFile);
PathRemoveFileSpec(tchInitialDir);
}
else if (StringCchLen(tchDefaultDir)) {
else if (StringCchLenW(tchDefaultDir,COUNTOF(tchDefaultDir))) {
ExpandEnvironmentStrings(tchDefaultDir,tchInitialDir,COUNTOF(tchInitialDir));
if (PathIsRelative(tchInitialDir)) {
WCHAR tchModule[MAX_PATH] = { L'\0' };
@ -7764,7 +7764,7 @@ BOOL SaveFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir)
ofn.Flags = OFN_HIDEREADONLY /*| OFN_NOCHANGEDIR*/ |
/*OFN_NODEREFERENCELINKS |*/ OFN_OVERWRITEPROMPT |
OFN_DONTADDTORECENT | OFN_PATHMUSTEXIST;
ofn.lpstrDefExt = (StringCchLen(tchDefaultExtension)) ? tchDefaultExtension : NULL;
ofn.lpstrDefExt = (StringCchLenW(tchDefaultExtension,COUNTOF(tchDefaultExtension))) ? tchDefaultExtension : NULL;
if (GetSaveFileName(&ofn)) {
StringCchCopyN(lpstrFile,cchFile,szNewFile,COUNTOF(szNewFile));
@ -7791,7 +7791,7 @@ BOOL CALLBACK EnumWndProc(HWND hwnd,LPARAM lParam)
if (GetClassName(hwnd,szClassName,COUNTOF(szClassName)))
if (StringCchCompareI(szClassName,wchWndClass) == 0) {
if (StringCchCompareINW(szClassName,COUNTOF(szClassName),wchWndClass,COUNTOF(wchWndClass)) == 0) {
DWORD dwReuseLock = GetDlgItemInt(hwnd,IDC_REUSELOCK,NULL,FALSE);
if (GetTickCount() - dwReuseLock >= REUSEWINDOWLOCKTIMEOUT) {
@ -7812,7 +7812,7 @@ BOOL CALLBACK EnumWndProc2(HWND hwnd,LPARAM lParam)
if (GetClassName(hwnd,szClassName,COUNTOF(szClassName)))
if (StringCchCompareI(szClassName,wchWndClass) == 0) {
if (StringCchCompareINW(szClassName,COUNTOF(szClassName),wchWndClass,COUNTOF(wchWndClass)) == 0) {
DWORD dwReuseLock = GetDlgItemInt(hwnd,IDC_REUSELOCK,NULL,FALSE);
if (GetTickCount() - dwReuseLock >= REUSEWINDOWLOCKTIMEOUT) {
@ -7991,7 +7991,7 @@ BOOL ActivatePrevInst()
if (lpSchemeArg)
cb += (lstrlen(lpSchemeArg) + 1) * sizeof(WCHAR);
cchTitleExcerpt = StringCchLen(szTitleExcerpt);
cchTitleExcerpt = StringCchLenW(szTitleExcerpt,COUNTOF(szTitleExcerpt));
if (cchTitleExcerpt)
cb += (cchTitleExcerpt + 1) * sizeof(WCHAR);
@ -8139,7 +8139,7 @@ BOOL RelaunchElevated(LPWSTR lpArgs) {
StringCchCopy(szArguments,COUNTOF(szArguments),szArgs);
}
else {
if (StringCchLen(szIniFile) > 0)
if (StringCchLenW(szIniFile,COUNTOF(szIniFile)) > 0)
StringCchPrintf(szArguments,COUNTOF(szArguments),L"/f \"%s\" %s",szIniFile,szArgs);
else
StringCchCopy(szArguments,COUNTOF(szArguments),szArgs);
@ -8264,12 +8264,12 @@ void SetNotifyIconTitle(HWND hwnd)
nid.uID = 0;
nid.uFlags = NIF_TIP;
if (StringCchLen(szTitleExcerpt)) {
if (StringCchLenW(szTitleExcerpt,COUNTOF(szTitleExcerpt))) {
GetString(IDS_TITLEEXCERPT,tchFormat,COUNTOF(tchFormat));
StringCchPrintf(tchTitle,COUNTOF(tchTitle),tchFormat,szTitleExcerpt);
}
else if (StringCchLen(szCurFile)) {
else if (StringCchLenW(szCurFile,COUNTOF(szCurFile))) {
SHGetFileInfo2(szCurFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME);
PathCompactPathEx(tchTitle,shfi.szDisplayName,COUNTOF(tchTitle)-4,0);
}
@ -8299,7 +8299,7 @@ void InstallFileWatching(LPCWSTR lpszFile)
HANDLE hFind;
// Terminate
if (!iFileWatchingMode || !lpszFile || StringCchLenN(lpszFile,MAX_PATH) == 0)
if (!iFileWatchingMode || !lpszFile || StringCchLen(lpszFile,MAX_PATH) == 0)
{
if (bRunningWatch)
{

View File

@ -375,10 +375,10 @@ extern "C" BOOL EditPrint(HWND hwnd,LPCWSTR pszDocTitle,LPCWSTR pszPageFormat)
{
SIZE sizeInfo;
SelectObject(hdc,fontFooter);
GetTextExtentPoint32(hdc,dateString,StringCchLen(dateString),&sizeInfo);
GetTextExtentPoint32(hdc,dateString,StringCchLenW(dateString,COUNTOF(dateString)),&sizeInfo);
ExtTextOut(hdc, frPrint.rc.right - 5 - sizeInfo.cx, frPrint.rc.top - headerLineHeight / 2,
/*ETO_OPAQUE*/0, &rcw, dateString,
StringCchLen(dateString), NULL);
StringCchLenW(dateString,COUNTOF(dateString)), NULL);
}
if (iPrintHeader < 3)
@ -409,10 +409,10 @@ extern "C" BOOL EditPrint(HWND hwnd,LPCWSTR pszDocTitle,LPCWSTR pszPageFormat)
if (iPrintFooter == 0)
{
SIZE sizeFooter;
GetTextExtentPoint32(hdc,pageString,StringCchLen(pageString),&sizeFooter);
GetTextExtentPoint32(hdc,pageString,StringCchLenW(pageString,COUNTOF(pageString)),&sizeFooter);
ExtTextOut(hdc, frPrint.rc.right - 5 - sizeFooter.cx, frPrint.rc.bottom + footerLineHeight / 2,
/*ETO_OPAQUE*/0, &rcw, pageString,
StringCchLen(pageString), NULL);
StringCchLenW(pageString,COUNTOF(pageString)), NULL);
SetTextAlign(hdc, ta);
pen = ::CreatePen(0, 1, RGB(0,0,0));

View File

@ -3289,7 +3289,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) {
}
if (StrStr(lexDefault.Styles[STY_CARET + iIdx].szValue,L"noblink")) {
SendMessage(hwnd,SCI_SETCARETPERIOD,(WPARAM)0,0);
if (StringCchLen(wchCaretStyle))
if (StringCchLenW(wchCaretStyle,COUNTOF(wchCaretStyle)))
StringCchCat(wchCaretStyle,COUNTOF(wchCaretStyle),L"; ");
StringCchCat(wchCaretStyle,COUNTOF(wchCaretStyle),L"noblink");
}
@ -3305,7 +3305,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) {
(int)GetRValue(rgb),
(int)GetGValue(rgb),
(int)GetBValue(rgb));
if (StringCchLen(wchCaretStyle))
if (StringCchLenW(wchCaretStyle,COUNTOF(wchCaretStyle)))
StringCchCat(wchCaretStyle,COUNTOF(wchCaretStyle),L"; ");
StringCchCat(wchCaretStyle,COUNTOF(wchCaretStyle),wch);
}
@ -3737,7 +3737,7 @@ void Style_SetLexerFromFile(HWND hwnd,LPCWSTR lpszFile)
}
if (!bFound && bAutoSelect && /* bAutoSelect == FALSE skips lexer search */
(lpszFile && StringCchLenN(lpszFile,MAX_PATH) > 0 && *lpszExt)) {
(lpszFile && StringCchLen(lpszFile,MAX_PATH) > 0 && *lpszExt)) {
if (*lpszExt == L'.') ++lpszExt;
@ -3946,7 +3946,7 @@ extern WCHAR tchFileDlgFilters[5*1024];
BOOL Style_GetOpenDlgFilterStr(LPWSTR lpszFilter,int cchFilter)
{
if (StringCchLen(tchFileDlgFilters) == 0)
if (StringCchLenW(tchFileDlgFilters,COUNTOF(tchFileDlgFilters)) == 0)
GetString(IDS_FILTER_ALL,lpszFilter,cchFilter);
else {
StringCchCopyN(lpszFilter,cchFilter,tchFileDlgFilters,cchFilter - 2);
@ -4236,7 +4236,7 @@ BOOL Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle,BOOL bDefaultStyle
if (HIBYTE(GetKeyState(VK_SHIFT)))
cf.Flags |= CF_FIXEDPITCHONLY;
if (!ChooseFont(&cf) || !StringCchLen(lf.lfFaceName))
if (!ChooseFont(&cf) || !StringCchLenW(lf.lfFaceName,COUNTOF(lf.lfFaceName)))
return FALSE;
// Map back to lpszStyle
@ -4340,21 +4340,21 @@ BOOL Style_SelectColor(HWND hwnd,BOOL bFore,LPWSTR lpszStyle,int cchStyle)
}
if (Style_StrGetFontQuality(lpszStyle,tch,COUNTOF(tch)))
{
if (StringCchLen(szNewStyle))
if (StringCchLenW(szNewStyle,COUNTOF(szNewStyle)))
StringCchCat(szNewStyle,COUNTOF(szNewStyle),L"; ");
StringCchCat(szNewStyle,COUNTOF(szNewStyle),L"smoothing:");
StringCchCat(szNewStyle,COUNTOF(szNewStyle),tch);
}
if (Style_StrGetCharSet(lpszStyle,&iValue))
{
if (StringCchLen(szNewStyle))
if (StringCchLenW(szNewStyle, COUNTOF(szNewStyle)))
StringCchCat(szNewStyle,COUNTOF(szNewStyle),L"; ");
StringCchPrintf(tch,COUNTOF(tch),L"charset:%i",iValue);
StringCchCat(szNewStyle,COUNTOF(szNewStyle),tch);
}
if (Style_StrGetSizeStr(lpszStyle,tch,COUNTOF(tch)))
{
if (StringCchLen(szNewStyle))
if (StringCchLenW(szNewStyle, COUNTOF(szNewStyle)))
StringCchCat(szNewStyle,COUNTOF(szNewStyle),L"; ");
StringCchCat(szNewStyle,COUNTOF(szNewStyle),L"size:");
StringCchCat(szNewStyle,COUNTOF(szNewStyle),tch);
@ -4362,26 +4362,26 @@ BOOL Style_SelectColor(HWND hwnd,BOOL bFore,LPWSTR lpszStyle,int cchStyle)
if (StrStrI(lpszStyle,L"bold"))
{
if (StringCchLen(szNewStyle))
if (StringCchLenW(szNewStyle, COUNTOF(szNewStyle)))
StringCchCat(szNewStyle,COUNTOF(szNewStyle),L"; ");
StringCchCat(szNewStyle,COUNTOF(szNewStyle),L"bold");
}
if (StrStrI(lpszStyle,L"italic"))
{
if (StringCchLen(szNewStyle))
if (StringCchLenW(szNewStyle, COUNTOF(szNewStyle)))
StringCchCat(szNewStyle,COUNTOF(szNewStyle),L"; ");
StringCchCat(szNewStyle,COUNTOF(szNewStyle),L"italic");
}
if (StrStrI(lpszStyle,L"underline"))
{
if (StringCchLen(szNewStyle))
if (StringCchLenW(szNewStyle, COUNTOF(szNewStyle)))
StringCchCat(szNewStyle,COUNTOF(szNewStyle),L"; ");
StringCchCat(szNewStyle,COUNTOF(szNewStyle),L"underline");
}
if (bFore)
{
if (StringCchLen(szNewStyle))
if (StringCchLenW(szNewStyle, COUNTOF(szNewStyle)))
StringCchCat(szNewStyle,COUNTOF(szNewStyle),L"; ");
StringCchPrintf(tch,COUNTOF(tch),L"fore:#%02X%02X%02X",
(int)GetRValue(iRGBResult),
@ -4399,7 +4399,7 @@ BOOL Style_SelectColor(HWND hwnd,BOOL bFore,LPWSTR lpszStyle,int cchStyle)
}
else
{
if (StringCchLen(szNewStyle))
if (StringCchLenW(szNewStyle, COUNTOF(szNewStyle)))
StringCchCat(szNewStyle,COUNTOF(szNewStyle),L"; ");
if (Style_StrGetColor(TRUE,lpszStyle,&iValue))
{
@ -4561,7 +4561,7 @@ int Style_GetLexerIconId(PEDITLEXER plex)
WCHAR pszFile[MAX_PATH + BUFZIZE_STYLE_EXTENTIONS];
WCHAR *pszExtensions;
if (StringCchLen(plex->szExtensions))
if (StringCchLenW(plex->szExtensions,COUNTOF(plex->szExtensions)))
pszExtensions = plex->szExtensions;
else
pszExtensions = plex->pszDefExt;
@ -4573,7 +4573,7 @@ int Style_GetLexerIconId(PEDITLEXER plex)
if (p) { *p = L'\0'; }
// check for ; at beginning
if (StringCchLenN(pszFile, COUNTOF(pszFile)) < 3)
if (StringCchLen(pszFile, COUNTOF(pszFile)) < 3)
StringCchCat(pszFile, COUNTOF(pszFile),L"txt");
SHFILEINFO shfi;
@ -5232,7 +5232,7 @@ void Style_ConfigDlg(HWND hwnd)
else {
fStylesModified = TRUE;
if (StringCchLen(szIniFile) == 0 && !fWarnedNoIniFile) {
if (StringCchLenW(szIniFile,COUNTOF(szIniFile)) == 0 && !fWarnedNoIniFile) {
MsgBox(MBWARN,IDS_SETTINGSNOTSAVED);
fWarnedNoIniFile = TRUE;
}