Commit 262df042 authored by sof's avatar sof
Browse files

[project @ 2001-08-01 21:55:04 by sof]

Support LFNs
parent 0d84f3fa
/* /*
* *
* $Id: ghci.c,v 1.1 2001/07/30 10:40:36 rrt Exp $ * $Id: ghci.c,v 1.2 2001/08/01 21:55:04 sof Exp $
* *
* ghci wrapper - invokes ghc.exe with the added command-line * ghci wrapper - invokes ghc.exe with the added command-line
* option "--interactive". * option "--interactive".
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <stdio.h> #include <stdio.h>
#include <process.h> #include <process.h>
#include <malloc.h> #include <malloc.h>
#include <stdlib.h>
#define BINARY_NAME "ghc.exe" #define BINARY_NAME "ghc.exe"
#define IACTIVE_OPTION "--interactive" #define IACTIVE_OPTION "--interactive"
...@@ -49,19 +50,20 @@ int ...@@ -49,19 +50,20 @@ int
main(int argc, char** argv) main(int argc, char** argv)
{ {
TCHAR binPath[FILENAME_MAX+1]; TCHAR binPath[FILENAME_MAX+1];
TCHAR binPathShort[MAX_PATH+1];
DWORD dwSize = FILENAME_MAX; DWORD dwSize = FILENAME_MAX;
DWORD dwRes; DWORD dwRes;
TCHAR* szEnd; TCHAR* szEnd;
char** new_argv; char** new_argv;
int i; int i;
/* Locate the binary we want to start up */ /* Locate the binary we want to start up */
dwRes = dwRes =
SearchPath(NULL, SearchPath(NULL,
BINARY_NAME, BINARY_NAME,
NULL, NULL,
dwSize, dwSize,
binPath, (char*)binPath,
&szEnd); &szEnd);
if (dwRes == 0) { if (dwRes == 0) {
...@@ -69,12 +71,20 @@ main(int argc, char** argv) ...@@ -69,12 +71,20 @@ main(int argc, char** argv)
return 1; return 1;
} }
dwSize = MAX_PATH;
/* Turn the path into short form - LFN form causes problems
when passed in argv[0]. */
if ( !(GetShortPathName(binPath, binPathShort, dwSize)) ) {
errmsg("Unable to locate ghc.exe");
return 1;
}
new_argv = (char**)malloc(sizeof(char) * (argc + 1 + 1)); new_argv = (char**)malloc(sizeof(char) * (argc + 1 + 1));
if (new_argv == NULL) { if (new_argv == NULL) {
errmsg("failed to start up ghc.exe"); errmsg("failed to start up ghc.exe");
return 1; return 1;
} }
new_argv[0] = binPath; new_argv[0] = binPathShort;
new_argv[1] = (char*)malloc(sizeof(char) * (strlen(IACTIVE_OPTION) + 1)); new_argv[1] = (char*)malloc(sizeof(char) * (strlen(IACTIVE_OPTION) + 1));
if (new_argv[1]) { if (new_argv[1]) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment