diff options
| author | sof <unknown> | 2003-06-02 16:24:07 +0000 |
|---|---|---|
| committer | sof <unknown> | 2003-06-02 16:24:07 +0000 |
| commit | 475ef37cd19bc8234205ca02d1251d47e267bd1f (patch) | |
| tree | 1e5c5fbaea3be83fc4c960e9ec854c102fc1e4ea | |
| parent | 6d7921bb43458ebb30b9c6d94ad05a9e089b8997 (diff) | |
| download | haskell-475ef37cd19bc8234205ca02d1251d47e267bd1f.tar.gz | |
[project @ 2003-06-02 16:24:07 by sof]
Surround copied argv entries in double quotes to avoid quoting issues
(but don't quote me on that.)
Merge to STABLE.
| -rw-r--r-- | ghc/driver/ghci/ghci.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/ghc/driver/ghci/ghci.c b/ghc/driver/ghci/ghci.c index d04af169f0..8c6926cd7d 100644 --- a/ghc/driver/ghci/ghci.c +++ b/ghc/driver/ghci/ghci.c @@ -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; |
