summaryrefslogtreecommitdiffstats
path: root/external/glib2/glib-remove-wgetmainargs.patch.1
blob: 28555d71257ff22631e6a22bdfc4c284233173ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
From 3cc349b04e76880a9d2f3c3d2195d171e110f66c Mon Sep 17 00:00:00 2001
From: TingPing <tingping@tingping.se>
Date: Sat, 20 Dec 2014 18:39:00 -0500
Subject: [PATCH] win32: Replace usage of __wgetmainargs()

It was an internal function that has been removed with VS 2015

Use g_win32_get_command_line() or CommandLineToArgvW() directly.

https://bugzilla.gnome.org/show_bug.cgi?id=741822
---
 glib/gspawn-win32-helper.c | 20 +++----------------
 glib/gspawn.c              |  9 ++-------
 3 files changed, 22 insertions(+), 56 deletions(-)

diff -ur glib2.org/glib/gspawn.c glib2/glib/gspawn.c
--- glib2.org/glib/gspawn.c	2017-11-16 23:53:53.619191200 +0100
+++ glib2/glib/gspawn.c	2017-11-17 21:48:54.905453400 +0100
@@ -480,13 +480,8 @@
  * main(). wmain() has a wide character argument vector as parameter.
  *
  * At least currently, mingw doesn't support wmain(), so if you use
- * mingw to develop the spawned program, it will have to call the
- * undocumented function __wgetmainargs() to get the wide character
- * argument vector and environment. See gspawn-win32-helper.c in the
- * GLib sources or init.c in the mingw runtime sources for a prototype
- * for that function. Alternatively, you can retrieve the Win32 system
- * level wide character command line passed to the spawned program
- * using the GetCommandLineW() function.
+ * mingw to develop the spawned program, it should call
+ * g_win32_get_command_line() to get arguments in UTF-8.
  *
  * On Windows the low-level child process creation API
  * <function>CreateProcess()</function> doesn't use argument vectors,
diff -ur glib2.org/glib/gspawn-win32-helper.c glib2/glib/gspawn-win32-helper.c
--- glib2.org/glib/gspawn-win32-helper.c	2017-11-16 23:53:53.556618800 +0100
+++ glib2/glib/gspawn-win32-helper.c	2017-11-17 21:48:16.887044400 +0100
@@ -54,20 +54,6 @@
  * away in the global __argc and __argv by the C runtime startup code.
  */
 
-/* Info peeked from mingw runtime's source code. __wgetmainargs() is a
- * function to get the program's argv in wide char format.
- */
-
-typedef struct {
-  int newmode;
-} _startupinfo;
-
-extern void __wgetmainargs(int *argc,
-			   wchar_t ***wargv,
-			   wchar_t ***wenviron,
-			   int expand_wildcards,
-			   _startupinfo *startupinfo);
-
 /* Copy of protect_argv that handles wchar_t strings */
 
 static gint
@@ -169,14 +155,13 @@
   gint argv_zero_offset = ARG_PROGRAM;
   wchar_t **new_wargv;
   int argc;
-  wchar_t **wargv, **wenvp;
-  _startupinfo si = { 0 };
+  wchar_t **wargv;
   char c;
 
   g_assert (__argc >= ARG_COUNT);
 
   /* Fetch the wide-char argument vector */
-  __wgetmainargs (&argc, &wargv, &wenvp, 0, &si);
+  wargv = CommandLineToArgvW (GetCommandLineW(), &argc);
 
   /* We still have the system codepage args in __argv. We can look
    * at the first args in which gspawn-win32.c passes us flags and
@@ -329,5 +314,7 @@
 
   read (helper_sync_fd, &c, 1);
 
+  LocalFree (wargv);
+
   return 0;
 }