Index: goption.c
===================================================================
RCS file: /cvs/gnome/glib/glib/goption.c,v
retrieving revision 1.40
diff -u -r1.40 goption.c
--- goption.c	9 Jun 2005 15:39:29 -0000	1.40
+++ goption.c	17 Jun 2005 05:35:09 -0000
@@ -849,15 +849,16 @@
       {
 	gchar *tmp;
 	gboolean retval;
-	
-	tmp = g_locale_to_utf8 (value, -1, NULL, NULL, error);
-
-	if (!value)
-	  return FALSE;
-
+	if (value) 
+	  {	
+	    tmp = g_locale_to_utf8 (value, -1, NULL, NULL, error);
+	  }
 	retval = (* (GOptionArgFunc) entry->arg_data) (option_name, tmp, group->user_data, error);
 	
-	g_free (tmp);
+	if (value) 
+	  {	
+	    g_free (tmp);
+	  }	
 	
 	return retval;
 	
@@ -909,9 +910,40 @@
 	      
 	      if (index < *argc - 1)
 		{
-		  value = (*argv)[index + 1];
-		  add_pending_null (context, &((*argv)[index + 1]), NULL);
-		  *new_index = index + 1;
+		  if (group->entries[j].arg != G_OPTION_ARG_CALLBACK)	
+		    {    
+		      value = (*argv)[index + 1];
+		      add_pending_null (context, &((*argv)[index + 1]), NULL);
+		      *new_index = index+1;
+		    }
+		  else
+		    {
+                      if (strncmp ((*argv)[index + 1],"-",1) == 0) 
+		        {
+		          gboolean retval;
+		          retval = parse_arg (context, group, &group->entries[j],
+		              NULL, NULL, error);
+	  	          *parsed = TRUE;
+		          g_free (option_name);
+	   	          return retval;
+		        }
+		      else
+		        {
+		          value = (*argv)[index + 1];
+		          add_pending_null (context, &((*argv)[index + 1]), NULL);
+		          *new_index = index + 1;
+			}
+	            }
+		}
+	      else if (index >= *argc - 1 &&
+		       group->entries[j].arg == G_OPTION_ARG_CALLBACK)
+		{
+		    gboolean retval;
+		    retval = parse_arg (context, group, &group->entries[j],
+		          NULL, NULL, error);
+	  	    *parsed = TRUE;
+		    g_free (option_name);
+	   	    return retval;
 		}
 	      else
 		{
@@ -978,11 +1010,42 @@
 
 	      if (arg[len] == '=')
 		value = arg + len + 1;
-	      else if (*index < *argc - 1)
+	      else if (*index < *argc - 1) 
 		{
-		  value = (*argv)[*index + 1];
-		  add_pending_null (context, &((*argv)[*index + 1]), NULL);
-		  (*index)++;
+		  if (group->entries[j].arg != G_OPTION_ARG_CALLBACK)	
+		    {    
+		      value = (*argv)[*index + 1];
+		      add_pending_null (context, &((*argv)[*index + 1]), NULL);
+		      (*index)++;
+		    }
+		  else
+		    {
+                      if (strncmp ((*argv)[*index + 1],"-",1) == 0) 
+		        {
+		          gboolean retval;
+		          retval = parse_arg (context, group, &group->entries[j],
+		              NULL, NULL, error);
+	  	          *parsed = TRUE;
+		          g_free (option_name);
+	   	          return retval;
+		        }
+		      else
+		        {
+		          value = (*argv)[*index + 1];
+		          add_pending_null (context, &((*argv)[*index + 1]), NULL);
+		          (*index)++;
+			}
+	            }
+		}
+	      else if (*index >= *argc - 1 &&
+		       group->entries[j].arg == G_OPTION_ARG_CALLBACK)
+		{
+		    gboolean retval;
+		    retval = parse_arg (context, group, &group->entries[j],
+		          NULL, NULL, error);
+	  	    *parsed = TRUE;
+		    g_free (option_name);
+	   	    return retval;
 		}
 	      else
 		{
@@ -1001,7 +1064,7 @@
 
 	      g_free (option_name);
 	      *parsed = TRUE;
-	    }
+	    } 
 	}
     }
   
