[gjs] console: Fix ARGV when using -c to specify program



commit a5406f32f3c49507307f2cad88fc6f101304a43a
Author: Florian MÃllner <fmuellner gnome org>
Date:   Fri Nov 18 07:44:11 2011 +0100

    console: Fix ARGV when using -c to specify program
    
    Parameters parsed by GOptionContext are removed from argv, so we
    only need to adjust the array ourselves when a filename is specified
    (which is parsed manually).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=664475

 gjs/console.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
---
diff --git a/gjs/console.c b/gjs/console.c
index 4ff9a6a..369e072 100644
--- a/gjs/console.c
+++ b/gjs/console.c
@@ -85,6 +85,8 @@ main(int argc, char **argv)
         }
         source_js_version = gjs_context_scan_buffer_for_js_version(script, 1024);
         filename = argv[1];
+        argc--;
+        argv++;
     }
 
     /* If user explicitly specifies a version, use it */
@@ -98,7 +100,7 @@ main(int argc, char **argv)
 
     /* prepare command line arguments */
     if (!gjs_context_define_string_array(js_context, "ARGV",
-                                         argc - 2, (const char**)argv + 2,
+                                         argc - 1, (const char**)argv + 1,
                                          &error)) {
         g_printerr("Failed to defined ARGV: %s", error->message);
         exit(1);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]