mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-13 14:05:05 +01:00
Add a testcase.
2005-05-06 Matthias Clasen <mclasen@redhat.com> * tests/option-test.c: Add a testcase. * glib/goption.c (g_option_context_parse): Treat '-' on its own as a non-option argument. (#168008, Tim Musson, Thomas Leonard and others)
This commit is contained in:
parent
2ae1a46b4c
commit
6e60dd8489
@ -1,3 +1,11 @@
|
|||||||
|
2005-05-06 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* tests/option-test.c: Add a testcase.
|
||||||
|
|
||||||
|
* glib/goption.c (g_option_context_parse): Treat '-'
|
||||||
|
on its own as a non-option argument. (#168008, Tim Musson,
|
||||||
|
Thomas Leonard and others)
|
||||||
|
|
||||||
2005-05-05 Owen Taylor <otaylor@redhat.com>
|
2005-05-05 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gdataset.[ch] glib/gdatasetprivate.h: Add
|
* glib/gdataset.[ch] glib/gdatasetprivate.h: Add
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
2005-05-06 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* tests/option-test.c: Add a testcase.
|
||||||
|
|
||||||
|
* glib/goption.c (g_option_context_parse): Treat '-'
|
||||||
|
on its own as a non-option argument. (#168008, Tim Musson,
|
||||||
|
Thomas Leonard and others)
|
||||||
|
|
||||||
2005-05-05 Owen Taylor <otaylor@redhat.com>
|
2005-05-05 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gdataset.[ch] glib/gdatasetprivate.h: Add
|
* glib/gdataset.[ch] glib/gdatasetprivate.h: Add
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
2005-05-06 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* tests/option-test.c: Add a testcase.
|
||||||
|
|
||||||
|
* glib/goption.c (g_option_context_parse): Treat '-'
|
||||||
|
on its own as a non-option argument. (#168008, Tim Musson,
|
||||||
|
Thomas Leonard and others)
|
||||||
|
|
||||||
2005-05-05 Owen Taylor <otaylor@redhat.com>
|
2005-05-05 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gdataset.[ch] glib/gdatasetprivate.h: Add
|
* glib/gdataset.[ch] glib/gdatasetprivate.h: Add
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
2005-05-06 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* tests/option-test.c: Add a testcase.
|
||||||
|
|
||||||
|
* glib/goption.c (g_option_context_parse): Treat '-'
|
||||||
|
on its own as a non-option argument. (#168008, Tim Musson,
|
||||||
|
Thomas Leonard and others)
|
||||||
|
|
||||||
2005-05-05 Owen Taylor <otaylor@redhat.com>
|
2005-05-05 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gdataset.[ch] glib/gdatasetprivate.h: Add
|
* glib/gdataset.[ch] glib/gdatasetprivate.h: Add
|
||||||
|
@ -1168,7 +1168,7 @@ g_option_context_parse (GOptionContext *context,
|
|||||||
gchar *arg, *dash;
|
gchar *arg, *dash;
|
||||||
gboolean parsed = FALSE;
|
gboolean parsed = FALSE;
|
||||||
|
|
||||||
if ((*argv)[i][0] == '-' && !stop_parsing)
|
if ((*argv)[i][0] == '-' && (*argv)[i][1] != '\0' && !stop_parsing)
|
||||||
{
|
{
|
||||||
if ((*argv)[i][1] == '-')
|
if ((*argv)[i][1] == '-')
|
||||||
{
|
{
|
||||||
|
@ -859,6 +859,30 @@ unknown_short_test (void)
|
|||||||
g_option_context_free (context);
|
g_option_context_free (context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* test that lone dashes are treated as non-options */
|
||||||
|
void lonely_dash_test (void)
|
||||||
|
{
|
||||||
|
GOptionContext *context;
|
||||||
|
gboolean retval;
|
||||||
|
GError *error = NULL;
|
||||||
|
gchar **argv;
|
||||||
|
int argc;
|
||||||
|
|
||||||
|
context = g_option_context_new (NULL);
|
||||||
|
|
||||||
|
/* Now try parsing */
|
||||||
|
argv = split_string ("program -", &argc);
|
||||||
|
|
||||||
|
retval = g_option_context_parse (context, &argc, &argv, &error);
|
||||||
|
|
||||||
|
g_assert (retval);
|
||||||
|
|
||||||
|
g_assert (argv[1] && strcmp (argv[1], "-") == 0);
|
||||||
|
|
||||||
|
g_strfreev (argv);
|
||||||
|
g_option_context_free (context);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
@ -904,5 +928,8 @@ main (int argc, char **argv)
|
|||||||
/* test for bug 166609 */
|
/* test for bug 166609 */
|
||||||
unknown_short_test ();
|
unknown_short_test ();
|
||||||
|
|
||||||
|
/* test for bug 168008 */
|
||||||
|
lonely_dash_test ();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user