OSDN Git Service

cocoa: do not create a spurious window for -version
authorTristan Gingold <gingold@adacore.com>
Tue, 15 Mar 2011 13:18:22 +0000 (14:18 +0100)
committerAndreas Färber <andreas.faerber@web.de>
Tue, 14 Jun 2011 01:08:56 +0000 (03:08 +0200)
When invoked with -version, qemu will exit just after displaying the version,
so there is no need to create a window.
Also handles --XXX options.

Signed-off-by: Tristan Gingold <gingold@adacore.com>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
ui/cocoa.m

index 20f91bc..1ff1ac6 100644 (file)
@@ -865,10 +865,19 @@ int main (int argc, const char * argv[]) {
 
     /* In case we don't need to display a window, let's not do that */
     for (i = 1; i < argc; i++) {
-        if (!strcmp(argv[i], "-vnc") ||
-            !strcmp(argv[i], "-nographic") ||
-            !strcmp(argv[i], "-curses")) {
+        const char *opt = argv[i];
+
+        if (opt[0] == '-') {
+            /* Treat --foo the same as -foo.  */
+            if (opt[1] == '-') {
+                opt++;
+            }
+            if (!strcmp(opt, "-vnc") ||
+                !strcmp(opt, "-nographic") ||
+                !strcmp(opt, "-version") ||
+                !strcmp(opt, "-curses")) {
                 return qemu_main(gArgc, gArgv);
+            }
         }
     }