Fix notepad /p
Francois Gouget
fgouget at codeweavers.com
Mon Aug 30 13:12:24 CDT 2004
The wine.inf defines the shell\print action as 'notepad /p %1' but
notepad did not recognize '/' as the start of an option!
Another oddity I noticed is lots of things like:
while (*cmdline && *cmdline == ' ') cmdline++;
Obviously if *cmdline==' ' then it's not going to be '\0'!
So I also simplified these.
Finally '/p' seemed to be pretty simple to implement so I gave it a try.
At least it works for me.
Changelog:
* programs/notepad/main.c
Francois Gouget <fgouget at codeweavers.com>
Also recognize '/' as the start of an option.
Implement 'notepad /p'.
Simplify many string parsing loops.
--
Francois Gouget
fgouget at codeweavers.com
-------------- next part --------------
Index: programs/notepad/main.c
===================================================================
RCS file: /var/cvs/wine/programs/notepad/main.c,v
retrieving revision 1.30
diff -u -r1.30 main.c
--- programs/notepad/main.c 8 Jul 2004 20:18:10 -0000 1.30
+++ programs/notepad/main.c 30 Aug 2004 09:27:33 -0000
@@ -199,14 +199,13 @@
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 @@
while (*cmdline && *cmdline != delimiter);
if (*cmdline == delimiter) cmdline++;
- while (*cmdline && (*cmdline == ' ' || *cmdline == '-'))
+ while (*cmdline == ' ' || *cmdline == '-' || *cmdline == '/')
{
WCHAR option;
@@ -223,14 +222,14 @@
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 @@
{
DoOpenFile(file_name);
InvalidateRect(Globals.hMainWnd, NULL, FALSE);
+ if (opt_print)
+ DIALOG_FilePrint();
}
else
{
More information about the wine-patches
mailing list