[project @ 2003-12-15 16:45:23 by simonmar]
[ghc-hetmet.git] / ghc / rts / RtsFlags.c
index 55effe2..1793104 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: RtsFlags.c,v 1.68 2003/04/21 14:45:28 sof Exp $
+ * $Id: RtsFlags.c,v 1.72 2003/11/12 17:49:09 sof Exp $
  *
  * (c) The AQUA Project, Glasgow University, 1994-1997
  * (c) The GHC Team, 1998-1999
@@ -41,8 +41,9 @@ extern struct RTS_FLAGS RtsFlags;
 /*
  * Split argument lists
  */
-int     prog_argc = 0; /* an "int" so as to match normal "argc" */
+int     prog_argc = 0;    /* an "int" so as to match normal "argc" */
 char  **prog_argv = NULL;
+char   *prog_name = NULL; /* 'basename' of prog_argv[0] */
 int     rts_argc = 0;  /* ditto */
 char   *rts_argv[MAX_RTS_ARGS];
 
@@ -331,7 +332,7 @@ usage_text[] = {
 "  -?       Prints this message and exits; the program is not executed",
 "",
 "  -K<size> Sets the maximum stack size (default 1M)  Egs: -K32k   -K512k",
-"  -k<size> Sets the initial thread stack size (default 1k)  Egs: -K4k   -K2m",
+"  -k<size> Sets the initial thread stack size (default 1k)  Egs: -k4k   -k2m",
 "",
 "  -A<size> Sets the minimum allocation area size (default 256k) Egs: -A1m -A10k",
 "  -M<size> Sets the maximum heap size (default unlimited)  Egs: -M256k -M1G",
@@ -456,7 +457,7 @@ usage_text[] = {
 0
 };
 
-static __inline__ rtsBool
+STATIC_INLINE rtsBool
 strequal(const char *a, const char * b)
 {
     return(strcmp(a, b) == 0);
@@ -497,9 +498,17 @@ setupRtsFlags(int *argc, char *argv[], int *rts_argc, char *rts_argv[])
     char *last_slash;
 
     /* Remove directory from argv[0] -- default files in current directory */
-
-    if ((last_slash = (char *) strrchr(argv[0], '/')) != NULL)
-       strcpy(argv[0], last_slash+1);
+    if ((last_slash = (char *) strrchr(argv[0], 
+#if !defined(mingw32_TARGET_OS)
+                                      '/')
+#else
+                                      '\\')
+#endif
+                                      ) != NULL) {
+       prog_name = last_slash+1;
+    } else {
+       prog_name = argv[0];
+    }
 
     total_arg = *argc;
     arg = 1;