mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-22 00:38:06 +08:00
* lib/libcmain.c (main): Properly deal with quoted first argument.
This commit is contained in:
parent
23b9802aa0
commit
fc2eba361c
@ -1,3 +1,7 @@
|
|||||||
|
2004-12-09 Christopher Faylor <cgf@timesys.com>
|
||||||
|
|
||||||
|
* lib/libcmain.c (main): Properly deal with quoted first argument.
|
||||||
|
|
||||||
2004-12-06 Christopher Faylor <cgf@timesys.com>
|
2004-12-06 Christopher Faylor <cgf@timesys.com>
|
||||||
|
|
||||||
* pinfo.h (proc_pipe::*): Delete class.
|
* pinfo.h (proc_pipe::*): Delete class.
|
||||||
|
@ -9,26 +9,35 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|||||||
details. */
|
details. */
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define SP " \t\n"
|
||||||
|
|
||||||
/* Allow apps which don't have a main work, as long as they define WinMain */
|
/* Allow apps which don't have a main work, as long as they define WinMain */
|
||||||
int
|
int
|
||||||
main ()
|
main ()
|
||||||
{
|
{
|
||||||
HMODULE x = GetModuleHandleA(0);
|
HMODULE x = GetModuleHandle (0);
|
||||||
char *s = GetCommandLineA ();
|
char *s = GetCommandLine ();
|
||||||
STARTUPINFO si;
|
STARTUPINFO si;
|
||||||
|
char *nexts;
|
||||||
|
|
||||||
/* GetCommandLineA returns the entire command line including the
|
s += strspn (s, SP);
|
||||||
program name, but WinMain is defined to accept the command
|
|
||||||
line without the program name. */
|
if (*s != '"')
|
||||||
while (*s != ' ' && *s != '\0')
|
nexts = strpbrk (s, SP);
|
||||||
++s;
|
else
|
||||||
while (*s == ' ')
|
while ((nexts = strchr (s + 1, '"')) != NULL && nexts[-1] == '\\')
|
||||||
++s;
|
s = nexts;
|
||||||
|
|
||||||
|
if (!nexts)
|
||||||
|
nexts = strchr (s, '\0');
|
||||||
|
else
|
||||||
|
nexts += strspn (nexts + 1, SP);
|
||||||
|
|
||||||
GetStartupInfo (&si);
|
GetStartupInfo (&si);
|
||||||
|
|
||||||
return WinMain (x, 0, s,
|
return WinMain (x, 0, nexts,
|
||||||
((si.dwFlags & STARTF_USESHOWWINDOW) != 0
|
((si.dwFlags & STARTF_USESHOWWINDOW) != 0
|
||||||
? si.wShowWindow
|
? si.wShowWindow
|
||||||
: SW_SHOWNORMAL));
|
: SW_SHOWNORMAL));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user