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 fbc9501d71c3d44f9994894103acdec5d97fd44f..43d1b59206c9c548a5cb67f04fa3065ccb8e4833 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 fbc9501d71c3d44f9994894103acdec5d97fd44f..43d1b59206c9c548a5cb67f04fa3065ccb8e4833 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 fbc9501d71c3d44f9994894103acdec5d97fd44f..43d1b59206c9c548a5cb67f04fa3065ccb8e4833 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 fbc9501d71c3d44f9994894103acdec5d97fd44f..43d1b59206c9c548a5cb67f04fa3065ccb8e4833 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 a8528de366014db10c5d6fb8e0066ca84b46a395..234c1c93888ac95909de8d112b348f7b2d27380d 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 9642b0fecdc6cf1748909f71fc47125b88915858..1383b27071353e2ddeb36a7cbd49ec3eb3bb1b41 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;
 }