[glib] Fix another faulty GApplicationCommandline example
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Fix another faulty GApplicationCommandline example
- Date: Fri, 8 Apr 2011 21:03:01 +0000 (UTC)
commit 1a0424b7ff4550ae90ff730bb98d40bface512f3
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Apr 8 17:02:01 2011 -0400
Fix another faulty GApplicationCommandline example
Several flaws were pointed out by Shaun McCance. We were
leaking handled arguments, and we were mishandling the last
argument, and we were actually skipping arguments too.
https://bugzilla.gnome.org/show_bug.cgi?id=647031
gio/tests/gapplication-example-cmdline2.c | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/gio/tests/gapplication-example-cmdline2.c b/gio/tests/gapplication-example-cmdline2.c
index 4351224..ed8ddcd 100644
--- a/gio/tests/gapplication-example-cmdline2.c
+++ b/gio/tests/gapplication-example-cmdline2.c
@@ -30,16 +30,20 @@ test_local_cmdline (GApplication *application,
argv = *arguments;
- for (i = 0; argv[i]; i++)
+ i = 1;
+ while (argv[i])
{
if (g_str_has_prefix (argv[i], "--local-"))
{
g_print ("handling argument %s locally\n", argv[i]);
- for (j = i + 1; argv[j]; j++)
- {
- argv[j - 1] = argv[j];
- argv[j] = NULL;
- }
+ g_free (argv[i]);
+ for (j = i; argv[j]; j++)
+ argv[j] = argv[j + 1];
+ }
+ else
+ {
+ g_print ("not handling argument %s locally\n", argv[i]);
+ i++;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]