+2004-10-03 Anders Carlsson <andersca@gnome.org>
+
+ * glib/goption.c: (parse_arg):
+ Set arg_data on filenames. (Discovered by Mats-Ola Persson).
+
+ * tests/option-test.c: (arg_test3), (ignore_test3), (main):
+ Add test for filename args.
+
2004-10-01 Tor Lillqvist <tml@iki.fi>
* glib/goption.c (g_option_context_parse): Use
+2004-10-03 Anders Carlsson <andersca@gnome.org>
+
+ * glib/goption.c: (parse_arg):
+ Set arg_data on filenames. (Discovered by Mats-Ola Persson).
+
+ * tests/option-test.c: (arg_test3), (ignore_test3), (main):
+ Add test for filename args.
+
2004-10-01 Tor Lillqvist <tml@iki.fi>
* glib/goption.c (g_option_context_parse): Use
+2004-10-03 Anders Carlsson <andersca@gnome.org>
+
+ * glib/goption.c: (parse_arg):
+ Set arg_data on filenames. (Discovered by Mats-Ola Persson).
+
+ * tests/option-test.c: (arg_test3), (ignore_test3), (main):
+ Add test for filename args.
+
2004-10-01 Tor Lillqvist <tml@iki.fi>
* glib/goption.c (g_option_context_parse): Use
+2004-10-03 Anders Carlsson <andersca@gnome.org>
+
+ * glib/goption.c: (parse_arg):
+ Set arg_data on filenames. (Discovered by Mats-Ola Persson).
+
+ * tests/option-test.c: (arg_test3), (ignore_test3), (main):
+ Add test for filename args.
+
2004-10-01 Tor Lillqvist <tml@iki.fi>
* glib/goption.c (g_option_context_parse): Use
+2004-10-03 Anders Carlsson <andersca@gnome.org>
+
+ * glib/goption.c: (parse_arg):
+ Set arg_data on filenames. (Discovered by Mats-Ola Persson).
+
+ * tests/option-test.c: (arg_test3), (ignore_test3), (main):
+ Add test for filename args.
+
2004-10-01 Tor Lillqvist <tml@iki.fi>
* glib/goption.c (g_option_context_parse): Use
change->prev.str = *(gchar **)entry->arg_data;
change->allocated.str = data;
+ *(gchar **)entry->arg_data = data;
break;
}
int arg_test1_int;
gchar *arg_test2_string;
+gchar *arg_test3_filename;
gchar **array_test1_array;
}
void
+arg_test3 (void)
+{
+ GOptionContext *context;
+ gboolean retval;
+ GError *error = NULL;
+ gchar **argv;
+ int argc;
+ GOptionEntry entries [] =
+ { { "test", 0, 0, G_OPTION_ARG_FILENAME, &arg_test3_filename, NULL, NULL },
+ { NULL } };
+
+ context = g_option_context_new (NULL);
+ g_option_context_add_main_entries (context, entries, NULL);
+
+ /* Now try parsing */
+ argv = split_string ("program --test foo.txt", &argc);
+
+ retval = g_option_context_parse (context, &argc, &argv, &error);
+ g_assert (retval);
+
+ /* Last arg specified is the one that should be stored */
+ g_assert (strcmp (arg_test3_filename, "foo.txt") == 0);
+
+ g_free (arg_test3_filename);
+
+ g_strfreev (argv);
+ g_option_context_free (context);
+}
+
+void
ignore_test1 (void)
{
GOptionContext *context;
g_free (arg);
g_strfreev (argv_copy);
g_free (argv);
-
- /* Try again */
- argv = split_string ("program --test=foo --hello", &argc);
- argv_copy = copy_stringv (argv, argc);
-
- retval = g_option_context_parse (context, &argc, &argv, &error);
- g_assert (retval);
-
- /* Check array */
- arg = join_stringv (argc, argv);
- g_assert (strcmp (arg, "program --hello") == 0);
-
- g_assert (strcmp (ignore_test3_string, "foo") == 0);
- g_free (ignore_test3_string);
-
- g_free (arg);
- g_strfreev (argv_copy);
- g_free (argv);
g_option_context_free (context);
}
/* Test that special argument parsing works */
arg_test1 ();
arg_test2 ();
+ arg_test3 ();
/* Test string arrays */
array_test1 ();