Skip to content

Commit c5a9c8c

Browse files
committed
Make all root paths absolute
1 parent 52d1aee commit c5a9c8c

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

Diff for: lib/package.gi

+1
Original file line numberDiff line numberDiff line change
@@ -1864,6 +1864,7 @@ InstallGlobalFunction( SetPackagePath, function( pkgname, pkgpath )
18641864
InstallGlobalFunction( ExtendRootDirectories, function( rootpaths )
18651865
local i;
18661866

1867+
rootpaths:= List( rootpaths, GAP_realpath );
18671868
rootpaths:= Filtered( rootpaths, path -> not path in GAPInfo.RootPaths );
18681869
if not IsEmpty( rootpaths ) then
18691870
# 'DirectoriesLibrary' concatenates root paths with directory names.

Diff for: src/sysroots.c

+13-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "sysstr.h"
1919
#include "system.h"
2020

21+
#include <limits.h>
2122
#include <stdlib.h>
2223

2324

@@ -197,14 +198,25 @@ void SySetGapRootPath(const Char * string)
197198
return;
198199
const UInt userhomelen = strlen(userhome);
199200
for (i = 0; i < MAX_GAP_DIRS && SyGapRootPaths[i][0]; i++) {
200-
const UInt pathlen = strlen(SyGapRootPaths[i]);
201+
UInt pathlen = strlen(SyGapRootPaths[i]);
201202
if (SyGapRootPaths[i][0] == '~' &&
202203
userhomelen + pathlen < sizeof(SyGapRootPaths[i])) {
203204
SyMemmove(SyGapRootPaths[i] + userhomelen,
204205
// don't copy the ~ but the trailing '\0'
205206
SyGapRootPaths[i] + 1, pathlen);
206207
memcpy(SyGapRootPaths[i], userhome, userhomelen);
207208
}
209+
210+
// convert all paths to absolute paths
211+
Char tempstr[GAP_PATH_MAX];
212+
213+
realpath(SyGapRootPaths[i], tempstr);
214+
strxcpy(SyGapRootPaths[i], tempstr, sizeof(SyGapRootPaths[i]));
215+
pathlen = strlen(SyGapRootPaths[i]);
216+
if (SyGapRootPaths[i][pathlen - 1] != '/') {
217+
SyGapRootPaths[i][pathlen] = '/';
218+
SyGapRootPaths[i][pathlen + 1] = '\0';
219+
}
208220
}
209221
}
210222

Diff for: src/sysroots.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void SySetGapRootPath(const Char * string);
3838
**
3939
** <buf> must point to a buffer of at least <size> characters. This function
4040
** then searches for a readable file with the name <filename> in the system
41-
** area. If sich a file is found then its absolute path is copied into
41+
** area. If such a file is found then its absolute path is copied into
4242
** <buf>, and <buf> is returned. If no file is found or if <buf> is not big
4343
** enough, then <buf> is set to an empty string and NULL is returned.
4444
*/

0 commit comments

Comments
 (0)