From df658a601013bb74b0690196f24ae82ebec559b5 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Fri, 13 Jan 2023 14:42:29 +0100 Subject: [PATCH] Refactoring: make code more readable --- PowerEditor/src/winmain.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/PowerEditor/src/winmain.cpp b/PowerEditor/src/winmain.cpp index c1624e1d6..7a5595e08 100644 --- a/PowerEditor/src/winmain.cpp +++ b/PowerEditor/src/winmain.cpp @@ -409,22 +409,23 @@ PWSTR stripIgnoredParams(ParamVector & params, PWSTR pCmdLine) int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int) { - generic_string cmdLineString = pCmdLine ? pCmdLine : _T(""); - ParamVector params; - parseCommandLine(pCmdLine, params); - PWSTR pCmdLineWithoutIgnores = stripIgnoredParams(params, pCmdLine); - - MiniDumper mdump; //for debugging purposes. - bool TheFirstOne = true; ::SetLastError(NO_ERROR); ::CreateMutex(NULL, false, TEXT("nppInstance")); if (::GetLastError() == ERROR_ALREADY_EXISTS) TheFirstOne = false; + + generic_string cmdLineString = pCmdLine ? pCmdLine : _T(""); + ParamVector params; + parseCommandLine(pCmdLine, params); + + // Convert commandline to notepad-compatible format, if applicable + // For treating "-notepadStyleCmdline" "/P" and "-z" if ( isInList(FLAG_NOTEPAD_COMPATIBILITY, params) ) { + PWSTR pCmdLineWithoutIgnores = stripIgnoredParams(params, pCmdLine); params = convertParamsToNotepadStyle(pCmdLineWithoutIgnores); } @@ -723,6 +724,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int) MSG msg; msg.wParam = 0; Win32Exception::installHandler(); + MiniDumper mdump; //for debugging purposes. try { notepad_plus_plus.init(hInstance, NULL, quotFileName.c_str(), &cmdLineParams);