Also recognize '/' as the start of an option.

Implement 'notepad /p'.
Simplify many string parsing loops.
This commit is contained in:
Francois Gouget 2004-08-30 19:29:13 +00:00 committed by Alexandre Julliard
parent 8fa7ee2632
commit 21c85efd83
1 changed files with 10 additions and 9 deletions

View File

@ -199,14 +199,13 @@ static int AlertFileDoesNotExist(LPCWSTR szFileName)
static void HandleCommandLine(LPWSTR cmdline)
{
WCHAR delimiter;
int opt_print=0;
/* skip white space */
while (*cmdline && *cmdline == ' ') cmdline++;
while (*cmdline == ' ') cmdline++;
/* skip executable name */
delimiter = ' ';
if (*cmdline == '"')
delimiter = '"';
delimiter = (*cmdline == '"' ? '"' : ' ');
do
{
@ -215,7 +214,7 @@ static void HandleCommandLine(LPWSTR cmdline)
while (*cmdline && *cmdline != delimiter);
if (*cmdline == delimiter) cmdline++;
while (*cmdline && (*cmdline == ' ' || *cmdline == '-'))
while (*cmdline == ' ' || *cmdline == '-' || *cmdline == '/')
{
WCHAR option;
@ -223,14 +222,14 @@ static void HandleCommandLine(LPWSTR cmdline)
option = *cmdline;
if (option) cmdline++;
while (*cmdline && *cmdline == ' ') cmdline++;
while (*cmdline == ' ') cmdline++;
switch(option)
{
case 'p':
case 'P': printf("Print file: ");
/* TODO - not yet able to print a file */
break;
case 'P':
opt_print=1;
break;
}
}
@ -275,6 +274,8 @@ static void HandleCommandLine(LPWSTR cmdline)
{
DoOpenFile(file_name);
InvalidateRect(Globals.hMainWnd, NULL, FALSE);
if (opt_print)
DIALOG_FilePrint();
}
else
{