2019-07-03 16:16:11 +02:00
|
|
|
diff --git a/src/Intrinsic.c b/src/Intrinsic.c
|
|
|
|
index c9624ec..addcdba 100644
|
|
|
|
--- a/src/Intrinsic.c
|
|
|
|
+++ b/src/Intrinsic.c
|
|
|
|
@@ -1312,21 +1312,101 @@ static void FillInLangSubs(
|
2016-12-02 17:25:34 +01:00
|
|
|
} else (void) strcpy(*rest, string);
|
|
|
|
}
|
|
|
|
|
2019-07-03 16:16:11 +02:00
|
|
|
+
|
|
|
|
+
|
|
|
|
/*
|
2016-12-02 17:25:34 +01:00
|
|
|
- * default path used if environment variable XFILESEARCHPATH
|
|
|
|
- * is not defined. Also substitued for %D.
|
|
|
|
- * The exact value should be documented in the implementation
|
|
|
|
- * notes for any Xt implementation.
|
|
|
|
+ Return the default search path for the function
|
2019-07-03 16:16:11 +02:00
|
|
|
+ XtResolvePathname to use if XFILESEARCHPATH is
|
2016-12-02 17:25:34 +01:00
|
|
|
+ not defined.
|
|
|
|
+
|
|
|
|
+ It returns the combination the set of values which are the 6 "stems" below,
|
2019-07-03 16:16:11 +02:00
|
|
|
+ prepended with "/run/current-system/profile", and $GUIX_PROFILE and
|
2016-12-02 17:25:34 +01:00
|
|
|
+ "$HOME/.guix-profile"
|
|
|
|
+
|
2019-07-03 16:16:11 +02:00
|
|
|
+ These values provide the default paths where Guix/GuixSD can expect
|
2016-12-02 17:25:34 +01:00
|
|
|
+ to find resources for installed packages.
|
|
|
|
*/
|
|
|
|
-static const char *implementation_default_path(void)
|
|
|
|
+static const char *guix_default_path(void)
|
|
|
|
{
|
|
|
|
-#if defined(WIN32)
|
|
|
|
- static char xfilesearchpath[] = "";
|
|
|
|
+ static const char *search_path_default_stem[] = {
|
|
|
|
+ "/lib/X11/%L/%T/%N%C%S",
|
|
|
|
+ "/lib/X11/%l/%T/%N%C%S",
|
|
|
|
+ "/lib/X11/%T/%N%C%S",
|
|
|
|
+ "/lib/X11/%L/%T/%N%S",
|
|
|
|
+ "/lib/X11/%l/%T/%N%S",
|
|
|
|
+ "/lib/X11/%T/%N%S"
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+#define SIZEOF_STEMS (strlen (search_path_default_stem[0]) \
|
|
|
|
+ + strlen (search_path_default_stem[1]) \
|
|
|
|
+ + strlen (search_path_default_stem[2]) \
|
|
|
|
+ + strlen (search_path_default_stem[3]) \
|
|
|
|
+ + strlen (search_path_default_stem[4]) \
|
|
|
|
+ + strlen (search_path_default_stem[5]))
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ int i;
|
|
|
|
+ const char *current_profile = "/run/current-system/profile";
|
|
|
|
+ char *home = getenv ("HOME");
|
|
|
|
+ char *guix_profile = getenv ("GUIX_PROFILE");
|
|
|
|
+
|
2019-07-03 16:16:11 +02:00
|
|
|
+ size_t bytesAllocd = SIZEOF_STEMS + 1;
|
2016-12-02 17:25:34 +01:00
|
|
|
+
|
|
|
|
+ /* This function is evaluated multiple times and the calling
|
|
|
|
+ code assumes that it is idempotent. So we must not allow
|
|
|
|
+ (say) a changed environment variable to cause it to return
|
|
|
|
+ something different. */
|
|
|
|
+ static char *path = NULL;
|
|
|
|
+ if (path)
|
|
|
|
+ return path;
|
|
|
|
+
|
|
|
|
+ bytesAllocd += 6 * (1 + strlen (current_profile));
|
|
|
|
+
|
|
|
|
+ if (guix_profile != NULL)
|
|
|
|
+ {
|
|
|
|
+ bytesAllocd += SIZEOF_STEMS;
|
|
|
|
+ bytesAllocd += 6 * (1 + strlen (guix_profile));
|
|
|
|
+ }
|
2019-07-03 16:16:11 +02:00
|
|
|
|
|
|
|
- return xfilesearchpath;
|
|
|
|
-#else
|
|
|
|
- return XFILESEARCHPATHDEFAULT;
|
|
|
|
-#endif
|
2016-12-02 17:25:34 +01:00
|
|
|
+ if (home != NULL)
|
|
|
|
+ {
|
|
|
|
+ bytesAllocd += SIZEOF_STEMS;
|
|
|
|
+ bytesAllocd += 6 * (1 + strlen(home) + strlen ("/.guix-profile"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ path = XtMalloc(bytesAllocd);
|
|
|
|
+ if (path == NULL) _XtAllocError(NULL);
|
|
|
|
+
|
|
|
|
+ memset (path, 0, bytesAllocd);
|
2019-07-03 16:16:11 +02:00
|
|
|
+
|
2016-12-02 17:25:34 +01:00
|
|
|
+ for (i = 0 ; i < 6 ; ++i)
|
|
|
|
+ {
|
|
|
|
+ strcat (path, current_profile);
|
|
|
|
+ strcat (path, search_path_default_stem[i]);
|
|
|
|
+ strcat (path, ":");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (guix_profile != NULL)
|
|
|
|
+ for (i = 0 ; i < 6 ; ++i)
|
|
|
|
+ {
|
|
|
|
+ strcat (path, guix_profile);
|
|
|
|
+ strcat (path, search_path_default_stem[i]);
|
|
|
|
+ strcat (path, ":");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (home != NULL)
|
|
|
|
+ for (i = 0 ; i < 6 ; ++i)
|
|
|
|
+ {
|
|
|
|
+ strcat (path, home);
|
|
|
|
+ strcat (path, "/.guix-profile");
|
|
|
|
+ strcat (path, search_path_default_stem[i]);
|
|
|
|
+ strcat (path, ":");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* Remove final : */
|
|
|
|
+ path[strlen(path) - 1] = '\0';
|
2019-07-03 16:16:11 +02:00
|
|
|
+
|
2016-12-02 17:25:34 +01:00
|
|
|
+ return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-03 16:16:11 +02:00
|
|
|
@@ -1354,7 +1434,7 @@ _XtString XtResolvePathname(
|
2016-12-02 17:25:34 +01:00
|
|
|
{
|
|
|
|
XtPerDisplay pd;
|
|
|
|
static const char *defaultPath = NULL;
|
|
|
|
- const char *impl_default = implementation_default_path();
|
|
|
|
+ const char *impl_default = guix_default_path();
|
2019-07-03 16:16:11 +02:00
|
|
|
int idef_len = (int) strlen(impl_default);
|
2016-12-02 17:25:34 +01:00
|
|
|
char *massagedPath;
|
|
|
|
int bytesAllocd, bytesLeft;
|