diff --git a/far/FarEng.hlf.m4 b/far/FarEng.hlf.m4 index 0b28b8a797..ae043e06c0 100644 --- a/far/FarEng.hlf.m4 +++ b/far/FarEng.hlf.m4 @@ -5502,16 +5502,15 @@ $ #far:config System.Executor.ExcludeCmds# Изменение этого параметра возможно через ~far:config~@FarConfig@ -@System.Executor.NotQuotedShell -$ #far:config System.Executor.NotQuotedShell# - При передаче строки командному процессору, она заключается в кавычки. Это необходимо для правильной работы CMD.EXE. - Параметр позволяет задать список командных процессоров, для которых строка в кавычки заключаться не будет. Имя командного процессора берётся из переменной среды %comspec%. +@System.Executor.ComspecArguments +$ #far:config System.Executor.ComspecArguments# - По умолчанию значение = "TCC.EXE;TCCLE.EXE". + Arguments for command processor. #{0}# is a placeholder for entire executing command. + If your processor uses differnt keys or quotes you can change it here. - В параметре можно использовать переменные среды. + Default value: #/S /C "{0}"# (compatible with cmd.exe) - Изменение этого параметра возможно через ~far:config~@FarConfig@ + This parameter can be changed only via ~far:config~@FarConfig@ @System.Executor.FullTitle $ #far:config System.Executor.FullTitle# @@ -5536,28 +5535,6 @@ $ #far:config Interface.FormatNumberSeparators# Изменение этого параметра возможно через ~far:config~@FarConfig@ -@System.Executor.ComSpecParams -$ #far:config System.Executor.ComSpecParams# - Параметр позволяет задавать ключи для командного процессора при запуске внешних программ. - - Перед запуском внешней программы Far Manager формирует строку запуска подобно следующему шаблону: - - COMSPEC ComSpecParams Program ProgramParams - - Здесь - - COMSPEC - значение переменной среды %COMSPEC% - ComSpecParams - этот параметр (для cmd.exe это '/C ') - Program - запускаемая программа - ProgramParams - параметры запускаемой программы - - По умолчанию значение = "/C" - - Изменение этого параметра возможно через ~far:config~@FarConfig@ - - See also ~System.Executor.NotQuotedShell~@System.Executor.NotQuotedShell@, -~System.Executor.ExcludeCmds~@System.Executor.ExcludeCmds@ - @System.Executor.BatchType $ #far:config System.Executor.BatchType# Параметр позволяет задавать список расширений файлов, по которым Far Manager будет различать какие diff --git a/far/FarRus.hlf.m4 b/far/FarRus.hlf.m4 index 315fa2483a..f1aecce812 100644 --- a/far/FarRus.hlf.m4 +++ b/far/FarRus.hlf.m4 @@ -5624,14 +5624,13 @@ $ #far:config System.Executor.ExcludeCmds# Изменение этого параметра возможно через ~far:config~@FarConfig@ -@System.Executor.NotQuotedShell -$ #far:config System.Executor.NotQuotedShell# - При передаче строки командному процессору, она заключается в кавычки. Это необходимо для правильной работы CMD.EXE. - Параметр позволяет задать список командных процессоров, для которых строка в кавычки заключаться не будет. Имя командного процессора берётся из переменной среды %comspec%. +@System.Executor.ComspecArguments +$ #far:config System.Executor.ComspecArguments# - По умолчанию значение = "TCC.EXE;TCCLE.EXE". + Аргументы, передаваемые командному процессору. #{0}# заменяется непосредственно исполняемой командой. + Если ваш процессор использует другие ключи и/или кавычки, вы можете задать это здесь. - В параметре можно использовать переменные среды. + Значение по умолчанию: #/S /C "{0}"# (совместимо с cmd.exe) Изменение этого параметра возможно через ~far:config~@FarConfig@ @@ -5658,28 +5657,6 @@ $ #far:config Interface.FormatNumberSeparators# Изменение этого параметра возможно через ~far:config~@FarConfig@ -@System.Executor.ComSpecParams -$ #far:config System.Executor.ComSpecParams# - Параметр позволяет задавать ключи для командного процессора при запуске внешних программ. - - Перед запуском внешней программы Far Manager формирует строку запуска подобно следующему шаблону: - - COMSPEC ComSpecParams Program ProgramParams - - Здесь - - COMSPEC - значение переменной среды %COMSPEC% - ComSpecParams - этот параметр (для cmd.exe это '/C ') - Program - запускаемая программа - ProgramParams - параметры запускаемой программы - - По умолчанию значение = "/C" - - Изменение этого параметра возможно через ~far:config~@FarConfig@ - - См. также ~System.Executor.NotQuotedShell~@System.Executor.NotQuotedShell@, -~System.Executor.ExcludeCmds~@System.Executor.ExcludeCmds@ - @System.Executor.BatchType $ #far:config System.Executor.BatchType# Параметр позволяет задавать список расширений файлов, по которым Far Manager будет различать какие diff --git a/far/PluginA.hpp b/far/PluginA.hpp index 578517deb7..eb6c592af6 100644 --- a/far/PluginA.hpp +++ b/far/PluginA.hpp @@ -96,8 +96,8 @@ class PluginA: public Plugin const char *GetMsgA(LNGID nID) const; private: - virtual void Prologue() override { SetFileApisToOEM(); OEMApiCnt++; } - virtual void Epilogue() override { OEMApiCnt--; if(!OEMApiCnt) SetFileApisToANSI(); } + virtual void Prologue() override { Plugin::Prologue(); SetFileApisToOEM(); ++OEMApiCnt; } + virtual void Epilogue() override { Plugin::Epilogue(); --OEMApiCnt; if(!OEMApiCnt) SetFileApisToANSI(); } void FreePluginInfo(); void ConvertPluginInfo(const oldfar::PluginInfo &Src, PluginInfo *Dest); @@ -110,7 +110,7 @@ class PluginA: public Plugin oldfar::PluginPanelItem *pFDPanelItemA; oldfar::PluginPanelItem *pVFDPanelItemA; - UINT64 OEMApiCnt; + std::atomic_ulong OEMApiCnt; bool opif_shortcut; std::unique_ptr FileVersion; diff --git a/far/changelog b/far/changelog index 00b637e614..b1cd83bc28 100644 --- a/far/changelog +++ b/far/changelog @@ -1,4 +1,14 @@ -zg 28.04.2016 13:20:04 +0200 - build 4643 +drkns 28.04.2016 16:47:33 +0200 - build 4644 + +1. Продолжение экспериментальных изменений в запускателе: + - System.Executor.NotQuotedShell и System.Executor.ComSpecParams больше нет. Однако, теперь есть System.Executor.ComspecArguments, управляющий одновременно и ключами, и кавычками. + По умолчанию значение совместимо с cmd.exe - /S /C "{0}", где {0} будет заменено исполняемой командой. + Для bash замените на -c '{0}', для tcc - на -с {0} + - (частично) #0003223: при передаче в comspec разворачивалось больше, чем нужно. + +2. Используем std::atomic вместо Interlocked*(). + +zg 28.04.2016 13:20:04 +0200 - build 4643 1. в комбобоксе не срабатывал хоткей для текущего элемента. diff --git a/far/cmdline.cpp b/far/cmdline.cpp index f20fa7f92e..5a48f715f1 100644 --- a/far/cmdline.cpp +++ b/far/cmdline.cpp @@ -436,7 +436,7 @@ int CommandLine::ProcessKey(const Manager::Key& Key) Info.Command = strStr; Info.WaitMode = Info.no_wait; Info.NewWindow = IsNewWindow; - Info.DirectRun = false; + Info.ExecMode = Info.detect; Info.RunAs = IsRunAs; SetString(L"", false); @@ -851,7 +851,7 @@ void CommandLine::ShowViewEditHistory() Info.Command = strStr; Info.WaitMode = Type == HR_EXTERNAL_WAIT? Info.wait_finish : Info.no_wait; Info.NewWindow = false; - Info.DirectRun = false; + Info.ExecMode = Info.detect; Info.RunAs = false; ExecString(Info); @@ -1053,7 +1053,7 @@ void CommandLine::ExecString(execute_info& Info) FarChDir(m_CurDir); - if (!Info.DirectRun) + if (Info.ExecMode != Info.direct) { if (!Info.Command.empty() && Info.Command[0] == L'@') { diff --git a/far/cmdline.hpp b/far/cmdline.hpp index c7bf7ccb4b..d8740cd98f 100644 --- a/far/cmdline.hpp +++ b/far/cmdline.hpp @@ -41,11 +41,12 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. struct execute_info { enum wait_mode { no_wait, wait_idle, wait_finish }; + enum exec_mode { detect, direct, external }; string Command; wait_mode WaitMode; bool NewWindow; - bool DirectRun; + exec_mode ExecMode; bool RunAs; }; diff --git a/far/config.cpp b/far/config.cpp index 29bffee2c7..d36d99d1cd 100644 --- a/far/config.cpp +++ b/far/config.cpp @@ -1805,8 +1805,7 @@ void Options::InitConfigData() {FSSF_PRIVATE, NKeySystemExecutor,L"RestoreCP", OPT_DEF(Exec.RestoreCPAfterExecute, true)}, {FSSF_PRIVATE, NKeySystemExecutor,L"UseAppPath", OPT_DEF(Exec.ExecuteUseAppPath, true)}, {FSSF_PRIVATE, NKeySystemExecutor,L"UseHomeDir", OPT_DEF(Exec.UseHomeDir, true)}, - {FSSF_PRIVATE, NKeySystemExecutor,L"NotQuotedShell", OPT_DEF(Exec.strNotQuotedShell, L"TCC.EXE;TCCLE.EXE")}, - {FSSF_PRIVATE, NKeySystemExecutor,L"ComSpecParams", OPT_DEF(Exec.strComSpecParams, L"/C")}, + {FSSF_PRIVATE, NKeySystemExecutor,L"ComspecFormat", OPT_DEF(Exec.ComspecArguments, L"/S /C \"{0}\"")}, {FSSF_PRIVATE, NKeyViewer,L"AutoDetectCodePage", OPT_DEF(ViOpt.AutoDetectCodePage, true)}, {FSSF_PRIVATE, NKeyViewer,L"DefaultCodePage", OPT_DEF(ViOpt.DefaultCodePage, GetACP())}, @@ -3036,7 +3035,7 @@ void Options::ShellOptions(bool LastCommand, const MOUSE_EVENT_RECORD *MouseEven } } - int CurrentWindowType = Global->WindowManager->GetCurrentWindow()->GetType(); + const auto CurrentWindowType = Global->WindowManager->GetCurrentWindow()->GetType(); // TODO:Здесь как то нужно изменить, чтобы учесть будущие новые типы полноэкранных окон // или то, что, скажем редактор/вьювер может быть не полноэкранным diff --git a/far/config.hpp b/far/config.hpp index b4424e5fa2..2b6244e608 100644 --- a/far/config.hpp +++ b/far/config.hpp @@ -600,10 +600,9 @@ class Options: noncopyable BoolOption ExecuteFullTitle; StringOption strExecuteBatchType; StringOption strExcludeCmds; - StringOption strComSpecParams; + StringOption ComspecArguments; BoolOption UseHomeDir; // cd ~ StringOption strHomeDir; // cd ~ - StringOption strNotQuotedShell; }; palette Palette; diff --git a/far/dialog.cpp b/far/dialog.cpp index 5d3c756499..bcff99e0e4 100644 --- a/far/dialog.cpp +++ b/far/dialog.cpp @@ -4301,12 +4301,14 @@ void Dialog::Process() if (m_ExitCode == -1) { - static LONG in_dialog = -1; + static std::atomic_long DialogsCount(0); clock_t btm = 0; long save = 0; DialogMode.Set(DMODE_BEGINLOOP); - if (!InterlockedIncrement(&in_dialog)) + ++DialogsCount; + + if (DialogsCount == 1) { btm = clock(); save = WaitUserTime; @@ -4317,7 +4319,9 @@ void Dialog::Process() Global->WindowManager->ExecuteModal(shared_from_this()); save += (clock() - btm); - if (InterlockedDecrement(&in_dialog) == -1) + --DialogsCount; + + if (!DialogsCount) WaitUserTime = save; } diff --git a/far/elevation.hpp b/far/elevation.hpp index 3d11958439..acdb393669 100644 --- a/far/elevation.hpp +++ b/far/elevation.hpp @@ -73,8 +73,8 @@ class elevation: noncopyable class suppress: noncopyable { public: - suppress(): m_owner(Global? Global->Elevation : nullptr) { if (m_owner) InterlockedIncrement(&m_owner->m_suppressions); } - ~suppress() { if (m_owner) InterlockedDecrement(&m_owner->m_suppressions); } + suppress(): m_owner(Global? Global->Elevation : nullptr) { if (m_owner) ++m_owner->m_suppressions; } + ~suppress() { if (m_owner) --m_owner->m_suppressions; } private: elevation* m_owner; @@ -91,7 +91,7 @@ class elevation: noncopyable bool Initialize(); bool ElevationApproveDlg(LNGID Why, const string& Object); - volatile long m_suppressions; + std::atomic_ulong m_suppressions; os::handle m_pipe; os::handle m_process; os::handle m_job; diff --git a/far/execute.cpp b/far/execute.cpp index 79f80e4632..c7b7604765 100644 --- a/far/execute.cpp +++ b/far/execute.cpp @@ -368,66 +368,59 @@ static bool FindModule(const string& Module, string &strDest,DWORD &ImageSubsyst } /* - возвращает 2*PipeFound + 1*Escaped + true: ok, found command & arguments. + false: it's too complex, let's comspec deal with it. */ -static int PartCmdLine(const string& CmdStr, string &strNewCmdStr, string &strNewCmdPar) +static bool PartCmdLine(const string& CmdStr, string &strNewCmdStr, string &strNewCmdPar) { - int PipeFound = 0, Escaped = 0; - bool quoted = false; - strNewCmdStr = os::env::expand_strings(CmdStr); - RemoveExternalSpaces(strNewCmdStr); - const wchar_t * const NewCmdStr = strNewCmdStr.data(); - const wchar_t *CmdPtr = NewCmdStr; - const wchar_t *ParPtr = nullptr; + auto Begin = CmdStr.cbegin() + CmdStr.find_first_not_of(L' '); + auto End = CmdStr.cend(); + auto ParamsBegin = End; + // Разделим собственно команду для исполнения и параметры. // При этом заодно определим наличие символов переопределения потоков // Работаем с учетом кавычек. Т.е. пайп в кавычках - не пайп. - static const wchar_t ending_chars[] = L"/ <>|&"; + static const wchar_t ending_chars[] = L" <>|&"; - while (*CmdPtr) + bool InQuotes = false; + bool TooComplex = false; + for (auto i = Begin; i != End; ++i) { - if (*CmdPtr == L'"') - quoted = !quoted; - - if (!quoted && *CmdPtr == L'^' && CmdPtr[1] > L' ') // "^>" и иже с ним + if (*i == L'"') { - Escaped = 1; // - CmdPtr++; // ??? может быть '^' надо удалить... + InQuotes = !InQuotes; } - else if (!quoted && CmdPtr != NewCmdStr) + + if (!InQuotes) { - const wchar_t *ending = wcschr(ending_chars, *CmdPtr); - if ( ending ) + if (const auto ending = wcschr(ending_chars, *i)) { - if (!ParPtr) - ParPtr = CmdPtr; - - if (ending >= ending_chars+2) - PipeFound = 1; + if (ParamsBegin == End) + { + ParamsBegin = i; + } + if (ending >= ending_chars + 1) + { + TooComplex = true; + break; + } } } - - if (ParPtr && PipeFound) // Нам больше ничего не надо узнавать - break; - - CmdPtr++; } - if (ParPtr) // Мы нашли параметры и отделяем мух от котлет - { - size_t Pos = ParPtr - NewCmdStr; - if (*ParPtr == L' ') //AY: первый пробел между командой и параметрами не нужен, - ++ParPtr; // он добавляется заново в Execute. - - strNewCmdPar = ParPtr; - strNewCmdStr.resize(Pos); + strNewCmdStr.assign(Begin, ParamsBegin); + if (ParamsBegin != End) // Мы нашли параметры и отделяем мух от котлет + { + //AY: первый пробел между командой и параметрами не нужен, он добавляется заново в Execute. + if (*ParamsBegin == L' ') + { + ++ParamsBegin; + } + strNewCmdPar.assign(ParamsBegin, End); } - - Unquote(strNewCmdStr); - - return 2*PipeFound + 1*Escaped; + return !TooComplex; } static bool RunAsSupported(LPCWSTR Name) @@ -663,7 +656,7 @@ void OpenFolderInShell(const string& Folder) Info.Command = Folder; Info.WaitMode = Info.no_wait; Info.NewWindow = true; - Info.DirectRun = true; + Info.ExecMode = Info.direct; Info.RunAs = false; Execute(Info, true, true); @@ -675,7 +668,11 @@ bool Execute(execute_info& Info, bool FolderRun, bool Silent, const std::functio string strNewCmdStr; string strNewCmdPar; - int PipeOrEscaped = PartCmdLine(Info.Command, strNewCmdStr, strNewCmdPar); + if (!PartCmdLine(Info.Command, strNewCmdStr, strNewCmdPar)) + { + strNewCmdStr = Info.Command; + Info.ExecMode = Info.external; + } const bool IsDirectory = os::fs::is_directory(strNewCmdStr); @@ -696,7 +693,7 @@ bool Execute(execute_info& Info, bool FolderRun, bool Silent, const std::functio if (strNewCmdPar.empty() && IsDirectory) { ConvertNameToFull(strNewCmdStr, strNewCmdStr); - Info.DirectRun = true; + Info.ExecMode = Info.direct; FolderRun=true; } } @@ -707,11 +704,11 @@ bool Execute(execute_info& Info, bool FolderRun, bool Silent, const std::functio os::handle Process; LPCWSTR lpVerb = nullptr; - if (FolderRun && Info.DirectRun) + if (FolderRun && Info.ExecMode == Info.direct) { AddEndSlash(strNewCmdStr); // НАДА, иначе ShellExecuteEx "возьмет" BAT/CMD/пр.ересь, но не каталог } - else + else if (Info.ExecMode == Info.detect) { bool internal; FindModule(strNewCmdStr,strNewCmdStr,dwSubSystem,internal); @@ -732,36 +729,18 @@ bool Execute(execute_info& Info, bool FolderRun, bool Silent, const std::functio dwSubSystem=dwSubSystem2; } } - - if (dwSubSystem == IMAGE_SUBSYSTEM_UNKNOWN && !StrCmpNI(strNewCmdStr.data(),L"ECHO.",5)) // вариант "echo." - { - strNewCmdStr.replace(4, 1, 1, L' '); - PartCmdLine(strNewCmdStr,strNewCmdStr,strNewCmdPar); - - if (strNewCmdPar.empty()) - strNewCmdStr+=L'.'; - - FindModule(strNewCmdStr,strNewCmdStr,dwSubSystem,internal); - } } } if (dwSubSystem == IMAGE_SUBSYSTEM_WINDOWS_GUI) { - if (!Info.DirectRun) - { - Info.DirectRun = (PipeOrEscaped < 1); //??? <= 1 если бы '^' были удалены - } - if (Info.DirectRun) + if (Info.ExecMode == Info.detect) { + Info.ExecMode = Info.direct; Silent = true; } Info.NewWindow = true; } - else if (dwSubSystem == IMAGE_SUBSYSTEM_WINDOWS_CUI && !Info.DirectRun && !internal) - { - Info.DirectRun = (PipeOrEscaped < 1); //??? <= 1 если бы '^' были удалены - } } bool Visible=false; @@ -802,21 +781,20 @@ bool Execute(execute_info& Info, bool FolderRun, bool Silent, const std::functio } } - string ComSpecParams(Global->Opt->Exec.strComSpecParams); - ComSpecParams += L" "; - // ShellExecuteEx Win8.1+ wrongly opens symlinks in the separate console window // Workaround: execute through %comspec% - if (Info.DirectRun && !Info.NewWindow && IsWindows8Point1OrGreater()) + if (Info.ExecMode == Info.direct && !Info.NewWindow && IsWindows8Point1OrGreater()) { os::fs::file_status fstatus(strNewCmdStr); if (os::fs::is_file(fstatus) && fstatus.check(FILE_ATTRIBUTE_REPARSE_POINT)) { - Info.DirectRun = false; + Info.ExecMode = Info.external; } } - if (Info.DirectRun) + string ComSpecParams; + + if (Info.ExecMode == Info.direct) { seInfo.lpFile = strNewCmdStr.data(); if(!strNewCmdPar.empty()) @@ -838,24 +816,8 @@ bool Execute(execute_info& Info, bool FolderRun, bool Silent, const std::functio return false; } - std::vector NotQuotedShellList; - split(NotQuotedShellList, os::env::expand_strings(Global->Opt->Exec.strNotQuotedShell), STLF_UNIQUE); - bool bQuotedShell = !(std::any_of(CONST_RANGE(NotQuotedShellList, i) { return !StrCmpI(i,PointToName(strComspec.data())); })); - QuoteSpace(strNewCmdStr); - bool bDoubleQ = strNewCmdStr.find_first_of(L"&<>()@^|=;, ") != string::npos; - if ((!strNewCmdPar.empty() || bDoubleQ) && bQuotedShell) - { - ComSpecParams += L"\""; - } - ComSpecParams += strNewCmdStr; - if (!strNewCmdPar.empty()) - { - ComSpecParams.append(L" ").append(strNewCmdPar); - } - if ((!strNewCmdPar.empty() || bDoubleQ) && bQuotedShell) - { - ComSpecParams += L"\""; - } + ComSpecParams = Global->Opt->Exec.ComspecArguments; + ReplaceStrings(ComSpecParams, L"{0}", Info.Command); seInfo.lpFile = strComspec.data(); seInfo.lpParameters = ComSpecParams.data(); @@ -1032,7 +994,7 @@ bool Execute(execute_info& Info, bool FolderRun, bool Silent, const std::functio if (!Result) { std::vector Strings; - if (Info.DirectRun) + if (Info.ExecMode == Info.direct) Strings = { MSG(MCannotExecute), strNewCmdStr }; else Strings = { MSG(MCannotInvokeComspec), strComspec, MSG(MCheckComspecVar) }; @@ -1044,7 +1006,7 @@ bool Execute(execute_info& Info, bool FolderRun, bool Silent, const std::functio L"ErrCannotExecute", nullptr, nullptr, - { Info.DirectRun? strNewCmdStr : strComspec }); + { Info.ExecMode == Info.direct? strNewCmdStr : strComspec }); } return Result; @@ -1292,7 +1254,7 @@ bool ExpandOSAliases(string &strStr) string strNewCmdStr; string strNewCmdPar; - PartCmdLine(strStr,strNewCmdStr,strNewCmdPar); + PartCmdLine(strStr, strNewCmdStr, strNewCmdPar); const wchar_t* ExeName=PointToName(Global->g_strFarModuleName); wchar_t_ptr Buffer(4096); diff --git a/far/filelist.cpp b/far/filelist.cpp index 25a8092f91..e80d89fa52 100644 --- a/far/filelist.cpp +++ b/far/filelist.cpp @@ -2740,7 +2740,7 @@ void FileList::ProcessEnter(bool EnableExec,bool SeparateWindow,bool EnableAssoc Info.Command = strFileName; Info.WaitMode = PluginMode? Info.wait_finish : Info.no_wait; Info.NewWindow = SeparateWindow; - Info.DirectRun = true; + Info.ExecMode = Info.direct; Info.RunAs = RunAs; Parent()->GetCmdLine()->ExecString(Info); @@ -5004,7 +5004,7 @@ bool FileList::ApplyCommand() Info.Command = strConvertedCommand; Info.WaitMode = ListFileUsed? Info.wait_idle : Info.no_wait; Info.NewWindow = false; - Info.DirectRun = false; + Info.ExecMode = Info.detect; Info.RunAs = false; Parent()->GetCmdLine()->ExecString(Info); diff --git a/far/filetype.cpp b/far/filetype.cpp index 55e9a218df..4e2b618502 100644 --- a/far/filetype.cpp +++ b/far/filetype.cpp @@ -187,7 +187,7 @@ bool ProcessLocalFileTypes(const string& Name, const string& ShortName, FILETYPE Info.Command = strCommand; Info.WaitMode = AlwaysWaitFinish? Info.wait_finish : ListFileUsed? Info.wait_idle : Info.no_wait; Info.NewWindow = false; - Info.DirectRun = false; + Info.ExecMode = Info.detect; Info.RunAs = false; Global->CtrlObject->CmdLine()->ExecString(Info); @@ -285,7 +285,7 @@ void ProcessGlobalFileTypes(const string& Name, bool AlwaysWaitFinish, bool RunA Info.Command = strName; Info.WaitMode = AlwaysWaitFinish? Info.wait_finish : Info.no_wait; Info.NewWindow = true; - Info.DirectRun = true; + Info.ExecMode = Info.direct; Info.RunAs = RunAs; Global->CtrlObject->CmdLine()->ExecString(Info); @@ -325,7 +325,7 @@ void ProcessExternal(const string& Command, const string& Name, const string& Sh Info.Command = strExecStr; Info.WaitMode = AlwaysWaitFinish? Info.wait_finish : ListFileUsed? Info.wait_idle : Info.no_wait; Info.NewWindow = false; - Info.DirectRun = false; + Info.ExecMode = Info.detect; Info.RunAs = false; Global->CtrlObject->CmdLine()->ExecString(Info); diff --git a/far/headers.hpp b/far/headers.hpp index 8d050926d3..9f943ec7bb 100644 --- a/far/headers.hpp +++ b/far/headers.hpp @@ -38,8 +38,9 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "disable_warnings_in_std_begin.hpp" //---------------------------------------------------------------------------- -#include #include +#include +#include #include #include #include diff --git a/far/main.cpp b/far/main.cpp index 4bed7870f6..2482ae3f54 100644 --- a/far/main.cpp +++ b/far/main.cpp @@ -236,7 +236,7 @@ static int MainProcess( Info.Command = ppanel; Info.WaitMode = Info.no_wait; Info.NewWindow = false; - Info.DirectRun = false; + Info.ExecMode = Info.detect; Info.RunAs = false; Global->CtrlObject->CmdLine()->ExecString(Info); @@ -262,7 +262,7 @@ static int MainProcess( Info.Command = apanel; Info.WaitMode = Info.no_wait; Info.NewWindow = false; - Info.DirectRun = false; + Info.ExecMode = Info.detect; Info.RunAs = false; Global->CtrlObject->CmdLine()->ExecString(Info); diff --git a/far/manager.cpp b/far/manager.cpp index ff8a158b58..92ed763c8e 100644 --- a/far/manager.cpp +++ b/far/manager.cpp @@ -61,7 +61,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "fileedit.hpp" #include "scrsaver.hpp" -long Manager::CurrentWindowType=-1; +std::atomic_long Manager::CurrentWindowType(-1); bool Manager::window_comparer::operator()(window_ptr_ref lhs, window_ptr_ref rhs) const { @@ -980,7 +980,7 @@ void Manager::DeleteCommit(window_ptr_ref Param) const auto ClearCurrentWindow = [this] { m_currentWindow = nullptr; - InterlockedExchange(&CurrentWindowType,-1); + CurrentWindowType = -1; }; if (ModalIndex!=-1) { @@ -1069,7 +1069,7 @@ void Manager::ActivateCommit(window_ptr_ref Param) DeactivateCommit(m_currentWindow); m_currentWindow=Param; - InterlockedExchange(&CurrentWindowType,m_currentWindow->GetType()); + CurrentWindowType = m_currentWindow->GetType(); UpdateMacroArea(); RefreshCommit(Param); Param->OnChangeFocus(true); diff --git a/far/manager.hpp b/far/manager.hpp index 0a858d55d5..ad7ff934cd 100644 --- a/far/manager.hpp +++ b/far/manager.hpp @@ -189,7 +189,7 @@ class Manager: noncopyable bool EndLoop; // Признак выхода из цикла int ModalExitCode; bool StartManager; - static long CurrentWindowType; + static std::atomic_long CurrentWindowType; std::queue> m_Queue; std::vector> m_GlobalKeyHandlers; std::unordered_map m_Executed; diff --git a/far/notification.cpp b/far/notification.cpp index dba6031c16..51b6aefd9a 100644 --- a/far/notification.cpp +++ b/far/notification.cpp @@ -98,12 +98,12 @@ bool message_manager::dispatch() message_manager::suppress::suppress(): m_owner(MessageManager()) { - InterlockedIncrement(&m_owner.m_suppressions); + ++m_owner.m_suppressions; } message_manager::suppress::~suppress() { - InterlockedDecrement(&m_owner.m_suppressions); + --m_owner.m_suppressions; } message_manager& MessageManager() diff --git a/far/notification.hpp b/far/notification.hpp index cbb5962047..e75f21fb23 100644 --- a/far/notification.hpp +++ b/far/notification.hpp @@ -130,7 +130,7 @@ class message_manager: noncopyable message_queue m_Messages; handlers_map m_Handlers; std::unique_ptr m_Window; - volatile long m_suppressions; + std::atomic_ulong m_suppressions; }; message_manager& MessageManager(); diff --git a/far/plclass.cpp b/far/plclass.cpp index b982d8fd26..04865d2eb3 100644 --- a/far/plclass.cpp +++ b/far/plclass.cpp @@ -46,6 +46,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "FarGuid.hpp" #include "processname.hpp" #include "language.hpp" +#include "scrbuf.hpp" DECLARE_PLUGIN_FUNCTION(iClosePanel, void (WINAPI*)(const ClosePanelInfo *Info)) DECLARE_PLUGIN_FUNCTION(iCompare, intptr_t (WINAPI*)(const CompareInfo *Info)) diff --git a/far/plclass.hpp b/far/plclass.hpp index aef1894483..dadfc3b919 100644 --- a/far/plclass.hpp +++ b/far/plclass.hpp @@ -278,6 +278,9 @@ class Plugin: noncopyable void HandleFailure(ExecuteStruct& es); + virtual void Prologue() {} + virtual void Epilogue() {} + plugin_factory::exports_array Exports; std::unordered_set m_dialogs; @@ -291,9 +294,6 @@ class Plugin: noncopyable friend class plugin_factory; friend class native_plugin_factory; - virtual void Prologue() {}; - virtual void Epilogue() {}; - void InitExports(); void ClearExports(); void SetGuid(const GUID& Guid); diff --git a/far/usermenu.cpp b/far/usermenu.cpp index e3a9c88d92..9ac20293ff 100644 --- a/far/usermenu.cpp +++ b/far/usermenu.cpp @@ -819,7 +819,7 @@ int UserMenu::ProcessSingleMenu(std::list& Menu, int MenuPos, std: Info.Command = strCommand; Info.WaitMode = ListFileUsed? Info.wait_idle : Info.no_wait; Info.NewWindow = false; - Info.DirectRun = false; + Info.ExecMode = Info.detect; Info.RunAs = false; Global->CtrlObject->CmdLine()->ExecString(Info); } diff --git a/far/vbuild.m4 b/far/vbuild.m4 index 111395554e..6c6039bc28 100644 --- a/far/vbuild.m4 +++ b/far/vbuild.m4 @@ -1 +1 @@ -m4_define(BUILD,4643)m4_dnl +m4_define(BUILD,4644)m4_dnl