eht16 commented on this pull request.


> @@ -1032,4 +1032,31 @@ gchar *win32_get_user_config_dir(void)
        return g_build_filename(g_get_user_config_dir(), "geany", NULL);
 }
 
+
+void win32_make_argc_and_argv_in_utf8(gint *pargc, gchar ***pargv)

Maybe `win32_convert_argv_to_utf8()` would be a better name.

> +{
+       int num_arg;
+       LPWSTR *szarglist = CommandLineToArgvW(GetCommandLineW(), &num_arg);
+       char **utf8argv = g_new0(char *, num_arg + 1);
+       int i = num_arg;
+       while(i)
+       {
+               i--;
+               utf8argv[i] = g_utf16_to_utf8((gunichar2 *)szarglist[i], -1, 
NULL, NULL, NULL);
+       }
+       *pargc = num_arg;
+       *pargv = utf8argv;
+       LocalFree(szarglist);
+}
+
+void win32_free_argv_made_in_utf8(gint argc, gchar **argv)

The code is quite generic and not Windows-specific, so it could go into 
src/utils.c as `utils_free_argv()`, similar to `utils_free_pointers()`.

> @@ -1231,6 +1230,9 @@ gint main_lib(gint argc, gchar **argv)
 #endif
 
        gtk_main();
+#ifdef G_OS_WIN32
+       win32_free_argv_made_in_utf8(argc, argv);

Maybe the call including the G_OS_WIN32 guard could go into a seperate function 
in src/libmain.c as it should be also in 
https://github.com/geany/geany/blob/master/src/libmain.c#L1090.
Strictly there are more places where it should be called, e.g. every place 
where we call `exit()` but this would require some refactoring before which is 
out of scope of this PR (and technically it is not very necessary as the memory 
in cleaned up anyway on `exit()`).

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/1258#pullrequestreview-7732004

Reply via email to