X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=driver%2Fghci%2Fghci.c;h=414521f97d3ed18564fa4ace1a38257dfd833ad3;hb=e5c3b478b3cd1707cf122833822f44b2ac09b8e9;hp=f21a12a4ba44fa224be0b0bcda14865e9a160d61;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/driver/ghci/ghci.c b/driver/ghci/ghci.c index f21a12a..414521f 100644 --- a/driver/ghci/ghci.c +++ b/driver/ghci/ghci.c @@ -1,168 +1,24 @@ -/* - * - * $Id: ghci.c,v 1.10 2005/05/05 00:58:38 sof Exp $ - * - * ghci wrapper for Win32 only - * - * This wrapper invokes ghc.exe with the added command-line - * option "--interactive". - * (On Unix this is done by the ghci.sh shell script, but - * that does not work so well on Win32.) - * - * (c) The GHC Team 2001 - * - * ghc.exe is searched for using the 'normal' search rules - * for DLLs / EXEs (i.e., first in the same dir as this wrapper, - * then system dirs, then PATH). - * - * To compile: - * - * MSVC: cl /o ghci.exe /c ghciwrap.c - * mingw: gcc -mno-cygwin -o ghci.exe ghciwrap.c - * - * If you want to associate your own icon with the wrapper, - * here's how to do it: - * - * * Create a one-line .rc file, ghci.rc (say), containing - * 0 ICON "hsicon.ico" - * (subst the string literal for the name of your icon file). - * * Compile it up (assuming the .ico file is in the same dir - * as the .rc file): - * - * MSVC: rc /i. /fo ghci.res ghci.rc - * mingw: windres -o ghci.res -i ghci.rc -O coff - * - * * Add the resulting .res file to the link line of the wrapper: - * - * MSVC: cl /o ghci.exe /c ghciwrap.c ghci.res - * mingw: gcc -mno-cygwin -o ghci.exe ghciwrap.c ghci.res - * - */ -#include +#include "cwrapper.h" +#include "getLocation.h" #include -#include -#include #include -#include -#include -#define BINARY_NAME "ghc.exe" -#define IACTIVE_OPTION "--interactive" +int main(int argc, char** argv) { + char *binDir; + char *exePath; + char *preArgv[1]; -#define errmsg(msg) fprintf(stderr, msg "\n"); fflush(stderr) -#define errmsg1(msg,val) fprintf(stderr, msg "\n",val); fflush(stderr) + if (getenv("_")) { + printf("WARNING: GHCi invoked via 'ghci.exe' in *nix-like shells (cygwin-bash, in particular)\n"); + printf(" doesn't handle Ctrl-C well; use the 'ghcii.sh' shell wrapper instead\n"); + fflush(stdout); + } -int -main(int argc, char** argv) -{ - TCHAR binPath[FILENAME_MAX+1]; - TCHAR binPathShort[MAX_PATH+1]; - DWORD dwSize = FILENAME_MAX; - TCHAR* szEnd; - int i; - char* new_cmdline; - char *ptr, *src; - unsigned int cmdline_len = 0; - char **pp; - LPTSTR pp1; + binDir = getExecutablePath(); + exePath = mkString("%s/ghc.exe", binDir); + preArgv[0] = "--interactive"; - STARTUPINFO si; - PROCESS_INFORMATION pi; - - ZeroMemory(&pi, sizeof(PROCESS_INFORMATION)); - ZeroMemory(&si, sizeof(STARTUPINFO)); - si.cb = sizeof(STARTUPINFO); - - if ( getenv("_") ) { - printf("WARNING: GHCi invoked via 'ghci.exe' in *nix-like shells (cygwin-bash, in particular)\n"); - printf(" doesn't handle Ctrl-C well; use the 'ghcii.sh' shell wrapper instead\n"); - fflush(stdout); - } - - /* Locate the binary we want to start up */ - if ( !SearchPath(NULL, - BINARY_NAME, - NULL, - dwSize, - (char*)binPath, - &szEnd) ) { - errmsg1("%s: Unable to locate ghc.exe", argv[0]); - 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)) ) { - errmsg1("%s: Unable to locate ghc.exe", argv[0]); - return 1; - } - - /* Compute length of the flattened 'argv', including extra IACTIVE_OPTION (and spaces!) */ - cmdline_len += 1 + strlen(IACTIVE_OPTION); - for(i=1;i