From e176f212a78317855288e770bdfcd207f11ee46f Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 19 Dec 2004 05:20:12 +0000 Subject: [PATCH] Call post-parse hooks also if argv is NULL. (#161668, Marcin Krzyzanowski) 2004-12-19 Matthias Clasen * glib/goption.c (g_option_context_parse): Call post-parse hooks also if argv is NULL. (#161668, Marcin Krzyzanowski) --- ChangeLog | 6 ++++++ ChangeLog.pre-2-10 | 6 ++++++ ChangeLog.pre-2-12 | 6 ++++++ ChangeLog.pre-2-6 | 6 ++++++ ChangeLog.pre-2-8 | 6 ++++++ glib/goption.c | 43 +++++++++++++++++++++++-------------------- 6 files changed, 53 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 41a9f78..f070027 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-12-19 Matthias Clasen + + * glib/goption.c (g_option_context_parse): Call + post-parse hooks also if argv is NULL. (#161668, + Marcin Krzyzanowski) + 2004-12-16 Matthias Clasen * configure.in: Bump version diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 41a9f78..f070027 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +2004-12-19 Matthias Clasen + + * glib/goption.c (g_option_context_parse): Call + post-parse hooks also if argv is NULL. (#161668, + Marcin Krzyzanowski) + 2004-12-16 Matthias Clasen * configure.in: Bump version diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 41a9f78..f070027 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,9 @@ +2004-12-19 Matthias Clasen + + * glib/goption.c (g_option_context_parse): Call + post-parse hooks also if argv is NULL. (#161668, + Marcin Krzyzanowski) + 2004-12-16 Matthias Clasen * configure.in: Bump version diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 41a9f78..f070027 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,9 @@ +2004-12-19 Matthias Clasen + + * glib/goption.c (g_option_context_parse): Call + post-parse hooks also if argv is NULL. (#161668, + Marcin Krzyzanowski) + 2004-12-16 Matthias Clasen * configure.in: Bump version diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 41a9f78..f070027 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +2004-12-19 Matthias Clasen + + * glib/goption.c (g_option_context_parse): Call + post-parse hooks also if argv is NULL. (#161668, + Marcin Krzyzanowski) + 2004-12-16 Matthias Clasen * configure.in: Bump version diff --git a/glib/goption.c b/glib/goption.c index 11e8671..373852c 100644 --- a/glib/goption.c +++ b/glib/goption.c @@ -1324,30 +1324,33 @@ g_option_context_parse (GOptionContext *context, } } + } - /* Call post-parse hooks */ - list = context->groups; - while (list) - { - GOptionGroup *group = list->data; - - if (group->post_parse_func) - { - if (!(* group->post_parse_func) (context, group, - group->user_data, error)) - goto fail; - } - - list = list->next; - } - - if (context->main_group && context->main_group->post_parse_func) + /* Call post-parse hooks */ + list = context->groups; + while (list) + { + GOptionGroup *group = list->data; + + if (group->post_parse_func) { - if (!(* context->main_group->post_parse_func) (context, context->main_group, - context->main_group->user_data, error)) + if (!(* group->post_parse_func) (context, group, + group->user_data, error)) goto fail; } - + + list = list->next; + } + + 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)) + goto fail; + } + + if (argc && argv) + { free_pending_nulls (context, TRUE); for (i = 1; i < *argc; i++) -- 2.7.4