diff --git a/src/gap.c b/src/gap.c index 0e336db901..82ffda1f97 100644 --- a/src/gap.c +++ b/src/gap.c @@ -1052,13 +1052,13 @@ static Obj FuncSHOULD_QUIT_ON_BREAK(Obj self) ** The general idea is to put all kernel-specific info in here, and clean up ** the assortment of global variables previously used */ +static Obj KernelArgs; static Obj FuncKERNEL_INFO(Obj self) { Obj res = NEW_PREC(0); UInt r; Obj tmp; - UInt i; AssPRec(res, RNamName("GAP_ARCHITECTURE"), MakeImmString(GAPARCH)); AssPRec(res, RNamName("KERNEL_VERSION"), MakeImmString(SyKernelVersion)); @@ -1073,15 +1073,11 @@ static Obj FuncKERNEL_INFO(Obj self) AssPRec(res, RNamName("uname"), SyGetOsRelease()); // make command line available to GAP level - tmp = NEW_PLIST_IMM(T_PLIST, 16); - for (i = 0; SyOriginalArgv[i]; i++) { - PushPlist(tmp, MakeImmString(SyOriginalArgv[i])); - } - AssPRec(res, RNamName("COMMAND_LINE"), tmp); + AssPRec(res, RNamName("COMMAND_LINE"), KernelArgs); // make environment available to GAP level tmp = NEW_PREC(0); - for (i = 0; environ[i]; i++) { + for (int i = 0; environ[i]; i++) { Char * p = strchr(environ[i], '='); if (!p) { // should never happen... @@ -1317,6 +1313,7 @@ static Int InitKernel ( { // register global bags with the garbage collector InitGlobalBag( &WindowCmdString, "src/gap.c:WindowCmdString" ); + InitGlobalBag( &KernelArgs, "src/gap.c:KernelArgs" ); // init filters and functions InitHdlrFuncsFromTable( GVarFuncs ); @@ -1458,6 +1455,12 @@ void InitializeGap ( // call kernel initialisation ModulesInitKernel(); + // make command line available to GAP level + KernelArgs = NEW_PLIST_IMM(T_PLIST, *pargc); + for (int i = 0; i < *pargc; i++) { + PushPlist(KernelArgs, MakeImmString(argv[i])); + } + #ifdef HPCGAP InitMainThread(); #endif diff --git a/src/sysopt.h b/src/sysopt.h index 448234599d..cb04f7a598 100644 --- a/src/sysopt.h +++ b/src/sysopt.h @@ -157,8 +157,6 @@ extern Char * SyRestoring; extern UInt SyInitializing; -extern Char ** SyOriginalArgv; -extern UInt SyOriginalArgc; /**************************************************************************** ** diff --git a/src/system.c b/src/system.c index 6a6ae0475a..8b027161b0 100644 --- a/src/system.c +++ b/src/system.c @@ -541,11 +541,6 @@ static const struct optInfo options[] = { { 0, "", 0, 0, 0}}; -Char ** SyOriginalArgv; -UInt SyOriginalArgc; - - - void InitSystem ( Int argc, Char * argv [], @@ -609,10 +604,6 @@ void InitSystem ( SyInstallAnswerIntr(); } - // save the original command line for export to GAP - SyOriginalArgc = argc; - SyOriginalArgv = argv; - // scan the command line for options that we have to process in the kernel // we just scan the whole command line looking for the keys for the options we recognise // anything else will presumably be dealt with in the library