On 07/24/16 20:40, Nikolay Sivov wrote:
+/*********************************************************************
_get_narrow_winmain_command_line (UCRTBASE.@)
- */
+char* CDECL _get_narrow_winmain_command_line(void) +{
- static char *narrow_command_line;
- char *s;
- if (narrow_command_line)
return narrow_command_line;
- s = GetCommandLineA();
- if (*s == '"')
- {
s++;
while (*s)
if (*s++ == '"')
break;
- }
- else
- {
while (*s && *s != ' ' && *s != '\t')
s++;
- }
- while (*s == ' ' || *s == '\t')
s++;
- return narrow_command_line = s;
+}
It will not work in following case (executable name "test ws.exe"): CMD> test" "ws.exe other args or CMD> """test ws.exe" other args Probably there's no real use case for that but it shouldn't be hard to handle this cases as well.
Thanks, Piotr
On 25.07.2016 16:13, Piotr Caban wrote:
On 07/24/16 20:40, Nikolay Sivov wrote:
+/*********************************************************************
_get_narrow_winmain_command_line (UCRTBASE.@)
- */
+char* CDECL _get_narrow_winmain_command_line(void) +{
- static char *narrow_command_line;
- char *s;
- if (narrow_command_line)
return narrow_command_line;
- s = GetCommandLineA();
- if (*s == '"')
- {
s++;
while (*s)
if (*s++ == '"')
break;
- }
- else
- {
while (*s && *s != ' ' && *s != '\t')
s++;
- }
- while (*s == ' ' || *s == '\t')
s++;
- return narrow_command_line = s;
+}
It will not work in following case (executable name "test ws.exe"): CMD> test" "ws.exe other args or CMD> """test ws.exe" other args Probably there's no real use case for that but it shouldn't be hard to handle this cases as well.
Thanks for the review, I just sent improved version.