[v2 PATCH] ucrtbase: Implement _get_narrow_winmain_command_line/_get_wide_winmain_command_line

Nikolay Sivov nsivov at codeweavers.com
Mon Jul 25 15:42:48 CDT 2016


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---

v2: handle multiple leading quotes and embedded quoted blocks

 .../api-ms-win-crt-runtime-l1-1-0.spec             |  4 +-
 dlls/msvcrt/data.c                                 | 84 ++++++++++++++++++++++
 dlls/ucrtbase/ucrtbase.spec                        |  4 +-
 3 files changed, 88 insertions(+), 4 deletions(-)

diff --git a/dlls/api-ms-win-crt-runtime-l1-1-0/api-ms-win-crt-runtime-l1-1-0.spec b/dlls/api-ms-win-crt-runtime-l1-1-0/api-ms-win-crt-runtime-l1-1-0.spec
index 17b9861..cbda9ce 100644
--- a/dlls/api-ms-win-crt-runtime-l1-1-0/api-ms-win-crt-runtime-l1-1-0.spec
+++ b/dlls/api-ms-win-crt-runtime-l1-1-0/api-ms-win-crt-runtime-l1-1-0.spec
@@ -43,11 +43,11 @@
 @ cdecl _get_initial_narrow_environment() ucrtbase._get_initial_narrow_environment
 @ cdecl _get_initial_wide_environment() ucrtbase._get_initial_wide_environment
 @ cdecl _get_invalid_parameter_handler() ucrtbase._get_invalid_parameter_handler
-@ stub _get_narrow_winmain_command_line
+@ cdecl _get_narrow_winmain_command_line() ucrtbase._get_narrow_winmain_command_line
 @ cdecl _get_pgmptr(ptr) ucrtbase._get_pgmptr
 @ cdecl _get_terminate() ucrtbase._get_terminate
 @ cdecl _get_thread_local_invalid_parameter_handler() ucrtbase._get_thread_local_invalid_parameter_handler
-@ stub _get_wide_winmain_command_line
+@ cdecl _get_wide_winmain_command_line() ucrtbase._get_wide_winmain_command_line
 @ cdecl _get_wpgmptr(ptr) ucrtbase._get_wpgmptr
 @ cdecl _getdllprocaddr(long str long) ucrtbase._getdllprocaddr
 @ cdecl _getpid() ucrtbase._getpid
diff --git a/dlls/msvcrt/data.c b/dlls/msvcrt/data.c
index fafbc38..b6dbfdb 100644
--- a/dlls/msvcrt/data.c
+++ b/dlls/msvcrt/data.c
@@ -692,3 +692,87 @@ int CDECL _initialize_wide_environment(void)
   FIXME("stub\n");
   return 0;
 }
+
+/*********************************************************************
+ *		_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 == '"')
+  {
+      /* skip all leading quotes */
+      while (*++s == '"')
+          ;
+      /* skip everything up to next quote */
+      while (*s && *s++ != '"')
+          ;
+  }
+  else
+  {
+      while (*s && *s != ' ' && *s != '\t')
+      {
+          /* allow embedded quoted blocks */
+          if (*s == '"')
+          {
+              s++;
+              while (*s && *s++ != '"')
+                 ;
+          }
+          else
+              s++;
+      }
+  }
+  while (*s == ' ' || *s == '\t')
+      s++;
+
+  return narrow_command_line = s;
+}
+
+/*********************************************************************
+ *		_get_wide_winmain_command_line (UCRTBASE.@)
+ */
+MSVCRT_wchar_t* CDECL _get_wide_winmain_command_line(void)
+{
+  static MSVCRT_wchar_t *wide_command_line;
+  MSVCRT_wchar_t *s;
+
+  if (wide_command_line)
+      return wide_command_line;
+
+  s = GetCommandLineW();
+  if (*s == '"')
+  {
+      /* skip all leading quotes */
+      while (*++s == '"')
+          ;
+      /* skip everything up to next quote */
+      while (*s && *s++ != '"')
+          ;
+  }
+  else
+  {
+      while (*s && *s != ' ' && *s != '\t')
+      {
+          /* allow embedded quoted blocks */
+          if (*s == '"')
+          {
+              s++;
+              while (*s && *s++ != '"')
+                 ;
+          }
+          else
+              s++;
+      }
+  }
+  while (*s == ' ' || *s == '\t')
+      s++;
+
+  return wide_command_line = s;
+}
diff --git a/dlls/ucrtbase/ucrtbase.spec b/dlls/ucrtbase/ucrtbase.spec
index 7058990..99e5ec9 100644
--- a/dlls/ucrtbase/ucrtbase.spec
+++ b/dlls/ucrtbase/ucrtbase.spec
@@ -368,7 +368,7 @@
 @ cdecl _get_initial_narrow_environment()
 @ cdecl _get_initial_wide_environment()
 @ cdecl _get_invalid_parameter_handler()
-@ stub _get_narrow_winmain_command_line
+@ cdecl _get_narrow_winmain_command_line()
 @ cdecl _get_osfhandle(long) MSVCRT__get_osfhandle
 @ cdecl _get_pgmptr(ptr)
 @ cdecl _get_printf_count_output() MSVCRT__get_printf_count_output
@@ -379,7 +379,7 @@
 @ cdecl _get_timezone(ptr)
 @ cdecl _get_tzname(ptr str long long) MSVCRT__get_tzname
 @ cdecl _get_unexpected() MSVCRT__get_unexpected
-@ stub _get_wide_winmain_command_line
+@ cdecl _get_wide_winmain_command_line()
 @ cdecl _get_wpgmptr(ptr)
 @ cdecl _getc_nolock(ptr) MSVCRT__fgetc_nolock
 @ cdecl _getch()
-- 
2.8.1




More information about the wine-patches mailing list