[project @ 2003-06-02 16:24:07 by sof]
authorsof <unknown>
Mon, 2 Jun 2003 16:24:07 +0000 (16:24 +0000)
committersof <unknown>
Mon, 2 Jun 2003 16:24:07 +0000 (16:24 +0000)
Surround copied argv entries in double quotes to avoid quoting issues
(but don't quote me on that.)

Merge to STABLE.

ghc/driver/ghci/ghci.c

index d04af16..8c6926c 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *
- * $Id: ghci.c,v 1.5 2002/01/07 16:32:54 sof Exp $
+ * $Id: ghci.c,v 1.6 2003/06/02 16:24:07 sof Exp $
  *
  * ghci wrapper - invokes ghc.exe with the added command-line
  *                option "--interactive".
@@ -95,12 +95,17 @@ main(int argc, char** argv)
   }
 
   for ( i=1; i < argc; i++ ) {
-    new_argv[i+1] = (char*)malloc(sizeof(char) * (strlen(argv[i]) + 1));
+    int len = strlen(argv[i]);
+    /* to avoid quoting issues, surround each option in double quotes */
+    new_argv[i+1] = (char*)malloc(sizeof(char) * (len + 3));
     if (new_argv[i+1] == NULL) {
       errmsg("failed to start up ghc.exe");
       return 1;
     } else {
-      strcpy(new_argv[i+1], argv[i]);
+      new_argv[i+1][0] = '"';
+      strcpy(1 + new_argv[i+1], argv[i]);
+      new_argv[i+1][len+1] = '"';
+      new_argv[i+1][len+2] = '\0';
     }
   }
   new_argv[i+1] = NULL;