mirror of
https://github.com/Maximus5/ConEmu.git
synced 2025-05-08 16:52:10 +08:00
gh-2330: Fix crash on startup.
This commit is contained in:
parent
8ee47398be
commit
9ae13a660d
@ -914,6 +914,7 @@ project "Tests"
|
||||
removefiles (conemu_remove)
|
||||
removefiles {
|
||||
"src/ConEmu/ConEmuApp.*",
|
||||
"src/UnitTests/test_*/*.cpp",
|
||||
}
|
||||
|
||||
vpaths {
|
||||
|
@ -93,6 +93,8 @@
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Comspec/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=conemu/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=CONEMUC/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=conemupack/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=conemusetup/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Conhost/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=CONIN/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=CONOUT/@EntryIndexedValue">True</s:Boolean>
|
||||
@ -156,6 +158,7 @@
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=farctrl/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=FARHOME/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=FFIND/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=fmtetc/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=fndgsc/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=FTYPE/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=fulldump/@EntryIndexedValue">True</s:Boolean>
|
||||
@ -199,6 +202,7 @@
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=lpfn/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=lpft/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=lplpsz/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=lpnmtdi/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=lpst/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=lpte/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=lsbi/@EntryIndexedValue">True</s:Boolean>
|
||||
@ -214,6 +218,7 @@
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=messg/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=minidump/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=mnuhints/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Monospace/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=MSGBOX/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=msprintf/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=msvsmon/@EntryIndexedValue">True</s:Boolean>
|
||||
@ -229,12 +234,15 @@
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ntvdm/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Numpad/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=ools/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Oper/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=ored/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=osvi/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=otepad/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Outl/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=PARENTFARPID/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Parm/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=PCTL/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=phdr/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Pids/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=pipeserver/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=PLDR/@EntryIndexedValue">True</s:Boolean>
|
||||
@ -248,6 +256,7 @@
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Printf/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=PROCNOTFOUND/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=PROCS/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=PROFILECD/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Prog/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=proxylogin/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=psbi/@EntryIndexedValue">True</s:Boolean>
|
||||
@ -262,6 +271,7 @@
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=rclsid/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Realloc/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Recv/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=REGCONFONT/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=rhkp/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=riid/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=rpsz/@EntryIndexedValue">True</s:Boolean>
|
||||
@ -317,6 +327,7 @@
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=vshost/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=wchars/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=wcsrchr/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=wget/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=whatsnew/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=windir/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=WINDOWACTIVATED/@EntryIndexedValue">True</s:Boolean>
|
||||
|
@ -48,7 +48,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "SearchCtrl.h"
|
||||
#include "Update.h"
|
||||
#include "VirtualConsole.h"
|
||||
#include "VConChild.h"
|
||||
#include "version.h"
|
||||
#include "../common/MSetter.h"
|
||||
#include "../common/WObjects.h"
|
||||
@ -88,7 +87,7 @@ namespace ConEmuAbout
|
||||
|
||||
void TabSelected(HWND hDlg, int idx);
|
||||
|
||||
wchar_t* gsSysInfo = nullptr;
|
||||
CEStr* gsSysInfo = nullptr;
|
||||
void ReloadSysInfo();
|
||||
void LogStartEnvInt(LPCWSTR asText, LPARAM lParam, bool bFirst, bool bNewLine);
|
||||
|
||||
@ -167,36 +166,34 @@ INT_PTR WINAPI ConEmuAbout::aboutProc(HWND hDlg, UINT messg, WPARAM wParam, LPAR
|
||||
false, UM_SEARCH, IDOK);
|
||||
EditIconHint_Subclass(hDlg);
|
||||
|
||||
wchar_t* pszLabel = GetDlgItemTextPtr(hDlg, stConEmuVersion);
|
||||
CEStr pszLabel = GetDlgItemTextPtr(hDlg, stConEmuVersion);
|
||||
if (pszLabel)
|
||||
{
|
||||
wchar_t* pszSet = nullptr;
|
||||
CEStr pszSet;
|
||||
|
||||
if (gpUpd)
|
||||
{
|
||||
wchar_t* pszVerInfo = gpUpd->GetCurVerInfo();
|
||||
const CEStr pszVerInfo = gpUpd->GetCurVerInfo();
|
||||
if (pszVerInfo)
|
||||
{
|
||||
pszSet = lstrmerge(pszLabel, L" ", pszVerInfo);
|
||||
free(pszVerInfo);
|
||||
pszSet = CEStr(pszLabel, L" ", pszVerInfo);
|
||||
}
|
||||
}
|
||||
|
||||
if (!pszSet)
|
||||
{
|
||||
pszSet = lstrmerge(pszLabel, L" ", CLngRc::getRsrc(lng_PleaseCheckManually/*"Please check for updates manually"*/));
|
||||
pszSet = CEStr(pszLabel, L" ", CLngRc::getRsrc(lng_PleaseCheckManually/*"Please check for updates manually"*/));
|
||||
}
|
||||
|
||||
if (pszSet)
|
||||
{
|
||||
SetDlgItemText(hDlg, stConEmuVersion, pszSet);
|
||||
free(pszSet);
|
||||
}
|
||||
|
||||
free(pszLabel);
|
||||
pszLabel.Release();
|
||||
}
|
||||
|
||||
HWND hTab = GetDlgItem(hDlg, tbAboutTabs);
|
||||
const HWND hTab = GetDlgItem(hDlg, tbAboutTabs);
|
||||
INT_PTR nPage = -1;
|
||||
|
||||
for (size_t i = 0; i < countof(Pages); i++)
|
||||
@ -340,8 +337,8 @@ INT_PTR WINAPI ConEmuAbout::aboutProc(HWND hDlg, UINT messg, WPARAM wParam, LPAR
|
||||
void ConEmuAbout::searchProc(HWND hDlg, HWND hSearch, bool bReentr)
|
||||
{
|
||||
HWND hEdit = GetDlgItem(hDlg, tAboutText);
|
||||
wchar_t* pszPart = GetDlgItemTextPtr(hSearch, 0);
|
||||
wchar_t* pszText = GetDlgItemTextPtr(hEdit, 0);
|
||||
CEStr pszPart = GetDlgItemTextPtr(hSearch, 0);
|
||||
CEStr pszText = GetDlgItemTextPtr(hEdit, 0);
|
||||
bool bRetry = false;
|
||||
|
||||
if (pszPart && *pszPart && pszText && *pszText)
|
||||
@ -403,9 +400,6 @@ void ConEmuAbout::searchProc(HWND hDlg, HWND hSearch, bool bReentr)
|
||||
}
|
||||
}
|
||||
|
||||
SafeFree(pszPart);
|
||||
SafeFree(pszText);
|
||||
|
||||
if (bRetry)
|
||||
{
|
||||
searchProc(hDlg, hSearch, true);
|
||||
@ -473,11 +467,12 @@ void ConEmuAbout::TabSelected(HWND hDlg, int idx)
|
||||
|
||||
wcscpy_c(sLastOpenTab, Pages[idx].Title);
|
||||
LPCWSTR pszNewText = Pages[idx].Text;
|
||||
// ReSharper disable once CppJoinDeclarationAndAssignment
|
||||
CEStr lsTemp;
|
||||
if (gpConEmu->mp_PushInfo && gpConEmu->mp_PushInfo->mp_Active && gpConEmu->mp_PushInfo->mp_Active->pszFullMessage)
|
||||
{
|
||||
// EDIT control requires \r\n as line endings
|
||||
lsTemp = lstrmerge(gpConEmu->mp_PushInfo->mp_Active->pszFullMessage, L"\r\n\r\n\r\n", pszNewText);
|
||||
lsTemp = CEStr(gpConEmu->mp_PushInfo->mp_Active->pszFullMessage, L"\r\n\r\n\r\n", pszNewText);
|
||||
pszNewText = lsTemp.ms_Val;
|
||||
}
|
||||
SetDlgItemText(hDlg, tAboutText, pszNewText);
|
||||
@ -485,11 +480,14 @@ void ConEmuAbout::TabSelected(HWND hDlg, int idx)
|
||||
|
||||
void ConEmuAbout::LogStartEnvInt(LPCWSTR asText, LPARAM lParam, bool bFirst, bool bNewLine)
|
||||
{
|
||||
lstrmerge(&gsSysInfo, asText, bNewLine ? L"\r\n" : nullptr);
|
||||
_ASSERTE(isMainThread());
|
||||
if (!gsSysInfo)
|
||||
gsSysInfo = new CEStr;
|
||||
gsSysInfo->Append(asText, bNewLine ? L"\r\n" : nullptr);
|
||||
|
||||
if (bFirst && gpConEmu)
|
||||
{
|
||||
lstrmerge(&gsSysInfo, L" AppID: ", gpConEmu->ms_AppID, L"\r\n");
|
||||
gsSysInfo->Append(L" AppID: ", gpConEmu->ms_AppID, L"\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -498,12 +496,13 @@ void ConEmuAbout::ReloadSysInfo()
|
||||
if (!gpStartEnv)
|
||||
return;
|
||||
|
||||
_ASSERTE(isMainThread());
|
||||
_ASSERTE(lstrcmp(Pages[countof(Pages)-1].Title, L"SysInfo") == 0);
|
||||
SafeFree(gsSysInfo);
|
||||
gsSysInfo->Clear();
|
||||
|
||||
LoadStartupEnvEx::ToString(gpStartEnv, LogStartEnvInt, 0);
|
||||
|
||||
Pages[countof(Pages)-1].Text = gsSysInfo;
|
||||
Pages[countof(Pages)-1].Text = gsSysInfo->c_str();
|
||||
}
|
||||
|
||||
void ConEmuAbout::OnInfo_About(LPCWSTR asPageName /*= nullptr*/)
|
||||
|
@ -497,7 +497,7 @@ void CAltNumpad::DumpStatus()
|
||||
wchar_t wszChars[3] = L"", szStatus[80];
|
||||
ucs32 wc32 = GetChars(wszChars);
|
||||
swprintf_c(szStatus, L"Alt+Num: `%s` (%Xh/%u)", wszChars, wc32, wc32);
|
||||
lsStatus = lstrmerge(szStatus,
|
||||
lsStatus = CEStr(szStatus,
|
||||
CLngRc::getRsrc(
|
||||
mb_External ? lng_AltNumberExt/*" - <Enter> to paste, <Esc> to cancel"*/
|
||||
: (mn_NumberBase == 16) ? lng_AltNumberStdUCS/*" - release <Alt> to paste UNICODE code point"*/
|
||||
|
@ -195,7 +195,7 @@ void CommandHistory::Add(LPCWSTR asCommand, bool bFront /*= true*/)
|
||||
}
|
||||
}
|
||||
|
||||
p = lstrdup(asCommand);
|
||||
p = lstrdup(asCommand).Detach();
|
||||
if (!p)
|
||||
return;
|
||||
|
||||
|
@ -685,7 +685,7 @@ void LogFocusInfo(LPCWSTR asInfo, int Level/*=1*/)
|
||||
#ifdef _DEBUG
|
||||
if ((Level == 1) || gpSet->isLogging(Level))
|
||||
{
|
||||
CEStr lsMsg = lstrmerge(asInfo, szStyles);
|
||||
const CEStr lsMsg(asInfo, szStyles);
|
||||
DEBUGSTRFOCUS(lsMsg);
|
||||
}
|
||||
#endif
|
||||
@ -866,14 +866,14 @@ void CConEmuMain::AppendExtraArgs(LPCWSTR asSwitch, LPCWSTR asSwitchValue /*= nu
|
||||
if (!asSwitch || !*asSwitch)
|
||||
return;
|
||||
|
||||
lstrmerge(&mps_ConEmuExtraArgs, asSwitch, L" ");
|
||||
mps_ConEmuExtraArgs.Append(asSwitch, L" ");
|
||||
|
||||
if (asSwitchValue && *asSwitchValue)
|
||||
{
|
||||
if (IsQuotationNeeded(asSwitchValue))
|
||||
lstrmerge(&mps_ConEmuExtraArgs, L"\"", asSwitchValue, L"\" ");
|
||||
mps_ConEmuExtraArgs.Append(L"\"", asSwitchValue, L"\" ");
|
||||
else
|
||||
lstrmerge(&mps_ConEmuExtraArgs, asSwitchValue, L" ");
|
||||
mps_ConEmuExtraArgs.Append(asSwitchValue, L" ");
|
||||
}
|
||||
}
|
||||
|
||||
@ -889,7 +889,7 @@ LPCWSTR CConEmuMain::MakeConEmuStartArgs(CEStr& rsArgs, LPCWSTR asOtherConfig /*
|
||||
if (pszConfig && !*pszConfig)
|
||||
pszConfig = nullptr;
|
||||
|
||||
LPCWSTR pszAddArgs = gpConEmu->mps_ConEmuExtraArgs;
|
||||
const wchar_t* pszAddArgs = gpConEmu->mps_ConEmuExtraArgs.c_str();
|
||||
|
||||
const size_t cchMax = 1 // _wcscat_c requires size including terminating zero
|
||||
+ (pszConfig ? (_tcslen(pszConfig) + 16) : 0)
|
||||
@ -3322,7 +3322,7 @@ LPCWSTR CConEmuMain::ParseScriptLineOptions(LPCWSTR apszLine, bool* rpbSetActive
|
||||
if (pArgs)
|
||||
{
|
||||
SafeFree(pArgs->pszStartupDir);
|
||||
pArgs->pszStartupDir = lstrdup(szArg);
|
||||
pArgs->pszStartupDir = lstrdup(szArg).Detach();
|
||||
}
|
||||
apszLine = pcszCmd; // OK
|
||||
continue;
|
||||
@ -3335,7 +3335,7 @@ LPCWSTR CConEmuMain::ParseScriptLineOptions(LPCWSTR apszLine, bool* rpbSetActive
|
||||
if (pArgs)
|
||||
{
|
||||
SafeFree(pArgs->pszIconFile);
|
||||
pArgs->pszIconFile = lstrdup(szArg);
|
||||
pArgs->pszIconFile = lstrdup(szArg).Detach();
|
||||
}
|
||||
apszLine = pcszCmd; // OK
|
||||
continue;
|
||||
@ -3348,16 +3348,15 @@ LPCWSTR CConEmuMain::ParseScriptLineOptions(LPCWSTR apszLine, bool* rpbSetActive
|
||||
if (pArgs)
|
||||
{
|
||||
SafeFree(pArgs->pszRenameTab);
|
||||
pArgs->pszRenameTab = lstrdup(szArg);
|
||||
pArgs->pszRenameTab = lstrdup(szArg).Detach();
|
||||
}
|
||||
apszLine = pcszCmd; // OK
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
wchar_t* pszErr = lstrmerge(L"Unsupported switch in task command:", L"\r\n", apszLine);
|
||||
int iBtn = MsgBox(pszErr, MB_ICONSTOP | MB_OKCANCEL, GetDefaultTitle());
|
||||
SafeFree(pszErr);
|
||||
const CEStr pszErr(L"Unsupported switch in task command:", L"\r\n", apszLine);
|
||||
const int iBtn = MsgBox(pszErr, MB_ICONSTOP | MB_OKCANCEL, GetDefaultTitle());
|
||||
if (iBtn == IDCANCEL)
|
||||
return nullptr;
|
||||
return L"";
|
||||
@ -3372,9 +3371,8 @@ LPCWSTR CConEmuMain::ParseScriptLineOptions(LPCWSTR apszLine, bool* rpbSetActive
|
||||
CVirtualConsole* CConEmuMain::CreateConGroup(LPCWSTR apszScript, const RConStartArgsEx *apDefArgs /*= nullptr*/)
|
||||
{
|
||||
CVirtualConsole* pVConResult = nullptr;
|
||||
// Поехали
|
||||
wchar_t *pszDataW = lstrdup(apszScript);
|
||||
const wchar_t *pszCursor = pszDataW;
|
||||
const CEStr pszDataW(apszScript);
|
||||
const wchar_t *pszCursor = pszDataW.c_str();
|
||||
CEStr szLine;
|
||||
//wchar_t *pszNewLine = wcschr(pszLine, L'\n');
|
||||
CVirtualConsole *pSetActive = nullptr, *pVCon = nullptr, *pLastVCon = nullptr;
|
||||
@ -3403,7 +3401,7 @@ CVirtualConsole* CConEmuMain::CreateConGroup(LPCWSTR apszScript, const RConStart
|
||||
}
|
||||
|
||||
if (apDefArgs && apDefArgs->pszStartupDir && *apDefArgs->pszStartupDir)
|
||||
args.pszStartupDir = lstrdup(apDefArgs->pszStartupDir);
|
||||
args.pszStartupDir = lstrdup(apDefArgs->pszStartupDir).Detach();
|
||||
else
|
||||
SafeFree(args.pszStartupDir);
|
||||
|
||||
@ -3433,7 +3431,7 @@ CVirtualConsole* CConEmuMain::CreateConGroup(LPCWSTR apszScript, const RConStart
|
||||
if (*pszLine)
|
||||
{
|
||||
SafeFree(args.pszSpecialCmd);
|
||||
args.pszSpecialCmd = lstrdup(pszLine);
|
||||
args.pszSpecialCmd = lstrdup(pszLine).Detach();
|
||||
|
||||
// If any previous tab was marked as "active"/"foreground" for starting group,
|
||||
// we need to run others tabs in "background"
|
||||
@ -3491,7 +3489,6 @@ CVirtualConsole* CConEmuMain::CreateConGroup(LPCWSTR apszScript, const RConStart
|
||||
|
||||
pVConResult = (pSetActive ? pSetActive : pLastVCon);
|
||||
wrap:
|
||||
SafeFree(pszDataW);
|
||||
CVConGroup::OnCreateGroupEnd();
|
||||
return pVConResult;
|
||||
}
|
||||
@ -3626,7 +3623,7 @@ void CConEmuMain::SetTitle(HWND ahWnd, LPCWSTR asTitle, bool abTrySync /*= false
|
||||
impl(HWND ahWnd, LPCWSTR asTitle, CConEmuMain* apConEmu)
|
||||
{
|
||||
hWnd = ahWnd;
|
||||
psTitle = lstrdup(asTitle);
|
||||
psTitle = lstrdup(asTitle).Detach();
|
||||
pConEmu = apConEmu;
|
||||
};
|
||||
static LRESULT setTitle(LPARAM lParam)
|
||||
@ -3665,12 +3662,12 @@ void CConEmuMain::ExecuteProcessFinished(bool bOpt)
|
||||
|
||||
void CConEmuMain::SetPostGuiMacro(LPCWSTR asGuiMacro)
|
||||
{
|
||||
ConEmuMacro::ConcatMacro(ms_PostGuiMacro.ms_Val, asGuiMacro);
|
||||
ConEmuMacro::ConcatMacro(ms_PostGuiMacro, asGuiMacro);
|
||||
}
|
||||
|
||||
void CConEmuMain::AddPostGuiRConMacro(LPCWSTR asGuiMacro)
|
||||
{
|
||||
ConEmuMacro::ConcatMacro(ms_PostRConMacro.ms_Val, asGuiMacro);
|
||||
ConEmuMacro::ConcatMacro(ms_PostRConMacro, asGuiMacro);
|
||||
}
|
||||
|
||||
void CConEmuMain::ExecPostGuiMacro()
|
||||
@ -3683,18 +3680,14 @@ void CConEmuMain::ExecPostGuiMacro()
|
||||
|
||||
if (!ms_PostGuiMacro.IsEmpty())
|
||||
{
|
||||
wchar_t* pszMacro = ms_PostGuiMacro.Detach();
|
||||
LPWSTR pszRc = ConEmuMacro::ExecuteMacro(pszMacro, VCon.VCon() ? VCon->RCon() : nullptr);
|
||||
SafeFree(pszRc);
|
||||
SafeFree(pszMacro);
|
||||
CEStr pszMacro = std::move(ms_PostGuiMacro);
|
||||
CEStr pszRc = ConEmuMacro::ExecuteMacro(std::move(pszMacro), VCon.VCon() ? VCon->RCon() : nullptr);
|
||||
}
|
||||
|
||||
if (!ms_PostRConMacro.IsEmpty() && VCon.VCon())
|
||||
{
|
||||
wchar_t* pszMacro = ms_PostRConMacro.Detach();
|
||||
LPWSTR pszRc = ConEmuMacro::ExecuteMacro(pszMacro, VCon.VCon() ? VCon->RCon() : nullptr);
|
||||
SafeFree(pszRc);
|
||||
SafeFree(pszMacro);
|
||||
CEStr pszMacro = std::move(ms_PostRConMacro);
|
||||
CEStr pszRc = ConEmuMacro::ExecuteMacro(std::move(pszMacro), VCon.VCon() ? VCon->RCon() : nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3807,7 +3800,7 @@ void CConEmuMain::LoadIcons()
|
||||
}
|
||||
else
|
||||
{
|
||||
lsLog.Attach(lstrmerge(L"Loading icon `", szIconPath, L"`"));
|
||||
lsLog = CEStr(L"Loading icon `", szIconPath, L"`");
|
||||
}
|
||||
}
|
||||
|
||||
@ -3833,7 +3826,7 @@ void CConEmuMain::LoadIcons()
|
||||
|
||||
if (hClassIcon)
|
||||
{
|
||||
lsLog.Attach(lstrmerge(L"External icons were loaded, small=", hClassIconSm?L"OK":L"nullptr", L", large=", hClassIcon?L"OK":L"nullptr"));
|
||||
lsLog = CEStr(L"External icons were loaded, small=", hClassIconSm?L"OK":L"nullptr", L", large=", hClassIcon?L"OK":L"nullptr");
|
||||
LogString(lsLog);
|
||||
}
|
||||
else
|
||||
@ -3963,7 +3956,7 @@ void CConEmuMain::PostMacroFontSetName(wchar_t* pszFontName, WORD anHeight /*= 0
|
||||
{
|
||||
if (!abPosted)
|
||||
{
|
||||
wchar_t* pszDup = lstrdup(pszFontName);
|
||||
wchar_t* pszDup = lstrdup(pszFontName).Detach();
|
||||
WPARAM wParam = (((DWORD)anHeight) << 16) | (anWidth);
|
||||
PostMessage(ghWnd, mn_MsgMacroFontSetName, wParam, (LPARAM)pszDup);
|
||||
}
|
||||
@ -4123,7 +4116,7 @@ bool CConEmuMain::RecreateAction(RecreateActionParm aRecreate, BOOL abConfirm, R
|
||||
{
|
||||
_ASSERTE((args.pszSpecialCmd && *args.pszSpecialCmd) || !abConfirm);
|
||||
SafeFree(args.pszSpecialCmd);
|
||||
args.pszSpecialCmd = lstrdup(GetCmd());
|
||||
args.pszSpecialCmd = lstrdup(GetCmd()).Detach();
|
||||
}
|
||||
|
||||
if (!args.pszSpecialCmd || !*args.pszSpecialCmd)
|
||||
@ -4312,8 +4305,7 @@ int CConEmuMain::RunSingleInstance(HWND hConEmuWnd /*= nullptr*/, LPCWSTR apszCm
|
||||
if (lpszCmd && (*lpszCmd == TaskBracketLeft) && !mb_ConEmuWorkDirArg && !mb_ConEmuHere)
|
||||
{
|
||||
RConStartArgsEx args;
|
||||
wchar_t* pszDataW = LoadConsoleBatch(lpszCmd, &args);
|
||||
SafeFree(pszDataW);
|
||||
const CEStr pszDataW = LoadConsoleBatch(lpszCmd, &args);
|
||||
if (args.pszStartupDir && *args.pszStartupDir)
|
||||
{
|
||||
lstrcpyn(pIn->NewCmd.szCurDir, args.pszStartupDir, countof(pIn->NewCmd.szCurDir));
|
||||
@ -6198,18 +6190,18 @@ wchar_t CConEmuMain::IsConsoleBatchOrTask(LPCWSTR asSource)
|
||||
return Supported;
|
||||
}
|
||||
|
||||
wchar_t* CConEmuMain::LoadConsoleBatch(LPCWSTR asSource, RConStartArgsEx* pArgs /*= nullptr*/)
|
||||
CEStr CConEmuMain::LoadConsoleBatch(LPCWSTR asSource, RConStartArgsEx* pArgs /*= nullptr*/)
|
||||
{
|
||||
if (pArgs && pArgs->pszTaskName)
|
||||
{
|
||||
SafeFree(pArgs->pszTaskName);
|
||||
}
|
||||
|
||||
wchar_t cType = IsConsoleBatchOrTask(asSource);
|
||||
const wchar_t cType = IsConsoleBatchOrTask(asSource);
|
||||
if (!cType)
|
||||
{
|
||||
_ASSERTE(asSource && (*asSource==CmdFilePrefix || *asSource==TaskBracketLeft));
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
|
||||
// If task name is quoted
|
||||
@ -6230,25 +6222,25 @@ wchar_t* CConEmuMain::LoadConsoleBatch(LPCWSTR asSource, RConStartArgsEx* pArgs
|
||||
}
|
||||
}
|
||||
|
||||
wchar_t* pszDataW = nullptr;
|
||||
CEStr result;
|
||||
|
||||
switch (cType)
|
||||
{
|
||||
case CmdFilePrefix:
|
||||
// В качестве "команды" указан "пакетный файл" одновременного запуска нескольких консолей
|
||||
pszDataW = LoadConsoleBatch_File(asSource);
|
||||
// it's a "batch" file for simultaneous run of several consoles
|
||||
result = LoadConsoleBatch_File(asSource);
|
||||
break;
|
||||
|
||||
case TaskBracketLeft:
|
||||
case AutoStartTaskLeft: // AutoStartTaskName
|
||||
// Имя задачи
|
||||
pszDataW = LoadConsoleBatch_Task(asSource, pArgs);
|
||||
// The Task name
|
||||
result = LoadConsoleBatch_Task(asSource, pArgs);
|
||||
break;
|
||||
|
||||
case DropLnkPrefix:
|
||||
// Сюда мы попадаем, если на ConEmu (или его ярлык)
|
||||
// набрасывают (в проводнике?) один или несколько других файлов/программ
|
||||
pszDataW = LoadConsoleBatch_Drops(asSource);
|
||||
// We get here when on ConEmu (or it's desktop shortcut) user
|
||||
// drops (D&D) one or several other items.
|
||||
result = LoadConsoleBatch_Drops(asSource);
|
||||
break;
|
||||
|
||||
#ifdef _DEBUG
|
||||
@ -6257,49 +6249,38 @@ wchar_t* CConEmuMain::LoadConsoleBatch(LPCWSTR asSource, RConStartArgsEx* pArgs
|
||||
#endif
|
||||
}
|
||||
|
||||
return pszDataW;
|
||||
return result;
|
||||
}
|
||||
|
||||
wchar_t* CConEmuMain::LoadConsoleBatch_File(LPCWSTR asSource)
|
||||
CEStr CConEmuMain::LoadConsoleBatch_File(LPCWSTR asSource)
|
||||
{
|
||||
wchar_t* pszDataW = nullptr;
|
||||
CEStr pszDataW;
|
||||
|
||||
if (asSource && (*asSource == CmdFilePrefix))
|
||||
{
|
||||
// В качестве "команды" указан "пакетный файл" одновременного запуска нескольких консолей
|
||||
DWORD nSize = 0, nErrCode = 0;
|
||||
int iRead = ReadTextFile(asSource+1, (1<<20), pszDataW, nSize, nErrCode);
|
||||
const int iRead = ReadTextFile(asSource + 1, (1 << 20), pszDataW, nSize, nErrCode);
|
||||
|
||||
if (iRead == -1)
|
||||
{
|
||||
wchar_t szCurDir[MAX_PATH*2]; szCurDir[0] = 0; GetCurrentDirectory(countof(szCurDir), szCurDir);
|
||||
size_t cchMax = _tcslen(asSource)+100+_tcslen(szCurDir);
|
||||
wchar_t* pszErrMsg = (wchar_t*)calloc(cchMax,2);
|
||||
_wcscpy_c(pszErrMsg, cchMax, L"Can't open console batch file:\n" L"\x2018"/*‘*/);
|
||||
_wcscat_c(pszErrMsg, cchMax, asSource+1);
|
||||
_wcscat_c(pszErrMsg, cchMax, L"\x2019"/*’*/ L"\nCurrent directory:\n" L"\x2018"/*‘*/);
|
||||
_wcscat_c(pszErrMsg, cchMax, szCurDir);
|
||||
_wcscat_c(pszErrMsg, cchMax, L"\x2019"/*’*/);
|
||||
DisplayLastError(pszErrMsg, nErrCode);
|
||||
free(pszErrMsg);
|
||||
//Destroy(); -- must caller
|
||||
const CEStr szCurDir = GetCurDir();
|
||||
const CEStr szErrMsg(L"Can't open console batch file:\n" L"\x2018"/*‘*/, asSource + 1, L"\x2019"/*’*/ L"\nCurrent directory:\n" L"\x2018"/*‘*/, szCurDir, L"\x2019"/*’*/);
|
||||
DisplayLastError(szErrMsg, nErrCode);
|
||||
//Destroy(); -- must do caller
|
||||
return nullptr;
|
||||
}
|
||||
else if (iRead == -2)
|
||||
{
|
||||
wchar_t* pszErrMsg = (wchar_t*)calloc(_tcslen(asSource)+100,2);
|
||||
lstrcpy(pszErrMsg, L"Console batch file is too large or empty:\n" L"\x2018"/*‘*/); lstrcat(pszErrMsg, asSource+1); lstrcat(pszErrMsg, L"\x2019"/*’*/);
|
||||
DisplayLastError(pszErrMsg, nErrCode);
|
||||
free(pszErrMsg);
|
||||
const CEStr szErrMsg(L"Console batch file is too large or empty:\n" L"\x2018"/*‘*/, asSource + 1, L"\x2019"/*’*/);
|
||||
DisplayLastError(szErrMsg, nErrCode);
|
||||
//Destroy(); -- must caller
|
||||
return nullptr;
|
||||
}
|
||||
else if (iRead < 0)
|
||||
{
|
||||
wchar_t* pszErrMsg = (wchar_t*)calloc(_tcslen(asSource)+100,2);
|
||||
lstrcpy(pszErrMsg, L"Reading console batch file failed:\n" L"\x2018"/*‘*/); lstrcat(pszErrMsg, asSource+1); lstrcat(pszErrMsg, L"\x2019"/*’*/);
|
||||
DisplayLastError(pszErrMsg, nErrCode);
|
||||
free(pszErrMsg);
|
||||
const CEStr szErrMsg(L"Reading console batch file failed:\n" L"\x2018"/*‘*/, asSource + 1, L"\x2019"/*’*/);
|
||||
DisplayLastError(szErrMsg, nErrCode);
|
||||
//Destroy(); -- must caller
|
||||
return nullptr;
|
||||
}
|
||||
@ -6313,9 +6294,9 @@ wchar_t* CConEmuMain::LoadConsoleBatch_File(LPCWSTR asSource)
|
||||
return pszDataW;
|
||||
}
|
||||
|
||||
wchar_t* CConEmuMain::LoadConsoleBatch_Drops(LPCWSTR asSource)
|
||||
CEStr CConEmuMain::LoadConsoleBatch_Drops(LPCWSTR asSource)
|
||||
{
|
||||
wchar_t* pszDataW = nullptr;
|
||||
CEStr pszDataW;
|
||||
|
||||
if (asSource && (*asSource == DropLnkPrefix))
|
||||
{
|
||||
@ -6362,9 +6343,11 @@ wchar_t* CConEmuMain::LoadConsoleBatch_Drops(LPCWSTR asSource)
|
||||
}
|
||||
|
||||
// Поехали
|
||||
LPWSTR pszConsoles[MAX_CONSOLE_COUNT] = {};
|
||||
CEStrConcat pszConsoles;
|
||||
pszConsoles.Reserve(MAX_CONSOLE_COUNT * 2);
|
||||
const wchar_t lineDelim[] = L"\r\n";
|
||||
size_t cchLen, cchAllLen = 0, iCount = 0;
|
||||
while ((iCount < MAX_CONSOLE_COUNT) && (asSource = NextArg(asSource, szPart)))
|
||||
while ((iCount < MAX_CONSOLE_COUNT) && ((asSource = NextArg(asSource, szPart))))
|
||||
{
|
||||
if (lstrcmpi(PointToExt(szPart), L".lnk") == 0)
|
||||
{
|
||||
@ -6385,16 +6368,21 @@ wchar_t* CConEmuMain::LoadConsoleBatch_Drops(LPCWSTR asSource)
|
||||
cchLen = _tcslen(szExe)+3
|
||||
+ _tcslen(pszArguments)+1
|
||||
+ (*szDir ? (_tcslen(szDir)+32) : 0); // + "-new_console:d<Dir>
|
||||
pszConsoles[iCount] = (wchar_t*)malloc(cchLen*sizeof(wchar_t));
|
||||
swprintf_c(pszConsoles[iCount], cchLen/*#SECURELEN*/, L"\"%s\"%s%s",
|
||||
CEStr console;
|
||||
if (console.GetBuffer(cchLen))
|
||||
{
|
||||
swprintf_c(console.data(), console.GetMaxCount(), L"\"%s\"%s%s",
|
||||
Unquote(szExe), *pszArguments ? L" " : L"", pszArguments);
|
||||
if (*szDir)
|
||||
{
|
||||
_wcscat_c(pszConsoles[iCount], cchLen, L" \"-new_console:d");
|
||||
_wcscat_c(pszConsoles[iCount], cchLen, Unquote(szDir));
|
||||
_wcscat_c(pszConsoles[iCount], cchLen, L"\"");
|
||||
console.Append(L" \"-new_console:d");
|
||||
console.Append(Unquote(szDir));
|
||||
console.Append(L"\"");
|
||||
}
|
||||
pszConsoles.Append(std::move(console));
|
||||
pszConsoles.Append(lineDelim);
|
||||
iCount++;
|
||||
}
|
||||
|
||||
cchAllLen += cchLen+3;
|
||||
}
|
||||
@ -6403,9 +6391,14 @@ wchar_t* CConEmuMain::LoadConsoleBatch_Drops(LPCWSTR asSource)
|
||||
else
|
||||
{
|
||||
cchLen = _tcslen(szPart) + 3;
|
||||
pszConsoles[iCount] = (wchar_t*)malloc(cchLen*sizeof(wchar_t));
|
||||
swprintf_c(pszConsoles[iCount], cchLen/*#SECURELEN*/, L"\"%s\"", (LPCWSTR)szPart);
|
||||
CEStr console;
|
||||
if (console.GetBuffer(cchLen))
|
||||
{
|
||||
swprintf_c(console.data(), console.GetMaxCount(), L"\"%s\"", szPart.c_str());
|
||||
pszConsoles.Append(std::move(console));
|
||||
pszConsoles.Append(lineDelim);
|
||||
iCount++;
|
||||
}
|
||||
|
||||
cchAllLen += cchLen+3;
|
||||
}
|
||||
@ -6422,17 +6415,9 @@ wchar_t* CConEmuMain::LoadConsoleBatch_Drops(LPCWSTR asSource)
|
||||
return nullptr;
|
||||
|
||||
if (iCount == 1)
|
||||
return pszConsoles[0];
|
||||
|
||||
// Теперь - собрать pszDataW
|
||||
pszDataW = (wchar_t*)malloc(cchAllLen*sizeof(*pszDataW));
|
||||
*pszDataW = 0;
|
||||
for (size_t i = 0; i < iCount; i++)
|
||||
{
|
||||
_wcscat_c(pszDataW, cchAllLen, pszConsoles[i]);
|
||||
_wcscat_c(pszDataW, cchAllLen, L"\r\n");
|
||||
free(pszConsoles[i]);
|
||||
}
|
||||
pszDataW = std::move(pszConsoles.GetString(0));
|
||||
else
|
||||
pszDataW = pszConsoles.GetData();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -6442,9 +6427,9 @@ wchar_t* CConEmuMain::LoadConsoleBatch_Drops(LPCWSTR asSource)
|
||||
return pszDataW;
|
||||
}
|
||||
|
||||
wchar_t* CConEmuMain::LoadConsoleBatch_Task(LPCWSTR asSource, RConStartArgsEx* pArgs /*= nullptr*/)
|
||||
CEStr CConEmuMain::LoadConsoleBatch_Task(LPCWSTR asSource, RConStartArgsEx* pArgs /*= nullptr*/)
|
||||
{
|
||||
wchar_t* pszDataW = nullptr;
|
||||
CEStr pszDataW;
|
||||
|
||||
if (asSource && ((*asSource == TaskBracketLeft) || (lstrcmp(asSource, AutoStartTaskName) == 0)))
|
||||
{
|
||||
@ -6464,14 +6449,14 @@ wchar_t* CConEmuMain::LoadConsoleBatch_Task(LPCWSTR asSource, RConStartArgsEx* p
|
||||
if (pGrp)
|
||||
{
|
||||
if (pArgs)
|
||||
pArgs->pszTaskName = lstrdup(szName);
|
||||
pArgs->pszTaskName = lstrdup(szName).Detach();
|
||||
|
||||
// TODO: Supposed to be appended to EACH command (task line),
|
||||
// TODO: but now lsTail may be appended to single-command tasks only
|
||||
if (pGrp->pszCommands && !wcschr(pGrp->pszCommands, L'\n'))
|
||||
pszDataW = lstrmerge(pGrp->pszCommands, lsTail.IsEmpty() ? nullptr : L" ", lsTail.ms_Val);
|
||||
pszDataW = CEStr(pGrp->pszCommands, lsTail.IsEmpty() ? nullptr : L" ", lsTail.ms_Val);
|
||||
else
|
||||
pszDataW = lstrdup(pGrp->pszCommands);
|
||||
pszDataW.Set(pGrp->pszCommands);
|
||||
|
||||
if (pArgs && pGrp->pszGuiArgs)
|
||||
{
|
||||
@ -6493,16 +6478,18 @@ wchar_t* CConEmuMain::LoadConsoleBatch_Task(LPCWSTR asSource, RConStartArgsEx* p
|
||||
|
||||
if (!pszDataW || !*pszDataW)
|
||||
{
|
||||
size_t cchMax = _tcslen(szName)+100;
|
||||
wchar_t* pszErrMsg = (wchar_t*)calloc(cchMax,sizeof(*pszErrMsg));
|
||||
swprintf_c(pszErrMsg, cchMax/*#SECURELEN*/, L"Command group %s %s!\n"
|
||||
ssize_t cchMax = _tcslen(szName) + 100;
|
||||
CEStr pszErrMsg;
|
||||
if (pszErrMsg.GetBuffer(cchMax))
|
||||
{
|
||||
swprintf_c(pszErrMsg.data(), pszErrMsg.GetMaxCount(), L"Command group %s %s!\n"
|
||||
L"Choose your shell?",
|
||||
(LPCWSTR)szName, pszDataW ? L"is empty" : L"not found");
|
||||
szName.c_str(L""), pszDataW ? L"is empty" : L"not found");
|
||||
}
|
||||
const int nBtn = MsgBox(pszErrMsg.c_str(L"Choose your shell?"), MB_YESNO | MB_ICONEXCLAMATION);
|
||||
|
||||
int nBtn = MsgBox(pszErrMsg, MB_YESNO|MB_ICONEXCLAMATION);
|
||||
|
||||
SafeFree(pszErrMsg);
|
||||
SafeFree(pszDataW);
|
||||
pszErrMsg.Release();
|
||||
pszDataW.Release();
|
||||
|
||||
if (nBtn == IDYES)
|
||||
{
|
||||
@ -6513,19 +6500,19 @@ wchar_t* CConEmuMain::LoadConsoleBatch_Task(LPCWSTR asSource, RConStartArgsEx* p
|
||||
if (pszDefCmd && *pszDefCmd)
|
||||
{
|
||||
SafeFree(args.pszSpecialCmd);
|
||||
args.pszSpecialCmd = lstrdup(pszDefCmd);
|
||||
args.pszSpecialCmd = lstrdup(pszDefCmd).Detach();
|
||||
}
|
||||
|
||||
int nCreateRc = RecreateDlg(&args);
|
||||
|
||||
if ((nCreateRc == IDC_START) && args.pszSpecialCmd && *args.pszSpecialCmd)
|
||||
{
|
||||
wchar_t* pszNewCmd = nullptr;
|
||||
CEStr pszNewCmd;
|
||||
if ((*args.pszSpecialCmd == CmdFilePrefix) || (*args.pszSpecialCmd == TaskBracketLeft))
|
||||
{
|
||||
wchar_t* pszTaskName = args.pszSpecialCmd; args.pszSpecialCmd = nullptr;
|
||||
CEStr pszTaskName; pszTaskName.Attach(std::move(args.pszSpecialCmd));
|
||||
args.pszSpecialCmd = nullptr; // reset command as we pass args (as extra options) into LoadConsoleBatch
|
||||
pszNewCmd = LoadConsoleBatch(pszTaskName, &args);
|
||||
free(pszTaskName);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -6561,7 +6548,7 @@ bool CConEmuMain::CreateStartupConsoles()
|
||||
|
||||
if (isScript)
|
||||
{
|
||||
CEStr szDataW((LPCWSTR)pszCmd);
|
||||
CEStr szDataW(pszCmd);
|
||||
|
||||
// "Script" is a Task represented as one string with "|||" as command delimiter
|
||||
// Replace "|||" to "\r\n" as standard Task expects
|
||||
@ -6592,7 +6579,7 @@ bool CConEmuMain::CreateStartupConsoles()
|
||||
RConStartArgsEx args;
|
||||
// Was "/dir" specified in the app switches?
|
||||
if (mb_ConEmuWorkDirArg)
|
||||
args.pszStartupDir = lstrdup(ms_ConEmuWorkDir);
|
||||
args.pszStartupDir = lstrdup(ms_ConEmuWorkDir).Detach();
|
||||
CEStr lsLog(L"Creating console group using task ", pszCmd);
|
||||
LogString(lsLog);
|
||||
// Here are either text file with Task contents, or just a Task name
|
||||
@ -6619,7 +6606,7 @@ bool CConEmuMain::CreateStartupConsoles()
|
||||
args.Detached = crb_Off;
|
||||
|
||||
SafeFree(args.pszSpecialCmd);
|
||||
args.pszSpecialCmd = lstrdup(GetCmd());
|
||||
args.pszSpecialCmd = lstrdup(GetCmd()).Detach();
|
||||
|
||||
CEStr lsLog(L"Creating console using command ", args.pszSpecialCmd);
|
||||
LogString(lsLog);
|
||||
|
@ -158,7 +158,7 @@ class CConEmuMain
|
||||
LPCWSTR WorkDir(LPCWSTR asOverrideCurDir = nullptr);
|
||||
bool ChangeWorkDir(LPCWSTR asTempCurDir);
|
||||
private:
|
||||
LPWSTR mps_ConEmuExtraArgs = nullptr; // Used with TaskBar jump list creation (/FontDir, /FontFile, etc.)
|
||||
CEStr mps_ConEmuExtraArgs; // Used with TaskBar jump list creation (/FontDir, /FontFile, etc.)
|
||||
public:
|
||||
void AppendExtraArgs(LPCWSTR asSwitch, LPCWSTR asSwitchValue = nullptr);
|
||||
LPCWSTR MakeConEmuStartArgs(CEStr& rsArgs, LPCWSTR asOtherConfig = nullptr) const;
|
||||
@ -501,12 +501,12 @@ class CConEmuMain
|
||||
HWND mh_RightClickingWnd = nullptr;
|
||||
bool PatchMouseEvent(UINT messg, POINT& ptCurClient, POINT& ptCurScreen, WPARAM wParam, bool& isPrivate);
|
||||
public:
|
||||
wchar_t* LoadConsoleBatch(LPCWSTR asSource, RConStartArgsEx* pArgs = nullptr);
|
||||
CEStr LoadConsoleBatch(LPCWSTR asSource, RConStartArgsEx* pArgs = nullptr);
|
||||
static wchar_t IsConsoleBatchOrTask(LPCWSTR asSource);
|
||||
private:
|
||||
wchar_t* LoadConsoleBatch_File(LPCWSTR asSource);
|
||||
wchar_t* LoadConsoleBatch_Drops(LPCWSTR asSource);
|
||||
wchar_t* LoadConsoleBatch_Task(LPCWSTR asSource, RConStartArgsEx* pArgs = nullptr);
|
||||
CEStr LoadConsoleBatch_File(LPCWSTR asSource);
|
||||
CEStr LoadConsoleBatch_Drops(LPCWSTR asSource);
|
||||
CEStr LoadConsoleBatch_Task(LPCWSTR asSource, RConStartArgsEx* pArgs = nullptr);
|
||||
public:
|
||||
void RightClickingPaint(HDC hdcIntVCon, CVirtualConsole* apVCon);
|
||||
void CtrlWinAltSpace();
|
||||
|
@ -298,27 +298,14 @@ bool GetDlgItemUnsigned(HWND hDlg, WORD nID, DWORD& nValue, DWORD nMin /*= 0*/,
|
||||
return true;
|
||||
}
|
||||
|
||||
wchar_t* GetDlgItemTextPtr(HWND hDlg, WORD nID)
|
||||
CEStr GetDlgItemTextPtr(HWND hDlg, WORD nID)
|
||||
{
|
||||
wchar_t* pszText = nullptr;
|
||||
size_t cchMax = 0;
|
||||
MyGetDlgItemText(hDlg, nID, cchMax, pszText);
|
||||
return pszText;
|
||||
CEStr result;
|
||||
MyGetDlgItemText(hDlg, nID, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <size_t size>
|
||||
int MyGetDlgItemText(HWND hDlg, WORD nID, wchar_t (&rszText)[size])
|
||||
{
|
||||
CEStr szText;
|
||||
size_t cchMax = 0;
|
||||
int nLen = MyGetDlgItemText(hDlg, nID, cchMax, szText.ms_Val);
|
||||
if (lstrcmp(rszText, szText.ms_Val) == 0)
|
||||
return false;
|
||||
lstrcpyn(rszText, szText.ms_Val, size);
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t MyGetDlgItemText(HWND hDlg, WORD nID, size_t& cchMax, wchar_t*& pszText)
|
||||
size_t MyGetDlgItemText(HWND hDlg, WORD nID, CEStr& rsText)
|
||||
{
|
||||
HWND hEdit;
|
||||
|
||||
@ -328,35 +315,30 @@ size_t MyGetDlgItemText(HWND hDlg, WORD nID, size_t& cchMax, wchar_t*& pszText)
|
||||
hEdit = hDlg;
|
||||
|
||||
if (!hEdit)
|
||||
{
|
||||
rsText.Clear();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
int nLen = GetWindowTextLength(hEdit);
|
||||
int nLen = GetWindowTextLengthW(hEdit);
|
||||
|
||||
if (nLen > 0)
|
||||
{
|
||||
if (!pszText || (((UINT)nLen) >= cchMax))
|
||||
if (!rsText.GetBuffer(nLen))
|
||||
{
|
||||
SafeFree(pszText);
|
||||
cchMax = nLen+32;
|
||||
pszText = (wchar_t*)calloc(cchMax,sizeof(*pszText));
|
||||
_ASSERTE(pszText);
|
||||
_ASSERTE(rsText.data() != nullptr)
|
||||
}
|
||||
|
||||
|
||||
if (pszText)
|
||||
else
|
||||
{
|
||||
pszText[0] = 0;
|
||||
GetWindowText(hEdit, pszText, nLen+1);
|
||||
rsText.SetAt(0, 0);
|
||||
GetWindowTextW(hEdit, rsText.data(), rsText.GetMaxCount());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_ASSERTE(nLen == 0);
|
||||
nLen = 0;
|
||||
|
||||
if (pszText)
|
||||
*pszText = 0;
|
||||
rsText.Clear();
|
||||
}
|
||||
|
||||
return nLen;
|
||||
@ -445,9 +427,9 @@ bool GetColorRef(LPCWSTR pszText, COLORREF* pCR)
|
||||
}
|
||||
|
||||
|
||||
wchar_t* SelectFolder(LPCWSTR asTitle, LPCWSTR asDefFolder /*= nullptr*/, HWND hParent /*= ghWnd*/, DWORD/*CESelectFileFlags*/ nFlags /*= sff_AutoQuote*/, CRealConsole* apRCon /*= nullptr*/)
|
||||
CEStr SelectFolder(LPCWSTR asTitle, LPCWSTR asDefFolder /*= nullptr*/, HWND hParent /*= ghWnd*/, DWORD/*CESelectFileFlags*/ nFlags /*= sff_AutoQuote*/, CRealConsole* apRCon /*= nullptr*/)
|
||||
{
|
||||
wchar_t* pszResult = nullptr;
|
||||
CEStr pszResult = nullptr;
|
||||
|
||||
BROWSEINFO bi = {hParent};
|
||||
wchar_t szFolder[MAX_PATH+1] = {0};
|
||||
@ -469,23 +451,15 @@ wchar_t* SelectFolder(LPCWSTR asTitle, LPCWSTR asDefFolder /*= nullptr*/, HWND h
|
||||
{
|
||||
CEStr path;
|
||||
if (DupCygwinPath(szFolder, (nFlags & sff_AutoQuote), apRCon ? apRCon->GetMntPrefix() : nullptr, path))
|
||||
pszResult = path.Detach();
|
||||
pszResult = std::move(path);
|
||||
}
|
||||
else if ((nFlags & sff_AutoQuote) && (wcschr(szFolder, L' ') != nullptr))
|
||||
{
|
||||
size_t cchLen = _tcslen(szFolder);
|
||||
pszResult = (wchar_t*)malloc((cchLen+3)*sizeof(*pszResult));
|
||||
if (pszResult)
|
||||
{
|
||||
pszResult[0] = L'"';
|
||||
_wcscpy_c(pszResult+1, cchLen+1, szFolder);
|
||||
pszResult[cchLen+1] = L'"';
|
||||
pszResult[cchLen+2] = 0;
|
||||
}
|
||||
pszResult = CEStr(L"\"", szFolder, L"\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
pszResult = lstrdup(szFolder);
|
||||
pszResult.Set(szFolder);
|
||||
}
|
||||
}
|
||||
|
||||
@ -495,21 +469,22 @@ wchar_t* SelectFolder(LPCWSTR asTitle, LPCWSTR asDefFolder /*= nullptr*/, HWND h
|
||||
return pszResult;
|
||||
}
|
||||
|
||||
wchar_t* SelectFile(LPCWSTR asTitle, LPCWSTR asDefFile /*= nullptr*/, LPCWSTR asDefPath /*= nullptr*/, HWND hParent /*= ghWnd*/, LPCWSTR asFilter /*= nullptr*/, DWORD/*CESelectFileFlags*/ nFlags /*= sff_AutoQuote*/, CRealConsole* apRCon /*= nullptr*/)
|
||||
CEStr SelectFile(LPCWSTR asTitle, LPCWSTR asDefFile /*= nullptr*/, LPCWSTR asDefPath /*= nullptr*/, HWND hParent /*= ghWnd*/, LPCWSTR asFilter /*= nullptr*/, DWORD/*CESelectFileFlags*/ nFlags /*= sff_AutoQuote*/, CRealConsole* apRCon /*= nullptr*/)
|
||||
{
|
||||
wchar_t* pszResult = nullptr;
|
||||
CEStr pszResult;
|
||||
|
||||
wchar_t temp[MAX_PATH+10] = {};
|
||||
wchar_t temp[MAX_PATH] = {};
|
||||
if (asDefFile)
|
||||
_wcscpy_c(temp+1, countof(temp)-2, asDefFile);
|
||||
_wcscpy_c(temp, countof(temp), asDefFile);
|
||||
|
||||
OPENFILENAME ofn = {sizeof(ofn)};
|
||||
OPENFILENAME ofn{};
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = hParent;
|
||||
ofn.lpstrFilter = asFilter ? asFilter : L"All files (*.*)\0*.*\0Text files (*.txt,*.ini,*.log)\0*.txt;*.ini;*.log\0Executables (*.exe,*.com,*.bat,*.cmd)\0*.exe;*.com;*.bat;*.cmd\0Scripts (*.vbs,*.vbe,*.js,*.jse)\0*.vbs;*.vbe;*.js;*.jse\0\0";
|
||||
//ofn.lpstrFilter = L"All files (*.*)\0*.*\0\0";
|
||||
ofn.lpstrFile = temp+1;
|
||||
ofn.lpstrFile = temp;
|
||||
ofn.lpstrInitialDir = asDefPath;
|
||||
ofn.nMaxFile = countof(temp)-10;
|
||||
ofn.nMaxFile = countof(temp);
|
||||
ofn.lpstrTitle = asTitle ? asTitle : L"Choose file";
|
||||
ofn.Flags = OFN_ENABLESIZING|OFN_NOCHANGEDIR
|
||||
| OFN_PATHMUSTEXIST|OFN_EXPLORER|OFN_HIDEREADONLY|((nFlags & sff_SaveNewFile) ? OFN_OVERWRITEPROMPT : OFN_FILEMUSTEXIST);
|
||||
@ -517,34 +492,28 @@ wchar_t* SelectFile(LPCWSTR asTitle, LPCWSTR asDefFile /*= nullptr*/, LPCWSTR as
|
||||
if (asDefFile && (asDefFile[0] == L'*' && asDefFile[1] == L'.' && asDefFile[2]))
|
||||
ofn.lpstrDefExt = (asDefFile+2);
|
||||
|
||||
BOOL bRc = (nFlags & sff_SaveNewFile)
|
||||
const BOOL bRc = (nFlags & sff_SaveNewFile)
|
||||
? GetSaveFileName(&ofn)
|
||||
: GetOpenFileName(&ofn);
|
||||
|
||||
if (bRc)
|
||||
{
|
||||
LPCWSTR pszName = temp+1;
|
||||
|
||||
if (nFlags & sff_Cygwin)
|
||||
{
|
||||
CEStr path;
|
||||
if (DupCygwinPath(pszName, (nFlags & sff_AutoQuote), apRCon ? apRCon->GetMntPrefix() : nullptr, path))
|
||||
pszResult = path.Detach();
|
||||
if (DupCygwinPath(temp, (nFlags & sff_AutoQuote), apRCon ? apRCon->GetMntPrefix() : nullptr, path))
|
||||
pszResult = std::move(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((nFlags & sff_AutoQuote) && (wcschr(pszName, L' ') != nullptr))
|
||||
if ((nFlags & sff_AutoQuote) && (wcschr(temp, L' ') != nullptr))
|
||||
{
|
||||
temp[0] = L'"';
|
||||
wcscat_c(temp, L"\"");
|
||||
pszName = temp;
|
||||
pszResult = CEStr(L"\"", temp, L"\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
temp[0] = L' ';
|
||||
pszResult.Set(temp);
|
||||
}
|
||||
|
||||
pszResult = lstrdup(pszName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1155,7 +1124,7 @@ HWND FindTopExplorerWindow()
|
||||
return hwndFind;
|
||||
}
|
||||
|
||||
wchar_t* getFocusedExplorerWindowPath()
|
||||
CEStr getFocusedExplorerWindowPath()
|
||||
{
|
||||
#define FE_CHECK_OUTER_FAIL(statement) \
|
||||
if (!SUCCEEDED(statement)) goto outer_fail;
|
||||
@ -1166,7 +1135,7 @@ wchar_t* getFocusedExplorerWindowPath()
|
||||
#define FE_RELEASE(hnd) \
|
||||
if (hnd) { hnd->Release(); hnd = nullptr; }
|
||||
|
||||
wchar_t* ret = nullptr;
|
||||
CEStr ret;
|
||||
wchar_t szPath[MAX_PATH] = L"";
|
||||
|
||||
IShellBrowser *psb = nullptr;
|
||||
@ -1208,7 +1177,7 @@ wchar_t* getFocusedExplorerWindowPath()
|
||||
if (!SHGetPathFromIDList(pidlFolder, szPath) || !*szPath)
|
||||
goto fail;
|
||||
|
||||
ret = lstrdup(szPath);
|
||||
ret.Set(szPath);
|
||||
|
||||
CoTaskMemFree(pidlFolder);
|
||||
|
||||
@ -1348,7 +1317,7 @@ static HRESULT _CreateShellLink(PCWSTR pszArguments, PCWSTR pszPrefix, PCWSTR ps
|
||||
if (!args.pszIconFile)
|
||||
{
|
||||
_ASSERTE(args.pszSpecialCmd == nullptr);
|
||||
args.pszSpecialCmd = lstrdup(pszTemp);
|
||||
args.pszSpecialCmd = lstrdup(pszTemp).Detach();
|
||||
args.ProcessNewConArg();
|
||||
}
|
||||
if (args.pszIconFile)
|
||||
@ -1792,26 +1761,26 @@ HRESULT UpdateAppUserModelID()
|
||||
// Config type/file + [.[No]Quake]
|
||||
if (gpSetCls->isResetBasicSettings)
|
||||
{
|
||||
lstrmerge(&lsTempBuf.ms_Val, L"::Basic", szSuffix);
|
||||
lsTempBuf.Append(L"::Basic", szSuffix);
|
||||
}
|
||||
else if (gpConEmu->opt.ForceUseRegistryPrm)
|
||||
{
|
||||
lstrmerge(&lsTempBuf.ms_Val, L"::Registry", szSuffix);
|
||||
lsTempBuf.Append(L"::Registry", szSuffix);
|
||||
}
|
||||
else if (bSpecialXmlFile && pszConfigFile && *pszConfigFile)
|
||||
{
|
||||
lstrmerge(&lsTempBuf.ms_Val, L"::", pszConfigFile, szSuffix);
|
||||
lsTempBuf.Append(L"::", pszConfigFile, szSuffix);
|
||||
}
|
||||
else
|
||||
{
|
||||
lstrmerge(&lsTempBuf.ms_Val, L"::Xml", szSuffix);
|
||||
lsTempBuf.Append(L"::Xml", szSuffix);
|
||||
}
|
||||
|
||||
// Named configuration?
|
||||
if (!gpSetCls->isResetBasicSettings
|
||||
&& (pszConfigName && *pszConfigName))
|
||||
{
|
||||
lstrmerge(&lsTempBuf.ms_Val, L"::", pszConfigName);
|
||||
lsTempBuf.Append(L"::", pszConfigName);
|
||||
}
|
||||
|
||||
// Create hash - AppID (will go to mapping)
|
||||
@ -2007,7 +1976,7 @@ void AssertBox(LPCTSTR szText, LPCTSTR szFile, const UINT nLine, LPEXCEPTION_POI
|
||||
}
|
||||
|
||||
swprintf_c(szCodes, L"\r\nPreError=%i, PostError=%i, Result=%i", nPreCode, nPostCode, nRet);
|
||||
lstrmerge(&szFull.ms_Val, szCodes);
|
||||
szFull.Append(szCodes);
|
||||
}
|
||||
|
||||
if (nRet == IDRETRY)
|
||||
@ -2087,7 +2056,7 @@ int CheckZoneIdentifiers(bool abAutoUnblock)
|
||||
if (HasZoneIdentifier(lsFile, nZone)
|
||||
&& (nZone != 0 /*LocalComputer*/))
|
||||
{
|
||||
lstrmerge(&szZonedFiles.ms_Val, szZonedFiles.ms_Val ? L"\r\n" : nullptr, lsFile.ms_Val);
|
||||
szZonedFiles.Append(szZonedFiles.ms_Val ? L"\r\n" : nullptr, lsFile.ms_Val);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2168,7 +2137,7 @@ int CheckZoneIdentifiers(bool abAutoUnblock)
|
||||
}
|
||||
}
|
||||
|
||||
lsMsg = lstrmerge(L"Failed to drop ZoneId in file:\r\n", lsFile, L"\r\n\r\n" L"Ignore error and continue?" L"\r\n");
|
||||
lsMsg = CEStr(L"Failed to drop ZoneId in file:\r\n", lsFile, L"\r\n\r\n" L"Ignore error and continue?" L"\r\n");
|
||||
if (DisplayLastError(lsMsg, nErrCode, MB_ICONSTOP|MB_YESNO) != IDYES)
|
||||
{
|
||||
return -1; // Fails to change
|
||||
@ -2678,7 +2647,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
gpSet->isAnsiLog = true;
|
||||
gpSet->isAnsiLogCodes = true;
|
||||
SafeFree(gpSet->pszAnsiLog);
|
||||
gpSet->pszAnsiLog = lstrdup(gpConEmu->opt.AnsiLogPath.GetStr());
|
||||
gpSet->pszAnsiLog = lstrdup(gpConEmu->opt.AnsiLogPath.GetStr()).Detach();
|
||||
}
|
||||
|
||||
DEBUGSTRSTARTUPLOG(L"SettingsLoaded");
|
||||
|
@ -1110,17 +1110,15 @@ bool CConEmuCtrl::key_GuiMacro(const ConEmuChord& VkState, bool TestOnly, const
|
||||
if (hk->GuiMacro && *hk->GuiMacro)
|
||||
{
|
||||
// Т.к. ExecuteMacro издевается над строкой
|
||||
wchar_t* pszCopy = lstrdup(hk->GuiMacro);
|
||||
CEStr pszCopy(hk->GuiMacro);
|
||||
if (!pszCopy)
|
||||
{
|
||||
_ASSERTE(pszCopy); // -V571
|
||||
}
|
||||
else
|
||||
{
|
||||
wchar_t* pszResult = ConEmuMacro::ExecuteMacro(pszCopy, pRCon);
|
||||
CEStr pszResult = ConEmuMacro::ExecuteMacro(std::move(pszCopy), pRCon);
|
||||
TODO("Когда появится StatusLine - хорошо бы в ней результат показать");
|
||||
SafeFree(pszResult);
|
||||
free(pszCopy);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -1133,13 +1131,13 @@ void CConEmuCtrl::ChooseTabFromMenu(BOOL abFirstTabOnly, POINT pt, DWORD Align /
|
||||
if (!Align)
|
||||
Align = TPM_LEFTALIGN|TPM_TOPALIGN;
|
||||
|
||||
int nTab = gpConEmu->mp_Menu->trackPopupMenu(tmp_TabsList, hPopup, Align|TPM_RETURNCMD,
|
||||
const int nTab = gpConEmu->mp_Menu->trackPopupMenu(tmp_TabsList, hPopup, Align|TPM_RETURNCMD,
|
||||
pt.x, pt.y, ghWnd);
|
||||
|
||||
if (nTab >= IDM_VCON_FIRST && nTab <= IDM_VCON_LAST)
|
||||
{
|
||||
int nNewV = ((int)HIWORD(nTab))-1;
|
||||
int nNewR = ((int)LOWORD(nTab))-1;
|
||||
const int nNewV = ((int)HIWORD(nTab)) - 1;
|
||||
const int nNewR = ((int)LOWORD(nTab)) - 1;
|
||||
|
||||
CVConGuard VCon;
|
||||
if (CVConGroup::GetVCon(nNewV, &VCon))
|
||||
@ -1295,9 +1293,9 @@ bool CConEmuCtrl::key_ResetTerminal(const ConEmuChord& /*VkState*/, bool TestOnl
|
||||
return false;
|
||||
}
|
||||
|
||||
const CEStr szMacro(L"Write(\"\\ec\")");
|
||||
const CEStr szResult = ConEmuMacro::ExecuteMacro(szMacro.ms_Val, pRCon);
|
||||
LogString(CEStr(L"Reset terminal macro result: ", szResult));
|
||||
CEStr szMacro(L"Write(\"\\ec\")");
|
||||
const CEStr szResult = ConEmuMacro::ExecuteMacro(std::move(szMacro), pRCon);
|
||||
LogString(CEStr(L"Reset terminal macro result: ", szResult.c_str()));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1554,9 +1552,9 @@ size_t CConEmuCtrl::GetOpenedPanels(wchar_t*& pszDirs, int& iCount, int& iCurren
|
||||
{
|
||||
if (psz[i] && psz[i][0])
|
||||
{
|
||||
int iLen = lstrlen(psz[i]);
|
||||
cchAllLen += (iLen+1);
|
||||
Dirs.push_back(lstrdup(psz[i]));
|
||||
const int iLen = lstrlen(psz[i]);
|
||||
cchAllLen += (iLen + 1);
|
||||
Dirs.push_back(lstrdup(psz[i]).Detach());
|
||||
iCount++;
|
||||
}
|
||||
}
|
||||
@ -1603,8 +1601,7 @@ bool CConEmuCtrl::key_RunTask(const ConEmuChord& VkState, bool TestOnly, const C
|
||||
{
|
||||
wchar_t szMacro[64];
|
||||
swprintf_c(szMacro, L"Task(%i)", hk->GetTaskIndex()+1); //1-based
|
||||
wchar_t* pszResult = ConEmuMacro::ExecuteMacro(szMacro, pRCon);
|
||||
SafeFree(pszResult);
|
||||
CEStr pszResult = ConEmuMacro::ExecuteMacro(szMacro, pRCon);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ void CESwitch::SetStr(LPCWSTR NewVal, CESwitchType NewType /*= sw_Str*/)
|
||||
{
|
||||
if (GetStr())
|
||||
free(Str);
|
||||
Str = (NewVal && *NewVal) ? lstrdup(NewVal) : nullptr;
|
||||
Str = (NewVal && *NewVal) ? lstrdup(NewVal).Detach() : nullptr;
|
||||
Exists = true;
|
||||
if (Type != NewType)
|
||||
{
|
||||
@ -353,12 +353,12 @@ LPCTSTR CConEmuStart::GetCmd(bool *pIsCmdList, bool bNoTask /*= false*/)
|
||||
wcscat_c(szFar, L"\"");
|
||||
|
||||
// Finally - Result
|
||||
pszNewCmd = lstrdup(szFar);
|
||||
pszNewCmd = lstrdup(szFar).Detach();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Если Far.exe не найден рядом с ConEmu - запустить cmd.exe
|
||||
pszNewCmd = GetComspec(&gpSet->ComSpec);
|
||||
pszNewCmd = GetComspec(&gpSet->ComSpec).Detach();
|
||||
//wcscpy_c(szFar, L"cmd");
|
||||
}
|
||||
|
||||
@ -366,7 +366,7 @@ LPCTSTR CConEmuStart::GetCmd(bool *pIsCmdList, bool bNoTask /*= false*/)
|
||||
else
|
||||
{
|
||||
// Simple Copy
|
||||
pszNewCmd = lstrdup(GetDefaultCmd());
|
||||
pszNewCmd = lstrdup(GetDefaultCmd()).Detach();
|
||||
}
|
||||
|
||||
SetCurCmd(pszNewCmd, false);
|
||||
@ -518,7 +518,7 @@ bool CConEmuStart::GetCfgParm(LPCWSTR& cmdLineRest, CESwitch& Val, int nMaxLen,
|
||||
|
||||
// We need independent absolute file paths, Working dir changes during ConEmu session
|
||||
if (bExpandAndDup)
|
||||
Val.Str = GetFullPathNameEx(curCommand); // it allocates memory
|
||||
Val.Str = GetFullPathNameEx(curCommand).Detach(); // it allocates memory
|
||||
else
|
||||
Val.SetStr(curCommand, Val.Type); // #OPTIMIZE - no need to copy, move instead
|
||||
|
||||
@ -543,10 +543,7 @@ void CConEmuStart::ProcessConEmuArgsVar()
|
||||
// Full command line: config switches AND -cmd/-cmdlist
|
||||
_ASSERTE(!opt.cmdLine.IsEmpty());
|
||||
|
||||
// Don't set `nullptr`, it would remove var from env block!
|
||||
LPCWSTR pszValue;
|
||||
|
||||
pszValue = opt.cfgSwitches.IsEmpty() ? L"" : opt.cfgSwitches.ms_Val;
|
||||
const wchar_t* pszValue = opt.cfgSwitches.IsEmpty() ? L"" : opt.cfgSwitches.ms_Val;
|
||||
SetEnvironmentVariableW(L"ConEmuArgs", pszValue);
|
||||
|
||||
if (opt.runCommand.IsEmpty())
|
||||
@ -556,7 +553,7 @@ void CConEmuStart::ProcessConEmuArgsVar()
|
||||
}
|
||||
else
|
||||
{
|
||||
opt.cmdRunCommand.Attach(lstrmerge(opt.isScript ? L"-cmd " : L"-cmdlist ", opt.runCommand));
|
||||
opt.cmdRunCommand.Set(opt.isScript ? L"-cmd " : L"-cmdlist ", opt.runCommand);
|
||||
_ASSERTE(!opt.cmdRunCommand.IsEmpty());
|
||||
SetEnvironmentVariableW(L"ConEmuArgs2", opt.cmdRunCommand);
|
||||
}
|
||||
@ -882,14 +879,14 @@ bool CConEmuStart::ParseCommandLine(LPCWSTR pszCmdLine, int& iResult)
|
||||
{
|
||||
if (pi.dwProcessId)
|
||||
swprintf_c(szExtra, L", PID=%u", pi.dwProcessId);
|
||||
lsLog = lstrmerge(
|
||||
lsLog = CEStr(
|
||||
L"Process was created successfully",
|
||||
szExtra);
|
||||
}
|
||||
else
|
||||
{
|
||||
swprintf_c(szExtra, L", ErrorCode=%u", nErr);
|
||||
lsLog = lstrmerge(
|
||||
lsLog = CEStr(
|
||||
L"Failed to start process",
|
||||
szExtra);
|
||||
}
|
||||
@ -1475,7 +1472,7 @@ bool CConEmuStart::ParseCommandLine(LPCWSTR pszCmdLine, int& iResult)
|
||||
if ((lstrcmpni(pszTestSwitch, L"new_console", 11) == 0)
|
||||
|| (lstrcmpni(pszTestSwitch, L"cur_console", 11) == 0))
|
||||
{
|
||||
szNewConWarn = lstrmerge(L"\r\n\r\n",
|
||||
szNewConWarn = CEStr(L"\r\n\r\n",
|
||||
CLngRc::getRsrc(lng_UnknownSwitch4/*"Switch -new_console must be specified *after* -run or -runlist"*/)
|
||||
);
|
||||
}
|
||||
|
@ -376,7 +376,7 @@ int ConfirmDialog(LPCWSTR asMessage,
|
||||
|
||||
if (!asUrl || !*asUrl)
|
||||
asUrl = gsHomePage;
|
||||
szWebLink = lstrmerge(L"<a href=\"", asUrl, L"\">", asUrl, L"</a>");
|
||||
szWebLink = CEStr(L"<a href=\"", asUrl, L"\">", asUrl, L"</a>");
|
||||
|
||||
switch (uType & 0xF)
|
||||
{
|
||||
@ -454,17 +454,17 @@ int ConfirmDialog(LPCWSTR asMessage,
|
||||
|
||||
if (config.cButtons >= 1)
|
||||
{
|
||||
lsBtn1 = lstrmerge(asBtn1Name ? asBtn1Name : pszName1, asBtn1Hint ? L"\n" : nullptr, asBtn1Hint);
|
||||
lsBtn1 = CEStr(asBtn1Name ? asBtn1Name : pszName1, asBtn1Hint ? L"\n" : nullptr, asBtn1Hint);
|
||||
buttons[0].pszButtonText = lsBtn1.ms_Val;
|
||||
}
|
||||
if (config.cButtons >= 2)
|
||||
{
|
||||
lsBtn2 = lstrmerge(asBtn2Name ? asBtn2Name : pszName2, asBtn2Hint ? L"\n" : nullptr, asBtn2Hint);
|
||||
lsBtn2 = CEStr(asBtn2Name ? asBtn2Name : pszName2, asBtn2Hint ? L"\n" : nullptr, asBtn2Hint);
|
||||
buttons[1].pszButtonText = lsBtn2.ms_Val;
|
||||
}
|
||||
if (config.cButtons >= 3)
|
||||
{
|
||||
lsBtn3 = lstrmerge(asBtn3Name ? asBtn3Name : pszName3, asBtn3Hint ? L"\n" : nullptr, asBtn3Hint);
|
||||
lsBtn3 = CEStr(asBtn3Name ? asBtn3Name : pszName3, asBtn3Hint ? L"\n" : nullptr, asBtn3Hint);
|
||||
buttons[2].pszButtonText = lsBtn3.ms_Val;
|
||||
}
|
||||
|
||||
@ -512,26 +512,26 @@ int ConfirmDialog(LPCWSTR asMessage,
|
||||
// Use standard message box otherwise
|
||||
// **********************************
|
||||
|
||||
szText = lstrmerge(
|
||||
szText = CEStr(
|
||||
asMainLabel, asMainLabel ? L"\r\n" : nullptr,
|
||||
asMessage);
|
||||
|
||||
// URL hint?
|
||||
if (asUrl)
|
||||
{
|
||||
lstrmerge(&szText.ms_Val, L"\r\n\r\n", asUrl);
|
||||
szText.Append(L"\r\n\r\n", asUrl);
|
||||
}
|
||||
|
||||
// Button hints?
|
||||
if (asBtn1Hint || asBtn2Hint || asBtn3Hint)
|
||||
{
|
||||
lstrmerge(&szText.ms_Val, L"\r\n\r\n");
|
||||
szText.Append(L"\r\n\r\n");
|
||||
if (asBtn1Hint)
|
||||
lstrmerge(&szText.ms_Val, L"\r\n<", pszName1, L"> - ", asBtn1Hint);
|
||||
szText.Append(L"\r\n<", pszName1, L"> - ", asBtn1Hint);
|
||||
if (asBtn2Hint)
|
||||
lstrmerge(&szText.ms_Val, L"\r\n<", pszName2, L"> - ", asBtn2Hint);
|
||||
szText.Append(L"\r\n<", pszName2, L"> - ", asBtn2Hint);
|
||||
if (asBtn3Hint)
|
||||
lstrmerge(&szText.ms_Val, L"\r\n<", pszName3, L"> - ", asBtn3Hint);
|
||||
szText.Append(L"\r\n<", pszName3, L"> - ", asBtn3Hint);
|
||||
}
|
||||
|
||||
// Show dialog
|
||||
|
@ -263,24 +263,25 @@ wrap:
|
||||
return;
|
||||
}
|
||||
|
||||
wchar_t* CDragDrop::FileCreateName(BOOL abActive, BOOL abFolder, LPCWSTR asSubFolder, LPCWSTR asFileName)
|
||||
CEStr CDragDrop::FileCreateName(BOOL abActive, BOOL abFolder, LPCWSTR asSubFolder, LPCWSTR asFileName) const
|
||||
{
|
||||
if (!asFileName || !*asFileName)
|
||||
if (IsStrEmpty(asFileName))
|
||||
{
|
||||
AssertMsg(L"Can't drop file! Filename is empty!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CEStr result;
|
||||
wchar_t *pszFullName = nullptr;
|
||||
LPCWSTR pszNameW = asFileName;
|
||||
INT_PTR nSize = 0;
|
||||
LPCWSTR pszPanelPath = abActive ? m_pfpi->pszActivePath : m_pfpi->pszPassivePath;
|
||||
const auto* pszPanelPath = abActive ? m_pfpi->pszActivePath : m_pfpi->pszPassivePath;
|
||||
INT_PTR nPathLen = _tcslen(pszPanelPath) + 1;
|
||||
INT_PTR nSubFolderLen = (asSubFolder && *asSubFolder) ? _tcslen(asSubFolder) : 0;
|
||||
const INT_PTR nSubFolderLen = (asSubFolder && *asSubFolder) ? _tcslen(asSubFolder) : 0;
|
||||
nSize = nPathLen + nSubFolderLen + 17;
|
||||
|
||||
|
||||
LPCWSTR pszSlash = wcsrchr(pszNameW, L'\\');
|
||||
const auto* pszSlash = wcsrchr(pszNameW, L'\\');
|
||||
|
||||
if (pszSlash)
|
||||
{
|
||||
@ -300,7 +301,7 @@ wchar_t* CDragDrop::FileCreateName(BOOL abActive, BOOL abFolder, LPCWSTR asSubFo
|
||||
nSize += _tcslen(pszNameW)+1;
|
||||
|
||||
MCHKHEAP;
|
||||
pszFullName = (wchar_t*)calloc(nSize, sizeof(*pszFullName));
|
||||
pszFullName = result.GetBuffer(nSize);
|
||||
|
||||
if (!pszFullName)
|
||||
{
|
||||
@ -313,7 +314,7 @@ wchar_t* CDragDrop::FileCreateName(BOOL abActive, BOOL abFolder, LPCWSTR asSubFo
|
||||
BOOL lbNeedUnc = FALSE;
|
||||
|
||||
if (pszPanelPath[0] != L'\\' || pszPanelPath[1] != L'\\' || pszPanelPath[2] != L'?' || pszPanelPath[3] != L'\\')
|
||||
lbNeedUnc = TRUE;
|
||||
lbNeedUnc = TRUE; // NOLINT(bugprone-branch-clone)
|
||||
else if (pszPanelPath[0] == L'\\' && pszPanelPath[1] == L'\\')
|
||||
lbNeedUnc = TRUE;
|
||||
|
||||
@ -367,7 +368,6 @@ wchar_t* CDragDrop::FileCreateName(BOOL abActive, BOOL abFolder, LPCWSTR asSubFo
|
||||
if (!abFolder && ((nTotal <= 0) || (pszFullName[nTotal - 1] == L'\\')))
|
||||
{
|
||||
Assert((nTotal > 0) && (pszFullName[nTotal - 1] != L'\\'));
|
||||
free(pszFullName);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -387,41 +387,38 @@ wchar_t* CDragDrop::FileCreateName(BOOL abActive, BOOL abFolder, LPCWSTR asSubFo
|
||||
{
|
||||
if (!(fnd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
||||
{
|
||||
CEStr szMsg(L"Can't create directory! Same name file exists!\n", pszFullName);
|
||||
const CEStr szMsg(L"Can't create directory! Same name file exists!\n", pszFullName);
|
||||
MsgBox(szMsg, MB_ICONSTOP, gpConEmu->GetDefaultTitle(), ghWnd, false);
|
||||
free(pszFullName);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else if (fnd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
CEStr szMsg(L"Can't create file! Same name folder exists!\n", pszFullName);
|
||||
const CEStr szMsg(L"Can't create file! Same name folder exists!\n", pszFullName);
|
||||
MsgBox(szMsg, MB_ICONSTOP, gpConEmu->GetDefaultTitle(), ghWnd, false);
|
||||
free(pszFullName);
|
||||
return nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
int nRc = IDCANCEL;
|
||||
int nCchSize = nSize + 255;
|
||||
wchar_t* pszMsg = (wchar_t*)calloc(nCchSize, 2);
|
||||
if (pszMsg)
|
||||
const ssize_t nCchSize = nSize + 255;
|
||||
CEStr pszMsg;
|
||||
if (pszMsg.GetBuffer(nCchSize))
|
||||
{
|
||||
LARGE_INTEGER liSize;
|
||||
liSize.LowPart = fnd.nFileSizeLow; liSize.HighPart = fnd.nFileSizeHigh;
|
||||
FILETIME ftl;
|
||||
FileTimeToLocalFileTime(&fnd.ftLastWriteTime, &ftl);
|
||||
SYSTEMTIME st; FileTimeToSystemTime(&ftl, &st);
|
||||
swprintf_s(pszMsg, nCchSize,
|
||||
swprintf_s(pszMsg.data(), pszMsg.GetMaxCount(),
|
||||
L"File already exists!\n\n%s\nSize: %I64i\nDate: %02i.%02i.%i %02i:%02i:%02i\n\nOverwrite?",
|
||||
pszFullName, liSize.QuadPart, st.wDay, st.wMonth, st.wYear, st.wHour, st.wMinute, st.wSecond);
|
||||
nRc = MsgBox(pszMsg, MB_ICONEXCLAMATION|MB_YESNO, gpConEmu->GetDefaultTitle(), ghWnd, false);
|
||||
free(pszMsg);
|
||||
pszMsg.Release();
|
||||
}
|
||||
|
||||
if (nRc != IDYES)
|
||||
{
|
||||
free(pszFullName);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -444,7 +441,7 @@ wchar_t* CDragDrop::FileCreateName(BOOL abActive, BOOL abFolder, LPCWSTR asSubFo
|
||||
}
|
||||
|
||||
MCHKHEAP;
|
||||
return pszFullName;
|
||||
return result;
|
||||
}
|
||||
|
||||
HANDLE CDragDrop::FileStart(LPCWSTR pszFullName)
|
||||
@ -506,17 +503,17 @@ HRESULT CDragDrop::FileWrite(HANDLE ahFile, DWORD anSize, LPVOID apData)
|
||||
|
||||
HRESULT CDragDrop::DropFromStream(IDataObject* pDataObject, BOOL abActive)
|
||||
{
|
||||
STGMEDIUM stgDescr = { 0 };
|
||||
FORMATETC fmtetc = { CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
|
||||
STGMEDIUM stgDescr{};
|
||||
FORMATETC fmtetc{ CF_HDROP, nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
|
||||
HANDLE hFile = nullptr;
|
||||
size_t BufferSize = 0x10000;
|
||||
BYTE *cBuffer = (BYTE*)malloc(BufferSize);
|
||||
const unsigned BufferSize = 0x10000;
|
||||
BYTE *cBuffer = static_cast<BYTE*>(malloc(BufferSize));
|
||||
DWORD dwRead = 0;
|
||||
BOOL lbWide = FALSE;
|
||||
HRESULT hr = S_OK;
|
||||
HRESULT hrStg = S_OK;
|
||||
INT_PTR cchSubFolder = MAX_WIDE_PATH_LENGTH;
|
||||
wchar_t* pszSubFolder = (wchar_t*)calloc(cchSubFolder, sizeof(*pszSubFolder));
|
||||
wchar_t* pszSubFolder = static_cast<wchar_t*>(calloc(cchSubFolder, sizeof(*pszSubFolder)));
|
||||
|
||||
if (!cBuffer || !pszSubFolder)
|
||||
{
|
||||
@ -533,12 +530,12 @@ HRESULT CDragDrop::DropFromStream(IDataObject* pDataObject, BOOL abActive)
|
||||
{
|
||||
if (iu == 0)
|
||||
{
|
||||
fmtetc.cfFormat = (CLIPFORMAT)RegisterClipboardFormat(CFSTR_FILEDESCRIPTORW);
|
||||
fmtetc.cfFormat = static_cast<CLIPFORMAT>(RegisterClipboardFormat(CFSTR_FILEDESCRIPTORW));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Outlook 2k передает ANSI!
|
||||
fmtetc.cfFormat = (CLIPFORMAT)RegisterClipboardFormat(CFSTR_FILEDESCRIPTORA);
|
||||
fmtetc.cfFormat = static_cast<CLIPFORMAT>(RegisterClipboardFormat(CFSTR_FILEDESCRIPTORA));
|
||||
}
|
||||
|
||||
// !! The caller then assumes responsibility for releasing the STGMEDIUM structure.
|
||||
@ -553,24 +550,24 @@ HRESULT CDragDrop::DropFromStream(IDataObject* pDataObject, BOOL abActive)
|
||||
|
||||
if (lbWide)
|
||||
{
|
||||
pDescW = (FILEGROUPDESCRIPTORW*)GlobalLock(stgDescr.hGlobal);
|
||||
pDescW = static_cast<FILEGROUPDESCRIPTORW*>(GlobalLock(stgDescr.hGlobal));
|
||||
mn_AllFiles = pDescW->cItems;
|
||||
}
|
||||
else
|
||||
{
|
||||
pDescA = (FILEGROUPDESCRIPTORA*)GlobalLock(stgDescr.hGlobal);
|
||||
pDescA = static_cast<FILEGROUPDESCRIPTORA*>(GlobalLock(stgDescr.hGlobal));
|
||||
mn_AllFiles = pDescA->cItems;
|
||||
}
|
||||
|
||||
// Имена файлов теперь лежат в stgMedium, а для получения содержимого
|
||||
fmtetc.cfFormat = (CLIPFORMAT)RegisterClipboardFormat(CFSTR_FILECONTENTS);
|
||||
fmtetc.cfFormat = static_cast<CLIPFORMAT>(RegisterClipboardFormat(CFSTR_FILECONTENTS));
|
||||
pszSubFolder[0] = 0;
|
||||
|
||||
int nLastProgress = -1;
|
||||
|
||||
for (mn_CurFile = 0; mn_CurFile<mn_AllFiles; mn_CurFile++)
|
||||
{
|
||||
int nProgress = (mn_CurFile * 100 / mn_AllFiles);
|
||||
int nProgress = static_cast<int>(mn_CurFile * 100 / mn_AllFiles);
|
||||
if (nLastProgress != nProgress)
|
||||
{
|
||||
gpConEmu->Taskbar_SetProgressValue(nProgress);
|
||||
@ -584,21 +581,21 @@ HRESULT CDragDrop::DropFromStream(IDataObject* pDataObject, BOOL abActive)
|
||||
// Well, here we may get different structures...
|
||||
if (lbWide)
|
||||
{
|
||||
ptrFileName = (LPVOID)(pDescW->fgd[mn_CurFile].cFileName);
|
||||
ptrFileName = static_cast<LPVOID>(pDescW->fgd[mn_CurFile].cFileName);
|
||||
lbFolder = (pDescW->fgd[mn_CurFile].dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptrFileName = (LPVOID)(pDescA->fgd[mn_CurFile].cFileName);
|
||||
ptrFileName = static_cast<LPVOID>(pDescA->fgd[mn_CurFile].cFileName);
|
||||
lbFolder = (pDescA->fgd[mn_CurFile].dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY;
|
||||
}
|
||||
|
||||
// But we need UNICODE strings
|
||||
wchar_t* pszWideBuf = lbWide ? nullptr : lstrdupW((LPCSTR)ptrFileName);
|
||||
LPCWSTR pszWideName = lbWide ? (LPCWSTR)ptrFileName : pszWideBuf;
|
||||
CEStr pszWideBuf = lbWide ? nullptr : lstrdupW(static_cast<const char*>(ptrFileName));
|
||||
LPCWSTR pszWideName = lbWide ? static_cast<const wchar_t*>(ptrFileName) : pszWideBuf.c_str();
|
||||
|
||||
bool bCreateFolder = lbFolder;
|
||||
wchar_t* pszNewFolder = nullptr;
|
||||
CEStr pszNewFolder = nullptr;
|
||||
|
||||
if (!lbFolder)
|
||||
{
|
||||
@ -625,7 +622,7 @@ HRESULT CDragDrop::DropFromStream(IDataObject* pDataObject, BOOL abActive)
|
||||
{
|
||||
swprintf_c(sUnknownError, L"Drag item #%i contains too long path!", mn_CurFile+1);
|
||||
DebugLog(sUnknownError, TRUE);
|
||||
SafeFree(pszWideBuf);
|
||||
pszWideBuf.Release();
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -663,7 +660,7 @@ HRESULT CDragDrop::DropFromStream(IDataObject* pDataObject, BOOL abActive)
|
||||
if (sUnknownError[0] == 0)
|
||||
swprintf_c(sUnknownError, L"Drag item #%i has invalid file name!", mn_CurFile+1);
|
||||
|
||||
SafeFree(pszWideBuf);
|
||||
pszWideBuf.Release();
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -677,8 +674,8 @@ HRESULT CDragDrop::DropFromStream(IDataObject* pDataObject, BOOL abActive)
|
||||
{
|
||||
swprintf_c(sUnknownError, L"Drag item #%i contains too long path!", mn_CurFile+1);
|
||||
DebugLog(sUnknownError, TRUE);
|
||||
SafeFree(pszNewFolder);
|
||||
SafeFree(pszWideBuf);
|
||||
pszNewFolder.Release();
|
||||
pszWideBuf.Release();
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -692,41 +689,44 @@ HRESULT CDragDrop::DropFromStream(IDataObject* pDataObject, BOOL abActive)
|
||||
}
|
||||
|
||||
// Раз это папка - просто создать
|
||||
if (!MyCreateDirectory(pszNewFolder))
|
||||
if (!MyCreateDirectory(pszNewFolder.data()))
|
||||
{
|
||||
DWORD nErr = GetLastError();
|
||||
|
||||
if (nErr != ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
INT_PTR nLen = _tcslen(pszNewFolder) + 128;
|
||||
wchar_t* pszErr = (wchar_t*)malloc(nLen*sizeof(*pszErr));
|
||||
swprintf_c(pszErr, nLen/*#SECURELEN*/, L"Can't create directory for drag item #%i!\n%s\nError code=0x%08X", mn_CurFile+1, pszNewFolder, nErr);
|
||||
CEStr pszErr;
|
||||
if (pszErr.GetBuffer(nLen))
|
||||
{
|
||||
swprintf_c(pszErr.data(), pszErr.GetMaxCount(),
|
||||
L"Can't create directory for drag item #%i!\n%s\nError code=0x%08X",
|
||||
mn_CurFile + 1, pszNewFolder.c_str(), nErr);
|
||||
|
||||
AssertMsg(pszErr);
|
||||
|
||||
SafeFree(pszErr);
|
||||
SafeFree(pszNewFolder);
|
||||
SafeFree(pszWideBuf);
|
||||
}
|
||||
pszNewFolder.Release();
|
||||
pszWideBuf.Release();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MCHKHEAP;
|
||||
SafeFree(pszNewFolder);
|
||||
pszNewFolder.Release();
|
||||
|
||||
if (lbFolder)
|
||||
{
|
||||
SafeFree(pszWideBuf);
|
||||
continue; // переходим к следующему файлу/папке
|
||||
pszWideBuf.Release();
|
||||
continue; // next folder/file
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Files now
|
||||
|
||||
wchar_t* pszNewFileName = FileCreateName(abActive, false, pszSubFolder, pszWideName);
|
||||
CEStr pszNewFileName = FileCreateName(abActive, false, pszSubFolder, pszWideName);
|
||||
|
||||
SafeFree(pszWideBuf);
|
||||
pszWideBuf.Release();
|
||||
|
||||
if (!pszNewFileName)
|
||||
{
|
||||
@ -770,13 +770,13 @@ HRESULT CDragDrop::DropFromStream(IDataObject* pDataObject, BOOL abActive)
|
||||
else
|
||||
{
|
||||
hFile = FileStart(pszNewFileName);
|
||||
free(pszNewFileName); pszNewFileName = nullptr;
|
||||
pszNewFileName.Release();
|
||||
}
|
||||
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
// Может возвращать и S_FALSE (конец файла?)
|
||||
while(SUCCEEDED(hr = pFile->Read(cBuffer, BufferSize, &dwRead)) && dwRead)
|
||||
// S_FALSE - end of file?
|
||||
while (SUCCEEDED(hr = pFile->Read(cBuffer, BufferSize, &dwRead)) && dwRead)
|
||||
{
|
||||
TODO("Сюда прогресс с градусником прицепить можно");
|
||||
|
||||
@ -802,14 +802,14 @@ HRESULT CDragDrop::DropFromStream(IDataObject* pDataObject, BOOL abActive)
|
||||
{
|
||||
lbKnownMedium = TRUE;
|
||||
SIZE_T nFileSize = GlobalSize(stgMedium.hGlobal);
|
||||
LPBYTE ptrFileData = (LPBYTE)GlobalLock(stgMedium.hGlobal);
|
||||
LPBYTE ptrFileData = static_cast<LPBYTE>(GlobalLock(stgMedium.hGlobal));
|
||||
|
||||
if (!pszNewFileName)
|
||||
hFile = INVALID_HANDLE_VALUE;
|
||||
else
|
||||
{
|
||||
hFile = FileStart(pszNewFileName);
|
||||
free(pszNewFileName); pszNewFileName = nullptr;
|
||||
pszNewFileName.Release();
|
||||
}
|
||||
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
@ -820,7 +820,7 @@ HRESULT CDragDrop::DropFromStream(IDataObject* pDataObject, BOOL abActive)
|
||||
|
||||
while (nFileSize > 0)
|
||||
{
|
||||
dwRead = std::min<DWORD>(nFileSize, 65536); //-V103
|
||||
dwRead = LODWORD(std::min<SIZE_T>(nFileSize, 65536)); //-V103
|
||||
TODO("Сюда прогресс с градусником прицепить можно");
|
||||
|
||||
if (FileWrite(hFile, dwRead, ptrCur) != S_OK)
|
||||
@ -850,11 +850,7 @@ HRESULT CDragDrop::DropFromStream(IDataObject* pDataObject, BOOL abActive)
|
||||
|
||||
}
|
||||
|
||||
if (pszNewFileName)
|
||||
{
|
||||
// Уже должен быть освобожден, но проверим
|
||||
free(pszNewFileName); pszNewFileName = nullptr;
|
||||
}
|
||||
pszNewFileName.Release();
|
||||
|
||||
// Ошибку показать один раз на дроп (чтобы не ругаться на КАЖДЫЙ бросаемый файл)
|
||||
//MBoxA(_T("Drag object does not contains known medium!"));
|
||||
@ -1153,19 +1149,20 @@ HRESULT CDragDrop::DropLinks(HDROP hDrop, int iQuantity, BOOL abActive)
|
||||
{
|
||||
TCHAR curr[MAX_DROP_PATH];
|
||||
LPCTSTR pszTo = abActive ? m_pfpi->pszActivePath : m_pfpi->pszPassivePath;
|
||||
INT_PTR nToLen = _tcslen(pszTo);
|
||||
const size_t nToLen = _tcslen(pszTo);
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
for (int i = 0 ; i < iQuantity; i++)
|
||||
{
|
||||
int nLen = DragQueryFile(hDrop, i, curr, MAX_DROP_PATH);
|
||||
const int qRc = DragQueryFile(hDrop, i, curr, MAX_DROP_PATH);
|
||||
|
||||
if (nLen <= 0 || nLen >= MAX_DROP_PATH) continue;
|
||||
if (qRc <= 0 || qRc >= MAX_DROP_PATH)
|
||||
continue;
|
||||
|
||||
LPCTSTR pszTitle = wcsrchr(curr, '\\');
|
||||
if (pszTitle) pszTitle++; else pszTitle = curr;
|
||||
|
||||
nLen = nToLen+2+_tcslen(pszTitle)+4; //-V112
|
||||
const size_t nLen = nToLen + 2 + _tcslen(pszTitle) + 4; //-V112
|
||||
TCHAR *szLnkPath = new TCHAR[nLen];
|
||||
_wcscpy_c(szLnkPath, nLen, pszTo);
|
||||
|
||||
|
@ -66,7 +66,7 @@ class CDragDrop :
|
||||
//ITEMIDLIST m_DesktopID;
|
||||
DWORD mn_AllFiles, mn_CurFile; __int64 mn_CurWritten;
|
||||
HANDLE FileStart(LPCWSTR pszFullName);
|
||||
wchar_t* FileCreateName(BOOL abActive, BOOL abFolder, LPCWSTR asSubFolder, LPCWSTR asFileName);
|
||||
CEStr FileCreateName(BOOL abActive, BOOL abFolder, LPCWSTR asSubFolder, LPCWSTR asFileName) const;
|
||||
HRESULT FileWrite(HANDLE ahFile, DWORD anSize, LPVOID apData);
|
||||
//void EnumDragFormats(IDataObject * pDataObject);
|
||||
void ReportUnknownData(IDataObject * pDataObject, LPCWSTR sUnknownError);
|
||||
|
@ -1239,7 +1239,7 @@ bool CDragDropData::CheckIsUpdatePackage(IDataObject * pDataObject)
|
||||
|
||||
if (bHasUpdatePackage)
|
||||
{
|
||||
mpsz_UpdatePackage = lstrdup(pszFileNames);
|
||||
mpsz_UpdatePackage = lstrdup(pszFileNames).Detach();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ INT_PTR CEFindDlg::findTextProc(HWND hWnd2, UINT messg, WPARAM wParam, LPARAM lP
|
||||
SetTimer(hWnd2, 101, 1000, nullptr);
|
||||
|
||||
SetClassLongPtr(hWnd2, GCLP_HICON, (LONG_PTR)hClassIcon);
|
||||
SetDlgItemText(hWnd2, tFindText, gpSet->FindOptions.pszText ? gpSet->FindOptions.pszText : L"");
|
||||
SetDlgItemText(hWnd2, tFindText, gpSet->FindOptions.text.c_str(L""));
|
||||
CDlgItemHelper::checkDlgButton(hWnd2, cbFindMatchCase, gpSet->FindOptions.bMatchCase);
|
||||
CDlgItemHelper::checkDlgButton(hWnd2, cbFindWholeWords, gpSet->FindOptions.bMatchWholeWords);
|
||||
CDlgItemHelper::checkDlgButton(hWnd2, cbFindFreezeConsole, gpSet->FindOptions.bFreezeConsole);
|
||||
@ -162,8 +162,8 @@ INT_PTR CEFindDlg::findTextProc(HWND hWnd2, UINT messg, WPARAM wParam, LPARAM lP
|
||||
#endif
|
||||
CDlgItemHelper::checkDlgButton(hWnd2, cbFindTransparent, gpSet->FindOptions.bTransparent);
|
||||
|
||||
if (gpSet->FindOptions.pszText && *gpSet->FindOptions.pszText)
|
||||
SendDlgItemMessage(hWnd2, tFindText, EM_SETSEL, 0, lstrlen(gpSet->FindOptions.pszText));
|
||||
if (!gpSet->FindOptions.text.IsEmpty())
|
||||
SendDlgItemMessage(hWnd2, tFindText, EM_SETSEL, 0, gpSet->FindOptions.text.GetLen());
|
||||
|
||||
// Зовем всегда, чтобы инициализировать буфер для поиска как минимум
|
||||
gpConEmu->DoFindText(0);
|
||||
@ -225,13 +225,13 @@ INT_PTR CEFindDlg::findTextProc(HWND hWnd2, UINT messg, WPARAM wParam, LPARAM lP
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (gpSet->FindOptions.pszText && *gpSet->FindOptions.pszText)
|
||||
if (!gpSet->FindOptions.text.IsEmpty())
|
||||
gpConEmu->DoFindText(nDirection);
|
||||
}
|
||||
else if (HIWORD(wParam) == EN_CHANGE || HIWORD(wParam) == CBN_EDITCHANGE || HIWORD(wParam) == CBN_SELCHANGE)
|
||||
{
|
||||
MyGetDlgItemText(hWnd2, tFindText, gpSet->FindOptions.cchTextMax, gpSet->FindOptions.pszText);
|
||||
if (gpSet->FindOptions.pszText && *gpSet->FindOptions.pszText)
|
||||
MyGetDlgItemText(hWnd2, tFindText, gpSet->FindOptions.text);
|
||||
if (!gpSet->FindOptions.text.IsEmpty())
|
||||
gpConEmu->DoFindText(0);
|
||||
}
|
||||
break;
|
||||
|
@ -349,14 +349,14 @@ void CFindPanel::OnSearch()
|
||||
if (!CVConGroup::isVConExists(0))
|
||||
return;
|
||||
|
||||
MyGetDlgItemText(mh_Edit, 0, gpSet->FindOptions.cchTextMax, gpSet->FindOptions.pszText);
|
||||
if (gpSet->FindOptions.pszText && *gpSet->FindOptions.pszText)
|
||||
MyGetDlgItemText(mh_Edit, 0, gpSet->FindOptions.text);
|
||||
if (!gpSet->FindOptions.text.IsEmpty())
|
||||
{
|
||||
int nDirection = 0;
|
||||
if (ms_PrevSearch->ms_Val && (lstrcmp(ms_PrevSearch->ms_Val, gpSet->FindOptions.pszText) == 0))
|
||||
if (ms_PrevSearch->ms_Val && (lstrcmp(ms_PrevSearch->ms_Val, gpSet->FindOptions.text) == 0))
|
||||
nDirection = isPressed(VK_SHIFT) ? -1 : 1;
|
||||
gpConEmu->DoFindText(nDirection);
|
||||
ms_PrevSearch->Set(gpSet->FindOptions.pszText);
|
||||
ms_PrevSearch->Set(gpSet->FindOptions.text);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1887,7 +1887,7 @@ bool CFontMgr::CreateFontGroup(CLogFont inFont)
|
||||
{
|
||||
if (m_Font[0]->ms_FontError && (m_Font2.Ptr() && m_Font2->ms_FontError))
|
||||
{
|
||||
ms_FontError = lstrmerge(m_Font[0]->ms_FontError, L"\n", m_Font2->ms_FontError);
|
||||
ms_FontError = CEStr(m_Font[0]->ms_FontError, L"\n", m_Font2->ms_FontError);
|
||||
}
|
||||
else if (m_Font2.Ptr() && m_Font2->ms_FontError)
|
||||
{
|
||||
|
@ -287,7 +287,7 @@ BOOL CGuiServer::GuiServerCommand(LPVOID pInst, CESERVER_REQ* pIn, CESERVER_REQ*
|
||||
RConStartArgsEx rTest;
|
||||
if (pszCommand[0])
|
||||
{
|
||||
rTest.pszSpecialCmd = lstrdup(pszCommand);
|
||||
rTest.pszSpecialCmd = lstrdup(pszCommand).Detach();
|
||||
rTest.ProcessNewConArg();
|
||||
}
|
||||
|
||||
@ -317,14 +317,14 @@ BOOL CGuiServer::GuiServerCommand(LPVOID pInst, CESERVER_REQ* pIn, CESERVER_REQ*
|
||||
|
||||
_ASSERTE(pIn->NewCmd.ShowHide != sih_StartDetached); // cannot be as pszCommand was filled
|
||||
args.Detached = (pIn->NewCmd.ShowHide == sih_StartDetached) ? crb_On : crb_Off;
|
||||
args.pszSpecialCmd = lstrdup(pszCommand);
|
||||
args.pszSpecialCmd = lstrdup(pszCommand).Detach();
|
||||
if (pIn->NewCmd.szCurDir[0] == 0)
|
||||
{
|
||||
_ASSERTE(pIn->NewCmd.szCurDir[0] != 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
args.pszStartupDir = lstrdup(pIn->NewCmd.szCurDir);
|
||||
args.pszStartupDir = lstrdup(pIn->NewCmd.szCurDir).Detach();
|
||||
}
|
||||
|
||||
LPCWSTR pszStrings = pIn->NewCmd.GetEnvStrings();
|
||||
@ -712,14 +712,14 @@ BOOL CGuiServer::GuiServerCommand(LPVOID pInst, CESERVER_REQ* pIn, CESERVER_REQ*
|
||||
pRCon = VCon->RCon();
|
||||
|
||||
DWORD nFarPluginPID = pRCon ? pRCon->GetFarPID(true) : 0;
|
||||
LPWSTR pszResult = ConEmuMacro::ExecuteMacro(pIn->GuiMacro.sMacro, pRCon, (nFarPluginPID==pIn->hdr.nSrcPID), &pIn->GuiMacro);
|
||||
CEStr pszResult = ConEmuMacro::ExecuteMacro(pIn->GuiMacro.sMacro, pRCon, (nFarPluginPID==pIn->hdr.nSrcPID), &pIn->GuiMacro);
|
||||
|
||||
const auto nLen = pszResult ? _tcslen(pszResult) : 0;
|
||||
|
||||
pcbReplySize = sizeof(CESERVER_REQ_HDR) + sizeof(CESERVER_REQ_GUIMACRO) + nLen * sizeof(wchar_t);
|
||||
if (!ExecuteNewCmd(ppReply, pcbMaxReplySize, pIn->hdr.nCmd, pcbReplySize))
|
||||
{
|
||||
SafeFree(pszResult);
|
||||
pszResult.Release();
|
||||
goto wrap;
|
||||
}
|
||||
|
||||
@ -727,7 +727,7 @@ BOOL CGuiServer::GuiServerCommand(LPVOID pInst, CESERVER_REQ* pIn, CESERVER_REQ*
|
||||
{
|
||||
lstrcpy(ppReply->GuiMacro.sMacro, pszResult);
|
||||
ppReply->GuiMacro.nSucceeded = 1;
|
||||
free(pszResult);
|
||||
pszResult.Release();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -216,14 +216,13 @@ bool PtMouseDblClickTest(const MSG& msg1, const MSG msg2);
|
||||
bool IntFromString(int& rnValue, LPCWSTR asValue, int anBase = 10, LPCWSTR* rsEnd = nullptr);
|
||||
bool GetDlgItemSigned(HWND hDlg, WORD nID, int& nValue, int nMin = 0, int nMax = 0);
|
||||
bool GetDlgItemUnsigned(HWND hDlg, WORD nID, DWORD& nValue, DWORD nMin = 0, DWORD nMax = 0);
|
||||
wchar_t* GetDlgItemTextPtr(HWND hDlg, WORD nID);
|
||||
template <size_t size> bool MyGetDlgItemText(HWND hDlg, WORD nID, wchar_t (&rszText)[size]);
|
||||
size_t MyGetDlgItemText(HWND hDlg, WORD nID, size_t& cchMax, wchar_t*& pszText);
|
||||
CEStr GetDlgItemTextPtr(HWND hDlg, WORD nID);
|
||||
size_t MyGetDlgItemText(HWND hDlg, WORD nID, CEStr& rsText);
|
||||
bool GetColorRef(LPCWSTR pszText, COLORREF* pCR);
|
||||
|
||||
//#pragma warning(disable: 4311) // 'type cast' : pointer truncation from 'HBRUSH' to 'BOOL'
|
||||
|
||||
wchar_t* getFocusedExplorerWindowPath();
|
||||
CEStr getFocusedExplorerWindowPath();
|
||||
enum CESelectFileFlags
|
||||
{
|
||||
sff_Default = 0,
|
||||
@ -231,8 +230,8 @@ enum CESelectFileFlags
|
||||
sff_Cygwin = 2,
|
||||
sff_SaveNewFile = 4,
|
||||
};
|
||||
wchar_t* SelectFolder(LPCWSTR asTitle, LPCWSTR asDefFolder = nullptr, HWND hParent = ghWnd, DWORD/*CESelectFileFlags*/ nFlags = sff_AutoQuote, CRealConsole* apRCon = nullptr);
|
||||
wchar_t* SelectFile(LPCWSTR asTitle, LPCWSTR asDefFile = nullptr, LPCWSTR asDefPath = nullptr, HWND hParent = ghWnd, LPCWSTR asFilter = nullptr, DWORD/*CESelectFileFlags*/ nFlags = sff_AutoQuote, CRealConsole* apRCon = nullptr);
|
||||
CEStr SelectFolder(LPCWSTR asTitle, LPCWSTR asDefFolder = nullptr, HWND hParent = ghWnd, DWORD/*CESelectFileFlags*/ nFlags = sff_AutoQuote, CRealConsole* apRCon = nullptr);
|
||||
CEStr SelectFile(LPCWSTR asTitle, LPCWSTR asDefFile = nullptr, LPCWSTR asDefPath = nullptr, HWND hParent = ghWnd, LPCWSTR asFilter = nullptr, DWORD/*CESelectFileFlags*/ nFlags = sff_AutoQuote, CRealConsole* apRCon = nullptr);
|
||||
|
||||
#include "../common/RConStartArgsEx.h"
|
||||
|
||||
|
@ -201,7 +201,7 @@ ConEmuHotKey& ConEmuHotKey::SetMacro(const wchar_t* guiMacro)
|
||||
{
|
||||
if (GuiMacro && GuiMacro != guiMacro)
|
||||
free(GuiMacro);
|
||||
GuiMacro = guiMacro ? lstrdup(guiMacro) : nullptr;
|
||||
GuiMacro = guiMacro ? lstrdup(guiMacro).Detach() : nullptr;
|
||||
_ASSERTE(fkey == nullptr || fkey == CConEmuCtrl::key_GuiMacro);
|
||||
fkey = CConEmuCtrl::key_GuiMacro;
|
||||
return *this;
|
||||
@ -228,15 +228,15 @@ LPCWSTR ConEmuHotKey::CreateNotUniqueWarning(LPCWSTR asHotkey, LPCWSTR asDescr1,
|
||||
wchar_t* ptrPoint = lsFmt.ms_Val ? (wchar_t*)wcsstr(lsFmt.ms_Val, L"%s") : nullptr;
|
||||
if (!ptrPoint)
|
||||
{
|
||||
rsWarning.Attach(lstrmerge(L"Hotkey <", asHotkey, L"> is not unique",
|
||||
L"\n", asDescr1, L"\n", asDescr2));
|
||||
rsWarning = CEStr(L"Hotkey <", asHotkey, L"> is not unique",
|
||||
L"\n", asDescr1, L"\n", asDescr2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ASSERTE(ptrPoint[0] == L'%' && ptrPoint[1] == L's' && ptrPoint[2]);
|
||||
*ptrPoint = 0;
|
||||
rsWarning.Attach(lstrmerge(lsFmt.ms_Val, asHotkey, ptrPoint+2,
|
||||
L"\n", asDescr1, L"\n", asDescr2));
|
||||
rsWarning = CEStr(lsFmt.ms_Val, asHotkey, ptrPoint+2,
|
||||
L"\n", asDescr1, L"\n", asDescr2);
|
||||
}
|
||||
return rsWarning.ms_Val;
|
||||
}
|
||||
|
@ -68,7 +68,6 @@ public:
|
||||
wchar_t* GuiMacro{nullptr};
|
||||
|
||||
// Internal
|
||||
size_t cchGuiMacroMax{};
|
||||
bool NotChanged{};
|
||||
|
||||
public:
|
||||
|
@ -226,7 +226,7 @@ int CIconList::CreateTabIcon(LPCWSTR asIconDescr, bool bAdmin, LPCWSTR asWorkDir
|
||||
if (iCreatedIcon == -1)
|
||||
{
|
||||
// To avoid numerous CreateTabIconInt calls - just remember "No icon" for that asIconDescr
|
||||
TabIconCache DummyIcon = {lstrdup(asIconDescr), -1, bAdmin, (mh_TabIcons==nullptr)};
|
||||
TabIconCache DummyIcon = {lstrdup(asIconDescr).Detach(), -1, bAdmin, (mh_TabIcons==nullptr)};
|
||||
m_Icons.push_back(DummyIcon);
|
||||
}
|
||||
wrap:
|
||||
@ -312,7 +312,7 @@ int CIconList::CreateTabIconInt(LPCWSTR asIconDescr, bool bAdmin, LPCWSTR asWork
|
||||
int iIconIdxAdm = -1;
|
||||
iIconIdx = ImageList_ReplaceIcon(mh_TabIcons, -1, hFileIcon);
|
||||
|
||||
const TabIconCache newIcon = {lstrdup(asIconDescr), iIconIdx, false, false};
|
||||
const TabIconCache newIcon = {lstrdup(asIconDescr).Detach(), iIconIdx, false, false};
|
||||
m_Icons.push_back(newIcon);
|
||||
|
||||
if (mn_AdminOverlayIndex >= 0)
|
||||
@ -327,7 +327,7 @@ int CIconList::CreateTabIconInt(LPCWSTR asIconDescr, bool bAdmin, LPCWSTR asWork
|
||||
iIconIdxAdm = ImageList_ReplaceIcon(mh_TabIcons, -1, hNewIcon);
|
||||
DestroyIcon(hNewIcon);
|
||||
|
||||
const TabIconCache admIcon = {lstrdup(asIconDescr), iIconIdxAdm, true, false};
|
||||
const TabIconCache admIcon = {lstrdup(asIconDescr).Detach(), iIconIdxAdm, true, false};
|
||||
m_Icons.push_back(admIcon);
|
||||
|
||||
if (bAdmin && (iIconIdxAdm > 0))
|
||||
|
@ -72,7 +72,7 @@ void CImgButtons::Add(LPCWSTR asText, ToolImgCreate_t fnCreate, UINT nCtrlId, LP
|
||||
lstrcpyn(btn.ResId, asText ? asText : L"", countof(btn.ResId));
|
||||
|
||||
btn.nCtrlId = nCtrlId;
|
||||
btn.pszHint = lstrdup(asHint);
|
||||
btn.pszHint = lstrdup(asHint).Detach();
|
||||
btn.OnClick = fnClick;
|
||||
|
||||
btn.pImg = fnCreate();
|
||||
|
@ -197,7 +197,7 @@ bool CLngRc::LoadResources(LPCWSTR asLanguage, LPCWSTR asFile)
|
||||
gpConEmu->LogString(lsLog);
|
||||
}
|
||||
|
||||
const int iRc = ReadTextFile(asFile, 1 << 24 /*16Mb max*/, lsJsonData.ms_Val, jsonDataSize, nErrCode);
|
||||
const int iRc = ReadTextFile(asFile, 1 << 24 /*16Mb max*/, lsJsonData, jsonDataSize, nErrCode);
|
||||
if (iRc != 0)
|
||||
{
|
||||
// TODO: Log error
|
||||
@ -282,7 +282,7 @@ bool CLngRc::LoadLanguages(MJsonValue* pJson)
|
||||
LngDefinition lng = {};
|
||||
lng.id = lsId.Detach();
|
||||
lng.name = lsName.Detach();
|
||||
lng.descr = lstrmerge(lng.id, L": ", lng.name);
|
||||
lng.descr = CEStr(lng.id, L": ", lng.name).Detach();
|
||||
m_Languages.push_back(lng);
|
||||
}
|
||||
} // for (size_t i = 0; i < iCount; i++)
|
||||
@ -446,12 +446,11 @@ bool CLngRc::SetResource(MArray<LngRcItem>& arr, const int idx, LPCWSTR asValue,
|
||||
}
|
||||
else
|
||||
{
|
||||
auto* newStr = lstrdup(asValue);
|
||||
CEStr newStr(asValue);
|
||||
if (newStr)
|
||||
{
|
||||
item.MaxLen = static_cast<uint16_t>(iLen);
|
||||
std::swap(item.Str, newStr);
|
||||
free(newStr);
|
||||
newStr.Swap(item.Str);
|
||||
}
|
||||
}
|
||||
bOk = (item.Str != nullptr);
|
||||
@ -479,7 +478,7 @@ bool CLngRc::SetResource(MArray<LngRcItem>& arr, int idx, MJsonValue* pJson)
|
||||
_ASSERTE(FALSE && "String format failure");
|
||||
return false;
|
||||
}
|
||||
lstrmerge(&lsValue.ms_Val, jStr.getString());
|
||||
lsValue.Append(jStr.getString());
|
||||
}
|
||||
|
||||
if (lsValue.IsEmpty())
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -35,15 +35,15 @@ struct CESERVER_REQ_GUIMACRO;
|
||||
namespace ConEmuMacro
|
||||
{
|
||||
// Общая функция, для обработки любого известного макроса
|
||||
LPWSTR ExecuteMacro(LPWSTR asMacro, CRealConsole* apRCon, bool abFromPlugin = false, CESERVER_REQ_GUIMACRO* Opt = nullptr);
|
||||
CEStr ExecuteMacro(CEStr&& macro, CRealConsole* apRCon, bool abFromPlugin = false, CESERVER_REQ_GUIMACRO* Opt = nullptr);
|
||||
// Конвертация из "старого" в "новый" формат
|
||||
// Старые макросы хранились как "Verbatim" но без префикса
|
||||
LPWSTR ConvertMacro(LPCWSTR asMacro, BYTE FromVersion, bool bShowErrorTip = true);
|
||||
CEStr ConvertMacro(LPCWSTR asMacro, BYTE FromVersion, bool bShowErrorTip = true);
|
||||
// Some functions must be executed in main thread
|
||||
// but they may be called from console
|
||||
LRESULT ExecuteMacroSync(WPARAM wParam, LPARAM lParam);
|
||||
// Helper to concatenate macros.
|
||||
// They must be ‘concatenatable’, example: Print("abc"); Print("Qqq")
|
||||
// But following WILL NOT work: Print: Abd qqq
|
||||
LPCWSTR ConcatMacro(LPWSTR& rsMacroList, LPCWSTR asAddMacro);
|
||||
LPCWSTR ConcatMacro(CEStr& rsMacroList, LPCWSTR asAddMacro);
|
||||
};
|
||||
|
@ -35,23 +35,23 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "../common/MStrEsc.h"
|
||||
|
||||
// bAutoString==true : auto convert of gmt_String to gmt_VString
|
||||
wchar_t* GuiMacro::AsString()
|
||||
CEStr GuiMacro::AsString() const
|
||||
{
|
||||
if (!szFunc || !*szFunc)
|
||||
{
|
||||
_ASSERTE(szFunc && *szFunc);
|
||||
return lstrdup(L"");
|
||||
return CEStr(L"");
|
||||
}
|
||||
|
||||
size_t cchTotal = _tcslen(szFunc) + 5;
|
||||
|
||||
wchar_t** pszArgs = nullptr;
|
||||
MArray<CEStr> pszArgs;
|
||||
|
||||
if (argc > 0)
|
||||
{
|
||||
// ReSharper disable once CppTooWideScope
|
||||
wchar_t szNum[12];
|
||||
pszArgs = (wchar_t**)calloc(argc, sizeof(wchar_t*));
|
||||
if (!pszArgs)
|
||||
if (!pszArgs.resize(argc))
|
||||
{
|
||||
_ASSERTE(FALSE && "Memory allocation failed");
|
||||
return lstrdup(L"");
|
||||
@ -73,11 +73,10 @@ wchar_t* GuiMacro::AsString()
|
||||
break;
|
||||
case gmt_Str:
|
||||
// + " ... ", + escaped (4x len in maximum for "\xFF" form)
|
||||
pszArgs[i] = (wchar_t*)malloc((3+(argv[i].Str ? _tcslen(argv[i].Str)*4 : 0))*sizeof(*argv[i].Str));
|
||||
if (pszArgs[i])
|
||||
if (pszArgs[i].GetBuffer(3 + (argv[i].Str ? _tcslen(argv[i].Str) * 4 : 0)))
|
||||
{
|
||||
LPCWSTR pszSrc = argv[i].Str;
|
||||
LPWSTR pszDst = pszArgs[i];
|
||||
auto* pszDst = pszArgs[i].data();
|
||||
// Start
|
||||
*(pszDst++) = L'"';
|
||||
// Value
|
||||
@ -89,11 +88,10 @@ wchar_t* GuiMacro::AsString()
|
||||
break;
|
||||
case gmt_VStr:
|
||||
// + @" ... ", + escaped (double len in maximum)
|
||||
pszArgs[i] = (wchar_t*)malloc((4+(argv[i].Str ? _tcslen(argv[i].Str)*2 : 0))*sizeof(*argv[i].Str));
|
||||
if (pszArgs[i])
|
||||
if (pszArgs[i].GetBuffer(4 + (argv[i].Str ? _tcslen(argv[i].Str) * 2 : 0)))
|
||||
{
|
||||
LPCWSTR pszSrc = argv[i].Str;
|
||||
LPWSTR pszDst = pszArgs[i];
|
||||
wchar_t* pszDst = pszArgs[i].data();
|
||||
// Start
|
||||
*(pszDst++) = L'@'; *(pszDst++) = L'"';
|
||||
// Loop
|
||||
@ -108,20 +106,17 @@ wchar_t* GuiMacro::AsString()
|
||||
cchTotal += _tcslen(pszArgs[i])+1;
|
||||
}
|
||||
break;
|
||||
case gmt_Fn:
|
||||
default:
|
||||
_ASSERTE(FALSE && "Argument type not supported");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wchar_t* pszBuf = (wchar_t*)malloc(cchTotal*sizeof(*pszBuf));
|
||||
CEStr result;
|
||||
wchar_t* pszBuf = result.GetBuffer(cchTotal);
|
||||
if (!pszBuf)
|
||||
{
|
||||
for (size_t i = 0; i < argc; i++)
|
||||
{
|
||||
SafeFree(pszArgs[i]);
|
||||
}
|
||||
SafeFree(pszArgs);
|
||||
_ASSERTE(FALSE && "Memory allocation failed");
|
||||
return lstrdup(L"");
|
||||
}
|
||||
@ -143,7 +138,6 @@ wchar_t* GuiMacro::AsString()
|
||||
{
|
||||
_wcscpy_c(pszDst, cchTotal, pszArgs[i]);
|
||||
pszDst += _tcslen(pszDst);
|
||||
free(pszArgs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,16 +146,11 @@ wchar_t* GuiMacro::AsString()
|
||||
//done:
|
||||
*(pszDst++) = 0;
|
||||
#ifdef _DEBUG
|
||||
size_t cchUsed = (pszDst - pszBuf);
|
||||
const size_t cchUsed = (pszDst - pszBuf);
|
||||
_ASSERTE(cchUsed <= cchTotal);
|
||||
#endif
|
||||
|
||||
|
||||
if (pszArgs)
|
||||
{
|
||||
free(pszArgs);
|
||||
}
|
||||
return pszBuf;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool GuiMacro::GetIntArg(size_t idx, int& val)
|
||||
@ -177,13 +166,13 @@ bool GuiMacro::GetIntArg(size_t idx, int& val)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GuiMacro::GetStrArg(size_t idx, LPWSTR& val)
|
||||
bool GuiMacro::GetStrArg(size_t idx, CEStr& val)
|
||||
{
|
||||
// It it is detected as "Int" but we need "Str" - return it as string
|
||||
if ((idx >= argc)
|
||||
|| (argv[idx].Type != gmt_Str && argv[idx].Type != gmt_VStr && argv[idx].Type != gmt_Int))
|
||||
{
|
||||
val = nullptr;
|
||||
val.Release();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -191,23 +180,19 @@ bool GuiMacro::GetStrArg(size_t idx, LPWSTR& val)
|
||||
return (val != nullptr);
|
||||
}
|
||||
|
||||
bool GuiMacro::GetRestStrArgs(size_t idx, LPWSTR& val)
|
||||
bool GuiMacro::GetRestStrArgs(size_t idx, CEStr& val)
|
||||
{
|
||||
if (!GetStrArg(idx, val))
|
||||
return false;
|
||||
if (!IsStrArg(idx+1))
|
||||
return true; // No more string arguments!
|
||||
// Concatenate string (memory was allocated continuously for all arguments)
|
||||
LPWSTR pszEnd = val + _tcslen(val);
|
||||
// Concatenate string
|
||||
for (size_t i = idx+1; i < argc; i++)
|
||||
{
|
||||
LPWSTR pszAdd;
|
||||
CEStr pszAdd;
|
||||
if (!GetStrArg(i, pszAdd))
|
||||
break;
|
||||
size_t iLen = _tcslen(pszAdd);
|
||||
if (pszEnd < pszAdd)
|
||||
wmemmove(pszEnd, pszAdd, iLen+1);
|
||||
pszEnd += iLen;
|
||||
val.Append(pszAdd);
|
||||
}
|
||||
// Trim argument list, there is only one returned string left...
|
||||
argc = idx+1;
|
||||
@ -241,7 +226,7 @@ bool GuiMacro::IsStrArg(size_t idx)
|
||||
/* ************************* */
|
||||
namespace ConEmuMacro {
|
||||
|
||||
GuiMacro* GetNextMacro(LPWSTR& asString, bool abConvert, wchar_t** rsErrMsg)
|
||||
GuiMacro* GetNextMacro(wchar_t*& asString, bool abConvert, CEStr* rsErrMsg)
|
||||
{
|
||||
// Skip white-spaces
|
||||
SkipWhiteSpaces(asString);
|
||||
@ -249,7 +234,7 @@ GuiMacro* GetNextMacro(LPWSTR& asString, bool abConvert, wchar_t** rsErrMsg)
|
||||
if (!asString || !*asString)
|
||||
{
|
||||
if (rsErrMsg)
|
||||
*rsErrMsg = lstrdup(L"Empty Macro");
|
||||
rsErrMsg->Set(L"Empty Macro");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -257,7 +242,7 @@ GuiMacro* GetNextMacro(LPWSTR& asString, bool abConvert, wchar_t** rsErrMsg)
|
||||
{
|
||||
if (rsErrMsg)
|
||||
{
|
||||
*rsErrMsg = lstrmerge(
|
||||
*rsErrMsg = CEStr(
|
||||
L"Invalid Macro, remove surrounding quotes:\r\n",
|
||||
asString,
|
||||
nullptr);
|
||||
@ -331,7 +316,7 @@ GuiMacro* GetNextMacro(LPWSTR& asString, bool abConvert, wchar_t** rsErrMsg)
|
||||
_ASSERTE(chTerm || (asString && (*asString == 0)));
|
||||
if (rsErrMsg)
|
||||
{
|
||||
*rsErrMsg = lstrmerge(
|
||||
*rsErrMsg = CEStr(
|
||||
L"Invalid Macro, can't get function name:\r\n",
|
||||
asString,
|
||||
nullptr);
|
||||
@ -341,7 +326,7 @@ GuiMacro* GetNextMacro(LPWSTR& asString, bool abConvert, wchar_t** rsErrMsg)
|
||||
|
||||
if (rsErrMsg)
|
||||
{
|
||||
*rsErrMsg = lstrmerge(
|
||||
*rsErrMsg = CEStr(
|
||||
L"Invalid Macro, too long function name:\r\n",
|
||||
asString,
|
||||
nullptr);
|
||||
@ -505,21 +490,21 @@ GuiMacro* GetNextMacro(LPWSTR& asString, bool abConvert, wchar_t** rsErrMsg)
|
||||
// Helper to concatenate macros.
|
||||
// They must be ‘concatenatable’, example: Print("abc"); Print("Qqq")
|
||||
// But following WILL NOT work: Print: Abd qqq
|
||||
LPCWSTR ConcatMacro(LPWSTR& rsMacroList, LPCWSTR asAddMacro)
|
||||
LPCWSTR ConcatMacro(CEStr& rsMacroList, LPCWSTR asAddMacro)
|
||||
{
|
||||
if (!asAddMacro || !*asAddMacro)
|
||||
{
|
||||
return rsMacroList;
|
||||
}
|
||||
|
||||
if (!rsMacroList || !*rsMacroList)
|
||||
if (rsMacroList.IsEmpty())
|
||||
{
|
||||
SafeFree(rsMacroList);
|
||||
rsMacroList.Release();
|
||||
rsMacroList = lstrdup(asAddMacro);
|
||||
}
|
||||
else
|
||||
{
|
||||
lstrmerge(&rsMacroList, L"; ", asAddMacro);
|
||||
rsMacroList.Append(L"; ", asAddMacro);
|
||||
}
|
||||
|
||||
return rsMacroList;
|
||||
@ -542,9 +527,10 @@ void SkipWhiteSpaces(LPWSTR& rsString)
|
||||
|
||||
// Get next numerical argument (dec or hex)
|
||||
// Delimiter - comma or space
|
||||
LPWSTR GetNextInt(LPWSTR& rsArguments, GuiMacroArg& rnValue)
|
||||
wchar_t* GetNextInt(wchar_t*& rsArguments, GuiMacroArg& rnValue)
|
||||
{
|
||||
LPWSTR pszArg = nullptr, pszEnd = nullptr;
|
||||
wchar_t* pszArg = nullptr;
|
||||
wchar_t* pszEnd = nullptr;
|
||||
rnValue.Str = rsArguments;
|
||||
rnValue.Int = 0; // Reset
|
||||
|
||||
@ -605,7 +591,7 @@ LPWSTR GetNextInt(LPWSTR& rsArguments, GuiMacroArg& rnValue)
|
||||
}
|
||||
|
||||
// Получить следующий строковый параметр
|
||||
LPWSTR GetNextString(LPWSTR& rsArguments, LPWSTR& rsString, bool bColonDelim, bool& bEndBracket)
|
||||
wchar_t* GetNextString(wchar_t*& rsArguments, wchar_t*& rsString, bool bColonDelim, bool& bEndBracket)
|
||||
{
|
||||
rsString = nullptr; // Сброс
|
||||
|
||||
@ -614,7 +600,7 @@ LPWSTR GetNextString(LPWSTR& rsArguments, LPWSTR& rsString, bool bColonDelim, bo
|
||||
|
||||
#ifdef _DEBUG
|
||||
LPWSTR pszArgStart = rsArguments;
|
||||
LPWSTR pszArgEnd = rsArguments+_tcslen(rsArguments);
|
||||
LPWSTR pszArgEnd = rsArguments + _tcslen(rsArguments);
|
||||
#endif
|
||||
|
||||
// Пропустить white-space
|
||||
|
@ -69,10 +69,10 @@ struct GuiMacro
|
||||
size_t argc;
|
||||
GuiMacroArg* argv; // No need to release mem, buffer allocated for the full GuiMacro data
|
||||
|
||||
wchar_t* AsString();
|
||||
CEStr AsString() const;
|
||||
bool GetIntArg(size_t idx, int& val);
|
||||
bool GetStrArg(size_t idx, LPWSTR& val);
|
||||
bool GetRestStrArgs(size_t idx, LPWSTR& val);
|
||||
bool GetStrArg(size_t idx, CEStr& val);
|
||||
bool GetRestStrArgs(size_t idx, CEStr& val);
|
||||
bool IsIntArg(size_t idx);
|
||||
bool IsStrArg(size_t idx);
|
||||
};
|
||||
@ -82,9 +82,9 @@ namespace ConEmuMacro
|
||||
/* ****************************** */
|
||||
/* ****** Helper functions ****** */
|
||||
/* ****************************** */
|
||||
LPWSTR GetNextString(LPWSTR& rsArguments, LPWSTR& rsString, bool bColonDelim, bool& bEndBracket);
|
||||
LPWSTR GetNextInt(LPWSTR& rsArguments, GuiMacroArg& rnValue);
|
||||
wchar_t* GetNextString(wchar_t*& rsArguments, wchar_t*& rsString, bool bColonDelim, bool& bEndBracket);
|
||||
wchar_t* GetNextInt(wchar_t*& rsArguments, GuiMacroArg& rnValue);
|
||||
void SkipWhiteSpaces(LPWSTR& rsString);
|
||||
LPWSTR Int2Str(UINT nValue, bool bSigned);
|
||||
GuiMacro* GetNextMacro(LPWSTR& asString, bool abConvert, wchar_t** rsErrMsg);
|
||||
CEStr Int2Str(UINT nValue, bool bSigned);
|
||||
GuiMacro* GetNextMacro(wchar_t*& asString, bool abConvert, CEStr* rsErrMsg);
|
||||
}
|
||||
|
@ -520,7 +520,7 @@ bool CMatch::GetNextLine(CRConDataGuard& data, int nLine)
|
||||
wmemmove(ptr, line.pChar, line.nLen);
|
||||
ptr[line.nLen] = 0;
|
||||
// Append new data
|
||||
if (!lstrmerge(&m_SrcLine.ms_Val, ptr))
|
||||
if (!m_SrcLine.Append(ptr))
|
||||
return false;
|
||||
mn_SrcLength += line.nLen;
|
||||
return true;
|
||||
|
@ -325,7 +325,7 @@ void CConEmuMenu::OnNewConPopupMenu(POINT* ptWhere /*= nullptr*/, DWORD nFlags /
|
||||
Folders.push_back(flNew);
|
||||
}
|
||||
|
||||
szTempName = lstrmerge(L"{", pszFolder + 2);
|
||||
szTempName = CEStr(L"{", pszFolder + 2);
|
||||
pszTaskName = szTempName;
|
||||
}
|
||||
|
||||
@ -495,7 +495,7 @@ void CConEmuMenu::OnNewConPopupMenu(POINT* ptWhere /*= nullptr*/, DWORD nFlags /
|
||||
if ((itm.ItemType == CmdTaskPopupItem::eTaskAll) || (itm.ItemType == CmdTaskPopupItem::eTaskPopup))
|
||||
{
|
||||
const CommandTasks* pGrp = (const CommandTasks*)itm.pGrp;
|
||||
con.pszSpecialCmd = lstrdup(pGrp->pszName);
|
||||
con.pszSpecialCmd = lstrdup(pGrp->pszName).Detach();
|
||||
pGrp->ParseGuiArgs(&con);
|
||||
_ASSERTE(con.pszSpecialCmd && *con.pszSpecialCmd==TaskBracketLeft && con.pszSpecialCmd[lstrlen(con.pszSpecialCmd)-1]==TaskBracketRight);
|
||||
}
|
||||
@ -507,7 +507,7 @@ void CConEmuMenu::OnNewConPopupMenu(POINT* ptWhere /*= nullptr*/, DWORD nFlags /
|
||||
pGrp->ParseGuiArgs(&con);
|
||||
|
||||
// Task pre-options, for example ">*cmd"
|
||||
con.pszSpecialCmd = lstrdup(gpConEmu->ParseScriptLineOptions(itm.pszCmd, nullptr, &con));
|
||||
con.pszSpecialCmd = lstrdup(gpConEmu->ParseScriptLineOptions(itm.pszCmd, nullptr, &con)).Detach();
|
||||
|
||||
con.ProcessNewConArg();
|
||||
|
||||
@ -517,7 +517,7 @@ void CConEmuMenu::OnNewConPopupMenu(POINT* ptWhere /*= nullptr*/, DWORD nFlags /
|
||||
{
|
||||
_ASSERTE(itm.pszCmd && (*itm.pszCmd != L'>'));
|
||||
|
||||
con.pszSpecialCmd = lstrdup(itm.pszCmd);
|
||||
con.pszSpecialCmd = lstrdup(itm.pszCmd).Detach();
|
||||
|
||||
_ASSERTE(con.pszSpecialCmd && *con.pszSpecialCmd);
|
||||
}
|
||||
@ -551,11 +551,11 @@ void CConEmuMenu::OnNewConPopupMenu(POINT* ptWhere /*= nullptr*/, DWORD nFlags /
|
||||
}
|
||||
|
||||
// Release handles
|
||||
for (INT_PTR i = 0; i < m_CmdTaskPopup.size(); i++)
|
||||
for (auto& taskMenuItem : m_CmdTaskPopup)
|
||||
{
|
||||
if (m_CmdTaskPopup[i].hPopup)
|
||||
DestroyMenu(m_CmdTaskPopup[i].hPopup);
|
||||
SafeFree(m_CmdTaskPopup[i].pszTaskBuf);
|
||||
if (taskMenuItem.hPopup)
|
||||
DestroyMenu(taskMenuItem.hPopup);
|
||||
taskMenuItem.pszTaskBuf.Release();
|
||||
}
|
||||
DestroyMenu(hPopup);
|
||||
}
|
||||
@ -667,7 +667,7 @@ void CConEmuMenu::OnNewConPopupMenuRClick(HMENU hMenu, UINT nItemPos)
|
||||
LPCWSTR pszCmd = gpConEmu->ParseScriptLineOptions(itm.pszCmd, nullptr, &con);
|
||||
|
||||
// Well, start selected line from Task
|
||||
con.pszSpecialCmd = lstrdup(pszCmd);
|
||||
con.pszSpecialCmd = lstrdup(pszCmd).Detach();
|
||||
if (!con.pszSpecialCmd)
|
||||
{
|
||||
_ASSERTE(con.pszSpecialCmd!=nullptr);
|
||||
@ -929,10 +929,8 @@ void CConEmuMenu::ExecPopupMenuCmd(TrackMenuPlace place, CVirtualConsole* apVCon
|
||||
case IDM_SPLIT2RIGHT:
|
||||
case IDM_SPLIT2BOTTOM:
|
||||
{
|
||||
LPWSTR pszMacro = lstrdup((nCmd == IDM_SPLIT2RIGHT) ? L"Split(0,50,0)" : L"Split(0,0,50)");
|
||||
LPWSTR pszRc = ConEmuMacro::ExecuteMacro(pszMacro, apVCon->RCon());
|
||||
SafeFree(pszMacro);
|
||||
SafeFree(pszRc);
|
||||
CEStr pszMacro = lstrdup((nCmd == IDM_SPLIT2RIGHT) ? L"Split(0,50,0)" : L"Split(0,0,50)");
|
||||
CEStr pszRc = ConEmuMacro::ExecuteMacro(std::move(pszMacro), apVCon->RCon());
|
||||
break;
|
||||
}
|
||||
case IDM_CHILDSYSMENU:
|
||||
@ -1177,7 +1175,7 @@ POINT CConEmuMenu::CalcTabMenuPos(CVirtualConsole* apVCon)
|
||||
|
||||
int CConEmuMenu::FillTaskPopup(HMENU hMenu, CmdTaskPopupItem* pParent)
|
||||
{
|
||||
const CommandTasks* pGrp = (const CommandTasks*)pParent->pGrp;
|
||||
const CommandTasks* pGrp = static_cast<const CommandTasks*>(pParent->pGrp);
|
||||
|
||||
CmdTaskPopupItem itm = {CmdTaskPopupItem::eNone};
|
||||
|
||||
@ -1185,22 +1183,19 @@ int CConEmuMenu::FillTaskPopup(HMENU hMenu, CmdTaskPopupItem* pParent)
|
||||
//itm.pGrp = pGrp;
|
||||
|
||||
int nCount = 0;
|
||||
const size_t nMenuHotkeyMax = _tcslen(sMenuHotkey);
|
||||
const ssize_t nMenuHotkeyMax = _tcslen(sMenuHotkey);
|
||||
|
||||
if (pGrp && pGrp->pszCommands && *pGrp->pszCommands)
|
||||
{
|
||||
SafeFree(pParent->pszTaskBuf);
|
||||
pParent->pszTaskBuf = lstrdup(pGrp->pszCommands);
|
||||
|
||||
wchar_t *pszDataW = pParent->pszTaskBuf;
|
||||
wchar_t *pszDataW = pParent->pszTaskBuf.data();
|
||||
wchar_t *pszLine = pszDataW;
|
||||
wchar_t *pszNewLine = wcschr(pszLine, L'\n');
|
||||
//const UINT nStartID = 1000;
|
||||
//UINT nLastID = 0;
|
||||
//LPCWSTR pszLines[MAX_CONSOLE_COUNT];
|
||||
|
||||
while (*pszLine && (nCount < MAX_CONSOLE_COUNT))
|
||||
{
|
||||
pszLine = const_cast<wchar_t*>(SkipNonPrintable(pszLine));
|
||||
wchar_t* pszNewLine = wcschr(pszLine, L'\n');
|
||||
if (pszNewLine)
|
||||
{
|
||||
*pszNewLine = 0;
|
||||
@ -1208,8 +1203,6 @@ int CConEmuMenu::FillTaskPopup(HMENU hMenu, CmdTaskPopupItem* pParent)
|
||||
*(pszNewLine-1) = 0;
|
||||
}
|
||||
|
||||
while (*pszLine == L' ') pszLine++;
|
||||
|
||||
if (*pszLine)
|
||||
{
|
||||
itm.Reset(CmdTaskPopupItem::eTaskCmd, ++mn_CmdLastID);
|
||||
@ -1220,29 +1213,22 @@ int CConEmuMenu::FillTaskPopup(HMENU hMenu, CmdTaskPopupItem* pParent)
|
||||
else
|
||||
itm.szShort[0] = 0;
|
||||
|
||||
// Обработать возможные "&" в строке запуска, чтобы они в меню видны были
|
||||
//itm.pszTaskBuf = lstrmerge(itm.szShort, pszLine);
|
||||
// Escape possible "&" in the command line, let them visible in the menu
|
||||
const size_t cchItemMax = _tcslen(itm.szShort) + (2 * _tcslen(pszLine)) + 1;
|
||||
itm.pszTaskBuf = (wchar_t*)malloc(cchItemMax*sizeof(*itm.pszTaskBuf));
|
||||
_wcscpy_c(itm.pszTaskBuf, cchItemMax, itm.szShort);
|
||||
CmdTaskPopupItem::SetMenuName(itm.pszTaskBuf, cchItemMax, pszLine, true);
|
||||
if (itm.pszTaskBuf.GetBuffer(cchItemMax))
|
||||
{
|
||||
itm.pszTaskBuf.Set(itm.szShort);
|
||||
CmdTaskPopupItem::SetMenuName(itm.pszTaskBuf.data(), cchItemMax, pszLine, true);
|
||||
|
||||
InsertMenu(hMenu, -1, MF_BYPOSITION|MF_ENABLED|MF_STRING, itm.nCmd, itm.pszTaskBuf);
|
||||
InsertMenu(hMenu, -1, MF_BYPOSITION | MF_ENABLED | MF_STRING, itm.nCmd, itm.pszTaskBuf.c_str());
|
||||
m_CmdTaskPopup.push_back(itm);
|
||||
|
||||
nCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pszNewLine) break;
|
||||
|
||||
pszLine = pszNewLine+1;
|
||||
|
||||
if (!*pszLine) break;
|
||||
|
||||
while ((*pszLine == L'\r') || (*pszLine == L'\n'))
|
||||
pszLine++; // пропустить все переводы строк
|
||||
|
||||
pszNewLine = wcschr(pszLine, L'\n');
|
||||
pszLine = pszNewLine + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1355,74 +1341,12 @@ LRESULT CConEmuMenu::OnInitMenuPopup(HWND hWnd, HMENU hMenu, LPARAM lParam)
|
||||
if (mb_CmdShowTaskItems && p && (p->ItemType == CmdTaskPopupItem::eTaskPopup) && !p->bPopupInitialized)
|
||||
{
|
||||
p->bPopupInitialized = TRUE;
|
||||
const CommandTasks* pGrp = (const CommandTasks*)p->pGrp;
|
||||
|
||||
//CmdTaskPopupItem itm = {CmdTaskPopupItem::eNone};
|
||||
|
||||
//itm.Reset(CmdTaskPopupItem::eTask, ++mn_CmdLastID, L"Run all commands");
|
||||
//itm.pGrp = pGrp;
|
||||
|
||||
//int nCount = 0;
|
||||
//int nMenuHotkeyMax = _tcslen(sMenuHotkey);
|
||||
const CommandTasks* pGrp = static_cast<const CommandTasks*>(p->pGrp);
|
||||
|
||||
if (pGrp && pGrp->pszCommands && *pGrp->pszCommands)
|
||||
{
|
||||
int nCount = FillTaskPopup(hMenu, p);
|
||||
|
||||
//p->pszTaskBuf = lstrdup(pGrp->pszCommands);
|
||||
//wchar_t *pszDataW = p->pszTaskBuf;
|
||||
//wchar_t *pszLine = pszDataW;
|
||||
//wchar_t *pszNewLine = wcschr(pszLine, L'\n');
|
||||
////const UINT nStartID = 1000;
|
||||
////UINT nLastID = 0;
|
||||
////LPCWSTR pszLines[MAX_CONSOLE_COUNT];
|
||||
|
||||
//while (*pszLine && (nCount < MAX_CONSOLE_COUNT))
|
||||
//{
|
||||
// if (pszNewLine)
|
||||
// {
|
||||
// *pszNewLine = 0;
|
||||
// if ((pszNewLine > pszDataW) && (*(pszNewLine-1) == L'\r'))
|
||||
// *(pszNewLine-1) = 0;
|
||||
// }
|
||||
|
||||
// while (*pszLine == L' ') pszLine++;
|
||||
|
||||
// if (*pszLine)
|
||||
// {
|
||||
// itm.Reset(CmdTaskPopupItem::eTaskCmd, ++mn_CmdLastID);
|
||||
// itm.pGrp = pGrp;
|
||||
// itm.pszCmd = pszLine;
|
||||
// if (nCount <= nMenuHotkeyMax)
|
||||
// swprintf_c(itm.szShort, L"&%c: ", sMenuHotkey[nCount]);
|
||||
// else
|
||||
// itm.szShort[0] = 0;
|
||||
|
||||
// // Обработать возможные "&" в строке запуска, чтобы они в меню видны были
|
||||
// //itm.pszTaskBuf = lstrmerge(itm.szShort, pszLine);
|
||||
// INT_PTR cchItemMax = _tcslen(itm.szShort) + 2*_tcslen(pszLine) + 1;
|
||||
// itm.pszTaskBuf = (wchar_t*)malloc(cchItemMax*sizeof(*itm.pszTaskBuf));
|
||||
// _wcscpy_c(itm.pszTaskBuf, cchItemMax, itm.szShort);
|
||||
// CmdTaskPopupItem::SetMenuName(itm.pszTaskBuf, cchItemMax, pszLine, true);
|
||||
|
||||
// InsertMenu(hMenu, -1, MF_BYPOSITION|MF_ENABLED|MF_STRING, itm.nCmd, itm.pszTaskBuf);
|
||||
// m_CmdTaskPopup.push_back(itm);
|
||||
|
||||
// nCount++;
|
||||
// }
|
||||
|
||||
// if (!pszNewLine) break;
|
||||
|
||||
// pszLine = pszNewLine+1;
|
||||
|
||||
// if (!*pszLine) break;
|
||||
|
||||
// while ((*pszLine == L'\r') || (*pszLine == L'\n'))
|
||||
// pszLine++; // пропустить все переводы строк
|
||||
|
||||
// pszNewLine = wcschr(pszLine, L'\n');
|
||||
//}
|
||||
|
||||
if (nCount > 1)
|
||||
{
|
||||
CmdTaskPopupItem itm = {CmdTaskPopupItem::eNone};
|
||||
|
@ -138,10 +138,10 @@ private:
|
||||
enum CmdTaskPopupItemType { eNone, eTaskPopup, eTaskAll, eTaskCmd, eMore, eCmd, eNewDlg, eSetupTasks, eClearHistory } ItemType = {};
|
||||
int nCmd = 0;
|
||||
const void/*CommandTasks*/* pGrp = nullptr;
|
||||
LPCWSTR pszCmd = nullptr;
|
||||
LPCWSTR pszCmd = nullptr; // pointer to the parent.pszTaskBuf
|
||||
wchar_t szShort[64] = L"";
|
||||
HMENU hPopup = nullptr;
|
||||
wchar_t* pszTaskBuf = nullptr;
|
||||
CEStr pszTaskBuf = nullptr;
|
||||
bool bPopupInitialized = false;
|
||||
|
||||
void Reset(CmdTaskPopupItemType newItemType, int newCmdId, LPCWSTR asName = nullptr);
|
||||
|
@ -53,13 +53,12 @@ bool MyOpenClipboard(LPCWSTR asAction)
|
||||
// Open Windows' clipboard
|
||||
while (!(lbRc = OpenClipboard((ghWnd && IsWindow(ghWnd)) ? ghWnd : nullptr)) && (iMaxTries-- > 0))
|
||||
{
|
||||
DWORD dwErr = GetLastError();
|
||||
const DWORD dwErr = GetLastError();
|
||||
|
||||
wchar_t szCode[32]; swprintf_c(szCode, L", Code=%u", dwErr);
|
||||
wchar_t* pszMsg = lstrmerge(L"OpenClipboard failed (", asAction, L")", szCode);
|
||||
CEStr pszMsg(L"OpenClipboard failed (", asAction, L")", szCode);
|
||||
LogString(pszMsg);
|
||||
int iBtn = DisplayLastError(pszMsg, dwErr, MB_RETRYCANCEL|MB_ICONSTOP);
|
||||
SafeFree(pszMsg);
|
||||
const int iBtn = DisplayLastError(pszMsg, dwErr, MB_RETRYCANCEL|MB_ICONSTOP);
|
||||
|
||||
if (iBtn != IDRETRY)
|
||||
return false;
|
||||
@ -196,7 +195,7 @@ bool CopyToClipboard(LPCWSTR asText)
|
||||
return bCopied;
|
||||
}
|
||||
|
||||
wchar_t* GetCliboardText(DWORD& rnErrCode, wchar_t* rsErrText, INT_PTR cchErrMax)
|
||||
CEStr GetClipboardText(DWORD& rnErrCode, wchar_t* rsErrText, INT_PTR cchErrMax)
|
||||
{
|
||||
if (!rsErrText || cchErrMax < 255)
|
||||
{
|
||||
@ -206,7 +205,7 @@ wchar_t* GetCliboardText(DWORD& rnErrCode, wchar_t* rsErrText, INT_PTR cchErrMax
|
||||
|
||||
HGLOBAL hglb;
|
||||
LPCWSTR lptstr;
|
||||
wchar_t* pszBuf = nullptr;
|
||||
CEStr result;
|
||||
|
||||
if ((hglb = GetClipboardData(CF_UNICODETEXT)) == nullptr)
|
||||
{
|
||||
@ -242,10 +241,10 @@ wchar_t* GetCliboardText(DWORD& rnErrCode, wchar_t* rsErrText, INT_PTR cchErrMax
|
||||
}
|
||||
else
|
||||
{
|
||||
pszBuf = lstrdup(lptstr, 1); // Reserve memory for space-termination
|
||||
Assert(pszBuf!=nullptr);
|
||||
result = lstrdup(lptstr, 1); // Reserve memory for space-termination
|
||||
Assert(result.c_str() != nullptr);
|
||||
GlobalUnlock(hglb);
|
||||
}
|
||||
|
||||
return pszBuf;
|
||||
return result;
|
||||
}
|
||||
|
@ -35,4 +35,4 @@ bool MyOpenClipboard(LPCWSTR asAction);
|
||||
void MyCloseClipboard();
|
||||
HANDLE MySetClipboardData(UINT uFormat, HANDLE hMem);
|
||||
bool CopyToClipboard(LPCWSTR asText);
|
||||
wchar_t* GetCliboardText(DWORD& rnErrCode, wchar_t* rsErrText, INT_PTR cchErrMax);
|
||||
CEStr GetClipboardText(DWORD& rnErrCode, wchar_t* rsErrText, INT_PTR cchErrMax);
|
||||
|
@ -347,13 +347,13 @@ void Settings::ReleasePointers()
|
||||
SafeFree(psHistoryLocation);
|
||||
SafeFree(psDefaultTerminalApps);
|
||||
|
||||
SafeFree(psAnsiAllowed);
|
||||
SafeDelete(psAnsiAllowed);
|
||||
SafeFree(pszAnsiLog);
|
||||
|
||||
SafeFree(pszCTSIntelligentExceptions);
|
||||
SafeFree(sFarGotoEditor);
|
||||
SafeFree(pszTabSkipWords);
|
||||
SafeFree(psEnvironmentSet);
|
||||
SafeDelete(psEnvironmentSet);
|
||||
|
||||
FreeCmdTasks();
|
||||
FreeStartupTask();
|
||||
@ -369,7 +369,7 @@ void Settings::ReleasePointers()
|
||||
ProgressesCount = 0;
|
||||
|
||||
UpdSet.FreePointers();
|
||||
SafeFree(FindOptions.pszText);
|
||||
FindOptions.text.Release();
|
||||
}
|
||||
|
||||
Settings::~Settings()
|
||||
@ -453,7 +453,7 @@ void Settings::InitSettings()
|
||||
}
|
||||
|
||||
AutoReloadEnvironment = true;
|
||||
psEnvironmentSet = lstrdup(
|
||||
psEnvironmentSet = new CEStr(
|
||||
L"set PATH=%ConEmuBaseDir%\\Scripts;%PATH%\r\n"
|
||||
L"\r\n"
|
||||
L"# set ConEmuPromptNames=NO\r\n" // created after gh-1570
|
||||
@ -659,10 +659,10 @@ void Settings::InitSettings()
|
||||
|
||||
isProcessAnsi = true;
|
||||
isAnsiExec = ansi_CmdOnly;
|
||||
psAnsiAllowed = lstrdup(L"cmd -cur_console:R /cGitShowBranch.cmd\r\n");
|
||||
psAnsiAllowed = new CEStr(L"cmd -cur_console:R /cGitShowBranch.cmd\r\n");
|
||||
isAnsiLog = false;
|
||||
isAnsiLogCodes = false;
|
||||
pszAnsiLog = lstrdup(CEANSILOGFOLDER);
|
||||
pszAnsiLog = lstrdup(CEANSILOGFOLDER).Detach();
|
||||
isKillSshAgent = true;
|
||||
isProcessNewConArg = true;
|
||||
isProcessCmdStart = false; // gh#420
|
||||
@ -681,7 +681,7 @@ void Settings::InitSettings()
|
||||
wcscpy_c(szTabModifiedSuffix, L"[*]");
|
||||
wchar_t szTabSkipWords[64];
|
||||
wcscpy_c(szTabSkipWords, L"Administrator:|Администратор:");
|
||||
pszTabSkipWords = lstrdup(szTabSkipWords);
|
||||
pszTabSkipWords = lstrdup(szTabSkipWords).Detach();
|
||||
wcscpy_c(szTabPanels, szTabConsole); // Раньше была только настройка "TabConsole". Унаследовать ее в "TabPanels"
|
||||
wcscpy_c(szTabEditor, L"<%c.%i>{%s}");
|
||||
wcscpy_c(szTabEditorModified, L"<%c.%i>[%s] *");
|
||||
@ -692,7 +692,7 @@ void Settings::InitSettings()
|
||||
isSafeFarClose = true;
|
||||
sSafeFarCloseMacro = nullptr; // если nullptr - то используется макрос по умолчанию
|
||||
isCTSIntelligent = true;
|
||||
pszCTSIntelligentExceptions = LineDelimited2MSZ(L"far|vim");
|
||||
pszCTSIntelligentExceptions = LineDelimited2MSZ(L"far|vim").Detach();
|
||||
isCTSAutoCopy = true;
|
||||
isCTSResetOnRelease = false;
|
||||
isCTSIBeam = true;
|
||||
@ -713,7 +713,7 @@ void Settings::InitSettings()
|
||||
isPasteConfirmEnter = true;
|
||||
nPasteConfirmLonger = 200;
|
||||
isFarGotoEditor = true; //isFarGotoEditorVk = VK_LCONTROL;
|
||||
sFarGotoEditor = lstrdup(HI_GOTO_EDITOR_FAR);
|
||||
sFarGotoEditor = lstrdup(HI_GOTO_EDITOR_FAR).Detach();
|
||||
isHighlightMouseRow = false; // Not turned on by default
|
||||
isHighlightMouseCol = false; // Not turned on by default
|
||||
|
||||
@ -1096,7 +1096,7 @@ void Settings::LoadAppsSettings(SettingsBase* reg, bool abFromOpDlg /*= false*/)
|
||||
if (NewApps[nSucceeded]->AppNames /*&& *NewApps[nSucceeded]->AppNames*/)
|
||||
{
|
||||
NewApps[nSucceeded]->cchNameMax = wcslen(NewApps[nSucceeded]->AppNames)+1;
|
||||
NewApps[nSucceeded]->AppNamesLwr = lstrdup(NewApps[nSucceeded]->AppNames);
|
||||
NewApps[nSucceeded]->AppNamesLwr = lstrdup(NewApps[nSucceeded]->AppNames).Detach();
|
||||
CharLowerBuff(NewApps[nSucceeded]->AppNamesLwr, lstrlen(NewApps[nSucceeded]->AppNamesLwr));
|
||||
reg->Load(L"Elevated", NewApps[nSucceeded]->Elevated);
|
||||
LoadAppSettings(reg, NewApps[nSucceeded]/*, NewAppColors[nSucceeded]->Colors*/);
|
||||
@ -1498,7 +1498,7 @@ void Settings::CreatePredefinedPalettes(int iAddUserCount)
|
||||
{
|
||||
Palettes[n] = (ColorPalette*)calloc(1, sizeof(ColorPalette));
|
||||
_ASSERTE(DefColors[n].pszTitle && DefColors[n].pszTitle[0]==L'<' && DefColors[n].pszTitle[lstrlen(DefColors[n].pszTitle)-1]==L'>');
|
||||
Palettes[n]->pszName = lstrdup(DefColors[n].pszTitle);
|
||||
Palettes[n]->pszName = lstrdup(DefColors[n].pszTitle).Detach();
|
||||
Palettes[n]->bPredefined = true;
|
||||
Palettes[n]->nTextColorIdx = Palettes[n]->nBackColorIdx = CEDEF_BackColorAuto/*16*/;
|
||||
Palettes[n]->nPopTextColorIdx = Palettes[n]->nPopBackColorIdx = CEDEF_BackColorAuto/*16*/;
|
||||
@ -1977,7 +1977,7 @@ void Settings::PaletteSaveAs(LPCWSTR asName,
|
||||
|
||||
// Сохранять допускается только пользовательские палитры
|
||||
Palettes[nIndex]->bPredefined = false;
|
||||
Palettes[nIndex]->pszName = lstrdup(asName);
|
||||
Palettes[nIndex]->pszName = lstrdup(asName).Detach();
|
||||
|
||||
BOOL bTextChanged = !bNewPalette && ((Palettes[nIndex]->nTextColorIdx != anTextColorIdx) || (Palettes[nIndex]->nBackColorIdx != anBackColorIdx));
|
||||
BOOL bPopupChanged = !bNewPalette && ((Palettes[nIndex]->nPopTextColorIdx != anPopTextColorIdx) || (Palettes[nIndex]->nPopBackColorIdx != anPopBackColorIdx));
|
||||
@ -2099,7 +2099,7 @@ void Settings::ProgressesSetDuration(LPCWSTR asName, DWORD anDuration)
|
||||
return;
|
||||
}
|
||||
|
||||
Progresses[ProgressesCount]->pszName = lstrdup(asName);
|
||||
Progresses[ProgressesCount]->pszName = lstrdup(asName).Detach();
|
||||
Progresses[ProgressesCount]->nDuration = anDuration;
|
||||
|
||||
ProgressesCount++;
|
||||
@ -2507,7 +2507,8 @@ void Settings::LoadSettings(bool& rbNeedCreateVanilla, const SettingsStorage* ap
|
||||
|
||||
reg->Load(L"ProcessAnsi", isProcessAnsi);
|
||||
reg->Load(L"AnsiExecution", isAnsiExec); if (isAnsiExec > ansi_Disabled) isAnsiExec = ansi_Disabled;
|
||||
this->LoadMSZ(reg, L"AnsiAllowedCommands", psAnsiAllowed, L"\r\n", true);
|
||||
if (!psAnsiAllowed) psAnsiAllowed = new CEStr();
|
||||
this->LoadMSZ(reg, L"AnsiAllowedCommands", *psAnsiAllowed, L"\r\n", true);
|
||||
|
||||
reg->Load(L"AnsiLog", isAnsiLog);
|
||||
reg->Load(L"AnsiLogCodes", isAnsiLogCodes);
|
||||
@ -2688,7 +2689,8 @@ void Settings::LoadSettings(bool& rbNeedCreateVanilla, const SettingsStorage* ap
|
||||
//Update Comspec(&ComSpec); --> CSettings::SettingsLoaded
|
||||
|
||||
reg->Load(L"AutoReloadEnvironment", AutoReloadEnvironment);
|
||||
this->LoadMSZ(reg, L"EnvironmentSet", psEnvironmentSet, L"\r\n", true);
|
||||
if (!psEnvironmentSet) psEnvironmentSet = new CEStr(); else psEnvironmentSet->Clear();
|
||||
this->LoadMSZ(reg, L"EnvironmentSet", *psEnvironmentSet, L"\r\n", true);
|
||||
|
||||
reg->Load(L"CTS.Intelligent", isCTSIntelligent);
|
||||
{
|
||||
@ -2973,7 +2975,7 @@ void Settings::LoadSettings(bool& rbNeedCreateVanilla, const SettingsStorage* ap
|
||||
|
||||
// FindText: bMatchCase, bMatchWholeWords, bFreezeConsole, bHighlightAll
|
||||
// FindOptions.pszText may be used to pre-fill search dialog field if search-bar is hidden
|
||||
reg->Load(L"FindText", &FindOptions.pszText);
|
||||
reg->Load(L"FindText", &FindOptions.text.ms_Val);
|
||||
reg->Load(L"FindMatchCase", FindOptions.bMatchCase);
|
||||
reg->Load(L"FindMatchWholeWords", FindOptions.bMatchWholeWords);
|
||||
reg->Load(L"FindFreezeConsole", FindOptions.bFreezeConsole);
|
||||
@ -3271,8 +3273,8 @@ void Settings::AutoSaveSettings(SettingsBase* reg/* = nullptr*/, bool saveAll/*
|
||||
// Таски пишутся в отдельный ключ
|
||||
if (bTaskAutoSave)
|
||||
{
|
||||
wchar_t* pszTabs = CVConGroup::GetTasks();
|
||||
if (pszTabs && *pszTabs)
|
||||
CEStr pszTabs = CVConGroup::GetTasks();
|
||||
if (pszTabs)
|
||||
{
|
||||
BOOL lbOpened = FALSE;
|
||||
wchar_t szCmdKey[MAX_PATH+64];
|
||||
@ -3293,7 +3295,7 @@ void Settings::AutoSaveSettings(SettingsBase* reg/* = nullptr*/, bool saveAll/*
|
||||
if (StartupTask)
|
||||
{
|
||||
wchar_t szConfig[300] = L"";
|
||||
LPCWSTR pszConfigName = gpSetCls->GetConfigName();
|
||||
const wchar_t* pszConfigName = gpSetCls->GetConfigName();
|
||||
if (pszConfigName && *pszConfigName)
|
||||
{
|
||||
swprintf_c(szConfig, L"/config \"%s\"", pszConfigName);
|
||||
@ -3316,7 +3318,6 @@ void Settings::AutoSaveSettings(SettingsBase* reg/* = nullptr*/, bool saveAll/*
|
||||
gpConEmu->LogWindowPos(L"AutoSaveSettings - FAILED(OpenKey(AutoStartTaskName, KEY_WRITE))");
|
||||
}
|
||||
}
|
||||
SafeFree(pszTabs);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -3401,7 +3402,7 @@ void Settings::SaveFindOptions(SettingsBase* reg/* = nullptr*/)
|
||||
}
|
||||
}
|
||||
|
||||
reg->Save(L"FindText", FindOptions.pszText);
|
||||
reg->Save(L"FindText", FindOptions.text.c_str());
|
||||
reg->Save(L"FindMatchCase", FindOptions.bMatchCase);
|
||||
reg->Save(L"FindMatchWholeWords", FindOptions.bMatchWholeWords);
|
||||
#if 0
|
||||
@ -3621,14 +3622,13 @@ BOOL Settings::SaveSettings(BOOL abSilent /*= FALSE*/, const SettingsStorage* ap
|
||||
reg->Save(L"DefaultTerminalDebugLog", isDefaultTerminalDebugLog);
|
||||
reg->Save(L"DefaultTerminalConfirm", static_cast<BYTE>(nDefaultTerminalConfirmClose));
|
||||
{
|
||||
wchar_t* pszApps = GetDefaultTerminalApps(); // MSZ -> "|"-delimited string
|
||||
reg->Save(L"DefaultTerminalApps", pszApps);
|
||||
SafeFree(pszApps);
|
||||
const CEStr pszApps = GetDefaultTerminalApps(); // MSZ -> "|"-delimited string
|
||||
reg->Save(L"DefaultTerminalApps", pszApps.c_str());
|
||||
}
|
||||
|
||||
reg->Save(L"ProcessAnsi", isProcessAnsi);
|
||||
reg->Save(L"AnsiExecution", isAnsiExec);
|
||||
this->SaveMSZ(reg, L"AnsiAllowedCommands", psAnsiAllowed, L"\r\n", false);
|
||||
this->SaveMSZ(reg, L"AnsiAllowedCommands", psAnsiAllowed ? psAnsiAllowed->c_str() : nullptr, L"\r\n", false);
|
||||
|
||||
reg->Save(L"AnsiLog", isAnsiLog);
|
||||
reg->Save(L"AnsiLogCodes", isAnsiLogCodes);
|
||||
@ -3758,12 +3758,11 @@ BOOL Settings::SaveSettings(BOOL abSilent /*= FALSE*/, const SettingsStorage* ap
|
||||
reg->Save(L"ComSpec.UncPaths", _bool(ComSpec.isAllowUncPaths));
|
||||
reg->Save(L"ComSpec.Path", ComSpec.ComspecExplicit);
|
||||
reg->Save(L"AutoReloadEnvironment", AutoReloadEnvironment);
|
||||
this->SaveMSZ(reg, L"EnvironmentSet", psEnvironmentSet, L"\r\n", false);
|
||||
this->SaveMSZ(reg, L"EnvironmentSet", psEnvironmentSet ? psEnvironmentSet->c_str() : nullptr, L"\r\n", false);
|
||||
reg->Save(L"CTS.Intelligent", isCTSIntelligent);
|
||||
{
|
||||
wchar_t* pszApps = GetIntelligentExceptions(); // MSZ -> "|"-delimited string
|
||||
reg->Save(L"CTS.IntelligentExceptions", pszApps);
|
||||
SafeFree(pszApps);
|
||||
const CEStr pszApps = GetIntelligentExceptions(); // MSZ -> "|"-delimited string
|
||||
reg->Save(L"CTS.IntelligentExceptions", pszApps.c_str());
|
||||
}
|
||||
reg->Save(L"CTS.AutoCopy", isCTSAutoCopy);
|
||||
reg->Save(L"CTS.ResetOnRelease", isCTSResetOnRelease);
|
||||
@ -3793,9 +3792,8 @@ BOOL Settings::SaveSettings(BOOL abSilent /*= FALSE*/, const SettingsStorage* ap
|
||||
reg->Save(L"FixFarBorders", isFixFarBorders);
|
||||
reg->Save(L"Anti-aliasing2", isAntiAlias2);
|
||||
{
|
||||
wchar_t* pszCharRanges = CreateCharRanges(mpc_CharAltFontRanges);
|
||||
reg->Save(L"FixFarBordersRanges", pszCharRanges ? pszCharRanges : L"2013-25C4");
|
||||
if (pszCharRanges) free(pszCharRanges);
|
||||
CEStr pszCharRanges = CreateCharRanges(mpc_CharAltFontRanges);
|
||||
reg->Save(L"FixFarBordersRanges", pszCharRanges.c_str(L"2013-25C4"));
|
||||
}
|
||||
reg->Save(L"ExtendUCharMap", isExtendUCharMap);
|
||||
reg->Save(L"EnhanceGraphics", isEnhanceGraphics);
|
||||
@ -4268,15 +4266,15 @@ int Settings::ParseCharRanges(LPCWSTR asRanges, BYTE (&Chars)[0x10000], BYTE abV
|
||||
|
||||
int iRc = 0;
|
||||
int n = 0, nMax = _tcslen(asRanges);
|
||||
wchar_t *pszCopy = lstrdup(asRanges);
|
||||
CEStr pszCopy(asRanges);
|
||||
if (!pszCopy)
|
||||
{
|
||||
_ASSERTE(pszCopy!=nullptr);
|
||||
return -1;
|
||||
}
|
||||
wchar_t *pszRange = pszCopy;
|
||||
wchar_t *pszRange = pszCopy.data();
|
||||
wchar_t *pszNext = nullptr;
|
||||
UINT cBegin, cEnd;
|
||||
UINT cBegin = -1, cEnd;
|
||||
|
||||
memset(Chars, 0, sizeof(Chars));
|
||||
|
||||
@ -4319,16 +4317,14 @@ int Settings::ParseCharRanges(LPCWSTR asRanges, BYTE (&Chars)[0x10000], BYTE abV
|
||||
|
||||
iRc = 0; // ok
|
||||
wrap:
|
||||
if (pszCopy)
|
||||
free(pszCopy);
|
||||
return iRc;
|
||||
}
|
||||
|
||||
// caller must free(result)
|
||||
wchar_t* Settings::CreateCharRanges(BYTE (&Chars)[0x10000])
|
||||
CEStr Settings::CreateCharRanges(BYTE (&Chars)[0x10000])
|
||||
{
|
||||
size_t nMax = 1024;
|
||||
wchar_t* pszRanges = (wchar_t*)calloc(nMax,sizeof(*pszRanges));
|
||||
const size_t nMax = 1024;
|
||||
CEStr result;
|
||||
wchar_t* pszRanges = result.GetBuffer(nMax);
|
||||
if (!pszRanges)
|
||||
{
|
||||
_ASSERTE(pszRanges!=nullptr);
|
||||
@ -4338,19 +4334,19 @@ wchar_t* Settings::CreateCharRanges(BYTE (&Chars)[0x10000])
|
||||
wchar_t* psz = pszRanges;
|
||||
wchar_t* pszEnd = pszRanges + nMax;
|
||||
UINT c = 0;
|
||||
_ASSERTE((countof(Chars)-1) == 0xFFFF);
|
||||
_ASSERTE((countof(Chars) - 1) == 0xFFFF);
|
||||
while (c < countof(Chars))
|
||||
{
|
||||
if (Chars[c])
|
||||
{
|
||||
if ((psz + 10) >= pszEnd)
|
||||
{
|
||||
// Слишком длинный блок
|
||||
// Too long block
|
||||
_ASSERTE((psz + 10) < pszEnd);
|
||||
break;
|
||||
}
|
||||
|
||||
UINT cBegin = (c++);
|
||||
const UINT cBegin = (c++);
|
||||
UINT cEnd = cBegin;
|
||||
|
||||
while (c < countof(Chars) && Chars[c])
|
||||
@ -4374,7 +4370,7 @@ wchar_t* Settings::CreateCharRanges(BYTE (&Chars)[0x10000])
|
||||
}
|
||||
}
|
||||
|
||||
return pszRanges;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Settings::CheckCharAltFont(ucs32 inChar)
|
||||
@ -4426,7 +4422,7 @@ void Settings::CheckConsoleSettings()
|
||||
}
|
||||
}
|
||||
|
||||
wchar_t* Settings::GetStoragePlaceDescr(const SettingsStorage* apStorage, LPCWSTR asPrefix)
|
||||
CEStr Settings::GetStoragePlaceDescr(const SettingsStorage* apStorage, LPCWSTR asPrefix)
|
||||
{
|
||||
SettingsStorage temp = {};
|
||||
if (apStorage == nullptr)
|
||||
@ -4435,7 +4431,7 @@ wchar_t* Settings::GetStoragePlaceDescr(const SettingsStorage* apStorage, LPCWST
|
||||
apStorage = &temp;
|
||||
}
|
||||
|
||||
return lstrmerge(
|
||||
return CEStr(
|
||||
asPrefix,
|
||||
// [reg], [xml], ...
|
||||
L" ", apStorage->getTypeName(),
|
||||
@ -5235,7 +5231,7 @@ bool Settings::CmdTaskGetDefaultShell(RConStartArgsEx& args, CEStr& lsTitle)
|
||||
SafeFree(args.pszSpecialCmd);
|
||||
|
||||
// Run all tabs of the task, if they were specified
|
||||
args.pszSpecialCmd = lstrdup(pGrp->pszName);
|
||||
args.pszSpecialCmd = lstrdup(pGrp->pszName).Detach();
|
||||
lsTitle.Set(pGrp->pszName);
|
||||
break;
|
||||
}
|
||||
@ -5243,7 +5239,7 @@ bool Settings::CmdTaskGetDefaultShell(RConStartArgsEx& args, CEStr& lsTitle)
|
||||
|
||||
if (!args.pszSpecialCmd)
|
||||
{
|
||||
args.pszSpecialCmd = GetComspec(&gpSet->ComSpec); //lstrdup(L"cmd");
|
||||
args.pszSpecialCmd = GetComspec(&gpSet->ComSpec).Detach(); //lstrdup(L"cmd");
|
||||
if (!args.pszSpecialCmd)
|
||||
{
|
||||
_ASSERTE(FALSE && "Memory allocation failure");
|
||||
@ -5256,12 +5252,17 @@ bool Settings::CmdTaskGetDefaultShell(RConStartArgsEx& args, CEStr& lsTitle)
|
||||
if (lsTitle.IsEmpty())
|
||||
lsTitle.Set(L"cmd.exe");
|
||||
|
||||
lstrmerge(&args.pszSpecialCmd, L" /k \"%ConEmuBaseDir%\\CmdInit.cmd\"");
|
||||
CEStr merged(args.pszSpecialCmd, L" /k \"%ConEmuBaseDir%\\CmdInit.cmd\"");
|
||||
if (merged)
|
||||
{
|
||||
SafeFree(args.pszSpecialCmd);
|
||||
args.pszSpecialCmd = merged.Detach();
|
||||
}
|
||||
}
|
||||
|
||||
if (!args.pszStartupDir)
|
||||
{
|
||||
args.pszStartupDir = lstrdup(L"%CD%");
|
||||
args.pszStartupDir = lstrdup(L"%CD%").Detach();
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -5455,7 +5456,7 @@ int Settings::CmdTaskSet(int anIndex, LPCWSTR asName, LPCWSTR asGuiArgs, LPCWSTR
|
||||
bool bDuplicate = false;
|
||||
wchar_t szIndex[16] = L"";
|
||||
if (s) swprintf_c(szIndex, L" (%u)", s);
|
||||
lsName.Attach(lstrmerge(TaskBracketLeftS, lsNaked.ms_Val, szIndex, TaskBracketRightS));
|
||||
lsName = CEStr(TaskBracketLeftS, lsNaked.ms_Val, szIndex, TaskBracketRightS);
|
||||
|
||||
for (INT_PTR i = 0; (i < CmdTaskCount) && !bDuplicate; i++)
|
||||
{
|
||||
@ -5512,7 +5513,7 @@ const wchar_t* Settings::GetDefaultTerminalAppsMSZ()
|
||||
}
|
||||
|
||||
// returns "|"-delimited string
|
||||
wchar_t* Settings::GetDefaultTerminalApps()
|
||||
CEStr Settings::GetDefaultTerminalApps()
|
||||
{
|
||||
return MSZ2LineDelimited(psDefaultTerminalApps);
|
||||
}
|
||||
@ -5529,7 +5530,7 @@ void Settings::SetDefaultTerminalApps(const wchar_t* apszApps)
|
||||
// "|" delimited String -> MSZ
|
||||
if (apszApps && *apszApps)
|
||||
{
|
||||
psDefaultTerminalApps = LineDelimited2MSZ(apszApps);
|
||||
psDefaultTerminalApps = LineDelimited2MSZ(apszApps).Detach();
|
||||
}
|
||||
|
||||
if (gpConEmu)
|
||||
@ -5540,15 +5541,16 @@ void Settings::SetDefaultTerminalApps(const wchar_t* apszApps)
|
||||
|
||||
|
||||
// MSZ -> "<asDelim>"-delimited string
|
||||
wchar_t* Settings::MSZ2LineDelimited(const wchar_t* apszLines, LPCWSTR asDelim /*= L"|"*/, bool bFinalToo /*= false*/)
|
||||
CEStr Settings::MSZ2LineDelimited(const wchar_t* apszLines, LPCWSTR asDelim /*= L"|"*/, bool bFinalToo /*= false*/)
|
||||
{
|
||||
if (!apszLines || !*apszLines)
|
||||
if (IsStrEmpty(apszLines))
|
||||
{
|
||||
return lstrdup(L"");
|
||||
return CEStr(L"");
|
||||
}
|
||||
|
||||
// Evaluate required len
|
||||
INT_PTR nTotalLen = bFinalToo ? 2 : 1, nLen;
|
||||
INT_PTR nDelimLen = asDelim ? _tcslen(asDelim) : 0;
|
||||
const INT_PTR nDelimLen = asDelim ? _tcslen(asDelim) : 0;
|
||||
const wchar_t* psz = apszLines;
|
||||
while (*psz)
|
||||
{
|
||||
@ -5557,11 +5559,12 @@ wchar_t* Settings::MSZ2LineDelimited(const wchar_t* apszLines, LPCWSTR asDelim /
|
||||
nTotalLen += nLen + nDelimLen;
|
||||
}
|
||||
// Buffer
|
||||
wchar_t* pszRet = (wchar_t*)malloc(nTotalLen*sizeof(*pszRet));
|
||||
CEStr result;
|
||||
wchar_t* pszRet = result.GetBuffer(nTotalLen);
|
||||
if (!pszRet)
|
||||
{
|
||||
_ASSERTE(pszRet);
|
||||
return lstrdup(L"");
|
||||
return CEStr(L"");
|
||||
}
|
||||
// Conversion
|
||||
wchar_t* pszDst = pszRet; psz = apszLines;
|
||||
@ -5589,19 +5592,20 @@ wchar_t* Settings::MSZ2LineDelimited(const wchar_t* apszLines, LPCWSTR asDelim /
|
||||
}
|
||||
*pszDst = 0;
|
||||
|
||||
return pszRet;
|
||||
return result;
|
||||
}
|
||||
|
||||
// "|"-delimited string -> MSZ
|
||||
// !!! Returns LOWER-CASE string !!!
|
||||
wchar_t* Settings::LineDelimited2MSZ(const wchar_t* apszApps, bool bLowerCase /*= true*/)
|
||||
CEStr Settings::LineDelimited2MSZ(const wchar_t* apszApps, bool bLowerCase /*= true*/) const
|
||||
{
|
||||
wchar_t* pszDst = nullptr;
|
||||
CEStr result;
|
||||
|
||||
// "|" delimited String -> MSZ
|
||||
if (apszApps && *apszApps)
|
||||
if (IsStrNotEmpty(apszApps))
|
||||
{
|
||||
INT_PTR nLen = _tcslen(apszApps);
|
||||
pszDst = (wchar_t*)malloc((nLen+3)*sizeof(*pszDst));
|
||||
const INT_PTR nLen = _tcslen(apszApps);
|
||||
auto* pszDst = result.GetBuffer(nLen + 3);
|
||||
|
||||
if (pszDst)
|
||||
{
|
||||
@ -5629,30 +5633,31 @@ wchar_t* Settings::LineDelimited2MSZ(const wchar_t* apszApps, bool bLowerCase /*
|
||||
apszApps = pszNext + 1;
|
||||
}
|
||||
*(psz++) = 0;
|
||||
*(psz++) = 0; // для гарантии
|
||||
*(psz++) = 0; // ASCIIZZ
|
||||
}
|
||||
}
|
||||
|
||||
return pszDst;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// "\r\n"-delimited string -> MSZ
|
||||
wchar_t* Settings::MultiLine2MSZ(const wchar_t* apszLines, DWORD* pcbSize/*in bytes*/)
|
||||
CEStr Settings::MultiLine2MSZ(const wchar_t* apszLines, DWORD* pcbSize/*in bytes*/) const
|
||||
{
|
||||
wchar_t* pszDst = nullptr;
|
||||
CEStr result;
|
||||
DWORD cbSize = 0;
|
||||
|
||||
if (apszLines && *apszLines)
|
||||
{
|
||||
CEStr lsLine;
|
||||
INT_PTR nLenMax = lstrlen(apszLines) + 2;
|
||||
if ((pszDst = (wchar_t*)malloc(nLenMax*sizeof(wchar_t))) == nullptr)
|
||||
auto* pszDst = result.GetBuffer(nLenMax);
|
||||
if (pszDst == nullptr)
|
||||
{
|
||||
_ASSERTE(FALSE && "Memory allocation failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
CEStr lsLine;
|
||||
wchar_t* psz = pszDst;
|
||||
LPCWSTR pszSrc = apszLines;
|
||||
while ((pszSrc = NextLine(pszSrc, lsLine, NLF_NONE)))
|
||||
@ -5661,11 +5666,11 @@ wchar_t* Settings::MultiLine2MSZ(const wchar_t* apszLines, DWORD* pcbSize/*in by
|
||||
// That is a registry limitation
|
||||
if (lsLine.IsEmpty())
|
||||
lsLine.Set(L" ");
|
||||
int iLineLen = lstrlen(lsLine.ms_Val) + 1;
|
||||
const int iLineLen = lstrlen(lsLine.ms_Val) + 1;
|
||||
if ((psz - pszDst + 1 + iLineLen) >= nLenMax)
|
||||
{
|
||||
INT_PTR nNewLenMax = std::max((psz - pszDst + 1 + iLineLen), nLenMax) + 1024;
|
||||
wchar_t* pszRealloc = (wchar_t*)realloc(pszDst, nNewLenMax*sizeof(wchar_t));
|
||||
const INT_PTR nNewLenMax = std::max((psz - pszDst + 1 + iLineLen), nLenMax) + 1024;
|
||||
auto* pszRealloc = result.GetBuffer(nNewLenMax);
|
||||
if (!pszRealloc)
|
||||
{
|
||||
_ASSERTE(FALSE && "Reallocation failed");
|
||||
@ -5690,17 +5695,17 @@ wchar_t* Settings::MultiLine2MSZ(const wchar_t* apszLines, DWORD* pcbSize/*in by
|
||||
|
||||
if (pcbSize)
|
||||
*pcbSize = cbSize;
|
||||
return pszDst;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Settings::LoadMSZ(SettingsBase* reg, LPCWSTR asName, wchar_t*& rsLines, LPCWSTR asDelim /*= L"|"*/, bool bFinalToo /*= false*/)
|
||||
bool Settings::LoadMSZ(SettingsBase* reg, LPCWSTR asName, CEStr& rsLines, LPCWSTR asDelim /*= L"|"*/, bool bFinalToo /*= false*/)
|
||||
{
|
||||
wchar_t* pszMsz = nullptr; // MSZZ
|
||||
|
||||
bool bRc = reg->Load(asName, &pszMsz);
|
||||
const bool bRc = reg->Load(asName, &pszMsz);
|
||||
if (bRc && pszMsz)
|
||||
{
|
||||
SafeFree(rsLines);
|
||||
rsLines.Clear();
|
||||
rsLines = MSZ2LineDelimited(pszMsz, asDelim, bFinalToo);
|
||||
free(pszMsz);
|
||||
}
|
||||
@ -5713,11 +5718,9 @@ void Settings::SaveMSZ(SettingsBase* reg, LPCWSTR asName, LPCWSTR rsLines, LPCWS
|
||||
{
|
||||
// MSZZ
|
||||
DWORD nCbSize = 0;
|
||||
wchar_t* psMSZ = MultiLine2MSZ(rsLines, &nCbSize/*in bytes*/);
|
||||
CEStr psMSZ = MultiLine2MSZ(rsLines, &nCbSize/*in bytes*/);
|
||||
|
||||
reg->SaveMSZ(asName, psMSZ, nCbSize);
|
||||
|
||||
SafeFree(psMSZ);
|
||||
}
|
||||
|
||||
// "\0"-delimited
|
||||
@ -5726,7 +5729,7 @@ const wchar_t* Settings::GetIntelligentExceptionsMSZ()
|
||||
return pszCTSIntelligentExceptions;
|
||||
}
|
||||
// returns "|"-delimited
|
||||
wchar_t* Settings::GetIntelligentExceptions()
|
||||
CEStr Settings::GetIntelligentExceptions()
|
||||
{
|
||||
return MSZ2LineDelimited(pszCTSIntelligentExceptions);
|
||||
}
|
||||
@ -5734,7 +5737,7 @@ wchar_t* Settings::GetIntelligentExceptions()
|
||||
void Settings::SetIntelligentExceptions(const wchar_t* apszApps)
|
||||
{
|
||||
SafeFree(pszCTSIntelligentExceptions);
|
||||
pszCTSIntelligentExceptions = LineDelimited2MSZ(apszApps);
|
||||
pszCTSIntelligentExceptions = LineDelimited2MSZ(apszApps).Detach();
|
||||
}
|
||||
|
||||
|
||||
@ -5996,7 +5999,7 @@ void Settings::LoadHotkeys(SettingsBase* reg, const bool& bSendAltEnter, const b
|
||||
SafeFree(ppHK->GuiMacro);
|
||||
if (MacroVersion < GUI_MACRO_VERSION)
|
||||
{
|
||||
ppHK->GuiMacro = ConEmuMacro::ConvertMacro(pszMacro, MacroVersion, true);
|
||||
ppHK->GuiMacro = ConEmuMacro::ConvertMacro(pszMacro, MacroVersion, true).Detach();
|
||||
SafeFree(pszMacro);
|
||||
}
|
||||
else
|
||||
|
@ -218,14 +218,14 @@ struct Settings
|
||||
//reg->Load(L"AutoReloadEnvironment", AutoReloadEnvironment);
|
||||
bool AutoReloadEnvironment;
|
||||
//reg->LoadMSZ(L"EnvironmentSet", psEnvironmentSet);
|
||||
wchar_t* psEnvironmentSet; // commands: multiline, "\r\n" separated
|
||||
CEStr* psEnvironmentSet; // commands: multiline, "\r\n" separated
|
||||
|
||||
// Service functions
|
||||
wchar_t* LineDelimited2MSZ(const wchar_t* apszApps, bool bLowerCase = true); // "|"-delimited string -> MSZ
|
||||
wchar_t* MSZ2LineDelimited(const wchar_t* apszLines, LPCWSTR asDelim = L"|", bool bFinalToo = false); // MSZ -> "<asDelim>"-delimited string
|
||||
wchar_t* MultiLine2MSZ(const wchar_t* apszLines, DWORD* pcbSize/*in bytes*/); // "\r\n"-delimited string -> MSZ
|
||||
CEStr LineDelimited2MSZ(const wchar_t* apszApps, bool bLowerCase = true) const; // "|"-delimited string -> MSZ
|
||||
CEStr MSZ2LineDelimited(const wchar_t* apszLines, LPCWSTR asDelim = L"|", bool bFinalToo = false); // MSZ -> "<asDelim>"-delimited string
|
||||
CEStr MultiLine2MSZ(const wchar_t* apszLines, DWORD* pcbSize/*in bytes*/) const; // "\r\n"-delimited string -> MSZ
|
||||
|
||||
bool LoadMSZ(SettingsBase* reg, LPCWSTR asName, wchar_t*& rsLines, LPCWSTR asDelim /*= L"|"*/, bool bFinalToo /*= false*/);
|
||||
bool LoadMSZ(SettingsBase* reg, LPCWSTR asName, CEStr& rsLines, LPCWSTR asDelim /*= L"|"*/, bool bFinalToo /*= false*/);
|
||||
void SaveMSZ(SettingsBase* reg, LPCWSTR asName, LPCWSTR rsLines, LPCWSTR asDelim /*= L"|"*/, bool bLowerCase /*= true*/);
|
||||
|
||||
// Replace default terminal
|
||||
@ -237,7 +237,7 @@ struct Settings
|
||||
bool isDefaultTerminalNewWindow;
|
||||
bool isDefaultTerminalDebugLog;
|
||||
TerminalConfirmClose nDefaultTerminalConfirmClose; // "Press Enter to close console". 0 - Auto, 1 - Always, 2 - Never
|
||||
wchar_t* GetDefaultTerminalApps(); // "|" delimited
|
||||
CEStr GetDefaultTerminalApps(); // "|" delimited
|
||||
const wchar_t* GetDefaultTerminalAppsMSZ(); // "\0" delimited
|
||||
void SetDefaultTerminalApps(const wchar_t* apszApps); // "|" delimited
|
||||
private:
|
||||
@ -497,7 +497,7 @@ struct Settings
|
||||
// Default: "2013-25C4"; Example: "0410-044F;2013-25C4;"
|
||||
BYTE mpc_CharAltFontRanges[0x10000];
|
||||
int ParseCharRanges(LPCWSTR asRanges, BYTE (&Chars)[0x10000], BYTE abValue = TRUE);
|
||||
wchar_t* CreateCharRanges(BYTE (&Chars)[0x10000]); // caller must free(result)
|
||||
CEStr CreateCharRanges(BYTE (&Chars)[0x10000]); // caller must free(result)
|
||||
bool CheckCharAltFont(ucs32 inChar);
|
||||
|
||||
|
||||
@ -566,7 +566,7 @@ struct Settings
|
||||
wchar_t* pszCTSIntelligentExceptions; // Don't use IntelliSel in these app-processes
|
||||
public:
|
||||
// Service functions
|
||||
wchar_t* GetIntelligentExceptions(); // "|" delimited
|
||||
CEStr GetIntelligentExceptions(); // "|" delimited
|
||||
const wchar_t* GetIntelligentExceptionsMSZ(); // "\0" delimited
|
||||
void SetIntelligentExceptions(const wchar_t* apszApps); // "|" delimited
|
||||
//reg->Load(L"CTS.AutoCopy", isCTSAutoCopy);
|
||||
@ -1085,7 +1085,7 @@ struct Settings
|
||||
// "AnsiExecution"
|
||||
BYTE isAnsiExec; // enum AnsiExecutionPerm
|
||||
// "AnsiAllowedCommands"
|
||||
wchar_t* psAnsiAllowed; // commands: multiline, "\r\n" separated
|
||||
CEStr* psAnsiAllowed; // commands: multiline, "\r\n" separated
|
||||
|
||||
//reg->Load(L"AnsiLog", isAnsiLog);
|
||||
bool isAnsiLog; // Limited logging of console contents (same output as processed by ConEmu::ConsoleFlags::ProcessAnsi)
|
||||
@ -1168,7 +1168,7 @@ struct Settings
|
||||
void ResetSavedOnExit();
|
||||
|
||||
SettingsBase* CreateSettings(const SettingsStorage* apStorage);
|
||||
wchar_t* GetStoragePlaceDescr(const SettingsStorage* apStorage, LPCWSTR asPrefix);
|
||||
CEStr GetStoragePlaceDescr(const SettingsStorage* apStorage, LPCWSTR asPrefix);
|
||||
|
||||
SettingsStorage GetSettingsType();
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -131,7 +131,7 @@ class CSettings
|
||||
RecreateActionParm GetDefaultCreateAction();
|
||||
|
||||
SingleInstanceArgEnum SingleInstanceArg; // по умолчанию = sgl_Default, но для Quake переключается на = sgl_Enabled
|
||||
bool IsSingleInstanceArg();
|
||||
bool IsSingleInstanceArg() const;
|
||||
SingleInstanceShowHideType SingleInstanceShowHide; // по умолчанию = sih_None
|
||||
bool ResetCmdHistory(HWND hParent = nullptr);
|
||||
void SetSaveCmdHistory(bool bSaveHistory);
|
||||
@ -175,10 +175,10 @@ class CSettings
|
||||
bool PrepareBackground(CVirtualConsole* apVCon, HDC* phBgDc, COORD* pbgBmpSize);
|
||||
bool PollBackgroundFile(); // true, если файл изменен
|
||||
#else
|
||||
CBackgroundInfo* GetBackgroundObject();
|
||||
CBackgroundInfo* GetBackgroundObject() const;
|
||||
#endif
|
||||
bool LoadBackgroundFile(LPCWSTR inPath, bool abShowErrors=false);
|
||||
bool IsBackgroundEnabled(CVirtualConsole* apVCon);
|
||||
bool IsBackgroundEnabled(CVirtualConsole* apVCon) const;
|
||||
void NeedBackgroundUpdate();
|
||||
//CBackground* CreateBackgroundImage(const BITMAPFILEHEADER* apBkImgData);
|
||||
public:
|
||||
@ -269,6 +269,8 @@ class CSettings
|
||||
//
|
||||
LRESULT OnListBoxDblClk(HWND hWnd2, WPARAM wParam, LPARAM lParam);
|
||||
LRESULT OnPage(LPNMHDR phdr);
|
||||
LRESULT OnNextPage();
|
||||
LRESULT OnPrevPage();
|
||||
INT_PTR OnMeasureFontItem(HWND hWnd2, UINT messg, WPARAM wParam, LPARAM lParam);
|
||||
INT_PTR OnDrawFontItem(HWND hWnd2, UINT messg, WPARAM wParam, LPARAM lParam);
|
||||
UINT mn_ActivateTabMsg;
|
||||
@ -290,7 +292,7 @@ class CSettings
|
||||
HWND hwndTip, hwndBalloon;
|
||||
TOOLINFO tiBalloon;
|
||||
static BOOL CALLBACK RegisterTipsForChild(HWND hChild, LPARAM lParam);
|
||||
void RecreateFont(WORD wFromID);
|
||||
void RecreateFont(WORD wFromID) const;
|
||||
#if 0
|
||||
// Theming
|
||||
HMODULE mh_Uxtheme;
|
||||
|
@ -117,7 +117,7 @@ void FindStartupTask(SettingsLoadedFlags slfFlags)
|
||||
// Don't set default task, use exact command specified by user
|
||||
if ((gpSet->nStartType == 0) && !gpSet->psStartSingleApp)
|
||||
{
|
||||
gpSet->psStartSingleApp = lstrdup(pszCmdLine);
|
||||
gpSet->psStartSingleApp = lstrdup(pszCmdLine).Detach();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -145,7 +145,7 @@ void FindStartupTask(SettingsLoadedFlags slfFlags)
|
||||
{
|
||||
gpSet->nStartType = 2;
|
||||
SafeFree(gpSet->psStartTasksName);
|
||||
gpSet->psStartTasksName = lstrdup(pTask->pszName);
|
||||
gpSet->psStartTasksName = lstrdup(pTask->pszName).Detach();
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ LPCWSTR GetStartupCommand(CEStr& command)
|
||||
if (gpSet->psStartTasksFile)
|
||||
{
|
||||
wchar_t prefix[2] = {CmdFilePrefix};
|
||||
command = lstrmerge(prefix, gpSet->psStartTasksFile);
|
||||
command = CEStr(prefix, gpSet->psStartTasksFile);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
@ -587,18 +587,16 @@ static INT_PTR OnButtonClicked(HWND hDlg, UINT messg, WPARAM wParam, LPARAM lPar
|
||||
|
||||
SettingsStorage CurStorage = gpSet->GetSettingsType();
|
||||
|
||||
LRESULT lSelStorage = SendDlgItemMessage(hDlg, lbStorageLocation, CB_GETCURSEL, 0, 0);
|
||||
const LRESULT lSelStorage = SendDlgItemMessage(hDlg, lbStorageLocation, CB_GETCURSEL, 0, 0);
|
||||
if (lSelStorage > 0)
|
||||
{
|
||||
// Значит юзер выбрал "создать настройки" в другом месте
|
||||
wchar_t* pszNewPlace = GetDlgItemTextPtr(hDlg, lbStorageLocation);
|
||||
// User choses to "create settings" in the other place
|
||||
const CEStr pszNewPlace = GetDlgItemTextPtr(hDlg, lbStorageLocation);
|
||||
if (!gpConEmu->SetConfigFile(pszNewPlace, true/*abWriteReq*/, false/*abSpecialPath*/))
|
||||
{
|
||||
// Ошибка уже показана
|
||||
SafeFree(pszNewPlace);
|
||||
// error already shown
|
||||
return 1;
|
||||
}
|
||||
SafeFree(pszNewPlace);
|
||||
}
|
||||
|
||||
/* Startup task */
|
||||
@ -1005,7 +1003,7 @@ public:
|
||||
|| (f.rsOptionalFull && asOptionalFull && (lstrcmpi(f.rsOptionalFull, asOptionalFull) == 0)))
|
||||
return;
|
||||
}
|
||||
const FoundFile ff = {lstrdup(asFound), (asOptionalFull && *asOptionalFull) ? lstrdup(asOptionalFull) : nullptr};
|
||||
const FoundFile ff = {lstrdup(asFound).Detach(), (asOptionalFull && *asOptionalFull) ? lstrdup(asOptionalFull).Detach() : nullptr};
|
||||
this->push_back(ff);
|
||||
}
|
||||
};
|
||||
@ -1068,7 +1066,7 @@ static size_t FindOnDrives(LPCWSTR asFirstDrive, LPCWSTR asSearchPath, FoundFile
|
||||
return true;
|
||||
if (RegGetStringValue(hk, nullptr, i->pszValName, lsPath) > 0)
|
||||
{
|
||||
i->regFiles->push_back(JoinPath(lsPath, i->pszFile));
|
||||
i->regFiles->push_back(JoinPath(lsPath, i->pszFile).Detach());
|
||||
}
|
||||
std::ignore = pszSubkeyName;
|
||||
return true;
|
||||
@ -1101,7 +1099,7 @@ static size_t FindOnDrives(LPCWSTR asFirstDrive, LPCWSTR asSearchPath, FoundFile
|
||||
{
|
||||
if (RegGetStringValue(root, lsBuf, lsValName, lsVal, bits[b]) > 0)
|
||||
{
|
||||
regFiles.push_back(JoinPath(lsVal, pszFile));
|
||||
regFiles.push_back(JoinPath(lsVal, pszFile).Detach());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1166,7 +1164,7 @@ static size_t FindOnDrives(LPCWSTR asFirstDrive, LPCWSTR asSearchPath, FoundFile
|
||||
if (asFirstDrive && *asFirstDrive)
|
||||
{
|
||||
INT_PTR nDrvLen = _tcslen(asFirstDrive);
|
||||
rsFound.Attach(JoinPath(asFirstDrive, asSearchPath));
|
||||
rsFound = JoinPath(asFirstDrive, asSearchPath);
|
||||
if (FileExists(rsFound))
|
||||
{
|
||||
foundFiles.Add(rsFound, nullptr);
|
||||
@ -1183,7 +1181,7 @@ static size_t FindOnDrives(LPCWSTR asFirstDrive, LPCWSTR asSearchPath, FoundFile
|
||||
const UINT nType = GetDriveType(szDrive);
|
||||
if (nType != DRIVE_FIXED)
|
||||
continue;
|
||||
rsFound.Attach(JoinPath(szDrive, asSearchPath));
|
||||
rsFound = JoinPath(szDrive, asSearchPath);
|
||||
if (FileExists(rsFound))
|
||||
{
|
||||
foundFiles.Add(rsFound, nullptr);
|
||||
@ -1242,7 +1240,7 @@ public:
|
||||
pszSlash = wcsrchr(expanded.data(), L'\\');
|
||||
}
|
||||
|
||||
Store(lstrdup(szName), lstrdup(expanded));
|
||||
Store(lstrdup(szName).Detach(), lstrdup(expanded).Detach());
|
||||
|
||||
// If we want to try something like "%windir%\.."
|
||||
if ((--nBackSteps) < 0)
|
||||
@ -1316,7 +1314,8 @@ static bool UnExpandEnvStrings(LPCWSTR asSource, wchar_t* rsUnExpanded, INT_PTR
|
||||
|
||||
if (iCmp == 0)
|
||||
{
|
||||
if (!szTemp.Attach(lstrmerge(v.pszName, asSource+iCmpLen)))
|
||||
szTemp = CEStr(v.pszName, asSource + iCmpLen);
|
||||
if (!szTemp)
|
||||
return false;
|
||||
iLen = lstrlen(szTemp);
|
||||
if (iLen > cchMax)
|
||||
@ -1334,24 +1333,16 @@ class AppFoundList
|
||||
public:
|
||||
struct AppInfo
|
||||
{
|
||||
LPWSTR szFullPath, szExpanded;
|
||||
wchar_t szTaskName[64], szTaskBaseName[40];
|
||||
LPWSTR szArgs, szPrefix, szGuiArg;
|
||||
VS_FIXEDFILEINFO Ver; // bool LoadAppVersion(LPCWSTR FarPath, VS_FIXEDFILEINFO& Version, wchar_t (&ErrText)[512])
|
||||
DWORD dwSubsystem, dwBits;
|
||||
FarVersion FarVer; // ConvertVersionToFarVersion
|
||||
int iStep;
|
||||
bool bForceQuot;
|
||||
CEStr szFullPath, szExpanded;
|
||||
wchar_t szTaskName[64] = L"", szTaskBaseName[40] = L"";
|
||||
CEStr szArgs, szPrefix, szGuiArg;
|
||||
VS_FIXEDFILEINFO Ver{}; // bool LoadAppVersion(LPCWSTR FarPath, VS_FIXEDFILEINFO& Version, wchar_t (&ErrText)[512])
|
||||
DWORD dwSubsystem{ 0 }, dwBits{ 0 };
|
||||
FarVersion FarVer{}; // ConvertVersionToFarVersion
|
||||
int iStep{ 0 };
|
||||
bool bForceQuot{ false };
|
||||
bool isNeedQuot() const { return bForceQuot || IsQuotationNeeded(szFullPath); };
|
||||
bool bPrimary; // Do not rename this task while unifying
|
||||
void Free()
|
||||
{
|
||||
SafeFree(szFullPath);
|
||||
SafeFree(szExpanded);
|
||||
SafeFree(szArgs);
|
||||
SafeFree(szPrefix);
|
||||
SafeFree(szGuiArg);
|
||||
};
|
||||
bool bPrimary{ false }; // Do not rename this task while unifying
|
||||
};
|
||||
MArray<AppInfo> Installed;
|
||||
|
||||
@ -1389,8 +1380,7 @@ protected:
|
||||
else if (pszOptFull && (lstrcmpi(ai.szFullPath, pszOptFull) == 0))
|
||||
{
|
||||
// Store path with environment variables (unexpanded) or without path at all (just "Far.exe" for example)
|
||||
SafeFree(ai.szFullPath);
|
||||
ai.szFullPath = lstrdup(szPath);
|
||||
ai.szFullPath.Set(szPath);
|
||||
path_match = true;
|
||||
}
|
||||
else if (pszOptFull && ai.szExpanded && (lstrcmpi(ai.szExpanded, pszOptFull) == 0))
|
||||
@ -1427,12 +1417,6 @@ protected:
|
||||
|
||||
void Clean()
|
||||
{
|
||||
for (INT_PTR i = 0; i < Installed.size(); i++)
|
||||
{
|
||||
AppInfo& FI = Installed[i];
|
||||
FI.Free();
|
||||
}
|
||||
|
||||
Installed.clear();
|
||||
}
|
||||
|
||||
@ -1711,7 +1695,7 @@ public:
|
||||
}
|
||||
|
||||
CEStr szTemp(JoinPath(szPath, pszTail));
|
||||
szArgs.Attach(lstrmerge(szArgs.ms_Val, szTemp));
|
||||
szArgs.Append(szTemp);
|
||||
}
|
||||
}
|
||||
// Succeeded?
|
||||
@ -1723,9 +1707,9 @@ public:
|
||||
|
||||
// Spaces in path? (use expanded path)
|
||||
if (ai.isNeedQuot())
|
||||
szFull = lstrmerge(ai.szPrefix, L"\"", ai.szFullPath, L"\"", pszArgs);
|
||||
szFull = CEStr(ai.szPrefix, L"\"", ai.szFullPath, L"\"", pszArgs);
|
||||
else
|
||||
szFull = lstrmerge(ai.szPrefix, ai.szFullPath, pszArgs);
|
||||
szFull = CEStr(ai.szPrefix, ai.szFullPath, pszArgs);
|
||||
|
||||
// Create task
|
||||
if (!szFull.IsEmpty())
|
||||
@ -1983,7 +1967,7 @@ static void CreateFarTasks()
|
||||
{
|
||||
FarVerList::AppInfo& FI = Vers.Installed[i];
|
||||
bool bNeedQuot = (wcschr(FI.szFullPath, L' ') != nullptr);
|
||||
LPWSTR pszFullPath = FI.szFullPath;
|
||||
const wchar_t* pszFullPath = FI.szFullPath.c_str();
|
||||
wchar_t szUnexpanded[MAX_PATH];
|
||||
if (wcschr(pszFullPath, L'\\') && UnExpandEnvStrings(pszFullPath, szUnexpanded, countof(szUnexpanded)))
|
||||
pszFullPath = szUnexpanded;
|
||||
@ -1993,12 +1977,12 @@ static void CreateFarTasks()
|
||||
// it will get already expanded command line which may have erroneous path.
|
||||
// That's very bad when running x64 Far, but %FARHOME% points to x86 Far.
|
||||
// And don't preset FARHOME variable, it makes harder to find Tab icon.
|
||||
wchar_t* pszCommand = lstrmerge(L"set \"FARHOME=\" & \"", pszFullPath, L"\"");
|
||||
CEStr pszCommand(L"set \"FARHOME=\" & \"", pszFullPath, L"\"");
|
||||
|
||||
if (pszCommand)
|
||||
{
|
||||
if (FI.FarVer.dwVerMajor >= 2)
|
||||
lstrmerge(&pszCommand, L" /w");
|
||||
pszCommand.Append(L" /w");
|
||||
|
||||
// Don't duplicate plugin folders (ConEmu) to avoid doubled lines in F11 (Far 1.x and Far 2.x problem)
|
||||
bool bDontDuplicate = false;
|
||||
@ -2022,7 +2006,7 @@ static void CreateFarTasks()
|
||||
|
||||
// Force Far to use proper plugins folders
|
||||
if (!bDontDuplicate)
|
||||
lstrmerge(&pszCommand, L" /p\"%ConEmuDir%\\Plugins\\ConEmu;%FARHOME%\\Plugins;%FARPROFILE%\\Plugins\"");
|
||||
pszCommand.Append(L" /p\"%ConEmuDir%\\Plugins\\ConEmu;%FARHOME%\\Plugins;%FARPROFILE%\\Plugins\"");
|
||||
|
||||
|
||||
// Suggest this task as ConEmu startup default
|
||||
@ -2031,10 +2015,6 @@ static void CreateFarTasks()
|
||||
|
||||
CreateDefaultTask(FI.szTaskName, nullptr, pszCommand);
|
||||
}
|
||||
|
||||
// Release memory
|
||||
SafeFree(FI.szFullPath);
|
||||
SafeFree(pszCommand);
|
||||
}
|
||||
Vers.Installed.clear();
|
||||
}
|
||||
@ -2140,17 +2120,17 @@ static void CreateVCTask(AppFoundList& App, LPCWSTR pszPlatform, LPCWSTR pszVer,
|
||||
case 0:
|
||||
if (!pszPlatform)
|
||||
continue;
|
||||
pszVcVarsBat.Attach(JoinPath(pszDir, L"vcvarsall.bat"));
|
||||
pszVcVarsBat = JoinPath(pszDir, L"vcvarsall.bat");
|
||||
break;
|
||||
case 1:
|
||||
if (!pszPlatform)
|
||||
continue;
|
||||
pszVcVarsBat.Attach(JoinPath(pszDir, L"VC\\Auxiliary\\Build\\vcvarsall.bat"));
|
||||
pszVcVarsBat = JoinPath(pszDir, L"VC\\Auxiliary\\Build\\vcvarsall.bat");
|
||||
break;
|
||||
case 2:
|
||||
if (pszPlatform)
|
||||
continue;
|
||||
pszVcVarsBat.Attach(JoinPath(pszDir, L"Common7\\Tools\\VsDevCmd.bat"));
|
||||
pszVcVarsBat = JoinPath(pszDir, L"Common7\\Tools\\VsDevCmd.bat");
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
@ -2193,7 +2173,7 @@ static void CreateVCTask(AppFoundList& App, LPCWSTR pszPlatform, LPCWSTR pszVer,
|
||||
case 9: pszIconSfx = L",10\""; break;
|
||||
default: pszIconSfx = L"\"";
|
||||
}
|
||||
lstrmerge(&pszSuffix.ms_Val, L" -new_console:C:\"", pszIconSource, pszIconSfx);
|
||||
pszSuffix.Append(L" -new_console:C:\"", pszIconSource, pszIconSfx);
|
||||
}
|
||||
|
||||
const CEStr pszName(L"SDK::VS ", pszVer, pszPlatform ? L" " : nullptr, pszPlatform, L" tools prompt");
|
||||
@ -2449,7 +2429,7 @@ static void CreateBashTask()
|
||||
CEStr lsPath(ExpandEnvStr(iconFile));
|
||||
if (FileExists(lsPath))
|
||||
{
|
||||
wslIcon.Attach(lstrmerge(L"-icon \"", iconFile, L"\""));
|
||||
wslIcon = CEStr(L"-icon \"", iconFile, L"\"");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2542,7 +2522,7 @@ static void CreateBashTask()
|
||||
else
|
||||
continue;
|
||||
|
||||
SafeFree(ai.szGuiArg);
|
||||
ai.szGuiArg.Release();
|
||||
|
||||
if (szConnectorName)
|
||||
{
|
||||
@ -2559,7 +2539,7 @@ static void CreateBashTask()
|
||||
|
||||
if (!msysGit2)
|
||||
{
|
||||
lstrmerge(&ai.szPrefix,
|
||||
ai.szPrefix.Append(
|
||||
// TODO: Optimize: Don't add PATH if required cygwin1.dll/msys2.dll is already on path
|
||||
L"set \"PATH=", szBinPath, L";%PATH%\" & ",
|
||||
// Change main executable
|
||||
@ -2574,12 +2554,12 @@ static void CreateBashTask()
|
||||
{
|
||||
_ASSERTE(ai.szArgs && wcsstr(ai.szArgs, L"--command=/usr/bin/bash.exe"));
|
||||
const wchar_t* cmdPtr = L"--command=";
|
||||
wchar_t* pszCmd = wcsstr(ai.szArgs, cmdPtr);
|
||||
wchar_t* pszCmd = wcsstr(ai.szArgs.data(), cmdPtr);
|
||||
if (pszCmd)
|
||||
{
|
||||
pszCmd += wcslen(cmdPtr);
|
||||
_ASSERTE(ai.szPrefix == nullptr || !*ai.szPrefix);
|
||||
lstrmerge(&ai.szPrefix,
|
||||
ai.szPrefix.Append(
|
||||
// TODO: Optimize: Don't add PATH if required cygwin1.dll/msys2.dll is already on path
|
||||
L"set \"PATH=", szBinPath, L"\\usr\\bin;%PATH%\" & ");
|
||||
// Insert connector between "--command=" and "/usr/bin/bash.exe"
|
||||
@ -2593,11 +2573,10 @@ static void CreateBashTask()
|
||||
L"%ConEmuBaseDirShort%\\", szConnectorName,
|
||||
/*bNeedQuot ? L"\" " :*/ L" ",
|
||||
// And the tail of the command: "/usr/bin/bash.exe -l -i"
|
||||
L"/", pszCmd+1,
|
||||
L"/", pszCmd + 1,
|
||||
// Force xterm mode
|
||||
L" -new_console:p");
|
||||
SafeFree(ai.szArgs);
|
||||
ai.szArgs = lsArgs.Detach();
|
||||
ai.szArgs = std::move(lsArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -105,23 +105,17 @@ bool CEHelpPopup::OpenSettingsWiki(HWND hDlg, WORD nCtrlId)
|
||||
wchar_t szId[20];
|
||||
msprintf(szId, countof(szId), L"#id%i", nCtrlId);
|
||||
|
||||
//if (nCtrlId == tCmdGroupCommands)
|
||||
//{
|
||||
// // Some controls are processed personally
|
||||
// lsUrl.Attach(lstrmerge(CEWIKIBASE, L"NewConsole.html", szId));
|
||||
//}
|
||||
//else
|
||||
if (hDlg == ghOpWnd)
|
||||
{
|
||||
lsUrl.Attach(lstrmerge(CEWIKIBASE, L"Settings.html", szId));
|
||||
lsUrl = CEStr(CEWIKIBASE, L"Settings.html", szId);
|
||||
}
|
||||
else if (hDlg == FastConfig::ghFastCfg)
|
||||
{
|
||||
lsUrl.Attach(lstrmerge(CEWIKIBASE, L"SettingsFast.html", szId));
|
||||
lsUrl = CEStr(CEWIKIBASE, L"SettingsFast.html", szId);
|
||||
}
|
||||
else if (gpSetCls->GetActivePageWiki(lsUrl))
|
||||
{
|
||||
lstrmerge(&lsUrl.ms_Val, szId);
|
||||
lsUrl.Append(szId);
|
||||
}
|
||||
|
||||
if (lsUrl.IsEmpty())
|
||||
|
@ -2365,10 +2365,9 @@ bool CRealBuffer::ApplyConsoleInfo()
|
||||
{
|
||||
wchar_t szInfo[128];
|
||||
swprintf_c(szInfo, L"mp_RCon->m_GetDataPipe.Transact failed, code=%i\r\n", (int)mp_RCon->m_GetDataPipe.GetErrorCode());
|
||||
wchar_t* pszFull = lstrmerge(szInfo, mp_RCon->m_GetDataPipe.GetErrorText());
|
||||
const CEStr pszFull(szInfo, mp_RCon->m_GetDataPipe.GetErrorText());
|
||||
//MBoxA(pszFull);
|
||||
LogString(pszFull);
|
||||
SafeFree(pszFull);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -3125,11 +3124,10 @@ bool CRealBuffer::ProcessFarHyperlink(UINT messg, COORD crFrom, bool bUpdateScre
|
||||
//_ASSERTE(pszWinPath!=nullptr); // must not be here!
|
||||
//pszWinPath = cmd.szFile; -- file not found, do not open absent files!
|
||||
CEStr szDir;
|
||||
wchar_t* pszErrMsg = lstrmerge(L"File '", cmd.szFile, L"' not found!\nDirectory: ", mp_RCon->GetConsoleCurDir(szDir, false));
|
||||
const CEStr pszErrMsg(L"File '", cmd.szFile, L"' not found!\nDirectory: ", mp_RCon->GetConsoleCurDir(szDir, false));
|
||||
if (pszErrMsg)
|
||||
{
|
||||
MsgBox(pszErrMsg, MB_ICONSTOP);
|
||||
free(pszErrMsg);
|
||||
}
|
||||
}
|
||||
else if (bUseExtEditor || !CVConGroup::isFarExist(fwt_NonModal|fwt_PluginRequired, nullptr, &VCon))
|
||||
@ -3142,11 +3140,11 @@ bool CRealBuffer::ProcessFarHyperlink(UINT messg, COORD crFrom, bool bUpdateScre
|
||||
//LPCWSTR pszVar[] = {L"%1", L"%2", L"%3", ...};
|
||||
//%3’ - C:\\Path\\File, ‘%4’ - C:/Path/File, ‘%5’ - /C/Path/File
|
||||
|
||||
CEStr szSlashed; szSlashed.Attach(MakeStraightSlashPath(pszWinPath));
|
||||
CEStr szSlashed(MakeStraightSlashPath(pszWinPath));
|
||||
CEStr szCygwin; DupCygwinPath(pszWinPath, false, mp_RCon->GetMntPrefix(), szCygwin);
|
||||
LPCWSTR pszVal[] = {szRow, szCol, pszWinPath, (LPCWSTR)szSlashed, (LPCWSTR)szCygwin};
|
||||
//_ASSERTE(countof(pszVar)==countof(pszVal));
|
||||
wchar_t* pszCmd = ExpandMacroValues(gpSet->sFarGotoEditor, pszVal, countof(pszVal));
|
||||
CEStr pszCmd = ExpandMacroValues(gpSet->sFarGotoEditor, pszVal, countof(pszVal));
|
||||
if (!pszCmd)
|
||||
{
|
||||
DisplayLastError(L"Invalid command specified in \"External editor\"", -1);
|
||||
@ -3157,16 +3155,16 @@ bool CRealBuffer::ProcessFarHyperlink(UINT messg, COORD crFrom, bool bUpdateScre
|
||||
bool bRunOutside = (pszCmd[0] == L'#');
|
||||
if (bRunOutside)
|
||||
{
|
||||
args.pszSpecialCmd = lstrdup(pszCmd+1);
|
||||
SafeFree(pszCmd);
|
||||
args.pszSpecialCmd = lstrdup(pszCmd.c_str() + 1).Detach();
|
||||
pszCmd.Release();
|
||||
}
|
||||
else
|
||||
{
|
||||
args.pszSpecialCmd = pszCmd; pszCmd = nullptr;
|
||||
args.pszSpecialCmd = pszCmd.Detach();
|
||||
}
|
||||
|
||||
WARNING("Здесь нужно бы попытаться взять текущую директорию из шелла. Точнее, из консоли НА МОМЕНТ выдачи этой строки.");
|
||||
args.pszStartupDir = mp_RCon->m_Args.pszStartupDir ? lstrdup(mp_RCon->m_Args.pszStartupDir) : nullptr;
|
||||
args.pszStartupDir = CEStr(mp_RCon->m_Args.pszStartupDir).Detach();
|
||||
args.RunAsAdministrator = mp_RCon->m_Args.RunAsAdministrator;
|
||||
args.ForceUserDialog = (
|
||||
(mp_RCon->m_Args.ForceUserDialog == crb_On)
|
||||
@ -3186,11 +3184,11 @@ bool CRealBuffer::ProcessFarHyperlink(UINT messg, COORD crFrom, bool bUpdateScre
|
||||
{
|
||||
if (SearchAppPaths(szExe.c_str(), szExe, true, &szPrevPath))
|
||||
{
|
||||
wchar_t* pszChanged = MergeCmdLine(szExe, pszTemp);
|
||||
CEStr pszChanged(MergeCmdLine(szExe, pszTemp));
|
||||
if (pszChanged)
|
||||
{
|
||||
SafeFree(args.pszSpecialCmd);
|
||||
args.pszSpecialCmd = pszChanged;
|
||||
args.pszSpecialCmd = pszChanged.Detach();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5518,9 +5516,8 @@ bool CRealBuffer::DoSelectionCopyInt(CECopyMode CopyMode, bool bStreamMode, int
|
||||
GlobalFree(hUnicode);
|
||||
if (iWriteRc < 0)
|
||||
{
|
||||
wchar_t* pszErr = lstrmerge(L"Failed to create file\n", pszDstFile);
|
||||
const CEStr pszErr(L"Failed to create file\n", pszDstFile);
|
||||
DisplayLastError(pszErr, nErrCode);
|
||||
SafeFree(pszErr);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -556,15 +556,6 @@ CRealConsole::~CRealConsole()
|
||||
|
||||
SafeDelete(mpcs_CurWorkDir);
|
||||
|
||||
SafeFree(mpsz_PostCreateMacro);
|
||||
|
||||
//SafeFree(mpsz_CmdBuffer);
|
||||
|
||||
//if (mp_Rgn)
|
||||
//{
|
||||
// delete mp_Rgn;
|
||||
// mp_Rgn = nullptr;
|
||||
//}
|
||||
SafeCloseHandle(mh_UpdateServerActiveEvent);
|
||||
SafeCloseHandle(mh_MonitorThreadEvent);
|
||||
SafeDelete(mp_Files);
|
||||
@ -1273,7 +1264,7 @@ bool CRealConsole::AttachConemuC(HWND ahConWnd, DWORD anConemuC_PID, const CESER
|
||||
{
|
||||
SafeFree(m_Args.pszSpecialCmd);
|
||||
_ASSERTE(m_Args.Detached == crb_On);
|
||||
m_Args.pszSpecialCmd = lstrdup(rStartStop->sCmdLine);
|
||||
m_Args.pszSpecialCmd = lstrdup(rStartStop->sCmdLine).Detach();
|
||||
}
|
||||
|
||||
_ASSERTE(hProcess==nullptr || (mp_sei && mp_sei->hProcess));
|
||||
@ -1410,7 +1401,7 @@ void CRealConsole::SetInitEnvCommands(CESERVER_REQ_SRVSTARTSTOPRET& pRet)
|
||||
|
||||
if (gpSet->psEnvironmentSet)
|
||||
{
|
||||
env.AddLines(gpSet->psEnvironmentSet, true);
|
||||
env.AddLines(gpSet->psEnvironmentSet->c_str(), true);
|
||||
}
|
||||
|
||||
size_t cchData = 0;
|
||||
@ -1433,7 +1424,7 @@ void CRealConsole::SetInitEnvCommands(CESERVER_REQ_SRVSTARTSTOPRET& pRet)
|
||||
}
|
||||
if (pszPalette && *pszPalette)
|
||||
{
|
||||
pRet.PaletteName.Set(lstrdup(pszPalette), wcslen(pszPalette)+1);
|
||||
pRet.PaletteName.Set(lstrdup(pszPalette).Detach());
|
||||
}
|
||||
|
||||
if (pPal)
|
||||
@ -1452,7 +1443,7 @@ void CRealConsole::SetInitEnvCommands(CESERVER_REQ_SRVSTARTSTOPRET& pRet)
|
||||
_ASSERTE(pRet.TaskName.psz == nullptr);
|
||||
if (m_Args.pszTaskName && *m_Args.pszTaskName)
|
||||
{
|
||||
pRet.TaskName.Set(lstrdup(m_Args.pszTaskName), wcslen(m_Args.pszTaskName)+1);
|
||||
pRet.TaskName.Set(lstrdup(m_Args.pszTaskName).Detach());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1468,7 +1459,7 @@ void CRealConsole::PasteExplorerPath(bool bDoCd /*= true*/, bool bSetFocus /*= t
|
||||
{
|
||||
AssertThis();
|
||||
|
||||
wchar_t* pszPath = getFocusedExplorerWindowPath();
|
||||
CEStr pszPath = getFocusedExplorerWindowPath();
|
||||
|
||||
if (pszPath)
|
||||
{
|
||||
@ -1482,8 +1473,6 @@ void CRealConsole::PasteExplorerPath(bool bDoCd /*= true*/, bool bSetFocus /*= t
|
||||
if (!mp_ConEmu->isMeForeground())
|
||||
mp_ConEmu->DoMinimizeRestore(sih_SetForeground);
|
||||
}
|
||||
|
||||
free(pszPath);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4085,8 +4074,8 @@ bool CRealConsole::StartDebugger(StartDebugType sdt)
|
||||
}
|
||||
for (int i = 0; i < nCount; i++)
|
||||
{
|
||||
lstrmerge(&lsPID.ms_Val, lsPID.ms_Val ? L"," : nullptr, ultow_s(pPrc[i].ProcessID, szExe, 10));
|
||||
if (lstrlen(lsPID.ms_Val) > MAX_PATH)
|
||||
lsPID = CEStr(lsPID.ms_Val ? L"," : nullptr, ultow_s(pPrc[i].ProcessID, szExe, 10));
|
||||
if (lsPID.GetLen() > MAX_PATH)
|
||||
break;
|
||||
}
|
||||
swprintf_c(szExe, L"\"%s\" /DEBUGPID=%s /DUMP", pszServer, lsPID.ms_Val);
|
||||
@ -4137,7 +4126,7 @@ bool CRealConsole::StartDebugger(StartDebugType sdt)
|
||||
|| (((sdt != sdt_DumpMemory) && (sdt != sdt_DumpMemoryTree)) && bShowStartDlg)
|
||||
)
|
||||
{
|
||||
Args.pszSpecialCmd = lstrdup(szExe);
|
||||
Args.pszSpecialCmd = lstrdup(szExe).Detach();
|
||||
Args.nSplitValue = 700;
|
||||
|
||||
int nRc = mp_ConEmu->RecreateDlg(&Args, true);
|
||||
@ -4935,7 +4924,7 @@ bool CRealConsole::CreateOrRunAs(CRealConsole* pRCon, RConStartArgsEx& Args,
|
||||
// When starting under another credentials - try to use %USERPROFILE% instead of "system32"
|
||||
HRESULT hr = E_FAIL;
|
||||
wchar_t szUserDir[MAX_PATH] = L"";
|
||||
wchar_t* pszChangedCmd = nullptr;
|
||||
CEStr pszChangedCmd;
|
||||
// Issue 1557: switch -new_console:u:"other_user:password" lock the account of other_user
|
||||
if (!lpszWorkDir || !*lpszWorkDir)
|
||||
{
|
||||
@ -4948,11 +4937,11 @@ bool CRealConsole::CreateOrRunAs(CRealConsole* pRCon, RConStartArgsEx& Args,
|
||||
CmdArg exe;
|
||||
LPCWSTR pszTemp = psCurCmd;
|
||||
if ((pszTemp = NextArg(pszTemp, exe)))
|
||||
pszChangedCmd = lstrmerge(exe, L" /PROFILECD ", pszTemp);
|
||||
pszChangedCmd = CEStr(exe, L" /PROFILECD ", pszTemp);
|
||||
}
|
||||
DWORD nFlags = (Args.RunAsNetOnly == crb_On) ? LOGON_NETCREDENTIALS_ONLY : LOGON_WITH_PROFILE;
|
||||
lbRc = (CreateProcessWithLogonW(Args.pszUserName, Args.pszDomain, Args.szUserPassword,
|
||||
nFlags, nullptr, pszChangedCmd ? pszChangedCmd : psCurCmd,
|
||||
nFlags, nullptr, pszChangedCmd ? pszChangedCmd.data() : psCurCmd,
|
||||
NORMAL_PRIORITY_CLASS|CREATE_DEFAULT_ERROR_MODE
|
||||
|(bConsoleProcess ? CREATE_NEW_CONSOLE : 0)
|
||||
, nullptr, lpszWorkDir, &si, &pi) != FALSE);
|
||||
@ -4963,7 +4952,6 @@ bool CRealConsole::CreateOrRunAs(CRealConsole* pRCon, RConStartArgsEx& Args,
|
||||
dwLastError = GetLastError();
|
||||
|
||||
SecureZeroMemory(Args.szUserPassword, sizeof(Args.szUserPassword));
|
||||
SafeFree(pszChangedCmd);
|
||||
}
|
||||
else if (Args.RunAsRestricted == crb_On)
|
||||
{
|
||||
@ -5635,15 +5623,15 @@ void CRealConsole::OnSelectionChanged()
|
||||
if (sel.dwFlags & CONSOLE_MOUSE_SELECTION)
|
||||
m_Mouse.bWasMouseSelection = true;
|
||||
|
||||
bool bStreamMode = ((sel.dwFlags & CONSOLE_TEXT_SELECTION) != 0);
|
||||
int nCellsCount = mp_ABuf->GetSelectionCellsCount();
|
||||
const bool bStreamMode = ((sel.dwFlags & CONSOLE_TEXT_SELECTION) != 0);
|
||||
const int nCellsCount = mp_ABuf->GetSelectionCellsCount();
|
||||
|
||||
wchar_t szCoords[128] = L"", szChars[20];
|
||||
swprintf_c(szCoords, L"{%i,%i}-{%i,%i}:{%i,%i}",
|
||||
sel.srSelection.Left+1, sel.srSelection.Top+1,
|
||||
sel.srSelection.Right+1, sel.srSelection.Bottom+1,
|
||||
sel.dwSelectionAnchor.X+1, sel.dwSelectionAnchor.Y+1);
|
||||
szSelInfo = lstrmerge(
|
||||
szSelInfo = CEStr(
|
||||
ltow_s(nCellsCount, szChars, 10),
|
||||
CLngRc::getRsrc(lng_SelChars/*" chars "*/),
|
||||
szCoords,
|
||||
@ -5737,7 +5725,7 @@ void CRealConsole::DoFindText(int nDirection)
|
||||
}
|
||||
if (mp_ABuf)
|
||||
{
|
||||
mp_ABuf->MarkFindText(nDirection, gpSet->FindOptions.pszText, gpSet->FindOptions.bMatchCase, gpSet->FindOptions.bMatchWholeWords);
|
||||
mp_ABuf->MarkFindText(nDirection, gpSet->FindOptions.text, gpSet->FindOptions.bMatchCase, gpSet->FindOptions.bMatchWholeWords);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6100,7 +6088,7 @@ void CRealConsole::StopSignal()
|
||||
CConEmuChild::ProcessVConClosed(mp_VCon);
|
||||
|
||||
// Clear some vars
|
||||
SafeFree(mpsz_PostCreateMacro);
|
||||
mpsz_PostCreateMacro.Release();
|
||||
}
|
||||
}
|
||||
|
||||
@ -8200,11 +8188,11 @@ LPCWSTR CRealConsole::GetActiveProcessInfo(CEStr& rsInfo)
|
||||
m_RootInfo.nPID,
|
||||
CLngRc::getRsrc(lng_ExitCode/*"exit code"*/),
|
||||
m_RootInfo.nExitCode);
|
||||
rsInfo = lstrmerge(ms_RootProcessName, szExitInfo);
|
||||
rsInfo = CEStr(ms_RootProcessName, szExitInfo);
|
||||
}
|
||||
else if ((m_StartState < rss_ProcessActive) && ms_RootProcessName[0])
|
||||
{
|
||||
rsInfo = lstrmerge(L"Starting: ", ms_RootProcessName);
|
||||
rsInfo = CEStr(L"Starting: ", ms_RootProcessName);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -8526,7 +8514,7 @@ int CRealConsole::GetDefaultAppSettingsId()
|
||||
if (wcschr(pszName, L'.') == nullptr)
|
||||
{
|
||||
// If extension was not defined, assume it's an .exe
|
||||
szExe.Attach(lstrmerge(szExe.c_str(), L".exe"));
|
||||
szExe = CEStr(szExe.c_str(), L".exe");
|
||||
pszName = PointToName(szExe);
|
||||
}
|
||||
|
||||
@ -9903,15 +9891,15 @@ bool CRealConsole::RecreateProcess(RConStartArgsEx *args)
|
||||
if (mp_ConEmu->IsConsoleBatchOrTask(args->pszSpecialCmd))
|
||||
{
|
||||
// Load Task contents
|
||||
wchar_t* pszTaskCommands = mp_ConEmu->LoadConsoleBatch(args->pszSpecialCmd, args);
|
||||
if (!pszTaskCommands || !*pszTaskCommands)
|
||||
CEStr pszTaskCommands = mp_ConEmu->LoadConsoleBatch(args->pszSpecialCmd, args);
|
||||
if (pszTaskCommands.IsEmpty())
|
||||
{
|
||||
CEStr lsMsg(L"Can't load task contents!\n", args->pszSpecialCmd);
|
||||
MsgBox(lsMsg, MB_ICONSTOP);
|
||||
return false;
|
||||
}
|
||||
// Only one command can started in a console
|
||||
wchar_t* pszBreak = (wchar_t*)wcspbrk(pszTaskCommands, L"\r\n");
|
||||
wchar_t* pszBreak = wcspbrk(pszTaskCommands.data(), L"\r\n");
|
||||
if (pszBreak)
|
||||
{
|
||||
CEStr lsMsg(L"Task ", args->pszSpecialCmd, L" contains more than a command.\n" L"Only first will be executed.");
|
||||
@ -9922,7 +9910,7 @@ bool CRealConsole::RecreateProcess(RConStartArgsEx *args)
|
||||
}
|
||||
// Run contents but not a "task"
|
||||
SafeFree(args->pszSpecialCmd);
|
||||
args->pszSpecialCmd = pszTaskCommands;
|
||||
args->pszSpecialCmd = pszTaskCommands.Detach();
|
||||
}
|
||||
}
|
||||
|
||||
@ -9934,9 +9922,8 @@ bool CRealConsole::RecreateProcess(RConStartArgsEx *args)
|
||||
wchar_t szPrefix[128];
|
||||
swprintf_c(szPrefix, L"CRealConsole::RecreateProcess, hView=x%08X, Detached=%u, AsAdmin=%u, Cmd=",
|
||||
LODWORD(mp_VCon->GetView()), static_cast<UINT>(args->Detached), static_cast<UINT>(args->RunAsAdministrator));
|
||||
wchar_t* pszInfo = lstrmerge(szPrefix, args->pszSpecialCmd ? args->pszSpecialCmd : L"<nullptr>");
|
||||
LogString(pszInfo ? pszInfo : szPrefix);
|
||||
SafeFree(pszInfo);
|
||||
const CEStr pszInfo(szPrefix, args->pszSpecialCmd ? args->pszSpecialCmd : L"<nullptr>");
|
||||
LogString(pszInfo.c_str(szPrefix));
|
||||
}
|
||||
|
||||
const bool bCopied = m_Args.AssignFrom(*args, true);
|
||||
@ -11093,9 +11080,8 @@ INT_PTR CRealConsole::renameProc(HWND hDlg, UINT messg, WPARAM wParam, LPARAM lP
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
wchar_t* pszNew = GetDlgItemTextPtr(hDlg, tNewTabName);
|
||||
const CEStr pszNew = GetDlgItemTextPtr(hDlg, tNewTabName);
|
||||
pRCon->RenameTab(pszNew);
|
||||
SafeFree(pszNew);
|
||||
EndDialog(hDlg, IDOK);
|
||||
return TRUE;
|
||||
}
|
||||
@ -11195,7 +11181,7 @@ bool CRealConsole::DuplicateRoot(bool bSkipMsg /*= false*/, bool bRunAsAdmin /*=
|
||||
else
|
||||
{
|
||||
CEStr szWorkDir; GetConsoleCurDir(szWorkDir, true);
|
||||
CEStr szConfirm(L"Do you want to duplicate tab with root?\n",
|
||||
const CEStr szConfirm(L"Do you want to duplicate tab with root?\n",
|
||||
L"Process: ", p->Name, L"\n",
|
||||
L"Directory: ", szWorkDir);
|
||||
if (bSkipMsg || !gpSet->isMultiDupConfirm
|
||||
@ -11211,21 +11197,21 @@ bool CRealConsole::DuplicateRoot(bool bSkipMsg /*= false*/, bool bRunAsAdmin /*=
|
||||
bRootCmdRedefined = true;
|
||||
SafeFree(args.pszSpecialCmd);
|
||||
if (asParm)
|
||||
args.pszSpecialCmd = lstrmerge(asApp, L" ", asParm);
|
||||
args.pszSpecialCmd = CEStr(asApp, L" ", asParm).Detach();
|
||||
else
|
||||
args.pszSpecialCmd = lstrdup(asApp);
|
||||
args.pszSpecialCmd = CEStr(asApp).Detach();
|
||||
}
|
||||
else if (asParm && *asParm)
|
||||
{
|
||||
bRootCmdRedefined = true;
|
||||
lstrmerge(&args.pszSpecialCmd, L" ", asParm);
|
||||
CEStr(args.pszSpecialCmd, L" ", asParm).Swap(args.pszSpecialCmd);
|
||||
}
|
||||
|
||||
|
||||
if (asNewConsole && *asNewConsole)
|
||||
{
|
||||
lstrmerge(&args.pszSpecialCmd, L" ", asNewConsole);
|
||||
bRootCmdRedefined = true;
|
||||
CEStr(args.pszSpecialCmd, L" ", asNewConsole).Swap(args.pszSpecialCmd);
|
||||
}
|
||||
|
||||
// Нужно оставить там "new_console", иначе не отключается подтверждение закрытия например
|
||||
@ -11233,7 +11219,7 @@ bool CRealConsole::DuplicateRoot(bool bSkipMsg /*= false*/, bool bRunAsAdmin /*=
|
||||
|
||||
// Explicitly load "detected" working directory
|
||||
SafeFree(args.pszStartupDir);
|
||||
args.pszStartupDir = lstrdup(szWorkDir);
|
||||
args.pszStartupDir = lstrdup(szWorkDir).Detach();
|
||||
|
||||
// Mark as detached, because the new console will be started from active shell process,
|
||||
// but not from ConEmu (yet, behavior planned to be changed)
|
||||
@ -12260,7 +12246,7 @@ void CRealConsole::Paste(CEPasteMode PasteMode /*= pm_Standard*/, LPCWSTR asText
|
||||
|
||||
if (MyOpenClipboard(L"GetClipboard"))
|
||||
{
|
||||
buffer = GetCliboardText(nErrCode, szErr, countof(szErr));
|
||||
buffer = GetClipboardText(nErrCode, szErr, countof(szErr));
|
||||
MyCloseClipboard();
|
||||
}
|
||||
|
||||
@ -12374,7 +12360,7 @@ void CRealConsole::Paste(CEPasteMode PasteMode /*= pm_Standard*/, LPCWSTR asText
|
||||
|
||||
if (nBufLen && m_Term.bBracketedPaste)
|
||||
{
|
||||
CEStr bracketedText = lstrmerge(L"\x1B[200~", buffer.c_str(), L"\x1B[201~");
|
||||
CEStr bracketedText(L"\x1B[200~", buffer.c_str(), L"\x1B[201~");
|
||||
if (bracketedText.IsEmpty())
|
||||
{
|
||||
_ASSERTE(bracketedText.IsEmpty());
|
||||
@ -13537,12 +13523,8 @@ const RConStartArgsEx& CRealConsole::GetArgs()
|
||||
|
||||
void CRealConsole::SetPaletteName(LPCWSTR asPaletteName)
|
||||
{
|
||||
wchar_t* pszOld = m_Args.pszPalette;
|
||||
wchar_t* pszNew = nullptr;
|
||||
if (asPaletteName && *asPaletteName)
|
||||
pszNew = lstrdup(asPaletteName);
|
||||
m_Args.pszPalette = pszNew;
|
||||
SafeFree(pszOld);
|
||||
CEStr pszNew(asPaletteName);
|
||||
pszNew.Swap(m_Args.pszPalette);
|
||||
_ASSERTE(!mp_VCon->m_SelfPalette.bPredefined);
|
||||
PrepareDefaultColors();
|
||||
}
|
||||
@ -13559,7 +13541,7 @@ LPCWSTR CRealConsole::GetCmd(bool bThisOnly /*= false*/)
|
||||
return L"";
|
||||
}
|
||||
|
||||
wchar_t* CRealConsole::CreateCommandLine(const bool abForTasks /*= false*/)
|
||||
CEStr CRealConsole::CreateCommandLine(const bool abForTasks /*= false*/)
|
||||
{
|
||||
AssertThisRet(nullptr);
|
||||
|
||||
@ -13576,11 +13558,11 @@ wchar_t* CRealConsole::CreateCommandLine(const bool abForTasks /*= false*/)
|
||||
const auto* pszRenamed = tab->Renamed.Ptr();
|
||||
if (pszRenamed && *pszRenamed)
|
||||
{
|
||||
m_Args.pszRenameTab = lstrdup(pszRenamed);
|
||||
m_Args.pszRenameTab = lstrdup(pszRenamed).Detach();
|
||||
}
|
||||
}
|
||||
|
||||
wchar_t* pszCmd = m_Args.CreateCommandLine(abForTasks);
|
||||
CEStr pszCmd = m_Args.CreateCommandLine(abForTasks);
|
||||
|
||||
m_Args.pszStartupDir = pszDirSave;
|
||||
|
||||
@ -15551,7 +15533,7 @@ void CRealConsole::SetConStatus(LPCWSTR asStatus, DWORD/*enum ConStatusOption*/
|
||||
|
||||
wchar_t szPrefix[128];
|
||||
swprintf_c(szPrefix, L"CRealConsole::SetConStatus, hView=x%08X: ", (DWORD)(DWORD_PTR)mp_VCon->GetView());
|
||||
wchar_t* pszInfo = lstrmerge(szPrefix, *asStatus ? asStatus : L"<Empty>");
|
||||
CEStr pszInfo(szPrefix, *asStatus ? asStatus : L"<Empty>");
|
||||
DEBUGSTRSTATUS(pszInfo);
|
||||
|
||||
#ifdef _DEBUG
|
||||
@ -15563,8 +15545,6 @@ void CRealConsole::SetConStatus(LPCWSTR asStatus, DWORD/*enum ConStatusOption*/
|
||||
|
||||
LogString(pszInfo);
|
||||
|
||||
SafeFree(pszInfo);
|
||||
|
||||
size_t cchMax = countof(m_ConStatus.szText);
|
||||
if (asStatus[0])
|
||||
lstrcpyn(m_ConStatus.szText, asStatus, cchMax);
|
||||
@ -15895,13 +15875,14 @@ void CRealConsole::PostMacro(LPCWSTR asMacro, bool abAsync /*= FALSE*/)
|
||||
// This is GuiMacro, but not a Far Manager macros
|
||||
if (asMacro[1])
|
||||
{
|
||||
CEStr pszGui(asMacro+1), szRc;
|
||||
CEStr pszGui(asMacro + 1);
|
||||
CEStr szRc;
|
||||
if (isLogging())
|
||||
{
|
||||
CEStr lsLog(L"CRealConsole::PostMacro: ", asMacro);
|
||||
const CEStr lsLog(L"CRealConsole::PostMacro: ", asMacro);
|
||||
LogString(lsLog);
|
||||
}
|
||||
szRc = ConEmuMacro::ExecuteMacro(pszGui.ms_Val, this);
|
||||
szRc = ConEmuMacro::ExecuteMacro(std::move(pszGui), this);
|
||||
LogString(szRc.c_str(L"<nullptr>"));
|
||||
TODO("Show result in the status line?");
|
||||
}
|
||||
@ -16017,7 +15998,7 @@ void CRealConsole::PostMacro(LPCWSTR asMacro, bool abAsync /*= FALSE*/)
|
||||
}
|
||||
}
|
||||
|
||||
wchar_t* CRealConsole::PostponeMacro(wchar_t*&& asMacro)
|
||||
CEStr CRealConsole::PostponeMacro(CEStr&& asMacro)
|
||||
{
|
||||
AssertThisRet(lstrdup(L"InvalidPointer"));
|
||||
if (!asMacro)
|
||||
@ -16028,12 +16009,12 @@ wchar_t* CRealConsole::PostponeMacro(wchar_t*&& asMacro)
|
||||
|
||||
if (!mpsz_PostCreateMacro)
|
||||
{
|
||||
mpsz_PostCreateMacro = asMacro;
|
||||
mpsz_PostCreateMacro = std::move(asMacro);
|
||||
}
|
||||
else
|
||||
{
|
||||
ConEmuMacro::ConcatMacro(mpsz_PostCreateMacro, asMacro);
|
||||
SafeFree(asMacro);
|
||||
asMacro.Release();
|
||||
}
|
||||
|
||||
return lstrdup(L"PostponedRCon");
|
||||
@ -16043,23 +16024,20 @@ void CRealConsole::ProcessPostponedMacro()
|
||||
{
|
||||
AssertThis();
|
||||
|
||||
wchar_t* pszMacro = nullptr;
|
||||
wchar_t* pszResult = nullptr;
|
||||
CEStr pszMacro = nullptr;
|
||||
CEStr pszResult = nullptr;
|
||||
|
||||
if (mpsz_PostCreateMacro)
|
||||
{
|
||||
pszMacro = mpsz_PostCreateMacro;
|
||||
pszMacro = std::move(mpsz_PostCreateMacro);
|
||||
mpsz_PostCreateMacro = nullptr;
|
||||
}
|
||||
|
||||
if (pszMacro)
|
||||
{
|
||||
CVConGuard VCon(mp_VCon);
|
||||
pszResult = ConEmuMacro::ExecuteMacro(pszMacro, this);
|
||||
pszResult = ConEmuMacro::ExecuteMacro(std::move(pszMacro), this);
|
||||
}
|
||||
|
||||
SafeFree(pszMacro);
|
||||
SafeFree(pszResult);
|
||||
}
|
||||
|
||||
DWORD CRealConsole::InitiateDetach()
|
||||
|
@ -357,7 +357,7 @@ class CRealConsole
|
||||
bool SetOtherWindowRgn(HWND hWnd, int nRects, LPRECT prcRects, bool bRedraw);
|
||||
void PostDragCopy(bool abMove);
|
||||
void PostMacro(LPCWSTR asMacro, bool abAsync = false);
|
||||
wchar_t* PostponeMacro(wchar_t*&& asMacro);
|
||||
CEStr PostponeMacro(CEStr&& asMacro);
|
||||
bool GetFarVersion(FarVersion* pfv);
|
||||
bool IsFarLua();
|
||||
bool StartDebugger(StartDebugType sdt);
|
||||
@ -374,7 +374,7 @@ class CRealConsole
|
||||
BYTE Data[1];
|
||||
};
|
||||
};
|
||||
wchar_t* mpsz_PostCreateMacro;
|
||||
CEStr mpsz_PostCreateMacro;
|
||||
void ProcessPostponedMacro();
|
||||
static DWORD WINAPI PostMacroThread(LPVOID lpParameter);
|
||||
HANDLE mh_PostMacroThread; DWORD mn_PostMacroThreadID;
|
||||
@ -576,7 +576,7 @@ class CRealConsole
|
||||
void SetPaletteName(LPCWSTR asPaletteName);
|
||||
LPCWSTR GetCmd(bool bThisOnly = false);
|
||||
LPCWSTR GetStartupDir();
|
||||
wchar_t* CreateCommandLine(bool abForTasks = false);
|
||||
CEStr CreateCommandLine(bool abForTasks = false);
|
||||
bool GetUserPwd(const wchar_t*& rpszUser, const wchar_t*& rpszDomain, bool& rbRestricted) const;
|
||||
short GetProgress(AnsiProgressStatus* rpnState/*1-error,2-ind*/, bool* rpbNotFromTitle = nullptr);
|
||||
/// <summary>
|
||||
|
@ -836,17 +836,16 @@ CESERVER_REQ* CRealServer::cmdGuiMacro(LPVOID pInst, CESERVER_REQ* pIn, UINT nDa
|
||||
CESERVER_REQ* pOut = nullptr;
|
||||
|
||||
DEBUGSTRCMD(L"GUI recieved CECMD_GUIMACRO\n");
|
||||
DWORD nFarPluginPID = mp_RCon->GetFarPID(true);
|
||||
LPWSTR pszResult = ConEmuMacro::ExecuteMacro(pIn->GuiMacro.sMacro, mp_RCon, (nFarPluginPID==pIn->hdr.nSrcPID), &pIn->GuiMacro);
|
||||
const DWORD nFarPluginPID = mp_RCon->GetFarPID(true);
|
||||
const CEStr pszResult = ConEmuMacro::ExecuteMacro(pIn->GuiMacro.sMacro, mp_RCon, (nFarPluginPID==pIn->hdr.nSrcPID), &pIn->GuiMacro);
|
||||
|
||||
size_t nLen = pszResult ? _tcslen(pszResult) : 0;
|
||||
pOut = ExecuteNewCmd(pIn->hdr.nCmd, sizeof(CESERVER_REQ_HDR)+sizeof(CESERVER_REQ_GUIMACRO)+nLen*sizeof(wchar_t));
|
||||
const size_t nLen = pszResult.GetLen();
|
||||
pOut = ExecuteNewCmd(pIn->hdr.nCmd, sizeof(CESERVER_REQ_HDR) + sizeof(CESERVER_REQ_GUIMACRO) + nLen * sizeof(wchar_t));
|
||||
|
||||
if (pszResult)
|
||||
{
|
||||
lstrcpy(pOut->GuiMacro.sMacro, pszResult);
|
||||
pOut->GuiMacro.nSucceeded = 1;
|
||||
free(pszResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1508,8 +1507,8 @@ CESERVER_REQ* CRealServer::cmdIsAnsiExecAllowed(LPVOID pInst, CESERVER_REQ* pIn,
|
||||
}
|
||||
else if (nDataSize > sizeof(wchar_t))
|
||||
{
|
||||
LPCWSTR pszExec = (LPCWSTR)pIn->wData;
|
||||
CEStr lsAllowed((LPCWSTR)gpSet->psAnsiAllowed);
|
||||
const auto* pszExec = reinterpret_cast<LPCWSTR>(pIn->wData);
|
||||
const CEStr lsAllowed(*gpSet->psAnsiAllowed);
|
||||
LPCWSTR pszFrom = lsAllowed.ms_Val;
|
||||
CEStr lsCmd;
|
||||
while (!bAllowed && (pszFrom = NextLine(pszFrom, lsCmd)))
|
||||
|
@ -108,11 +108,11 @@ int CRecreateDlg::RecreateDlg(RConStartArgsEx* apArgs, bool abDontAutoSelCmd /*=
|
||||
|
||||
InitVars();
|
||||
|
||||
bool bPrev = gpConEmu->SetSkipOnFocus(true);
|
||||
const bool bPrev = gpConEmu->SetSkipOnFocus(true);
|
||||
CDpiForDialog::Create(mp_DpiAware);
|
||||
// Modal dialog (CreateDialog)
|
||||
int nRc = CDynDialog::ExecuteDialog(IDD_RESTART, mh_Parent, RecreateDlgProc, (LPARAM)this);
|
||||
UNREFERENCED_PARAMETER(nRc);
|
||||
const auto nRc = CDynDialog::ExecuteDialog(IDD_RESTART, mh_Parent, RecreateDlgProc, reinterpret_cast<LPARAM>(this));
|
||||
std::ignore = nRc;
|
||||
gpConEmu->SetSkipOnFocus(bPrev);
|
||||
|
||||
FreeVars();
|
||||
@ -193,7 +193,7 @@ INT_PTR CRecreateDlg::OnInitDialog(HWND hDlg, UINT messg, WPARAM wParam, LPARAM
|
||||
lsAppend = tempArgs.CreateCommandLine(false);
|
||||
if (!lsAppend.IsEmpty())
|
||||
{
|
||||
lsTempCmd = lstrmerge(pszSetCmd, ((lsAppend[0] == L' ') ? nullptr : L" "), lsAppend);
|
||||
lsTempCmd = CEStr(pszSetCmd, ((lsAppend[0] == L' ') ? nullptr : L" "), lsAppend);
|
||||
pszSetCmd = lsTempCmd.ms_Val;
|
||||
}
|
||||
}
|
||||
@ -501,27 +501,27 @@ INT_PTR CRecreateDlg::OnUserControls(HWND hDlg, UINT messg, WPARAM wParam, LPARA
|
||||
|
||||
if (nStatus == NERR_Success)
|
||||
{
|
||||
wchar_t *pszAdmin = nullptr, *pszLikeAdmin = nullptr, *pszOtherUser = nullptr;
|
||||
CEStr pszAdmin, pszLikeAdmin, pszOtherUser;
|
||||
|
||||
for (DWORD i = 0; i < dwEntriesRead; ++i)
|
||||
{
|
||||
// usri3_logon_server "\\*" wchar_t *
|
||||
if (!(info[i].usri3_flags & UF_ACCOUNTDISABLE) && info[i].usri3_name && *info[i].usri3_name)
|
||||
{
|
||||
SendDlgItemMessage(hDlg, tRunAsUser, CB_ADDSTRING, 0, (LPARAM)info[i].usri3_name);
|
||||
SendDlgItemMessage(hDlg, tRunAsUser, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(info[i].usri3_name));
|
||||
|
||||
if (info[i].usri3_priv == 2/*USER_PRIV_ADMIN*/)
|
||||
{
|
||||
if (!pszAdmin && (info[i].usri3_user_id == 500))
|
||||
pszAdmin = lstrdup(info[i].usri3_name);
|
||||
pszAdmin.Set(info[i].usri3_name);
|
||||
else if (!pszLikeAdmin && (lstrcmpi(ms_CurUser, info[i].usri3_name) != 0))
|
||||
pszLikeAdmin = lstrdup(info[i].usri3_name);
|
||||
pszLikeAdmin.Set(info[i].usri3_name);
|
||||
}
|
||||
else if (!pszOtherUser
|
||||
&& (info[i].usri3_priv == 1/*USER_PRIV_USER*/)
|
||||
&& (lstrcmpi(ms_CurUser, info[i].usri3_name) != 0))
|
||||
{
|
||||
pszOtherUser = lstrdup(info[i].usri3_name);
|
||||
pszOtherUser.Set(info[i].usri3_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -529,12 +529,14 @@ INT_PTR CRecreateDlg::OnUserControls(HWND hDlg, UINT messg, WPARAM wParam, LPARA
|
||||
if (GetWindowTextLength(GetDlgItem(hDlg, tRunAsUser)) == 0)
|
||||
{
|
||||
// Try to suggest "Administrator" account
|
||||
SetDlgItemText(hDlg, tRunAsUser, pszAdmin ? pszAdmin : pszLikeAdmin ? pszLikeAdmin : pszOtherUser ? pszOtherUser : ms_CurUser);
|
||||
SetDlgItemText(hDlg, tRunAsUser,
|
||||
pszAdmin ? pszAdmin.c_str()
|
||||
: pszLikeAdmin ? pszLikeAdmin.c_str()
|
||||
: pszOtherUser ? pszOtherUser.c_str()
|
||||
: ms_CurUser);
|
||||
}
|
||||
|
||||
::NetApiBufferFree(info);
|
||||
SafeFree(pszAdmin);
|
||||
SafeFree(pszLikeAdmin);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -562,13 +564,12 @@ INT_PTR CRecreateDlg::OnSysCommand(HWND hDlg, UINT messg, WPARAM wParam, LPARAM
|
||||
// Подтверждение спросит ResetCmdHistory
|
||||
if (gpSetCls->ResetCmdHistory(hDlg))
|
||||
{
|
||||
wchar_t* pszCmd = GetDlgItemTextPtr(hDlg, IDC_RESTART_CMD);
|
||||
const CEStr pszCmd = GetDlgItemTextPtr(hDlg, IDC_RESTART_CMD);
|
||||
SendDlgItemMessage(hDlg, IDC_RESTART_CMD, CB_RESETCONTENT, 0,0);
|
||||
SendMessage(hDlg, UM_FILL_CMDLIST, FALSE, 0);
|
||||
if (pszCmd)
|
||||
{
|
||||
SetDlgItemText(hDlg, IDC_RESTART_CMD, pszCmd);
|
||||
free(pszCmd);
|
||||
SetDlgItemText(hDlg, IDC_RESTART_CMD, pszCmd.c_str());
|
||||
}
|
||||
}
|
||||
SetWindowLongPtr(hDlg, DWLP_MSGRESULT, 0);
|
||||
@ -594,25 +595,22 @@ INT_PTR CRecreateDlg::OnButtonClicked(HWND hDlg, UINT messg, WPARAM wParam, LPAR
|
||||
{
|
||||
case IDC_CHOOSE:
|
||||
{
|
||||
wchar_t *pszFilePath = SelectFile(L"Choose program to run", nullptr, nullptr, hDlg, L"Executables (*.exe)\0*.exe\0All files (*.*)\0*.*\0\0", sff_AutoQuote);
|
||||
const CEStr pszFilePath = SelectFile(L"Choose program to run", nullptr, nullptr, hDlg, L"Executables (*.exe)\0*.exe\0All files (*.*)\0*.*\0\0", sff_AutoQuote);
|
||||
if (pszFilePath)
|
||||
{
|
||||
SetDlgItemText(hDlg, IDC_RESTART_CMD, pszFilePath);
|
||||
SafeFree(pszFilePath);
|
||||
SetDlgItemText(hDlg, IDC_RESTART_CMD, pszFilePath.c_str());
|
||||
}
|
||||
return TRUE;
|
||||
} // case IDC_CHOOSE:
|
||||
|
||||
case IDC_CHOOSE_DIR:
|
||||
{
|
||||
wchar_t* pszDefFolder = GetDlgItemTextPtr(hDlg, IDC_STARTUP_DIR);
|
||||
wchar_t* pszFolder = SelectFolder(L"Choose startup directory", pszDefFolder, hDlg, sff_Default);
|
||||
const CEStr pszDefFolder = GetDlgItemTextPtr(hDlg, IDC_STARTUP_DIR);
|
||||
const CEStr pszFolder = SelectFolder(L"Choose startup directory", pszDefFolder, hDlg, sff_Default);
|
||||
if (pszFolder)
|
||||
{
|
||||
SetDlgItemText(hDlg, IDC_STARTUP_DIR, pszFolder);
|
||||
SafeFree(pszFolder);
|
||||
SetDlgItemText(hDlg, IDC_STARTUP_DIR, pszFolder.c_str());
|
||||
}
|
||||
SafeFree(pszDefFolder);
|
||||
return TRUE;
|
||||
} // case IDC_CHOOSE_DIR:
|
||||
|
||||
@ -677,7 +675,7 @@ INT_PTR CRecreateDlg::OnButtonClicked(HWND hDlg, UINT messg, WPARAM wParam, LPAR
|
||||
if (SendDlgItemMessage(hDlg, rbAnotherUser, BM_GETCHECK, 0, 0))
|
||||
{
|
||||
pArgs->RunAsRestricted = crb_Off;
|
||||
pArgs->pszUserName = GetDlgItemTextPtr(hDlg, tRunAsUser);
|
||||
pArgs->pszUserName = GetDlgItemTextPtr(hDlg, tRunAsUser).Detach();
|
||||
pArgs->RunAsNetOnly = SendDlgItemMessage(hDlg, cbRunAsNetOnly, BM_GETCHECK, 0, 0) ? crb_On : crb_Off;
|
||||
|
||||
if (pArgs->pszUserName)
|
||||
@ -709,12 +707,11 @@ INT_PTR CRecreateDlg::OnButtonClicked(HWND hDlg, UINT messg, WPARAM wParam, LPAR
|
||||
// Another user? We may fail with access denied. Check only for "current user" account
|
||||
if (!pArgs->pszUserName && pszDirResult && *pszDirResult && !DirectoryExists(pszDirResult))
|
||||
{
|
||||
wchar_t* pszErrInfo = lstrmerge(L"Specified directory does not exists!\n", pszDirResult, L"\n" L"Do you want to choose another directory?\n\n");
|
||||
const CEStr pszErrInfo(L"Specified directory does not exists!\n", pszDirResult, L"\n" L"Do you want to choose another directory?\n\n");
|
||||
const DWORD nErr = GetLastError();
|
||||
const int iDirBtn = DisplayLastError(pszErrInfo, nErr, MB_ICONEXCLAMATION|MB_YESNO, nullptr, hDlg);
|
||||
if (iDirBtn == IDYES)
|
||||
{
|
||||
SafeFree(pszErrInfo);
|
||||
return 1;
|
||||
}
|
||||
// User want to run "as is". Most likely it will fail, but who knows...
|
||||
@ -727,7 +724,7 @@ INT_PTR CRecreateDlg::OnButtonClicked(HWND hDlg, UINT messg, WPARAM wParam, LPAR
|
||||
SafeFree(pArgs->pszSpecialCmd);
|
||||
|
||||
// GetDlgItemText выделяет память через calloc
|
||||
pArgs->pszSpecialCmd = GetDlgItemTextPtr(hDlg, IDC_RESTART_CMD);
|
||||
pArgs->pszSpecialCmd = GetDlgItemTextPtr(hDlg, IDC_RESTART_CMD).Detach();
|
||||
|
||||
if (pArgs->pszSpecialCmd)
|
||||
gpSet->HistoryAdd(pArgs->pszSpecialCmd);
|
||||
@ -931,17 +928,17 @@ void CRecreateDlg::InitVars()
|
||||
// * Ни одной консоли нет (предложить то что запускается при старте - Task, команда)
|
||||
// * Консоли есть (пусть наверное будет то что запускается при старте - Task, команда)
|
||||
|
||||
wchar_t* pszBuf = nullptr;
|
||||
CEStr pszBuf;
|
||||
|
||||
_ASSERTE(pRCon || (mp_Args->aRecreate == cra_CreateTab || mp_Args->aRecreate == cra_EditTab));
|
||||
|
||||
LPCWSTR pszCmd = pRCon ? pRCon->GetCmd() : nullptr;
|
||||
if (pszCmd && *pszCmd)
|
||||
mpsz_CurCmd = lstrdup(pszCmd);
|
||||
mpsz_CurCmd = lstrdup(pszCmd).Detach();
|
||||
|
||||
LPCWSTR pszSystem = gpConEmu->GetCmd();
|
||||
const wchar_t* pszSystem = gpConEmu->GetCmd();
|
||||
if (pszSystem && *pszSystem && (lstrcmpi(pszSystem, AutoStartTaskName) != 0))
|
||||
mpsz_SysCmd = lstrdup(pszSystem);
|
||||
mpsz_SysCmd = lstrdup(pszSystem).Detach();
|
||||
|
||||
bool bDirFromRCon = false;
|
||||
|
||||
@ -949,7 +946,7 @@ void CRecreateDlg::InitVars()
|
||||
{
|
||||
// When recreate - always show active console command line
|
||||
_ASSERTE(pRCon);
|
||||
mpsz_DefCmd = lstrdup(pszCmd);
|
||||
mpsz_DefCmd = lstrdup(pszCmd).Detach();
|
||||
bDirFromRCon = true;
|
||||
}
|
||||
else
|
||||
@ -961,13 +958,13 @@ void CRecreateDlg::InitVars()
|
||||
if (!pszCmd)
|
||||
{
|
||||
pszBuf = gpConEmu->LoadConsoleBatch(AutoStartTaskName);
|
||||
wchar_t* pszLine = wcschr(pszBuf, L'\n');
|
||||
if (pszLine > pszBuf && *(pszLine-1) == L'\r')
|
||||
wchar_t* pszLine = wcschr(pszBuf.data(), L'\n');
|
||||
if (pszLine > pszBuf.data() && *(pszLine-1) == L'\r')
|
||||
pszLine--;
|
||||
if (pszLine)
|
||||
*pszLine = 0;
|
||||
|
||||
pszCmd = gpConEmu->ParseScriptLineOptions(pszBuf, nullptr, mp_Args);
|
||||
pszCmd = gpConEmu->ParseScriptLineOptions(pszBuf.c_str(), nullptr, mp_Args);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -983,17 +980,15 @@ void CRecreateDlg::InitVars()
|
||||
bDirFromRCon = true;
|
||||
}
|
||||
|
||||
mpsz_DefCmd = lstrdup(pszCmd);
|
||||
mpsz_DefCmd = lstrdup(pszCmd).Detach();
|
||||
//mpsz_DefDir = lstrdup(mp_Args->pszStartupDir ? mp_Args->pszStartupDir : L"");
|
||||
}
|
||||
|
||||
if (bDirFromRCon)
|
||||
{
|
||||
TODO("May be try to retrieve current directory of the shell?");
|
||||
mpsz_DefDir = lstrdup(ms_RConCurDir);
|
||||
mpsz_DefDir = lstrdup(ms_RConCurDir).Detach();
|
||||
}
|
||||
|
||||
SafeFree(pszBuf);
|
||||
}
|
||||
|
||||
void CRecreateDlg::FreeVars()
|
||||
|
@ -181,7 +181,7 @@ void CommandTasks::ParseGuiArgs(RConStartArgsEx* pArgs) const
|
||||
}
|
||||
|
||||
SafeFree(pArgs->pszStartupDir);
|
||||
pArgs->pszStartupDir = expanded ? expanded.Detach() : lstrdup(szArg);
|
||||
pArgs->pszStartupDir = expanded ? expanded.Detach() : lstrdup(szArg).Detach();
|
||||
}
|
||||
}
|
||||
else if (szArg.IsSwitch(L"-icon"))
|
||||
@ -199,7 +199,7 @@ void CommandTasks::ParseGuiArgs(RConStartArgsEx* pArgs) const
|
||||
}
|
||||
|
||||
SafeFree(pArgs->pszIconFile);
|
||||
pArgs->pszIconFile = expanded ? expanded.Detach() : lstrdup(szArg);
|
||||
pArgs->pszIconFile = expanded ? expanded.Detach() : lstrdup(szArg).Detach();
|
||||
}
|
||||
}
|
||||
else if (szArg.OneOfSwitches(L"-single", L"-reuse"))
|
||||
@ -216,12 +216,12 @@ void CommandTasks::ParseGuiArgs(RConStartArgsEx* pArgs) const
|
||||
// Turn on quake mode in starting console?
|
||||
// Disallowed if current window is already in Quake mode.
|
||||
if (!gpSet->isQuakeStyle)
|
||||
lstrmerge(&pArgs->pszAddGuiArg, L"-quake ");
|
||||
CEStr(pArgs->pszAddGuiArg, L"-quake ").Swap(pArgs->pszAddGuiArg);
|
||||
}
|
||||
else if (szArg.IsSwitch(L"-NoQuake"))
|
||||
{
|
||||
// Disable quake in starting console
|
||||
lstrmerge(&pArgs->pszAddGuiArg, L"-NoQuake ");
|
||||
CEStr(pArgs->pszAddGuiArg, L"-NoQuake ").Swap(pArgs->pszAddGuiArg);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -233,9 +233,8 @@ void CommandTasks::ParseGuiArgs(RConStartArgsEx* pArgs) const
|
||||
// Errors notification
|
||||
if (pszOk && *pszOk)
|
||||
{
|
||||
wchar_t* pszErr = lstrmerge(L"Unsupported task parameters\r\nTask name: ", pszName, L"\r\nParameters: ", pszOk);
|
||||
const CEStr pszErr(L"Unsupported task parameters\r\nTask name: ", pszName, L"\r\nParameters: ", pszOk);
|
||||
MsgBox(pszErr, MB_ICONSTOP);
|
||||
SafeFree(pszErr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -407,7 +406,7 @@ bool CommandTasks::SaveCmdTask(SettingsBase* reg, bool isStartup) const
|
||||
nActive = iCmdCount; // 1-based
|
||||
}
|
||||
|
||||
save_items.push_back(lstrdup(pszCmd));
|
||||
save_items.push_back(lstrdup(pszCmd).Detach());
|
||||
|
||||
if (pszEnd)
|
||||
*pszEnd = chSave;
|
||||
@ -450,7 +449,7 @@ CEStr CommandTasks::GetFirstCommandForPrompt() const
|
||||
const auto* const pszRaw = gpConEmu->ParseScriptLineOptions(lsData.ms_Val, nullptr, nullptr);
|
||||
if (pszRaw)
|
||||
{
|
||||
args.pszSpecialCmd = lstrdup(pszRaw);
|
||||
args.pszSpecialCmd = lstrdup(pszRaw).Detach();
|
||||
// Parse all -new_console's
|
||||
args.ProcessNewConArg();
|
||||
// Prohibit external requests for credentials
|
||||
|
@ -66,7 +66,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "Status.h"
|
||||
#include "TabBar.h"
|
||||
#include "TrayIcon.h"
|
||||
#include "UpdateSet.h"
|
||||
#include "Update.h"
|
||||
#include "VConGroup.h"
|
||||
#include "VirtualConsole.h"
|
||||
|
||||
@ -1002,7 +1002,7 @@ void CSetDlgButtons::OnButtonClicked_Cursor(HWND hDlg, WORD CB, BYTE uCheck, App
|
||||
} // rCursorH ... cbInactiveCursorIgnoreSize
|
||||
|
||||
// Service function for GuiMacro::SetOption
|
||||
wchar_t* CSetDlgButtons::CheckButtonMacro(WORD CB, BYTE uCheck)
|
||||
CEStr CSetDlgButtons::CheckButtonMacro(WORD CB, BYTE uCheck)
|
||||
{
|
||||
if (uCheck > BST_INDETERMINATE)
|
||||
{
|
||||
@ -1463,46 +1463,39 @@ void CSetDlgButtons::OnBtn_CmdGroupApp(HWND hDlg, WORD CB, BYTE uCheck)
|
||||
|
||||
if (nDlgRc == IDC_START)
|
||||
{
|
||||
wchar_t* pszCmd = args.CreateCommandLine(true);
|
||||
if (!pszCmd || !*pszCmd)
|
||||
CEStr pszCmd = args.CreateCommandLine(true);
|
||||
if (pszCmd.IsEmpty())
|
||||
{
|
||||
DisplayLastError(L"Can't compile command line for new tab\nAll fields are empty?", -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
//SendDlgItemMessage(hDlg, tCmdGroupCommands, EM_REPLACESEL, TRUE, (LPARAM)pszName);
|
||||
wchar_t* pszFull = GetDlgItemTextPtr(hDlg, tCmdGroupCommands);
|
||||
if (!pszFull || !*pszFull)
|
||||
CEStr pszFull = GetDlgItemTextPtr(hDlg, tCmdGroupCommands);
|
||||
if (pszFull.IsEmpty())
|
||||
{
|
||||
SafeFree(pszFull);
|
||||
pszFull.Release();
|
||||
pszFull = pszCmd;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t cchLen = _tcslen(pszFull);
|
||||
size_t cchMax = cchLen + 7 + _tcslen(pszCmd);
|
||||
pszFull = (wchar_t*)realloc(pszFull, cchMax*sizeof(*pszFull));
|
||||
const ssize_t cchLen = pszFull.GetLen();
|
||||
pszFull.GetBuffer(pszFull.GetLen() + 7 + pszCmd.GetLen());
|
||||
|
||||
int nRN = 0;
|
||||
if (cchLen >= 2)
|
||||
if (cchLen >= 2 && pszFull[cchLen - 2] == L'\r' && pszFull[cchLen - 1] == L'\n')
|
||||
{
|
||||
if (pszFull[cchLen-2] == L'\r' && pszFull[cchLen-1] == L'\n')
|
||||
++nRN;
|
||||
if (cchLen >= 4 && pszFull[cchLen - 4] == L'\r' && pszFull[cchLen - 3] == L'\n')
|
||||
{
|
||||
nRN++;
|
||||
if (cchLen >= 4)
|
||||
{
|
||||
if (pszFull[cchLen-4] == L'\r' && pszFull[cchLen-3] == L'\n')
|
||||
{
|
||||
nRN++;
|
||||
}
|
||||
}
|
||||
++nRN;
|
||||
}
|
||||
}
|
||||
|
||||
if (nRN < 2)
|
||||
_wcscat_c(pszFull, cchMax, nRN ? L"\r\n" : L"\r\n\r\n");
|
||||
pszFull.Append(nRN ? L"\r\n" : L"\r\n\r\n");
|
||||
|
||||
_wcscat_c(pszFull, cchMax, pszCmd);
|
||||
pszFull.Append(pszCmd);
|
||||
}
|
||||
|
||||
if (pszFull)
|
||||
@ -1518,9 +1511,7 @@ void CSetDlgButtons::OnBtn_CmdGroupApp(HWND hDlg, WORD CB, BYTE uCheck)
|
||||
}
|
||||
if (pszCmd == pszFull)
|
||||
pszCmd = nullptr;
|
||||
SafeFree(pszFull);
|
||||
}
|
||||
SafeFree(pszCmd);
|
||||
}
|
||||
} // cbCmdGroupApp
|
||||
|
||||
@ -1599,11 +1590,10 @@ void CSetDlgButtons::OnBtn_CmdTasksActive(HWND hDlg, WORD CB, BYTE uCheck)
|
||||
{
|
||||
_ASSERTE(CB==cbCmdTasksActive);
|
||||
|
||||
wchar_t* pszTasks = CVConGroup::GetTasks(); // вернуть все открытые таски
|
||||
const CEStr pszTasks = CVConGroup::GetTasks(); // вернуть все открытые таски
|
||||
if (pszTasks)
|
||||
{
|
||||
SendDlgItemMessage(hDlg, tCmdGroupCommands, EM_REPLACESEL, TRUE, (LPARAM)pszTasks);
|
||||
SafeFree(pszTasks);
|
||||
SendDlgItemMessage(hDlg, tCmdGroupCommands, EM_REPLACESEL, TRUE, reinterpret_cast<LPARAM>(pszTasks.c_str()));
|
||||
}
|
||||
} // cbCmdTasksActive
|
||||
|
||||
@ -1879,7 +1869,7 @@ void CSetDlgButtons::OnBtn_UnicodeRangesApply(HWND hDlg, WORD CB, BYTE uCheck)
|
||||
{
|
||||
_ASSERTE(CB==cbUnicodeRangesApply);
|
||||
|
||||
wchar_t* pszNameAndRange = GetDlgItemTextPtr(hDlg, tUnicodeRanges);
|
||||
CEStr pszNameAndRange = GetDlgItemTextPtr(hDlg, tUnicodeRanges);
|
||||
LPCWSTR pszRanges = pszNameAndRange ? pszNameAndRange : L"";
|
||||
// Strip possible descriptions from predefined subsets
|
||||
LPCWSTR pszColon = wcschr(pszRanges, L':');
|
||||
@ -1889,7 +1879,6 @@ void CSetDlgButtons::OnBtn_UnicodeRangesApply(HWND hDlg, WORD CB, BYTE uCheck)
|
||||
++pszRanges;
|
||||
// Now parse text ranges
|
||||
gpSet->ParseCharRanges(pszRanges, gpSet->mpc_CharAltFontRanges);
|
||||
SafeFree(pszNameAndRange);
|
||||
|
||||
if (gpSet->isFixFarBorders)
|
||||
{
|
||||
@ -2066,10 +2055,9 @@ void CSetDlgButtons::OnBtn_ComspecExplicit(HWND hDlg, WORD CB, BYTE uCheck)
|
||||
//cbComspecTest
|
||||
void CSetDlgButtons::OnBtn_ComspecTest(HWND hDlg, WORD CB, BYTE uCheck)
|
||||
{
|
||||
wchar_t* psz = GetComspec(&gpSet->ComSpec);
|
||||
CEStr psz = GetComspec(&gpSet->ComSpec);
|
||||
|
||||
MsgBox(psz ? psz : L"<nullptr>", MB_ICONINFORMATION, gpConEmu->GetDefaultTitle(), ghOpWnd);
|
||||
SafeFree(psz);
|
||||
|
||||
} // cbComspecTest
|
||||
|
||||
@ -4243,13 +4231,13 @@ void CSetDlgButtons::OnBtn_UpdateInetToolCmd(HWND hDlg, WORD CB, BYTE uCheck)
|
||||
if (GetOpenFileName(&ofn))
|
||||
{
|
||||
CEStr lsCmd;
|
||||
LPCWSTR pszName = PointToName(szInetExe);
|
||||
const wchar_t* pszName = PointToName(szInetExe);
|
||||
if (lstrcmpi(pszName, L"wget.exe") == 0)
|
||||
lsCmd = lstrmerge(L"\"", szInetExe, L"\" %1 -O %2");
|
||||
lsCmd = CEStr(L"\"", szInetExe, L"\" %1 -O %2");
|
||||
else if (lstrcmpi(pszName, L"curl.exe") == 0)
|
||||
lsCmd = lstrmerge(L"\"", szInetExe, L"\" -L %1 -o %2");
|
||||
lsCmd = CEStr(L"\"", szInetExe, L"\" -L %1 -o %2");
|
||||
else
|
||||
lsCmd = lstrmerge(L"\"", szInetExe, L"\" %1 %2");
|
||||
lsCmd = CEStr(L"\"", szInetExe, L"\" %1 %2");
|
||||
SetDlgItemText(hDlg, tUpdateInetTool, lsCmd.ms_Val);
|
||||
}
|
||||
} // cbUpdateInetToolPath
|
||||
@ -4493,13 +4481,13 @@ void CSetDlgButtons::OnBtn_GotoEditorCmd(HWND hDlg, WORD CB, BYTE uCheck)
|
||||
|
||||
if (GetSaveFileName(&ofn))
|
||||
{
|
||||
wchar_t *pszBuf = MergeCmdLine(szPath, pszTemp);
|
||||
CEStr pszBuf = MergeCmdLine(szPath, pszTemp);
|
||||
if (pszBuf)
|
||||
{
|
||||
SetDlgItemText(hDlg, lbGotoEditorCmd, pszBuf);
|
||||
|
||||
SafeFree(gpSet->sFarGotoEditor);
|
||||
gpSet->sFarGotoEditor = pszBuf;
|
||||
gpSet->sFarGotoEditor = pszBuf.Detach();
|
||||
}
|
||||
}
|
||||
} // bGotoEditorCmd
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
static BYTE isOptChecked(WORD nCtrlId, WORD CB, BYTE uCheck);
|
||||
|
||||
public:
|
||||
static wchar_t* CheckButtonMacro(WORD CB, BYTE uCheck);
|
||||
static CEStr CheckButtonMacro(WORD CB, BYTE uCheck);
|
||||
|
||||
protected:
|
||||
static bool ProcessButtonClick(HWND hDlg, WORD CB, BYTE uCheck);
|
||||
|
@ -51,7 +51,7 @@ LRESULT CSetPgANSI::OnInitDialog(HWND hDlg, bool abInitial)
|
||||
_ASSERTE(ansi_Allowed==0 && rbAnsiSecureCmd==(rbAnsiSecureAny+ansi_CmdOnly) && rbAnsiSecureOff==(rbAnsiSecureAny+ansi_Disabled));
|
||||
checkRadioButton(hDlg, rbAnsiSecureAny, rbAnsiSecureOff, rbAnsiSecureAny+gpSet->isAnsiExec);
|
||||
|
||||
SetDlgItemText(hDlg, tAnsiSecure, gpSet->psAnsiAllowed ? gpSet->psAnsiAllowed : L"");
|
||||
SetDlgItemText(hDlg, tAnsiSecure, gpSet->psAnsiAllowed ? gpSet->psAnsiAllowed->c_str() : L"");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -62,8 +62,12 @@ LRESULT CSetPgANSI::OnEditChanged(HWND hDlg, WORD nCtrlId)
|
||||
{
|
||||
case tAnsiSecure:
|
||||
{
|
||||
size_t cchMax = gpSet->psAnsiAllowed ? (_tcslen(gpSet->psAnsiAllowed)+1) : 0;
|
||||
MyGetDlgItemText(hDlg, tAnsiSecure, cchMax, gpSet->psAnsiAllowed);
|
||||
if (gpSet->psAnsiAllowed == nullptr)
|
||||
{
|
||||
_ASSERTE(gpSet->psAnsiAllowed != nullptr);
|
||||
gpSet->psAnsiAllowed = new CEStr();
|
||||
}
|
||||
MyGetDlgItemText(hDlg, tAnsiSecure, *gpSet->psAnsiAllowed);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -35,7 +35,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "ConEmu.h"
|
||||
#include "OptionsClass.h"
|
||||
#include "SetPgComspec.h"
|
||||
#include "SetPgIntegr.h"
|
||||
#include "VConGroup.h"
|
||||
|
||||
CSetPgComspec::CSetPgComspec()
|
||||
@ -82,7 +81,7 @@ INT_PTR CSetPgComspec::OnComboBox(HWND hDlg, WORD nCtrlId, WORD code)
|
||||
|
||||
void CSetPgComspec::ReloadAutorun()
|
||||
{
|
||||
wchar_t *pszCmd = nullptr;
|
||||
CEStr pszCmd;
|
||||
|
||||
BOOL bForceNewWnd = isChecked(mh_Dlg, cbCmdAutorunNewWnd);
|
||||
|
||||
@ -99,16 +98,15 @@ void CSetPgComspec::ReloadAutorun()
|
||||
|
||||
SetDlgItemText(mh_Dlg, tCmdAutoAttach, pszCmd ? pszCmd : L"");
|
||||
checkDlgButton(mh_Dlg, cbCmdAutorunNewWnd, bForceNewWnd);
|
||||
|
||||
SafeFree(pszCmd);
|
||||
}
|
||||
|
||||
// Load current value of "HKCU\Software\Microsoft\Command Processor" : "AutoRun"
|
||||
// (bClear==true) - remove from it our "... Cmd_Autorun.cmd ..." part
|
||||
wchar_t* CSetPgComspec::LoadAutorunValue(HKEY hkCmd, bool bClear)
|
||||
CEStr CSetPgComspec::LoadAutorunValue(HKEY hkCmd, bool bClear)
|
||||
{
|
||||
size_t cchCmdMax = 65535;
|
||||
wchar_t *pszCmd = (wchar_t*)malloc(cchCmdMax*sizeof(*pszCmd));
|
||||
const size_t cchCmdMax = 65535;
|
||||
CEStr result;
|
||||
wchar_t *pszCmd = result.GetBuffer(cchCmdMax);
|
||||
if (!pszCmd)
|
||||
{
|
||||
_ASSERTE(pszCmd!=nullptr);
|
||||
@ -119,7 +117,7 @@ wchar_t* CSetPgComspec::LoadAutorunValue(HKEY hkCmd, bool bClear)
|
||||
//HKEY hkCmd = nullptr;
|
||||
//if (0 == RegOpenKeyEx(HKEY_CURRENT_USER, L"Software\\Microsoft\\Command Processor", 0, KEY_READ, &hkCmd))
|
||||
|
||||
DWORD cbMax = (cchCmdMax-2) * sizeof(*pszCmd);
|
||||
DWORD cbMax = (cchCmdMax - 2) * sizeof(*pszCmd);
|
||||
if (0 == RegQueryValueEx(hkCmd, L"AutoRun", nullptr, nullptr, (LPBYTE)pszCmd, &cbMax))
|
||||
{
|
||||
pszCmd[cbMax>>1] = 0;
|
||||
@ -167,7 +165,7 @@ wchar_t* CSetPgComspec::LoadAutorunValue(HKEY hkCmd, bool bClear)
|
||||
{
|
||||
pszEnd = SkipNonPrintable(pszEnd);
|
||||
}
|
||||
size_t cchLeft = _tcslen(pszEnd)+1;
|
||||
const size_t cchLeft = _tcslen(pszEnd)+1;
|
||||
// move command (from right) to the 'Cmd_Autorun.cmd' place
|
||||
memmove(pszStart, pszEnd, cchLeft*sizeof(wchar_t));
|
||||
}
|
||||
@ -181,7 +179,7 @@ wchar_t* CSetPgComspec::LoadAutorunValue(HKEY hkCmd, bool bClear)
|
||||
}
|
||||
|
||||
// Skip spaces?
|
||||
LPCWSTR pszChar = SkipNonPrintable(pszCmd);
|
||||
const auto* pszChar = SkipNonPrintable(pszCmd);
|
||||
if (!pszChar || !*pszChar)
|
||||
{
|
||||
*pszCmd = 0;
|
||||
@ -195,9 +193,9 @@ wchar_t* CSetPgComspec::LoadAutorunValue(HKEY hkCmd, bool bClear)
|
||||
// Done
|
||||
if (pszCmd && (*pszCmd == 0))
|
||||
{
|
||||
SafeFree(pszCmd);
|
||||
result.Release();
|
||||
}
|
||||
return pszCmd;
|
||||
return result;
|
||||
}
|
||||
|
||||
void CSetPgComspec::RegisterCmdAutorun(bool bEnabled, bool bForced /*= false*/)
|
||||
@ -210,10 +208,10 @@ void CSetPgComspec::RegisterCmdAutorun(bool bEnabled, bool bForced /*= false*/)
|
||||
nullptr, 0, KEY_READ | KEY_WRITE, nullptr, &hkCmd, nullptr);
|
||||
if (rc == 0)
|
||||
{
|
||||
wchar_t* pszCur = nullptr;
|
||||
wchar_t* pszBuf = nullptr;
|
||||
CEStr pszCur = nullptr;
|
||||
CEStr pszBuf = nullptr;
|
||||
LPCWSTR pszSet = L"";
|
||||
wchar_t szCmd[MAX_PATH+128];
|
||||
wchar_t szCmd[MAX_PATH + 128] = L"";
|
||||
|
||||
if (bEnabled)
|
||||
{
|
||||
@ -221,7 +219,7 @@ void CSetPgComspec::RegisterCmdAutorun(bool bEnabled, bool bForced /*= false*/)
|
||||
pszSet = pszCur;
|
||||
|
||||
swprintf_c(szCmd, L"\"%s\\Cmd_Autorun.cmd", gpConEmu->ms_ConEmuBaseDir);
|
||||
if (FileExists(szCmd+1))
|
||||
if (FileExists(szCmd + 1))
|
||||
{
|
||||
wcscat_c(szCmd, bForceNewWnd ? L"\" \"/GHWND=NEW\"" : L"\"");
|
||||
|
||||
@ -232,14 +230,10 @@ void CSetPgComspec::RegisterCmdAutorun(bool bEnabled, bool bForced /*= false*/)
|
||||
else
|
||||
{
|
||||
// Current "AutoRun" is not empty, need concatenate
|
||||
const size_t cchAll = _tcslen(szCmd) + _tcslen(pszCur) + 5;
|
||||
pszBuf = static_cast<wchar_t*>(malloc(cchAll*sizeof(*pszBuf)));
|
||||
_ASSERTE(pszBuf);
|
||||
pszBuf = CEStr(szCmd, L" & ", pszCur); // conveyer next command indifferent to %errorlevel%
|
||||
_ASSERTE(!pszBuf.IsEmpty());
|
||||
if (pszBuf)
|
||||
{
|
||||
_wcscpy_c(pszBuf, cchAll, szCmd);
|
||||
_wcscat_c(pszBuf, cchAll, L" & "); // conveyer next command indifferent to %errorlevel%
|
||||
_wcscat_c(pszBuf, cchAll, pszCur);
|
||||
// Ok, Set
|
||||
pszSet = pszBuf;
|
||||
}
|
||||
@ -258,14 +252,10 @@ void CSetPgComspec::RegisterCmdAutorun(bool bEnabled, bool bForced /*= false*/)
|
||||
pszSet = pszCur ? pszCur : L"";
|
||||
}
|
||||
|
||||
const DWORD cchLen = _tcslen(pszSet)+1;
|
||||
const DWORD cchLen = _tcslen(pszSet) + 1;
|
||||
RegSetValueEx(hkCmd, L"AutoRun", 0, REG_SZ, LPBYTE(pszSet), cchLen*sizeof(wchar_t));
|
||||
|
||||
RegCloseKey(hkCmd);
|
||||
|
||||
if (pszBuf && (pszBuf != pszCur) && (pszBuf != szCmd))
|
||||
free(pszBuf);
|
||||
SafeFree(pszCur);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
public:
|
||||
void ReloadAutorun();
|
||||
void RegisterCmdAutorun(bool bEnabled, bool bForced = false);
|
||||
wchar_t* LoadAutorunValue(HKEY hkCmd, bool bClear);
|
||||
CEStr LoadAutorunValue(HKEY hkCmd, bool bClear);
|
||||
|
||||
protected:
|
||||
// Members
|
||||
|
@ -203,9 +203,9 @@ void CSetPgDebug::debugLogShell(DWORD nParentPID, CESERVER_REQ_ONCREATEPROCESS*
|
||||
shl->nParentPID = nParentPID;
|
||||
shl->nParentBits = pInfo->nSourceBits;
|
||||
wcscpy_c(shl->szFunction, pInfo->sFunction);
|
||||
shl->pszAction = lstrdup(pInfo->wsValue);
|
||||
shl->pszFile = lstrdup(pszFile);
|
||||
shl->pszParam = lstrdup(pszParam);
|
||||
shl->pszAction = lstrdup(pInfo->wsValue).Detach();
|
||||
shl->pszFile = lstrdup(pszFile).Detach();
|
||||
shl->pszParam = lstrdup(pszParam).Detach();
|
||||
shl->bDos = (pInfo->nImageBits == 16) && (pInfo->nImageSubsystem == IMAGE_SUBSYSTEM_DOS_EXECUTABLE);
|
||||
shl->nImageBits = pInfo->nImageBits;
|
||||
shl->nImageSubsystem = pInfo->nImageSubsystem;
|
||||
@ -219,19 +219,18 @@ void CSetPgDebug::debugLogShell(DWORD nParentPID, CESERVER_REQ_ONCREATEPROCESS*
|
||||
|
||||
// Append directory and bat/tmp files contents to pszParam
|
||||
{
|
||||
LPCWSTR pszDir = (pInfo->wsValue+pInfo->nActionLen+pInfo->nFileLen+pInfo->nParamLen);
|
||||
const wchar_t* pszDir = (pInfo->wsValue + pInfo->nActionLen + pInfo->nFileLen + pInfo->nParamLen);
|
||||
LPCWSTR pszAppFile = nullptr;
|
||||
wchar_t*& pszParamEx = shl->pszParam;
|
||||
CEStr pszParamEx(shl->pszParam);
|
||||
|
||||
if (pszDir && *pszDir)
|
||||
{
|
||||
CEStr lsDir((pszParamEx && *pszParamEx) ? L"\r\n\r\n" : nullptr, L"CD: \"", pszDir, L"\"");
|
||||
lstrmerge(&pszParamEx, lsDir);
|
||||
pszParamEx.Append(!pszParamEx.IsEmpty() ? L"\r\n\r\n" : nullptr, L"CD: \"", pszDir, L"\"");
|
||||
}
|
||||
|
||||
if (shl->pszFile)
|
||||
{
|
||||
LPCWSTR pszExt = PointToExt(shl->pszFile);
|
||||
const wchar_t* pszExt = PointToExt(shl->pszFile);
|
||||
if (pszExt && (!lstrcmpi(pszExt, L".bat") || !lstrcmpi(pszExt, L".cmd")))
|
||||
debugLogShellText(pszParamEx, (pszAppFile = shl->pszFile));
|
||||
}
|
||||
@ -385,39 +384,25 @@ void CSetPgDebug::debugLogShell(DebugLogShellActivity *pShl)
|
||||
free(pShl);
|
||||
}
|
||||
|
||||
void CSetPgDebug::debugLogShellText(wchar_t* &pszParamEx, LPCWSTR asFile)
|
||||
void CSetPgDebug::debugLogShellText(CEStr& pszParamEx, LPCWSTR asFile)
|
||||
{
|
||||
_ASSERTE(pszParamEx!=nullptr && asFile && *asFile);
|
||||
_ASSERTE(pszParamEx != nullptr && asFile && *asFile);
|
||||
|
||||
CEStr szBuf;
|
||||
DWORD cchMax = 32*1024/*32 KB*/;
|
||||
DWORD nRead = 0, nErrCode = (DWORD)-1;
|
||||
DWORD nRead = 0, nErrCode = static_cast<DWORD>(-1);
|
||||
|
||||
#ifdef _DEBUG
|
||||
LPCWSTR pszExt = PointToExt(asFile);
|
||||
const wchar_t* pszExt = PointToExt(asFile);
|
||||
bool bCmdBatch = ((lstrcmpi(pszExt, L".bat") == 0) && (lstrcmpi(pszExt, L".cmd") == 0));
|
||||
#endif
|
||||
|
||||
// ReadTextFile will use BOM if it exists
|
||||
UINT nDefCP = CP_OEMCP;
|
||||
const UINT nDefCP = CP_OEMCP;
|
||||
|
||||
if (0 == ReadTextFile(asFile, cchMax, szBuf.ms_Val, nRead, nErrCode, nDefCP))
|
||||
if (0 == ReadTextFile(asFile, cchMax, szBuf, nRead, nErrCode, nDefCP))
|
||||
{
|
||||
size_t nAll = 0;
|
||||
wchar_t* pszNew = nullptr;
|
||||
|
||||
nAll = (lstrlen(pszParamEx)+20) + nRead + 1 + 2*lstrlen(asFile);
|
||||
pszNew = (wchar_t*)realloc(pszParamEx, nAll*sizeof(wchar_t));
|
||||
if (pszNew)
|
||||
{
|
||||
_wcscat_c(pszNew, nAll, L"\r\n\r\n>>>");
|
||||
_wcscat_c(pszNew, nAll, asFile);
|
||||
_wcscat_c(pszNew, nAll, L"\r\n");
|
||||
_wcscat_c(pszNew, nAll, szBuf);
|
||||
_wcscat_c(pszNew, nAll, L"\r\n<<<");
|
||||
_wcscat_c(pszNew, nAll, asFile);
|
||||
pszParamEx = pszNew;
|
||||
}
|
||||
pszParamEx.Append(L"\r\n\r\n>>>", asFile, L"\r\n", szBuf, L"\r\n<<<", asFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,5 +147,5 @@ protected:
|
||||
DWORD mn_ActivityCmdStartTick;
|
||||
|
||||
// Helpers
|
||||
static void debugLogShellText(wchar_t* &pszParamEx, LPCWSTR asFile);
|
||||
static void debugLogShellText(CEStr& pszParamEx, LPCWSTR asFile);
|
||||
};
|
||||
|
@ -60,12 +60,11 @@ LRESULT CSetPgDefTerm::OnInitDialog(HWND hDlg, bool abInitial)
|
||||
CheckDlgButton(hDlg, cbDefaultTerminalDebugLog, gpSet->isDefaultTerminalDebugLog);
|
||||
CheckRadioButton(hDlg, rbDefaultTerminalConfAuto, rbDefaultTerminalConfNever,
|
||||
rbDefaultTerminalConfAuto + static_cast<int>(gpSet->nDefaultTerminalConfirmClose));
|
||||
wchar_t* pszApps = gpSet->GetDefaultTerminalApps();
|
||||
CEStr pszApps = gpSet->GetDefaultTerminalApps();
|
||||
_ASSERTE(pszApps!=nullptr);
|
||||
SetDlgItemText(hDlg, tDefaultTerminal, pszApps);
|
||||
if (wcschr(pszApps, L',') != nullptr && wcschr(pszApps, L'|') == nullptr)
|
||||
Icon.ShowTrayIcon(L"List of hooked executables must be delimited with \"|\" but not commas", tsa_Default_Term);
|
||||
SafeFree(pszApps);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -76,15 +75,13 @@ LRESULT CSetPgDefTerm::OnEditChanged(HWND hDlg, WORD nCtrlId)
|
||||
{
|
||||
case tDefaultTerminal:
|
||||
{
|
||||
wchar_t* pszApps = GetDlgItemTextPtr(hDlg, tDefaultTerminal);
|
||||
if (!pszApps || !*pszApps)
|
||||
CEStr pszApps = GetDlgItemTextPtr(hDlg, tDefaultTerminal);
|
||||
if (!pszApps)
|
||||
{
|
||||
SafeFree(pszApps);
|
||||
pszApps = lstrdup(DEFAULT_TERMINAL_APPS/*L"explorer.exe"*/);
|
||||
pszApps.Set(DEFAULT_TERMINAL_APPS/*L"explorer.exe"*/);
|
||||
SetDlgItemText(hDlg, tDefaultTerminal, pszApps);
|
||||
}
|
||||
gpSet->SetDefaultTerminalApps(pszApps);
|
||||
SafeFree(pszApps);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -48,7 +48,7 @@ LRESULT CSetPgEnvironment::OnInitDialog(HWND hDlg, bool abInitial)
|
||||
checkDlgButton(hDlg, cbAddConEmuBase2Path, (gpSet->ComSpec.AddConEmu2Path & CEAP_AddConEmuBaseDir) ? BST_CHECKED : BST_UNCHECKED);
|
||||
checkDlgButton(hDlg, cbAutoReloadEnvironment, (gpSet->AutoReloadEnvironment) ? BST_CHECKED : BST_UNCHECKED);
|
||||
|
||||
SetDlgItemText(hDlg, tSetCommands, gpSet->psEnvironmentSet ? gpSet->psEnvironmentSet : L"");
|
||||
SetDlgItemText(hDlg, tSetCommands, gpSet->psEnvironmentSet ? gpSet->psEnvironmentSet->c_str(L"") : L"");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -59,8 +59,9 @@ LRESULT CSetPgEnvironment::OnEditChanged(HWND hDlg, WORD nCtrlId)
|
||||
{
|
||||
case tSetCommands:
|
||||
{
|
||||
size_t cchMax = gpSet->psEnvironmentSet ? (_tcslen(gpSet->psEnvironmentSet)+1) : 0;
|
||||
MyGetDlgItemText(hDlg, tSetCommands, cchMax, gpSet->psEnvironmentSet);
|
||||
if (!gpSet->psEnvironmentSet)
|
||||
gpSet->psEnvironmentSet = new CEStr();
|
||||
MyGetDlgItemText(hDlg, tSetCommands, *gpSet->psEnvironmentSet);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -112,7 +112,7 @@ LRESULT CSetPgFeatures::OnEditChanged(HWND hDlg, WORD nCtrlId)
|
||||
{
|
||||
case tAnsiLogPath:
|
||||
SafeFree(gpSet->pszAnsiLog);
|
||||
gpSet->pszAnsiLog = GetDlgItemTextPtr(hDlg, tAnsiLogPath);
|
||||
gpSet->pszAnsiLog = GetDlgItemTextPtr(hDlg, tAnsiLogPath).Detach();
|
||||
break;
|
||||
|
||||
case tDebugLogDir:
|
||||
|
@ -120,7 +120,7 @@ LRESULT CSetPgFonts::OnInitDialog(HWND hDlg, bool abInitial)
|
||||
L"CJK: 2E80-9FC3;AC00-D7A3;F900-FAFF;FE30-FE4F;FF01-FF60;FFE0-FFE6;",
|
||||
nullptr
|
||||
};
|
||||
CEStr szCharRanges(gpSet->CreateCharRanges(gpSet->mpc_CharAltFontRanges));
|
||||
const CEStr szCharRanges(gpSet->CreateCharRanges(gpSet->mpc_CharAltFontRanges));
|
||||
LPCWSTR pszCurrentRange = szCharRanges.ms_Val;
|
||||
bool bExist = false;
|
||||
|
||||
|
@ -302,7 +302,7 @@ struct SwitchParser
|
||||
_ASSERTE(ps && !ps->switch_.IsEmpty());
|
||||
const bool bOpt = !ps->opt_.IsEmpty();
|
||||
const bool bQuot = (bOpt && IsQuotationNeeded(ps->opt_));
|
||||
lstrmerge(&rsReady.ms_Val,
|
||||
rsReady.Append(
|
||||
ps->switch_,
|
||||
bOpt ? L" " : nullptr,
|
||||
bQuot ? L"\"" : nullptr,
|
||||
@ -313,7 +313,7 @@ struct SwitchParser
|
||||
if (!rsReady.IsEmpty() || cmdList_)
|
||||
{
|
||||
// Add "-run" without command to depict we run ConEmu "as default"
|
||||
lstrmerge(&rsReady.ms_Val,
|
||||
rsReady.Append(
|
||||
cmdList_ ? L"-RunList " : L"-run ", cmd_);
|
||||
}
|
||||
else
|
||||
@ -343,9 +343,9 @@ LRESULT CSetPgIntegr::OnInitDialog(HWND hDlg, bool abInitial)
|
||||
ReloadHereList(&iHere, &iInside);
|
||||
|
||||
// Возвращает nullptr, если строка пустая
|
||||
wchar_t* pszCurInside = GetDlgItemTextPtr(hDlg, cbInsideName);
|
||||
CEStr pszCurInside = GetDlgItemTextPtr(hDlg, cbInsideName);
|
||||
_ASSERTE((pszCurInside==nullptr) || (*pszCurInside!=0));
|
||||
wchar_t* pszCurHere = GetDlgItemTextPtr(hDlg, cbHereName);
|
||||
CEStr pszCurHere = GetDlgItemTextPtr(hDlg, cbHereName);
|
||||
_ASSERTE((pszCurHere==nullptr) || (*pszCurHere!=0));
|
||||
|
||||
wchar_t szIcon[MAX_PATH+32];
|
||||
@ -378,9 +378,6 @@ LRESULT CSetPgIntegr::OnInitDialog(HWND hDlg, bool abInitial)
|
||||
SetDlgItemText(hDlg, tHereIcon, szIcon);
|
||||
}
|
||||
|
||||
SafeFree(pszCurInside);
|
||||
SafeFree(pszCurHere);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -698,7 +695,7 @@ void CSetPgIntegr::UnregisterShellInvalids()
|
||||
//LPCWSTR pszInside = StrStrI(szCmd, L"-inside");
|
||||
const LPCWSTR pszConEmu = StrStrI(szCmd, L"conemu");
|
||||
if (pszConEmu)
|
||||
lsNames.push_back(lstrdup(szName));
|
||||
lsNames.push_back(lstrdup(szName).Detach());
|
||||
else
|
||||
iOthers++;
|
||||
}
|
||||
@ -798,10 +795,10 @@ bool CSetPgIntegr::ReloadHereList(int* pnHere /*= nullptr*/, int* pnInside /*= n
|
||||
int iTotalCount = 0;
|
||||
|
||||
// Возвращает nullptr, если строка пустая
|
||||
wchar_t* pszCurInside = GetDlgItemTextPtr(mh_Dlg, cbInsideName);
|
||||
_ASSERTE((pszCurInside==nullptr) || (*pszCurInside!=0));
|
||||
wchar_t* pszCurHere = GetDlgItemTextPtr(mh_Dlg, cbHereName);
|
||||
_ASSERTE((pszCurHere==nullptr) || (*pszCurHere!=0));
|
||||
CEStr pszCurInside = GetDlgItemTextPtr(mh_Dlg, cbInsideName);
|
||||
_ASSERTE(pszCurInside.IsNull() || !pszCurInside.IsEmpty());
|
||||
CEStr pszCurHere = GetDlgItemTextPtr(mh_Dlg, cbHereName);
|
||||
_ASSERTE(pszCurHere.IsNull() || !pszCurHere.IsEmpty());
|
||||
|
||||
MSetter lSkip(&mb_SkipSelChange);
|
||||
|
||||
@ -858,12 +855,12 @@ bool CSetPgIntegr::ReloadHereList(int* pnHere /*= nullptr*/, int* pnInside /*= n
|
||||
const UINT nListID = bHasInside ? cbInsideName : cbHereName;
|
||||
SendDlgItemMessage(mh_Dlg, nListID, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(szName));
|
||||
|
||||
if ((bHasInside ? pszCurInside : pszCurHere) == nullptr)
|
||||
if ((bHasInside ? pszCurInside.IsEmpty() : pszCurHere.IsEmpty()))
|
||||
{
|
||||
if (bHasInside)
|
||||
pszCurInside = lstrdup(szName);
|
||||
pszCurInside.Set(szName);
|
||||
else
|
||||
pszCurHere = lstrdup(szName);
|
||||
pszCurHere.Set(szName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -881,9 +878,6 @@ bool CSetPgIntegr::ReloadHereList(int* pnHere /*= nullptr*/, int* pnInside /*= n
|
||||
if (pszCurHere && *pszCurHere)
|
||||
CSetDlgLists::SelectStringExact(mh_Dlg, cbHereName, pszCurHere);
|
||||
|
||||
SafeFree(pszCurInside);
|
||||
SafeFree(pszCurHere);
|
||||
|
||||
free(pszCmd);
|
||||
|
||||
return (iTotalCount > 0);
|
||||
|
@ -71,7 +71,6 @@ LRESULT CSetPgKeys::OnInitDialog(HWND hDlg, bool abInitial)
|
||||
for (INT_PTR i = gpHotKeys->size() - 1; i >= 0; i--)
|
||||
{
|
||||
ConEmuHotKey* p = &((*gpHotKeys)[i]);
|
||||
p->cchGuiMacroMax = p->GuiMacro ? (wcslen(p->GuiMacro)+1) : 0;
|
||||
}
|
||||
|
||||
HWND hList = GetDlgItem(hDlg, lbConEmuHotKeys);
|
||||
@ -650,7 +649,9 @@ LRESULT CSetPgKeys::OnEditChanged(HWND hDlg, WORD nCtrlId)
|
||||
case tGuiMacro:
|
||||
if (mp_ActiveHotKey && (mp_ActiveHotKey->HkType == chk_Macro))
|
||||
{
|
||||
MyGetDlgItemText(hDlg, tGuiMacro, mp_ActiveHotKey->cchGuiMacroMax, mp_ActiveHotKey->GuiMacro);
|
||||
CEStr macro;
|
||||
MyGetDlgItemText(hDlg, tGuiMacro, macro);
|
||||
macro.Swap(mp_ActiveHotKey->GuiMacro);
|
||||
FillHotKeysList(hDlg, false);
|
||||
}
|
||||
break;
|
||||
|
@ -51,9 +51,9 @@ CSetPgMarkCopy::~CSetPgMarkCopy()
|
||||
LRESULT CSetPgMarkCopy::OnInitDialog(HWND hDlg, bool abInitial)
|
||||
{
|
||||
checkDlgButton(hDlg, cbCTSIntelligent, gpSet->isCTSIntelligent);
|
||||
wchar_t* pszExcept = gpSet->GetIntelligentExceptions();
|
||||
CEStr pszExcept = gpSet->GetIntelligentExceptions();
|
||||
SetDlgItemText(hDlg, tCTSIntelligentExceptions, pszExcept ? pszExcept : L"");
|
||||
SafeFree(pszExcept);
|
||||
pszExcept.Release();
|
||||
|
||||
checkDlgButton(hDlg, cbCTSAutoCopy, gpSet->isCTSAutoCopy);
|
||||
checkDlgButton(hDlg, cbCTSResetOnRelease, (gpSet->isCTSResetOnRelease && gpSet->isCTSAutoCopy));
|
||||
@ -232,9 +232,8 @@ LRESULT CSetPgMarkCopy::OnEditChanged(HWND hDlg, WORD nCtrlId)
|
||||
case tCTSIntelligentExceptions:
|
||||
// *** Console text selections - intelligent exclusions ***
|
||||
{
|
||||
wchar_t* pszApps = GetDlgItemTextPtr(hDlg, tCTSIntelligentExceptions);
|
||||
const CEStr pszApps = GetDlgItemTextPtr(hDlg, tCTSIntelligentExceptions);
|
||||
gpSet->SetIntelligentExceptions(pszApps);
|
||||
SafeFree(pszApps);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -182,10 +182,9 @@ LRESULT CSetPgSizePos::OnEditChanged(HWND hDlg, WORD nCtrlId)
|
||||
case tWndY:
|
||||
if (isChecked(hDlg, rNormal) == BST_CHECKED)
|
||||
{
|
||||
wchar_t *pVal = GetDlgItemTextPtr(hDlg, nCtrlId);
|
||||
bool bValid = (pVal && (isDigit(pVal[0]) || (pVal[0]==L'-' && isDigit(pVal[1]))));
|
||||
const CEStr pVal = GetDlgItemTextPtr(hDlg, nCtrlId);
|
||||
const bool bValid = (pVal && (isDigit(pVal[0]) || (pVal[0]==L'-' && isDigit(pVal[1]))));
|
||||
enableDlgItem(hDlg, cbApplyPos, bValid);
|
||||
SafeFree(pVal);
|
||||
}
|
||||
break; // case tWndX: case tWndY:
|
||||
case tWndWidth:
|
||||
@ -193,10 +192,9 @@ LRESULT CSetPgSizePos::OnEditChanged(HWND hDlg, WORD nCtrlId)
|
||||
if (isChecked(hDlg, rNormal) == BST_CHECKED)
|
||||
{
|
||||
CESize sz = {0};
|
||||
wchar_t *pVal = GetDlgItemTextPtr(hDlg, nCtrlId);
|
||||
bool bValid = (pVal && sz.SetFromString(false, pVal));
|
||||
const CEStr pVal = GetDlgItemTextPtr(hDlg, nCtrlId);
|
||||
const bool bValid = (pVal && sz.SetFromString(false, pVal));
|
||||
enableDlgItem(hDlg, cbApplyPos, bValid);
|
||||
SafeFree(pVal);
|
||||
}
|
||||
break; // case tWndWidth: case tWndHeight:
|
||||
|
||||
|
@ -157,12 +157,11 @@ INT_PTR CSetPgStartup::PageDlgProc(HWND hDlg, UINT messg, WPARAM wParam, LPARAM
|
||||
pszTitle = L"Choose command file";
|
||||
}
|
||||
|
||||
wchar_t* pszRet = SelectFile(pszTitle, temp, nullptr, ghOpWnd, pszFilter, (CB==cbCmdLine)?sff_AutoQuote:sff_Default);
|
||||
const CEStr pszRet = SelectFile(pszTitle, temp, nullptr, ghOpWnd, pszFilter, (CB == cbCmdLine) ? sff_AutoQuote : sff_Default);
|
||||
|
||||
if (pszRet)
|
||||
{
|
||||
SetDlgItemText(hDlg, (CB==cbCmdLine)?tCmdLine:tStartTasksFile, pszRet);
|
||||
SafeFree(pszRet);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -188,7 +188,7 @@ LRESULT CSetPgTabs::OnEditChanged(HWND hDlg, WORD nCtrlId)
|
||||
case tTabSkipWords:
|
||||
{
|
||||
SafeFree(gpSet->pszTabSkipWords);
|
||||
gpSet->pszTabSkipWords = GetDlgItemTextPtr(hDlg, nCtrlId);
|
||||
gpSet->pszTabSkipWords = GetDlgItemTextPtr(hDlg, nCtrlId).Detach();
|
||||
gpConEmu->mp_TabBar->Update(TRUE);
|
||||
break;
|
||||
}
|
||||
|
@ -186,11 +186,10 @@ INT_PTR CSetPgTasks::OnComboBox(HWND hWnd2, WORD nCtrlId, WORD code)
|
||||
if (pCmd)
|
||||
{
|
||||
_ASSERTE(pCmd->pszName);
|
||||
wchar_t* pszNoBrk = lstrdup(!pCmd->pszName ? L"" : (pCmd->pszName[0] != TaskBracketLeft) ? pCmd->pszName : (pCmd->pszName+1));
|
||||
if (*pszNoBrk && (pszNoBrk[_tcslen(pszNoBrk)-1] == TaskBracketRight))
|
||||
pszNoBrk[_tcslen(pszNoBrk)-1] = 0;
|
||||
CEStr pszNoBrk(!pCmd->pszName ? L"" : (pCmd->pszName[0] != TaskBracketLeft) ? pCmd->pszName : (pCmd->pszName+1));
|
||||
if (!pszNoBrk.IsEmpty() && (pszNoBrk[pszNoBrk.GetLen() - 1] == TaskBracketRight))
|
||||
pszNoBrk.SetAt(pszNoBrk.GetLen() - 1, 0);
|
||||
SetDlgItemText(hWnd2, tCmdGroupName, pszNoBrk);
|
||||
SafeFree(pszNoBrk);
|
||||
|
||||
wchar_t szKey[128] = L"";
|
||||
SetDlgItemText(hWnd2, tCmdGroupKey, pCmd->HotKey.GetHotkeyName(szKey));
|
||||
|
@ -33,8 +33,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
struct FindTextOptions
|
||||
{
|
||||
size_t cchTextMax;
|
||||
wchar_t* pszText;
|
||||
CEStr text;
|
||||
bool bMatchCase;
|
||||
bool bMatchWholeWords;
|
||||
bool bFreezeConsole;
|
||||
|
@ -401,7 +401,7 @@ bool SettingsINI::OpenKey(const wchar_t *regPath, unsigned access, BOOL abSilent
|
||||
|
||||
CloseHandle(hFile);
|
||||
|
||||
wchar_t* pszDup = lstrdup(regPath);
|
||||
wchar_t* pszDup = CEStr(regPath).Detach();
|
||||
if (!pszDup)
|
||||
{
|
||||
mpsz_IniFile = nullptr;
|
||||
@ -637,13 +637,12 @@ const char* SettingsXML::wcs2utf(const wchar_t* wc, CEStrA& str)
|
||||
{
|
||||
str.Release();
|
||||
int ucLen = WideCharToMultiByte(CP_UTF8, 0, wc, -1, nullptr, 0, nullptr, nullptr);
|
||||
str = static_cast<char*>(malloc(ucLen));
|
||||
if (!str.ms_Val)
|
||||
if (!str.GetBuffer(ucLen))
|
||||
{
|
||||
_ASSERTE(str.ms_Val!=nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
ucLen = WideCharToMultiByte(CP_UTF8, 0, wc, -1, str.ms_Val, ucLen, nullptr, nullptr);
|
||||
ucLen = WideCharToMultiByte(CP_UTF8, 0, wc, -1, str.data(), ucLen, nullptr, nullptr);
|
||||
if (ucLen <= 0)
|
||||
{
|
||||
_ASSERTE(ucLen > 0);
|
||||
@ -679,7 +678,7 @@ const char* SettingsXML::wcs2utf(const wchar_t* wc) const
|
||||
return allocated;
|
||||
}
|
||||
|
||||
bool SettingsXML::OpenStorage(unsigned access, wchar_t*& pszErr)
|
||||
bool SettingsXML::OpenStorage(unsigned access, CEStr& pszErr)
|
||||
{
|
||||
bool bRc = false;
|
||||
bool bNeedReopen = (mp_File == nullptr);
|
||||
@ -781,7 +780,7 @@ bool SettingsXML::OpenStorage(unsigned access, wchar_t*& pszErr)
|
||||
|
||||
{
|
||||
_ASSERTE(mp_File == nullptr);
|
||||
_ASSERTE(mp_Utf8Data == nullptr);
|
||||
_ASSERTE(mp_Utf8Data.data() == nullptr);
|
||||
|
||||
DWORD cchChars = 0, nErrCode = 0;
|
||||
if (ReadTextFile(pszXmlFile, static_cast<DWORD>(-1), mp_Utf8Data, cchChars, nErrCode) < 0)
|
||||
@ -792,7 +791,7 @@ bool SettingsXML::OpenStorage(unsigned access, wchar_t*& pszErr)
|
||||
try
|
||||
{
|
||||
mp_File = new document;
|
||||
mp_File->parse<parse_declaration_node|parse_comment_nodes>(mp_Utf8Data);
|
||||
mp_File->parse<parse_declaration_node|parse_comment_nodes>(mp_Utf8Data.data());
|
||||
// <?xml version="1.0" encoding="utf-8"?>
|
||||
node* decl = mp_File->first_node();
|
||||
if (!decl || (decl->type() != node_declaration))
|
||||
@ -808,7 +807,7 @@ bool SettingsXML::OpenStorage(unsigned access, wchar_t*& pszErr)
|
||||
catch (rapidxml::parse_error& e)
|
||||
{
|
||||
CEStr lsWhat, lsWhere;
|
||||
pszErr = lstrmerge(
|
||||
pszErr = CEStr(
|
||||
L"Exception in SettingsXML::OpenStorage\r\n",
|
||||
((access & KEY_WRITE) != KEY_WRITE)
|
||||
? L"Failed to load configuration file!\r\n"
|
||||
@ -831,7 +830,7 @@ bool SettingsXML::OpenKey(const wchar_t *regPath, unsigned access, BOOL abSilent
|
||||
_ASSERTE(!gpConEmu->IsResetBasicSettings() || ((access & KEY_WRITE)!=KEY_WRITE));
|
||||
|
||||
bool lbRc = false;
|
||||
wchar_t* pszErr = nullptr;
|
||||
CEStr pszErr = nullptr;
|
||||
wchar_t szName[MAX_PATH];
|
||||
const wchar_t* psz = nullptr;
|
||||
SettingsXML::node* pKey = nullptr;
|
||||
@ -858,7 +857,7 @@ bool SettingsXML::OpenKey(const wchar_t *regPath, unsigned access, BOOL abSilent
|
||||
if (!pKey)
|
||||
{
|
||||
const wchar_t szRootError[] = L"XML: Root node not found!";
|
||||
pszErr = lstrmerge(szRootError, m_Storage.File, L"\r\n", regPath);
|
||||
pszErr = CEStr(szRootError, m_Storage.File, L"\r\n", regPath);
|
||||
goto wrap;
|
||||
}
|
||||
|
||||
@ -867,7 +866,8 @@ bool SettingsXML::OpenKey(const wchar_t *regPath, unsigned access, BOOL abSilent
|
||||
// Получить следующий токен
|
||||
psz = wcschr(regPath, L'\\');
|
||||
|
||||
if (!psz) psz = regPath + _tcslen(regPath);
|
||||
if (!psz)
|
||||
psz = regPath + _tcslen(regPath);
|
||||
|
||||
lstrcpyn(szName, regPath, psz-regPath+1);
|
||||
// Найти в структуре XML
|
||||
@ -877,13 +877,13 @@ bool SettingsXML::OpenKey(const wchar_t *regPath, unsigned access, BOOL abSilent
|
||||
{
|
||||
if (bAllowCreate)
|
||||
{
|
||||
pszErr = lstrmerge(L"XML: Can't create key <", szName, L">!");
|
||||
pszErr = CEStr(L"XML: Can't create key <", szName, L">!");
|
||||
}
|
||||
else
|
||||
{
|
||||
//swprintf_c(szErr, L"XML: key <%s> not found!", szName);
|
||||
// Don't show error - use default settings
|
||||
SafeFree(pszErr);
|
||||
pszErr.Release();
|
||||
}
|
||||
|
||||
goto wrap;
|
||||
@ -908,20 +908,19 @@ bool SettingsXML::OpenKey(const wchar_t *regPath, unsigned access, BOOL abSilent
|
||||
catch (rapidxml::parse_error& e)
|
||||
{
|
||||
CEStr lsWhat, lsWhere;
|
||||
pszErr = lstrmerge(L"Exception in SettingsXML::OpenKey\r\n", m_Storage.File,
|
||||
pszErr = CEStr(L"Exception in SettingsXML::OpenKey\r\n", m_Storage.File,
|
||||
L"\r\n", regPath, L"\r\n",
|
||||
utf2wcs(e.what(), lsWhat), L"\r\n", utf2wcs(e.where<char>(), lsWhere));
|
||||
lbRc = false;
|
||||
}
|
||||
|
||||
wrap:
|
||||
if (!lbRc && (pszErr && *pszErr) && !abSilent)
|
||||
if (!lbRc && !pszErr.IsEmpty() && !abSilent)
|
||||
{
|
||||
// Don't show error message box as a child of ghWnd
|
||||
// otherwise it may be closed unexpectedly on exit
|
||||
MsgBox(pszErr, MB_ICONSTOP, nullptr, nullptr);
|
||||
}
|
||||
SafeFree(pszErr);
|
||||
|
||||
return lbRc;
|
||||
}
|
||||
@ -1031,7 +1030,7 @@ void SettingsXML::CloseStorage() noexcept
|
||||
}
|
||||
}
|
||||
|
||||
SafeFree(mp_Utf8Data);
|
||||
mp_Utf8Data.Release();
|
||||
|
||||
SafeDelete(mp_File);
|
||||
|
||||
|
@ -203,7 +203,7 @@ struct SettingsXML : public SettingsBase
|
||||
using document = rapidxml::xml_document<char>;
|
||||
using node = rapidxml::xml_node<char>;
|
||||
using attribute = rapidxml::xml_attribute<char>;
|
||||
char* mp_Utf8Data = nullptr;
|
||||
CEStrA mp_Utf8Data = nullptr;
|
||||
document* mp_File = nullptr;
|
||||
node* mp_Key = nullptr;
|
||||
bool mb_Modified = false; // Save was called at least once (data may be or may be not changed)
|
||||
@ -228,7 +228,7 @@ struct SettingsXML : public SettingsBase
|
||||
protected:
|
||||
void SetDataChanged();
|
||||
|
||||
bool OpenStorage(unsigned access, wchar_t*& pszErr);
|
||||
bool OpenStorage(unsigned access, CEStr& pszErr);
|
||||
void CloseStorage() noexcept;
|
||||
void TouchKey(node* apKey) noexcept;
|
||||
|
||||
|
@ -31,7 +31,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#define SHOWDEBUGSTR
|
||||
|
||||
#define DEBUGSTRTABS(l,i,s) // { wchar_t szLbl[80]; swprintf_c(szLbl, L"CTabPanelWin(%s,%i): ",l,i+1); wchar_t* pszDbg = lstrmerge(szLbl,s); DEBUGSTR(pszDbg); SafeFree(pszDbg); }
|
||||
#define DEBUGSTRTABS(l,i,s) // { wchar_t szLbl[80]; swprintf_c(szLbl, L"CTabPanelWin(%s,%i): ",l,i+1); wchar_t* pszDbg = CEStr(szLbl,s); DEBUGSTR(pszDbg); SafeFree(pszDbg); }
|
||||
#define DEBUGSTRSEL(s) //DEBUGSTR(s)
|
||||
#define DEBUGSTRSIZE(s) //DEBUGSTR(s)
|
||||
#define DEBUGSTRPANE(s) //DEBUGSTR(s)
|
||||
|
@ -99,6 +99,7 @@ bool TempFile::CreateTempFile(LPCWSTR asDir, LPCWSTR asFileNameTempl, ErrorInfo&
|
||||
{
|
||||
szDir.Set(asDir);
|
||||
}
|
||||
szDir.Append(L"\\");
|
||||
|
||||
// Checking %TEMP% for valid path
|
||||
ValidatePath(szDir, asDir);
|
||||
@ -146,7 +147,7 @@ bool TempFile::CreateTempFile(LPCWSTR asDir, LPCWSTR asFileNameTempl, ErrorInfo&
|
||||
fileHandle_.SetHandle(
|
||||
CreateFileW(path_, GENERIC_WRITE, FILE_SHARE_READ, &sec, CREATE_NEW, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_TEMPORARY, nullptr),
|
||||
MHandle::CloseHandle);
|
||||
if (!fileHandle_)
|
||||
if (!fileHandle_.HasHandle())
|
||||
{
|
||||
dwErr = GetLastError();
|
||||
if ((dwErr == ERROR_PATH_NOT_FOUND) && (i == 0))
|
||||
|
@ -99,7 +99,7 @@ void ConEmuUpdateSettings::SetUpdateVerLocation(LPCWSTR asNewIniLocation)
|
||||
if (asNewIniLocation && *asNewIniLocation
|
||||
&& !IsVerLocationDeprecated(asNewIniLocation))
|
||||
{
|
||||
szUpdateVerLocation = lstrdup(asNewIniLocation);
|
||||
szUpdateVerLocation = lstrdup(asNewIniLocation).Detach();
|
||||
}
|
||||
|
||||
if (gpSetCls && ghOpWnd)
|
||||
@ -136,7 +136,7 @@ void ConEmuUpdateSettings::ResetToDefaults()
|
||||
isSetupDetected = 0; // 0-пока не проверялся, 1-установлено через Installer, пути совпали, 2-Installer не запускался
|
||||
isSetup64 = WIN3264TEST(false,true); // определяется вместе с isSetupDetected
|
||||
|
||||
szUpdateExeCmdLineDef = lstrdup(L"\"%1\" /p:%3 /qr");
|
||||
szUpdateExeCmdLineDef = lstrdup(L"\"%1\" /p:%3 /qr").Detach();
|
||||
SafeFree(szUpdateExeCmdLine);
|
||||
|
||||
bool bWinRar = false;
|
||||
@ -195,7 +195,8 @@ void ConEmuUpdateSettings::ResetToDefaults()
|
||||
}
|
||||
if (!pszArcPath || !*pszArcPath)
|
||||
{
|
||||
szUpdateArcCmdLineDef = lstrdup(L"\"%ProgramFiles%\\7-Zip\\7zg.exe\" x -y \"%1\""); // "%1"-archive file, "%2"-ConEmu base dir
|
||||
// "%1"-archive file, "%2"-ConEmu base dir
|
||||
szUpdateArcCmdLineDef = lstrdup(L"\"%ProgramFiles%\\7-Zip\\7zg.exe\" x -y \"%1\"").Detach();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -223,9 +224,10 @@ void ConEmuUpdateSettings::ResetToDefaults()
|
||||
SafeFree(pszArcPath);
|
||||
SafeFree(szUpdateArcCmdLine);
|
||||
|
||||
szUpdateDownloadPath = lstrdup(L"%TEMP%\\ConEmu");
|
||||
szUpdateDownloadPath = lstrdup(L"%TEMP%\\ConEmu").Detach();
|
||||
isUpdateLeavePackages = false;
|
||||
szUpdatePostUpdateCmd = lstrdup(L"echo Last successful update>ConEmuUpdate.info && date /t>>ConEmuUpdate.info && time /t>>ConEmuUpdate.info"); // Юзер может чего-то свое делать с распакованными файлами
|
||||
// The example how to apply something over updated installation
|
||||
szUpdatePostUpdateCmd = lstrdup(L"echo Last successful update>ConEmuUpdate.info && date /t>>ConEmuUpdate.info && time /t>>ConEmuUpdate.info").Detach();
|
||||
}
|
||||
|
||||
ConEmuUpdateSettings::~ConEmuUpdateSettings()
|
||||
@ -256,28 +258,29 @@ void ConEmuUpdateSettings::LoadFrom(ConEmuUpdateSettings* apFrom)
|
||||
{
|
||||
FreePointers();
|
||||
|
||||
szUpdateVerLocation = (apFrom->szUpdateVerLocation && *apFrom->szUpdateVerLocation) ? lstrdup(apFrom->szUpdateVerLocation) : nullptr; // ConEmu latest version location info
|
||||
szUpdateVerLocation = (apFrom->szUpdateVerLocation && *apFrom->szUpdateVerLocation)
|
||||
? lstrdup(apFrom->szUpdateVerLocation).Detach() : nullptr; // ConEmu latest version location info
|
||||
isUpdateCheckOnStartup = apFrom->isUpdateCheckOnStartup;
|
||||
isUpdateCheckHourly = apFrom->isUpdateCheckHourly;
|
||||
isUpdateConfirmDownload = apFrom->isUpdateConfirmDownload;
|
||||
isUpdateUseBuilds = (apFrom->isUpdateUseBuilds >= Builds::Stable && apFrom->isUpdateUseBuilds <= Builds::Preview)
|
||||
? apFrom->isUpdateUseBuilds : GetDefaultUpdateChannel();
|
||||
isUpdateInetTool = apFrom->isUpdateInetTool;
|
||||
szUpdateInetTool = lstrdup(apFrom->szUpdateInetTool);
|
||||
szUpdateInetTool = lstrdup(apFrom->szUpdateInetTool).Detach();
|
||||
isUpdateUseProxy = apFrom->isUpdateUseProxy;
|
||||
szUpdateProxy = lstrdup(apFrom->szUpdateProxy); // "Server:port"
|
||||
szUpdateProxyUser = lstrdup(apFrom->szUpdateProxyUser);
|
||||
szUpdateProxyPassword = lstrdup(apFrom->szUpdateProxyPassword);
|
||||
szUpdateProxy = lstrdup(apFrom->szUpdateProxy).Detach(); // "Server:port"
|
||||
szUpdateProxyUser = lstrdup(apFrom->szUpdateProxyUser).Detach();
|
||||
szUpdateProxyPassword = lstrdup(apFrom->szUpdateProxyPassword).Detach();
|
||||
isUpdateDownloadSetup = apFrom->isUpdateDownloadSetup; // 0-Auto, 1-Installer (ConEmuSetup.exe), 2-7z archive (ConEmu.7z), WinRar or 7z required
|
||||
isSetupDetected = apFrom->isSetupDetected;
|
||||
// "%1"-archive or setup file, "%2"-ConEmu base dir, "%3"-x86/x64, "%4"-ConEmu PID
|
||||
szUpdateExeCmdLine = lstrdup(apFrom->szUpdateExeCmdLine);
|
||||
szUpdateExeCmdLineDef = lstrdup(apFrom->szUpdateExeCmdLineDef);
|
||||
szUpdateArcCmdLine = lstrdup(apFrom->szUpdateArcCmdLine);
|
||||
szUpdateArcCmdLineDef = lstrdup(apFrom->szUpdateArcCmdLineDef);
|
||||
szUpdateDownloadPath = lstrdup(apFrom->szUpdateDownloadPath); // "%TEMP%"
|
||||
szUpdateExeCmdLine = lstrdup(apFrom->szUpdateExeCmdLine).Detach();
|
||||
szUpdateExeCmdLineDef = lstrdup(apFrom->szUpdateExeCmdLineDef).Detach();
|
||||
szUpdateArcCmdLine = lstrdup(apFrom->szUpdateArcCmdLine).Detach();
|
||||
szUpdateArcCmdLineDef = lstrdup(apFrom->szUpdateArcCmdLineDef).Detach();
|
||||
szUpdateDownloadPath = lstrdup(apFrom->szUpdateDownloadPath).Detach(); // "%TEMP%"
|
||||
isUpdateLeavePackages = apFrom->isUpdateLeavePackages;
|
||||
szUpdatePostUpdateCmd = lstrdup(apFrom->szUpdatePostUpdateCmd); // Юзер может чего-то свое делать с распакованными файлами
|
||||
szUpdatePostUpdateCmd = lstrdup(apFrom->szUpdatePostUpdateCmd).Detach(); // User may apply something over updated installation
|
||||
}
|
||||
|
||||
bool ConEmuUpdateSettings::UpdatesAllowed(wchar_t (&szReason)[128])
|
||||
|
@ -1560,7 +1560,7 @@ bool CVConGroup::isFar(bool abPluginRequired/*=false*/)
|
||||
|
||||
// Если ли фар где-то?
|
||||
// Return "1-based"(!) value. 1 - Far Panels (or console), 2,3,... - Far Editor/Viewer windows
|
||||
int CVConGroup::isFarExist(CEFarWindowType anWindowType/*=fwt_Any*/, LPWSTR asName/*=nullptr*/, CVConGuard* rpVCon/*=nullptr*/)
|
||||
int CVConGroup::isFarExist(CEFarWindowType anWindowType/*=fwt_Any*/, const wchar_t* asName/*=nullptr*/, CVConGuard* rpVCon/*=nullptr*/)
|
||||
{
|
||||
int iFound = 0;
|
||||
bool lbLocked = false;
|
||||
@ -1661,7 +1661,7 @@ int CVConGroup::isFarExist(CEFarWindowType anWindowType/*=fwt_Any*/, LPWSTR asNa
|
||||
if (asName && *asName)
|
||||
{
|
||||
// Note. Для панелей - тут пустая строка
|
||||
LPCWSTR tabName = tab->Name.Ptr();
|
||||
const wchar_t* tabName = tab->Name.Ptr();
|
||||
if (lstrcmpi(tabName, asName) == 0)
|
||||
{
|
||||
iFound = (j+1);
|
||||
@ -3585,7 +3585,7 @@ BOOL CVConGroup::AttachRequested(HWND ahConWnd, const CESERVER_REQ_STARTSTOP* pS
|
||||
impl.pArgs->BackgroundTab = pStartStop->bRunInBackgroundTab ? crb_On : crb_Undefined;
|
||||
impl.pArgs->RunAsAdministrator = pStartStop->bUserIsAdmin ? crb_On : crb_Undefined;
|
||||
_ASSERTE(pStartStop->sCmdLine[0]!=0);
|
||||
impl.pArgs->pszSpecialCmd = lstrdup(pStartStop->sCmdLine);
|
||||
impl.pArgs->pszSpecialCmd = lstrdup(pStartStop->sCmdLine).Detach();
|
||||
|
||||
if (gpConEmu->isIconic())
|
||||
{
|
||||
@ -4268,12 +4268,12 @@ CVirtualConsole* CVConGroup::CreateCon(RConStartArgsEx& args, bool abAllowScript
|
||||
}
|
||||
|
||||
_ASSERTE(args.pszSpecialCmd == nullptr);
|
||||
args.pszSpecialCmd = lstrdup(pszSysCmd);
|
||||
args.pszSpecialCmd = lstrdup(pszSysCmd).Detach();
|
||||
|
||||
if (pszSysDir)
|
||||
{
|
||||
_ASSERTE(args.pszStartupDir==nullptr);
|
||||
args.pszStartupDir = lstrdup(pszSysDir);
|
||||
args.pszStartupDir = lstrdup(pszSysDir).Detach();
|
||||
}
|
||||
|
||||
_ASSERTE(args.pszSpecialCmd && *args.pszSpecialCmd);
|
||||
@ -5944,8 +5944,9 @@ void CVConGroup::PopulateSplitPanes(MArray<CVConGuard*>& VCons) const
|
||||
}
|
||||
}
|
||||
|
||||
wchar_t* CVConGroup::GetTasks()
|
||||
CEStr CVConGroup::GetTasks()
|
||||
{
|
||||
CEStr result;
|
||||
wchar_t* pszAll = nullptr;
|
||||
wchar_t* pszTask[MAX_CONSOLE_COUNT] = {};
|
||||
size_t nTaskLen[MAX_CONSOLE_COUNT] = {};
|
||||
@ -5996,20 +5997,15 @@ wchar_t* CVConGroup::GetTasks()
|
||||
if (VCon->VCon() == gp_VActive)
|
||||
activeTask = t;
|
||||
|
||||
wchar_t* pszCmd = VCon->VCon()->RCon()->CreateCommandLine(true);
|
||||
CEStr pszCmd = VCon->VCon()->RCon()->CreateCommandLine(true);
|
||||
delete VCon;
|
||||
addVCon[i] = nullptr;
|
||||
|
||||
if (!pszCmd)
|
||||
if (pszCmd.IsEmpty())
|
||||
continue;
|
||||
if (!*pszCmd)
|
||||
{
|
||||
SafeFree(pszCmd);
|
||||
continue;
|
||||
}
|
||||
|
||||
size_t nLen = nTaskLen[t] = _tcslen(pszCmd);
|
||||
pszTask[t++] = pszCmd;
|
||||
const size_t nLen = nTaskLen[t] = _tcslen(pszCmd);
|
||||
pszTask[t++] = pszCmd.Detach();
|
||||
nAllLen += nLen + 6; // + "\r\n\r\n>*"
|
||||
}
|
||||
|
||||
@ -6020,7 +6016,7 @@ wchar_t* CVConGroup::GetTasks()
|
||||
|
||||
// Allocate memory for result Task
|
||||
nAllLen += 3;
|
||||
pszAll = (wchar_t*)malloc(nAllLen*sizeof(*pszAll));
|
||||
pszAll = result.GetBuffer(nAllLen);
|
||||
if (!pszAll)
|
||||
return nullptr;
|
||||
wchar_t* psz = pszAll;
|
||||
@ -6054,5 +6050,5 @@ wchar_t* CVConGroup::GetTasks()
|
||||
|
||||
_ASSERTE((psz > pszAll) && ((size_t)(psz - pszAll) < nAllLen));
|
||||
*psz = 0; // ASCIIZ
|
||||
return pszAll;
|
||||
return result;
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ public:
|
||||
static bool isEditor();
|
||||
static bool isViewer();
|
||||
static bool isFar(bool abPluginRequired=false);
|
||||
static int isFarExist(CEFarWindowType anWindowType=fwt_Any, LPWSTR asName=nullptr, CVConGuard* rpVCon=nullptr);
|
||||
static int isFarExist(CEFarWindowType anWindowType = fwt_Any, const wchar_t* asName = nullptr, CVConGuard* rpVCon = nullptr);
|
||||
static bool isVConHWND(HWND hChild, CVConGuard* rpVCon = nullptr);
|
||||
static bool isConsolePID(DWORD nPID);
|
||||
static DWORD GetFarPID(bool abPluginRequired = false);
|
||||
@ -265,7 +265,7 @@ public:
|
||||
|
||||
static RECT AllTextRect(SIZE* rpSplits = nullptr, bool abMinimal = false);
|
||||
|
||||
static wchar_t* GetTasks();
|
||||
static CEStr GetTasks();
|
||||
|
||||
//public:
|
||||
// bool ResizeConsoles(const RECT &rFrom, enum ConEmuRect tFrom);
|
||||
|
@ -2345,7 +2345,7 @@ void CVirtualConsole::SetSelfPalette(WORD wAttributes, WORD wPopupAttributes, co
|
||||
LPCWSTR pszExt = PointToExt(pszRootProcessName);
|
||||
if (!pszExt || (pszExt > pszRootProcessName))
|
||||
{
|
||||
lsPrefix = lstrmerge(L"#Attached:", pszRootProcessName);
|
||||
lsPrefix = CEStr(L"#Attached:", pszRootProcessName);
|
||||
wchar_t* pszDot = lsPrefix.ms_Val ? wcsrchr(lsPrefix.ms_Val, L'.') : nullptr;
|
||||
if (pszDot)
|
||||
{
|
||||
@ -2367,7 +2367,7 @@ void CVirtualConsole::SetSelfPalette(WORD wAttributes, WORD wPopupAttributes, co
|
||||
else
|
||||
{
|
||||
swprintf_c(szSuffix, L":%02i", i);
|
||||
szAutoName = lstrmerge(lsPrefix.IsEmpty() ? L"#Attached" : lsPrefix.ms_Val, szSuffix);
|
||||
szAutoName = CEStr(lsPrefix.IsEmpty() ? L"#Attached" : lsPrefix.ms_Val, szSuffix);
|
||||
}
|
||||
|
||||
if (gpSet->PaletteGetIndex(szAutoName) != -1)
|
||||
|
@ -267,10 +267,10 @@ LPCWSTR MakeWinPath(LPCWSTR asAnyPath, LPCWSTR pszMntPrefix, CEStr& szWinPath)
|
||||
return pszRc;
|
||||
}
|
||||
|
||||
wchar_t* MakeStraightSlashPath(LPCWSTR asWinPath)
|
||||
CEStr MakeStraightSlashPath(LPCWSTR asWinPath)
|
||||
{
|
||||
wchar_t* pszSlashed = lstrdup(asWinPath);
|
||||
wchar_t* p = wcschr(pszSlashed, L'\\');
|
||||
CEStr pszSlashed(asWinPath);
|
||||
wchar_t* p = wcschr(pszSlashed.data(), L'\\');
|
||||
while (p)
|
||||
{
|
||||
*p = L'/';
|
||||
|
@ -40,7 +40,7 @@ void initMainThread();
|
||||
|
||||
const wchar_t* DupCygwinPath(LPCWSTR asWinPath, bool bAutoQuote, LPCWSTR asMntPrefix, CEStr& path);
|
||||
LPCWSTR MakeWinPath(LPCWSTR asAnyPath, LPCWSTR pszMntPrefix, CEStr& szWinPath);
|
||||
wchar_t* MakeStraightSlashPath(LPCWSTR asWinPath);
|
||||
CEStr MakeStraightSlashPath(LPCWSTR asWinPath);
|
||||
bool FixDirEndSlash(wchar_t* rsPath);
|
||||
|
||||
bool isKey(DWORD wp,DWORD vk);
|
||||
|
@ -273,13 +273,11 @@ void ReportFail(LPCWSTR asInfo)
|
||||
wchar_t szTitle[128];
|
||||
swprintf_c(szTitle, L"ConEmuBg, PID=%u", GetCurrentProcessId());
|
||||
|
||||
wchar_t* pszErr = lstrmerge(asInfo,
|
||||
const CEStr pszErr(asInfo,
|
||||
L"\n" L"Config value: ", gsXmlConfigFile[0] ? gsXmlConfigFile : szDefaultXmlName,
|
||||
L"\n" L"Expanded: ", gpszXmlFile ? gpszXmlFile : L"<NULL>");
|
||||
|
||||
MessageBox(NULL, pszErr, szTitle, MB_ICONSTOP|MB_SYSTEMMODAL);
|
||||
|
||||
free(pszErr);
|
||||
MessageBox(nullptr, pszErr, szTitle, MB_ICONSTOP | MB_SYSTEMMODAL);
|
||||
}
|
||||
|
||||
bool WasXmlLoaded()
|
||||
@ -354,7 +352,7 @@ bool CheckXmlFile(bool abUpdateName /*= false*/)
|
||||
}
|
||||
if (gpszXmlFolder)
|
||||
free(gpszXmlFolder);
|
||||
gpszXmlFolder = lstrdup(gpszXmlFile);
|
||||
gpszXmlFolder = lstrdup(gpszXmlFile).Detach();
|
||||
if (gpszXmlFolder)
|
||||
{
|
||||
wchar_t* pszSlash = wcsrchr(gpszXmlFolder, L'\\');
|
||||
@ -1207,7 +1205,7 @@ int FillPanelParams(PaintBackgroundArg* pBk, BkPanelInfo *pPanel, DrawInfo *pDra
|
||||
ChunkInfo Panel = {ChunkInfo::ci_WindowPanels, ChunkInfo::ci_PanelNone};
|
||||
MSectionLockSimple CS;
|
||||
|
||||
LPWSTR pszFormat = lstrdup(pPanel->szFormat ? pPanel->szFormat : L"");
|
||||
CEStr pszFormat(pPanel->szFormat ? pPanel->szFormat : L"");
|
||||
size_t nMaxLen = lstrlen(pPanel->szCurDir ? pPanel->szCurDir : L"");
|
||||
LPWSTR pszPath = (wchar_t*)malloc((nMaxLen+2)*sizeof(*pszPath));
|
||||
_wcscpy_c(pszPath, nMaxLen+1, pPanel->szCurDir ? pPanel->szCurDir : L"");
|
||||
@ -1441,7 +1439,7 @@ int FillPanelParams(PaintBackgroundArg* pBk, BkPanelInfo *pPanel, DrawInfo *pDra
|
||||
}
|
||||
else if (lstrcmpi(pszAttrName, L"format") == 0)
|
||||
{
|
||||
if (!CompareNames(pszAttrValue, pszFormat))
|
||||
if (!CompareNames(pszAttrValue, pszFormat.data()))
|
||||
Test.CondFailed = TRUE;
|
||||
}
|
||||
}
|
||||
@ -1653,8 +1651,6 @@ int FillPanelParams(PaintBackgroundArg* pBk, BkPanelInfo *pPanel, DrawInfo *pDra
|
||||
wrap:
|
||||
if (pszPath)
|
||||
free(pszPath);
|
||||
if (pszFormat)
|
||||
free(pszFormat);
|
||||
return iFound;
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ protected:
|
||||
|
||||
void UpdateProgress();
|
||||
|
||||
void ReportMessage(CEDownloadCommand rm, LPCWSTR asFormat, CEDownloadArgType nextArgType = at_None, ...);
|
||||
void ReportMessage(CEDownloadCommand rm, LPCWSTR asFormat /*, CEDownloadArgType nextArgType = at_None, Value, ...*/...);
|
||||
|
||||
static VOID CALLBACK InetCallback(HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength);
|
||||
#if 0
|
||||
@ -298,11 +298,11 @@ void CDownloader::SetProxy(LPCWSTR asProxy, LPCWSTR asProxyUser, LPCWSTR asProxy
|
||||
SafeFree(m_Proxy.szProxyPassword);
|
||||
|
||||
if (asProxy)
|
||||
m_Proxy.szProxy = lstrdup(asProxy);
|
||||
m_Proxy.szProxy = lstrdup(asProxy).Detach();
|
||||
if (asProxyUser)
|
||||
m_Proxy.szProxyUser = lstrdup(asProxyUser);
|
||||
m_Proxy.szProxyUser = lstrdup(asProxyUser).Detach();
|
||||
if (asProxyPassword)
|
||||
m_Proxy.szProxyPassword = lstrdup(asProxyPassword);
|
||||
m_Proxy.szProxyPassword = lstrdup(asProxyPassword).Detach();
|
||||
}
|
||||
|
||||
void CDownloader::SetLogin(LPCWSTR asUser, LPCWSTR asPassword)
|
||||
@ -313,9 +313,9 @@ void CDownloader::SetLogin(LPCWSTR asUser, LPCWSTR asPassword)
|
||||
SafeFree(m_Server.szPassword);
|
||||
|
||||
if (asUser)
|
||||
m_Server.szUser = lstrdup(asUser);
|
||||
m_Server.szUser = lstrdup(asUser).Detach();
|
||||
if (asPassword)
|
||||
m_Server.szPassword = lstrdup(asPassword);
|
||||
m_Server.szPassword = lstrdup(asPassword).Detach();
|
||||
}
|
||||
|
||||
bool CDownloader::SetProxyForHandle(HANDLE hInternet)
|
||||
@ -387,7 +387,7 @@ bool CDownloader::InitInterface()
|
||||
|
||||
if (!wi)
|
||||
{
|
||||
ReportMessage(dc_LogCallback, L"InitInterface()");
|
||||
ReportMessage(dc_LogCallback, L"InitInterface()", at_None);
|
||||
wi = new CWinInet;
|
||||
if (!wi)
|
||||
{
|
||||
@ -437,7 +437,7 @@ bool CDownloader::WaitAsyncResult()
|
||||
if (!mb_AsyncMode)
|
||||
return true;
|
||||
//TODO!!! Для отладки, пока просто смотрим, какие функции вызывают какие калбэки
|
||||
ReportMessage(dc_LogCallback, L"... waiting 5 sec");
|
||||
ReportMessage(dc_LogCallback, L"... waiting 5 sec", at_None);
|
||||
Sleep(5000);
|
||||
return true;
|
||||
}
|
||||
@ -775,7 +775,7 @@ BOOL CDownloader::DownloadFile(LPCWSTR asSource, LPCWSTR asTarget, DWORD& crc, D
|
||||
DWORD ProxyType = INTERNET_OPEN_TYPE_DIRECT;
|
||||
LPCWSTR ProxyName = nullptr;
|
||||
wchar_t szServer[MAX_PATH];
|
||||
wchar_t* pszSrvPath = nullptr;
|
||||
CEStr pszSrvPath;
|
||||
wchar_t *pszColon;
|
||||
INTERNET_PORT nServerPort = INTERNET_DEFAULT_HTTP_PORT;
|
||||
bool bSecureHTTPS = false;
|
||||
@ -789,9 +789,9 @@ BOOL CDownloader::DownloadFile(LPCWSTR asSource, LPCWSTR asTarget, DWORD& crc, D
|
||||
const auto* pszAgent = msz_AgentName ? msz_AgentName : szConEmuAgent;
|
||||
LPCWSTR szAcceptTypes[] = {L"*/*", nullptr};
|
||||
LPCWSTR* ppszAcceptTypes = szAcceptTypes;
|
||||
DWORD nFlags, nService;
|
||||
BOOL bFRc;
|
||||
DWORD dwErr;
|
||||
DWORD nFlags = 0, nService = 0;
|
||||
BOOL bFRc = 0;
|
||||
DWORD dwErr = -1;
|
||||
MSectionLockSimple CS;
|
||||
|
||||
if (!wi)
|
||||
@ -1043,15 +1043,17 @@ BOOL CDownloader::DownloadFile(LPCWSTR asSource, LPCWSTR asTarget, DWORD& crc, D
|
||||
if (bFtp)
|
||||
{
|
||||
mb_FtpMode = true;
|
||||
wchar_t* pszSlash = wcsrchr(pszSrvPath, L'/');
|
||||
_ASSERTE(!pszSrvPath.IsNull());
|
||||
wchar_t* pszSlash = wcsrchr(pszSrvPath.data(), L'/');
|
||||
// Break path to dir+file
|
||||
if (pszSlash == pszSrvPath)
|
||||
pszSlash = nullptr; // Root
|
||||
else if (pszSlash)
|
||||
*pszSlash = 0; // It is our memory buffer, we can do anything with it
|
||||
// Set ftp directory
|
||||
const auto* pszSetDir = pszSlash ? pszSrvPath : L"/";
|
||||
const auto* pszFile = pszSlash ? (pszSlash + 1) : (*pszSrvPath == L'/') ? (pszSrvPath + 1) : pszSrvPath;
|
||||
const auto* pszSetDir = pszSlash ? pszSrvPath.c_str() : L"/";
|
||||
const auto* pszFile = pszSlash ? (pszSlash + 1)
|
||||
: (pszSrvPath[0] == L'/') ? (pszSrvPath.c_str() + 1) : pszSrvPath.c_str();
|
||||
|
||||
CS.Lock(&mcs_Handle); // Leaved in ExecRequest
|
||||
if (!ExecRequest(wi->_FtpSetCurrentDirectoryW(mh_Connect, pszSetDir), dwErr, CS))
|
||||
@ -1117,7 +1119,7 @@ BOOL CDownloader::DownloadFile(LPCWSTR asSource, LPCWSTR asTarget, DWORD& crc, D
|
||||
ReportMessage(dc_LogCallback, L"Http file opened x%08X", at_Uint, reinterpret_cast<DWORD_PTR>(mh_SrcFile), at_None);
|
||||
//WaitAsyncResult();
|
||||
|
||||
ReportMessage(dc_LogCallback, L"Sending request");
|
||||
ReportMessage(dc_LogCallback, L"Sending request", at_None);
|
||||
ResetEvent(mh_ReadyEvent);
|
||||
CS.Lock(&mcs_Handle); // Leaved in ExecRequest
|
||||
// ReSharper disable once CppJoinDeclarationAndAssignment
|
||||
@ -1165,7 +1167,7 @@ BOOL CDownloader::DownloadFile(LPCWSTR asSource, LPCWSTR asTarget, DWORD& crc, D
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportMessage(dc_LogCallback, L"Opening source from file system");
|
||||
ReportMessage(dc_LogCallback, L"Opening source from file system", at_None);
|
||||
mh_SrcFile = CreateFile(asSource, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr);
|
||||
if (!mh_SrcFile || (mh_SrcFile == INVALID_HANDLE_VALUE))
|
||||
{
|
||||
@ -1249,7 +1251,7 @@ wrap:
|
||||
if (lbRc)
|
||||
ReportMessage(dc_LogCallback, L"Download finished, %u bytes retrieved", at_Uint, size, at_None);
|
||||
else
|
||||
ReportMessage(dc_LogCallback, L"Download failed");
|
||||
ReportMessage(dc_LogCallback, L"Download failed", at_None);
|
||||
|
||||
if (mb_InetMode)
|
||||
{
|
||||
@ -1269,7 +1271,6 @@ wrap:
|
||||
}
|
||||
|
||||
SafeFree(ptrData);
|
||||
SafeFree(pszSrvPath);
|
||||
return lbRc;
|
||||
}
|
||||
|
||||
@ -1311,14 +1312,14 @@ void CDownloader::CloseInternet(bool bFull)
|
||||
|
||||
void CDownloader::RequestTerminate()
|
||||
{
|
||||
ReportMessage(dc_LogCallback, L"!!! Download termination was requested !!!");
|
||||
ReportMessage(dc_LogCallback, L"!!! Download termination was requested !!!", at_None);
|
||||
mb_RequestTerminate = true;
|
||||
CloseInternet(false);
|
||||
}
|
||||
|
||||
void CDownloader::SetAsync(bool bAsync)
|
||||
{
|
||||
ReportMessage(dc_LogCallback, L"Change mode to %s was requested", at_Str, bAsync?L"Async":L"Sync", at_None);
|
||||
ReportMessage(dc_LogCallback, L"Change mode to %s was requested", at_Str, bAsync ? L"Async" : L"Sync", at_None);
|
||||
mb_AsyncMode = bAsync;
|
||||
}
|
||||
|
||||
@ -1349,7 +1350,7 @@ void CDownloader::SetTimeout(UINT nWhat, DWORD nTimeout)
|
||||
void CDownloader::SetAgent(LPCWSTR aszAgentName)
|
||||
{
|
||||
SafeFree(msz_AgentName);
|
||||
msz_AgentName = (aszAgentName && *aszAgentName) ? lstrdup(aszAgentName) : nullptr;
|
||||
msz_AgentName = (aszAgentName && *aszAgentName) ? lstrdup(aszAgentName).Detach() : nullptr;
|
||||
}
|
||||
|
||||
BOOL CDownloader::ReadSource(LPCWSTR asSource, BOOL bInet, HANDLE hSource, BYTE* pData, DWORD cbData, DWORD* pcbRead)
|
||||
@ -1359,7 +1360,7 @@ BOOL CDownloader::ReadSource(LPCWSTR asSource, BOOL bInet, HANDLE hSource, BYTE*
|
||||
|
||||
if (bInet)
|
||||
{
|
||||
ReportMessage(dc_LogCallback, L"Reading source");
|
||||
ReportMessage(dc_LogCallback, L"Reading source", at_None);
|
||||
*pcbRead = 0;
|
||||
MSectionLockSimple CS;
|
||||
CS.Lock(&mcs_Handle); // Leaved in ExecRequest
|
||||
@ -1382,7 +1383,7 @@ BOOL CDownloader::ReadSource(LPCWSTR asSource, BOOL bInet, HANDLE hSource, BYTE*
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportMessage(dc_LogCallback, L"Reading file");
|
||||
ReportMessage(dc_LogCallback, L"Reading file", at_None);
|
||||
lbRc = ReadFile(hSource, pData, cbData, pcbRead, nullptr);
|
||||
if (!lbRc)
|
||||
ReportMessage(dc_ErrCallback,
|
||||
@ -1428,40 +1429,39 @@ void CDownloader::SetCallback(CEDownloadCommand cb, FDownloadCallback afnErrCall
|
||||
m_CallbackLParam[cb] = lParam;
|
||||
}
|
||||
|
||||
void CDownloader::ReportMessage(CEDownloadCommand rm, LPCWSTR asFormat, CEDownloadArgType nextArgType /*= at_None*/, ...)
|
||||
void CDownloader::ReportMessage(CEDownloadCommand rm, LPCWSTR asFormat /*, CEDownloadArgType nextArgType = at_None, Value, ...*/...)
|
||||
{
|
||||
_ASSERTE(asFormat && *asFormat && asFormat[lstrlen(asFormat)-1]!=L'\n');
|
||||
if (!mfn_Callback[rm])
|
||||
return;
|
||||
|
||||
CEDownloadArgType argType = nextArgType;
|
||||
|
||||
va_list argptr;
|
||||
va_start(argptr, nextArgType);
|
||||
|
||||
CEDownloadInfo args = {sizeof(args), m_CallbackLParam[rm], asFormat, 1, {}};
|
||||
|
||||
size_t i = 0;
|
||||
while (argType != at_None)
|
||||
if (IsStrNotEmpty(asFormat) && wcschr(asFormat, L'%') != nullptr)
|
||||
{
|
||||
va_list argptr;
|
||||
va_start(argptr, asFormat);
|
||||
while (i < countof(args.Args))
|
||||
{
|
||||
const auto argType = static_cast<CEDownloadArgType>(va_arg(argptr, int));
|
||||
if (argType == at_None)
|
||||
break;
|
||||
|
||||
if (argType == at_Uint)
|
||||
args.Args[i].uintArg = va_arg( argptr, DWORD_PTR );
|
||||
args.Args[i].uintArg = va_arg(argptr, DWORD_PTR);
|
||||
else if (argType == at_Str)
|
||||
args.Args[i].strArg = va_arg( argptr, wchar_t* );
|
||||
args.Args[i].strArg = va_arg(argptr, wchar_t*);
|
||||
else
|
||||
{
|
||||
_ASSERTE(argType==at_Uint || argType==at_Str);
|
||||
_ASSERTE(argType == at_Uint || argType == at_Str);
|
||||
break;
|
||||
}
|
||||
|
||||
args.Args[i++].argType = argType;
|
||||
if (i >= countof(args.Args))
|
||||
break;
|
||||
|
||||
argType = static_cast<CEDownloadArgType>(va_arg(argptr, int));
|
||||
}
|
||||
|
||||
va_end(argptr);
|
||||
}
|
||||
|
||||
args.argCount = i;
|
||||
|
||||
@ -1621,7 +1621,7 @@ static void PrintDownloadLog(LPCWSTR pszLabel, LPCWSTR pszInfo)
|
||||
swprintf_c(szTime, L"%i:%02i:%02i.%03i{%u} ",
|
||||
st.wHour, st.wMinute, st.wSecond, st.wMilliseconds, GetCurrentThreadId());
|
||||
|
||||
const CEStr lsAll(lstrmerge(szTime, pszLabel, (pszInfo && *pszInfo) ? pszInfo : L"<nullptr>\n"));
|
||||
const CEStr lsAll(szTime, pszLabel, (pszInfo && *pszInfo) ? pszInfo : L"<nullptr>\n");
|
||||
|
||||
DWORD nWritten;
|
||||
const int iLen = lstrlen(lsAll.ms_Val);
|
||||
@ -1848,7 +1848,7 @@ int DoDownload(LPCWSTR asCmdLine)
|
||||
}
|
||||
if (!bKnown)
|
||||
{
|
||||
const CEStr lsInfo(lstrmerge(L"Unknown argument '", psz, L"'"));
|
||||
const CEStr lsInfo(L"Unknown argument '", psz, L"'");
|
||||
DownloadLog(dc_ErrCallback, lsInfo);
|
||||
iRc = CERR_CARGUMENT;
|
||||
goto wrap;
|
||||
|
@ -881,12 +881,12 @@ int DoOutput(ConEmuExecAction eExecAction, LPCWSTR asCmdArg)
|
||||
{
|
||||
_ASSERTE(!bAsciiPrint || !DefaultCP);
|
||||
DWORD nSize = 0, nErrCode = 0;
|
||||
int iRead = ReadTextFile(szArg, (1<<24), szTemp.ms_Val, cchLen, nErrCode, bAsciiPrint ? (DWORD)-1 : DefaultCP);
|
||||
const int iRead = ReadTextFile(szArg, (1<<24), szTemp, cchLen, nErrCode, bAsciiPrint ? static_cast<DWORD>(-1) : DefaultCP);
|
||||
if (iRead < 0)
|
||||
{
|
||||
wchar_t szInfo[100];
|
||||
swprintf_c(szInfo, L"\r\nCode=%i, Error=%u\r\n", iRead, nErrCode);
|
||||
szTemp = lstrmerge(L"Reading source file failed!\r\n", szArg, szInfo);
|
||||
szTemp = CEStr(L"Reading source file failed!\r\n", szArg, szInfo);
|
||||
cchLen = static_cast<DWORD>(szTemp.GetLen());
|
||||
bAsciiPrint = false;
|
||||
iRc = 4;
|
||||
@ -927,11 +927,11 @@ int DoOutput(ConEmuExecAction eExecAction, LPCWSTR asCmdArg)
|
||||
}
|
||||
|
||||
// Concatenate result text
|
||||
lstrmerge(&szTemp.ms_Val, szTemp.IsEmpty() ? nullptr : L" ", pszAdd);
|
||||
szTemp.Append(szTemp.IsEmpty() ? nullptr : L" ", pszAdd);
|
||||
}
|
||||
|
||||
if (bAddNewLine)
|
||||
lstrmerge(&szTemp.ms_Val, L"\r\n");
|
||||
szTemp.Append(L"\r\n");
|
||||
pszText = szTemp.ms_Val;
|
||||
cchLen = pszText ? lstrlen(pszText) : 0;
|
||||
}
|
||||
|
@ -1836,7 +1836,7 @@ int WorkerServer::ProcessCommandLineArgs()
|
||||
//gState.conemuPid_ = ...;
|
||||
|
||||
SafeFree(gpszRunCmd);
|
||||
gpszRunCmd = lstrdup(L"");
|
||||
gpszRunCmd = lstrdup(L"").Detach();
|
||||
|
||||
CreateColorerHeader();
|
||||
}
|
||||
@ -3058,14 +3058,14 @@ HWND WorkerServer::Attach2Gui(DWORD nTimeout)
|
||||
_ASSERTE(NextArg(pszCfgSwitches,lsFirst) && !lsFirst.OneOfSwitches(L"-cmd",L"-cmdlist",L"-run",L"-runlist"));
|
||||
#endif
|
||||
|
||||
lstrmerge(&lsGuiCmd.ms_Val, L" ", cfgSwitches);
|
||||
lsGuiCmd.Append(L" ", cfgSwitches);
|
||||
lstrcpyn(gpSrv->guiSettings.sConEmuArgs, cfgSwitches, countof(gpSrv->guiSettings.sConEmuArgs));
|
||||
}
|
||||
|
||||
// The server called from am_Async (RunMode::RM_AUTOATTACH) mode
|
||||
lstrmerge(&lsGuiCmd.ms_Val, L" -Detached");
|
||||
lsGuiCmd.Append(L" -Detached");
|
||||
#ifdef _DEBUG
|
||||
lstrmerge(&lsGuiCmd.ms_Val, L" -NoKeyHooks");
|
||||
lsGuiCmd.Append(L" -NoKeyHooks");
|
||||
#endif
|
||||
|
||||
PROCESS_INFORMATION pi; memset(&pi, 0, sizeof(pi));
|
||||
|
@ -221,17 +221,17 @@ void SwitchStr::SetStr(const wchar_t* const newVal)
|
||||
{
|
||||
if (value)
|
||||
free(value);
|
||||
value = (newVal && *newVal) ? lstrdup(newVal) : nullptr;
|
||||
value = (newVal && *newVal) ? lstrdup(newVal).Detach() : nullptr;
|
||||
}
|
||||
exists = true;
|
||||
switchType = SwitchType::Str;
|
||||
}
|
||||
|
||||
void SwitchStr::SetStr(wchar_t*&& newVal)
|
||||
void SwitchStr::SetStr(CEStr&& newVal)
|
||||
{
|
||||
if (value != newVal && value != nullptr)
|
||||
if (value != newVal.data() && value != nullptr)
|
||||
free(value);
|
||||
value = newVal;
|
||||
value = newVal.Detach();
|
||||
exists = true;
|
||||
switchType = SwitchType::Str;
|
||||
}
|
||||
@ -327,14 +327,14 @@ void ConsoleArgs::ShowInjectsMsgBox(const ConEmuExecAction mode, const wchar_t*
|
||||
|
||||
void ConsoleArgs::AddConEmuArg(LPCWSTR asSwitch, LPCWSTR asValue)
|
||||
{
|
||||
lstrmerge(&conemuAddArgs_.ms_Val, asSwitch);
|
||||
conemuAddArgs_.Append(asSwitch);
|
||||
if (asValue && *asValue)
|
||||
{
|
||||
const bool needQuot = IsQuotationNeeded(asValue);
|
||||
lstrmerge(&conemuAddArgs_.ms_Val,
|
||||
conemuAddArgs_.Append(
|
||||
needQuot ? L" \"" : L" ",
|
||||
asValue,
|
||||
needQuot ? L"\"" : NULL);
|
||||
needQuot ? L"\"" : nullptr);
|
||||
}
|
||||
SetEnvironmentVariable(ENV_CONEMU_EXEARGS_W, conemuAddArgs_);
|
||||
}
|
||||
@ -721,7 +721,7 @@ int ConsoleArgs::ParseCommandLine(LPCWSTR pszCmdLine, const ConsoleMainMode anWo
|
||||
else if (szArg.IsSwitch(L"/ROOTEXE"))
|
||||
{
|
||||
if ((cmdLineRest = NextArg(cmdLineRest, szArg, &pszArgStart)))
|
||||
rootExe_.SetStr(lstrmerge(L"\"", szArg, L"\""));
|
||||
rootExe_.SetStr(CEStr(L"\"", szArg, L"\""));
|
||||
}
|
||||
else if (szArg.OneOfSwitches(L"/PID=", L"/TRMPID=", L"/FARPID=", L"/CONPID="))
|
||||
{
|
||||
|
@ -136,7 +136,7 @@ struct SwitchStr : public Switch
|
||||
bool IsEmpty() const;
|
||||
LPCWSTR GetStr() const;
|
||||
void SetStr(const wchar_t* newVal);
|
||||
void SetStr(wchar_t*&& newVal);
|
||||
void SetStr(CEStr&& newVal);
|
||||
SwitchStr& operator=(const wchar_t* newVal);
|
||||
};
|
||||
|
||||
|
@ -464,7 +464,7 @@ void OnProcessCreatedDbg(BOOL bRc, DWORD dwErr, LPPROCESS_INFORMATION pProcessIn
|
||||
|
||||
BOOL createProcess(BOOL abSkipWowChange, LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
|
||||
{
|
||||
const CEStr fnDescr(lstrmerge(L"createProcess App={", lpApplicationName, L"} Cmd={", lpCommandLine, L"}"));
|
||||
const CEStr fnDescr(L"createProcess App={", lpApplicationName, L"} Cmd={", lpCommandLine, L"}");
|
||||
LogFunction(fnDescr);
|
||||
|
||||
MWow64Disable wow;
|
||||
@ -716,7 +716,7 @@ bool CheckAndWarnHookSetters()
|
||||
}
|
||||
|
||||
swprintf_c(szAddress, WIN3264TEST(L"0x%08X",L"0x%08X%08X"), WIN3264WSPRINT((DWORD_PTR)hModule));
|
||||
szMessage = lstrmerge(
|
||||
szMessage = CEStr(
|
||||
L"WARNING! The ", pszTitle, L"'s hooks are detected at ", szAddress, L"\r\n"
|
||||
L" ");
|
||||
LPCWSTR pszTail = L"\r\n"
|
||||
@ -1148,11 +1148,11 @@ int __stdcall ConsoleMain3(const ConsoleMainMode anWorkMode, LPCWSTR asCmdLine)
|
||||
nExitPlaceStep = 350;
|
||||
|
||||
// Process environment variables
|
||||
wchar_t* pszExpandedCmd = ParseConEmuSubst(gpszRunCmd);
|
||||
CEStr pszExpandedCmd = ParseConEmuSubst(gpszRunCmd);
|
||||
if (pszExpandedCmd)
|
||||
{
|
||||
SafeFree(gpszRunCmd);
|
||||
gpszRunCmd = pszExpandedCmd;
|
||||
gpszRunCmd = pszExpandedCmd.Detach();
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
@ -2252,7 +2252,7 @@ void PrintExecuteError(LPCWSTR asCmd, DWORD dwErr, LPCWSTR asSpecialInfo/*=nullp
|
||||
|
||||
// 1. Substitute vars like: !ConEmuHWND!, !ConEmuDrawHWND!, !ConEmuBackHWND!, !ConEmuWorkDir!
|
||||
// 2. Expand environment variables (e.g. PowerShell doesn't accept %vars% as arguments)
|
||||
wchar_t* ParseConEmuSubst(LPCWSTR asCmd)
|
||||
CEStr ParseConEmuSubst(LPCWSTR asCmd)
|
||||
{
|
||||
if (!asCmd || !*asCmd)
|
||||
{
|
||||
@ -2288,7 +2288,7 @@ wchar_t* ParseConEmuSubst(LPCWSTR asCmd)
|
||||
|
||||
//_ASSERTE(FALSE && "Continue to ParseConEmuSubst");
|
||||
|
||||
wchar_t* pszCmdCopy = nullptr;
|
||||
CEStr pszCmdCopy;
|
||||
|
||||
if (bExclSubst)
|
||||
{
|
||||
@ -2317,9 +2317,7 @@ wchar_t* ParseConEmuSubst(LPCWSTR asCmd)
|
||||
}
|
||||
|
||||
CEStr pszExpand = ExpandEnvStr(pszCmdCopy ? pszCmdCopy : asCmd);
|
||||
|
||||
SafeFree(pszCmdCopy);
|
||||
return pszExpand.Detach();
|
||||
return pszExpand;
|
||||
}
|
||||
|
||||
BOOL SetTitle(LPCWSTR lsTitle)
|
||||
@ -2336,9 +2334,8 @@ BOOL SetTitle(LPCWSTR lsTitle)
|
||||
|
||||
if (gpLogSize)
|
||||
{
|
||||
wchar_t* pszLog = lstrmerge(bRc ? L"Done: " : L"Fail: ", pszSetTitle);
|
||||
CEStr pszLog(bRc ? L"Done: " : L"Fail: ", pszSetTitle);
|
||||
LogFunction(pszLog);
|
||||
SafeFree(pszLog);
|
||||
}
|
||||
|
||||
return bRc;
|
||||
@ -2349,8 +2346,7 @@ void UpdateConsoleTitle()
|
||||
LogFunction(L"UpdateConsoleTitle");
|
||||
|
||||
CmdArg szTemp;
|
||||
wchar_t *pszBuffer = nullptr;
|
||||
LPCWSTR pszSetTitle = nullptr, pszCopy;
|
||||
LPCWSTR pszSetTitle = nullptr;
|
||||
LPCWSTR pszReq = gpszForcedTitle ? gpszForcedTitle : gpszRunCmd;
|
||||
|
||||
if (!pszReq || !*pszReq)
|
||||
@ -2365,15 +2361,15 @@ void UpdateConsoleTitle()
|
||||
return;
|
||||
}
|
||||
|
||||
pszBuffer = ParseConEmuSubst(pszReq);
|
||||
CEStr pszBuffer = ParseConEmuSubst(pszReq);
|
||||
if (pszBuffer)
|
||||
pszReq = pszBuffer;
|
||||
pszCopy = pszReq;
|
||||
LPCWSTR pszCopy = pszReq;
|
||||
|
||||
if (!gpszForcedTitle && (pszCopy = NextArg(pszCopy, szTemp)))
|
||||
if (!gpszForcedTitle && ((pszCopy = NextArg(pszCopy, szTemp))))
|
||||
{
|
||||
wchar_t* pszName = (wchar_t*)PointToName(szTemp.ms_Val);
|
||||
wchar_t* pszExt = (wchar_t*)PointToExt(pszName);
|
||||
wchar_t* pszName = const_cast<wchar_t*>(PointToName(szTemp.ms_Val));
|
||||
wchar_t* pszExt = const_cast<wchar_t*>(PointToExt(pszName));
|
||||
if (pszExt)
|
||||
*pszExt = 0;
|
||||
pszSetTitle = pszName;
|
||||
@ -2395,8 +2391,6 @@ void UpdateConsoleTitle()
|
||||
|
||||
SetTitle(pszSetTitle);
|
||||
}
|
||||
|
||||
SafeFree(pszBuffer);
|
||||
}
|
||||
|
||||
// Проверить, что nPID это "ConEmuC.exe" или "ConEmuC64.exe"
|
||||
|
@ -194,7 +194,7 @@ void PrintBuffer(LPCSTR asBuffer);
|
||||
void Printf(LPCSTR asFormat, ...);
|
||||
void PrintError(const CEStr& message, DWORD dwErr);
|
||||
|
||||
wchar_t* ParseConEmuSubst(LPCWSTR asCmd);
|
||||
CEStr ParseConEmuSubst(LPCWSTR asCmd);
|
||||
void UpdateConsoleTitle();
|
||||
BOOL SetTitle(LPCWSTR lsTitle);
|
||||
void Help();
|
||||
|
@ -176,7 +176,7 @@ int DebuggerInfo::RunDebugger()
|
||||
}
|
||||
|
||||
SafeFree(gpszRunCmd);
|
||||
gpszRunCmd = lstrdup(L"");
|
||||
gpszRunCmd = lstrdup(L"").Detach();
|
||||
if (!gpszRunCmd)
|
||||
{
|
||||
PrintBuffer("Can't allocate 1 wchar!\n");
|
||||
@ -395,7 +395,7 @@ DWORD DebuggerInfo::DebugThread(LPVOID lpvParam)
|
||||
_wcscpyn_c(szProc, countof(szProc), info.szExeFile, countof(szProc));
|
||||
|
||||
swprintf_c(szInfo, L"Can't start debugging process. ErrCode=0x%08X\n", dwErr);
|
||||
CEStr lsInfo(lstrmerge(szInfo, dbgInfo.szDebuggingCmdLine, L"\n"));
|
||||
const CEStr lsInfo(szInfo, dbgInfo.szDebuggingCmdLine, L"\n");
|
||||
PrintBuffer(lsInfo);
|
||||
return CERR_CANTSTARTDEBUGGER;
|
||||
}
|
||||
@ -459,7 +459,7 @@ DWORD DebuggerInfo::DebugThread(LPVOID lpvParam)
|
||||
|
||||
// Добавить процесс в список для запуска альтернативного дебаггера соотвествующей битности
|
||||
// Force trailing "," even if only one PID specified ( --> bDebugMultiProcess = TRUE)
|
||||
lstrmerge(&szOtherBitPids.ms_Val, ltow_s(nDbgProcessID, szPID, 10), L",");
|
||||
szOtherBitPids.Append(ltow_s(nDbgProcessID, szPID, 10), L",");
|
||||
|
||||
// Может там еще процессы в списке на дамп?
|
||||
continue;
|
||||
@ -521,11 +521,11 @@ DWORD DebuggerInfo::DebugThread(LPVOID lpvParam)
|
||||
// Reverted to current bitness
|
||||
wcscat_c(szExe, WIN3264TEST(L"ConEmuC64.exe", L"ConEmuC.exe"));
|
||||
|
||||
szOtherDebugCmd.Attach(lstrmerge(L"\"", szExe, L"\" "
|
||||
szOtherDebugCmd = CEStr(L"\"", szExe, L"\" "
|
||||
L"/DEBUGPID=", szOtherBitPids.ms_Val,
|
||||
(dbgInfo.debugDumpProcess == DumpProcessType::AskUser) ? L" /DUMP" :
|
||||
(dbgInfo.debugDumpProcess == DumpProcessType::MiniDump) ? L" /MINIDUMP" :
|
||||
(dbgInfo.debugDumpProcess == DumpProcessType::FullDump) ? L" /FULLDUMP" : L""));
|
||||
(dbgInfo.debugDumpProcess == DumpProcessType::FullDump) ? L" /FULLDUMP" : L"");
|
||||
|
||||
STARTUPINFO si = {};
|
||||
si.cb = sizeof(si);
|
||||
@ -541,7 +541,7 @@ DWORD DebuggerInfo::DebugThread(LPVOID lpvParam)
|
||||
{
|
||||
DWORD dwErr = GetLastError();
|
||||
swprintf_c(szInfo, L"Can't start external debugger, ErrCode=0x%08X\n", dwErr);
|
||||
CEStr lsInfo(lstrmerge(szInfo, szOtherDebugCmd, L"\n"));
|
||||
const CEStr lsInfo(szInfo, szOtherDebugCmd, L"\n");
|
||||
PrintBuffer(lsInfo);
|
||||
}
|
||||
}
|
||||
@ -610,7 +610,7 @@ bool DebuggerInfo::IsDumpMulti() const
|
||||
return false;
|
||||
}
|
||||
|
||||
wchar_t* DebuggerInfo::FormatDumpName(wchar_t* DmpFile, size_t cchDmpMax, DWORD dwProcessId, bool bTrap, bool bFull) const
|
||||
void DebuggerInfo::FormatDumpName(wchar_t* DmpFile, size_t cchDmpMax, DWORD dwProcessId, bool bTrap, bool bFull) const
|
||||
{
|
||||
//TODO: Добавить в DmpFile имя без пути? <exename>-<ver>-<pid>-<yymmddhhmmss>.[m]dmp
|
||||
wchar_t szMinor[8] = L""; lstrcpyn(szMinor, _T(MVV_4a), countof(szMinor));
|
||||
@ -620,7 +620,6 @@ wchar_t* DebuggerInfo::FormatDumpName(wchar_t* DmpFile, size_t cchDmpMax, DWORD
|
||||
MVV_1, MVV_2, MVV_3, szMinor, dwProcessId,
|
||||
lt.wYear%100, lt.wMonth, lt.wDay, lt.wHour, lt.wMinute, lt.wSecond, lt.wMilliseconds,
|
||||
bFull ? L"dmp" : L"mdmp");
|
||||
return DmpFile;
|
||||
}
|
||||
|
||||
bool DebuggerInfo::GetSaveDumpName(DWORD dwProcessId, bool bFull, wchar_t* dmpFile, const DWORD cchMaxDmpFile) const
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
HANDLE GetProcessHandleForDebug(DWORD nPID, LPDWORD pnErrCode = nullptr) const;
|
||||
void AttachConHost(DWORD nConHostPID) const;
|
||||
bool IsDumpMulti() const;
|
||||
wchar_t* FormatDumpName(wchar_t* DmpFile, size_t cchDmpMax, DWORD dwProcessId, bool bTrap, bool bFull) const;
|
||||
void FormatDumpName(wchar_t* DmpFile, size_t cchDmpMax, DWORD dwProcessId, bool bTrap, bool bFull) const;
|
||||
bool GetSaveDumpName(DWORD dwProcessId, bool bFull, wchar_t* dmpFile, DWORD cchMaxDmpFile) const;
|
||||
void ProcessDebugEvent();
|
||||
void GenerateMiniDumpFromCtrlBreak();
|
||||
|
@ -156,12 +156,12 @@ public:
|
||||
SafeFree(m_Proxy.szProxyPassword);
|
||||
|
||||
// Empty string - for ‘autoconfig’
|
||||
m_Proxy.szProxy = lstrdup(asProxy ? asProxy : L"");
|
||||
m_Proxy.szProxy = lstrdup(asProxy ? asProxy : L"").Detach();
|
||||
|
||||
if (asProxyUser)
|
||||
m_Proxy.szProxyUser = lstrdup(asProxyUser);
|
||||
m_Proxy.szProxyUser = lstrdup(asProxyUser).Detach();
|
||||
if (asProxyPassword)
|
||||
m_Proxy.szProxyPassword = lstrdup(asProxyPassword);
|
||||
m_Proxy.szProxyPassword = lstrdup(asProxyPassword).Detach();
|
||||
};
|
||||
|
||||
// Logging, errors, download progress
|
||||
@ -181,7 +181,7 @@ public:
|
||||
SafeFree(szCmdStringFormat);
|
||||
if (asFormat && *asFormat)
|
||||
{
|
||||
szCmdStringFormat = lstrdup(asFormat);
|
||||
szCmdStringFormat = lstrdup(asFormat).Detach();
|
||||
}
|
||||
}
|
||||
|
||||
@ -472,11 +472,11 @@ protected:
|
||||
}
|
||||
// Exit
|
||||
return iRc;
|
||||
};
|
||||
}
|
||||
|
||||
wchar_t* CreateCommand(LPCWSTR asSource, LPCWSTR asTarget, UINT& iRc)
|
||||
CEStr CreateCommand(LPCWSTR asSource, LPCWSTR asTarget, UINT& iRc)
|
||||
{
|
||||
wchar_t* pszCommand = nullptr;
|
||||
CEStr pszCommand = nullptr;
|
||||
|
||||
if (!szCmdStringFormat || !*szCmdStringFormat)
|
||||
{
|
||||
@ -512,14 +512,14 @@ protected:
|
||||
"full_url_to_file" "local_path_name"
|
||||
*/
|
||||
|
||||
if (!(pszCommand = lstrmerge(L"\"", szConEmuC, L"\" -download ")))
|
||||
if ((pszCommand = CEStr(L"\"", szConEmuC, L"\" -download ")).IsEmpty())
|
||||
{
|
||||
iRc = E_OUTOFMEMORY;
|
||||
goto wrap;
|
||||
}
|
||||
|
||||
#if defined(_DEBUG)
|
||||
lstrmerge(&pszCommand, L"-debug ");
|
||||
pszCommand.Append(L"-debug ");
|
||||
#endif
|
||||
|
||||
for (INT_PTR i = 0; i < countof(Switches); i++)
|
||||
@ -529,14 +529,14 @@ protected:
|
||||
&& ((*pszValue)
|
||||
|| (lstrcmp(Switches[i].pszName, L"-proxy") == 0) // Pass empty string for proxy autoconfig
|
||||
)
|
||||
&& !lstrmerge(&pszCommand, Switches[i].pszName, L" \"", pszValue, L"\" "))
|
||||
&& !pszCommand.Append(Switches[i].pszName, L" \"", pszValue, L"\" "))
|
||||
{
|
||||
iRc = E_OUTOFMEMORY;
|
||||
goto wrap;
|
||||
}
|
||||
}
|
||||
|
||||
if (!lstrmerge(&pszCommand, asSource, L" \"", asTarget, L"\""))
|
||||
if (!pszCommand.Append(asSource, L" \"", asTarget, L"\""))
|
||||
{
|
||||
iRc = E_OUTOFMEMORY;
|
||||
goto wrap;
|
||||
@ -578,7 +578,7 @@ public:
|
||||
LPCWSTR pszName = PointToName(asTarget);
|
||||
if (pszName > asTarget)
|
||||
{
|
||||
szCmdDirectory = lstrdup(asTarget);
|
||||
szCmdDirectory = lstrdup(asTarget).Detach();
|
||||
if (!szCmdDirectory)
|
||||
{
|
||||
iRc = E_OUTOFMEMORY;
|
||||
@ -588,7 +588,7 @@ public:
|
||||
}
|
||||
|
||||
// Prepare command line for downloader tool
|
||||
pszCommand = CreateCommand(asSource, pszName, iRc);
|
||||
pszCommand = CreateCommand(asSource, pszName, iRc).Detach();
|
||||
if (!pszCommand)
|
||||
{
|
||||
_ASSERTE(iRc!=0);
|
||||
|
@ -285,7 +285,7 @@ void ArgGuiMacro(const CEStr& szArg, MacroInstance& inst)
|
||||
_ASSERTE(FALSE && "Unsupported GuiMacro option");
|
||||
if (gpLogSize)
|
||||
{
|
||||
CEStr strErr(lstrmerge(L"Unsupported GuiMacro option: ", szArg.ms_Val));
|
||||
const CEStr strErr(L"Unsupported GuiMacro option: ", szArg.ms_Val);
|
||||
gpLogSize->LogString(strErr);
|
||||
}
|
||||
break;
|
||||
@ -443,7 +443,7 @@ int __stdcall GuiMacro(LPCWSTR asInstance, LPCWSTR asMacro, BSTR* bsResult /*= N
|
||||
{
|
||||
_ASSERTE((lstrcmpni(asInstance, L"/GuiMacro", 9) != 0) && (lstrcmpni(asInstance, L"-GuiMacro", 9) != 0));
|
||||
|
||||
CEStr lsArg = lstrmerge(L"/GuiMacro:", asInstance);
|
||||
const CEStr lsArg(L"/GuiMacro:", asInstance);
|
||||
ArgGuiMacro(lsArg, inst);
|
||||
}
|
||||
|
||||
|
@ -63,8 +63,7 @@ template<>
|
||||
void DumpMember<WORD>(const WORD& data, LPCWSTR szName, LPCWSTR szIndent)
|
||||
{
|
||||
wchar_t szData[32];
|
||||
CEStr lsLine;
|
||||
lsLine = lstrmerge(szIndent, szName, L": ", ultow_s(data, szData, 10), L"\r\n");
|
||||
CEStr lsLine(szIndent, szName, L": ", ultow_s(data, szData, 10), L"\r\n");
|
||||
PrintBuffer(lsLine);
|
||||
}
|
||||
|
||||
@ -72,8 +71,7 @@ template<>
|
||||
void DumpMember<DWORD>(const DWORD& data, LPCWSTR szName, LPCWSTR szIndent)
|
||||
{
|
||||
wchar_t szData[32];
|
||||
CEStr lsLine;
|
||||
lsLine = lstrmerge(szIndent, szName, L": ", ultow_s(data, szData, 10), L"\r\n");
|
||||
CEStr lsLine(szIndent, szName, L": ", ultow_s(data, szData, 10), L"\r\n");
|
||||
PrintBuffer(lsLine);
|
||||
}
|
||||
|
||||
@ -153,19 +151,18 @@ struct FlagList
|
||||
|
||||
static void DumpFlags(const DWORD Flags, FlagList* flags, size_t flagsCount, LPCWSTR szName, LPCWSTR szIndent)
|
||||
{
|
||||
CEStr lsLine;
|
||||
lsLine = lstrmerge(szIndent, szName, L": ");
|
||||
CEStr lsLine(szIndent, szName, L": ");
|
||||
|
||||
LPCWSTR pszDelim = NULL;
|
||||
for (size_t i = 0; i < flagsCount; i++)
|
||||
{
|
||||
if (Flags & flags[i].flag)
|
||||
{
|
||||
lstrmerge(&lsLine.ms_Val, pszDelim, flags[i].name);
|
||||
lsLine.Append(pszDelim, flags[i].name);
|
||||
if (!pszDelim) pszDelim = L"|";
|
||||
}
|
||||
}
|
||||
lstrmerge(&lsLine.ms_Val, L"\r\n");
|
||||
lsLine.Append(L"\r\n");
|
||||
PrintBuffer(lsLine);
|
||||
}
|
||||
|
||||
@ -328,17 +325,17 @@ int ProcessMapping(MFileMapping<T>& fileMap, MapDumpEnum type, LPCWSTR pszMapNam
|
||||
|
||||
if (!fileMap.Open(FALSE, strSize))
|
||||
{
|
||||
lsMsg = lstrmerge(L"Failed to open mapping: `", pszMapName, L"`\r\n", fileMap.GetErrorText(), L"\r\n");
|
||||
lsMsg = CEStr(L"Failed to open mapping: `", pszMapName, L"`\r\n", fileMap.GetErrorText(), L"\r\n");
|
||||
PrintBuffer(lsMsg);
|
||||
return CERR_UNKNOWN_MAP_NAME;
|
||||
}
|
||||
|
||||
lsMsg = lstrmerge(L"Mapping: `", pszMapName, L"`\r\n");
|
||||
lsMsg = CEStr(L"Mapping: `", pszMapName, L"`\r\n");
|
||||
PrintBuffer(lsMsg);
|
||||
if (fileMap.Ptr()->cbSize != strSize)
|
||||
{
|
||||
wchar_t szReq[32] = L"", szGet[32] = L"";
|
||||
lsMsg = lstrmerge(L"### WARNING ###",
|
||||
lsMsg = CEStr(L"### WARNING ###",
|
||||
L" ReqSize=", ultow_s(strSize, szReq, 10),
|
||||
L" MapSize=", ultow_s(fileMap.Ptr()->cbSize, szGet, 10),
|
||||
L"\r\n");
|
||||
@ -356,7 +353,7 @@ int DumpStructData(LPCWSTR asMappingName)
|
||||
|
||||
if (!asMappingName || !*asMappingName || wcschr(asMappingName, L'%'))
|
||||
{
|
||||
lsMsg = lstrmerge(L"Invalid mapping name: `", asMappingName, L"`\r\n");
|
||||
lsMsg = CEStr(L"Invalid mapping name: `", asMappingName, L"`\r\n");
|
||||
PrintBuffer(lsMsg);
|
||||
return CERR_UNKNOWN_MAP_NAME;
|
||||
}
|
||||
@ -366,7 +363,7 @@ int DumpStructData(LPCWSTR asMappingName)
|
||||
if ((type == mde_Unknown) || !strSize)
|
||||
{
|
||||
_ASSERTE(type == mde_Unknown);
|
||||
lsMsg = lstrmerge(L"Unknown mapping name: `", asMappingName, L"`\r\n");
|
||||
lsMsg = CEStr(L"Unknown mapping name: `", asMappingName, L"`\r\n");
|
||||
PrintBuffer(lsMsg);
|
||||
return CERR_UNKNOWN_MAP_NAME;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ void CStartEnv::ChCp(LPCWSTR asCP)
|
||||
|
||||
void CStartEnv::Echo(LPCWSTR asSwitches, LPCWSTR asText)
|
||||
{
|
||||
CEStr lsFull = lstrmerge(asSwitches, (asSwitches && *asSwitches) ? L" " : nullptr, L"\"", asText, L"\"");
|
||||
const CEStr lsFull(asSwitches, (asSwitches && *asSwitches) ? L" " : nullptr, L"\"", asText, L"\"");
|
||||
DoOutput(ConEmuExecAction::OutEcho, lsFull);
|
||||
}
|
||||
|
||||
@ -186,12 +186,12 @@ void CStartEnv::Title(LPCWSTR asTitle)
|
||||
if (asTitle && *asTitle)
|
||||
{
|
||||
SafeFree(gpszForcedTitle);
|
||||
gpszForcedTitle = lstrdup(asTitle);
|
||||
gpszForcedTitle = lstrdup(asTitle).Detach();
|
||||
}
|
||||
}
|
||||
|
||||
void CStartEnv::Type(LPCWSTR asSwitches, LPCWSTR asFile)
|
||||
{
|
||||
const CEStr lsFull = lstrmerge(asSwitches, (asSwitches && *asSwitches) ? L" " : nullptr, L"\"", asFile, L"\"");
|
||||
const CEStr lsFull(asSwitches, (asSwitches && *asSwitches) ? L" " : nullptr, L"\"", asFile, L"\"");
|
||||
DoOutput(ConEmuExecAction::OutType, lsFull);
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ int WorkerBase::PostProcessPrepareCommandLine()
|
||||
}
|
||||
|
||||
SafeFree(gpszRunCmd);
|
||||
gpszRunCmd = lstrdup(L"");
|
||||
gpszRunCmd = lstrdup(L"").Detach();
|
||||
|
||||
if (!gpszRunCmd)
|
||||
{
|
||||
@ -1484,9 +1484,8 @@ void WorkerBase::CdToProfileDir() const
|
||||
// Write action to log file
|
||||
if (gpLogSize)
|
||||
{
|
||||
wchar_t* pszMsg = lstrmerge(bRc ? L"Work dir changed to %USERPROFILE%: " : L"CD failed to %USERPROFILE%: ", szPath);
|
||||
const CEStr pszMsg(bRc ? L"Work dir changed to %USERPROFILE%: " : L"CD failed to %USERPROFILE%: ", szPath);
|
||||
LogFunction(pszMsg);
|
||||
SafeFree(pszMsg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1694,7 +1693,7 @@ int WorkerBase::CheckAttachProcess()
|
||||
gsVersion, WIN3264TEST(32,64), nSelfPID, liArgsFailed,
|
||||
self.th32ParentProcessID, parent.szExeFile[0] ? parent.szExeFile : L"<terminated>");
|
||||
|
||||
const CEStr lsMsg = lstrmerge(szTitle, szFailMsg, L"\r\nCommand line:\r\n ", pszCmdLine);
|
||||
const CEStr lsMsg(szTitle, szFailMsg, L"\r\nCommand line:\r\n ", pszCmdLine);
|
||||
|
||||
// Avoid automatic termination of ExitWaitForKey
|
||||
gbInShutdown = FALSE;
|
||||
@ -1851,13 +1850,13 @@ CEStr WorkerBase::ExpandTaskCmd(LPCWSTR asCmdLine) const
|
||||
wmemmove(pIn->GetTask.data, asCmdLine, cchCount);
|
||||
_ASSERTE(pIn->GetTask.data[cchCount] == 0);
|
||||
|
||||
wchar_t* pszResult = nullptr;
|
||||
CEStr pszResult;
|
||||
// #SERVER Use conemuPid_ instead of conemuWnd_
|
||||
CESERVER_REQ* pOut = ExecuteGuiCmd(gState.conemuWnd_, pIn, gState.realConWnd_);
|
||||
if (pOut && (pOut->DataSize() > sizeof(pOut->GetTask)) && pOut->GetTask.data[0])
|
||||
{
|
||||
const LPCWSTR pszTail = SkipNonPrintable(pszNameEnd);
|
||||
pszResult = lstrmerge(pOut->GetTask.data, (pszTail && *pszTail) ? L" " : nullptr, pszTail);
|
||||
pszResult = CEStr(pOut->GetTask.data, (pszTail && *pszTail) ? L" " : nullptr, pszTail);
|
||||
}
|
||||
ExecuteFreeResult(pIn);
|
||||
ExecuteFreeResult(pOut);
|
||||
|
@ -300,15 +300,13 @@ void CDefTermHk::DefTermLogString(LPCWSTR asMessage, LPCWSTR asLabel /*= nullptr
|
||||
return;
|
||||
}
|
||||
|
||||
LPCWSTR pszReady = asMessage;
|
||||
// ReSharper disable once CppJoinDeclarationAndAssignment
|
||||
|
||||
CEStr lsBuf;
|
||||
if (asLabel && *asLabel)
|
||||
{
|
||||
lsBuf = lstrmerge(asLabel, asMessage);
|
||||
if (lsBuf.ms_Val)
|
||||
pszReady = lsBuf.ms_Val;
|
||||
lsBuf = CEStr(asLabel, asMessage);
|
||||
}
|
||||
const wchar_t* pszReady = lsBuf.IsEmpty() ? asMessage : lsBuf.c_str();
|
||||
|
||||
gpDefTerm->LogHookingStatus(GetCurrentProcessId(), pszReady);
|
||||
}
|
||||
@ -707,7 +705,7 @@ int CDefTermHk::DisplayLastError(LPCWSTR asLabel, DWORD dwError/*=0*/, DWORD dwM
|
||||
{
|
||||
wchar_t szInfo[64];
|
||||
msprintf(szInfo, countof(szInfo), L", ErrCode=x%X(%i)", dwError, static_cast<int>(dwError));
|
||||
const CEStr lsMsg = lstrmerge(asLabel, szInfo);
|
||||
const CEStr lsMsg(asLabel, szInfo);
|
||||
LogHookingStatus(GetCurrentProcessId(), lsMsg);
|
||||
}
|
||||
else
|
||||
|
@ -2472,7 +2472,7 @@ int DuplicateRoot(CESERVER_REQ_DUPLICATE* Duplicate)
|
||||
CESERVER_CONSOLE_MAPPING_HDR* pConMap = GetConMap();
|
||||
|
||||
RConStartArgs args; // Strip and process "-new_console" switches
|
||||
args.pszSpecialCmd = lstrdup(pszCmdLine);
|
||||
args.pszSpecialCmd = lstrdup(pszCmdLine).Detach();
|
||||
args.ProcessNewConArg();
|
||||
if (args.pszSpecialCmd && *args.pszSpecialCmd)
|
||||
pszCmdLine = args.pszSpecialCmd;
|
||||
|
@ -164,25 +164,6 @@ CShellProc::~CShellProc()
|
||||
mb_InShellExecuteEx = FALSE;
|
||||
}
|
||||
|
||||
if (mpwsz_TempAction)
|
||||
free(mpwsz_TempAction);
|
||||
if (mpwsz_TempFile)
|
||||
free(mpwsz_TempFile);
|
||||
if (mpwsz_TempParam)
|
||||
free(mpwsz_TempParam);
|
||||
// results
|
||||
if (mpsz_TempRetFile)
|
||||
free(mpsz_TempRetFile);
|
||||
if (mpsz_TempRetParam)
|
||||
free(mpsz_TempRetParam);
|
||||
if (mpsz_TempRetDir)
|
||||
free(mpsz_TempRetDir);
|
||||
if (mpwsz_TempRetFile)
|
||||
free(mpwsz_TempRetFile);
|
||||
if (mpwsz_TempRetParam)
|
||||
free(mpwsz_TempRetParam);
|
||||
if (mpwsz_TempRetDir)
|
||||
free(mpwsz_TempRetDir);
|
||||
// structures
|
||||
if (mlp_ExecInfoA)
|
||||
free(mlp_ExecInfoA);
|
||||
@ -316,33 +297,43 @@ void CShellProc::LogExitLine(const int rc, const int line) const
|
||||
LogShellString(szInfo);
|
||||
}
|
||||
|
||||
wchar_t* CShellProc::str2wcs(const char* psz, const UINT anCP)
|
||||
CEStr CShellProc::str2wcs(const char* psz, const UINT anCP)
|
||||
{
|
||||
if (!psz)
|
||||
return nullptr;
|
||||
const int nLen = lstrlenA(psz);
|
||||
wchar_t* pwsz = static_cast<wchar_t*>(calloc((nLen+1), sizeof(wchar_t)));
|
||||
CEStr pwsz;
|
||||
if (nLen > 0)
|
||||
{
|
||||
MultiByteToWideChar(anCP, 0, psz, nLen+1, pwsz, nLen+1);
|
||||
if (pwsz.GetBuffer(nLen))
|
||||
{
|
||||
MultiByteToWideChar(anCP, 0, psz, nLen + 1,
|
||||
pwsz.data(), static_cast<int>(pwsz.GetMaxCount()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pwsz[0] = 0;
|
||||
pwsz.Set(L"");
|
||||
}
|
||||
return pwsz;
|
||||
}
|
||||
char* CShellProc::wcs2str(const wchar_t* pwsz, UINT anCP)
|
||||
|
||||
CEStrA CShellProc::wcs2str(const wchar_t* pwsz, UINT anCP)
|
||||
{
|
||||
const int nLen = lstrlen(pwsz);
|
||||
char* psz = static_cast<char*>(calloc((nLen+1), sizeof(char)));
|
||||
CEStrA psz;
|
||||
if (nLen > 0)
|
||||
{
|
||||
WideCharToMultiByte(anCP, 0, pwsz, nLen+1, psz, nLen+1, nullptr, nullptr);
|
||||
const int aLen = WideCharToMultiByte(anCP, 0, pwsz, nLen + 1, nullptr, 0, nullptr, nullptr);
|
||||
if (aLen > 0 && psz.GetBuffer(aLen))
|
||||
{
|
||||
WideCharToMultiByte(anCP, 0, pwsz, nLen + 1,
|
||||
psz.data(), static_cast<int>(psz.GetMaxCount()), nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
psz[0] = 0;
|
||||
psz.Set("");
|
||||
}
|
||||
return psz;
|
||||
}
|
||||
@ -470,7 +461,7 @@ void CShellProc::CheckHooksDisabled()
|
||||
BOOL CShellProc::ChangeExecuteParams(enum CmdOnCreateType aCmd,
|
||||
LPCWSTR asFile, LPCWSTR asParam,
|
||||
ChangeExecFlags Flags, const RConStartArgs& args,
|
||||
LPWSTR* psFile, LPWSTR* psParam)
|
||||
CEStr& psFile, CEStr& psParam)
|
||||
{
|
||||
if (!LoadSrvMapping())
|
||||
return FALSE;
|
||||
@ -766,7 +757,7 @@ BOOL CShellProc::ChangeExecuteParams(enum CmdOnCreateType aCmd,
|
||||
lbUseDosBox = FALSE; // Don't set now
|
||||
if ((workOptions_ & ShellWorkOptions::ConsoleMode))
|
||||
{
|
||||
pszOurExe = lstrmerge(m_SrvMapping.ComSpec.ConEmuBaseDir, L"\\", (mn_ImageBits == 32) ? L"ConEmuC.exe" : L"ConEmuC64.exe"); //-V112
|
||||
pszOurExe = CEStr(m_SrvMapping.ComSpec.ConEmuBaseDir, L"\\", (mn_ImageBits == 32) ? L"ConEmuC.exe" : L"ConEmuC64.exe"); //-V112
|
||||
_ASSERTEX(ourGuiExe == false);
|
||||
}
|
||||
else
|
||||
@ -780,7 +771,7 @@ BOOL CShellProc::ChangeExecuteParams(enum CmdOnCreateType aCmd,
|
||||
if (!(workOptions_ & ShellWorkOptions::ConsoleMode))
|
||||
SetConsoleMode(true);
|
||||
|
||||
pszOurExe = lstrmerge(m_SrvMapping.ComSpec.ConEmuBaseDir, L"\\", (mn_ImageBits == 32) ? L"ConEmuC.exe" : L"ConEmuC64.exe");
|
||||
pszOurExe = CEStr(m_SrvMapping.ComSpec.ConEmuBaseDir, L"\\", (mn_ImageBits == 32) ? L"ConEmuC.exe" : L"ConEmuC64.exe");
|
||||
_ASSERTEX(ourGuiExe == false);
|
||||
}
|
||||
else if (mn_ImageBits == 16)
|
||||
@ -790,8 +781,8 @@ BOOL CShellProc::ChangeExecuteParams(enum CmdOnCreateType aCmd,
|
||||
|
||||
if (m_SrvMapping.cbSize && (m_SrvMapping.Flags & ConEmu::ConsoleFlags::DosBox))
|
||||
{
|
||||
szDosBoxExe.Attach(JoinPath(m_SrvMapping.ComSpec.ConEmuBaseDir, L"\\DosBox\\DosBox.exe"));
|
||||
szDosBoxCfg.Attach(JoinPath(m_SrvMapping.ComSpec.ConEmuBaseDir, L"\\DosBox\\DosBox.conf"));
|
||||
szDosBoxExe = JoinPath(m_SrvMapping.ComSpec.ConEmuBaseDir, L"\\DosBox\\DosBox.exe");
|
||||
szDosBoxCfg = JoinPath(m_SrvMapping.ComSpec.ConEmuBaseDir, L"\\DosBox\\DosBox.conf");
|
||||
|
||||
if (!FileExists(szDosBoxExe) || !FileExists(szDosBoxCfg))
|
||||
{
|
||||
@ -801,7 +792,7 @@ BOOL CShellProc::ChangeExecuteParams(enum CmdOnCreateType aCmd,
|
||||
}
|
||||
|
||||
// DosBox.exe - 32-bit process
|
||||
pszOurExe = lstrmerge(m_SrvMapping.ComSpec.ConEmuBaseDir, L"\\", L"ConEmuC.exe");
|
||||
pszOurExe = CEStr(m_SrvMapping.ComSpec.ConEmuBaseDir, L"\\", L"ConEmuC.exe");
|
||||
_ASSERTEX(ourGuiExe == false);
|
||||
lbUseDosBox = TRUE;
|
||||
}
|
||||
@ -817,7 +808,7 @@ BOOL CShellProc::ChangeExecuteParams(enum CmdOnCreateType aCmd,
|
||||
}
|
||||
else
|
||||
{
|
||||
pszOurExe = lstrmerge(m_SrvMapping.ComSpec.ConEmuBaseDir, L"\\", L"ConEmuC.exe");
|
||||
pszOurExe = CEStr(m_SrvMapping.ComSpec.ConEmuBaseDir, L"\\", L"ConEmuC.exe");
|
||||
_ASSERTEX(ourGuiExe == false);
|
||||
}
|
||||
}
|
||||
@ -867,12 +858,12 @@ BOOL CShellProc::ChangeExecuteParams(enum CmdOnCreateType aCmd,
|
||||
|
||||
if (aCmd == eShellExecute)
|
||||
{
|
||||
*psFile = lstrdup(pszOurExe);
|
||||
psFile.Set(pszOurExe);
|
||||
}
|
||||
else
|
||||
{
|
||||
nCchSize += wcslen(pszOurExe) + 1;
|
||||
*psFile = nullptr;
|
||||
psFile.Release();
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -927,17 +918,16 @@ BOOL CShellProc::ChangeExecuteParams(enum CmdOnCreateType aCmd,
|
||||
// В ShellExecute необходимо "ConEmuC.exe" вернуть в psFile, а для CreatePocess - в psParam
|
||||
// /C или /K в обоих случаях нужно пихать в psParam
|
||||
_ASSERTE(addDoubleQuote == FALSE); // Must not be set yet
|
||||
*psParam = static_cast<wchar_t*>(malloc(nCchSize*sizeof(wchar_t)));
|
||||
if (*psParam == nullptr)
|
||||
if (psParam.GetBuffer(nCchSize) == nullptr)
|
||||
{
|
||||
goto wrap;
|
||||
}
|
||||
(*psParam)[0] = 0;
|
||||
psParam.SetAt(0, 0);
|
||||
if (aCmd == eCreateProcess)
|
||||
{
|
||||
(*psParam)[0] = L'"';
|
||||
_wcscpy_c((*psParam)+1, nCchSize-1, pszOurExe);
|
||||
_wcscat_c((*psParam), nCchSize, L"\" ");
|
||||
psParam.Append(L"\"");
|
||||
psParam.Append(pszOurExe);
|
||||
psParam.Append(L"\" ");
|
||||
}
|
||||
|
||||
// as_Param: "C:\test.cmd" "c:\my documents\test.txt"
|
||||
@ -954,10 +944,10 @@ BOOL CShellProc::ChangeExecuteParams(enum CmdOnCreateType aCmd,
|
||||
}
|
||||
|
||||
if (lbUseDosBox)
|
||||
_wcscat_c((*psParam), nCchSize, L"/DOSBOX ");
|
||||
psParam.Append(L"/DOSBOX ");
|
||||
|
||||
if (m_SrvMapping.nLogLevel)
|
||||
_wcscat_c((*psParam), nCchSize, L"/LOG ");
|
||||
psParam.Append(L"/LOG ");
|
||||
|
||||
if (gFarMode.cbSize && gFarMode.bFarHookMode)
|
||||
{
|
||||
@ -965,7 +955,7 @@ BOOL CShellProc::ChangeExecuteParams(enum CmdOnCreateType aCmd,
|
||||
// Добавить /PARENTFAR=%u
|
||||
wchar_t szParentFar[64];
|
||||
msprintf(szParentFar, countof(szParentFar), L"/PARENTFARPID=%u ", GetCurrentProcessId());
|
||||
_wcscat_c((*psParam), nCchSize, szParentFar);
|
||||
psParam.Append(szParentFar);
|
||||
}
|
||||
|
||||
if (gbPrepareDefaultTerminal)
|
||||
@ -974,51 +964,52 @@ BOOL CShellProc::ChangeExecuteParams(enum CmdOnCreateType aCmd,
|
||||
|
||||
if (!szDefTermArg.IsEmpty())
|
||||
{
|
||||
_wcscat_c((*psParam), nCchSize, szDefTermArg);
|
||||
psParam.Append(szDefTermArg);
|
||||
}
|
||||
|
||||
_ASSERTE(((*psParam)[0] == L'\0') || (*((*psParam) + wcslen(*psParam) - 1) == L' '));
|
||||
_ASSERTE(!psParam.IsNull() && (psParam.IsEmpty() || psParam[psParam.GetLen() - 1] == L' '));
|
||||
if ((workOptions_ & ShellWorkOptions::InheritDefTerm) && (workOptions_ & ShellWorkOptions::ExeReplacedConsole) && deftermConEmuInsidePid_)
|
||||
{
|
||||
_wcscat_c((*psParam), nCchSize, L"/InheritDefTerm ");
|
||||
psParam.Append(L"/InheritDefTerm ");
|
||||
}
|
||||
|
||||
if ((workOptions_ & ShellWorkOptions::ConsoleMode))
|
||||
{
|
||||
_wcscat_c((*psParam), nCchSize, L"/AttachDefTerm /ROOT ");
|
||||
psParam.Append(L"/AttachDefTerm /ROOT ");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Starting GUI
|
||||
_wcscat_c((*psParam), nCchSize, L"-run ");
|
||||
psParam.Append(L"-run ");
|
||||
}
|
||||
|
||||
if (!szDefTermArg2.IsEmpty())
|
||||
{
|
||||
_wcscat_c((*psParam), nCchSize, szDefTermArg2);
|
||||
psParam.Append(szDefTermArg2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (args.InjectsDisable == crb_On)
|
||||
{
|
||||
_wcscat_c((*psParam), nCchSize, L"/NOINJECT ");
|
||||
psParam.Append(L"/NOINJECT ");
|
||||
}
|
||||
|
||||
_ASSERTE(((*psParam)[0] == L'\0') || (*((*psParam) + wcslen(*psParam) - 1) == L' '));
|
||||
_ASSERTE(!psParam.IsNull() && (psParam.IsEmpty() || psParam[psParam.GetLen() - 1] == L' '));
|
||||
if (lbNewConsoleFromGui)
|
||||
{
|
||||
int nCurLen = lstrlen(*psParam);
|
||||
msprintf((*psParam) + nCurLen, nCchSize - nCurLen, L"/ATTACH /GID=%u /GHWND=%08X /ROOT ",
|
||||
wchar_t rootCmd[80] = L"";
|
||||
msprintf(rootCmd, countof(rootCmd), L"/ATTACH /GID=%u /GHWND=%08X /ROOT ",
|
||||
m_SrvMapping.nGuiPID, m_SrvMapping.hConEmuRoot.GetPortableHandle());
|
||||
psParam.Append(rootCmd);
|
||||
TODO("Наверное, хорошо бы обработать /K|/C? Если консольное запускается из GUI");
|
||||
}
|
||||
else
|
||||
{
|
||||
_wcscat_c((*psParam), nCchSize, lbComSpecK ? L"/K " : L"/C ");
|
||||
psParam.Append(lbComSpecK ? L"/K " : L"/C ");
|
||||
// If was used "start" from cmd prompt or batch
|
||||
if (Flags & CEF_NEWCON_PREPEND)
|
||||
_wcscat_c((*psParam), nCchSize, L"-new_console ");
|
||||
psParam.Append(L"-new_console ");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1029,45 +1020,43 @@ BOOL CShellProc::ChangeExecuteParams(enum CmdOnCreateType aCmd,
|
||||
{
|
||||
_ASSERTEX(!gbPrepareDefaultTerminal);
|
||||
addDoubleQuote = true;
|
||||
_wcscat_c((*psParam), nCchSize, L"\"\"");
|
||||
_wcscat_c((*psParam), nCchSize, szDosBoxExe);
|
||||
_wcscat_c((*psParam), nCchSize, L"\" -noconsole ");
|
||||
_wcscat_c((*psParam), nCchSize, L" -conf \"");
|
||||
_wcscat_c((*psParam), nCchSize, szDosBoxCfg);
|
||||
_wcscat_c((*psParam), nCchSize, L"\" ");
|
||||
_wcscat_c((*psParam), nCchSize, L" -c \"");
|
||||
//_wcscat_c((*psParam), nCchSize, L" \"");
|
||||
// исполняемый файл (если есть, может быть только в asParam)
|
||||
psParam.Append(L"\"\"");
|
||||
psParam.Append(szDosBoxExe);
|
||||
psParam.Append(L"\" -noconsole ");
|
||||
psParam.Append(L" -conf \"");
|
||||
psParam.Append(szDosBoxCfg);
|
||||
psParam.Append(L"\" ");
|
||||
psParam.Append(L" -c \"");
|
||||
// executable file (if exists, could be in asParam only)
|
||||
if (asFile && *asFile)
|
||||
{
|
||||
LPCWSTR pszRunFile = asFile;
|
||||
wchar_t* pszShort = GetShortFileNameEx(asFile);
|
||||
CEStr pszShort = GetShortFileNameEx(asFile);
|
||||
if (pszShort)
|
||||
pszRunFile = pszShort;
|
||||
pszRunFile = pszShort.c_str();
|
||||
LPCWSTR pszSlash = wcsrchr(pszRunFile, L'\\');
|
||||
if (pszSlash)
|
||||
{
|
||||
if (pszRunFile[1] == L':')
|
||||
{
|
||||
_wcscatn_c((*psParam), nCchSize, pszRunFile, 2);
|
||||
_wcscat_c((*psParam), nCchSize, L"\" -c \"");
|
||||
const wchar_t drive[] = { pszRunFile[0], L':', 0 };
|
||||
psParam.Append(drive);
|
||||
psParam.Append(L"\" -c \"");
|
||||
}
|
||||
_wcscat_c((*psParam), nCchSize, L"cd ");
|
||||
_wcscatn_c((*psParam), nCchSize, pszRunFile, (pszSlash-pszRunFile));
|
||||
_wcscat_c((*psParam), nCchSize, L"\" -c \"");
|
||||
psParam.Append(L"cd ");
|
||||
CEStr folder; folder.Set(pszRunFile, (pszSlash - pszRunFile));
|
||||
psParam.Append(folder);
|
||||
psParam.Append(L"\" -c \"");
|
||||
}
|
||||
_wcscat_c((*psParam), nCchSize, pszRunFile);
|
||||
psParam.Append(pszRunFile);
|
||||
|
||||
if (pszShort)
|
||||
free(pszShort);
|
||||
|
||||
if (asParam && *asParam)
|
||||
_wcscat_c((*psParam), nCchSize, L" ");
|
||||
if (IsStrNotEmpty(asParam))
|
||||
psParam.Append(L" ");
|
||||
}
|
||||
// параметры, кавычки нужно экранировать!
|
||||
if (asParam && *asParam)
|
||||
{
|
||||
LPWSTR pszParam = nullptr;
|
||||
CEStr pszParam = nullptr;
|
||||
if (!asFile || !*asFile)
|
||||
{
|
||||
// exe-шника в asFile указано НЕ было, значит он в asParam, нужно его вытащить, и сформировать команду DosBox
|
||||
@ -1093,12 +1082,12 @@ BOOL CShellProc::ChangeExecuteParams(enum CmdOnCreateType aCmd,
|
||||
pszParam = lstrdup(pszQuot);
|
||||
INT_PTR nLen = lstrlen(pszParam);
|
||||
if (pszParam[nLen-1] == L'"')
|
||||
pszParam[nLen-1] = 0;
|
||||
pszParam.SetAt(nLen-1, 0);
|
||||
}
|
||||
asParam = pszParam;
|
||||
|
||||
LPCWSTR pszRunFile = ms_ExeTmp;
|
||||
wchar_t* pszShort = GetShortFileNameEx(ms_ExeTmp);
|
||||
CEStr pszShort = GetShortFileNameEx(ms_ExeTmp);
|
||||
if (pszShort)
|
||||
pszRunFile = pszShort;
|
||||
LPCWSTR pszSlash = wcsrchr(pszRunFile, L'\\');
|
||||
@ -1106,60 +1095,56 @@ BOOL CShellProc::ChangeExecuteParams(enum CmdOnCreateType aCmd,
|
||||
{
|
||||
if (pszRunFile[1] == L':')
|
||||
{
|
||||
_wcscatn_c((*psParam), nCchSize, pszRunFile, 2);
|
||||
_wcscat_c((*psParam), nCchSize, L"\" -c \"");
|
||||
const wchar_t drive[] = { pszRunFile[0], L':', 0 };
|
||||
psParam.Append(drive);
|
||||
psParam.Append(L"\" -c \"");
|
||||
}
|
||||
_wcscat_c((*psParam), nCchSize, L"cd ");
|
||||
_wcscatn_c((*psParam), nCchSize, pszRunFile, (pszSlash-pszRunFile));
|
||||
_wcscat_c((*psParam), nCchSize, L"\" -c \"");
|
||||
psParam.Append(L"cd ");
|
||||
CEStr folder; folder.Set(pszRunFile, (pszSlash - pszRunFile));
|
||||
psParam.Append(folder);
|
||||
psParam.Append(L"\" -c \"");
|
||||
}
|
||||
_wcscat_c((*psParam), nCchSize, pszRunFile);
|
||||
|
||||
if (pszShort)
|
||||
free(pszShort);
|
||||
psParam.Append(pszRunFile);
|
||||
|
||||
if (asParam && *asParam)
|
||||
_wcscat_c((*psParam), nCchSize, L" ");
|
||||
psParam.Append(L" ");
|
||||
}
|
||||
}
|
||||
|
||||
wchar_t* pszDst = (*psParam)+lstrlen((*psParam));
|
||||
auto dstIdx = psParam.GetLen();
|
||||
const wchar_t* pszSrc = SkipNonPrintable(asParam);
|
||||
while (pszSrc && *pszSrc)
|
||||
{
|
||||
if (*pszSrc == L'"')
|
||||
*(pszDst++) = L'\\';
|
||||
*(pszDst++) = *(pszSrc++);
|
||||
psParam.SetAt(dstIdx++, L'\\');
|
||||
psParam.SetAt(dstIdx++, *(pszSrc++));
|
||||
}
|
||||
*pszDst = 0;
|
||||
|
||||
if (pszParam)
|
||||
free(pszParam);
|
||||
psParam.SetAt(dstIdx, 0);
|
||||
}
|
||||
|
||||
_wcscat_c((*psParam), nCchSize, L"\" -c \"exit\" ");
|
||||
psParam.Append(L"\" -c \"exit\" ");
|
||||
|
||||
//_wcscat_c((*psParam), nCchSize, L" -noconsole ");
|
||||
//_wcscat_c((*psParam), nCchSize, L" -conf \"");
|
||||
//_wcscat_c((*psParam), nCchSize, szDosBoxCfg);
|
||||
//_wcscat_c((*psParam), nCchSize, L"\" ");
|
||||
//psParam.Append(L" -noconsole ");
|
||||
//psParam.Append(L" -conf \"");
|
||||
//psParam.Append(szDosBoxCfg);
|
||||
//psParam.Append(L"\" ");
|
||||
|
||||
}
|
||||
else //NOT lbUseDosBox
|
||||
{
|
||||
if (addDoubleQuote)
|
||||
_wcscat_c((*psParam), nCchSize, L"\"");
|
||||
psParam.Append(L"\"");
|
||||
|
||||
if (asFile && *asFile)
|
||||
{
|
||||
if (*asFile != L'"')
|
||||
_wcscat_c((*psParam), nCchSize, L"\"");
|
||||
_wcscat_c((*psParam), nCchSize, asFile);
|
||||
psParam.Append(L"\"");
|
||||
psParam.Append(asFile);
|
||||
if (*asFile != L'"')
|
||||
_wcscat_c((*psParam), nCchSize, L"\"");
|
||||
psParam.Append(L"\"");
|
||||
|
||||
if (asParam && *asParam)
|
||||
_wcscat_c((*psParam), nCchSize, L" ");
|
||||
psParam.Append(L" ");
|
||||
}
|
||||
|
||||
if (asParam && *asParam)
|
||||
@ -1193,7 +1178,7 @@ BOOL CShellProc::ChangeExecuteParams(enum CmdOnCreateType aCmd,
|
||||
else
|
||||
#endif
|
||||
{
|
||||
_wcscat_c((*psParam), nCchSize, asParam);
|
||||
psParam.Append(asParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1201,20 +1186,20 @@ BOOL CShellProc::ChangeExecuteParams(enum CmdOnCreateType aCmd,
|
||||
if (addDoubleQuote)
|
||||
{
|
||||
// [conemu_ml:254] TCC fails while executing: ""F:\program files\take command\tcc.exe" /C "alias where" "
|
||||
//--_wcscat_c((*psParam), nCchSize, L" \"");
|
||||
_wcscat_c((*psParam), nCchSize, L"\"");
|
||||
//--psParam.Append(L" \"");
|
||||
psParam.Append(L"\"");
|
||||
}
|
||||
|
||||
// logging
|
||||
{
|
||||
int cchLen = (*psFile ? lstrlen(*psFile) : 0) + (*psParam ? lstrlen(*psParam) : 0) + 128;
|
||||
const auto cchLen = psFile.GetLen() + psParam.GetLen() + 128;
|
||||
CEStr dbgMsg;
|
||||
if (dbgMsg.GetBuffer(cchLen))
|
||||
{
|
||||
msprintf(dbgMsg.data(), cchLen, L"RunChanged(ParentPID=%u): %s <%s> <%s>",
|
||||
GetCurrentProcessId(),
|
||||
(aCmd == eShellExecute) ? L"Shell" : (aCmd == eCreateProcess) ? L"Create" : L"???",
|
||||
*psFile ? *psFile : L"", *psParam ? *psParam : L"");
|
||||
psFile.c_str(L""), psParam.c_str(L""));
|
||||
LogShellString(dbgMsg);
|
||||
}
|
||||
}
|
||||
@ -1320,12 +1305,12 @@ bool CShellProc::PrepareNewConsoleInFile(
|
||||
// To be sure, it's our "-new_console" or "-cur_console" switch,
|
||||
// but not a something else...
|
||||
RConStartArgs lTestArg;
|
||||
lTestArg.pszSpecialCmd = lstrdup(asFile);
|
||||
lTestArg.pszSpecialCmd = lstrdup(asFile).Detach();
|
||||
if (lTestArg.ProcessNewConArg() > 0)
|
||||
{
|
||||
// pszSpecialCmd is supposed to be empty now, because asFile can contain only one "token"
|
||||
_ASSERTE(lTestArg.pszSpecialCmd == nullptr || *lTestArg.pszSpecialCmd == 0);
|
||||
lsReplaceParm = lstrmerge(asFile, (asFile && *asFile && asParam && *asParam) ? L" " : nullptr, asParam);
|
||||
lsReplaceParm = CEStr(asFile, (asFile && *asFile && asParam && *asParam) ? L" " : nullptr, asParam);
|
||||
_ASSERTE(!lsReplaceParm.IsEmpty());
|
||||
if (gbIsCmdProcess
|
||||
&& !GetStartingExeName(nullptr, lsReplaceParm, exeName)
|
||||
@ -1341,7 +1326,7 @@ bool CShellProc::PrepareNewConsoleInFile(
|
||||
// Insert "cmd.exe " before "-new_console" switches for clearness
|
||||
if (aCmd == eCreateProcess)
|
||||
{
|
||||
lsReplaceParm = lstrmerge(exeName, L" ", lsReplaceParm);
|
||||
lsReplaceParm = CEStr(exeName, L" ", lsReplaceParm);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1564,11 +1549,11 @@ CShellProc::PrepareExecuteResult CShellProc::PrepareExecuteParams(
|
||||
LPCWSTR asAction, LPCWSTR asFile, LPCWSTR asParam, LPCWSTR asDir,
|
||||
DWORD* anShellFlags, DWORD* anCreateFlags, DWORD* anStartFlags, DWORD* anShowCmd,
|
||||
HANDLE* lphStdIn, HANDLE* lphStdOut, HANDLE* lphStdErr,
|
||||
LPWSTR* psFile, LPWSTR* psParam, LPWSTR* psStartDir)
|
||||
CEStr& psFile, CEStr& psParam, CEStr& psStartDir)
|
||||
{
|
||||
// !!! anFlags может быть nullptr;
|
||||
// !!! asAction может быть nullptr;
|
||||
_ASSERTE(*psFile==nullptr && *psParam==nullptr);
|
||||
_ASSERTE(psFile.IsNull() && psParam.IsNull());
|
||||
if (!IsInterceptionEnabled())
|
||||
{
|
||||
LogShellString(L"PrepareExecuteParams skipped");
|
||||
@ -1660,7 +1645,7 @@ CShellProc::PrepareExecuteResult CShellProc::PrepareExecuteParams(
|
||||
int iLen = lstrlen(szInfo);
|
||||
msprintf(szInfo + iLen, countof(szInfo) - iLen, L" %s:x%X", parm.pName, *parm.pVal);
|
||||
}
|
||||
CEStr lsLog = lstrmerge(
|
||||
CEStr lsLog(
|
||||
(aCmd == eShellExecute) ? L"PrepareExecuteParams Shell " : L"PrepareExecuteParams Create ",
|
||||
szInfo, L"; file=", asFile, L"; param=", asParam, L";");
|
||||
LogShellString(lsLog);
|
||||
@ -1871,7 +1856,7 @@ CShellProc::PrepareExecuteResult CShellProc::PrepareExecuteParams(
|
||||
|
||||
if (asParam && *asParam && !mb_Opt_SkipNewConsole)
|
||||
{
|
||||
m_Args.pszSpecialCmd = lstrdup(asParam);
|
||||
m_Args.pszSpecialCmd = lstrdup(asParam).Detach();
|
||||
if (m_Args.ProcessNewConArg() > 0)
|
||||
{
|
||||
if (m_Args.NoDefaultTerm == crb_On)
|
||||
@ -2211,7 +2196,7 @@ CShellProc::PrepareExecuteResult CShellProc::PrepareExecuteParams(
|
||||
}
|
||||
}
|
||||
pIn = NewCmdOnCreate(eParmsChanged,
|
||||
asAction, *psFile, *psParam, asDir,
|
||||
asAction, psFile.c_str(), psParam.c_str(), asDir,
|
||||
anShellFlags, anCreateFlags, anStartFlags, anShowCmd,
|
||||
mn_ImageBits, mn_ImageSubsystem,
|
||||
hIn, hOut, hErr/*, szBaseDir, mb_DosBoxAllowed*/);
|
||||
@ -2259,23 +2244,23 @@ wrap:
|
||||
// Указание рабочей папки
|
||||
if (m_Args.pszStartupDir)
|
||||
{
|
||||
*psStartDir = m_Args.pszStartupDir;
|
||||
psStartDir.Attach(std::move(m_Args.pszStartupDir));
|
||||
m_Args.pszStartupDir = nullptr;
|
||||
}
|
||||
|
||||
if (bForceCutNewConsole && lsReplaceFile)
|
||||
{
|
||||
*psFile = lsReplaceFile.Detach();
|
||||
psFile = std::move(lsReplaceFile);
|
||||
}
|
||||
|
||||
if (bForceCutNewConsole && lsReplaceParm && (aCmd == eShellExecute))
|
||||
{
|
||||
*psParam = lsReplaceParm.Detach();
|
||||
psParam = std::move(lsReplaceParm);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Parameters substitution (cut -cur_console, -new_console)
|
||||
*psParam = m_Args.pszSpecialCmd;
|
||||
psParam.Attach(std::move(m_Args.pszSpecialCmd));
|
||||
m_Args.pszSpecialCmd = nullptr;
|
||||
}
|
||||
|
||||
@ -2319,7 +2304,7 @@ wrap:
|
||||
|
||||
if (lbChanged && (psStartDir && !*psStartDir) && !szLnkDir.IsEmpty())
|
||||
{
|
||||
*psStartDir = szLnkDir.Detach();
|
||||
psStartDir = std::move(szLnkDir);
|
||||
}
|
||||
|
||||
if (m_Args.ForceHooksServer == crb_On)
|
||||
@ -2330,8 +2315,8 @@ wrap:
|
||||
#ifdef DEBUG_SHELL_LOG_OUTPUT
|
||||
{
|
||||
const CEStr dbgStr(lbChanged ? L"PrepareExecuteParams changed: file=" : L"PrepareExecuteParams not_changed: file=",
|
||||
(psFile&&* psFile) ? *psFile : L"<null>", L"; param=", (psParam&&* psParam) ? *psParam : L"<null>",
|
||||
L"; dir=", (psStartDir&&* psStartDir) ? *psStartDir : L"<null>", L";");
|
||||
psFile.c_str(L"<null>"), L"; param=", psParam.c_str(L"<null>"),
|
||||
L"; dir=", psStartDir.c_str(L"<null>"), L";");
|
||||
LogShellString(dbgStr);
|
||||
}
|
||||
#endif
|
||||
@ -2369,7 +2354,7 @@ bool CShellProc::GetStartingExeName(LPCWSTR asFile, LPCWSTR asParam, CEStr& rsEx
|
||||
RConStartArgs lTempArgs;
|
||||
if (wcsstr(asParam, L"-new_console") || wcsstr(asParam, L"-cur_console"))
|
||||
{
|
||||
lTempArgs.pszSpecialCmd = lstrdup(SkipNonPrintable(asParam));
|
||||
lTempArgs.pszSpecialCmd = lstrdup(SkipNonPrintable(asParam)).Detach();
|
||||
if (lTempArgs.ProcessNewConArg())
|
||||
{
|
||||
asParam = SkipNonPrintable(lTempArgs.pszSpecialCmd);
|
||||
@ -2414,7 +2399,7 @@ BOOL CShellProc::OnShellExecuteA(LPCSTR* asAction, LPCSTR* asFile, LPCSTR* asPar
|
||||
mpwsz_TempAction, mpwsz_TempFile, mpwsz_TempParam, lsDir,
|
||||
anFlags, nullptr, nullptr, anShowCmd,
|
||||
nullptr, nullptr, nullptr, // *StdHandles
|
||||
&mpwsz_TempRetFile, &mpwsz_TempRetParam, &mpwsz_TempRetDir);
|
||||
mpwsz_TempRetFile, mpwsz_TempRetParam, mpwsz_TempRetDir);
|
||||
if (prepareResult == PrepareExecuteResult::Restrict)
|
||||
return false;
|
||||
|
||||
@ -2483,7 +2468,7 @@ BOOL CShellProc::OnShellExecuteW(LPCWSTR* asAction, LPCWSTR* asFile, LPCWSTR* as
|
||||
asDir ? *asDir : nullptr,
|
||||
anFlags, nullptr, nullptr, anShowCmd,
|
||||
nullptr, nullptr, nullptr, // *StdHandles
|
||||
&mpwsz_TempRetFile, &mpwsz_TempRetParam, &mpwsz_TempRetDir);
|
||||
mpwsz_TempRetFile, mpwsz_TempRetParam, mpwsz_TempRetDir);
|
||||
if (prepareResult == PrepareExecuteResult::Restrict)
|
||||
return false;
|
||||
|
||||
@ -2795,7 +2780,7 @@ BOOL CShellProc::OnCreateProcessA(LPCSTR* asFile, LPCSTR* asCmdLine, LPCSTR* asD
|
||||
nullptr, mpwsz_TempFile, mpwsz_TempParam, lsDir,
|
||||
nullptr, anCreationFlags, &lpSi->dwFlags, &state.showCmd,
|
||||
&lpSi->hStdInput, &lpSi->hStdOutput, &lpSi->hStdError,
|
||||
&mpwsz_TempRetFile, &mpwsz_TempRetParam, &mpwsz_TempRetDir);
|
||||
mpwsz_TempRetFile, mpwsz_TempRetParam, mpwsz_TempRetDir);
|
||||
if (prepareResult == PrepareExecuteResult::Restrict)
|
||||
return false;
|
||||
|
||||
@ -2903,7 +2888,7 @@ BOOL CShellProc::OnCreateProcessW(LPCWSTR* asFile, LPCWSTR* asCmdLine, LPCWSTR*
|
||||
asDir ? *asDir : nullptr,
|
||||
nullptr, anCreationFlags, &lpSi->dwFlags, &state.showCmd,
|
||||
&lpSi->hStdInput, &lpSi->hStdOutput, &lpSi->hStdError,
|
||||
&mpwsz_TempRetFile, &mpwsz_TempRetParam, &mpwsz_TempRetDir);
|
||||
mpwsz_TempRetFile, mpwsz_TempRetParam, mpwsz_TempRetDir);
|
||||
if (prepareResult == PrepareExecuteResult::Restrict)
|
||||
return false;
|
||||
|
||||
|
@ -110,16 +110,16 @@ private:
|
||||
UINT mn_CP; // = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
|
||||
|
||||
// Для конвертации параметров Ansi функций (работаем через Unicode для унификации)
|
||||
LPWSTR mpwsz_TempAction = nullptr; // = str2wcs(asAction, nCP);
|
||||
LPWSTR mpwsz_TempFile = nullptr; // = str2wcs(asFile, nCP);
|
||||
LPWSTR mpwsz_TempParam = nullptr; // = str2wcs(asParam, nCP);
|
||||
CEStr mpwsz_TempAction = nullptr; // = str2wcs(asAction, nCP);
|
||||
CEStr mpwsz_TempFile = nullptr; // = str2wcs(asFile, nCP);
|
||||
CEStr mpwsz_TempParam = nullptr; // = str2wcs(asParam, nCP);
|
||||
|
||||
LPSTR mpsz_TempRetFile = nullptr;
|
||||
LPSTR mpsz_TempRetParam = nullptr;
|
||||
LPSTR mpsz_TempRetDir = nullptr;
|
||||
LPWSTR mpwsz_TempRetFile = nullptr;
|
||||
LPWSTR mpwsz_TempRetParam = nullptr;
|
||||
LPWSTR mpwsz_TempRetDir = nullptr;
|
||||
CEStrA mpsz_TempRetFile = nullptr;
|
||||
CEStrA mpsz_TempRetParam = nullptr;
|
||||
CEStrA mpsz_TempRetDir = nullptr;
|
||||
CEStr mpwsz_TempRetFile = nullptr;
|
||||
CEStr mpwsz_TempRetParam = nullptr;
|
||||
CEStr mpwsz_TempRetDir = nullptr;
|
||||
|
||||
template<typename T>
|
||||
struct StructDeleter { // deleter
|
||||
@ -219,8 +219,8 @@ private:
|
||||
};
|
||||
|
||||
private:
|
||||
static wchar_t* str2wcs(const char* psz, UINT anCP);
|
||||
static char* wcs2str(const wchar_t* pwsz, UINT anCP);
|
||||
static CEStr str2wcs(const char* psz, UINT anCP);
|
||||
static CEStrA wcs2str(const wchar_t* pwsz, UINT anCP);
|
||||
bool IsAnsiConLoader(LPCWSTR asFile, LPCWSTR asParam);
|
||||
static bool PrepareNewConsoleInFile(
|
||||
CmdOnCreateType aCmd, LPCWSTR& asFile, LPCWSTR& asParam,
|
||||
@ -233,11 +233,11 @@ private:
|
||||
LPCWSTR asAction, LPCWSTR asFile, LPCWSTR asParam, LPCWSTR asDir,
|
||||
DWORD* anShellFlags, DWORD* anCreateFlags, DWORD* anStartFlags, DWORD* anShowCmd, // или Shell & Create флаги
|
||||
HANDLE* lphStdIn, HANDLE* lphStdOut, HANDLE* lphStdErr,
|
||||
LPWSTR* psFile, LPWSTR* psParam, LPWSTR* psStartDir);
|
||||
CEStr& psFile, CEStr& psParam, CEStr& psStartDir);
|
||||
BOOL ChangeExecuteParams(enum CmdOnCreateType aCmd,
|
||||
LPCWSTR asFile, LPCWSTR asParam,
|
||||
ChangeExecFlags Flags, const RConStartArgs& args,
|
||||
LPWSTR* psFile, LPWSTR* psParam);
|
||||
CEStr& psFile, CEStr& psParam);
|
||||
BOOL FixShellArgs(DWORD afMask, HWND ahWnd, DWORD* pfMask, HWND* phWnd) const;
|
||||
HWND FindCheckConEmuWindow();
|
||||
void LogExitLine(int rc, int line) const;
|
||||
|
@ -94,7 +94,7 @@ BOOL WINAPI OnSetConsoleTitleW(LPCWSTR lpConsoleTitle)
|
||||
gpLastSetConTitle = new CEStr(lstrdup(lpConsoleTitle));
|
||||
else
|
||||
gpLastSetConTitle->Set(lpConsoleTitle);
|
||||
CEStr lsDbg(lstrmerge(L"SetConsoleTitleW('", lpConsoleTitle, L"')\n"));
|
||||
CEStr lsDbg(L"SetConsoleTitleW('", lpConsoleTitle, L"')\n");
|
||||
OutputDebugString(lsDbg);
|
||||
#endif
|
||||
|
||||
|
@ -61,7 +61,7 @@ HRESULT OurShellExecCmdLine(HWND hwnd, LPCWSTR pwszCommand, LPCWSTR pwszStartDir
|
||||
HRESULT hr = E_UNEXPECTED;
|
||||
BOOL bShell = FALSE;
|
||||
|
||||
const CEStr lsLog = lstrmerge(L"OnShellExecCmdLine", bRunAsAdmin ? L"(RunAs): " : L": ", pwszCommand);
|
||||
const CEStr lsLog(L"OnShellExecCmdLine", bRunAsAdmin ? L"(RunAs): " : L": ", pwszCommand);
|
||||
CDefTermHk::DefTermLogString(lsLog);
|
||||
|
||||
// Bad thing, ShellExecuteEx needs File&Parm, but we get both in pwszCommand
|
||||
@ -104,7 +104,7 @@ HRESULT OurShellExecCmdLine(HWND hwnd, LPCWSTR pwszCommand, LPCWSTR pwszStartDir
|
||||
}
|
||||
else
|
||||
{
|
||||
wchar_t* pwCommand = lstrdup(pwszCommand);
|
||||
wchar_t* pwCommand = lstrdup(pwszCommand).Detach();
|
||||
const DWORD nCreateFlags = CREATE_NEW_CONSOLE | CREATE_UNICODE_ENVIRONMENT | CREATE_DEFAULT_ERROR_MODE;
|
||||
STARTUPINFO si = {};
|
||||
si.cb = sizeof(si);
|
||||
|
@ -986,7 +986,7 @@ int WINAPI OnGetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
|
||||
|
||||
#ifdef DEBUG_CON_TITLE
|
||||
wchar_t szPrefix[32]; swprintf_c(szPrefix, L"GetWindowTextW(x%08X)='", (DWORD)(DWORD_PTR)hWnd);
|
||||
CEStr lsDbg(lstrmerge(szPrefix, lpString, L"'\n"));
|
||||
CEStr lsDbg(szPrefix, lpString, L"'\n");
|
||||
OutputDebugString(lsDbg);
|
||||
if (gFarMode.cbSize && lpString && gpLastSetConTitle && gpLastSetConTitle->ms_Arg)
|
||||
{
|
||||
|
@ -714,7 +714,6 @@
|
||||
<ClCompile Include="ConEmuHk\ShellProcessor_test.cpp" />
|
||||
<ClCompile Include="UnitTests\ansi_test.cpp" />
|
||||
<ClCompile Include="UnitTests\main_test.cpp" />
|
||||
<ClCompile Include="UnitTests\test_crlf\crlf_test.cpp" />
|
||||
<ClCompile Include="UnitTests\test_mock_file.cpp" />
|
||||
<ClCompile Include="UnitTests\test_stubs.cpp" />
|
||||
<ClCompile Include="common\CEHandle.cpp" />
|
||||
|
@ -1256,9 +1256,6 @@
|
||||
<ClCompile Include="UnitTests\main_test.cpp">
|
||||
<Filter>tests</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="UnitTests\test_crlf\crlf_test.cpp">
|
||||
<Filter>tests</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="UnitTests\test_mock_file.cpp">
|
||||
<Filter>mocks</Filter>
|
||||
</ClCompile>
|
||||
|
@ -114,7 +114,7 @@ bool isCharAltFont(ucs32 inChar) { return false; }
|
||||
bool LogString(LPCWSTR asText) { return false; }
|
||||
bool LogString(LPCWSTR asInfo, bool abWriteTime /*= true*/, bool abWriteLine /*= true*/) { return false; }
|
||||
BOOL MoveWindowRect(HWND hWnd, const RECT& rcWnd, BOOL bRepaint) { return FALSE; }
|
||||
size_t MyGetDlgItemText(HWND hDlg, WORD nID, size_t& cchMax, wchar_t*& pszText) { return 0; }
|
||||
size_t MyGetDlgItemText(HWND hDlg, WORD nID, CEStr& pszText) { return 0; }
|
||||
void PatchMsgBoxIcon(HWND hWnd, UINT messg, WPARAM wParam, LPARAM lParam) {}
|
||||
bool ProcessMessage(MSG& Msg) { return false; }
|
||||
void RaiseTestException() {}
|
||||
|
@ -62,17 +62,20 @@ CEStr::CEStr(const wchar_t* asStr1, const wchar_t* asStr2/*= nullptr*/, const wc
|
||||
CESTRLOG3("CEStr::CEStr(const wchar_t* x%p, x%p, x%p, ...)", asStr1, asStr2, asStr3);
|
||||
|
||||
ssize_t cchMax = 0;
|
||||
size_t nonNulls = 0;
|
||||
const size_t Count = 9;
|
||||
ssize_t cch[Count] = {};
|
||||
const wchar_t* pszStr[Count] = { asStr1, asStr2, asStr3, asStr4, asStr5, asStr6, asStr7, asStr8, asStr9 };
|
||||
|
||||
for (size_t i = 0; i < Count; i++)
|
||||
{
|
||||
cch[i] = pszStr[i] ? lstrlen(pszStr[i]) : 0;
|
||||
if (pszStr[i] == nullptr) continue;
|
||||
cch[i] = lstrlen(pszStr[i]);
|
||||
cchMax += cch[i];
|
||||
++nonNulls;
|
||||
}
|
||||
|
||||
if (GetBuffer(cchMax))
|
||||
if (nonNulls && GetBuffer(cchMax))
|
||||
{
|
||||
wchar_t* psz = data();
|
||||
|
||||
@ -244,9 +247,9 @@ wchar_t* CEStr::GetBuffer(const ssize_t cchMaxLen)
|
||||
{
|
||||
CESTRLOG1("CEStr::GetBuffer(%i)", static_cast<int>(cchMaxLen));
|
||||
|
||||
if (cchMaxLen <= 0)
|
||||
if (cchMaxLen < 0)
|
||||
{
|
||||
_ASSERTE(cchMaxLen > 0);
|
||||
_ASSERTE(cchMaxLen >= 0);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -305,6 +308,13 @@ wchar_t* CEStr::Detach()
|
||||
return psz;
|
||||
}
|
||||
|
||||
void CEStr::Swap(wchar_t*& asPtr)
|
||||
{
|
||||
maxCount_ = 0;
|
||||
std::swap(asPtr, ms_Val);
|
||||
maxCount_ = ms_Val ? (wcslen(ms_Val) + 1) : 0;
|
||||
}
|
||||
|
||||
void CEStr::Release()
|
||||
{
|
||||
CESTRLOG1("CEStr::Release(x%p)", ms_Val);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user