Skip to content

Commit

Permalink
kernel: move all refs to SyLoadSystemInitFile to gap.c
Browse files Browse the repository at this point in the history
Ideally it would be eliminated but for now GAP.jl requires it.
  • Loading branch information
fingolfin committed Jan 7, 2025
1 parent d577ec1 commit 452ac35
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 31 deletions.
51 changes: 37 additions & 14 deletions src/gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ static Obj Error;
static UInt SystemErrorCode;


/****************************************************************************
**
*V SyLoadSystemInitFile . . . . . . should GAP load 'lib/init.g' at startup
**
** TODO: this variable could be made static or even deleted. However for
** now the GAP.jl Julia package is accessing it, so we have to keep it.
** See also issue #5890 for the reasons behind this.
*/
Int SyLoadSystemInitFile = 1;


/****************************************************************************
**
*V Last . . . . . . . . . . . . . . . . . . . . . . global variable 'last'
Expand Down Expand Up @@ -1527,21 +1538,33 @@ void InitializeGap (
// make command line available to GAP level
InitKernelArgs(argc, argv);

// read the init files
// this now actually runs the GAP session, we only get
// past here when we're about to exit.
if ( SyLoadSystemInitFile ) {
GAP_TRY {
if ( READ_GAP_ROOT("lib/init.g") == 0 ) {
Pr( "gap: hmm, I cannot find 'lib/init.g' maybe"
" use option '-l <gaproot>'?\n", 0, 0);
// should GAP load 'lib/init.g' on initialization?
if (SyCompilePlease) {
SyLoadSystemInitFile = 0;
}
#ifdef GAP_ENABLE_SAVELOAD
else if (SyRestoring) {
SyLoadSystemInitFile = 0;

Check warning on line 1547 in src/gap.c

View check run for this annotation

Codecov / codecov/patch

src/gap.c#L1547

Added line #L1547 was not covered by tests
}
#endif

if (SyLoadSystemInitFile) {
// read the init files
// depending on the command line this now actually runs the GAP
// session, we only get past here when we're about to exit.
GAP_TRY
{
if (READ_GAP_ROOT("lib/init.g") == 0) {
Pr("gap: hmm, I cannot find 'lib/init.g' maybe"

Check warning on line 1558 in src/gap.c

View check run for this annotation

Codecov / codecov/patch

src/gap.c#L1558

Added line #L1558 was not covered by tests
" use option '-l <gaproot>'?\n",
0, 0);
SystemErrorCode = 1;
}
}
GAP_CATCH {
Panic("Caught error at top-most level, probably quit from "
"library loading");
}
}
GAP_CATCH

Check warning on line 1564 in src/gap.c

View check run for this annotation

Codecov / codecov/patch

src/gap.c#L1564

Added line #L1564 was not covered by tests
{
Panic("Caught error at top-most level, probably quit from "

Check warning on line 1566 in src/gap.c

View check run for this annotation

Codecov / codecov/patch

src/gap.c#L1566

Added line #L1566 was not covered by tests
"library loading");
}
}

}
4 changes: 4 additions & 0 deletions src/sysopt.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ extern UInt SyInitializing;
/****************************************************************************
**
*V SyLoadSystemInitFile . . . . . . should GAP load 'lib/init.g' at startup
**
** TODO: this variable could be made static or even deleted. However for
** now the GAP.jl Julia package is accessing it, so we have to keep it.
** See also issue #5890 for the reasons behind this.
*/
extern Int SyLoadSystemInitFile;

Expand Down
17 changes: 0 additions & 17 deletions src/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,6 @@ Char * SyRestoring;
UInt SyInitializing;


/****************************************************************************
**
*V SyLoadSystemInitFile . . . . . . should GAP load 'lib/init.g' at startup
*/
Int SyLoadSystemInitFile = 1;


/****************************************************************************
**
*V SyUseModule . . . . . . . . . check for static modules in 'READ_GAP_ROOT'
Expand Down Expand Up @@ -663,16 +656,6 @@ void InitSystem (
syWinPut( 0, "@p", "1." );
}

// should GAP load 'init/lib.g' on initialization
if ( SyCompilePlease ) {
SyLoadSystemInitFile = 0;
}
#ifdef GAP_ENABLE_SAVELOAD
else if ( SyRestoring ) {
SyLoadSystemInitFile = 0;
}
#endif

// the users home directory
if ( getenv("HOME") != 0 ) {
strxcpy(DotGapPath, getenv("HOME"), sizeof(DotGapPath));
Expand Down

0 comments on commit 452ac35

Please sign in to comment.