diff options
author | Marco Trevisan <mail@3v1n0.net> | 2023-05-24 08:57:31 +0000 |
---|---|---|
committer | Marco Trevisan <mail@3v1n0.net> | 2023-05-24 08:57:31 +0000 |
commit | 5ae2d68ac35d47e8e800f3946992430efd2ee315 (patch) | |
tree | 2848c6dbdbd92b322d36c63f9f1e389c107b9031 | |
parent | 69e209764bcfef599a21b32f82f88f1906bf197c (diff) | |
parent | 6c6a844a508f6df1966aa849e8a1cd07625f83f5 (diff) | |
download | glib-5ae2d68ac35d47e8e800f3946992430efd2ee315.tar.gz |
Merge branch 'backport-3446-glib-compile-schemas-failed-glib-2-76' into 'glib-2-76'
Backport !3446 “glib-compile-resources: Fix non-ASCII arg parsing on Windows” to glib-2-76
See merge request GNOME/glib!3447
-rw-r--r-- | gio/glib-compile-resources.c | 19 | ||||
-rw-r--r-- | gio/glib-compile-schemas.c | 18 |
2 files changed, 37 insertions, 0 deletions
diff --git a/gio/glib-compile-resources.c b/gio/glib-compile-resources.c index 0f873d486..398a08ad4 100644 --- a/gio/glib-compile-resources.c +++ b/gio/glib-compile-resources.c @@ -837,6 +837,7 @@ main (int argc, char **argv) #ifdef G_OS_WIN32 gchar *tmp; + gchar **command_line = NULL; #endif setlocale (LC_ALL, GLIB_DEFAULT_LOCALE); @@ -863,11 +864,21 @@ main (int argc, char **argv) g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); error = NULL; +#ifdef G_OS_WIN32 + command_line = g_win32_get_command_line (); + if (!g_option_context_parse_strv (context, &command_line, &error)) + { + g_printerr ("%s\n", error->message); + return 1; + } + argc = g_strv_length (command_line); +#else if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printerr ("%s\n", error->message); return 1; } +#endif g_option_context_free (context); @@ -890,7 +901,11 @@ main (int argc, char **argv) compiler_type = get_compiler_id (compiler); g_free (compiler); +#ifdef G_OS_WIN32 + srcfile = command_line[1]; +#else srcfile = argv[1]; +#endif xmllint = g_strdup (g_getenv ("XMLLINT")); if (xmllint == NULL) @@ -1310,5 +1325,9 @@ main (int argc, char **argv) g_free (c_name); g_hash_table_unref (files); +#ifdef G_OS_WIN32 + g_strfreev (command_line); +#endif + return 0; } diff --git a/gio/glib-compile-schemas.c b/gio/glib-compile-schemas.c index efe6f8e77..04ef40457 100644 --- a/gio/glib-compile-schemas.c +++ b/gio/glib-compile-schemas.c @@ -22,6 +22,7 @@ /* Prologue {{{1 */ #include "config.h" +#include <glib.h> #include <gstdio.h> #include <gi18n.h> @@ -2182,6 +2183,7 @@ main (int argc, char **argv) #ifdef G_OS_WIN32 gchar *tmp = NULL; + gchar **command_line = NULL; #endif setlocale (LC_ALL, GLIB_DEFAULT_LOCALE); @@ -2206,12 +2208,23 @@ main (int argc, char **argv) "and the cache file is called gschemas.compiled.")); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); +#ifdef G_OS_WIN32 + command_line = g_win32_get_command_line (); + if (!g_option_context_parse_strv (context, &command_line, &error)) + { + fprintf (stderr, "%s\n", error->message); + retval = 1; + goto done; + } + argc = g_strv_length (command_line); +#else if (!g_option_context_parse (context, &argc, &argv, &error)) { fprintf (stderr, "%s\n", error->message); retval = 1; goto done; } +#endif if (show_version_and_exit) { @@ -2227,7 +2240,11 @@ main (int argc, char **argv) goto done; } +#ifdef G_OS_WIN32 + srcdir = command_line[1]; +#else srcdir = argv[1]; +#endif target = g_build_filename (targetdir ? targetdir : srcdir, "gschemas.compiled", NULL); @@ -2320,6 +2337,7 @@ done: #ifdef G_OS_WIN32 g_free (tmp); + g_strfreev (command_line); #endif return retval; |