Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:hiberis:mingw:win32
mingw32-glib2
0004-Add-g_option_context_parse_command_line.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0004-Add-g_option_context_parse_command_line.patch of Package mingw32-glib2
From af56bff915a81ced98c0d94880b5c5ccb825e138 Mon Sep 17 00:00:00 2001 From: Hib Eris <hib@hiberis.nl> Date: Wed, 6 Feb 2013 09:46:33 +0100 Subject: [PATCH 4/4] Add g_option_context_parse_command_line() https://bugzilla.gnome.org/show_bug.cgi?id=522131 --- docs/reference/glib/glib-sections.txt | 1 + glib/goption.c | 52 +++++++++++++++++++++++++++++++++++ glib/goption.h | 4 +++ 3 files changed, 57 insertions(+) diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt index eee5647..89d5ba7 100644 --- a/docs/reference/glib/glib-sections.txt +++ b/docs/reference/glib/glib-sections.txt @@ -1174,6 +1174,7 @@ GTranslateFunc g_option_context_set_translate_func g_option_context_set_translation_domain g_option_context_free +g_option_context_parse_command_line g_option_context_parse g_option_context_parse_utf8 g_option_context_set_help_enabled diff --git a/glib/goption.c b/glib/goption.c index 3edb30a..8dcd2de 100644 --- a/glib/goption.c +++ b/glib/goption.c @@ -2148,6 +2148,58 @@ g_option_context_parse_utf8 (GOptionContext *context, return option_context_parse_internal (context, TRUE, argc, argv, error); } +#ifndef G_OS_WIN32 +static +void getmainargs(int *argc, + char ***argv) +{ + extern char **environ; + char ***argvp; + void *p; + + asm ("mov %%esp, %0" : "=r" (p)); + argvp = p; + while (*argvp != environ) { + argvp++; + } + argvp--; + *argv = *argvp; + argvp--; + *argc = (int) *argvp; +} +#endif + +gboolean +g_option_context_parse_command_line (GOptionContext *context, GError **error) +{ +#ifdef G_OS_WIN32 + gboolean r; + int i, argc; + gchar **argv, **argv_tmp; + + argv = g_win32_get_utf8_argv(TRUE, &argc); + + argv_tmp = g_new (gchar *, argc + 1); + for (i = 0; i < argc; i++) + argv_tmp[i] = argv[i]; + argv_tmp[argc] = NULL; + + r = g_option_context_parse_utf8 (context, &argc, &argv_tmp, error); + + g_strfreev (argv); + g_free (argv_tmp); + + return r; +#else + int argc; + char **argv; + + getmainargs(&argc, &argv); + + return g_option_context_parse (context, &argc, &argv, error); +#endif +} + /** * g_option_group_new: * @name: the name for the option group, this is used to provide diff --git a/glib/goption.h b/glib/goption.h index 8950430..d4ce4c9 100644 --- a/glib/goption.h +++ b/glib/goption.h @@ -348,6 +348,10 @@ gboolean g_option_context_parse_utf8 (GOptionContext *context, gchar ***argv, GError **error); +GLIB_AVAILABLE_IN_2_36 +gboolean g_option_context_parse_command_line (GOptionContext *context, + GError **error); + GLIB_AVAILABLE_IN_ALL void g_option_context_set_translate_func (GOptionContext *context, GTranslateFunc func, -- 1.8.1.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor