option_name in NO_ARG(goption)



Hi,

Is there any strong reason to pass NULL as option_name to
a callback function of goption when G_OPTION_FLAG_NO_ARG is
set to flag?

Even if arg_data can be passed when registering a callback
function, option_name is useful for the callback function
which handles multiple options.

2005-06-21  Masatake YAMATO  <jet gyve org>

	* glib/goption.c (parse_short_option): Passing
	option_name even if NO_ARG it TRUE.
	(parse_long_option): Ditto.

Index: glib/goption.c
===================================================================
RCS file: /cvs/gnome/glib/glib/goption.c,v
retrieving revision 1.41
diff -u -r1.41 goption.c
--- glib/goption.c	18 Jun 2005 04:55:25 -0000	1.41
+++ glib/goption.c	21 Jun 2005 08:34:47 -0000
@@ -904,8 +904,13 @@
 	{
 	  if (NO_ARG (&group->entries[j]))
 	    {
+	      gchar *option_name;
+
+	      option_name = g_strdup_printf ("-%c", group->entries[j].short_name);
 	      parse_arg (context, group, &group->entries[j],
-			 NULL, NULL, error);
+			 NULL, option_name, error);
+	      g_free (option_name);
+	      
 	      *parsed = TRUE;
 	    }
 	  else
@@ -972,8 +977,12 @@
       if (NO_ARG (&group->entries[j]) &&
 	  strcmp (arg, group->entries[j].long_name) == 0)
 	{
+	  gchar *option_name;
+
+	  option_name = g_strconcat ("--", group->entries[j].long_name, NULL);
 	  parse_arg (context, group, &group->entries[j],
-		     NULL, NULL, error);
+		     NULL, option_name, error);
+	  g_free(option_name);
 	  
 	  add_pending_null (context, &((*argv)[*index]), NULL);
 	  *parsed = TRUE;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]