diff options
author | Andy Wingo <wingo@pobox.com> | 2009-06-20 14:26:54 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2009-06-20 14:26:54 +0200 |
commit | 179fe3363241ea1aeb48f1f63d13d2dd12196dcf (patch) | |
tree | 938015430875117c7c90c76ecd0bf570bfa8ee80 /libguile/load.c | |
parent | 89cb70a0d5f365ebdfcc0257d6cab4a80a9f6a74 (diff) | |
download | guile-179fe3363241ea1aeb48f1f63d13d2dd12196dcf.tar.gz |
put autocompiled files into ~/.cache or $XDG_CACHE_HOME
* module/system/base/compile.scm (compiled-file-name): Remove unneeded
path separator.
* libguile/load.c (scm_init_load_path): Change so the default cache path
is ~/.cache/guile/ccache/1.9, and respect $XDG_CACHE_HOME.
Diffstat (limited to 'libguile/load.c')
-rw-r--r-- | libguile/load.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/libguile/load.c b/libguile/load.c index d8139e657..890b0f824 100644 --- a/libguile/load.c +++ b/libguile/load.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995,1996,1998,1999,2000,2001, 2004, 2006 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1998,1999,2000,2001, 2004, 2006, 2009 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -247,24 +247,28 @@ scm_init_load_path () #endif /* SCM_LIBRARY_DIR */ { - char *home; + char cachedir[1024]; + char *e; +#ifdef HAVE_GETPWENT + struct passwd *pwd; +#endif - home = getenv ("HOME"); +#define FALLBACK_DIR "guile/ccache/"SCM_EFFECTIVE_VERSION + + if ((e = getenv ("XDG_CACHE_HOME"))) + snprintf (cachedir, sizeof(cachedir), "%s" FALLBACK_DIR, e); + else if ((e = getenv ("HOME"))) + snprintf (cachedir, sizeof(cachedir), "%s/.cache/" FALLBACK_DIR, e); #ifdef HAVE_GETPWENT - if (!home) - { - struct passwd *pwd; - pwd = getpwuid (getuid ()); - if (pwd) - home = pwd->pw_dir; - } + else if ((pwd = getpwuid (getuid ())) && pwd->pw_dir) + snprintf (cachedir, sizeof(cachedir), "%s/.cache/" FALLBACK_DIR, + pwd->pw_dir); #endif /* HAVE_GETPWENT */ - if (home) - { char buf[1024]; - snprintf (buf, sizeof(buf), - "%s/.guile-ccache/" SCM_EFFECTIVE_VERSION, home); - *scm_loc_compile_fallback_path = scm_from_locale_string (buf); - } + else + cachedir[0] = 0; + + if (cachedir[0]) + *scm_loc_compile_fallback_path = scm_from_locale_string (cachedir); } env = getenv ("GUILE_LOAD_PATH"); |