From 2161bf254f6bfdfe589f7750c30f129261a48b30 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Sun, 26 Feb 2012 21:20:24 +0100 Subject: [PATCH] goption: try to be helpful in goption args/flag checks When complaining about ill defined GOptionEntries include the name of the option group and entry in the warning. --- glib/goption.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/glib/goption.c b/glib/goption.c index 475589b..c1c520d 100644 --- a/glib/goption.c +++ b/glib/goption.c @@ -2178,14 +2178,16 @@ g_option_group_add_entries (GOptionGroup *group, if (c == '-' || (c != 0 && !g_ascii_isprint (c))) { - g_warning (G_STRLOC ": ignoring invalid short option '%c' (%d)", c, c); - group->entries[i].short_name = 0; + g_warning (G_STRLOC ": ignoring invalid short option '%c' (%d) in entry %s:%s", + c, c, group->name, group->entries[i].long_name); + group->entries[i].short_name = '\0'; } if (group->entries[i].arg != G_OPTION_ARG_NONE && (group->entries[i].flags & G_OPTION_FLAG_REVERSE) != 0) { - g_warning (G_STRLOC ": ignoring reverse flag on option of type %d", group->entries[i].arg); + g_warning (G_STRLOC ": ignoring reverse flag on option of arg-type %d in entry %s:%s", + group->entries[i].arg, group->name, group->entries[i].long_name); group->entries[i].flags &= ~G_OPTION_FLAG_REVERSE; } @@ -2193,7 +2195,8 @@ g_option_group_add_entries (GOptionGroup *group, if (group->entries[i].arg != G_OPTION_ARG_CALLBACK && (group->entries[i].flags & (G_OPTION_FLAG_NO_ARG|G_OPTION_FLAG_OPTIONAL_ARG|G_OPTION_FLAG_FILENAME)) != 0) { - g_warning (G_STRLOC ": ignoring no-arg, optional-arg or filename flags (%d) on option of type %d", group->entries[i].flags, group->entries[i].arg); + g_warning (G_STRLOC ": ignoring no-arg, optional-arg or filename flags (%d) on option of arg-type %d in entry %s:%s", + group->entries[i].flags, group->entries[i].arg, group->name, group->entries[i].long_name); group->entries[i].flags &= ~(G_OPTION_FLAG_NO_ARG|G_OPTION_FLAG_OPTIONAL_ARG|G_OPTION_FLAG_FILENAME); } -- 2.7.4