Skip to content

Commit 6a18146

Browse files
authored
kernel: move all refs to SyLoadSystemInitFile to gap.c (#5898)
Ideally it would be eliminated but for now GAP.jl requires it.
1 parent 4c3f859 commit 6a18146

File tree

3 files changed

+41
-31
lines changed

3 files changed

+41
-31
lines changed

src/gap.c

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ static Obj Error;
6868
static UInt SystemErrorCode;
6969

7070

71+
/****************************************************************************
72+
**
73+
*V SyLoadSystemInitFile . . . . . . should GAP load 'lib/init.g' at startup
74+
**
75+
** TODO: this variable could be made static or even deleted. However for
76+
** now the GAP.jl Julia package is accessing it, so we have to keep it.
77+
** See also issue #5890 for the reasons behind this.
78+
*/
79+
Int SyLoadSystemInitFile = 1;
80+
81+
7182
/****************************************************************************
7283
**
7384
*V Last . . . . . . . . . . . . . . . . . . . . . . global variable 'last'
@@ -1527,21 +1538,33 @@ void InitializeGap (
15271538
// make command line available to GAP level
15281539
InitKernelArgs(argc, argv);
15291540

1530-
// read the init files
1531-
// this now actually runs the GAP session, we only get
1532-
// past here when we're about to exit.
1533-
if ( SyLoadSystemInitFile ) {
1534-
GAP_TRY {
1535-
if ( READ_GAP_ROOT("lib/init.g") == 0 ) {
1536-
Pr( "gap: hmm, I cannot find 'lib/init.g' maybe"
1537-
" use option '-l <gaproot>'?\n", 0, 0);
1541+
// should GAP load 'lib/init.g' on initialization?
1542+
if (SyCompilePlease) {
1543+
SyLoadSystemInitFile = 0;
1544+
}
1545+
#ifdef GAP_ENABLE_SAVELOAD
1546+
else if (SyRestoring) {
1547+
SyLoadSystemInitFile = 0;
1548+
}
1549+
#endif
1550+
1551+
if (SyLoadSystemInitFile) {
1552+
// read the init files
1553+
// depending on the command line this now actually runs the GAP
1554+
// session, we only get past here when we're about to exit.
1555+
GAP_TRY
1556+
{
1557+
if (READ_GAP_ROOT("lib/init.g") == 0) {
1558+
Pr("gap: hmm, I cannot find 'lib/init.g' maybe"
1559+
" use option '-l <gaproot>'?\n",
1560+
0, 0);
15381561
SystemErrorCode = 1;
15391562
}
1540-
}
1541-
GAP_CATCH {
1542-
Panic("Caught error at top-most level, probably quit from "
1543-
"library loading");
1544-
}
1563+
}
1564+
GAP_CATCH
1565+
{
1566+
Panic("Caught error at top-most level, probably quit from "
1567+
"library loading");
1568+
}
15451569
}
1546-
15471570
}

src/sysopt.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ extern UInt SyInitializing;
161161
/****************************************************************************
162162
**
163163
*V SyLoadSystemInitFile . . . . . . should GAP load 'lib/init.g' at startup
164+
**
165+
** TODO: this variable could be made static or even deleted. However for
166+
** now the GAP.jl Julia package is accessing it, so we have to keep it.
167+
** See also issue #5890 for the reasons behind this.
164168
*/
165169
extern Int SyLoadSystemInitFile;
166170

src/system.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,6 @@ Char * SyRestoring;
207207
UInt SyInitializing;
208208

209209

210-
/****************************************************************************
211-
**
212-
*V SyLoadSystemInitFile . . . . . . should GAP load 'lib/init.g' at startup
213-
*/
214-
Int SyLoadSystemInitFile = 1;
215-
216-
217210
/****************************************************************************
218211
**
219212
*V SyUseModule . . . . . . . . . check for static modules in 'READ_GAP_ROOT'
@@ -663,16 +656,6 @@ void InitSystem (
663656
syWinPut( 0, "@p", "1." );
664657
}
665658

666-
// should GAP load 'init/lib.g' on initialization
667-
if ( SyCompilePlease ) {
668-
SyLoadSystemInitFile = 0;
669-
}
670-
#ifdef GAP_ENABLE_SAVELOAD
671-
else if ( SyRestoring ) {
672-
SyLoadSystemInitFile = 0;
673-
}
674-
#endif
675-
676659
// the users home directory
677660
if ( getenv("HOME") != 0 ) {
678661
strxcpy(DotGapPath, getenv("HOME"), sizeof(DotGapPath));

0 commit comments

Comments
 (0)