summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
7d446f0)
Make getArgs and getProgName behave identically in combined and standalone
modes.
/* ----------------------------------------------------------------------------
/* ----------------------------------------------------------------------------
- * $Id: RtsAPI.h,v 1.11 2000/03/31 03:09:35 hwloidl Exp $
+ * $Id: RtsAPI.h,v 1.12 2000/04/10 14:28:14 sewardj Exp $
*
* (c) The GHC Team, 1998-1999
*
*
* (c) The GHC Team, 1998-1999
*
/* ----------------------------------------------------------------------------
Starting up and shutting down the Haskell RTS.
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------------
Starting up and shutting down the Haskell RTS.
------------------------------------------------------------------------- */
-extern void startupHaskell ( int argc, char *argv[], void *init_root );
-extern void shutdownHaskell ( void );
+extern void startupHaskell ( int argc, char *argv[], void *init_root );
+extern void shutdownHaskell ( void );
extern void shutdownHaskellAndExit ( int exitCode );
extern void shutdownHaskellAndExit ( int exitCode );
+extern void setProgArgv ( int argc, char *argv[] );
+extern void getProgArgv ( int *argc, char **argv[] );
/* ----------------------------------------------------------------------------
Building Haskell objects from C datatypes.
/* ----------------------------------------------------------------------------
Building Haskell objects from C datatypes.
* included in the distribution.
*
* $RCSfile: hugs.c,v $
* included in the distribution.
*
* $RCSfile: hugs.c,v $
- * $Revision: 1.64 $
- * $Date: 2000/04/10 09:40:03 $
+ * $Revision: 1.65 $
+ * $Date: 2000/04/10 14:28:14 $
* ------------------------------------------------------------------------*/
#include <setjmp.h>
* ------------------------------------------------------------------------*/
#include <setjmp.h>
* Initialization, interpret command line args and read prelude:
* ------------------------------------------------------------------------*/
* Initialization, interpret command line args and read prelude:
* ------------------------------------------------------------------------*/
-static List /*CONID*/ initialize(argc,argv) /* Interpreter initialization */
-Int argc;
-String argv[]; {
- Int i;
- char argv_0_orig[1000];
+static List /*CONID*/ initialize ( Int argc, String argv[] )
+{
+ Int i, j;
List initialModules;
setLastEdit((String)0,0);
List initialModules;
setLastEdit((String)0,0);
readOptions("-p\"%s> \" -r$$");
readOptions(fromEnv("STGHUGSFLAGS",""));
readOptions("-p\"%s> \" -r$$");
readOptions(fromEnv("STGHUGSFLAGS",""));
- strncpy(argv_0_orig,argv[0],1000); /* startupHaskell mangles argv[0] */
- startupHaskell (argc,argv,NULL);
- argc = prog_argc;
- argv = prog_argv;
-
# if DEBUG
{
char exe_name[N_INSTALLDIR + 6];
# if DEBUG
{
char exe_name[N_INSTALLDIR + 6];
+ /* startupHaskell extracts args between +RTS ... -RTS, and sets
+ prog_argc/prog_argv to the rest. We want to further process
+ the rest, so we then get hold of them again.
+ */
+ startupHaskell ( argc, argv, NULL );
+ getProgArgv ( &argc, &argv );
+
/* Find out early on if we're in combined mode or not.
everybody(PREPREL) needs to know this. Also, establish the
heap size;
*/
/* Find out early on if we're in combined mode or not.
everybody(PREPREL) needs to know this. Also, establish the
heap size;
*/
- for (i=1; i < argc; ++i) {
+ for (i = 1; i < argc; ++i) {
if (strcmp(argv[i], "--")==0) break;
if (strcmp(argv[i], "-c")==0) combined = FALSE;
if (strcmp(argv[i], "+c")==0) combined = TRUE;
if (strcmp(argv[i], "--")==0) break;
if (strcmp(argv[i], "-c")==0) combined = FALSE;
if (strcmp(argv[i], "+c")==0) combined = TRUE;
- if (strncmp(argv[i],"+h",2)==0 ||
- strncmp(argv[i],"-h",2)==0)
+ if (strncmp(argv[i],"+h",2)==0 || strncmp(argv[i],"-h",2)==0)
setHeapSize(&(argv[i][2]));
}
everybody(PREPREL);
initialModules = NIL;
setHeapSize(&(argv[i][2]));
}
everybody(PREPREL);
initialModules = NIL;
- for (i=1; i < argc; ++i) { /* process command line arguments */
- if (strcmp(argv[i], "--")==0) break;
- if (argv[i] && argv[i][0]/* workaround for /bin/sh silliness*/
- && !processOption(argv[i])) {
- initialModules
- = cons ( mkCon(findText(argv[i])), initialModules );
+ for (i = 1; i < argc; ++i) { /* process command line arguments */
+ if (strcmp(argv[i], "--")==0)
+ { argv[i] = NULL; break; }
+ if (argv[i] && argv[i][0]/* workaround for /bin/sh silliness*/) {
+ if (!processOption(argv[i]))
+ initialModules
+ = cons ( mkCon(findText(argv[i])), initialModules );
+ argv[i] = NULL;
" combined mode\n\n" );
}
" combined mode\n\n" );
}
+ /* slide args back over the deleted ones. */
+ j = 1;
+ for (i = 1; i < argc; i++)
+ if (argv[i])
+ argv[j++] = argv[i];
+
+ argc = j;
+
+ setProgArgv ( argc, argv );
+
initDone = TRUE;
return initialModules;
}
initDone = TRUE;
return initialModules;
}
getArgs :: IO [String]
getArgs = primGetRawArgs >>= \rawargs ->
getArgs :: IO [String]
getArgs = primGetRawArgs >>= \rawargs ->
- return (drop 1 (dropWhile (/= "--") rawargs))
getProgName :: IO String
getProgName = primGetRawArgs >>= \rawargs ->
getProgName :: IO String
getProgName = primGetRawArgs >>= \rawargs ->
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
- * $Id: RtsStartup.c,v 1.39 2000/04/03 16:28:08 simonmar Exp $
+ * $Id: RtsStartup.c,v 1.40 2000/04/10 14:28:14 sewardj Exp $
*
* (c) The GHC Team, 1998-2000
*
*
* (c) The GHC Team, 1998-2000
*
static void initModules ( void * );
void
static void initModules ( void * );
void
+setProgArgv(int argc, char *argv[])
+{
+ /* Usually this is done by startupHaskell, so we don't need to call this.
+ However, sometimes Hugs wants to change the arguments which Haskell
+ getArgs >>= ... will be fed. So you can do that by calling here
+ _after_ calling startupHaskell.
+ */
+ prog_argc = argc;
+ prog_argv = argv;
+}
+
+void
+getProgArgv(int *argc, char **argv[])
+{
+ *argc = prog_argc;
+ *argv = prog_argv;
+}
+
+
+void
startupHaskell(int argc, char *argv[], void *init_root)
{
/* To avoid repeated initialisations of the RTS */
startupHaskell(int argc, char *argv[], void *init_root)
{
/* To avoid repeated initialisations of the RTS */