diff --git a/ChangeLog b/ChangeLog index 15e6ce206..a964df5b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-08-30 Anders Carlsson + + * glib/goption.c: (g_option_context_parse): + Set prgname to if argc and argv are NULL. + + * tests/option-test.c: (empty_test1), (main): + Add test case for that. + Sun Aug 29 23:58:38 2004 Matthias Clasen * glib/ghash.c (g_hash_table_lookup): Point to diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 15e6ce206..a964df5b4 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,11 @@ +2004-08-30 Anders Carlsson + + * glib/goption.c: (g_option_context_parse): + Set prgname to if argc and argv are NULL. + + * tests/option-test.c: (empty_test1), (main): + Add test case for that. + Sun Aug 29 23:58:38 2004 Matthias Clasen * glib/ghash.c (g_hash_table_lookup): Point to diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 15e6ce206..a964df5b4 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,11 @@ +2004-08-30 Anders Carlsson + + * glib/goption.c: (g_option_context_parse): + Set prgname to if argc and argv are NULL. + + * tests/option-test.c: (empty_test1), (main): + Add test case for that. + Sun Aug 29 23:58:38 2004 Matthias Clasen * glib/ghash.c (g_hash_table_lookup): Point to diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 15e6ce206..a964df5b4 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,11 @@ +2004-08-30 Anders Carlsson + + * glib/goption.c: (g_option_context_parse): + Set prgname to if argc and argv are NULL. + + * tests/option-test.c: (empty_test1), (main): + Add test case for that. + Sun Aug 29 23:58:38 2004 Matthias Clasen * glib/ghash.c (g_hash_table_lookup): Point to diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 15e6ce206..a964df5b4 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,11 @@ +2004-08-30 Anders Carlsson + + * glib/goption.c: (g_option_context_parse): + Set prgname to if argc and argv are NULL. + + * tests/option-test.c: (empty_test1), (main): + Add test case for that. + Sun Aug 29 23:58:38 2004 Matthias Clasen * glib/ghash.c (g_hash_table_lookup): Point to diff --git a/glib/goption.c b/glib/goption.c index d0cfe8645..85c08d5f4 100644 --- a/glib/goption.c +++ b/glib/goption.c @@ -1056,8 +1056,11 @@ g_option_context_parse (GOptionContext *context, (*argv)[j-k] = (*argv)[j]; *argc -= k; } - } - + } + } + else + { + g_set_prgname (""); } return TRUE; diff --git a/tests/option-test.c b/tests/option-test.c index 370ad6617..4dff3ddd7 100644 --- a/tests/option-test.c +++ b/tests/option-test.c @@ -410,6 +410,24 @@ add_test1 (void) g_option_context_free (context); } +void +empty_test1 (void) +{ + GOptionContext *context; + GOptionEntry entries [] = + { { NULL } }; + + context = g_option_context_new (NULL); + + g_option_context_add_main_entries (context, entries, NULL); + + g_option_context_parse (context, NULL, NULL, NULL); + + g_assert (strcmp (g_get_prgname (), "") == 0); + + g_option_context_free (context); +} + int main (int argc, char **argv) { @@ -433,6 +451,9 @@ main (int argc, char **argv) ignore_test2 (); add_test1 (); + + /* Test parsing empty args */ + empty_test1 (); return 0; }