mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-27 07:44:24 +02:00
Fix command line argument parsing regression
Work with the arguments in a temporary array of pointers to the command line before assigning them to paramVector as generic_string. Follow up to afb3889. Since then the arguments were copied to paramVector as generic_string too early, before the command line parsing finished. Closes https://github.com/notepad-plus-plus/notepad-plus-plus/pull/3575
This commit is contained in:
parent
ecc9258d45
commit
3fbd537371
@ -141,8 +141,8 @@ void parseCommandLine(const TCHAR* commandLine, ParamVector& paramVector)
|
|||||||
}
|
}
|
||||||
bool isInFile = false;
|
bool isInFile = false;
|
||||||
bool isInWhiteSpace = true;
|
bool isInWhiteSpace = true;
|
||||||
paramVector.clear();
|
|
||||||
size_t commandLength = lstrlen(cmdLinePtr);
|
size_t commandLength = lstrlen(cmdLinePtr);
|
||||||
|
std::vector<TCHAR *> args;
|
||||||
for (size_t i = 0; i < commandLength; ++i)
|
for (size_t i = 0; i < commandLength; ++i)
|
||||||
{
|
{
|
||||||
switch(cmdLinePtr[i])
|
switch(cmdLinePtr[i])
|
||||||
@ -151,7 +151,7 @@ void parseCommandLine(const TCHAR* commandLine, ParamVector& paramVector)
|
|||||||
{
|
{
|
||||||
if (!isInFile) //" will always be treated as start or end of param, in case the user forgot to add an space
|
if (!isInFile) //" will always be treated as start or end of param, in case the user forgot to add an space
|
||||||
{
|
{
|
||||||
paramVector.push_back(cmdLinePtr+i+1); //add next param(since zero terminated generic_string original, no overflow of +1)
|
args.push_back(cmdLinePtr+i+1); //add next param(since zero terminated original, no overflow of +1)
|
||||||
}
|
}
|
||||||
isInFile = !isInFile;
|
isInFile = !isInFile;
|
||||||
isInWhiteSpace = false;
|
isInWhiteSpace = false;
|
||||||
@ -173,14 +173,13 @@ void parseCommandLine(const TCHAR* commandLine, ParamVector& paramVector)
|
|||||||
{
|
{
|
||||||
if (!isInFile && isInWhiteSpace)
|
if (!isInFile && isInWhiteSpace)
|
||||||
{
|
{
|
||||||
paramVector.push_back(cmdLinePtr+i); //add next param
|
args.push_back(cmdLinePtr+i); //add next param
|
||||||
isInWhiteSpace = false;
|
isInWhiteSpace = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//the commandline generic_string is now a list of zero terminated strings concatenated, and the vector contains all the substrings
|
paramVector.assign(args.begin(), args.end());
|
||||||
|
|
||||||
delete [] cmdLine;
|
delete [] cmdLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user