aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-07-12 21:00:54 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2011-07-12 21:02:29 +0300
commit85a90a1cd71d35850bec9d820a670c1282ea9277 (patch)
treec5c269341a5047edce7d4e6ab0a692d40e6f948b /src
parent3e010c19412a53b86f251126d427a272224795bd (diff)
downloadidest-85a90a1cd71d35850bec9d820a670c1282ea9277.tar.gz
idest-85a90a1cd71d35850bec9d820a670c1282ea9277.tar.bz2
Improve Guile startup files loading sequence.
* src/guile.c (make_file_name): New file. (try_file): Remove. (load_startup_file): Pass in the command line the list of files which were to be tried after the file being loaded. * doc/idest.texi: Update.
Diffstat (limited to 'src')
-rw-r--r--src/guile.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/guile.c b/src/guile.c
index 3ccb5e6..da820ce 100644
--- a/src/guile.c
+++ b/src/guile.c
@@ -26,14 +26,13 @@ char *guile_script;
char *guile_function;
char **guile_argv;
-SCM_GLOBAL_VARIABLE_INIT (sym_idest_main, "idest-main", SCM_EOL);
+SCM_GLOBAL_VARIABLE_INIT(sym_idest_main, "idest-main", SCM_EOL);
SCM_GLOBAL_VARIABLE_INIT(sym_idest_readonly, "idest-readonly", SCM_BOOL_T);
SCM_GLOBAL_SYMBOL(idest_text, "text");
SCM_GLOBAL_SYMBOL(idest_lang, "lang");
SCM_GLOBAL_SYMBOL(idest_condesc, "condesc");
SCM_GLOBAL_SYMBOL(idest_descr, "descr");
-
static SCM
@@ -422,8 +421,8 @@ load_path_prepend(const char *dir)
*pscm = scm_cons(scm_from_locale_string(dir), path_scm);
}
-static int
-try_file(const char *dir, const char *file_name)
+static char *
+make_file_name(const char *dir, const char *file_name)
{
char *ptr;
size_t len = strlen(dir);
@@ -433,36 +432,37 @@ try_file(const char *dir, const char *file_name)
memcpy(ptr, dir, len);
ptr[len++] = '/';
strcpy(ptr + len, file_name);
-
- if (access(ptr, R_OK) == 0) {
- if (guile_load(ptr, 0, NULL))
- error(1, 0, "cannot load startup script %s", ptr);
- return 0;
- }
- free(ptr);
- return 1;
+ return ptr;
}
static void
load_startup_file()
{
+ int i;
const char init_name[] = ".idest.scm";
- const char *dir;
-
+ char *argv[4];
+
load_path_prepend(GUILE_SITE);
load_path_prepend(PKG_SITE);
load_path_prepend(".");
+
+ argv[0] = xstrdup(init_name);
+ argv[1] = make_file_name(getenv("HOME"), init_name);
+ argv[2] = make_file_name(PKG_SITE, "idest.scm");
+ argv[3] = NULL;
- if (access(init_name, R_OK) == 0) {
- if (guile_load((char*)init_name, 0, NULL) == 0)
- return;
- error(1, 0, "cannot load startup script %s", init_name);
+ for (i = 0; argv[i]; i++) {
+ if (access(argv[i], R_OK) == 0) {
+ if (guile_load(argv[i], 0, argv + i + 1))
+ error(1, 0, "cannot load startup script %s",
+ argv[i]);
+ break;
+ }
+ free(argv[i]);
}
-
- dir = getenv("HOME");
- if (dir && try_file(dir, init_name) == 0)
- return;
- try_file(PKG_SITE, "idest.scm");
+ /* Free the rest of arguments. */
+ for (; argv[i]; i++)
+ free(argv[i]);
}
void

Return to:

Send suggestions and report system problems to the System administrator.