[BUG_FIXED] Fix the bug while giving command C:\NppDir>notepad++ (w/o quote), npp try to open file "notepad++".

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@610 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2010-02-10 23:54:44 +00:00
parent e098cbc677
commit 0d2efe29ea
3 changed files with 14 additions and 8 deletions

View File

@ -759,11 +759,6 @@ void Notepad_plus::saveShortcuts()
NppParameters::getInstance()->writeShortcuts(); NppParameters::getInstance()->writeShortcuts();
} }
void Notepad_plus::saveSession(const Session & session)
{
(NppParameters::getInstance())->writeSession(session);
}
void Notepad_plus::doTrimTrailing() void Notepad_plus::doTrimTrailing()
{ {
_pEditView->execute(SCI_BEGINUNDOACTION); _pEditView->execute(SCI_BEGINUNDOACTION);

View File

@ -1071,3 +1071,7 @@ const TCHAR * Notepad_plus::fileSaveSession(size_t nbFile, TCHAR ** fileNames)
} }
void Notepad_plus::saveSession(const Session & session)
{
(NppParameters::getInstance())->writeSession(session);
}

View File

@ -39,20 +39,27 @@ void parseCommandLine(TCHAR * commandLine, ParamVector & paramVector) {
//params.erase(params.begin()); //params.erase(params.begin());
//remove the first element, since thats the path the the executable (GetCommandLine does that) //remove the first element, since thats the path the the executable (GetCommandLine does that)
TCHAR stopChar = TEXT(' '); TCHAR stopChar = TEXT(' ');
if (commandLine[0] == TEXT('\"')) { if (commandLine[0] == TEXT('\"')) {
stopChar = TEXT('\"'); stopChar = TEXT('\"');
commandLine++; commandLine++;
} }
//while this is not really DBCS compliant, space and quote are in the lower 127 ASCII range //while this is not really DBCS compliant, space and quote are in the lower 127 ASCII range
while(commandLine[0] && commandLine[0] != stopChar) while(commandLine[0] && commandLine[0] != stopChar)
{
commandLine++; commandLine++;
}
// For unknown reason, the following command :
// c:\NppDir>notepad++
// (without quote) will give string "notepad++\0notepad++\0"
// To avoid the unexpected behaviour we check the end of string before increasing the pointer
if (commandLine[0] != '\0')
commandLine++; //advance past stopChar commandLine++; //advance past stopChar
//kill remaining spaces //kill remaining spaces
while(commandLine[0] == TEXT(' ')) while(commandLine[0] == TEXT(' '))
commandLine++; commandLine++;
bool isFile = checkSingleFile(commandLine); //if the commandline specifies only a file, open it as such bool isFile = checkSingleFile(commandLine); //if the commandline specifies only a file, open it as such
if (isFile) { if (isFile) {
paramVector.push_back(commandLine); paramVector.push_back(commandLine);