Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/lib')
-rw-r--r--winsup/cygwin/lib/libcmain.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/winsup/cygwin/lib/libcmain.c b/winsup/cygwin/lib/libcmain.c
index 13cc34cd9..b0c011999 100644
--- a/winsup/cygwin/lib/libcmain.c
+++ b/winsup/cygwin/lib/libcmain.c
@@ -9,26 +9,35 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#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 */
int
main ()
{
- HMODULE x = GetModuleHandleA(0);
- char *s = GetCommandLineA ();
+ HMODULE x = GetModuleHandle (0);
+ char *s = GetCommandLine ();
STARTUPINFO si;
+ char *nexts;
+
+ s += strspn (s, SP);
+
+ if (*s != '"')
+ nexts = strpbrk (s, SP);
+ else
+ while ((nexts = strchr (s + 1, '"')) != NULL && nexts[-1] == '\\')
+ s = nexts;
- /* GetCommandLineA returns the entire command line including the
- program name, but WinMain is defined to accept the command
- line without the program name. */
- while (*s != ' ' && *s != '\0')
- ++s;
- while (*s == ' ')
- ++s;
+ if (!nexts)
+ nexts = strchr (s, '\0');
+ else
+ nexts += strspn (nexts + 1, SP);
GetStartupInfo (&si);
- return WinMain (x, 0, s,
+ return WinMain (x, 0, nexts,
((si.dwFlags & STARTF_USESHOWWINDOW) != 0
? si.wShowWindow
: SW_SHOWNORMAL));