mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-03 14:42:10 +01:00
Handle option contexts without a main group.
2004-09-01 Anders Carlsson <andersca@gnome.org> * glib/goption.c: (g_option_context_free), (print_help), (g_option_context_parse): Handle option contexts without a main group. * tests/option-test.c: (empty_test2), (main): Add test case for that.
This commit is contained in:
parent
7f760a9108
commit
338d949559
@ -1,3 +1,12 @@
|
||||
2004-09-01 Anders Carlsson <andersca@gnome.org>
|
||||
|
||||
* glib/goption.c: (g_option_context_free), (print_help),
|
||||
(g_option_context_parse):
|
||||
Handle option contexts without a main group.
|
||||
|
||||
* tests/option-test.c: (empty_test2), (main):
|
||||
Add test case for that.
|
||||
|
||||
2004-08-30 Anders Carlsson <andersca@gnome.org>
|
||||
|
||||
* glib/goption.c: (g_option_context_parse):
|
||||
|
@ -1,3 +1,12 @@
|
||||
2004-09-01 Anders Carlsson <andersca@gnome.org>
|
||||
|
||||
* glib/goption.c: (g_option_context_free), (print_help),
|
||||
(g_option_context_parse):
|
||||
Handle option contexts without a main group.
|
||||
|
||||
* tests/option-test.c: (empty_test2), (main):
|
||||
Add test case for that.
|
||||
|
||||
2004-08-30 Anders Carlsson <andersca@gnome.org>
|
||||
|
||||
* glib/goption.c: (g_option_context_parse):
|
||||
|
@ -1,3 +1,12 @@
|
||||
2004-09-01 Anders Carlsson <andersca@gnome.org>
|
||||
|
||||
* glib/goption.c: (g_option_context_free), (print_help),
|
||||
(g_option_context_parse):
|
||||
Handle option contexts without a main group.
|
||||
|
||||
* tests/option-test.c: (empty_test2), (main):
|
||||
Add test case for that.
|
||||
|
||||
2004-08-30 Anders Carlsson <andersca@gnome.org>
|
||||
|
||||
* glib/goption.c: (g_option_context_parse):
|
||||
|
@ -1,3 +1,12 @@
|
||||
2004-09-01 Anders Carlsson <andersca@gnome.org>
|
||||
|
||||
* glib/goption.c: (g_option_context_free), (print_help),
|
||||
(g_option_context_parse):
|
||||
Handle option contexts without a main group.
|
||||
|
||||
* tests/option-test.c: (empty_test2), (main):
|
||||
Add test case for that.
|
||||
|
||||
2004-08-30 Anders Carlsson <andersca@gnome.org>
|
||||
|
||||
* glib/goption.c: (g_option_context_parse):
|
||||
|
@ -1,3 +1,12 @@
|
||||
2004-09-01 Anders Carlsson <andersca@gnome.org>
|
||||
|
||||
* glib/goption.c: (g_option_context_free), (print_help),
|
||||
(g_option_context_parse):
|
||||
Handle option contexts without a main group.
|
||||
|
||||
* tests/option-test.c: (empty_test2), (main):
|
||||
Add test case for that.
|
||||
|
||||
2004-08-30 Anders Carlsson <andersca@gnome.org>
|
||||
|
||||
* glib/goption.c: (g_option_context_parse):
|
||||
|
@ -133,6 +133,7 @@ g_option_context_free (GOptionContext *context)
|
||||
g_list_foreach (context->groups, (GFunc)g_option_group_free, NULL);
|
||||
g_list_free (context->groups);
|
||||
|
||||
if (context->main_group)
|
||||
g_option_group_free (context->main_group);
|
||||
|
||||
free_changes_list (context, FALSE);
|
||||
@ -357,6 +358,7 @@ print_help (GOptionContext *context,
|
||||
|
||||
g_print ("%s\n", _("Application Options:"));
|
||||
|
||||
if (context->main_group)
|
||||
for (i = 0; i < context->main_group->n_entries; i++)
|
||||
print_entry (context->main_group, max_length, &context->main_group->entries[i]);
|
||||
|
||||
@ -836,7 +838,7 @@ g_option_context_parse (GOptionContext *context,
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
if (context->main_group->pre_parse_func)
|
||||
if (context->main_group && context->main_group->pre_parse_func)
|
||||
{
|
||||
if (!(* context->main_group->pre_parse_func) (context, context->main_group,
|
||||
context->main_group->user_data, error))
|
||||
@ -900,7 +902,8 @@ g_option_context_parse (GOptionContext *context,
|
||||
}
|
||||
}
|
||||
|
||||
if (!parse_long_option (context, context->main_group, &i, arg,
|
||||
if (context->main_group &&
|
||||
!parse_long_option (context, context->main_group, &i, arg,
|
||||
argc, argv, error, &parsed))
|
||||
goto fail;
|
||||
|
||||
@ -942,7 +945,8 @@ g_option_context_parse (GOptionContext *context,
|
||||
{
|
||||
parsed = FALSE;
|
||||
|
||||
if (!parse_short_option (context, context->main_group,
|
||||
if (context->main_group &&
|
||||
!parse_short_option (context, context->main_group,
|
||||
i, &new_i, arg[j],
|
||||
argc, argv, error, &parsed))
|
||||
{
|
||||
@ -1034,7 +1038,7 @@ g_option_context_parse (GOptionContext *context,
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
if (context->main_group->post_parse_func)
|
||||
if (context->main_group && context->main_group->post_parse_func)
|
||||
{
|
||||
if (!(* context->main_group->post_parse_func) (context, context->main_group,
|
||||
context->main_group->user_data, error))
|
||||
@ -1080,7 +1084,7 @@ g_option_context_parse (GOptionContext *context,
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
if (context->main_group->error_func)
|
||||
if (context->main_group && context->main_group->error_func)
|
||||
(* context->main_group->error_func) (context, context->main_group,
|
||||
context->main_group->user_data, error);
|
||||
|
||||
|
@ -428,6 +428,17 @@ empty_test1 (void)
|
||||
g_option_context_free (context);
|
||||
}
|
||||
|
||||
void
|
||||
empty_test2 (void)
|
||||
{
|
||||
GOptionContext *context;
|
||||
|
||||
context = g_option_context_new (NULL);
|
||||
g_option_context_parse (context, NULL, NULL, NULL);
|
||||
|
||||
g_option_context_free (context);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
@ -454,6 +465,7 @@ main (int argc, char **argv)
|
||||
|
||||
/* Test parsing empty args */
|
||||
empty_test1 ();
|
||||
empty_test2 ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user