Add a testcase.
authorMatthias Clasen <mclasen@redhat.com>
Fri, 6 May 2005 20:10:52 +0000 (20:10 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Fri, 6 May 2005 20:10:52 +0000 (20:10 +0000)
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)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-8
glib/goption.c
tests/option-test.c

index fbc9501..43d1b59 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
        * glib/gdataset.[ch] glib/gdatasetprivate.h: Add 
index fbc9501..43d1b59 100644 (file)
@@ -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>
 
        * glib/gdataset.[ch] glib/gdatasetprivate.h: Add 
index fbc9501..43d1b59 100644 (file)
@@ -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>
 
        * glib/gdataset.[ch] glib/gdatasetprivate.h: Add 
index fbc9501..43d1b59 100644 (file)
@@ -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>
 
        * glib/gdataset.[ch] glib/gdatasetprivate.h: Add 
index a8528de..234c1c9 100644 (file)
@@ -1168,7 +1168,7 @@ g_option_context_parse (GOptionContext   *context,
          gchar *arg, *dash;
          gboolean parsed = FALSE;
 
-         if ((*argv)[i][0] == '-' && !stop_parsing)
+         if ((*argv)[i][0] == '-' && (*argv)[i][1] != '\0' && !stop_parsing)
            {
              if ((*argv)[i][1] == '-')
                {
index 9642b0f..1383b27 100644 (file)
@@ -859,6 +859,30 @@ unknown_short_test (void)
   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
 main (int argc, char **argv)
 {
@@ -904,5 +928,8 @@ main (int argc, char **argv)
   /* test for bug 166609 */
   unknown_short_test ();
 
+  /* test for bug 168008 */
+  lonely_dash_test ();
+
   return 0;
 }