diff --git a/doc/chibi-scheme.1 b/doc/chibi-scheme.1 index 5347c16d..b5181296 100644 --- a/doc/chibi-scheme.1 +++ b/doc/chibi-scheme.1 @@ -172,10 +172,6 @@ searchs for modules in directories in the following order: .TP directories included with the -I path option -.TP - . -.TP - ./lib .TP directories included from CHIBI_MODULE_PATH .TP @@ -183,6 +179,9 @@ searchs for modules in directories in the following order: .TP directories included with -A path option +If CHIBI_MODULE_PATH is unset, the directoriese "./lib", and "." are +search in order. + .SH AUTHORS .PP Alex Shinn (alexshinn @ gmail . com) diff --git a/eval.c b/eval.c index 137de6b9..b3fd1a28 100644 --- a/eval.c +++ b/eval.c @@ -1,5 +1,5 @@ /* eval.c -- evaluator library implementation */ -/* Copyright (c) 2009-2012 Alex Shinn. All rights reserved. */ +/* Copyright (c) 2009-2013 Alex Shinn. All rights reserved. */ /* BSD-style license: http://synthcode.com/license.txt */ #include "chibi/eval.h" @@ -450,6 +450,7 @@ static void sexp_init_eval_context_bytecodes (sexp ctx) { #endif void sexp_init_eval_context_globals (sexp ctx) { + const char* user_path; sexp_gc_var1(tmp); ctx = sexp_make_child_context(ctx, NULL); sexp_gc_preserve1(ctx, tmp); @@ -458,13 +459,9 @@ void sexp_init_eval_context_globals (sexp ctx) { #endif sexp_global(ctx, SEXP_G_MODULE_PATH) = SEXP_NULL; sexp_add_path(ctx, sexp_default_module_path); - sexp_add_path(ctx, getenv(SEXP_MODULE_PATH_VAR)); - tmp = sexp_c_string(ctx, "./lib", 5); - sexp_push(ctx, sexp_global(ctx, SEXP_G_MODULE_PATH), tmp); - sexp_immutablep(sexp_global(ctx, SEXP_G_MODULE_PATH)) = 1; - tmp = sexp_c_string(ctx, ".", 1); - sexp_push(ctx, sexp_global(ctx, SEXP_G_MODULE_PATH), tmp); - sexp_immutablep(sexp_global(ctx, SEXP_G_MODULE_PATH)) = 1; + user_path = getenv(SEXP_MODULE_PATH_VAR); + if (!user_path) user_path = sexp_default_user_module_path; + sexp_add_path(ctx, user_path); #if SEXP_USE_GREEN_THREADS sexp_global(ctx, SEXP_G_IO_BLOCK_ERROR) = sexp_user_exception(ctx, SEXP_FALSE, "I/O would block", SEXP_NULL); diff --git a/include/chibi/features.h b/include/chibi/features.h index ce48dcdf..35730dca 100644 --- a/include/chibi/features.h +++ b/include/chibi/features.h @@ -304,6 +304,10 @@ #define SEXP_USE_MODULES ! SEXP_USE_NO_FEATURES #endif +#ifndef sexp_default_user_module_path +#define sexp_default_user_module_path "./lib:." +#endif + #ifndef SEXP_USE_TYPE_DEFS #define SEXP_USE_TYPE_DEFS ! SEXP_USE_NO_FEATURES #endif