+
+/* -----------------------------------------------------------------------------
+ Getting/Setting the program's arguments.
+
+ These are used by System.Environment, and parts of the RTS.
+ -------------------------------------------------------------------------- */
+
+void
+setProgName(char *argv[])
+{
+ char *last_slash;
+
+ /* Remove directory from argv[0] -- default files in current directory */
+ if ((last_slash = (char *) strrchr(argv[0],
+#if !defined(mingw32_HOST_OS)
+ '/'
+#else
+ '\\'
+#endif
+ )) != NULL) {
+ prog_name = last_slash+1;
+ } else {
+ prog_name = argv[0];
+ }
+}
+
+void
+getProgArgv(int *argc, char **argv[])
+{
+ if (argc) { *argc = prog_argc; }
+ if (argv) { *argv = prog_argv; }
+}
+
+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;
+ setProgName(prog_argv);
+}